The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings. More...
#include <QGLViewer/manipulatedCameraFrame.h>
Public Member Functions | |
ManipulatedCameraFrame () | |
ManipulatedCameraFrame (const ManipulatedCameraFrame &mcf) | |
ManipulatedCameraFrame & | operator= (const ManipulatedCameraFrame &mcf) |
virtual | ~ManipulatedCameraFrame () |
Public Member Functions inherited from qglviewer::ManipulatedFrame | |
ManipulatedFrame () | |
ManipulatedFrame (const ManipulatedFrame &mf) | |
ManipulatedFrame & | operator= (const ManipulatedFrame &mf) |
virtual | ~ManipulatedFrame () |
qreal | rotationSensitivity () const |
qreal | translationSensitivity () const |
qreal | spinningSensitivity () const |
qreal | zoomSensitivity () const |
qreal | wheelSensitivity () const |
bool | isSpinning () const |
Quaternion | spinningQuaternion () const |
bool | isManipulated () const |
QGLViewer::MouseAction | currentMouseAction () const |
virtual void | checkIfGrabsMouse (int x, int y, const Camera *const camera) |
Public Member Functions inherited from qglviewer::Frame | |
Frame () | |
Frame (const Frame &frame) | |
Frame & | operator= (const Frame &frame) |
virtual | ~Frame () |
Frame (const Vec &position, const Quaternion &orientation) | |
void | setPosition (const Vec &position) |
void | setPosition (qreal x, qreal y, qreal z) |
void | setPositionWithConstraint (Vec &position) |
void | setOrientation (const Quaternion &orientation) |
void | setOrientation (qreal q0, qreal q1, qreal q2, qreal q3) |
void | setOrientationWithConstraint (Quaternion &orientation) |
void | setPositionAndOrientation (const Vec &position, const Quaternion &orientation) |
void | setPositionAndOrientationWithConstraint (Vec &position, Quaternion &orientation) |
Vec | position () const |
Quaternion | orientation () const |
void | getPosition (qreal &x, qreal &y, qreal &z) const |
void | getOrientation (qreal &q0, qreal &q1, qreal &q2, qreal &q3) const |
void | setTranslation (const Vec &translation) |
void | setTranslation (qreal x, qreal y, qreal z) |
void | setTranslationWithConstraint (Vec &translation) |
void | setRotation (const Quaternion &rotation) |
void | setRotation (qreal q0, qreal q1, qreal q2, qreal q3) |
void | setRotationWithConstraint (Quaternion &rotation) |
void | setTranslationAndRotation (const Vec &translation, const Quaternion &rotation) |
void | setTranslationAndRotationWithConstraint (Vec &translation, Quaternion &rotation) |
Vec | translation () const |
Quaternion | rotation () const |
void | getTranslation (qreal &x, qreal &y, qreal &z) const |
void | getRotation (qreal &q0, qreal &q1, qreal &q2, qreal &q3) const |
const Frame * | referenceFrame () const |
void | setReferenceFrame (const Frame *const refFrame) |
bool | settingAsReferenceFrameWillCreateALoop (const Frame *const frame) |
void | translate (Vec &t) |
void | translate (const Vec &t) |
void | translate (qreal x, qreal y, qreal z) |
void | translate (qreal &x, qreal &y, qreal &z) |
void | rotate (Quaternion &q) |
void | rotate (const Quaternion &q) |
void | rotate (qreal q0, qreal q1, qreal q2, qreal q3) |
void | rotate (qreal &q0, qreal &q1, qreal &q2, qreal &q3) |
void | rotateAroundPoint (Quaternion &rotation, const Vec &point) |
void | rotateAroundPoint (const Quaternion &rotation, const Vec &point) |
void | alignWithFrame (const Frame *const frame, bool move=false, qreal threshold=0.0) |
void | projectOnLine (const Vec &origin, const Vec &direction) |
Vec | coordinatesOf (const Vec &src) const |
Vec | inverseCoordinatesOf (const Vec &src) const |
Vec | localCoordinatesOf (const Vec &src) const |
Vec | localInverseCoordinatesOf (const Vec &src) const |
Vec | coordinatesOfIn (const Vec &src, const Frame *const in) const |
Vec | coordinatesOfFrom (const Vec &src, const Frame *const from) const |
void | getCoordinatesOf (const qreal src[3], qreal res[3]) const |
void | getInverseCoordinatesOf (const qreal src[3], qreal res[3]) const |
void | getLocalCoordinatesOf (const qreal src[3], qreal res[3]) const |
void | getLocalInverseCoordinatesOf (const qreal src[3], qreal res[3]) const |
void | getCoordinatesOfIn (const qreal src[3], qreal res[3], const Frame *const in) const |
void | getCoordinatesOfFrom (const qreal src[3], qreal res[3], const Frame *const from) const |
Vec | transformOf (const Vec &src) const |
Vec | inverseTransformOf (const Vec &src) const |
Vec | localTransformOf (const Vec &src) const |
Vec | localInverseTransformOf (const Vec &src) const |
Vec | transformOfIn (const Vec &src, const Frame *const in) const |
Vec | transformOfFrom (const Vec &src, const Frame *const from) const |
void | getTransformOf (const qreal src[3], qreal res[3]) const |
void | getInverseTransformOf (const qreal src[3], qreal res[3]) const |
void | getLocalTransformOf (const qreal src[3], qreal res[3]) const |
void | getLocalInverseTransformOf (const qreal src[3], qreal res[3]) const |
void | getTransformOfIn (const qreal src[3], qreal res[3], const Frame *const in) const |
void | getTransformOfFrom (const qreal src[3], qreal res[3], const Frame *const from) const |
Constraint * | constraint () const |
void | setConstraint (Constraint *const constraint) |
const GLdouble * | matrix () const |
void | getMatrix (GLdouble m[4][4]) const |
void | getMatrix (GLdouble m[16]) const |
const GLdouble * | worldMatrix () const |
void | getWorldMatrix (GLdouble m[4][4]) const |
void | getWorldMatrix (GLdouble m[16]) const |
void | setFromMatrix (const GLdouble m[4][4]) |
void | setFromMatrix (const GLdouble m[16]) |
Frame | inverse () const |
Frame | worldInverse () const |
Public Member Functions inherited from qglviewer::MouseGrabber | |
MouseGrabber () | |
virtual | ~MouseGrabber () |
bool | grabsMouse () const |
bool | isInMouseGrabberPool () const |
void | addInMouseGrabberPool () |
void | removeFromMouseGrabberPool () |
void | clearMouseGrabberPool (bool autoDelete=false) |
Protected Member Functions | |
virtual void | startAction (int ma, bool withConstraint=true) |
Protected Member Functions inherited from qglviewer::ManipulatedFrame | |
void | computeMouseSpeed (const QMouseEvent *const e) |
Quaternion | deformedBallQuaternion (int x, int y, qreal cx, qreal cy, const Camera *const camera) |
qreal | deltaWithPrevPos (QMouseEvent *const event, Camera *const camera) const |
int | mouseOriginalDirection (const QMouseEvent *const e) |
qreal | wheelDelta (const QWheelEvent *event) const |
virtual void | mousePressEvent (QMouseEvent *const event, Camera *const camera) |
virtual void | mouseDoubleClickEvent (QMouseEvent *const event, Camera *const camera) |
Protected Member Functions inherited from qglviewer::MouseGrabber | |
void | setGrabsMouse (bool grabs) |
Private Slots | |
virtual void | flyUpdate () |
Private Member Functions | |
Quaternion | pitchYawQuaternion (int x, int y, const Camera *const camera) |
Quaternion | turnQuaternion (int x, const Camera *const camera) |
void | updateSceneUpVector () |
Private Attributes | |
bool | constrainedRotationIsReversed_ |
qreal | driveSpeed_ |
qreal | flySpeed_ |
QTimer | flyTimer_ |
Vec | pivotPoint_ |
bool | rotatesAroundUpVector_ |
Vec | sceneUpVector_ |
bool | zoomsOnPivotPoint_ |
Friends | |
class | ::QGLViewer |
class | Camera |
Pivot point | |
Vec | pivotPoint () const |
void | setPivotPoint (const Vec &point) |
Vec | revolveAroundPoint () const |
void | setRevolveArountPoint (const Vec &point) |
Camera manipulation | |
bool | rotatesAroundUpVector () const |
void | setRotatesAroundUpVector (bool constrained) |
bool | zoomsOnPivotPoint () const |
void | setZoomsOnPivotPoint (bool enabled) |
void | zoom (qreal delta, const Camera *const camera) |
Fly parameters | |
qreal | flySpeed () const |
Vec | sceneUpVector () const |
Vec | flyUpVector () const |
void | setFlyUpVector (const Vec &up) |
void | setFlySpeed (qreal speed) |
void | setSceneUpVector (const Vec &up) |
Mouse event handlers | |
virtual void | mouseReleaseEvent (QMouseEvent *const event, Camera *const camera) |
virtual void | mouseMoveEvent (QMouseEvent *const event, Camera *const camera) |
virtual void | wheelEvent (QWheelEvent *const event, Camera *const camera) |
Spinning | |
virtual void | spin () |
XML representation | |
virtual QDomElement | domElement (const QString &name, QDomDocument &document) const |
virtual void | initFromDOMElement (const QDomElement &element) |
Additional Inherited Members | |
Public Slots inherited from qglviewer::ManipulatedFrame | |
void | setRotationSensitivity (qreal sensitivity) |
void | setTranslationSensitivity (qreal sensitivity) |
void | setSpinningSensitivity (qreal sensitivity) |
void | setWheelSensitivity (qreal sensitivity) |
void | setZoomSensitivity (qreal sensitivity) |
void | setSpinningQuaternion (const Quaternion &spinningQuaternion) |
virtual void | startSpinning (int updateInterval) |
virtual void | stopSpinning () |
virtual void | initFromDOMElement (const QDomElement &element) |
Public Slots inherited from qglviewer::Frame | |
virtual void | initFromDOMElement (const QDomElement &element) |
Signals inherited from qglviewer::ManipulatedFrame | |
void | manipulated () |
void | spun () |
Signals inherited from qglviewer::Frame | |
void | interpolated () |
void | modified () |
Static Public Member Functions inherited from qglviewer::MouseGrabber | |
static const QList< MouseGrabber * > & | MouseGrabberPool () |
Protected Slots inherited from qglviewer::ManipulatedFrame | |
virtual void | spin () |
Protected Attributes inherited from qglviewer::ManipulatedFrame | |
QGLViewer::MouseAction | action_ |
QPoint | pressPos_ |
Constraint * | previousConstraint_ |
QPoint | prevPos_ |
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings.
A ManipulatedCameraFrame is a specialization of a ManipulatedFrame, designed to be set as the Camera::frame(). Mouse motions are basically interpreted in a negated way: when the mouse goes to the right, the ManipulatedFrame translation goes to the right, while the ManipulatedCameraFrame has to go to the left, so that the scene seems to move to the right.
A ManipulatedCameraFrame rotates around its pivotPoint(), which corresponds to the associated Camera::pivotPoint().
A ManipulatedCameraFrame can also "fly" in the scene. It basically moves forward, and turns according to the mouse motion. See flySpeed(), sceneUpVector() and the QGLViewer::MOVE_FORWARD and QGLViewer::MOVE_BACKWARD QGLViewer::MouseAction.
See the mouse page for a description of the possible actions that can be performed using the mouse and their bindings.
Definition at line 47 of file manipulatedCameraFrame.h.
ManipulatedCameraFrame::ManipulatedCameraFrame | ( | ) |
Default constructor.
flySpeed() is set to 0.0 and sceneUpVector() is (0,1,0). The pivotPoint() is set to (0,0,0).
Definition at line 37 of file manipulatedCameraFrame.cpp.
|
inlinevirtual |
Virtual destructor. Empty.
Definition at line 59 of file manipulatedCameraFrame.h.
ManipulatedCameraFrame::ManipulatedCameraFrame | ( | const ManipulatedCameraFrame & | mcf | ) |
Copy constructor. Performs a deep copy of all members using operator=().
Definition at line 59 of file manipulatedCameraFrame.cpp.
|
virtual |
Returns an XML QDomElement
that represents the ManipulatedCameraFrame.
Adds to the ManipulatedFrame::domElement() the ManipulatedCameraFrame specific informations in a ManipulatedCameraParameters
child QDomElement.
name
is the name of the QDomElement tag. doc
is the QDomDocument
factory used to create QDomElement.
Use initFromDOMElement() to restore the ManipulatedCameraFrame state from the resulting QDomElement
.
See Vec::domElement() for a complete example. See also Quaternion::domElement(), Frame::domElement(), Camera::domElement()...
Reimplemented from qglviewer::ManipulatedFrame.
Definition at line 142 of file manipulatedCameraFrame.cpp.
|
inline |
Returns the fly speed, expressed in OpenGL units.
It corresponds to the incremental displacement that is periodically applied to the ManipulatedCameraFrame position when a QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD QGLViewer::MouseAction is proceeded.
Definition at line 156 of file manipulatedCameraFrame.h.
|
privatevirtualslot |
Called for continuous frame motion in fly mode (see QGLViewer::MOVE_FORWARD). Emits manipulated().
Definition at line 80 of file manipulatedCameraFrame.cpp.
Vec ManipulatedCameraFrame::flyUpVector | ( | ) | const |
Definition at line 106 of file manipulatedCameraFrame.cpp.
|
virtualslot |
Restores the ManipulatedCameraFrame state from a QDomElement
created by domElement().
First calls ManipulatedFrame::initFromDOMElement() and then initializes ManipulatedCameraFrame specific parameters.
Definition at line 158 of file manipulatedCameraFrame.cpp.
|
protectedvirtual |
Overloading of ManipulatedFrame::mouseMoveEvent().
Motion depends on mouse binding (see mouse page for details). The resulting displacements are basically inverted from those of a ManipulatedFrame.
Reimplemented from qglviewer::ManipulatedFrame.
Definition at line 233 of file manipulatedCameraFrame.cpp.
|
protectedvirtual |
This is an overload of ManipulatedFrame::mouseReleaseEvent(). The QGLViewer::MouseAction is terminated.
Reimplemented from qglviewer::ManipulatedFrame.
Definition at line 396 of file manipulatedCameraFrame.cpp.
ManipulatedCameraFrame & ManipulatedCameraFrame::operator= | ( | const ManipulatedCameraFrame & | mcf | ) |
Equal operator. Calls ManipulatedFrame::operator=() and then copy attributes.
Definition at line 46 of file manipulatedCameraFrame.cpp.
|
private |
Returns a Quaternion that is the composition of two rotations, inferred from the mouse pitch (X axis) and yaw (sceneUpVector() axis).
Definition at line 464 of file manipulatedCameraFrame.cpp.
|
inline |
Returns the point the ManipulatedCameraFrame pivot point, around which the camera rotates.
It is defined in the world coordinate system. Default value is (0,0,0).
When the ManipulatedCameraFrame is associated to a Camera, Camera::pivotPoint() also returns this value. This point can interactively be changed using the mouse (see Camera::setPivotPointFromPixel() and QGLViewer::RAP_FROM_PIXEL and QGLViewer::RAP_IS_CENTER in the mouse page).
Definition at line 75 of file manipulatedCameraFrame.h.
|
inline |
Definition at line 80 of file manipulatedCameraFrame.h.
|
inline |
Returns true
when the frame's rotation is constrained around the sceneUpVector(), and false
otherwise, when the rotation is completely free (default).
In free mode, the associated camera can be arbitrarily rotated in the scene, along its three axis, thus possibly leading to any arbitrary orientation.
When you setRotatesAroundUpVector() to true
, the sceneUpVector() defines a 'vertical' direction around which the camera rotates. The camera can rotate left or right, around this axis. It can also be moved up or down to show the 'top' and 'bottom' views of the scene. As a result, the sceneUpVector() will always appear vertical in the scene, and the horizon is preserved and stays projected along the camera's horizontal axis.
Note that setting this value to true
when the sceneUpVector() is not already vertically projected will break these invariants. It will also limit the possible movement of the camera, possibly up to a lock when the sceneUpVector() is projected horizontally. Use Camera::setUpVector() to define the sceneUpVector() and align the camera before calling this method to ensure this does not happen.
Definition at line 106 of file manipulatedCameraFrame.h.
|
inline |
Returns the up vector of the scene, expressed in the world coordinate system.
In 'fly mode' (corresponding to the QGLViewer::MOVE_FORWARD and QGLViewer::MOVE_BACKWARD QGLViewer::MouseAction bindings), horizontal displacements of the mouse rotate the ManipulatedCameraFrame around this vector. Vertical displacements rotate always around the Camera X
axis.
This value is also used when setRotationIsConstrained() is set to true
to define the up vector (and incidentally the 'horizon' plane) around which the camera will rotate.
Default value is (0,1,0), but it is updated by the Camera when this object is set as its Camera::frame(). Camera::setOrientation() and Camera::setUpVector()) direclty modify this value and should be used instead.
Definition at line 171 of file manipulatedCameraFrame.h.
|
inlineslot |
Sets the flySpeed(), defined in OpenGL units.
Default value is 0.0, but it is modified according to the QGLViewer::sceneRadius() when the ManipulatedCameraFrame is set as the Camera::frame().
Definition at line 139 of file manipulatedCameraFrame.h.
void ManipulatedCameraFrame::setFlyUpVector | ( | const Vec & | up | ) |
Definition at line 111 of file manipulatedCameraFrame.cpp.
|
inline |
Sets the pivotPoint(), defined in the world coordinate system.
Definition at line 77 of file manipulatedCameraFrame.h.
|
inline |
Definition at line 81 of file manipulatedCameraFrame.h.
|
inline |
Sets the value of rotatesAroundUpVector().
Default value is false (free rotation).
Definition at line 110 of file manipulatedCameraFrame.h.
|
inlineslot |
Sets the sceneUpVector(), defined in the world coordinate system.
Default value is (0,1,0), but it is updated by the Camera when this object is set as its Camera::frame(). Using Camera::setUpVector() instead is probably a better solution.
Definition at line 145 of file manipulatedCameraFrame.h.
|
inline |
Sets the value of zoomsOnPivotPoint().
Default value is false.
Definition at line 124 of file manipulatedCameraFrame.h.
|
protectedvirtualslot |
Overloading of ManipulatedFrame::spin().
Rotates the ManipulatedCameraFrame around its pivotPoint() instead of its origin.
Definition at line 72 of file manipulatedCameraFrame.cpp.
|
protectedvirtual |
Protected internal method used to handle mouse events.
Reimplemented from qglviewer::ManipulatedFrame.
Definition at line 194 of file manipulatedCameraFrame.cpp.
|
private |
Returns a Quaternion that is a rotation around current camera Y, proportionnal to the horizontal mouse position.
Definition at line 457 of file manipulatedCameraFrame.cpp.
|
private |
This method will be called by the Camera when its orientation is changed, so that the sceneUpVector (private) is changed accordingly. You should not need to call this method.
Definition at line 120 of file manipulatedCameraFrame.cpp.
|
protectedvirtual |
This is an overload of ManipulatedFrame::wheelEvent().
The wheel behavior depends on the wheel binded action. Current possible actions are QGLViewer::ZOOM, QGLViewer::MOVE_FORWARD, QGLViewer::MOVE_BACKWARD. QGLViewer::ZOOM speed depends on wheelSensitivity() while QGLViewer::MOVE_FORWARD and QGLViewer::MOVE_BACKWARD depend on flySpeed(). See QGLViewer::setWheelBinding() to customize the binding.
Reimplemented from qglviewer::ManipulatedFrame.
Definition at line 413 of file manipulatedCameraFrame.cpp.
|
private |
Definition at line 214 of file manipulatedCameraFrame.cpp.
|
inline |
Returns whether or not the QGLViewer::ZOOM action zooms on the pivot point.
When set to false
(default), a zoom action will move the camera along its Camera::viewDirection(), i.e. back and forth along a direction perpendicular to the projection screen.
setZoomsOnPivotPoint() to true
will move the camera along an axis defined by the Camera::pivotPoint() and its current position instead. As a result, the projected position of the pivot point on screen will stay the same during a zoom.
Definition at line 120 of file manipulatedCameraFrame.h.
|
friend |
Definition at line 51 of file manipulatedCameraFrame.h.
|
friend |
Definition at line 50 of file manipulatedCameraFrame.h.
|
private |
Definition at line 224 of file manipulatedCameraFrame.h.
|
private |
Definition at line 217 of file manipulatedCameraFrame.h.
|
private |
Definition at line 216 of file manipulatedCameraFrame.h.
|
private |
Definition at line 219 of file manipulatedCameraFrame.h.
|
private |
Definition at line 228 of file manipulatedCameraFrame.h.
|
private |
Definition at line 221 of file manipulatedCameraFrame.h.
|
private |
Definition at line 218 of file manipulatedCameraFrame.h.
|
private |
Definition at line 226 of file manipulatedCameraFrame.h.