Main Page   Class Hierarchy   Compound List   Compound Members  

qglviewer::ManipulatedFrame Class Reference

A class that encapsulates the behavior of a manipulated Frame. More...

Inherits qglviewer::Frame.

List of all members.

Intrinsic parameters

Mode mode () const
float flySpeed () const
float rotationSensitivity () const
float translationSensitivity () const
void setMode (const Mode mode)
void toggleMode ()
void setFlySpeed (const float s)
void setRotationSensitivity (const float s)
void setTranslationSensitivity (const float s)

Public Types

enum  Mode { REVOLVE, FLY }

Signals

void manipulated ()

Public Methods

 ManipulatedFrame ()
virtual ~ManipulatedFrame ()
virtual QDomElement domElement (const QString &name, QDomDocument &doc) const
virtual void initFromDOMElement (const QDomElement &de)
void alignWithAxis ()
Current state
bool isManipulated () const
bool isSpinning () const
qglviewer::Vec flyUpVector () const

Protected Slots

void updateFrame ()
void updateFrame_Camera ()

Protected Methods

void updateFlyUpVector ()
Internal methods for spinning - Should be moved in a spinningFrame class.
virtual void startSpinning (const unsigned int delay=0)
virtual void stopSpinning ()
Mouse event handlers
virtual void mousePressEvent (QMouseEvent *, const Camera &)
virtual void mouseReleaseEvent (QMouseEvent *, Camera &)
virtual void mouseMoveCameraEvent (const int x, const int y, const Camera &)
virtual void mouseMoveFrameEvent (const int x, const int y, const Camera &)
virtual void wheelEvent (QWheelEvent *, const Camera &camera)


Detailed Description

A class that encapsulates the behavior of a manipulated Frame.

A manipulated Frame is a Frame that can be rotated and translated with a mouse. It is used to set and move the position of a camera or of an object of the scene.

Two frame manipulation modes are supported : REVOLVE and FLY (see Mode).


Member Enumeration Documentation

enum Mode
 

Mode describes the different modes of the ManipulatedFrame, set by setMode().

In REVOLVE mode, the frame revolves around a fixed point of the scene. When used for a camera, this is the Camera::revolveAroundPoint. For a scene ManipulatedFrame, it is the frame origin.

The FLY mode is made for a manipulated camera frame. The camera can then slowly move forward or backward in the scene, as if it was flying.

See mousePressEvent() for mouse button binding details. Current Mode value is returned by mode(). Use toggleMode() and setMode() to change mode. Example:

      camera.setMode(qglviewer::ManipulatedFrame::FLY);


Constructor & Destructor Documentation

ManipulatedFrame  
 

Creates a default manipulatedFrame. Translation is (0,0,0), with an identity rotation (0,0,0,1).

virtual ~ManipulatedFrame   [inline, virtual]
 

Virtual destructor. Empty.


Member Function Documentation

void alignWithAxis  
 

Align manipulatedFrame with closest axis (if any). QGLViewer::mouseDoubleClickEvent() calls this function when the left mouse button is double clicked.

Attention:
This function will be moved in Frame in future releases.

QDomElement domElement const QString &    name,
QDomDocument &    doc
const [virtual]
 

Creates an XML QDomElement that represents the ManipulatedFrame. name is the name of the QDomElement tag. You need to provide the QDomDocument doc that will hold the resulting element. Add to Frame::domElement() the ManipulatedFrame specific informations.

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

Reimplemented from qglviewer::Frame.

float flySpeed   const [inline]
 

Returns the current fly speed (used when mode() is FLY). Set with setFlySpeed(). Set to 0.5% of the sceneRadius in Camera::setSceneRadius().

qglviewer::Vec flyUpVector   const [inline]
 

Return the up vector used in FLY mode. The vector is orthogonal to the horizontal plane. Horizontal displacement of the mouse rotates the frame around this vector.

void initFromDOMElement const QDomElement &    de [virtual]
 

Restore the ManipulatedFrame state from a QDomElement created by domElement(). See also Frame::initFromDOMElement().

Reimplemented from qglviewer::Frame.

bool isManipulated   const [inline]
 

True when the ManipulatedFrame is being manipulated with the mouse. Can be used to manually simulate the QGLViewer::fastDraw() function. Used by QGLViewer.

bool isSpinning   const [inline]
 

True when the ManipulatedFrame is spinning (fast rotation when mouse button is released)

void manipulated   [signal]
 

This signal is emitted whenever the frame is manipulated using the mouse. Connect this signal to any object that must be notified. Note that when a manipulatedFrame is attached to a QGLViewer (see QGLViewer::setManipulatedFrame()), this signal is automatically connected to all the viewers' updateGL() functions (see QGLViewer::connectSignalToAllViewers()).

Mode mode   const [inline]
 

Returns the current ManipulatedFrame mode. Mode is set by setMode(). Returned values are defined by the Mode enum.

void mouseMoveCameraEvent const int    x,
const int    y,
const Camera   camera
[protected, virtual]
 

Move the camera frame according to the mouse motion. The camera is given as an argument so that its parameters (width and height of the window, fieldOfView) are available in order to fit the mouse motion and the display. Emits manipulated().

void mouseMoveFrameEvent const int    x,
const int    y,
const Camera   camera
[protected, virtual]
 

Move the manipulated frame according to the mouse motion. The camera is given as an argument so that its parameters (width and height of the window, fieldOfView) are available in order to fit the mouse motion and the display. Emits manipulated().

void mousePressEvent QMouseEvent *    e,
const Camera  
[protected, virtual]
 

The mouse behavior depends on the manipulatedFrame mode (see Mode).

In REVOLVE mode, when the ManipulatedFrame is used for a camera :

Left button rotates the scene around Camera::revolveAroundPoint(). Spinning is possible with a fast motion (see mouseReleaseEvent()) Middle button changes the camera zoom. Right button translates the camera in the camera XY plane. Left and middle button pressed together rotate around an axis orthogonal to the screen

In REVOLVE mode, when the ManipulatedFrame is attached to a frame of the scene (see QGLViewer::setManipulatedFrame()) :

Left button rotates the frame around its origin. Middle button changes zooms the frame in or out (along camera Z axis). Right button translates the frame in the camera XY plane.

In FLY mode (for camera only):

Left button changes the view direction and goes forward. Middle button changes the view direction. Right button changes the view direction and goes backward.

void mouseReleaseEvent QMouseEvent *    e,
Camera   camera
[protected, virtual]
 

When the user releases the mouse button, the manipulatedFrame action is stopped. If the action was a rotation (REVOLVE Mode), a continuous spinning is possible if the speed of the cursor is large enough when the buttb bbbbon is released. Press the rotate button again to stop the spinning.

float rotationSensitivity   const [inline]
 

Returns the current rotationSensitivity() as defined by setRotationSensitivity(). Default value is 1.0

void setFlySpeed const float    s [inline, slot]
 

When ManipulatedFrame is in FLY mode (see Mode), this value tunes the speed of the displacement. Current value is given by flySpeed().

void setMode const Mode    mode [slot]
 

Defines the ManipulatedFrame mode. Supported modes are defined by the Mode enum.

  camera.setMode(qglviewer::ManipulatedFrame::FLY); 
the namespace qglviewer is not necessary if you "use namespace qglviewer;".

void setRotationSensitivity const float    s [inline, slot]
 

Defines the influence of a mouse displacement on the frame rotation. Default value is 1.0. Defined with setRotationSensitivity().

void setTranslationSensitivity const float    s [inline, slot]
 

Defines the influence of a mouse displacement on the frame translation. Default value is 1.0. Defined with setTranslationSensitivity().

Note:
You should not have to modify this value as the frame translation is computed so that the frame intuitively exactly matches the mouse trajectory.
Note:
When the manipulated frame is used to move a Camera, you may be worried when you are looking at a small region of your scene, which translate too fast on the screen when you move the camera.
For a camera, it is the Camera::revolveAroundPoint() that exactly matches the mouse displacement. Instead of changing the translationSensitivity(), you may prefer to temporarilly set the Camera::RevolveAroundPoint() to a point of the small region of your scene (see the mouse page for the mouse binding).

virtual void startSpinning const unsigned int    delay = 0 [inline, protected, virtual]
 

Starts the spinning of the frame, defined by spinningQuaternion(). Use stopSpinning() to stop. delay msec will separate each update of the spinning.

virtual void stopSpinning   [inline, protected, virtual]
 

Stops the spinning which was initiated with startSpinning(). Spinning is initiated when the mouse is released with a sufficient speed in REVOLVE::Rotation mode. Clicking the mouse stops the spinning.

void toggleMode   [slot]
 

Change manipulatedFrame mode (defined by the Mode enum), see mode().

float translationSensitivity   const [inline]
 

Returns the current translationSensitivity() as defined by setTranslationSensitivity(). Default value is 1.0

void updateFlyUpVector   [protected]
 

This function will be called by the camera when the camera orientation is changed, so that the flyUpVector (private) is changed accordingly. You should not need to call this function.

void updateFrame   [protected, slot]
 

Called by the timer() for continuous frame motion (spinning). Emits manipulated().

void updateFrame_Camera   [protected, slot]
 

Called by the timer() for continuous frame motion (spinning and fly mode). Emits manipulated().

void wheelEvent QWheelEvent *    e,
const Camera   camera
[protected, virtual]
 

Using the wheel is equivalent to the use of the mouse middle button. See mousePressEvent() for details. Depending on your system configuration, you may have to & actually click the wheel in order to have it considered.


Generated on Thu Jan 16 12:53:47 2003 for libQGLViewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002