Main Page   Class Hierarchy   Compound List   All functions   Search  

SpinningFrame Class Reference

A Frame that can have its orientation (and possibly its position) updated at a regular time interval. More...

Inherits Frame.

Inherited by ManipulatedFrame.

List of all members.

Spinning parameters

Quaternion spinningQuaternion () const
Vec rotationCenter () const
bool rotatesAroundCenter () const
bool orientationIsFrozen () const
void setSpinningQuaternion (const Quaternion &q)
void setRotationCenter (const Vec &center)
void setRotateAroundCenter (const bool rac=true)
void freezeOrientation (const bool fo=true)

Timer configuration

bool isSpinning () const
int updateInterval () const
virtual void startSpinning (const int msecs=-1)
virtual void stopSpinning ()
void setUpdateInterval (const int msecs)

Signals

void spinned ()

Public Methods

 SpinningFrame ()
virtual ~SpinningFrame ()
virtual QDomElement domElement (const QString &name, QDomDocument &doc) const
virtual void initFromDOMElement (const QDomElement &de)

Protected Slots

void updateFrame ()


Detailed Description

A Frame that can have its orientation (and possibly its position) updated at a regular time interval.

A SpinningFrame is useful to animate some objects of the scene :

  init()
  {
    sf = new SpinningFrame();
    // Rotation around the Z axis, with a increment of 0.04 radian.
    sf->setSpinningQuaternion(Quaternion(Vec(0,0,1), 0.04));
    sf->startSpinning();
  }

  draw()
  {
    glPushMatrix();
    glMultMatrixd(sf->matrix());
    // Draw your object here.
    glPopMatrix();
  }
  

When rotatesAroundCenter() is true, the SpinningFrame will rotate around the rotationCenter() (defined in the world coordinate system). Use setRotateAroundCenter() and setRotationCenter() to change these values.

Additionally, when rotatesAroundCenter() is true, you can freeze the Frame orientation using freezeOrientation(). The Frame will then describe circles around the rotationCenter(), but its orientation will remain unchanged.

See the spinningFrame example for an illustration.

The spinningQuaternion() axis is always defined in the SpinningFrame coordinate system. You may want to use Frame::transformOfFrom() to convert this axis from an other Frame.

A mouse ManipulatedFrame derives from this class and it can spin when the mouse button is released while moving quickly enough. The manipulated object can hence have a continuous spinning (note that the Camera is one of these objects as it is attached to a ManipulatedFrame).

When spinning, the SpinningFrame emits a spinned() signal, which is connected to all the viewer's updateGL() functions. See the spinned() documentation for details.

when the SpinningFrame is created (see QGLViewer::connectSignalToAllViewers()), so that the display is automatically updated.

This signal connection technique is actually used for all the Frames that may be updated in your application. The ManipulatedFrame::manipulated() and the KeyFrameInterpolator::interpolated() signals are also connected to all the viewers' updateGL() functions when they are created.

In certain cases, this automatic display update may generate too many updates. Simply disconnect the signal to prevent this:

  QGLViewer::disconnectSignalToAllViewers(mySpinningFrame, SIGNAL(spinned()));
  


Constructor & Destructor Documentation

SpinningFrame  
 

Constructor sets default values : isSpinning() is false and updateInterval() is set to 40. The spinned() signal is connected to all the viewers (see QGLViewer::connectSignalToAllViewers()).

virtual ~SpinningFrame   [inline, virtual]
 

Virtual destructor. Empty.


Member Function Documentation

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

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

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

Reimplemented from Frame.

Reimplemented in ManipulatedCameraFrame, and ManipulatedFrame.

void freezeOrientation const bool    fo = true [inline, slot]
 

void initFromDOMElement const QDomElement &    de [virtual]
 

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

Reimplemented from Frame.

Reimplemented in ManipulatedCameraFrame, and ManipulatedFrame.

bool isSpinning   const [inline]
 

True when the SpinningFrame is spinning. updateInterval() returns the update interval.

bool orientationIsFrozen   const [inline]
 

bool rotatesAroundCenter   const [inline]
 

Vec rotationCenter   const [inline]
 

Current spinning rotation center. Set using setRotationCenter().

See the Detailed Description section for more explanations.

void setRotateAroundCenter const bool    rac = true [inline, slot]
 

void setRotationCenter const Vec   center [inline, slot]
 

Defines the current rotationCenter(). This value will be used only when rotatesAroundCenter() is true.

void setSpinningQuaternion const Quaternion   q [inline, slot]
 

Defines the current spinningQuaternion().

void setUpdateInterval const int    msecs [inline, slot]
 

Defines the update interval, defined in milliseconds. Default value is 40. Get current value from updateInterval().

Attention:
A change of the updateInterval() will not be taken into account until next call to startSpinning().

void spinned   [signal]
 

This signal is emitted whenever the frame is spinning. Connect this signal to any object that must be notified.

Note that when a SpinningFrame is created, this signal is automatically connected to all the viewers' updateGL() functions (see QGLViewer::connectSignalToAllViewers()), so that the QGLViewers' displays are automatically updated.

This signal connection technique is actually used for all the Frames that may be updated in your application. The ManipulatedFrame::manipulated() and the KeyFrameInterpolator::interpolated() signals are also connected to all the viewers' updateGL() functions when they are created. In certain cases, this automatic display update may generate too many updates. Simply disconnect one of the signals to prevent this:

    QGLViewer::disconnectSignalToAllViewers( pointerToTheSpinningFrame, SIGNAL(spinned()) );
    

Quaternion spinningQuaternion   const [inline]
 

This is the incremental rotation that will be applied to the SpinningFrame orientation, every updateInterval() milliseconds, when the SpinningFrame isSpinning(). Default value is a null rotation. Use setSpinningQuaternion() to define this value.

More complex rotation motion can be achieved using the rotationCenter() and freezeOrientation(). See the Detailed Description section.

void startSpinning const int    msecs = -1 [virtual, slot]
 

Starts the spinning of the frame. Use stopSpinning() to stop.

msec milliseconds will separate each update of the SpinningFrame position and orientation. When no interval is specified, the previous updateInterval() is used, otherwise updateInterval() is set to msecs.

See the spinningFrame example for an illustration.

virtual void stopSpinning   [inline, virtual, slot]
 

Stops the spinning which was initiated with startSpinning().

void updateFrame   [protected, slot]
 

Update the Frame orientation (and possibly position), according to the SpinningFrame parameters. Emits spinned().

int updateInterval   const [inline]
 

Returns the current update interval of the SpinningFrame. See isSpinning() to know if the Frame is actually spinning. This value can be set with setUpdateInterval() or with startSpinning().


Generated on Fri Jun 27 18:34:04 2003 for libQGLViewer by doxygen1.3-rc2