A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. More...

Inheritance diagram for ManipulatedFrame:

Signals

void manipulated ()
 This signal is emitted when ever the ManipulatedFrame is manipulated (i.e. More...
 
void spun ()
 This signal is emitted when the ManipulatedFrame isSpinning(). More...
 
- Signals inherited from Frame
void interpolated ()
 This signal is emitted when the Frame is interpolated by a KeyFrameInterpolator. More...
 
void modified ()
 This signal is emitted whenever the position() or the orientation() of the Frame is modified. More...
 

Public Member Functions

 ManipulatedFrame ()
 Default constructor. More...
 
 ManipulatedFrame (const ManipulatedFrame &mf)
 Copy constructor. More...
 
virtual ~ManipulatedFrame ()
 Virtual destructor. More...
 
ManipulatedFrameoperator= (const ManipulatedFrame &mf)
 Equal operator. More...
 
- Public Member Functions inherited from Frame
 Frame ()
 Creates a default Frame. More...
 
 Frame (const Frame &frame)
 Copy constructor. More...
 
virtual ~Frame ()
 Virtual destructor. More...
 
Frameoperator= (const Frame &frame)
 Equal operator. More...
 
 Frame (const Vec &position, const Quaternion &orientation)
 Creates a Frame with a position() and an orientation(). More...
 
void setPosition (const Vec &position)
 Sets the position() of the Frame, defined in the world coordinate system. More...
 
void setPosition (float x, float y, float z)
 Same as setPosition(), but with float parameters. More...
 
void setPositionWithConstraint (Vec &position)
 Same as setPosition(), but position is modified so that the potential constraint() of the Frame is satisfied. More...
 
void setOrientation (const Quaternion &orientation)
 Sets the orientation() of the Frame, defined in the world coordinate system. More...
 
void setOrientation (double q0, double q1, double q2, double q3)
 Same as setOrientation(), but with float parameters. More...
 
void setOrientationWithConstraint (Quaternion &orientation)
 Same as setOrientation(), but orientation is modified so that the potential constraint() of the Frame is satisfied. More...
 
void setPositionAndOrientation (const Vec &position, const Quaternion &orientation)
 Same as successive calls to setPosition() and then setOrientation(). More...
 
void setPositionAndOrientationWithConstraint (Vec &position, Quaternion &orientation)
 Same as setPositionAndOrientation() but position and orientation are modified to satisfy the constraint. More...
 
Vec position () const
 Returns the position of the Frame, defined in the world coordinate system. More...
 
Quaternion orientation () const
 Returns the orientation of the Frame, defined in the world coordinate system. More...
 
void getPosition (float &x, float &y, float &z) const
 x, y and z are set to the position() of the Frame. More...
 
void getOrientation (double &q0, double &q1, double &q2, double &q3) const
 Get the current orientation of the frame (same as orientation()). More...
 
void setTranslation (const Vec &translation)
 Sets the translation() of the frame, locally defined with respect to the referenceFrame(). More...
 
void setTranslation (float x, float y, float z)
 Same as setTranslation(), but with float parameters. More...
 
void setTranslationWithConstraint (Vec &translation)
 Same as setTranslation(), but translation is modified so that the potential constraint() of the Frame is satisfied. More...
 
void setRotation (const Quaternion &rotation)
 Set the current rotation Quaternion. More...
 
void setRotation (double q0, double q1, double q2, double q3)
 Same as setRotation() but with float Quaternion parameters. More...
 
void setRotationWithConstraint (Quaternion &rotation)
 Same as setRotation(), but rotation is modified so that the potential constraint() of the Frame is satisfied. More...
 
void setTranslationAndRotation (const Vec &translation, const Quaternion &rotation)
 Same as successive calls to setTranslation() and then setRotation(). More...
 
void setTranslationAndRotationWithConstraint (Vec &translation, Quaternion &rotation)
 Same as setTranslationAndRotation(), but translation and orientation are modified to satisfy the constraint(). More...
 
Vec translation () const
 Returns the Frame translation, defined with respect to the referenceFrame(). More...
 
Quaternion rotation () const
 Returns the Frame rotation, defined with respect to the referenceFrame(). More...
 
void getTranslation (float &x, float &y, float &z) const
 Fill x, y and z with the translation() of the Frame. More...
 
void getRotation (double &q0, double &q1, double &q2, double &q3) const
 The q are set to the rotation() of the Frame. More...
 
const FramereferenceFrame () const
 Returns the reference Frame, in which coordinates system the Frame is defined. More...
 
void setReferenceFrame (const Frame *const refFrame)
 Sets the referenceFrame() of the Frame. More...
 
bool settingAsReferenceFrameWillCreateALoop (const Frame *const frame)
 Returns true if setting frame as the Frame's referenceFrame() would create a loop in the Frame hierarchy. More...
 
void translate (Vec &t)
 Same as translate(const Vec&) but t may be modified to satisfy the translation constraint(). More...
 
void translate (const Vec &t)
 Translates the Frame of t (defined in the Frame coordinate system). More...
 
void translate (float x, float y, float z)
 Same as translate(const Vec&) but with float parameters. More...
 
void translate (float &x, float &y, float &z)
 Same as translate(Vec&) but with float parameters. More...
 
void rotate (Quaternion &q)
 Same as rotate(const Quaternion&) but q may be modified to satisfy the rotation constraint(). More...
 
void rotate (const Quaternion &q)
 Rotates the Frame by q (defined in the Frame coordinate system): R = R*q. More...
 
void rotate (double q0, double q1, double q2, double q3)
 Same as rotate(const Quaternion&) but with float Quaternion parameters. More...
 
void rotate (double &q0, double &q1, double &q2, double &q3)
 Same as rotate(Quaternion&) but with float Quaternion parameters. More...
 
void rotateAroundPoint (Quaternion &rotation, const Vec &point)
 Makes the Frame rotate() by rotation around point. More...
 
void rotateAroundPoint (const Quaternion &rotation, const Vec &point)
 Same as rotateAroundPoint(), but with a const rotation Quaternion. More...
 
void alignWithFrame (const Frame *const frame, bool move=false, float threshold=0.0f)
 Aligns the Frame with frame, so that two of their axis are parallel. More...
 
void projectOnLine (const Vec &origin, const Vec &direction)
 Translates the Frame so that its position() lies on the line defined by origin and direction (defined in the world coordinate system). More...
 
Vec coordinatesOf (const Vec &src) const
 Returns the Frame coordinates of a point src defined in the world coordinate system (converts from world to Frame). More...
 
Vec inverseCoordinatesOf (const Vec &src) const
 Returns the world coordinates of the point whose position in the Frame coordinate system is src (converts from Frame to world). More...
 
Vec localCoordinatesOf (const Vec &src) const
 Returns the Frame coordinates of a point src defined in the referenceFrame() coordinate system (converts from referenceFrame() to Frame). More...
 
Vec localInverseCoordinatesOf (const Vec &src) const
 Returns the referenceFrame() coordinates of a point src defined in the Frame coordinate system (converts from Frame to referenceFrame()). More...
 
Vec coordinatesOfIn (const Vec &src, const Frame *const in) const
 Returns the in coordinates of the point whose position in the Frame coordinate system is src (converts from Frame to in). More...
 
Vec coordinatesOfFrom (const Vec &src, const Frame *const from) const
 Returns the Frame coordinates of the point whose position in the from coordinate system is src (converts from from to Frame). More...
 
void getCoordinatesOf (const float src[3], float res[3]) const
 Same as coordinatesOf(), but with float parameters. More...
 
void getInverseCoordinatesOf (const float src[3], float res[3]) const
 Same as inverseCoordinatesOf(), but with float parameters. More...
 
void getLocalCoordinatesOf (const float src[3], float res[3]) const
 Same as localCoordinatesOf(), but with float parameters. More...
 
void getLocalInverseCoordinatesOf (const float src[3], float res[3]) const
 Same as localInverseCoordinatesOf(), but with float parameters. More...
 
void getCoordinatesOfIn (const float src[3], float res[3], const Frame *const in) const
 Same as coordinatesOfIn(), but with float parameters. More...
 
void getCoordinatesOfFrom (const float src[3], float res[3], const Frame *const from) const
 Same as coordinatesOfFrom(), but with float parameters. More...
 
Vec transformOf (const Vec &src) const
 Returns the Frame transform of a vector src defined in the world coordinate system (converts vectors from world to Frame). More...
 
Vec inverseTransformOf (const Vec &src) const
 Returns the world transform of the vector whose coordinates in the Frame coordinate system is src (converts vectors from Frame to world). More...
 
Vec localTransformOf (const Vec &src) const
 Returns the Frame transform of a vector src defined in the referenceFrame() coordinate system (converts vectors from referenceFrame() to Frame). More...
 
Vec localInverseTransformOf (const Vec &src) const
 Returns the referenceFrame() transform of a vector src defined in the Frame coordinate system (converts vectors from Frame to referenceFrame()). More...
 
Vec transformOfIn (const Vec &src, const Frame *const in) const
 Returns the in transform of the vector whose coordinates in the Frame coordinate system is src (converts vectors from Frame to in). More...
 
Vec transformOfFrom (const Vec &src, const Frame *const from) const
 Returns the Frame transform of the vector whose coordinates in the from coordinate system is src (converts vectors from from to Frame). More...
 
void getTransformOf (const float src[3], float res[3]) const
 Same as transformOf(), but with float parameters. More...
 
void getInverseTransformOf (const float src[3], float res[3]) const
 Same as inverseTransformOf(), but with float parameters. More...
 
void getLocalTransformOf (const float src[3], float res[3]) const
 Same as localTransformOf(), but with float parameters. More...
 
void getLocalInverseTransformOf (const float src[3], float res[3]) const
 Same as localInverseTransformOf(), but with float parameters. More...
 
void getTransformOfIn (const float src[3], float res[3], const Frame *const in) const
 Same as transformOfIn(), but with float parameters. More...
 
void getTransformOfFrom (const float src[3], float res[3], const Frame *const from) const
 Same as transformOfFrom(), but with float parameters. More...
 
Constraintconstraint () const
 Returns the current constraint applied to the Frame. More...
 
void setConstraint (Constraint *const constraint)
 Sets the constraint() attached to the Frame. More...
 
const GLdouble * matrix () const
 Returns the 4x4 OpenGL transformation matrix represented by the Frame. More...
 
void getMatrix (GLdouble m[4][4]) const
 GLdouble[4][4] version of matrix(). More...
 
void getMatrix (GLdouble m[16]) const
 GLdouble[16] version of matrix(). More...
 
const GLdouble * worldMatrix () const
 Returns the 4x4 OpenGL transformation matrix represented by the Frame. More...
 
void getWorldMatrix (GLdouble m[4][4]) const
 float[4][4] parameter version of worldMatrix(). More...
 
void getWorldMatrix (GLdouble m[16]) const
 float[16] parameter version of worldMatrix(). More...
 
void setFromMatrix (const GLdouble m[4][4])
 This is an overloaded method provided for convenience. More...
 
void setFromMatrix (const GLdouble m[16])
 Sets the Frame from an OpenGL matrix representation (rotation in the upper left 3x3 matrix and translation on the last line). More...
 
Frame inverse () const
 Returns a Frame representing the inverse of the Frame space transformation. More...
 
Frame worldInverse () const
 Returns the inverse() of the Frame world transformation. More...
 
- Public Member Functions inherited from MouseGrabber
 MouseGrabber ()
 Default constructor. More...
 
virtual ~MouseGrabber ()
 Virtual destructor. More...
 
bool grabsMouse () const
 Returns true when the MouseGrabber grabs the QGLViewer's mouse events. More...
 
bool isInMouseGrabberPool () const
 Returns true if the MouseGrabber is currently in the MouseGrabberPool() list. More...
 
void addInMouseGrabberPool ()
 Adds the MouseGrabber in the MouseGrabberPool(). More...
 
void removeFromMouseGrabberPool ()
 Removes the MouseGrabber from the MouseGrabberPool(). More...
 
void clearMouseGrabberPool (bool autoDelete=false)
 Clears the MouseGrabberPool(). More...
 

Protected Member Functions

void computeMouseSpeed (const QMouseEvent *const e)
 Updates mouse speed, measured in pixels/milliseconds. More...
 
Quaternion deformedBallQuaternion (int x, int y, float cx, float cy, const Camera *const camera)
 Returns a quaternion computed according to the mouse motion. More...
 
float deltaWithPrevPos (QMouseEvent *const event, Camera *const camera) const
 Returns a screen scaled delta from event's position to prevPos_, along the X or Y direction, whichever has the largest magnitude. More...
 
int mouseOriginalDirection (const QMouseEvent *const e)
 Return 1 if mouse motion was started horizontally and -1 if it was more vertical. More...
 
virtual void startAction (int ma, bool withConstraint=true)
 Protected internal method used to handle mouse events. More...
 
float wheelDelta (const QWheelEvent *event) const
 Returns a normalized wheel delta, proportionnal to wheelSensitivity(). More...
 
- Protected Member Functions inherited from MouseGrabber
void setGrabsMouse (bool grabs)
 Sets the grabsMouse() flag. More...
 

Protected Attributes

QGLViewer::MouseAction action_
 
QPoint pressPos_
 
ConstraintpreviousConstraint_
 
QPoint prevPos_
 

Friends

class ::QGLViewer
 
class Camera
 

Manipulation sensitivity

float rotationSensitivity () const
 Returns the influence of a mouse displacement on the ManipulatedFrame rotation. More...
 
float translationSensitivity () const
 Returns the influence of a mouse displacement on the ManipulatedFrame translation. More...
 
float spinningSensitivity () const
 Returns the minimum mouse speed required (at button release) to make the ManipulatedFrame spin(). More...
 
float zoomSensitivity () const
 Returns the zoom sensitivity. More...
 
float wheelSensitivity () const
 Returns the mouse wheel sensitivity. More...
 
void setRotationSensitivity (float sensitivity)
 Defines the rotationSensitivity(). More...
 
void setTranslationSensitivity (float sensitivity)
 Defines the translationSensitivity(). More...
 
void setSpinningSensitivity (float sensitivity)
 Defines the spinningSensitivity(), in pixels per milliseconds. More...
 
void setWheelSensitivity (float sensitivity)
 Defines the wheelSensitivity(). More...
 
void setZoomSensitivity (float sensitivity)
 Defines the zoomSensitivity(). More...
 

Spinning

bool isSpinning () const
 Returns true when the ManipulatedFrame is spinning. More...
 
Quaternion spinningQuaternion () const
 Returns the incremental rotation that is applied by spin() to the ManipulatedFrame orientation when it isSpinning(). More...
 
void setSpinningQuaternion (const Quaternion &spinningQuaternion)
 Defines the spinningQuaternion(). More...
 
virtual void startSpinning (int updateInterval)
 Starts the spinning of the ManipulatedFrame. More...
 
virtual void stopSpinning ()
 Stops the spinning motion started using startSpinning(). More...
 
virtual void spin ()
 Rotates the ManipulatedFrame by its spinningQuaternion(). More...
 

Mouse event handlers

virtual void mousePressEvent (QMouseEvent *const event, Camera *const camera)
 Initiates the ManipulatedFrame mouse manipulation. More...
 
virtual void mouseMoveEvent (QMouseEvent *const event, Camera *const camera)
 Modifies the ManipulatedFrame according to the mouse motion. More...
 
virtual void mouseReleaseEvent (QMouseEvent *const event, Camera *const camera)
 Stops the ManipulatedFrame mouse manipulation. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *const event, Camera *const camera)
 Overloading of MouseGrabber::mouseDoubleClickEvent(). More...
 
virtual void wheelEvent (QWheelEvent *const event, Camera *const camera)
 Overloading of MouseGrabber::wheelEvent(). More...
 

Current state

bool isManipulated () const
 Returns true when the ManipulatedFrame is being manipulated with the mouse. More...
 
QGLViewer::MouseAction currentMouseAction () const
 Returns the MouseAction currently applied to this ManipulatedFrame. More...
 

MouseGrabber implementation

virtual void checkIfGrabsMouse (int x, int y, const Camera *const camera)
 Implementation of the MouseGrabber main method. More...
 

XML representation

virtual QDomElement domElement (const QString &name, QDomDocument &document) const
 Returns an XML QDomElement that represents the ManipulatedFrame. More...
 
virtual void initFromDOMElement (const QDomElement &element)
 Restores the ManipulatedFrame state from a QDomElement created by domElement(). More...
 

Additional Inherited Members

- Public Slots inherited from Frame
virtual void initFromDOMElement (const QDomElement &element)
 Restores the Frame state from a QDomElement created by domElement(). More...
 
- Static Public Member Functions inherited from MouseGrabber
static const QList< MouseGrabber * > & MouseGrabberPool ()
 Returns a list containing pointers to all the active MouseGrabbers. More...
 

Detailed Description

A ManipulatedFrame is a Frame that can be rotated and translated using the mouse.

It converts the mouse motion into a translation and an orientation updates. A ManipulatedFrame is used to move an object in the scene. Combined with object selection, its MouseGrabber properties and a dynamic update of the scene, the ManipulatedFrame introduces a great reactivity in your applications.

A ManipulatedFrame is attached to a QGLViewer using QGLViewer::setManipulatedFrame():

init() { setManipulatedFrame( new ManipulatedFrame() ); }
draw()
{
glPushMatrix();
glMultMatrixd(manipulatedFrame()->matrix());
// draw the manipulated object here
glPopMatrix();
}

See the manipulatedFrame example for a complete application.

Mouse events are normally sent to the QGLViewer::camera(). You have to press the QGLViewer::FRAME state key (default is Control) to move the QGLViewer::manipulatedFrame() instead. See the mouse page for a description of mouse button bindings.

Inherited functionalities

A ManipulatedFrame is an overloaded instance of a Frame. The powerful coordinate system transformation functions (Frame::coordinatesOf(), Frame::transformOf(), ...) can hence be applied to a ManipulatedFrame.

A ManipulatedFrame is also a MouseGrabber. If the mouse cursor gets within a distance of 10 pixels from the projected position of the ManipulatedFrame, the ManipulatedFrame becomes the new QGLViewer::mouseGrabber(). It can then be manipulated directly, without any specific state key, object selection or GUI intervention. This is very convenient to directly move some objects in the scene (typically a light). See the mouseGrabber example as an illustration. Note that QWidget::setMouseTracking() needs to be enabled in order to use this feature (see the MouseGrabber documentation).

Advanced functionalities

A QGLViewer can handle at most one ManipulatedFrame at a time. If you want to move several objects in the scene, you simply have to keep a list of the different ManipulatedFrames, and to activate the right one (using QGLViewer::setManipulatedFrame()) when needed. This can for instance be done according to an object selection: see the luxo example for an illustration.

When the ManipulatedFrame is being manipulated using the mouse (mouse pressed and not yet released), isManipulated() returns true. This might be used to trigger a specific action or display (as is done with QGLViewer::fastDraw()).

The ManipulatedFrame also emits a manipulated() signal each time its state is modified by the mouse. This signal is automatically connected to the QGLViewer::update() slot when the ManipulatedFrame is attached to a viewer using QGLViewer::setManipulatedFrame().

You can make the ManipulatedFrame spin() if you release the rotation mouse button while moving the mouse fast enough (see spinningSensitivity()). See also translationSensitivity() and rotationSensitivity() for sensitivity tuning.

Definition at line 95 of file manipulatedFrame.h.

Constructor & Destructor Documentation

Default constructor.

The translation is set to (0,0,0), with an identity rotation (0,0,0,1) (see Frame constructor for details).

The different sensitivities are set to their default values (see rotationSensitivity(), translationSensitivity(), spinningSensitivity() and wheelSensitivity()).

Definition at line 43 of file manipulatedFrame.cpp.

References ManipulatedFrame::setRotationSensitivity(), ManipulatedFrame::setSpinningSensitivity(), ManipulatedFrame::setTranslationSensitivity(), ManipulatedFrame::setWheelSensitivity(), and ManipulatedFrame::setZoomSensitivity().

virtual ~ManipulatedFrame ( )
inlinevirtual

Virtual destructor.

Empty.

Definition at line 107 of file manipulatedFrame.h.

Copy constructor.

Performs a deep copy of all attributes using operator=().

Definition at line 79 of file manipulatedFrame.cpp.

Member Function Documentation

void checkIfGrabsMouse ( int  x,
int  y,
const Camera *const  camera 
)
virtual

Implementation of the MouseGrabber main method.

The ManipulatedFrame grabsMouse() when the mouse is within a 10 pixels region around its Camera::projectedCoordinatesOf() position().

See the mouseGrabber example for an illustration.

Implements MouseGrabber.

Definition at line 93 of file manipulatedFrame.cpp.

References Frame::position(), Camera::projectedCoordinatesOf(), and MouseGrabber::setGrabsMouse().

void computeMouseSpeed ( const QMouseEvent *const  e)
protected

Updates mouse speed, measured in pixels/milliseconds.

Should be called by any method which wants to use mouse speed. Currently used to trigger spinning in mouseReleaseEvent().

Definition at line 241 of file manipulatedFrame.cpp.

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::mouseMoveEvent().

QGLViewer::MouseAction currentMouseAction ( ) const
inline

Returns the MouseAction currently applied to this ManipulatedFrame.

Will return QGLViewer::NO_MOUSE_ACTION unless a mouse button is being pressed and has been bound to this QGLViewer::MouseHandler.

The binding between mouse buttons and key modifiers and MouseAction is set using QGLViewer::setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton buttons, MouseHandler handler, MouseAction action, bool withConstraint).

Definition at line 268 of file manipulatedFrame.h.

Quaternion deformedBallQuaternion ( int  x,
int  y,
float  cx,
float  cy,
const Camera *const  camera 
)
protected

Returns a quaternion computed according to the mouse motion.

Mouse positions are projected on a deformed ball, centered on (cx,cy).

Definition at line 534 of file manipulatedFrame.cpp.

References ManipulatedFrame::rotationSensitivity(), Camera::screenHeight(), Camera::screenWidth(), and Vec::squaredNorm().

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::mouseMoveEvent().

float deltaWithPrevPos ( QMouseEvent *const  event,
Camera *const  camera 
) const
protected

Returns a screen scaled delta from event's position to prevPos_, along the X or Y direction, whichever has the largest magnitude.

Definition at line 275 of file manipulatedFrame.cpp.

References Camera::screenHeight(), Camera::screenWidth(), and ManipulatedFrame::zoomSensitivity().

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::mouseMoveEvent().

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

Returns an XML QDomElement that represents the ManipulatedFrame.

Adds to the Frame::domElement() the ManipulatedFrame specific informations in a ManipulatedParameters child QDomElement.

name is the name of the QDomElement tag. doc is the QDomDocument factory used to create QDomElement.

Use initFromDOMElement() to restore the ManipulatedFrame state from the resulting QDomElement.

See Vec::domElement() for a complete example. See also Quaternion::domElement(), Camera::domElement()...

Reimplemented from Frame.

Reimplemented in ManipulatedCameraFrame.

Definition at line 116 of file manipulatedFrame.cpp.

References Frame::domElement(), ManipulatedFrame::rotationSensitivity(), ManipulatedFrame::spinningSensitivity(), ManipulatedFrame::translationSensitivity(), ManipulatedFrame::wheelSensitivity(), and ManipulatedFrame::zoomSensitivity().

Referenced by ManipulatedCameraFrame::domElement().

void initFromDOMElement ( const QDomElement &  element)
virtualslot

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

Fields that are not described in element are set to their default values (see ManipulatedFrame()).

First calls Frame::initFromDOMElement() and then initializes ManipulatedFrame specific parameters. Note that constraint() and referenceFrame() are not restored and are left unchanged.

See Vec::initFromDOMElement() for a complete code example.

Definition at line 138 of file manipulatedFrame.cpp.

References Frame::initFromDOMElement(), ManipulatedFrame::setRotationSensitivity(), ManipulatedFrame::setSpinningSensitivity(), ManipulatedFrame::setTranslationSensitivity(), ManipulatedFrame::setWheelSensitivity(), ManipulatedFrame::setZoomSensitivity(), and ManipulatedFrame::stopSpinning().

Referenced by ManipulatedCameraFrame::initFromDOMElement(), and QGLViewer::initFromDOMElement().

bool isManipulated ( ) const

Returns true when the ManipulatedFrame is being manipulated with the mouse.

Can be used to change the display of the manipulated object during manipulation.

When Camera::frame() of the QGLViewer::camera() isManipulated(), QGLViewer::fastDraw() is used in place of QGLViewer::draw() for scene rendering. A simplified drawing will then allow for interactive camera displacements.

Definition at line 174 of file manipulatedFrame.cpp.

Referenced by QGLViewer::mouseReleaseEvent().

bool isSpinning ( ) const
inline

Returns true when the ManipulatedFrame is spinning.

During spinning, spin() rotates the ManipulatedFrame by its spinningQuaternion() at a frequency defined when the ManipulatedFrame startSpinning().

Use startSpinning() and stopSpinning() to change this state. Default value is false.

Definition at line 222 of file manipulatedFrame.h.

void manipulated ( )
signal

This signal is emitted when ever the ManipulatedFrame is manipulated (i.e.

rotated or translated) using the mouse. Connect this signal to any object that should be notified.

Note that this signal is automatically connected to the QGLViewer::update() slot, when the ManipulatedFrame is attached to a viewer using QGLViewer::setManipulatedFrame(), which is probably all you need.

Use the QGLViewer::QGLViewerPool() if you need to connect this signal to all the viewers.

See also the spun(), modified(), interpolated() and KeyFrameInterpolator::interpolated() signals' documentations.

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), ManipulatedFrame::mouseMoveEvent(), ManipulatedCameraFrame::wheelEvent(), and ManipulatedFrame::wheelEvent().

void mouseDoubleClickEvent ( QMouseEvent *const  event,
Camera *const  camera 
)
protectedvirtual

Overloading of MouseGrabber::mouseDoubleClickEvent().

Left button double click aligns the ManipulatedFrame with the camera axis (see alignWithFrame() and QGLViewer::ALIGN_FRAME). Right button projects the ManipulatedFrame on the camera view direction.

Reimplemented from MouseGrabber.

Definition at line 482 of file manipulatedFrame.cpp.

References Frame::alignWithFrame(), Camera::frame(), Camera::position(), Frame::projectOnLine(), and Camera::viewDirection().

int mouseOriginalDirection ( const QMouseEvent *const  e)
protected

Return 1 if mouse motion was started horizontally and -1 if it was more vertical.

Returns 0 if this could not be determined yet (perfect diagonal motion, rare).

Definition at line 255 of file manipulatedFrame.cpp.

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::mouseMoveEvent().

void mousePressEvent ( QMouseEvent *const  event,
Camera *const  camera 
)
protectedvirtual

Initiates the ManipulatedFrame mouse manipulation.

Overloading of MouseGrabber::mousePressEvent(). See also mouseMoveEvent() and mouseReleaseEvent().

The mouse behavior depends on which button is pressed. See the QGLViewer mouse page for details.

Reimplemented from MouseGrabber.

Definition at line 305 of file manipulatedFrame.cpp.

References MouseGrabber::grabsMouse().

Referenced by QGLViewer::mousePressEvent().

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

Stops the ManipulatedFrame mouse manipulation.

Overloading of MouseGrabber::mouseReleaseEvent().

If the action was a QGLViewer::ROTATE QGLViewer::MouseAction, a continuous spinning is possible if the speed of the mouse cursor is larger than spinningSensitivity() when the button is released. Press the rotate button again to stop spinning. See startSpinning() and isSpinning().

Reimplemented from MouseGrabber.

Reimplemented in ManipulatedCameraFrame.

Definition at line 461 of file manipulatedFrame.cpp.

References Frame::setConstraint(), ManipulatedFrame::spinningSensitivity(), and ManipulatedFrame::startSpinning().

Referenced by ManipulatedCameraFrame::mouseReleaseEvent(), and QGLViewer::mouseReleaseEvent().

float rotationSensitivity ( ) const
inline

Returns the influence of a mouse displacement on the ManipulatedFrame rotation.

Default value is 1.0. With an identical mouse displacement, a higher value will generate a larger rotation (and inversely for lower values). A 0.0 value will forbid ManipulatedFrame mouse rotation (see also constraint()).

See also setRotationSensitivity(), translationSensitivity(), spinningSensitivity() and wheelSensitivity().

Definition at line 161 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::deformedBallQuaternion(), ManipulatedFrame::domElement(), ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::operator=().

void setRotationSensitivity ( float  sensitivity)
inlineslot
void setSpinningQuaternion ( const Quaternion spinningQuaternion)
inlineslot

Defines the spinningQuaternion().

Its axis is defined in the ManipulatedFrame coordinate system.

Definition at line 235 of file manipulatedFrame.h.

Referenced by ManipulatedCameraFrame::mouseMoveEvent(), and ManipulatedFrame::mouseMoveEvent().

void setSpinningSensitivity ( float  sensitivity)
inlineslot

Defines the spinningSensitivity(), in pixels per milliseconds.

Definition at line 146 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::initFromDOMElement(), ManipulatedFrame::ManipulatedFrame(), and ManipulatedFrame::operator=().

void setTranslationSensitivity ( float  sensitivity)
inlineslot
void setWheelSensitivity ( float  sensitivity)
inlineslot
void setZoomSensitivity ( float  sensitivity)
inlineslot
void spin ( )
protectedvirtualslot

Rotates the ManipulatedFrame by its spinningQuaternion().

Called by a timer when the ManipulatedFrame isSpinning().

Definition at line 191 of file manipulatedFrame.cpp.

References Frame::rotate(), and ManipulatedFrame::spinningQuaternion().

Referenced by ManipulatedFrame::mouseMoveEvent().

Quaternion spinningQuaternion ( ) const
inline

Returns the incremental rotation that is applied by spin() to the ManipulatedFrame orientation when it isSpinning().

Default value is a null rotation (identity Quaternion). Use setSpinningQuaternion() to change this value.

The spinningQuaternion() axis is defined in the ManipulatedFrame coordinate system. You can use Frame::transformOfFrom() to convert this axis from an other Frame coordinate system.

Definition at line 231 of file manipulatedFrame.h.

Referenced by ManipulatedCameraFrame::spin(), and ManipulatedFrame::spin().

float spinningSensitivity ( ) const
inline

Returns the minimum mouse speed required (at button release) to make the ManipulatedFrame spin().

See spin(), spinningQuaternion() and startSpinning() for details.

Mouse speed is expressed in pixels per milliseconds. Default value is 0.3 (300 pixels per second). Use setSpinningSensitivity() to tune this value. A higher value will make spinning more difficult (a value of 100.0 forbids spinning in practice).

See also setSpinningSensitivity(), translationSensitivity(), rotationSensitivity() and wheelSensitivity().

Definition at line 192 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::domElement(), ManipulatedFrame::mouseReleaseEvent(), and ManipulatedFrame::operator=().

void spun ( )
signal

This signal is emitted when the ManipulatedFrame isSpinning().

Note that for the QGLViewer::manipulatedFrame(), this signal is automatically connected to the QGLViewer::update() slot.

Connect this signal to any object that should be notified. Use the QGLViewer::QGLViewerPool() if you need to connect this signal to all the viewers.

See also the manipulated(), modified(), interpolated() and KeyFrameInterpolator::interpolated() signals' documentations.

void startAction ( int  ma,
bool  withConstraint = true 
)
protectedvirtual

Protected internal method used to handle mouse events.

Reimplemented in ManipulatedCameraFrame.

Definition at line 208 of file manipulatedFrame.cpp.

References Frame::constraint(), Frame::setConstraint(), and ManipulatedFrame::stopSpinning().

Referenced by QGLViewer::mousePressEvent(), ManipulatedCameraFrame::startAction(), and QGLViewer::wheelEvent().

void startSpinning ( int  updateInterval)
virtualslot

Starts the spinning of the ManipulatedFrame.

This method starts a timer that will call spin() every updateInterval milliseconds. The ManipulatedFrame isSpinning() until you call stopSpinning().

Definition at line 183 of file manipulatedFrame.cpp.

Referenced by ManipulatedFrame::mouseReleaseEvent().

virtual void stopSpinning ( )
inlinevirtualslot

Stops the spinning motion started using startSpinning().

isSpinning() will return false after this call.

Definition at line 239 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::initFromDOMElement(), QGLViewer::setManipulatedFrame(), ManipulatedFrame::startAction(), and QGLViewer::toggleCameraMode().

float translationSensitivity ( ) const
inline

Returns the influence of a mouse displacement on the ManipulatedFrame translation.

Default value is 1.0. You should not have to modify this value, since with 1.0 the ManipulatedFrame precisely stays under the mouse cursor.

With an identical mouse displacement, a higher value will generate a larger translation (and inversely for lower values). A 0.0 value will forbid ManipulatedFrame mouse translation (see also constraint()).

Note
When the ManipulatedFrame is used to move a Camera (see the ManipulatedCameraFrame class documentation), after zooming on a small region of your scene, the camera may translate too fast. For a camera, it is the Camera::pivotPoint() that exactly matches the mouse displacement. Hence, instead of changing the translationSensitivity(), solve the problem by (temporarily) setting the Camera::pivotPoint() to a point on the zoomed region (see the QGLViewer::RAP_FROM_PIXEL mouse binding in the mouse page).

See also setTranslationSensitivity(), rotationSensitivity(), spinningSensitivity() and wheelSensitivity().

Definition at line 180 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::domElement(), ManipulatedCameraFrame::mouseMoveEvent(), ManipulatedFrame::mouseMoveEvent(), and ManipulatedFrame::operator=().

float wheelDelta ( const QWheelEvent *  event) const
protected

Returns a normalized wheel delta, proportionnal to wheelSensitivity().

Definition at line 283 of file manipulatedFrame.cpp.

References ManipulatedFrame::wheelSensitivity().

Referenced by ManipulatedCameraFrame::wheelEvent(), and ManipulatedFrame::wheelEvent().

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

Overloading of MouseGrabber::wheelEvent().

Using the wheel is equivalent to a QGLViewer::ZOOM QGLViewer::MouseAction. See QGLViewer::setWheelBinding(), setWheelSensitivity().

Reimplemented from MouseGrabber.

Reimplemented in ManipulatedCameraFrame.

Definition at line 497 of file manipulatedFrame.cpp.

References ManipulatedFrame::manipulated(), Frame::setConstraint(), and ManipulatedFrame::wheelDelta().

Referenced by QGLViewer::wheelEvent().

float wheelSensitivity ( ) const
inline

Returns the mouse wheel sensitivity.

Default value is 1.0. A higher value will make the wheel action more efficient (usually meaning a faster zoom). Use a negative value to invert the zoom in and out directions.

See also setWheelSensitivity(), translationSensitivity(), rotationSensitivity() zoomSensitivity() and spinningSensitivity().

Definition at line 209 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::domElement(), ManipulatedFrame::operator=(), and ManipulatedFrame::wheelDelta().

float zoomSensitivity ( ) const
inline

Returns the zoom sensitivity.

Default value is 1.0. A higher value will make the zoom faster. Use a negative value to invert the zoom in and out directions.

See also setZoomSensitivity(), translationSensitivity(), rotationSensitivity() wheelSensitivity() and spinningSensitivity().

Definition at line 201 of file manipulatedFrame.h.

Referenced by ManipulatedFrame::deltaWithPrevPos(), ManipulatedFrame::domElement(), and ManipulatedFrame::operator=().


The documentation for this class was generated from the following files: