Display of visual hints | |
bool | axisIsDrawn () const |
bool | gridIsDrawn () const |
bool | fpsIsDisplayed () const |
bool | textIsEnabled () const |
bool | cameraPathIsEdited () const |
bool | isFullScreen () const |
bool | displaysInStereo () const |
void | toggleDrawAxis () |
void | toggleDrawGrid () |
void | toggleDisplayFPS () |
void | toggleEnableText () |
void | toggleCameraPathEditor () |
void | toggleFullScreen () |
void | toggleStereoDisplay () |
void | setDrawAxis (bool f=true) |
void | setDrawGrid (bool f=true) |
void | setDisplayFPS (bool f=true) |
void | setEnableText (bool f=true) |
void | editCameraPath (bool edit=true) |
void | setFullScreen (bool f=true) |
void | setStereoDisplay (bool f=true) |
Display functions | |
void | drawAxis (float scale=1.0) |
void | drawGrid () |
virtual void | startScreenCoordinatesSystem () const |
virtual void | stopScreenCoordinatesSystem () const |
virtual void | drawLight (GLenum light) |
virtual void | displayFPS () const |
void | drawText (GLfloat x, GLfloat y, const char *text, GLfloat height=15.0) const |
void | draw3DText (const qglviewer::Vec &pos, const qglviewer::Vec &normal, const QString &string, GLfloat height=0.1) const |
Scene related parameters and methods | |
float | aspectRatio () const |
float | sceneRadius () const |
void | getSceneCenter (float &x, float &y, float &z) const |
qglviewer::Vec | sceneCenter () const |
void | getRevolveAroundPoint (float &x, float &y, float &z) const |
qglviewer::Vec | revolveAroundPoint () const |
qglviewer::ManipulatedFrame * | manipulatedFrame () const |
float | currentFPS () |
qglviewer::Camera | camera |
void | setSceneRadius (float r) |
void | setSceneCenter (const qglviewer::Vec &sc) |
void | setSceneCenter (float x, float y, float z) |
void | showEntireScene () |
void | setManipulatedFrame (qglviewer::ManipulatedFrame *fr) |
Snapshots | |
const QString & | snapshotFilename () const |
const QString & | snapshotFormat () const |
void | saveSnapshot (bool automatic=false) |
void | setSnapshotFilename (const QString &n) |
void | setSnapshotFormat (const QString &f) |
Animation | |
bool | animationIsStarted () const |
int | animationPeriod () const |
void | setAnimationPeriod (int msecs) |
virtual void | startAnimation (int msecs=-1) |
virtual void | stopAnimation () |
void | toggleAnimationMode () |
Key customization | |
enum | ShortcutAction { DrawAxis, DrawGrid, DisplayFPS, EnableText, Exit, SaveScreenshot, CameraMode, FullScreen, Stereo, Animation, Help, EditCameraPaths } |
enum | MouseBehavior { CAMERA, FRAME } |
virtual void | setShortcutKey (ShortcutAction action, int key) |
virtual void | setShortcutStateKey (ShortcutAction action, ushort skey) |
Qt::Key | shortcutKey (const ShortcutAction action) const |
Qt::ButtonState | shortcutStateKey (ShortcutAction action) const |
virtual void | setKeyFrameKey (int nb, int key) |
virtual void | setAddKeyFrameStateKey (ushort skey) |
virtual void | setPlayKeyFramePathStateKey (ushort skey) |
virtual void | setDeleteKeyFrameStateKey (ushort skey) |
Qt::Key | keyFrameKey (int nb) |
Qt::ButtonState | addKeyFrameStateKey () |
Qt::ButtonState | playKeyFramePathStateKey () |
Qt::ButtonState | deleteKeyFrameStateKey () |
virtual void | setMouseStateKey (MouseBehavior behavior, ushort skey) |
Qt::ButtonState | mouseStateKey (MouseBehavior behavior) const |
Signals | |
void | message (const QString &) |
void | viewerInitialized () |
void | drawNeeded () |
void | animateNeeded () |
void | helpRequired () |
void | axisDrawn (bool on) |
void | gridDrawn (bool on) |
void | fpsDisplayed (bool on) |
void | textEnabled (bool on) |
void | cameraPathEdited (bool on) |
void | fullScreenChanged (bool on) |
void | stereoChanged (bool on) |
Public Methods | |
QGLViewer (QWidget *parent=NULL, const char *name=0, const QGLWidget *shareWidget=0, WFlags f=0) | |
QGLViewer (const QGLFormat &format, QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, WFlags f=0) | |
virtual | ~QGLViewer () |
virtual void | select (QMouseEvent *) |
Temp ! Change ! Kept for backward compatibility - Removed in version 1.3. | |
void | selectWarning () |
Temp ! Change ! select warning message - Removed in version 1.3. More... | |
void | convertClickToLine (const QMouseEvent *, float orig[3], float dir[3]) const |
void | convertClickToLine (const QMouseEvent *, qglviewer::Vec &orig, qglviewer::Vec &dir) const |
Save and restore state | |
virtual void | saveToFile (const QString &fileName="") |
virtual void | restoreFromFile (const QString &fileName="") |
virtual QDomElement | domElement (const QString &name, QDomDocument &doc) const |
virtual void | initFromDOMElement (const QDomElement &de) |
Static Public Methods | |
Static methods for all the viewers | |
All the created QGLViewers are stored in a pool. These methods allow you to use this pool. | |
void | connectSignalToAllViewers (const QObject *sender, const char *signal, const char *member=SLOT(updateGL())) |
void | disconnectSignalToAllViewers (const QObject *sender, const char *signal, const char *member=SLOT(updateGL())) |
void | updateGLForAllViewers () |
void | saveToFileForAllViewers () |
Protected Types | |
Protected Methods | |
virtual void | resizeGL (int w, int h) |
virtual void | initializeGL () |
virtual void | init () |
virtual void | help () |
virtual void | paintGL () |
virtual void | preDraw () |
virtual void | preDrawStereo (bool leftBuffer=true) |
virtual void | draw () |
virtual void | fastDraw () |
virtual void | postDraw () |
virtual void | animate () |
QWidget * | rootWidget () const |
OpenGL matrices | |
virtual void | loadProjectionMatrix (bool reset=true) const |
virtual void | getProjectionMatrix (float *m) const |
virtual void | getProjectionMatrix (double *m) const |
virtual void | loadModelViewMatrix (bool reset=true) const |
virtual void | getModelViewMatrix (GLdouble m[16]) const |
virtual void | getModelViewMatrix (GLfloat m[16]) const |
Mouse and keyboard handlers | |
virtual void | mousePressEvent (QMouseEvent *) |
virtual void | mouseDoubleClickEvent (QMouseEvent *) |
virtual void | mouseReleaseEvent (QMouseEvent *) |
virtual void | mouseMoveEvent (QMouseEvent *) |
virtual void | wheelEvent (QWheelEvent *) |
virtual void | timerEvent (QTimerEvent *) |
virtual void | keyPressEvent (QKeyEvent *) |
To use it, you can derive a class from it and overload the draw() virtual method. See the simpleViewer example for an introduction.
// The Viewer class inherits from QGLViewer and overloads the draw function. class Viewer : public QGLViewer { Q_OBJECT // Include this if you use Qt signals/slots public: Viewer() : QGLViewer() {} protected: virtual void draw(); { // Your OpenGL drawing code goes here... } };
An other method is to connect your drawing methods to the signals emited by the QGLViewer (clean callback mechanism). See the callback example for a complete example.
// A Scene class holds the scene data and provides a drawScene() function. class Scene : public QObject { Q_OBJECT // Needed in order to use the Qt signals/slots mechanism public : Scene(const QGLViewer* const v); public slots: void drawScene(); }; Scene::Scene(const QGLViewer* const viewer) : QObject() { // Connect the viewer signal to our draw function slot connect(viewer, SIGNAL(drawNeeded()), this, SLOT(drawScene())); }
Many functionalities are implemented : snapshots savings, camera displacement with keyFramed paths, manipulated frames with hierarchies and constraints. Try the numerous simple examples to discover the possibilities and understand how it works.
|
Defines the different mouse behavior modes : Camera or Frame motion. Use mouseStateKey() and setMouseStateKey() to select which key must be pressed to enable each one. See the mouse page for details. |
|
Defines the different actions that can directly be associated with a keyboard shortcut. Used by setShortcutKey(), setShortcutStateKey(), shortcutKey() and shortcutStateKey(). See the QGLViewer shortcuts page for details. |
|
Set default display flags (all |
|
Set default display flags (all |
|
Virtual destructor. Remove object from QGLViewer pool (see updateGLForAllViewers()) and calls saveToFile(). |
|
Returns the state key (Qt::AltButton, Qt::ShiftButton, Qt::ControlButton) that must be pressed with the keyFrameKey() to add a KeyFrame to a camera KeyFrame path. Default value is Qt::AltButton. See setAddKeyFrameStateKey() for details. See also keyFrameKey(), playKeyFramePathStateKey() and deleteKeyFrameStateKey(). See the QGLViewer shortcuts page for details. |
|
Scene animation function. Once startAnimation() has been called, an infinite loop calls animate() and draw(). |
|
Signal emitted by the default QGLViewer::animate() function. Connect this signal to your scene animation function. Use this signal-slot mechanism ONLY IF you don't inherit your viewer from QGLViewer (in that case, simply overload the animate() function). |
|
Return true when the animation loop is started, i.e. viewer calls animate() and draw(). See startAnimation() and animate() |
|
The animation loop period, in milliseconds. See startAnimation() and animate(). |
|
Returns the aspect ratio of the GL widget. That is the ratio between its width and height (see the QGLWidget documentation). |
|
This signal is emitted whenever axisIsDrawn() changes value. This can be done with setDrawAxis() or toggleDrawAxis(). |
|
Returns |
|
This signal is emitted whenever cameraPathIsEdited() changes value. This can be done with editCameraPath() or toggleCameraPathEditor(). |
|
Returns |
|
Connect a signal to a signal or a slot of all the QGLViewers. Typical usage would be: connectSignalToAllViewers(myScene, SIGNAL(needsRedisplay)); The default target signal is updateGL(), but any other signal/slot can be used. This function will silently ignore the connections that cannot be established. See also disconnectSignalToAllViewers() and updateGLForAllViewers(). |
|
This function should be called by your select() function to transform a window x,y coordinate to a (world coordinates) half line, for analytical intersection process.
The origin of the half line (eye position) is stored in See the select example for illustration. |
|
Same as convertClickToLine(), but the result is returned as a float[3]. |
|
Returns the current viewer frame rate, as displayed by displayFPS() (see setDisplayFPS() and toggleDisplayFPS()). This function is useful for true real-time applications that may adapt the computationnal load according to frame rate evolution in order to maintain a given frequency. Note that for stability reasons this value is averaged over 25 frames, and hence will only change every 25 frames. As Qt redraws the window only when needed, this value is meaningfull only when startAnimation() is called, when you use Camera::playKeyFramePath() or when the camera is manipulated with the mouse, so that draw() is called in a loop. |
|
Returns the state key (Qt::AltButton, Qt::ShiftButton, Qt::ControlButton) that must be pressed with the keyFrameKey() to delete a camera KeyFrame path. Default value is Qt::ControlButton. Once a path has been delete, trying to re-play the path (using keyFrameKey() and playKFStateKey()) will do nothing until new key frames are added (using keyFrameKey() and addKeyFrameStateKey()). Use setDeleteKeyFrameStateKey() to change this value. See the QGLViewer shortcuts page for details. |
|
Disconnect a signal to a signal or a slot of all the QGLViewers. Used in conjunction with connectSignalToAllViewers(). The default target signal is updateGL(), but any other signal/slot can be used. This function will silently ignore the connections that cannot be removed. See also updateGLForAllViewers(). |
|
Display the frame rate in the lower left corner. The frame rate is computed as an average and updateGL() must be called in a loop in order to have a meaningfull value (this is the case when animationIsStarted()). The FPS display can be toggled with toggleDisplayFPS() or with setDisplayFPS(). See also currentFPS(). |
|
Returns |
|
Creates an XML QDomElement that represents the QGLViewer. Use initFromDOMElement() to restore the QGLViewer state from the resulting domElement. Merges the ManipulatedFrame::domElement(), Camera::domElement(), ... elements.
|
|
The core function of the viewer, called to draw the scene. If you build a class that inherits from QGLViewer, this is the function you want to overload. See the simpleViewer example for an illustration. If you choose to use a callback mechanism instead, the default behavior of this function is to emit the drawNeeded() signal, which can be connected to your draw function. See the callback example for details.
|
|
Similar to drawText(), but the text is considered as a classical object of the 3D scene.
|
|
Displays an XYZ axis, with a given size (default is 1.0). The axis is glPushMatrix(); glTranslatef(x,y,z); glRotatef(90.,0.,1.,0.); drawAxis(0.2); glPopMatrix(); glPushMatrix(); glMultMatrixd(frame.matrix()); drawAxis(0.2); glPopMatrix();
|
|
Displays a XY grid. The calling function should set the |
|
This debugging function draws a representation of drawLight(GL_LIGHT0) |
|
Signal emitted by the default QGLViewer::draw() function. Connect this signal to your main drawing function. preDraw() is called before this signal is emited and will call loadProjectionMatrix() and loadModelViewMatrix() to set the viewing matrices. postDraw() will be called after this signal is answered. pre (resp. post) draw can be tuned by adding code at the beginning (resp. end) of your draw slot. You can check whether the camera is manipulated to call a fast draw version : if (viewer.camera->isManipulated()) fastDrawMethod(); else normalDrawMethod(); Use this signal-slot mechanism ONLY IF you don't inherit your viewer from QGLViewer (in that case, simply overload the draw() and fastDraw() function). |
|
Draws a
Text is displayed only when isTextEnabled() returns This function can be used in conjunction with the Camera::projectedCoordinatesOf() function to display a text attached to an object. In your draw() function call: qglviewer::Vec screenPos = camera.projectedCoordinatesOf(myFrame.position()); drawText(screenPos[0], screenPos[1], "My Object"); Text is displayed using the GLUT glutStrokeCharacter() function. The GL_MODELVIEW and GL_PROJECTION matrices are not modified by this function. The (0,0) coordinates is the lower left corner of the window. See startScreenCoordinatesSystem() for details. See also the draw3DText() function.
|
|
Start (default, |
|
Fast draw of the scene. Called instead of draw() when the camera is manipulated. Usefull for interactive displacements in a complex scene. Default behavior calls draw(). See the |
|
This signal is emitted whenever fpsIsDisplayed() changes value. This can be done with setDisplayFPS() or toggleDisplayFPS(). |
|
Returns |
|
This signal is emitted whenever isFullScreen() changes value. This can be done with setFullScreen() or toggleFullScreen(). |
|
Simply calls Camera::getModelViewMatrix(). Usefull for inheriting classes as it is a protected Camera method. |
|
Simply calls Camera::getModelViewMatrix(). Usefull for inheriting classes as it is a protected Camera method. |
|
Simply calls Camera::getProjectionMatrix(). Usefull for inheriting classes as it is a protected Camera method. |
|
Simply calls Camera::getProjectionMatrix(). Usefull for inheriting classes as it is a protected Camera method. |
|
float version of revolveAroundPoint(). |
|
float version of sceneCenter(). |
|
This signal is emitted whenever gridIsDrawn() changes value. This can be done with setDrawGrid() or toggleDrawGrid(). |
|
Returns |
|
This function is called when the user presses the HELP_KEY (default is H). It should display a brief help or start a more complex help browser. The default behavior (defined in QGLViewer::help()) is to display a short description of the different key and mouse bindings and emits the helpRequired() signal. You can add your own shortcuts description with this kind of code: QGLViewer::help(); cout << "Z\tSet the foo to zero" << endl; cout << "O\tChanges default output" << endl; ... |
|
Signal emitted by the default QGLViewer::help() function. Connect this signal to your own help function. Use this signal-slot mechanism ONLY IF you don't inherit your viewer from QGLViewer (in that case, simply overload the help() function). |
|
Initialisation of the viewer. Called in initializeGL(), before the first drawing. Can be used to set the camera (Camera::setPosition(), Camera::setFieldOfView(), ...) or to make the camera fit the scene (see Camera::showEntireScene()). OpenGL flags can also be (re)defined here. Default flags are set in initializeGL() but only the
|
|
Restores the QGLViewer state from a QDomElement created by domElement(). See also Camera::initFromDOMElement(), ManipulatedFrame::initFromDOMElement().
|
|
Initialization of the GL context, creation of some viewer display lists. Calls init() at the end. Defines the following default GL parameters : glClearColor(0.2, 0.2, 0.2, 1.0); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); init() is called at the end, and the openGL flags can be re-defined there. This function should not be overloaded. Use init() for viewer initialisation. In case of overloading, call QGLViewer::initializeGL() at the beginning of your new initializeGL() function. |
|
Returns |
|
Returns the camera Key Frame path shortcut key for index See also addKeyFrameStateKey(), playKeyFramePathStateKey() and deleteKeyFrameStateKey(). See the QGLViewer shortcuts page for details. |
|
Key pressed callback function. Some default keybindings are implemented. The different keys can easily be redefined using the associated static values (see the Static Protected Attributes section). Overload this function to implement your own key behavior. You should call the original function in the default case of your switch to preserve the default viewer key bindings : void Viewer::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_R : reset(); break; // and so on... default: QGLViewer::keyPressEvent(e); } } |
|
Simply calls Camera::loadModelViewMatrix(). Usefull for inheriting classes as it is a camera protected Camera method. |
|
Simply calls Camera::loadProjectionMatrix(). Usefull for inheriting classes as it is a camera protected Camera method. |
|
Returns the current manipulated frame, which will be applied the mouse motion when the shortcutKey() of ShortcutAction::Frame is pressed (default is Alt). Value is undefined when no frame has been associated with the viewer (by using setManipulatedFrame()). |
|
Standard message transmission. Used for progress bar for instance |
|
When the user double clicks on the mouse : Left button aligns the camera viewing direction to the closest axis (if any). Middle button fits the zoom so that the entire scene is visible (see setSceneRadius() and showEntireScene()). Right button moves the camera such that the scene center is projected in the center of the screen. |
|
Maintaining a button pressed while moving the mouse updates the camera or the manipulated frame. See mousePressEvent() for a description of the different possible actions. If you want to define your own mouse behavior, do something like this : void Viewer::mousePressEvent(QMouseEvent* e) { if ((e->state() & ~Qt::MouseButtonMask) == (Your personnal Shift/Control/Alt combinaison)) myMouseBehavior = true; else QGLViewer::mousePressEvent(e); } void mouseMoveEvent(QMouseEvent *e) { if (myMouseBehavior) // Use e->x() and e->y() as you want... else QGLViewer::mouseMoveEvent(e); } void mouseReleaseEvent(QMouseEvent* e) { if (myMouseBehavior) myMouseBehavior = false; else QGLViewer::mouseReleaseEvent(e); } Many other event handlers can be customized : mouseDoubleClickEvent(), wheelEvent(), mouseReleaseEvent()... See the Qt::QWidget protected members documentation for a complete list. Use setMouseStateKey() if you simply want to change the state key associated with the default behavior. See also setShortcutKey() and setShortcutStateKey(). |
|
There are two different mouse behaviors : camera or frame motion. The behavior depends on the state keys (Shift, Alt...) that are pressed when the click occurs. The different state keys can be tuned using setMouseStateKey(). For camera and frame motion, there are two modes (see see Camera::mode() or ManipulatedFrame::Mode()) : In REVOLVE mode : Left button rotates the scene around revolveAroundPoint(). Spining is possible with a fast motion. Middle button and whell changes the camera zoom. Right button translates the camera in the camera XY plane. In FLY mode : Left button changes the view direction and goes forward. Middle button changes the viewing direction. No motion. Right button changes the view direction and goes backward. See the mouse behavior and customization HTML page for details. See the mouseMoveEvent() documentation for an exemple of mouse behavior customization. Use the Qt::MouseButtonMask to separate the Control/Alt/Shift state key from the mouse (left/middle/right) buttons. if ((e->state() & ~Qt::MouseButtonMask) == MY_COMBINAISON_OF_Qt::ButtonState, Alt, Control, Shift) myBehaviorPressEvent(e); else QGLViewer::mousePressEvent(e); |
|
When the user releases the mouse button, the camera action is stopped. If the action was a rotation (REVOLVE CameraMode), a continuous spining is possible if the speed of the cursor is large enough when the button is released. Press the rotate button again to stop the spining. See the mouseMoveEvent() documentation for an exemple of mouse behavior customization. |
|
Returns the value of the key that should be pressed when clicking the mouse to select between the two mouse behaviors. The different mouse behaviors are represented in the MouseBehavior enum. The default values are Qt::NoButton for the Camera motion and Qt::AltButton for the Frame displacement.
The state key can be See the QGLViewer mouse page for details. |
|
The paint method. Calls preDraw(), draw() (or fastDraw()) and postDraw() in that order. Should not be overloaded. Overload the internal functions instead. If you choose to overload, the GL_Context must not be changed between two succesive calls to draw(), so that the user can feel free to set his/her openGL flags once for all.
If viewer displaysInStereo(), calls preDrawStereo(flag), draw(), postDraw(), first with flag = |
|
Returns the state key (Qt::AltButton, Qt::ShiftButton, Qt::ControlButton) that must be pressed with the keyFrameKey() to play a camera KeyFrame path. Default value is Qt::NoButton. See setPlayKeyFramePathStateKey() for details. See also keyFrameKey(), addKeyFrameStateKey() and deleteKeyFrameStateKey(). See the QGLViewer shortcuts page for details. |
|
Done after draw(). Default behavior displays axis, grid, FPS... when the respective flags are enabled. The GLContext (color, LIGHTING, BLEND...) should not be changed by this function, so that in draw(), the user can rely on the OpenGL context. Respect this convention (by pushing/popping the different attributes) if you overload this function. Assumes the GL_PROJECTION matrix was not changed by draw(), reset the GL_MODELVIEW matrix. |
|
Called before draw(). Default behavior clears screen and set the projection and model view matrices : glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // GL_PROJECTION matrix camera.loadProjectionMatrix(); // GL_MODELVIEW matrix camera.loadModelViewMatrix(); |
|
Called before draw. Default behavior clear screen and pops camera model view matrix. |
|
Called when the window size is modified. If you overide this function, be very careful to call first the inherited method. void Viewer::resizeGL( int w, int h ) { QGLViewer::resizeGL(w,h); // ... } |
|
Restores the QGLViewer from a state saved in
If This function is automatically called in the QGLViewer constructor. As saveToFile() is automatically called when a viewer is destroyed, the previous viewer state is restored when you restart your application. If you want some parameters (camera position for instance) to always be the same when your application is started, you should set their value directly in the init() function: camera.setPosition(0.0, 0.0, 3*sceneRadius()); camera.setOrientation(Quaternion()); If you viewer starts with a black screen, remember that the mouse double clicks automatically fit the orientation, zoom and placement of the camera. If sceneCenter() and sceneRadius() are properly defined, you no longer should have an empty screen. |
|
When the camera is in REVOLVE mode (see mode()), this is the point the camera revolves around. Default value is the sceneCenter(). This method simply calls Camera::revolveAroundPoint(). |
|
Recursively call parentWidget() until the root widget is found. |
|
Save a snapshot of the current image displayed by the widget. If no snapshot filename is defined (see snapshotFilename()) or if
Otherwise ( Save formats are those available in the QT installation, plus some vectorial formats (EPS, PS, fig). Some artifacts may appear when displaying the PS and EPS result. Simply remove the antialias option in ghostview to get the correct display. Printed output will be fine. The libEPSRender library was written by Cyril Soler (Cyril.Soler@imag.fr). |
|
Saves in
If no This function is called by the QGLViewer destructor. |
|
Calls saveToFile() for all the created QGLViewers. Called when you press the Exit shortcut key (see setShortcutKey). |
|
Scene should be included in a sphere centered on this point. See the Camera::sceneCenter() documentation. |
|
Returns the scene radius (used by the camera to set Camera::zNear() and Camera::zFar()). The entire scene must be included in a sphere of radius sceneRadius(), centered on sceneCenter(). |
|
Temp ! Change ! select warning message - Removed in version 1.3. select() is deprecated. Simply prints a message explaining how to implement objet selection. |
|
Defines the shortcut state key (Alt, Shift, Control) that must be pressed in conjuction with the keyFrameKey(i) to add a Key Frame to the camera Key Frame path of index
The state key can be set to Use setKeyFrameKey() to define the associated Key Frame key. See also setPlayKeyFramePathStateKey() and setDeleteKeyFrameStateKey(). See the QGLViewer shortcuts page for details. |
|
Set the period (in milliseconds) between the calls to animate(). Default is 40 msecs (25 Hz). The frame rate (keybinding 'F') will be set accordingly, provided that your animate() function is fast enough. |
|
Defines the shortcut state key (Alt, Shift, Control) that must be pressed in conjuction with the keyFrameKey(i) to delete the camera Key Frame path of index
The state key can be set to Use setKeyFrameKey() to define the associated Key Frame key. See also setAddKeyFrameStateKey() and setPlayKeyFramePathStateKey(). See the QGLViewer shortcuts page for details. |
|
Set the state of fpsIsDisplayed(). displayFPS() is called or not. See also toggleDisplayFPS() and currentFPS(). |
|
Set the state of the axisIsDrawn(). World axis is drawn or not. See also toggleDrawAxis(). |
|
Set the state of the gridIsDrawn(). A XY grid is drawn or not. See also toggleDrawGrid(). |
|
Set the state of textIsEnabled() : drawText() and draw3DText() actually draw text or not (default is yes). See also toggleEnableText(). |
|
Viewer is set in full screen mode (true, default) or not (false). Get current value from isFullScreen(). See also toggleFullScreen() and its S shortcut key. |
|
Defines the shortcut key associated with the camera Key Frame path of index Use setAddKeyFrameStateKey(), setPlayKeyFramePathStateKey() and setDeleteKeyFrameStateKey() to define the state key that must be pressed with this key to add, play or delete the Key Frame. Use setShortcutKey() to define other shortcut keys. See the QGLViewer shortcuts page for details. |
|
The frame You can use a manipulated frame to move an object in the scene. Your code will look like this (see the manipulatedFrame exemple): void Viewer::init() { ManipulatedFrame* myFrame = new ManipulatedFrame(); setManipulatedFrame(myFrame); } void draw() { glPushMatrix(); // Save previous state glMultMatrixd(myFrame->matrix()); // Your object drawing code goes here glPopMatrix(); // Restore previous state } Note that the camera can also be manipulated, just like a regular frame. Simply use: setManipulatedFrame( &(camera.frame) ); The value of the currently manipulated frame is retrieved with manipulatedFrame(). |
|
Defines which key should be pressed when clicking the mouse to select one of the two mouse behaviors. The different mouse behaviors are represented in the MouseBehavior enum. The default values are Qt::NoButton for the Camera motion and Qt::AltButton for the manipulated Frame.
The state key can be set to This exemple shows how to swap the camera and frame state keys: setMouseStateKey(QGLViewer::FRAME, Qt::NoButton); setMouseStateKey(QGLViewer::CAMERA, Qt::AltButton); With the following code, you will have to press the Alt and the Control key in order to move the camera: setMouseStateKey(QGLViewer::CAMERA, Qt::AltButton|Qt::ControlButton); If you want to move the camera with the Alt or the Control key, you need to overload the mousePressEvent() function: if (((e->state() & ~Qt::MouseButtonMask) == Qt::AltButton) || ((e->state() & ~Qt::MouseButtonMask) == Qt::ControlButton)) camera.frame.mousePressEvent(e); else QGLViewer::mousePressEvent(e); See the QGLViewer mouse page for details. |
|
Defines the shortcut state key (Alt, Shift, Control) that must be pressed in conjuction with the keyFrameKey(i) to start playing the camera Key Frame path of index
The state key can be set to Use setKeyFrameKey() to define the associated Key Frame key. See also setAddKeyFrameStateKey() and setDeleteKeyFrameStateKey(). See the QGLViewer shortcuts page for details. |
|
float version of setSceneCenter(). |
|
Set the center of the scene, defined in world coordinates. The entire scene should be include in a sphere of radius sceneRadius(), centered on sceneCenter(). Default value is (0,0,0), the world coordinate system origin. This method should typically be called in the init() function, when the drawn scene is not centered on the world origin (so that sceneRadius(), Camera::zNear() and Camera::zFar() can be tightly fitted to the scene). It should normally not be modified after. Viewer::init() { setSceneCenter(10,20,0); setSceneRadius(3.0); showEntireScene(); } revolveAroundPoint() has a different meaning, and is probably the value you want to change while the program is running (see Camera::setRevolveAroundPoint()).
|
|
Scene radius is used by the camera to scale axis and grid display, and to optimally set Camera::zNear() and Camera::zFar(). The entire scene must be included in a sphere centered on sceneCenter(), with radius sceneRadius(). Current value can be retrieved from sceneRadius(). You will typically use this function in QGLViewer::init() : setSceneRadius(3.0); showEntireScene(); By default the sceneRadius() is 1.0 is called in the QGLViewer constructor. |
|
Defines the shortcut key associated with a given action of the viewer. All the possible actions are defined by the QGLViewer::ShortcutAction enum.
For example, this code defines Alt-M as the new Camera::toggleMode() shortcut: setShortcutKey (QGLViewer::CameraMode, Qt::Key_M); setShortcutStateKey(QGLViewer::CameraMode, Qt::AltButton); See the QGLViewer shortcuts page for details and default values. |
|
Defines the shortcut state key (Alt, Shift, Control...) that should be pressed while pressing a given action shortcutKey(). All the possible actions are defined by the ShortcutAction enum.
The state key can be set to For example, this code defines Alt-M as the new Camera::toggleMode() shortcut: setShortcutKey (QGLViewer::CameraMode, Qt::Key_M); setShortcutStateKey(QGLViewer::CameraMode, Qt::AltButton); Use setShortcutKey() to define the shortcut key and shortcutStateKey() to get the current value. See also setSavePOVShortcutStateKey(), setRestorePOVShortcutStateKey() and setMouseStateKey(). See the QGLViewer shortcuts page for details and default values. |
|
Sets the filename to use (incrementally) when saving snapshot with saveSnapshot(). If the filename is relative, the current working directory at the moment of the function call is added. snapshotFilename() returns the current snapshot file name. |
|
Defines the snapshot file format. This format will be used by saveSnapshot() in automatic mode. In non-automatic mode, this will be the default format of the saveAs dialog box. The available formats are those handled by Qt. Classical values are "JPEG" (default snapshotFormat()), "PNG", "PPM, "BMP". Use the following code to get the actual list: QStringList formatList = QImage::outputFormatList(); for (QStringList::Iterator it = formatList.begin(); it != formatList.end(); ++it) cout << (*it) << endl; If the library was compiled with the EPSRender option, three additional vectorial formats are available: "EPS", "PS" and "XFIG".
|
|
Activates stereo mode (resp. switch back to mono when The QGLViewer instance must be created with a stereo format to handle stereovision: QGLFormat format; format.setStereoDisplay( TRUE ); QGLViewer viewer(format); |
|
Returns the current shortcut value as defined with setShortcutKey(). See the QGLViewer shortcuts page for details and default values. |
|
Returns the current shortcut state value as defined with setShortcutKey(). See the QGLViewer shortcuts page for details and default values. |
|
Set camera so that the entire scene is visible. This method should be called in init(), once the sceneRadius() and sceneCenter() have been properly set (use setSceneCenter() and setSceneRadius()). Simply calls Camera::showEntireScene(). |
|
Returns the current snapshot filename. Set by setSnapshotFilename(). Used in saveSnapshot(). |
|
Returns the current snapshot file format. Defined from the File Dialog window or with setSnapshotFormat(). Default value is "JPEG". |
|
Start the animation loop. animate() and draw() will be called in a loop.
If You may also be interested in KeyFrameInterpolator::startInterpolation(). |
|
Use this function when you want to start drawing directly with the 2D screen coordinates system in your draw() function. Once this function has been called, the Use Camera::projectedCoordinatesOf() to computed the 2D projection on screen of a 3D point. You need to call stopScreenCoordinatesSystem() at the end of the drawing block to restore the previous camera matrix. This function is called by drawText(). |
|
This signal is emitted whenever displaysInStereo() changes value. This can be done with setStereoDisplay() or toggleStereoDisplay(). |
|
Stop an animation started with startAnimation() or toggleAnimationMode(). |
|
This function closes the screen coordinates drawing block that was started by startScreenCoordinatesSystem(). The GL attributes that may have been changed in startScreenCoordinatesSystem() are restored.
|
|
This signal is emitted whenever textIsEnabled() changes value. This can be done with setEnableText() or toggleEnableText(). |
|
Returns |
|
Overloading of the timer function. Calls animate() (if animationIsStarted()) and then draw(), at a frequency set by setAnimationPeriod(). |
|
Calls startAnimation() or stopAnimation(), depending on animationIsStarted(). |
|
Start/stop the edition of the camera paths ( |
|
Toggle the state of fpsIsDisplayed(). displayFPS() is called or not ( |
|
Toggle the state of axisIsDrawn(). A wordl axis is drawn or not ( |
|
Toggle the state of gridIsDrawn() flag. A XY grid is drawn or not ( |
|
Toggle the state of textIsEnabled() : drawText() and draw3DText() actually draw text or not (default is yes) (? |
|
Viewer is toggled between normal and full screen mode (shortcut key Alt-Enter). See setFullScreen() and isFullScreen(). |
|
Toggle the state of displaysInStereo() ( |
|
updateGL() is called on all the created QGLViewers. All the viewers will have their display updated. See connectSignalToAllViewers() and disconnectSignalToAllViewers() for more complex connections. |
|
Signal emitted by the default QGLViewer::init() function. Connect this signal to the functions that need to be called before any drawing (if any), to initialize your viewer. Use this signal-slot mechanism ONLY IF you don't inherit your viewer from QGLViewer (in that case, simply overload the init() function). |
|
Using the wheel is equivalent to using the mouse middle button (a Zoom/Walk motion). See mousePressEvent() for details. Depending on your system configuration, you may have to actually click the wheel while . |
|
The camera that is used by the viewer. See the Camera() documentation for a complete description of the associated functions. |