SpinningFrame Class Reference

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

#include <spinningFrame.h>

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 Member Functions

 SpinningFrame ()
virtual ~SpinningFrame ()
 SpinningFrame (const SpinningFrame &sf)
SpinningFrameoperator= (const SpinningFrame &s)
virtual QDomElement domElement (const QString &name, QDomDocument &doc) const
virtual void initFromDOMElement (const QDomElement &e)

Protected Slots

void spin ()


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(); // Update display after each update of the SpinningFrame connect(sf, SIGNAL(spinned()), SLOT(updateGL())); // 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 spinning 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.

The ManipulatedFrame and ManipulatedCameraFrame classes both derive from this class and can hence have a continuous spinning motion (by default, this happens when the mouse button is released while moving the mouse quickly enough, see ManipulatedFrame::setSpinningSensitivity()).

When spinning, the SpinningFrame emits a spinned() signal, which should usually be connected to the viewer's updateGL() slot, so that successive updates of the SpinningFrame orientation are all displayed. See the spinned() documentation for details.


Constructor & Destructor Documentation

SpinningFrame  ) 
 

Constructor sets default values : isSpinning() is false and updateInterval() is set to 40 milliseconds. rotatesAroundCenter() is false and orientationIsFrozen() is false. The rotationCenter() is (0,0,0) and the spinningQuaternion() is (0,0,0,1).

virtual ~SpinningFrame  )  [inline, virtual]
 

Virtual destructor. Empty.

SpinningFrame const SpinningFrame sf  ) 
 

Copy constructor. Performs a deep copy of all members using operator=(). Signal and slot connections are not copied. If sf isSpinning(), this method will startSpinning().


Member Function Documentation

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

Creates an XML QDomElement that represents the SpinningFrame. Adds 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]
 

Defines whether or not orientationIsFrozen(). Default value is false.

void initFromDOMElement const QDomElement &  e  )  [virtual]
 

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

Fields that are not described in the QDomElement are set to their default values (see SpinningFrame()).

Reimplemented from Frame.

Reimplemented in ManipulatedCameraFrame, and ManipulatedFrame.

bool isSpinning  )  const [inline]
 

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

SpinningFrame & operator= const SpinningFrame sf  ) 
 

Classical = operator. Signal and slot connections are not copied. If sf isSpinning(), this method will startSpinning(). Calls Frame::operator=() and then set specific SpinningFrame members.

bool orientationIsFrozen  )  const [inline]
 

This value is only meaningful when the SpinningFrame rotatesAroundCenter(). In that case, it indicates whether or not the world orientation of the SpinningFrame is modified when it is rotated. Default value is false. See the spinningFrame example for an illustration.

bool rotatesAroundCenter  )  const [inline]
 

When set to true, the SpinningFrame will rotate around its rotationCenter() instead of rotating around its own origin. Default value is false. See the spinningFrame example for an illustration.

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]
 

Defines whether or not the SpinningFrame rotatesAroundCenter(). Default value is false.

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 spin  )  [protected, slot]
 

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

When the SpinningFrame rotatesAroundCenter(), it rotates around its rotationCenter(). Its orientation() is unchanged when orientationIsFrozen(), and modified according to the rotation otherwise.

When the SpinningFrame does not rotatesAroundCenter() (default), it is simply rotated (around its own origin).

void spinned  )  [signal]
 

This signal is emitted whenever the frame is spinning. Connect this signal to any object that should be notified, and especially the viewer(s) :

connect(mySpinningFrame, SIGNAL(spinned()), myViewer, SLOT(updateGL()));

Use QGLViewer::connectSignalToAllViewers() to connect this signal to all the viewers' updateGL() slots.

Note that for every QGLViewer, its QGLViewer::manipulatedFrame() and its QGLViewer::camera() Camera::frame() are SpinningFrame. For these, the spinned() signal is automatically connected to the QGLViewer updateGL() slot.

See also the ManipulatedFrame::manipulated() and KeyFrameInterpolator::interpolated() signals documentations.

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

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 Wed Dec 1 12:41:27 2004 for libQGLViewer by doxygen 1.3.7