ManipulatedCameraFrame Class Reference

The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings. More...

## Public Member Functions

| ManipulatedCameraFrame ()
virtual | ~ManipulatedCameraFrame ()
| ManipulatedCameraFrame (const ManipulatedCameraFrame &mcf)
ManipulatedCameraFrame & | operator= (const ManipulatedCameraFrame &mcf)
Public Member Functions inherited from ManipulatedFrame
| ManipulatedFrame ()
virtual | ~ManipulatedFrame ()
| ManipulatedFrame (const ManipulatedFrame &mf)
ManipulatedFrame & | operator= (const ManipulatedFrame &mf)
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 Frame
| Frame ()
virtual | ~Frame ()
| Frame (const Frame &frame)
Frame & | operator= (const Frame &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 MouseGrabber
| MouseGrabber ()
virtual | ~MouseGrabber ()
bool | grabsMouse () const
bool | isInMouseGrabberPool () const
void | addInMouseGrabberPool ()
void | removeFromMouseGrabberPool ()
void | clearMouseGrabberPool (bool autoDelete=false)

## Pivot point

Vec | pivotPoint () const
void | setPivotPoint (const Vec &point)

## Camera manipulation

bool | rotatesAroundUpVector () const
void | setRotatesAroundUpVector (bool constrained)
bool | zoomsOnPivotPoint () const
void | setZoomsOnPivotPoint (bool enabled)

## Fly parameters

qreal | flySpeed () const
Vec | sceneUpVector () const
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 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 Frame
virtual void | initFromDOMElement (const QDomElement &element)
Signals inherited from ManipulatedFrame
void | manipulated ()
void | spun ()
Signals inherited from Frame
void | modified ()
void | interpolated ()
Static Public Member Functions inherited from MouseGrabber
static const QList< MouseGrabber * > & | MouseGrabberPool ()
Protected Slots inherited from ManipulatedFrame
virtual void | spin ()
Protected Member Functions inherited from ManipulatedFrame
virtual void | mousePressEvent (QMouseEvent *const event, Camera *const camera)
virtual void | mouseDoubleClickEvent (QMouseEvent *const event, Camera *const camera)
Protected Member Functions inherited from MouseGrabber
void | setGrabsMouse (bool grabs)

## Detailed Description

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 MOVE_FORWARD and 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.

## Constructor & Destructor Documentation

## ManipulatedCameraFrame() [1/2]

ManipulatedCameraFrame | ( |  | ) |

Default constructor.

flySpeed() is set to 0.0 and sceneUpVector() is (0,1,0). The pivotPoint() is set to (0,0,0).

Attention
  Created object is removeFromMouseGrabberPool().

## ~ManipulatedCameraFrame()

virtual ~ManipulatedCameraFrame | ( |  | ) |

virtual

Virtual destructor. Empty.

## ManipulatedCameraFrame() [2/2]

ManipulatedCameraFrame | ( | const ManipulatedCameraFrame & | mcf | ) |

Copy constructor. Performs a deep copy of all members using operator=().

## Member Function Documentation

## domElement()

QDomElement domElement | ( | const QString & | name,
|  | QDomDocument & | document
| ) |  | const

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 ManipulatedFrame.

## flySpeed()

qreal flySpeed | ( |  | ) | const

Returns the fly speed, expressed in OpenGL units.

It corresponds to the incremental displacement that is periodically applied to the ManipulatedCameraFrame position when a MOVE_FORWARD or MOVE_BACKWARD QGLViewer::MouseAction is proceeded.

Attention
  When the ManipulatedCameraFrame is set as the Camera::frame(), this value is set according to the QGLViewer::sceneRadius() by QGLViewer::setSceneRadius().

## initFromDOMElement

void initFromDOMElement | ( | const QDomElement & | element | ) |

virtual slot

Restores the ManipulatedCameraFrame state from a `QDomElement` created by domElement().

First calls ManipulatedFrame::initFromDOMElement() and then initializes ManipulatedCameraFrame specific parameters.

## mouseMoveEvent()

void mouseMoveEvent | ( | QMouseEvent *const | event,
|  | Camera *const | camera
| ) |  |

protected virtual

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 ManipulatedFrame.

## mouseReleaseEvent()

void mouseReleaseEvent | ( | QMouseEvent *const | event,
|  | Camera *const | camera
| ) |  |

protected virtual

This is an overload of ManipulatedFrame::mouseReleaseEvent(). The QGLViewer::MouseAction is terminated.

Reimplemented from ManipulatedFrame.

## operator=()

ManipulatedCameraFrame & operator= | ( | const ManipulatedCameraFrame & | mcf | ) |

Equal operator. Calls ManipulatedFrame::operator=() and then copy attributes.

## pivotPoint()

Vec pivotPoint | ( |  | ) | const

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 RAP_FROM_PIXEL and RAP_IS_CENTER in the mouse page).

## rotatesAroundUpVector()

bool rotatesAroundUpVector | ( |  | ) | const

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.

## sceneUpVector()

Vec sceneUpVector | ( |  | ) | const

Returns the up vector of the scene, expressed in the world coordinate system.

In 'fly mode' (corresponding to the MOVE_FORWARD and 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.

## setFlySpeed

void setFlySpeed | ( | qreal | speed | ) |

slot

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().

## setPivotPoint()

void setPivotPoint | ( | const Vec & | point | ) |

Sets the pivotPoint(), defined in the world coordinate system.

## setRotatesAroundUpVector()

void setRotatesAroundUpVector | ( | bool | constrained | ) |

Sets the value of rotatesAroundUpVector().

Default value is false (free rotation).

## setSceneUpVector

void setSceneUpVector | ( | const Vec & | up | ) |

slot

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.

## setZoomsOnPivotPoint()

void setZoomsOnPivotPoint | ( | bool | enabled | ) |

Sets the value of zoomsOnPivotPoint().

Default value is false.

## spin

void spin | ( |  | ) |

protected virtual slot

Overloading of ManipulatedFrame::spin().

Rotates the ManipulatedCameraFrame around its pivotPoint() instead of its origin.

## wheelEvent()

void wheelEvent | ( | QWheelEvent *const | event,
|  | Camera *const | camera
| ) |  |

protected virtual

This is an overload of ManipulatedFrame::wheelEvent().

The wheel behavior depends on the wheel binded action. Current possible actions are ZOOM, MOVE_FORWARD, MOVE_BACKWARD. ZOOM speed depends on wheelSensitivity() while MOVE_FORWARD and MOVE_BACKWARD depend on flySpeed(). See QGLViewer::setWheelBinding() to customize the binding.

Reimplemented from ManipulatedFrame.

## zoomsOnPivotPoint()

bool zoomsOnPivotPoint | ( |  | ) | const

Returns whether or not the 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.