| camera.h | | camera.h | |
| /**************************************************************************
** | | /**************************************************************************
** | |
| | | | |
| Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | | Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | |
| | | | |
|
| This file is part of the QGLViewer library version 2.5.0. | | This file is part of the QGLViewer library version 2.5.1. | |
| | | | |
| http://www.libqglviewer.com - contact@libqglviewer.com | | http://www.libqglviewer.com - contact@libqglviewer.com | |
| | | | |
| This file may be used under the terms of the GNU General Public License | | This file may be used under the terms of the GNU General Public License | |
| versions 2.0 or 3.0 as published by the Free Software Foundation and | | versions 2.0 or 3.0 as published by the Free Software Foundation and | |
| appearing in the LICENSE file included in the packaging of this file. | | appearing in the LICENSE file included in the packaging of this file. | |
| In addition, as a special exception, Gilles Debunne gives you certain | | In addition, as a special exception, Gilles Debunne gives you certain | |
| additional rights, described in the file GPL_EXCEPTION in this package. | | additional rights, described in the file GPL_EXCEPTION in this package. | |
| | | | |
| libQGLViewer uses dual licensing. Commercial/proprietary software must | | libQGLViewer uses dual licensing. Commercial/proprietary software must | |
| purchase a libQGLViewer Commercial License. | | purchase a libQGLViewer Commercial License. | |
| | | | |
| This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | | This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
| WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | | WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| | | | |
| ***************************************************************************
**/ | | ***************************************************************************
**/ | |
| | | | |
| #ifndef QGLVIEWER_CAMERA_H | | #ifndef QGLVIEWER_CAMERA_H | |
| #define QGLVIEWER_CAMERA_H | | #define QGLVIEWER_CAMERA_H | |
| | | | |
|
| #include "manipulatedCameraFrame.h" | | | |
| #include "keyFrameInterpolator.h" | | #include "keyFrameInterpolator.h" | |
|
| | | class QGLViewer; | |
| | | | |
| namespace qglviewer { | | namespace qglviewer { | |
|
| | | | |
| | | class ManipulatedCameraFrame; | |
| | | | |
| /*! \brief A perspective or orthographic camera. | | /*! \brief A perspective or orthographic camera. | |
| \class Camera camera.h QGLViewer/camera.h | | \class Camera camera.h QGLViewer/camera.h | |
| | | | |
| A Camera defines some intrinsic parameters (fieldOfView(), position(), vi
ewDirection(), | | A Camera defines some intrinsic parameters (fieldOfView(), position(), vi
ewDirection(), | |
| upVector()...) and useful positioning tools that ease its placement (show
EntireScene(), | | upVector()...) and useful positioning tools that ease its placement (show
EntireScene(), | |
| fitSphere(), lookAt()...). It exports its associated OpenGL projection an
d modelview matrices and | | fitSphere(), lookAt()...). It exports its associated OpenGL projection an
d modelview matrices and | |
| can interactively be modified using the mouse. | | can interactively be modified using the mouse. | |
| | | | |
| <h3>Mouse manipulation</h3> | | <h3>Mouse manipulation</h3> | |
| | | | |
| | | | |
| skipping to change at line 106 | | skipping to change at line 109 | |
| /*! Enumerates the two possible types of Camera. | | /*! Enumerates the two possible types of Camera. | |
| | | | |
| See type() and setType(). This type mainly defines different Camera
projection matrix (see | | See type() and setType(). This type mainly defines different Camera
projection matrix (see | |
| loadProjectionMatrix()). Many other methods (pointUnderPixel(), conv
ertClickToLine(), | | loadProjectionMatrix()). Many other methods (pointUnderPixel(), conv
ertClickToLine(), | |
| projectedCoordinatesOf(), pixelGLRatio()...) take this Type into acc
ount. */ | | projectedCoordinatesOf(), pixelGLRatio()...) take this Type into acc
ount. */ | |
| enum Type { PERSPECTIVE, ORTHOGRAPHIC }; | | enum Type { PERSPECTIVE, ORTHOGRAPHIC }; | |
| | | | |
| /*! @name Position and orientation */ | | /*! @name Position and orientation */ | |
| //@{ | | //@{ | |
| public: | | public: | |
|
| /*! Returns the Camera position (the eye), defined in the world coor | | Vec position() const; | |
| dinate system. | | Vec upVector() const; | |
| | | Vec viewDirection() const; | |
| Use setPosition() to set the Camera position. Other convenient metho | | Vec rightVector() const; | |
| ds are showEntireScene() or | | Quaternion orientation() const; | |
| fitSphere(). Actually returns \c frame()->position(). | | | |
| | | | |
| This position corresponds to the projection center of a Camera::PERS | | | |
| PECTIVE Camera. It is not | | | |
| located in the image plane, which is at a zNear() distance ahead. */ | | | |
| Vec position() const { return frame()->position(); } | | | |
| | | | |
| /*! Returns the normalized up vector of the Camera, defined in the w | | | |
| orld coordinate system. | | | |
| | | | |
| Set using setUpVector() or setOrientation(). It is orthogonal to vie | | | |
| wDirection() and to | | | |
| rightVector(). | | | |
| | | | |
| It corresponds to the Y axis of the associated frame() (actually ret | | | |
| urns | | | |
| frame()->inverseTransformOf(Vec(0.0, 1.0, 0.0)) ). */ | | | |
| Vec upVector() const | | | |
| { | | | |
| return frame()->inverseTransformOf(Vec(0.0, 1.0, 0.0)); | | | |
| } | | | |
| /*! Returns the normalized view direction of the Camera, defined in | | | |
| the world coordinate system. | | | |
| | | | |
| Change this value using setViewDirection(), lookAt() or setOrientati | | | |
| on(). It is orthogonal to | | | |
| upVector() and to rightVector(). | | | |
| | | | |
| This corresponds to the negative Z axis of the frame() ( frame()->in | | | |
| verseTransformOf(Vec(0.0, | | | |
| 0.0, -1.0)) ). */ | | | |
| Vec viewDirection() const { return frame()->inverseTransformOf(Vec(0 | | | |
| .0, 0.0, -1.0)); } | | | |
| | | | |
| /*! Returns the normalized right vector of the Camera, defined in th | | | |
| e world coordinate system. | | | |
| | | | |
| This vector lies in the Camera horizontal plane, directed along the | | | |
| X axis (orthogonal to | | | |
| upVector() and to viewDirection()). Set using setUpVector(), lookAt( | | | |
| ) or setOrientation(). | | | |
| | | | |
| Simply returns frame()->inverseTransformOf(Vec(1.0, 0.0, 0.0)). */ | | | |
| Vec rightVector() const | | | |
| { | | | |
| return frame()->inverseTransformOf(Vec(1.0, 0.0, 0.0)); | | | |
| } | | | |
| | | | |
| /*! Returns the Camera orientation, defined in the world coordinate | | | |
| system. | | | |
| | | | |
| Actually returns \c frame()->orientation(). Use setOrientation(), se | | | |
| tUpVector() or lookAt() to | | | |
| set the Camera orientation. */ | | | |
| Quaternion orientation() const { return frame()->orientation(); } | | | |
| | | | |
| void setFromModelViewMatrix(const GLdouble* const modelViewMatrix); | | void setFromModelViewMatrix(const GLdouble* const modelViewMatrix); | |
| void setFromProjectionMatrix(const float matrix[12]); | | void setFromProjectionMatrix(const float matrix[12]); | |
| | | | |
| public Q_SLOTS: | | public Q_SLOTS: | |
|
| /*! Sets the Camera position() (the eye), defined in the world coord | | void setPosition(const Vec& pos); | |
| inate system. */ | | | |
| void setPosition(const Vec& pos) { frame()->setPosition(pos); } | | | |
| void setOrientation(const Quaternion& q); | | void setOrientation(const Quaternion& q); | |
| void setOrientation(float theta, float phi); | | void setOrientation(float theta, float phi); | |
| void setUpVector(const Vec& up, bool noMove=true); | | void setUpVector(const Vec& up, bool noMove=true); | |
| void setViewDirection(const Vec& direction); | | void setViewDirection(const Vec& direction); | |
| //@} | | //@} | |
| | | | |
| /*! @name Positioning tools */ | | /*! @name Positioning tools */ | |
| //@{ | | //@{ | |
| public Q_SLOTS: | | public Q_SLOTS: | |
| void lookAt(const Vec& target); | | void lookAt(const Vec& target); | |
| | | | |
| skipping to change at line 348 | | skipping to change at line 310 | |
| void setSceneBoundingBox(const Vec& min, const Vec& max); | | void setSceneBoundingBox(const Vec& min, const Vec& max); | |
| //@} | | //@} | |
| | | | |
| /*! @name Revolve Around Point */ | | /*! @name Revolve Around Point */ | |
| //@{ | | //@{ | |
| public Q_SLOTS: | | public Q_SLOTS: | |
| void setRevolveAroundPoint(const Vec& rap); | | void setRevolveAroundPoint(const Vec& rap); | |
| bool setRevolveAroundPointFromPixel(const QPoint& pixel); | | bool setRevolveAroundPointFromPixel(const QPoint& pixel); | |
| | | | |
| public: | | public: | |
|
| /*! The point the Camera revolves around with the QGLViewer::ROTATE | | Vec revolveAroundPoint() const; | |
| mouse binding. Defined in world coordinate system. | | | |
| | | | |
| Default value is the sceneCenter(). | | | |
| | | | |
| \attention setSceneCenter() changes this value. */ | | | |
| Vec revolveAroundPoint() const { return frame()->revolveAroundPoint( | | | |
| ); } | | | |
| //@} | | //@} | |
| | | | |
| /*! @name Associated frame */ | | /*! @name Associated frame */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| /*! Returns the ManipulatedCameraFrame attached to the Camera. | | /*! Returns the ManipulatedCameraFrame attached to the Camera. | |
| | | | |
| This ManipulatedCameraFrame defines its position() and orientation()
and can translate mouse | | This ManipulatedCameraFrame defines its position() and orientation()
and can translate mouse | |
| events into Camera displacement. Set using setFrame(). */ | | events into Camera displacement. Set using setFrame(). */ | |
| ManipulatedCameraFrame* frame() const { return frame_; } | | ManipulatedCameraFrame* frame() const { return frame_; } | |
| | | | |
| skipping to change at line 416 | | skipping to change at line 373 | |
| //@{ | | //@{ | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
| static void drawCamera(float scale=1.0, float aspectRatio=1.33, floa
t fieldOfView=M_PI/4.0); | | static void drawCamera(float scale=1.0, float aspectRatio=1.33, floa
t fieldOfView=M_PI/4.0); | |
| #endif | | #endif | |
| virtual void draw(bool drawFarPlane=true, float scale=1.0) const; | | virtual void draw(bool drawFarPlane=true, float scale=1.0) const; | |
| //@} | | //@} | |
| | | | |
| /*! @name World to Camera coordinate systems conversions */ | | /*! @name World to Camera coordinate systems conversions */ | |
| //@{ | | //@{ | |
| public: | | public: | |
|
| /*! Returns the Camera frame coordinates of a point \p src defined i | | Vec cameraCoordinatesOf(const Vec& src) const; | |
| n world coordinates. | | Vec worldCoordinatesOf(const Vec& src) const; | |
| | | | |
| worldCoordinatesOf() performs the inverse transformation. | | | |
| | | | |
| Note that the point coordinates are simply converted in a different | | | |
| coordinate system. They are | | | |
| not projected on screen. Use projectedCoordinatesOf() for that. */ | | | |
| Vec cameraCoordinatesOf(const Vec& src) const { return frame()->coor | | | |
| dinatesOf(src); } | | | |
| /*! Returns the world coordinates of the point whose position \p src | | | |
| is defined in the Camera | | | |
| coordinate system. | | | |
| | | | |
| cameraCoordinatesOf() performs the inverse transformation. */ | | | |
| Vec worldCoordinatesOf(const Vec& src) const { return frame()->inver | | | |
| seCoordinatesOf(src); } | | | |
| void getCameraCoordinatesOf(const float src[3], float res[3]) const; | | void getCameraCoordinatesOf(const float src[3], float res[3]) const; | |
| void getWorldCoordinatesOf(const float src[3], float res[3]) const; | | void getWorldCoordinatesOf(const float src[3], float res[3]) const; | |
| //@} | | //@} | |
| | | | |
| /*! @name 2D screen to 3D world coordinate systems conversions */ | | /*! @name 2D screen to 3D world coordinate systems conversions */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| Vec projectedCoordinatesOf(const Vec& src, const Frame* frame=NULL)
const; | | Vec projectedCoordinatesOf(const Vec& src, const Frame* frame=NULL)
const; | |
| Vec unprojectedCoordinatesOf(const Vec& src, const Frame* frame=NULL
) const; | | Vec unprojectedCoordinatesOf(const Vec& src, const Frame* frame=NULL
) const; | |
| void getProjectedCoordinatesOf(const float src[3], float res[3], con
st Frame* frame=NULL) const; | | void getProjectedCoordinatesOf(const float src[3], float res[3], con
st Frame* frame=NULL) const; | |
| void getUnprojectedCoordinatesOf(const float src[3], float res[3], c
onst Frame* frame=NULL) const; | | void getUnprojectedCoordinatesOf(const float src[3], float res[3], c
onst Frame* frame=NULL) const; | |
| void convertClickToLine(const QPoint& pixel, Vec& orig, Vec& dir) co
nst; | | void convertClickToLine(const QPoint& pixel, Vec& orig, Vec& dir) co
nst; | |
| Vec pointUnderPixel(const QPoint& pixel, bool& found) const; | | Vec pointUnderPixel(const QPoint& pixel, bool& found) const; | |
| //@} | | //@} | |
| | | | |
| /*! @name Fly speed */ | | /*! @name Fly speed */ | |
| //@{ | | //@{ | |
| public: | | public: | |
|
| /*! Returns the fly speed of the Camera. | | float flySpeed() const; | |
| | | | |
| Simply returns frame()->flySpeed(). See the ManipulatedCameraFrame:: | | | |
| flySpeed() documentation. | | | |
| This value is only meaningful when the MouseAction bindings is QGLVi | | | |
| ewer::MOVE_FORWARD or | | | |
| QGLViewer::MOVE_BACKWARD. | | | |
| | | | |
| Set to 1% of the sceneRadius() by setSceneRadius(). See also setFlyS | | | |
| peed(). */ | | | |
| float flySpeed() const { return frame()->flySpeed(); } | | | |
| public Q_SLOTS: | | public Q_SLOTS: | |
|
| /*! Sets the Camera flySpeed(). | | void setFlySpeed(float speed); | |
| | | | |
| \attention This value is modified by setSceneRadius(). */ | | | |
| void setFlySpeed(float speed) { frame()->setFlySpeed(speed); } | | | |
| //@} | | //@} | |
| | | | |
| /*! @name Stereo parameters */ | | /*! @name Stereo parameters */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| /*! Returns the user's inter-ocular distance (in meters). Default va
lue is 0.062m, which fits most people. | | /*! Returns the user's inter-ocular distance (in meters). Default va
lue is 0.062m, which fits most people. | |
| | | | |
| loadProjectionMatrixStereo() uses this value to define the Camera of
fset and frustum. See | | loadProjectionMatrixStereo() uses this value to define the Camera of
fset and frustum. See | |
| setIODistance(). */ | | setIODistance(). */ | |
| float IODistance() const { return IODistance_; } | | float IODistance() const { return IODistance_; } | |
| | | | |
End of changes. 10 change blocks. |
| 105 lines changed or deleted | | 16 lines changed or added | |
|
| mouseGrabber.h | | mouseGrabber.h | |
| /**************************************************************************
** | | /**************************************************************************
** | |
| | | | |
| Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | | Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | |
| | | | |
|
| This file is part of the QGLViewer library version 2.5.0. | | This file is part of the QGLViewer library version 2.5.1. | |
| | | | |
| http://www.libqglviewer.com - contact@libqglviewer.com | | http://www.libqglviewer.com - contact@libqglviewer.com | |
| | | | |
| This file may be used under the terms of the GNU General Public License | | This file may be used under the terms of the GNU General Public License | |
| versions 2.0 or 3.0 as published by the Free Software Foundation and | | versions 2.0 or 3.0 as published by the Free Software Foundation and | |
| appearing in the LICENSE file included in the packaging of this file. | | appearing in the LICENSE file included in the packaging of this file. | |
| In addition, as a special exception, Gilles Debunne gives you certain | | In addition, as a special exception, Gilles Debunne gives you certain | |
| additional rights, described in the file GPL_EXCEPTION in this package. | | additional rights, described in the file GPL_EXCEPTION in this package. | |
| | | | |
| libQGLViewer uses dual licensing. Commercial/proprietary software must | | libQGLViewer uses dual licensing. Commercial/proprietary software must | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | | This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
| WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | | WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| | | | |
| ***************************************************************************
**/ | | ***************************************************************************
**/ | |
| | | | |
| #ifndef QGLVIEWER_MOUSE_GRABBER_H | | #ifndef QGLVIEWER_MOUSE_GRABBER_H | |
| #define QGLVIEWER_MOUSE_GRABBER_H | | #define QGLVIEWER_MOUSE_GRABBER_H | |
| | | | |
| #include "config.h" | | #include "config.h" | |
| | | | |
|
| #if QT_VERSION >= 0x040000 | | #include <QEvent> | |
| # include <QEvent> | | | |
| #else | | | |
| # include <qevent.h> | | | |
| #endif | | | |
| | | | |
| class QGLViewer; | | class QGLViewer; | |
| | | | |
| namespace qglviewer { | | namespace qglviewer { | |
| class Camera; | | class Camera; | |
| | | | |
| /*! \brief Abstract class for objects that grab mouse focus in a QGLViewer. | | /*! \brief Abstract class for objects that grab mouse focus in a QGLViewer. | |
| \class MouseGrabber mouseGrabber.h QGLViewer/mouseGrabber.h | | \class MouseGrabber mouseGrabber.h QGLViewer/mouseGrabber.h | |
| | | | |
| MouseGrabber are objects which react to the mouse cursor, usually when it
hovers over them. This | | MouseGrabber are objects which react to the mouse cursor, usually when it
hovers over them. This | |
| | | | |
| skipping to change at line 143 | | skipping to change at line 139 | |
| \nosubgrouping */ | | \nosubgrouping */ | |
| class QGLVIEWER_EXPORT MouseGrabber | | class QGLVIEWER_EXPORT MouseGrabber | |
| { | | { | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
| friend class ::QGLViewer; | | friend class ::QGLViewer; | |
| #endif | | #endif | |
| | | | |
| public: | | public: | |
| MouseGrabber(); | | MouseGrabber(); | |
| /*! Virtual destructor. Removes the MouseGrabber from the MouseGrabb
erPool(). */ | | /*! Virtual destructor. Removes the MouseGrabber from the MouseGrabb
erPool(). */ | |
|
| #if QT_VERSION >= 0x040000 | | | |
| virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(
this); } | | virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(
this); } | |
|
| #else | | | |
| virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeRef( | | | |
| this); } | | | |
| #endif | | | |
| | | | |
| /*! @name Mouse grabbing detection */ | | /*! @name Mouse grabbing detection */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| /*! Pure virtual method, called by the QGLViewers before they test i
f the MouseGrabber | | /*! Pure virtual method, called by the QGLViewers before they test i
f the MouseGrabber | |
| grabsMouse(). Should setGrabsMouse() according to the mouse positi
on. | | grabsMouse(). Should setGrabsMouse() according to the mouse positi
on. | |
| | | | |
| This is the core method of the MouseGrabber. It has to be overloaded
in your derived class. | | This is the core method of the MouseGrabber. It has to be overloaded
in your derived class. | |
| Its goal is to update the grabsMouse() flag according to the mouse a
nd MouseGrabber current | | Its goal is to update the grabsMouse() flag according to the mouse a
nd MouseGrabber current | |
| positions, using setGrabsMouse(). | | positions, using setGrabsMouse(). | |
| | | | |
| skipping to change at line 206 | | skipping to change at line 198 | |
| public: | | public: | |
| /*! Returns a list containing pointers to all the active MouseGrabbe
rs. | | /*! Returns a list containing pointers to all the active MouseGrabbe
rs. | |
| | | | |
| Used by the QGLViewer to parse all the MouseGrabbers and to check if
any of them grabsMouse() | | Used by the QGLViewer to parse all the MouseGrabbers and to check if
any of them grabsMouse() | |
| using checkIfGrabsMouse(). | | using checkIfGrabsMouse(). | |
| | | | |
| You should not have to directly use this list. Use removeFromMouseGr
abberPool() and | | You should not have to directly use this list. Use removeFromMouseGr
abberPool() and | |
| addInMouseGrabberPool() to modify this list. | | addInMouseGrabberPool() to modify this list. | |
| | | | |
| \attention This method returns a \c QPtrList<MouseGrabber> with Qt 3
and a \c QList<MouseGrabber> with Qt 2. */ | | \attention This method returns a \c QPtrList<MouseGrabber> with Qt 3
and a \c QList<MouseGrabber> with Qt 2. */ | |
|
| #if QT_VERSION >= 0x040000 | | | |
| static const QList<MouseGrabber*>& MouseGrabberPool() { return Mouse
Grabber::MouseGrabberPool_; } | | static const QList<MouseGrabber*>& MouseGrabberPool() { return Mouse
Grabber::MouseGrabberPool_; } | |
|
| #else | | | |
| # if QT_VERSION >= 0x030000 | | | |
| static const QPtrList<MouseGrabber>& MouseGrabberPool() { return Mou | | | |
| seGrabber::MouseGrabberPool_; } | | | |
| # else | | | |
| static const QList<MouseGrabber>& MouseGrabberPool() { return MouseG | | | |
| rabber::MouseGrabberPool_; } | | | |
| # endif | | | |
| #endif | | | |
| | | | |
| /*! Returns \c true if the MouseGrabber is currently in the MouseGra
bberPool() list. | | /*! Returns \c true if the MouseGrabber is currently in the MouseGra
bberPool() list. | |
| | | | |
| Default value is \c true. When set to \c false using removeFromMouse
GrabberPool(), the | | Default value is \c true. When set to \c false using removeFromMouse
GrabberPool(), the | |
| QGLViewers no longer checkIfGrabsMouse() on this MouseGrabber. Use a
ddInMouseGrabberPool() to | | QGLViewers no longer checkIfGrabsMouse() on this MouseGrabber. Use a
ddInMouseGrabberPool() to | |
| insert it back. */ | | insert it back. */ | |
|
| #if QT_VERSION >= 0x040000 | | | |
| bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabbe
rPool_.contains(const_cast<MouseGrabber*>(this)); } | | bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabbe
rPool_.contains(const_cast<MouseGrabber*>(this)); } | |
|
| #else | | | |
| bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabbe | | | |
| rPool_.findRef(this) != -1; } | | | |
| #endif | | | |
| void addInMouseGrabberPool(); | | void addInMouseGrabberPool(); | |
| void removeFromMouseGrabberPool(); | | void removeFromMouseGrabberPool(); | |
| void clearMouseGrabberPool(bool autoDelete=false); | | void clearMouseGrabberPool(bool autoDelete=false); | |
| //@} | | //@} | |
| | | | |
| /*! @name Mouse event handlers */ | | /*! @name Mouse event handlers */ | |
| //@{ | | //@{ | |
| protected: | | protected: | |
| /*! Callback method called when the MouseGrabber grabsMouse() and a
mouse button is pressed. | | /*! Callback method called when the MouseGrabber grabsMouse() and a
mouse button is pressed. | |
| | | | |
| | | | |
| skipping to change at line 248 | | skipping to change at line 228 | |
| accordingly and mouseReleaseEvent() (called when the mouse button is
released) will terminate | | accordingly and mouseReleaseEvent() (called when the mouse button is
released) will terminate | |
| this action. | | this action. | |
| | | | |
| Use the \p event QMouseEvent::state() and QMouseEvent::button() to t
est the keyboard | | Use the \p event QMouseEvent::state() and QMouseEvent::button() to t
est the keyboard | |
| and button state and possibly change the MouseGrabber behavior accor
dingly. | | and button state and possibly change the MouseGrabber behavior accor
dingly. | |
| | | | |
| See the <a href="#_details">detailed description section</a> and the
<a | | See the <a href="#_details">detailed description section</a> and the
<a | |
| href="../examples/mouseGrabber.html">mouseGrabber example</a> for ex
amples. | | href="../examples/mouseGrabber.html">mouseGrabber example</a> for ex
amples. | |
| | | | |
| See the \c QGLWidget::mousePressEvent() and the \c QMouseEvent docum
entations for details. */ | | See the \c QGLWidget::mousePressEvent() and the \c QMouseEvent docum
entations for details. */ | |
|
| virtual void mousePressEvent(QMouseEvent* const event, Camera* const
camera) { Q_UNUSED(event) Q_UNUSED(camera) } | | virtual void mousePressEvent(QMouseEvent* const event, Camera* const
camera) { Q_UNUSED(event); Q_UNUSED(camera); } | |
| /*! Callback method called when the MouseGrabber grabsMouse() and a
mouse button is double clicked. | | /*! Callback method called when the MouseGrabber grabsMouse() and a
mouse button is double clicked. | |
| | | | |
| See the \c QGLWidget::mouseDoubleClickEvent() and the \c QMouseEvent
documentations for details. */ | | See the \c QGLWidget::mouseDoubleClickEvent() and the \c QMouseEvent
documentations for details. */ | |
|
| virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera*
const camera) { Q_UNUSED(event) Q_UNUSED(camera) } | | virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera*
const camera) { Q_UNUSED(event); Q_UNUSED(camera); } | |
| /*! Mouse release event callback method. See mousePressEvent(). */ | | /*! Mouse release event callback method. See mousePressEvent(). */ | |
|
| virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* con
st camera) { Q_UNUSED(event) Q_UNUSED(camera) } | | virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* con
st camera) { Q_UNUSED(event); Q_UNUSED(camera); } | |
| /*! Callback method called when the MouseGrabber grabsMouse() and th
e mouse is moved while a | | /*! Callback method called when the MouseGrabber grabsMouse() and th
e mouse is moved while a | |
| button is pressed. | | button is pressed. | |
| | | | |
| This method will typically update the state of the MouseGrabber from
the mouse displacement. See | | This method will typically update the state of the MouseGrabber from
the mouse displacement. See | |
| the mousePressEvent() documentation for details. */ | | the mousePressEvent() documentation for details. */ | |
|
| virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const
camera) { Q_UNUSED(event) Q_UNUSED(camera) } | | virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const
camera) { Q_UNUSED(event); Q_UNUSED(camera); } | |
| /*! Callback method called when the MouseGrabber grabsMouse() and th
e mouse wheel is used. | | /*! Callback method called when the MouseGrabber grabsMouse() and th
e mouse wheel is used. | |
| | | | |
| See the \c QGLWidget::wheelEvent() and the \c QWheelEvent documentat
ions for details. */ | | See the \c QGLWidget::wheelEvent() and the \c QWheelEvent documentat
ions for details. */ | |
|
| virtual void wheelEvent(QWheelEvent* const event, Camera* const came
ra) { Q_UNUSED(event) Q_UNUSED(camera) } | | virtual void wheelEvent(QWheelEvent* const event, Camera* const came
ra) { Q_UNUSED(event); Q_UNUSED(camera); } | |
| //@} | | //@} | |
| | | | |
| private: | | private: | |
| // Copy constructor and opertor= are declared private and undefined | | // Copy constructor and opertor= are declared private and undefined | |
| // Prevents everyone from trying to use them | | // Prevents everyone from trying to use them | |
| MouseGrabber(const MouseGrabber&); | | MouseGrabber(const MouseGrabber&); | |
| MouseGrabber& operator=(const MouseGrabber&); | | MouseGrabber& operator=(const MouseGrabber&); | |
| | | | |
| bool grabsMouse_; | | bool grabsMouse_; | |
| | | | |
| // Q G L V i e w e r p o o l | | // Q G L V i e w e r p o o l | |
|
| #if QT_VERSION >= 0x040000 | | | |
| static QList<MouseGrabber*> MouseGrabberPool_; | | static QList<MouseGrabber*> MouseGrabberPool_; | |
|
| #else | | | |
| static QPtrList<MouseGrabber> MouseGrabberPool_; | | | |
| #endif | | | |
| }; | | }; | |
| | | | |
| } // namespace qglviewer | | } // namespace qglviewer | |
| | | | |
| #endif // QGLVIEWER_MOUSE_GRABBER_H | | #endif // QGLVIEWER_MOUSE_GRABBER_H | |
| | | | |
End of changes. 15 change blocks. |
| 35 lines changed or deleted | | 7 lines changed or added | |
|
| qglviewer.h | | qglviewer.h | |
| /**************************************************************************
** | | /**************************************************************************
** | |
| | | | |
| Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | | Copyright (C) 2002-2013 Gilles Debunne. All rights reserved. | |
| | | | |
|
| This file is part of the QGLViewer library version 2.5.0. | | This file is part of the QGLViewer library version 2.5.1. | |
| | | | |
| http://www.libqglviewer.com - contact@libqglviewer.com | | http://www.libqglviewer.com - contact@libqglviewer.com | |
| | | | |
| This file may be used under the terms of the GNU General Public License | | This file may be used under the terms of the GNU General Public License | |
| versions 2.0 or 3.0 as published by the Free Software Foundation and | | versions 2.0 or 3.0 as published by the Free Software Foundation and | |
| appearing in the LICENSE file included in the packaging of this file. | | appearing in the LICENSE file included in the packaging of this file. | |
| In addition, as a special exception, Gilles Debunne gives you certain | | In addition, as a special exception, Gilles Debunne gives you certain | |
| additional rights, described in the file GPL_EXCEPTION in this package. | | additional rights, described in the file GPL_EXCEPTION in this package. | |
| | | | |
| libQGLViewer uses dual licensing. Commercial/proprietary software must | | libQGLViewer uses dual licensing. Commercial/proprietary software must | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | | This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
| WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | | WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
| | | | |
| ***************************************************************************
**/ | | ***************************************************************************
**/ | |
| | | | |
| #ifndef QGLVIEWER_QGLVIEWER_H | | #ifndef QGLVIEWER_QGLVIEWER_H | |
| #define QGLVIEWER_QGLVIEWER_H | | #define QGLVIEWER_QGLVIEWER_H | |
| | | | |
| #include "camera.h" | | #include "camera.h" | |
| | | | |
|
| #if QT_VERSION >= 0x040000 | | #include <QMap> | |
| # include <QMap> | | #include <QClipboard> | |
| # include <QClipboard> | | #include <QTime> | |
| #else | | | |
| # include <qmap.h> | | | |
| # include <qclipboard.h> | | | |
| #endif | | | |
| | | | |
| class QTabWidget; | | class QTabWidget; | |
| | | | |
| namespace qglviewer { | | namespace qglviewer { | |
| class MouseGrabber; | | class MouseGrabber; | |
|
| | | class ManipulatedFrame; | |
| | | class ManipulatedCameraFrame; | |
| } | | } | |
| | | | |
|
| #if QT_VERSION < 0x040000 | | | |
| # define Qt::KeyboardModifiers Qt::ButtonState | | | |
| # define Qt::MouseButtons Qt::ButtonState | | | |
| # define Qt::WindowFlags Qt::WFlags | | | |
| #endif | | | |
| | | | |
| /*! \brief A versatile 3D OpenGL viewer based on QGLWidget. | | /*! \brief A versatile 3D OpenGL viewer based on QGLWidget. | |
| \class QGLViewer qglviewer.h QGLViewer/qglviewer.h | | \class QGLViewer qglviewer.h QGLViewer/qglviewer.h | |
| | | | |
| It features many classical viewer functionalities, such as a camera trackba
ll, manipulated objects, | | It features many classical viewer functionalities, such as a camera trackba
ll, manipulated objects, | |
| snapshot saving and much <a href="../features.html">more</a>. Its main goal
is to ease the development | | snapshot saving and much <a href="../features.html">more</a>. Its main goal
is to ease the development | |
| of new 3D applications. | | of new 3D applications. | |
| | | | |
| New users should read the <a href="../introduction.html">introduction page<
/a> to get familiar with | | New users should read the <a href="../introduction.html">introduction page<
/a> to get familiar with | |
| important notions such as sceneRadius(), sceneCenter() and the world coordi
nate system. Try the | | important notions such as sceneRadius(), sceneCenter() and the world coordi
nate system. Try the | |
| numerous simple <a href="../examples/index.html">examples</a> to discover t
he possibilities and | | numerous simple <a href="../examples/index.html">examples</a> to discover t
he possibilities and | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 69 | |
| complete implementation. | | complete implementation. | |
| | | | |
| \nosubgrouping */ | | \nosubgrouping */ | |
| class QGLVIEWER_EXPORT QGLViewer : public QGLWidget | | class QGLVIEWER_EXPORT QGLViewer : public QGLWidget | |
| { | | { | |
| Q_OBJECT | | Q_OBJECT | |
| | | | |
| public: | | public: | |
| // Complete implementation is provided so that the constructor is de
fined with QT3_SUPPORT when .h is included. | | // Complete implementation is provided so that the constructor is de
fined with QT3_SUPPORT when .h is included. | |
| // (Would not be available otherwise since lib is compiled without Q
T3_SUPPORT). | | // (Would not be available otherwise since lib is compiled without Q
T3_SUPPORT). | |
|
| #if QT_VERSION < 0x040000 || defined QT3_SUPPORT | | #ifdef QT3_SUPPORT | |
| explicit QGLViewer(QWidget* parent=NULL, const char* name=0, const Q
GLWidget* shareWidget=0, Qt::WindowFlags flags=0) | | explicit QGLViewer(QWidget* parent=NULL, const char* name=0, const Q
GLWidget* shareWidget=0, Qt::WindowFlags flags=0) | |
| : QGLWidget(parent, name, shareWidget, flags) | | : QGLWidget(parent, name, shareWidget, flags) | |
| { defaultConstructor(); } | | { defaultConstructor(); } | |
| | | | |
| explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const
char* name=0, const QGLWidget* shareWidget=0,Qt::WindowFlags flags=0) | | explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const
char* name=0, const QGLWidget* shareWidget=0,Qt::WindowFlags flags=0) | |
| : QGLWidget(format, parent, name, shareWidget, flags) | | : QGLWidget(format, parent, name, shareWidget, flags) | |
| { defaultConstructor(); } | | { defaultConstructor(); } | |
| | | | |
| QGLViewer(QGLContext* context, QWidget* parent, const char* name=0,
const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0) | | QGLViewer(QGLContext* context, QWidget* parent, const char* name=0,
const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0) | |
|
| # if QT_VERSION >= 0x030200 | | | |
| : QGLWidget(context, parent, name, shareWidget, flags) { | | : QGLWidget(context, parent, name, shareWidget, flags) { | |
|
| # else | | | |
| // MOC_SKIP_BEGIN | | | |
| : QGLWidget(parent, name, shareWidget, flags) { | | | |
| Q_UNUSED(context); | | | |
| // MOC_SKIP_END | | | |
| # endif | | | |
| defaultConstructor(); } | | defaultConstructor(); } | |
| | | | |
| #else | | #else | |
| | | | |
| explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0
, Qt::WindowFlags flags=0); | | explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0
, Qt::WindowFlags flags=0); | |
| explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGL
Widget* shareWidget=0, Qt::WindowFlags flags=0); | | explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGL
Widget* shareWidget=0, Qt::WindowFlags flags=0); | |
| explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const
QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); | | explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const
QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); | |
| #endif | | #endif | |
| | | | |
| virtual ~QGLViewer(); | | virtual ~QGLViewer(); | |
| | | | |
| skipping to change at line 452 | | skipping to change at line 437 | |
| bool autoBufferSwap() const; | | bool autoBufferSwap() const; | |
| protected Q_SLOTS: | | protected Q_SLOTS: | |
| /*! Sets the autoBufferSwap() value. */ | | /*! Sets the autoBufferSwap() value. */ | |
| void setAutoBufferSwap(bool on); | | void setAutoBufferSwap(bool on); | |
| //@} | | //@} | |
| #endif | | #endif | |
| | | | |
| /*! @name Snapshots */ | | /*! @name Snapshots */ | |
| //@{ | | //@{ | |
| public: | | public: | |
|
| #if QT_VERSION < 0x030000 | | | |
| virtual QImage grabFrameBuffer(bool withAlpha=false); | | | |
| #endif | | | |
| /*! Returns the snapshot file name used by saveSnapshot(). | | /*! Returns the snapshot file name used by saveSnapshot(). | |
| | | | |
| This value is used in \p automatic mode (see saveSnapshot()). A dial
og is otherwise popped-up to | | This value is used in \p automatic mode (see saveSnapshot()). A dial
og is otherwise popped-up to | |
| set it. | | set it. | |
| | | | |
| You can also directly provide a file name using saveSnapshot(const Q
String&, bool). | | You can also directly provide a file name using saveSnapshot(const Q
String&, bool). | |
| | | | |
| If the file name is relative, the current working directory at the m
oment of the method call is | | If the file name is relative, the current working directory at the m
oment of the method call is | |
| used. Set using setSnapshotFileName(). */ | | used. Set using setSnapshotFileName(). */ | |
| const QString& snapshotFileName() const { return snapshotFileName_;
} | | const QString& snapshotFileName() const { return snapshotFileName_;
} | |
| | | | |
| skipping to change at line 567 | | skipping to change at line 549 | |
| \endcode | | \endcode | |
| will guarantee that this text will be properly displayed on arbitrar
y sized snapshots. | | will guarantee that this text will be properly displayed on arbitrar
y sized snapshots. | |
| | | | |
| Note that this method is not needed if you use drawText() which alre
ady calls it internally. */ | | Note that this method is not needed if you use drawText() which alre
ady calls it internally. */ | |
| QFont scaledFont(const QFont& font) const { | | QFont scaledFont(const QFont& font) const { | |
| if (tileRegion_ == NULL) | | if (tileRegion_ == NULL) | |
| return font; | | return font; | |
| else { | | else { | |
| QFont f(font); | | QFont f(font); | |
| if (f.pixelSize() == -1) | | if (f.pixelSize() == -1) | |
|
| #if QT_VERSION >= 0x040000 | | | |
| f.setPointSizeF(f.pointSizeF() * tileRegion_
->textScale); | | f.setPointSizeF(f.pointSizeF() * tileRegion_
->textScale); | |
|
| #else | | | |
| f.setPointSizeFloat(f.pointSizeFloat() * til | | | |
| eRegion_->textScale); | | | |
| #endif | | | |
| else | | else | |
| f.setPixelSize(f.pixelSize() * tileRegion_->
textScale); | | f.setPixelSize(f.pixelSize() * tileRegion_->
textScale); | |
| return f; | | return f; | |
| } | | } | |
| } | | } | |
| //@} | | //@} | |
| | | | |
| /*! @name Buffer to texture */ | | /*! @name Buffer to texture */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| | | | |
| skipping to change at line 808 | | skipping to change at line 786 | |
| | | | |
| /*! @name Mouse, keyboard and event handlers */ | | /*! @name Mouse, keyboard and event handlers */ | |
| //@{ | | //@{ | |
| protected: | | protected: | |
| virtual void mousePressEvent(QMouseEvent *); | | virtual void mousePressEvent(QMouseEvent *); | |
| virtual void mouseMoveEvent(QMouseEvent *); | | virtual void mouseMoveEvent(QMouseEvent *); | |
| virtual void mouseReleaseEvent(QMouseEvent *); | | virtual void mouseReleaseEvent(QMouseEvent *); | |
| virtual void mouseDoubleClickEvent(QMouseEvent *); | | virtual void mouseDoubleClickEvent(QMouseEvent *); | |
| virtual void wheelEvent(QWheelEvent *); | | virtual void wheelEvent(QWheelEvent *); | |
| virtual void keyPressEvent(QKeyEvent *); | | virtual void keyPressEvent(QKeyEvent *); | |
|
| | | virtual void keyReleaseEvent(QKeyEvent *); | |
| virtual void timerEvent(QTimerEvent *); | | virtual void timerEvent(QTimerEvent *); | |
| virtual void closeEvent(QCloseEvent *); | | virtual void closeEvent(QCloseEvent *); | |
| //@} | | //@} | |
| | | | |
| /*! @name Object selection */ | | /*! @name Object selection */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| /*! Returns the name (an integer value) of the entity that was last
selected by select(). This | | /*! Returns the name (an integer value) of the entity that was last
selected by select(). This | |
| value is set by endSelection(). See the select() documentation for d
etails. | | value is set by endSelection(). See the select() documentation for d
etails. | |
| | | | |
| | | | |
| skipping to change at line 955 | | skipping to change at line 934 | |
| virtual void setPlayKeyFramePathStateKey(int buttonState); | | virtual void setPlayKeyFramePathStateKey(int buttonState); | |
| // QGLViewer 2.0 without Qt4 support | | // QGLViewer 2.0 without Qt4 support | |
| virtual void setPlayPathStateKey(int buttonState); | | virtual void setPlayPathStateKey(int buttonState); | |
| virtual void setAddKeyFrameStateKey(int buttonState); | | virtual void setAddKeyFrameStateKey(int buttonState); | |
| #endif | | #endif | |
| virtual void setPathKey(int key, int index = 0); | | virtual void setPathKey(int key, int index = 0); | |
| virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modi
fiers); | | virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modi
fiers); | |
| virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers m
odifiers); | | virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers m
odifiers); | |
| //@} | | //@} | |
| | | | |
|
| | | public: | |
| /*! @name Mouse customization */ | | /*! @name Mouse customization */ | |
| //@{ | | //@{ | |
|
| protected: | | | |
| /*! Defines the different mouse handlers: camera() or manipulatedFra
me(). | | /*! Defines the different mouse handlers: camera() or manipulatedFra
me(). | |
| | | | |
|
| Used by setMouseBinding(), setMouseBinding(int, ClickAction, bool, i | | Used by setMouseBinding(), setMouseBinding(Qt::KeyboardModifiers mod | |
| nt) and setWheelBinding() to | | ifiers, Qt::MouseButtons, ClickAction, bool, int) | |
| define which handler receives the mouse events. */ | | and setWheelBinding() to define which handler receives the mouse eve | |
| | | nts. */ | |
| enum MouseHandler { CAMERA, FRAME }; | | enum MouseHandler { CAMERA, FRAME }; | |
| | | | |
| /*! Defines the possible actions that can be binded to a mouse click
using | | /*! Defines the possible actions that can be binded to a mouse click
using | |
|
| setMouseBinding(int,ClickAction,bool,int). | | setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, ClickAction
, bool, int). | |
| | | | |
| See the <a href="../mouse.html">mouse page</a> for details. */ | | See the <a href="../mouse.html">mouse page</a> for details. */ | |
| enum ClickAction { NO_CLICK_ACTION, ZOOM_ON_PIXEL, ZOOM_TO_FIT, SELE
CT, RAP_FROM_PIXEL, RAP_IS_CENTER, | | enum ClickAction { NO_CLICK_ACTION, ZOOM_ON_PIXEL, ZOOM_TO_FIT, SELE
CT, RAP_FROM_PIXEL, RAP_IS_CENTER, | |
| CENTER_FRAME, CENTER_SCENE, SHOW_
ENTIRE_SCENE, ALIGN_FRAME, ALIGN_CAMERA }; | | CENTER_FRAME, CENTER_SCENE, SHOW_
ENTIRE_SCENE, ALIGN_FRAME, ALIGN_CAMERA }; | |
| | | | |
|
| #ifndef DOXYGEN | | /*! Defines the possible actions that can be binded to a mouse actio | |
| // So that it can be used in ManipulatedFrame and ManipulatedCameraF | | n (a click, followed by a | |
| rame. | | | |
| public: | | | |
| #endif | | | |
| | | | |
| /*! Defines the possible actions that can be binded to a mouse motio | | | |
| n (a click, followed by a | | | |
| mouse displacement). | | mouse displacement). | |
| | | | |
| These actions may be binded to the camera() or to the manipulatedFra
me() (see QGLViewer::MouseHandler) using | | These actions may be binded to the camera() or to the manipulatedFra
me() (see QGLViewer::MouseHandler) using | |
| setMouseBinding(). */ | | setMouseBinding(). */ | |
| enum MouseAction { NO_MOUSE_ACTION, | | enum MouseAction { NO_MOUSE_ACTION, | |
| ROTATE, ZOOM, TRANSLATE, | | ROTATE, ZOOM, TRANSLATE, | |
| MOVE_FORWARD, LOOK_AROUND, MOVE_B
ACKWARD, | | MOVE_FORWARD, LOOK_AROUND, MOVE_B
ACKWARD, | |
| SCREEN_ROTATE, ROLL, DRIVE, | | SCREEN_ROTATE, ROLL, DRIVE, | |
| SCREEN_TRANSLATE, ZOOM_ON_REGION
}; | | SCREEN_TRANSLATE, ZOOM_ON_REGION
}; | |
| | | | |
|
| #ifdef DOXYGEN | | | |
| public: | | | |
| #endif | | | |
| | | | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
| MouseAction mouseAction(int state) const; | | MouseAction mouseAction(int state) const; | |
| int mouseHandler(int state) const; | | int mouseHandler(int state) const; | |
| int mouseButtonState(MouseHandler handler, MouseAction action, bool
withConstraint=true) const; | | int mouseButtonState(MouseHandler handler, MouseAction action, bool
withConstraint=true) const; | |
| ClickAction clickAction(int state, bool doubleClick, Qt::MouseButton
s buttonsBefore) const; | | ClickAction clickAction(int state, bool doubleClick, Qt::MouseButton
s buttonsBefore) const; | |
| void getClickButtonState(ClickAction action, int& state, bool& doubl
eClick, Qt::MouseButtons& buttonsBefore) const; | | void getClickButtonState(ClickAction action, int& state, bool& doubl
eClick, Qt::MouseButtons& buttonsBefore) const; | |
|
| | | int wheelButtonState(MouseHandler handler, MouseAction action, bool
withConstraint=true) const; | |
| #endif | | #endif | |
|
| MouseAction mouseAction(Qt::KeyboardModifiers modifiers, Qt::MouseBu | | | |
| ttons buttons) const; | | | |
| int mouseHandler(Qt::KeyboardModifiers modifiers, Qt::MouseButtons b | | | |
| uttons) const; | | | |
| ClickAction clickAction(Qt::KeyboardModifiers modifiers, Qt::MouseBu | | | |
| ttons buttons, bool doubleClick, Qt::MouseButtons buttonsBefore) const; | | | |
| | | | |
| Qt::MouseButtons mouseButtons(MouseHandler handler, MouseAction acti | | | |
| on, bool withConstraint=true) const; | | | |
| Qt::KeyboardModifiers keyboardModifiers(MouseHandler handler, MouseA | | | |
| ction action, bool withConstraint=true) const; | | | |
| void getClickActionState(ClickAction action, Qt::KeyboardModifiers& | | | |
| modifiers, Qt::MouseButtons& buttons, bool& doubleClick, Qt::MouseButtons& | | | |
| buttonsBefore) const; | | | |
| | | | |
|
| MouseAction wheelAction(Qt::KeyboardModifiers modifiers) const; | | MouseAction mouseAction(Qt::Key key, Qt::KeyboardModifiers modifiers | |
| int wheelHandler(Qt::KeyboardModifiers modifiers) const; | | , Qt::MouseButton button) const; | |
| int wheelButtonState(MouseHandler handler, MouseAction action, bool | | int mouseHandler(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::M | |
| withConstraint=true) const; | | ouseButton button) const; | |
| | | | |
| | | void getMouseActionBinding(MouseHandler handler, MouseAction action, | |
| | | bool withConstraint, | |
| | | Qt::Key& key, Qt: | |
| | | :KeyboardModifiers& modifiers, Qt::MouseButton& button) const; | |
| | | | |
| | | ClickAction clickAction(Qt::Key key, Qt::KeyboardModifiers modifiers | |
| | | , Qt::MouseButton button, | |
| | | bool doubleClick=fal | |
| | | se, Qt::MouseButtons buttonsBefore=Qt::NoButton) const; | |
| | | | |
| | | void getClickActionBinding(ClickAction action, Qt::Key& key, Qt::Key | |
| | | boardModifiers& modifiers, | |
| | | Qt::MouseButton& bu | |
| | | tton, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const; | |
| | | | |
| | | MouseAction wheelAction(Qt::Key key, Qt::KeyboardModifiers modifiers | |
| | | ) const; | |
| | | int wheelHandler(Qt::Key key, Qt::KeyboardModifiers modifiers) const | |
| | | ; | |
| | | | |
| | | void getWheelActionBinding(MouseHandler handler, MouseAction action, | |
| | | bool withConstraint, | |
| | | Qt::Key& key, Qt: | |
| | | :KeyboardModifiers& modifiers) const; | |
| | | | |
| public Q_SLOTS: | | public Q_SLOTS: | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
| void setMouseBinding(int state, MouseHandler handler, MouseAction ac
tion, bool withConstraint=true); | | void setMouseBinding(int state, MouseHandler handler, MouseAction ac
tion, bool withConstraint=true); | |
| void setMouseBinding(int state, ClickAction action, bool doubleClick
=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); | | void setMouseBinding(int state, ClickAction action, bool doubleClick
=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); | |
| void setMouseBindingDescription(int state, QString description, bool
doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); | | void setMouseBindingDescription(int state, QString description, bool
doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); | |
| #endif | | #endif | |
|
| void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButto | | | |
| ns buttons, MouseHandler handler, MouseAction action, bool withConstraint=t | | | |
| rue); | | | |
| void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButto | | | |
| ns buttons, ClickAction action, bool doubleClick=false, Qt::MouseButtons bu | | | |
| ttonsBefore=Qt::NoButton); | | | |
| void setMouseBindingDescription(Qt::KeyboardModifiers modifiers, Qt: | | | |
| :MouseButtons buttons, QString description, bool doubleClick=false, Qt::Mou | | | |
| seButtons buttonsBefore=Qt::NoButton); | | | |
| | | | |
|
| | | void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButto | |
| | | n buttons, MouseHandler handler, MouseAction action, bool withConstraint=tr | |
| | | ue); | |
| | | void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButto | |
| | | n button, ClickAction action, bool doubleClick=false, Qt::MouseButtons butt | |
| | | onsBefore=Qt::NoButton); | |
| void setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler h
andler, MouseAction action, bool withConstraint=true); | | void setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler h
andler, MouseAction action, bool withConstraint=true); | |
|
| void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardM | | void setMouseBindingDescription(Qt::KeyboardModifiers modifiers, Qt: | |
| odifiers modifiers); | | :MouseButton button, QString description, bool doubleClick=false, Qt::Mouse | |
| | | Buttons buttonsBefore=Qt::NoButton); | |
| | | | |
| | | void setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Q | |
| | | t::MouseButton buttons, MouseHandler handler, MouseAction action, bool with | |
| | | Constraint=true); | |
| | | void setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Q | |
| | | t::MouseButton button, ClickAction action, bool doubleClick=false, Qt::Mous | |
| | | eButtons buttonsBefore=Qt::NoButton); | |
| | | void setWheelBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, M | |
| | | ouseHandler handler, MouseAction action, bool withConstraint=true); | |
| | | void setMouseBindingDescription(Qt::Key key, Qt::KeyboardModifiers m | |
| | | odifiers, Qt::MouseButton button, QString description, bool doubleClick=fal | |
| | | se, Qt::MouseButtons buttonsBefore=Qt::NoButton); | |
| | | | |
| void clearMouseBindings(); | | void clearMouseBindings(); | |
|
| | | | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
|
| | | MouseAction wheelAction(Qt::KeyboardModifiers modifiers) const; | |
| | | int wheelHandler(Qt::KeyboardModifiers modifiers) const; | |
| | | | |
| | | void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardM | |
| | | odifiers modifiers); | |
| void setHandlerStateKey(MouseHandler handler, int buttonState); | | void setHandlerStateKey(MouseHandler handler, int buttonState); | |
| void setMouseStateKey(MouseHandler handler, int buttonState); | | void setMouseStateKey(MouseHandler handler, int buttonState); | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| static QString mouseActionString(QGLViewer::MouseAction ma); | | static QString mouseActionString(QGLViewer::MouseAction ma); | |
| static QString clickActionString(QGLViewer::ClickAction ca); | | static QString clickActionString(QGLViewer::ClickAction ca); | |
| //@} | | //@} | |
| | | | |
| /*! @name State persistence */ | | /*! @name State persistence */ | |
| | | | |
| skipping to change at line 1081 | | skipping to change at line 1069 | |
| Note that this list may contain \c NULL pointers if the asso
ciated viewer has been deleted. | | Note that this list may contain \c NULL pointers if the asso
ciated viewer has been deleted. | |
| | | | |
| Can be useful to apply a method or to connect a signal to all the vi
ewers: | | Can be useful to apply a method or to connect a signal to all the vi
ewers: | |
| \code | | \code | |
| foreach (QGLViewer* viewer, QGLViewer::QGLViewerPool()) | | foreach (QGLViewer* viewer, QGLViewer::QGLViewerPool()) | |
| connect(myObject, SIGNAL(IHaveChangedSignal()), viewer, SLOT(updat
e())); | | connect(myObject, SIGNAL(IHaveChangedSignal()), viewer, SLOT(updat
e())); | |
| \endcode | | \endcode | |
| | | | |
| \attention With Qt version 3, this method returns a \c QPtrList inst
ead. Use a \c QPtrListIterator | | \attention With Qt version 3, this method returns a \c QPtrList inst
ead. Use a \c QPtrListIterator | |
| to iterate on the list instead.*/ | | to iterate on the list instead.*/ | |
|
| #if QT_VERSION >= 0x040000 | | | |
| static const QList<QGLViewer*>& QGLViewerPool() { return QGLViewer::
QGLViewerPool_; } | | static const QList<QGLViewer*>& QGLViewerPool() { return QGLViewer::
QGLViewerPool_; } | |
|
| #else | | | |
| static const QPtrList<QGLViewer>& QGLViewerPool() { return QGLViewer | | | |
| ::QGLViewerPool_; } | | | |
| #endif | | | |
| | | | |
| /*! Returns the index of the QGLViewer \p viewer in the QGLViewerPoo
l(). This index in unique and | | /*! Returns the index of the QGLViewer \p viewer in the QGLViewerPoo
l(). This index in unique and | |
| can be used to identify the different created QGLViewers (see stateF
ileName() for an application | | can be used to identify the different created QGLViewers (see stateF
ileName() for an application | |
| example). | | example). | |
| | | | |
| When a QGLViewer is deleted, the QGLViewers' indexes are preserved a
nd NULL is set for that index. | | When a QGLViewer is deleted, the QGLViewers' indexes are preserved a
nd NULL is set for that index. | |
| When a QGLViewer is created, it is placed in the first avail
able position in that list. | | When a QGLViewer is created, it is placed in the first avail
able position in that list. | |
| Returns -1 if the QGLViewer could not be found (which should
not be possible). */ | | Returns -1 if the QGLViewer could not be found (which should
not be possible). */ | |
|
| #if QT_VERSION >= 0x040000 | | | |
| static int QGLViewerIndex(const QGLViewer* const viewer) { return QG
LViewer::QGLViewerPool_.indexOf(const_cast<QGLViewer*>(viewer)); } | | static int QGLViewerIndex(const QGLViewer* const viewer) { return QG
LViewer::QGLViewerPool_.indexOf(const_cast<QGLViewer*>(viewer)); } | |
|
| #else | | | |
| static int QGLViewerIndex(const QGLViewer* const viewer) { return QG | | | |
| LViewer::QGLViewerPool_.findRef(viewer); } | | | |
| #endif | | | |
| //@} | | //@} | |
| | | | |
| #ifndef DOXYGEN | | #ifndef DOXYGEN | |
| /*! @name Visual hints */ | | /*! @name Visual hints */ | |
| //@{ | | //@{ | |
| public: | | public: | |
| virtual void setVisualHintsMask(int mask, int delay = 2000); | | virtual void setVisualHintsMask(int mask, int delay = 2000); | |
| virtual void drawVisualHints(); | | virtual void drawVisualHints(); | |
| | | | |
| public Q_SLOTS: | | public Q_SLOTS: | |
| | | | |
| skipping to change at line 1212 | | skipping to change at line 1192 | |
| // M o u s e a c t i o n s | | // M o u s e a c t i o n s | |
| struct MouseActionPrivate { | | struct MouseActionPrivate { | |
| MouseHandler handler; | | MouseHandler handler; | |
| MouseAction action; | | MouseAction action; | |
| bool withConstraint; | | bool withConstraint; | |
| }; | | }; | |
| | | | |
| // M o u s e b i n d i n g s | | // M o u s e b i n d i n g s | |
| struct MouseBindingPrivate { | | struct MouseBindingPrivate { | |
| const Qt::KeyboardModifiers modifiers; | | const Qt::KeyboardModifiers modifiers; | |
|
| const Qt::MouseButtons buttons; | | const Qt::MouseButton button; | |
| | | const Qt::Key key; | |
| | | | |
|
| MouseBindingPrivate(Qt::KeyboardModifiers m, Qt::MouseButton | | MouseBindingPrivate(Qt::KeyboardModifiers m, Qt::MouseButton | |
| s b) | | b, Qt::Key k) | |
| : modifiers(m), buttons(b) {} | | : modifiers(m), button(b), key(k) {} | |
| | | | |
| // This sort order is used in mouseString() to display sorte
d mouse bindings | | // This sort order is used in mouseString() to display sorte
d mouse bindings | |
| bool operator<(const MouseBindingPrivate& mbp) const | | bool operator<(const MouseBindingPrivate& mbp) const | |
| { | | { | |
|
| | | if (key != mbp.key) | |
| | | return key < mbp.key; | |
| if (modifiers != mbp.modifiers) | | if (modifiers != mbp.modifiers) | |
| return modifiers < mbp.modifiers; | | return modifiers < mbp.modifiers; | |
|
| else | | return button < mbp.button; | |
| return buttons < mbp.buttons; | | } | |
| | | }; | |
| | | | |
| | | // W h e e l b i n d i n g s | |
| | | struct WheelBindingPrivate { | |
| | | const Qt::KeyboardModifiers modifiers; | |
| | | const Qt::Key key; | |
| | | | |
| | | WheelBindingPrivate(Qt::KeyboardModifiers m, Qt::Key k) | |
| | | : modifiers(m), key(k) {} | |
| | | | |
| | | // This sort order is used in mouseString() to display sorte | |
| | | d wheel bindings | |
| | | bool operator<(const WheelBindingPrivate& wbp) const | |
| | | { | |
| | | if (key != wbp.key) | |
| | | return key < wbp.key; | |
| | | return modifiers < wbp.modifiers; | |
| } | | } | |
| }; | | }; | |
| | | | |
| // C l i c k b i n d i n g s | | // C l i c k b i n d i n g s | |
| struct ClickBindingPrivate { | | struct ClickBindingPrivate { | |
| const Qt::KeyboardModifiers modifiers; | | const Qt::KeyboardModifiers modifiers; | |
|
| const Qt::MouseButtons buttons; | | const Qt::MouseButton button; | |
| const bool doubleClick; | | const bool doubleClick; | |
| const Qt::MouseButtons buttonsBefore; // only defined when d
oubleClick is true | | const Qt::MouseButtons buttonsBefore; // only defined when d
oubleClick is true | |
|
| | | const Qt::Key key; | |
| | | | |
|
| ClickBindingPrivate(Qt::KeyboardModifiers m, Qt::MouseButton | | ClickBindingPrivate(Qt::KeyboardModifiers m, Qt::MouseButton | |
| s b, bool dc, Qt::MouseButtons bb) | | b, bool dc, Qt::MouseButtons bb, Qt::Key k) | |
| : modifiers(m), buttons(b), doubleClick(dc), buttons | | : modifiers(m), button(b), doubleClick(dc), buttonsB | |
| Before(bb) {} | | efore(bb), key(k) {} | |
| | | | |
| // This sort order is used in mouseString() to display sorte
d mouse bindings | | // This sort order is used in mouseString() to display sorte
d mouse bindings | |
| bool operator<(const ClickBindingPrivate& cbp) const | | bool operator<(const ClickBindingPrivate& cbp) const | |
| { | | { | |
|
| | | if (key != cbp.key) | |
| | | return key < cbp.key; | |
| if (buttonsBefore != cbp.buttonsBefore) | | if (buttonsBefore != cbp.buttonsBefore) | |
| return buttonsBefore < cbp.buttonsBefore; | | return buttonsBefore < cbp.buttonsBefore; | |
|
| else | | if (modifiers != cbp.modifiers) | |
| if (modifiers != cbp.modifiers) | | return modifiers < cbp.modifiers; | |
| return modifiers < cbp.modifiers; | | if (button != cbp.button) | |
| else | | return button < cbp.button; | |
| if (buttons != cbp.buttons) | | return doubleClick != cbp.doubleClick; | |
| return buttons < cbp.buttons | | | |
| ; | | | |
| else | | | |
| return !doubleClick && cbp.d | | | |
| oubleClick; | | | |
| } | | } | |
| }; | | }; | |
| #endif | | #endif | |
| static QString formatClickActionPrivate(ClickBindingPrivate cbp); | | static QString formatClickActionPrivate(ClickBindingPrivate cbp); | |
|
| | | static bool isValidShortcutKey(int key); | |
| | | | |
| QMap<ClickBindingPrivate, QString> mouseDescription_; | | QMap<ClickBindingPrivate, QString> mouseDescription_; | |
| | | | |
| void setDefaultMouseBindings(); | | void setDefaultMouseBindings(); | |
| void performClickAction(ClickAction ca, const QMouseEvent* const e); | | void performClickAction(ClickAction ca, const QMouseEvent* const e); | |
| QMap<MouseBindingPrivate, MouseActionPrivate> mouseBinding_; | | QMap<MouseBindingPrivate, MouseActionPrivate> mouseBinding_; | |
|
| QMap<Qt::KeyboardModifiers, MouseActionPrivate> wheelBinding_; | | QMap<WheelBindingPrivate, MouseActionPrivate> wheelBinding_; | |
| QMap<ClickBindingPrivate, ClickAction> clickBinding_; | | QMap<ClickBindingPrivate, ClickAction> clickBinding_; | |
|
| | | Qt::Key currentlyPressedKey_; | |
| | | | |
| // S n a p s h o t s | | // S n a p s h o t s | |
| void initializeSnapshotFormats(); | | void initializeSnapshotFormats(); | |
| QImage frameBufferSnapshot(); | | QImage frameBufferSnapshot(); | |
| QString snapshotFileName_, snapshotFormat_; | | QString snapshotFileName_, snapshotFormat_; | |
| int snapshotCounter_, snapshotQuality_; | | int snapshotCounter_, snapshotQuality_; | |
| TileRegion* tileRegion_; | | TileRegion* tileRegion_; | |
| | | | |
| // Q G L V i e w e r p o o l | | // Q G L V i e w e r p o o l | |
|
| #if QT_VERSION >= 0x040000 | | | |
| static QList<QGLViewer*> QGLViewerPool_; | | static QList<QGLViewer*> QGLViewerPool_; | |
|
| #else | | | |
| static QPtrList<QGLViewer> QGLViewerPool_; | | | |
| #endif | | | |
| | | | |
| // S t a t e F i l e | | // S t a t e F i l e | |
| QString stateFileName_; | | QString stateFileName_; | |
| | | | |
| // H e l p w i n d o w | | // H e l p w i n d o w | |
| QTabWidget* helpWidget_; | | QTabWidget* helpWidget_; | |
| }; | | }; | |
| | | | |
| #endif // QGLVIEWER_QGLVIEWER_H | | #endif // QGLVIEWER_QGLVIEWER_H | |
| | | | |
End of changes. 43 change blocks. |
| 112 lines changed or deleted | | 116 lines changed or added | |
|