SOFA API  b3f2f2a4
Open source framework for multi-physics simuation
QGLViewer Class Reference

#include <QGLViewer/qglviewer.h>

A versatile 3D OpenGL viewer based on QOpenGLWidget. More...

Inheritance diagram for QGLViewer:

Detailed Description

A versatile 3D OpenGL viewer based on QOpenGLWidget.

It features many classical viewer functionalities, such as a camera trackball, manipulated objects, snapshot saving and much more. Its main goal is to ease the development of new 3D applications.

New users should read the introduction page to get familiar with important notions such as sceneRadius(), sceneCenter() and the world coordinate system. Try the numerous simple examples to discover the possibilities and understand how it works.

Usage

To use a QGLViewer, derive you viewer class from the QGLViewer and overload its draw() virtual method. See the simpleViewer example for an illustration.

An other option is to connect your drawing methods to the signals emitted by the QGLViewer (Qt's callback mechanism). See the callback example for a complete implementation.

Public Member Functions

 QGLViewer (QWidget *parent=0, Qt::WindowFlags flags=Qt::WindowFlags())
 Constructor. More...
 
virtual ~QGLViewer ()
 Virtual destructor. More...
 

Keyboard customization

enum  KeyboardAction {
  DRAW_AXIS , DRAW_GRID , DISPLAY_FPS , ENABLE_TEXT ,
  EXIT_VIEWER , SAVE_SCREENSHOT , CAMERA_MODE , FULL_SCREEN ,
  STEREO , ANIMATION , HELP , EDIT_CAMERA ,
  MOVE_CAMERA_LEFT , MOVE_CAMERA_RIGHT , MOVE_CAMERA_UP , MOVE_CAMERA_DOWN ,
  INCREASE_FLYSPEED , DECREASE_FLYSPEED , SNAPSHOT_TO_CLIPBOARD
}
 Defines the different actions that can be associated with a keyboard shortcut using setShortcut(). More...
 
unsigned int shortcut (KeyboardAction action) const
 Returns the keyboard shortcut associated to a given QGLViewer::KeyboardAction. More...
 
unsigned int keyboardAccelerator (KeyboardAction action) const
 
Qt::Key keyFrameKey (unsigned int index) const
 
Qt::KeyboardModifiers playKeyFramePathStateKey () const
 
Qt::KeyboardModifiers addKeyFrameStateKey () const
 
Qt::KeyboardModifiers playPathStateKey () const
 
Qt::Key pathKey (unsigned int index) const
 Returns the keyboard key associated to camera Key Frame path index. More...
 
Qt::KeyboardModifiers addKeyFrameKeyboardModifiers () const
 Returns the keyboard modifiers that must be pressed with a pathKey() to add the current camera position to a KeyFrame path. More...
 
Qt::KeyboardModifiers playPathKeyboardModifiers () const
 Returns the keyboard modifiers that must be pressed with a pathKey() to play a camera KeyFrame path. More...
 
void setShortcut (KeyboardAction action, unsigned int key)
 Defines the shortcut() that triggers a given QGLViewer::KeyboardAction. More...
 
void setKeyboardAccelerator (KeyboardAction action, unsigned int key)
 
void setKeyDescription (unsigned int key, QString description)
 Defines a custom keyboard shortcut description, that will be displayed in the help() window Keyboard tab. More...
 
void clearShortcuts ()
 Clears all the default keyboard shortcuts. More...
 
virtual void setKeyFrameKey (unsigned int index, int key)
 
virtual void setPlayKeyFramePathStateKey (unsigned int buttonState)
 
virtual void setPlayPathStateKey (unsigned int buttonState)
 
virtual void setAddKeyFrameStateKey (unsigned int buttonState)
 
virtual void setPathKey (int key, unsigned int index=0)
 Sets the pathKey() associated with the camera Key Frame path index. More...
 
virtual void setPlayPathKeyboardModifiers (Qt::KeyboardModifiers modifiers)
 Sets the playPathKeyboardModifiers() value. More...
 
virtual void setAddKeyFrameKeyboardModifiers (Qt::KeyboardModifiers modifiers)
 Sets the addKeyFrameKeyboardModifiers() value. More...
 

Mouse customization

enum  MouseHandler { CAMERA , FRAME }
 Defines the different mouse handlers: camera() or manipulatedFrame(). More...
 
enum  ClickAction {
  NO_CLICK_ACTION , ZOOM_ON_PIXEL , ZOOM_TO_FIT , SELECT ,
  RAP_FROM_PIXEL , RAP_IS_CENTER , CENTER_FRAME , CENTER_SCENE ,
  SHOW_ENTIRE_SCENE , ALIGN_FRAME , ALIGN_CAMERA
}
 Defines the possible actions that can be binded to a mouse click using setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, ClickAction, bool, int). More...
 
enum  MouseAction {
  NO_MOUSE_ACTION , ROTATE , ZOOM , TRANSLATE ,
  MOVE_FORWARD , LOOK_AROUND , MOVE_BACKWARD , SCREEN_ROTATE ,
  ROLL , DRIVE , SCREEN_TRANSLATE , ZOOM_ON_REGION
}
 Defines the possible actions that can be binded to a mouse action (a click, followed by a mouse displacement). More...
 
MouseAction mouseAction (unsigned int state) const
 This method is deprecated since version 2.5.0. More...
 
int mouseHandler (unsigned int state) const
 This method is deprecated since version 2.5.0. More...
 
int mouseButtonState (MouseHandler handler, MouseAction action, bool withConstraint=true) const
 This method is deprecated since version 2.5.0. More...
 
ClickAction clickAction (unsigned int state, bool doubleClick, Qt::MouseButtons buttonsBefore) const
 This method is deprecated since version 2.5.0. More...
 
void getClickButtonState (ClickAction action, unsigned int &state, bool &doubleClick, Qt::MouseButtons &buttonsBefore) const
 This method is deprecated since version 2.5.0. More...
 
unsigned int wheelButtonState (MouseHandler handler, MouseAction action, bool withConstraint=true) const
 This method is deprecated since version 2.5.0. More...
 
MouseAction mouseAction (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const
 Returns the MouseAction the will be triggered when the mouse button is pressed, while the keyboard modifiers and key are pressed. More...
 
int mouseHandler (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const
 Returns the MouseHandler which will be activated when the mouse button is pressed, while the modifiers and key are pressed. More...
 
void getMouseActionBinding (MouseHandler handler, MouseAction action, bool withConstraint, Qt::Key &key, Qt::KeyboardModifiers &modifiers, Qt::MouseButton &button) const
 Returns the mouse and keyboard state that triggers action on handler withConstraint. More...
 
ClickAction clickAction (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton) const
 Same as mouseAction(), but for the ClickAction set using setMouseBinding(). More...
 
void getClickActionBinding (ClickAction action, Qt::Key &key, Qt::KeyboardModifiers &modifiers, Qt::MouseButton &button, bool &doubleClick, Qt::MouseButtons &buttonsBefore) const
 Returns the mouse and keyboard state that triggers action. More...
 
MouseAction wheelAction (Qt::Key key, Qt::KeyboardModifiers modifiers) const
 Returns the MouseAction (if any) that is performed when using the wheel, when the modifiers and key keyboard keys are pressed. More...
 
int wheelHandler (Qt::Key key, Qt::KeyboardModifiers modifiers) const
 Returns the MouseHandler (if any) that receives wheel events when the modifiers and key keyboard keys are pressed. More...
 
void getWheelActionBinding (MouseHandler handler, MouseAction action, bool withConstraint, Qt::Key &key, Qt::KeyboardModifiers &modifiers) const
 Returns the keyboard state that triggers action on handler withConstraint using the mouse wheel. More...
 
void setMouseBinding (unsigned int state, MouseHandler handler, MouseAction action, bool withConstraint=true)
 This method is deprecated since version 2.5.0. More...
 
void setMouseBinding (unsigned int state, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 This method is deprecated since version 2.5.0. More...
 
void setMouseBindingDescription (unsigned int state, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 This method is deprecated since version 2.5.0. More...
 
void setMouseBinding (Qt::KeyboardModifiers modifiers, Qt::MouseButton buttons, MouseHandler handler, MouseAction action, bool withConstraint=true)
 Defines a MouseAction binding. More...
 
void setMouseBinding (Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 Defines a ClickAction binding. More...
 
void setWheelBinding (Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true)
 Defines a mouse wheel binding. More...
 
void setMouseBindingDescription (Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 Defines a custom mouse binding description, displayed in the help() window's Mouse tab. More...
 
void setMouseBinding (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton buttons, MouseHandler handler, MouseAction action, bool withConstraint=true)
 Associates a MouseAction to any mouse button, while keyboard modifiers and key are pressed. More...
 
void setMouseBinding (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 Associates a ClickAction to a button and keyboard key and modifier(s) combination. More...
 
void setWheelBinding (Qt::Key key, Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true)
 Associates a MouseAction and a MouseHandler to a mouse wheel event. More...
 
void setMouseBindingDescription (Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
 Defines a custom mouse binding description, displayed in the help() window's Mouse tab. More...
 
void clearMouseBindings ()
 Clears all the default mouse bindings. More...
 
MouseAction wheelAction (Qt::KeyboardModifiers modifiers) const
 This method is deprecated since version 2.5.0. More...
 
int wheelHandler (Qt::KeyboardModifiers modifiers) const
 This method is deprecated since version 2.5.0. More...
 
void setHandlerKeyboardModifiers (MouseHandler handler, Qt::KeyboardModifiers modifiers)
 This method has been deprecated since version 2.5.0. More...
 
void setHandlerStateKey (MouseHandler handler, unsigned int buttonState)
 
void setMouseStateKey (MouseHandler handler, unsigned int buttonState)
 

Visual hints

virtual void setVisualHintsMask (int mask, int delay=2000)
 Defines the mask that will be used to drawVisualHints(). More...
 
virtual void drawVisualHints ()
 Draws viewer related visual hints. More...
 
virtual void resetVisualHints ()
 Reset the mask used by drawVisualHints(). More...
 

Display of visual hints

bool axisIsDrawn () const
 Returns true if the world axis is drawn by the viewer. More...
 
bool gridIsDrawn () const
 Returns true if a XY grid is drawn by the viewer. More...
 
bool FPSIsDisplayed () const
 Returns true if the viewer displays the current frame rate (Frames Per Second). More...
 
bool textIsEnabled () const
 Returns true if text display (see drawText()) is enabled. More...
 
bool cameraIsEdited () const
 Returns true if the camera() is being edited in the viewer. More...
 
void setAxisIsDrawn (bool draw=true)
 Sets the state of axisIsDrawn(). More...
 
void setGridIsDrawn (bool draw=true)
 Sets the state of gridIsDrawn(). More...
 
void setFPSIsDisplayed (bool display=true)
 Sets the state of FPSIsDisplayed(). More...
 
void setTextIsEnabled (bool enable=true)
 Sets the state of textIsEnabled(). More...
 
void setCameraIsEdited (bool edit=true)
 Starts (edit = true, default) or stops (edit=false) the edition of the camera(). More...
 
void toggleAxisIsDrawn ()
 Toggles the state of axisIsDrawn(). More...
 
void toggleGridIsDrawn ()
 Toggles the state of gridIsDrawn(). More...
 
void toggleFPSIsDisplayed ()
 Toggles the state of FPSIsDisplayed(). More...
 
void toggleTextIsEnabled ()
 Toggles the state of textIsEnabled(). More...
 
void toggleCameraIsEdited ()
 Toggles the state of cameraIsEdited(). More...
 

Viewer's colors

QColor backgroundColor () const
 Returns the background color of the viewer. More...
 
QColor foregroundColor () const
 Returns the foreground color used by the viewer. More...
 
void setBackgroundColor (const QColor &color)
 Sets the backgroundColor() of the viewer and calls qglClearColor(). More...
 
void setForegroundColor (const QColor &color)
 Sets the foregroundColor() of the viewer, used to draw visual hints. More...
 

Scene dimensions

qreal sceneRadius () const
 Returns the scene radius. More...
 
qglviewer::Vec sceneCenter () const
 Returns the scene center, defined in world coordinates. More...
 
virtual void setSceneRadius (qreal radius)
 Sets the sceneRadius(). More...
 
virtual void setSceneCenter (const qglviewer::Vec &center)
 Sets the sceneCenter(), defined in world coordinates. More...
 
void setSceneBoundingBox (const qglviewer::Vec &min, const qglviewer::Vec &max)
 Convenient way to call setSceneCenter() and setSceneRadius() from a (world axis aligned) bounding box of the scene. More...
 
void showEntireScene ()
 Moves the camera so that the entire scene is visible. More...
 

Associated objects

qglviewer::Cameracamera () const
 Returns the associated qglviewer::Camera, never nullptr. More...
 
qglviewer::ManipulatedFramemanipulatedFrame () const
 Returns the viewer's qglviewer::ManipulatedFrame. More...
 
void setCamera (qglviewer::Camera *const camera)
 Associates a new qglviewer::Camera to the viewer. More...
 
void setManipulatedFrame (qglviewer::ManipulatedFrame *frame)
 Sets the viewer's manipulatedFrame(). More...
 

Mouse grabbers

qglviewer::MouseGrabbermouseGrabber () const
 Returns the current qglviewer::MouseGrabber, or nullptr if no qglviewer::MouseGrabber currently grabs mouse events. More...
 
void setMouseGrabberIsEnabled (const qglviewer::MouseGrabber *const mouseGrabber, bool enabled=true)
 Sets the mouseGrabberIsEnabled() state. More...
 
bool mouseGrabberIsEnabled (const qglviewer::MouseGrabber *const mouseGrabber)
 Returns true if mouseGrabber is enabled. More...
 
void setMouseGrabber (qglviewer::MouseGrabber *mouseGrabber)
 Directly defines the mouseGrabber(). More...
 

State of the viewer

qreal aspectRatio () const
 Returns the aspect ratio of the viewer's widget (width() / height()). More...
 
qreal currentFPS ()
 Returns the current averaged viewer frame rate. More...
 
bool isFullScreen () const
 Returns true if the viewer is in fullScreen mode. More...
 
bool displaysInStereo () const
 Returns true if the viewer displays in stereo. More...
 
virtual QSize sizeHint () const
 Returns the recommended size for the QGLViewer. More...
 
void setFullScreen (bool fullScreen=true)
 Sets the isFullScreen() state. More...
 
void setStereoDisplay (bool stereo=true)
 Sets the state of displaysInStereo(). More...
 
void toggleFullScreen ()
 Toggles the state of isFullScreen(). More...
 
void toggleStereoDisplay ()
 Toggles the state of displaysInStereo(). More...
 
void toggleCameraMode ()
 Swaps between two predefined camera mouse bindings. More...
 

Display methods

virtual void startScreenCoordinatesSystem (bool upward=false) const
 Modify the projection matrix so that drawing can be done directly with 2D screen coordinates. More...
 
virtual void stopScreenCoordinatesSystem () const
 Stops the pixel coordinate drawing block started by startScreenCoordinatesSystem(). More...
 
void drawText (int x, int y, const QString &text, const QFont &fnt=QFont())
 Draws text at position x, y (expressed in screen coordinates pixels, origin in the upper left corner of the widget). More...
 
void displayMessage (const QString &message, int delay=2000)
 Briefly displays a message in the lower left corner of the widget. More...
 
static void drawArrow (qreal length=1.0, qreal radius=-1.0, int nbSubdivisions=12)
 Draws a 3D arrow along the positive Z axis. More...
 
static void drawArrow (const qglviewer::Vec &from, const qglviewer::Vec &to, qreal radius=-1.0, int nbSubdivisions=12)
 Draws a 3D arrow between the 3D point from and the 3D point to, both defined in the current ModelView coordinates system. More...
 
static void drawAxis (qreal length=1.0)
 Draws an XYZ axis, with a given size (default is 1.0). More...
 
static void drawGrid (qreal size=1.0, int nbSubdivisions=10)
 Draws a grid in the XY plane, centered on (0,0,0) (defined in the current coordinate system). More...
 
virtual void drawLight (GLenum light, qreal scale=1.0) const
 Draws a representation of light. More...
 
void drawVectorial (void *param)
 

Snapshots

const QString & snapshotFileName () const
 Returns the snapshot file name used by saveSnapshot(). More...
 
const QString & snapshotFilename () const
 
const QString & snapshotFormat () const
 Returns the snapshot file format used by saveSnapshot(). More...
 
int snapshotCounter () const
 Returns the value of the counter used to name snapshots in saveSnapshot() when automatic is true. More...
 
int snapshotQuality ()
 Defines the image quality of the snapshots produced with saveSnapshot(). More...
 
QFont scaledFont (const QFont &font) const
 Return a possibly scaled version of font, used for snapshot rendering. More...
 
void saveSnapshot (bool automatic=true, bool overwrite=false)
 Saves a snapshot of the current image displayed by the widget. More...
 
void saveSnapshot (const QString &fileName, bool overwrite=false)
 Same as saveSnapshot(), except that it uses fileName instead of snapshotFileName(). More...
 
void setSnapshotFileName (const QString &name)
 Sets snapshotFileName(). More...
 
void setSnapshotFormat (const QString &format)
 Sets the snapshotFormat(). More...
 
void setSnapshotCounter (int counter)
 Sets the snapshotCounter(). More...
 
void setSnapshotQuality (int quality)
 Sets the snapshotQuality(). More...
 
bool openSnapshotFormatDialog ()
 Opens a dialog that displays the different available snapshot formats. More...
 
void snapshotToClipboard ()
 Takes a snapshot of the current display and pastes it to the clipboard. More...
 

Buffer to texture

GLuint bufferTextureId () const
 Returns the texture id of the texture created by copyBufferToTexture(). More...
 
qreal bufferTextureMaxU () const
 Returns the texture coordinate corresponding to the u extremum of the bufferTexture. More...
 
qreal bufferTextureMaxV () const
 Same as bufferTextureMaxU(), but for the v texture coordinate. More...
 
void renderText (int x, int y, const QString &str, const QFont &font=QFont())
 
void renderText (double x, double y, double z, const QString &str, const QFont &font=QFont())
 
void copyBufferToTexture (GLint internalFormat, GLenum format=GL_NONE)
 Makes a copy of the current buffer into a texture. More...
 

Animation

bool animationIsStarted () const
 Return true when the animation loop is started. More...
 
int animationPeriod () const
 The animation loop period, in milliseconds. More...
 
void setAnimationPeriod (int period)
 Sets the animationPeriod(), in milliseconds. More...
 
virtual void startAnimation ()
 Starts the animation loop. More...
 
virtual void stopAnimation ()
 Stops animation. More...
 
virtual void animate ()
 Scene animation method. More...
 
void toggleAnimation ()
 Calls startAnimation() or stopAnimation(), depending on animationIsStarted(). More...
 
void viewerInitialized ()
 Signal emitted by the default init() method. More...
 
void drawNeeded ()
 Signal emitted by the default draw() method. More...
 
void drawFinished (bool automatic)
 Signal emitted at the end of the QGLViewer::paintGL() method, when frame is drawn. More...
 
void animateNeeded ()
 Signal emitted by the default animate() method. More...
 
void helpRequired ()
 Signal emitted by the default QGLViewer::help() method. More...
 
void axisIsDrawnChanged (bool drawn)
 This signal is emitted whenever axisIsDrawn() changes value. More...
 
void gridIsDrawnChanged (bool drawn)
 This signal is emitted whenever gridIsDrawn() changes value. More...
 
void FPSIsDisplayedChanged (bool displayed)
 This signal is emitted whenever FPSIsDisplayed() changes value. More...
 
void textIsEnabledChanged (bool enabled)
 This signal is emitted whenever textIsEnabled() changes value. More...
 
void cameraIsEditedChanged (bool edited)
 This signal is emitted whenever cameraIsEdited() changes value. More...
 
void stereoChanged (bool on)
 This signal is emitted whenever displaysInStereo() changes value. More...
 
void pointSelected (const QMouseEvent *e)
 Signal emitted by select(). More...
 
void mouseGrabberChanged (qglviewer::MouseGrabber *mouseGrabber)
 Signal emitted by setMouseGrabber() when the mouseGrabber() is changed. More...
 

Help window

virtual QString helpString () const
 Returns the QString displayed in the help() window main tab. More...
 
virtual QString mouseString () const
 Returns a QString that describes the application mouse bindings, displayed in the help() window Mouse tab. More...
 
virtual QString keyboardString () const
 Returns a QString that describes the application keyboard shortcut bindings, and that will be displayed in the help() window Keyboard tab. More...
 
virtual QString mouseBindingsString () const
 This method is deprecated, use mouseString() instead. More...
 
virtual QString shortcutBindingsString () const
 This method is deprecated, use keyboardString() instead. More...
 
virtual void help ()
 Opens a modal help window that includes four tabs, respectively filled with helpString(), keyboardString(), mouseString() and about libQGLViewer. More...
 
virtual void aboutQGLViewer ()
 Displays the help window "About" tab. More...
 
QTabWidget * helpWidget ()
 Returns a pointer to the help widget. More...
 

Object selection

int selectedName () const
 Returns the name (an integer value) of the entity that was last selected by select(). More...
 
int selectBufferSize () const
 Returns the selectBuffer() size. More...
 
int selectRegionWidth () const
 Returns the width (in pixels) of a selection frustum, centered on the mouse cursor, that is used to select objects. More...
 
int selectRegionHeight () const
 See the selectRegionWidth() documentation. More...
 
GLuint * selectBuffer ()
 Returns a pointer to an array of GLuint. More...
 
virtual void select (const QMouseEvent *event)
 Simple wrapper method: calls select(event->pos()). More...
 
virtual void select (const QPoint &point)
 This method performs a selection in the scene from pixel coordinates. More...
 
void setSelectBufferSize (int size)
 Sets the selectBufferSize(). More...
 
void setSelectRegionWidth (int width)
 Sets the selectRegionWidth(). More...
 
void setSelectRegionHeight (int height)
 Sets the selectRegionHeight(). More...
 
void setSelectedName (int id)
 Set the selectedName() value. More...
 
virtual void beginSelection (const QPoint &point)
 This method should prepare the selection. More...
 
virtual void drawWithNames ()
 This method is called by select() and should draw selectable entities. More...
 
virtual void endSelection (const QPoint &point)
 This method is called by select() after scene elements were drawn by drawWithNames(). More...
 
virtual void postSelection (const QPoint &point)
 This method is called at the end of the select() procedure. More...
 

State persistence

QString stateFileName () const
 Returns the state file name. More...
 
virtual QDomElement domElement (const QString &name, QDomDocument &document) const
 Returns an XML QDomElement that represents the QGLViewer. More...
 
virtual void initFromDOMElement (const QDomElement &element)
 Restores the QGLViewer state from a QDomElement created by domElement(). More...
 
virtual void saveStateToFile ()
 Saves in stateFileName() an XML representation of the QGLViewer state, obtained from domElement(). More...
 
virtual bool restoreStateFromFile ()
 Restores the QGLViewer state from the stateFileName() file using initFromDOMElement(). More...
 
void setStateFileName (const QString &name)
 Defines the stateFileName() used by saveStateToFile() and restoreStateFromFile(). More...
 
void saveToFile (const QString &fileName=QString())
 This method is deprecated since version 1.3.9-5. More...
 
bool restoreFromFile (const QString &fileName=QString())
 This function is deprecated since version 1.3.9-5. More...
 

QGLViewer pool

static const QList< QGLViewer * > & QGLViewerPool ()
 Returns a QList that contains pointers to all the created QGLViewers. More...
 
static int QGLViewerIndex (const QGLViewer *const viewer)
 Returns the index of the QGLViewer viewer in the QGLViewerPool(). More...
 

Drawing methods

virtual void resizeGL (int width, int height)
 Callback method used when the widget size is modified. More...
 
virtual void initializeGL ()
 Initializes the QGLViewer OpenGL context and then calls user-defined init(). More...
 
virtual void init ()
 Initializes the viewer OpenGL context. More...
 
virtual void paintGL ()
 Main paint method, inherited from QOpenGLWidget. More...
 
virtual void preDraw ()
 Sets OpenGL state before draw(). More...
 
virtual void preDrawStereo (bool leftBuffer=true)
 Called before draw() (instead of preDraw()) when viewer displaysInStereo(). More...
 
virtual void draw ()
 The core method of the viewer, that draws the scene. More...
 
virtual void fastDraw ()
 Draws a simplified version of the scene to guarantee interactive camera displacements. More...
 
virtual void postDraw ()
 Called after draw() to draw viewer visual hints. More...
 

Mouse, keyboard and event handlers

virtual void mousePressEvent (QMouseEvent *)
 Overloading of the QWidget method. More...
 
virtual void mouseMoveEvent (QMouseEvent *)
 Overloading of the QWidget method. More...
 
virtual void mouseReleaseEvent (QMouseEvent *)
 Overloading of the QWidget method. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 Overloading of the QWidget method. More...
 
virtual void wheelEvent (QWheelEvent *)
 Overloading of the QWidget method. More...
 
virtual void keyPressEvent (QKeyEvent *)
 Overloading of the QWidget method. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 
virtual void timerEvent (QTimerEvent *)
 Overloading of the QObject method. More...
 
virtual void closeEvent (QCloseEvent *)
 Overloading of the QWidget method. More...
 

Constructor details

◆ QGLViewer()

QGLViewer::QGLViewer ( QWidget parent = 0,
Qt::WindowFlags  flags = Qt::WindowFlags() 
)
explicit

Constructor.

See QGLWidget documentation for details.

All viewer parameters (display flags, scene parameters, associated objects...) are set to their default values. See the associated documentation.

◆ ~QGLViewer()

QGLViewer::~QGLViewer ( )
virtual

Virtual destructor.

The viewer is replaced by nullptr in the QGLViewerPool() (in order to preserve other viewer's indexes) and allocated memory is released. The camera() is deleted and should be copied before if it is shared by an other viewer.

Function details

◆ aboutQGLViewer

void QGLViewer::aboutQGLViewer ( )
virtualslot

Displays the help window "About" tab.

See help() for details.

◆ addKeyFrameKeyboardModifiers()

Qt::KeyboardModifiers QGLViewer::addKeyFrameKeyboardModifiers ( ) const

Returns the keyboard modifiers that must be pressed with a pathKey() to add the current camera position to a KeyFrame path.

It can be Qt::NoModifier, Qt::ControlModifier, Qt::ShiftModifier, Qt::AltModifier, Qt::MetaModifier or a combination of these (using the bitwise '|' operator).

Default value is Qt::AltModifier. Defined using setAddKeyFrameKeyboardModifiers().

See also playPathKeyboardModifiers().

◆ addKeyFrameStateKey()

Qt::KeyboardModifiers QGLViewer::addKeyFrameStateKey ( ) const

◆ animate

virtual void QGLViewer::animate ( )
inlinevirtualslot

Scene animation method.

When animationIsStarted(), this method is in charge of the scene update before each draw(). Overload it to define how your scene evolves over time. The time should either be regularly incremented in this method (frame-rate independent animation) or computed from actual time (for instance using QTime::elapsed()) for real-time animations.

Note that KeyFrameInterpolator (which regularly updates a Frame) does

not use this method to animate a Frame, but rather rely on a QTimer signal-slot mechanism.

See the animation example for an illustration.

◆ animateNeeded

void QGLViewer::animateNeeded ( )
signal

Signal emitted by the default animate() method.

Connect this signal to your scene animation method or overload animate().

◆ animationIsStarted()

bool QGLViewer::animationIsStarted ( ) const
inline

Return true when the animation loop is started.

During animation, an infinite loop calls animate() and draw() and then waits for animationPeriod() milliseconds before calling animate() and draw() again. And again.

Use startAnimation(), stopAnimation() or toggleAnimation() to change this value.

See the animation example for illustration.

◆ animationPeriod()

int QGLViewer::animationPeriod ( ) const
inline

The animation loop period, in milliseconds.

When animationIsStarted(), this is delay waited after draw() to call animate() and draw() again. Default value is 40 milliseconds (25 Hz).

This value will define the currentFPS() when animationIsStarted() (provided that your animate() and draw() methods are fast enough).

If you want to know the maximum possible frame rate of your machine on a given scene, setAnimationPeriod() to 0, and startAnimation() (keyboard shortcut is Enter). The display will then be updated as often as possible, and the frame rate will be meaningful.

Note
This value is taken into account only the next time you call startAnimation(). If animationIsStarted(), you should stopAnimation() first.

◆ aspectRatio()

qreal QGLViewer::aspectRatio ( ) const
inline

Returns the aspect ratio of the viewer's widget (width() / height()).

◆ axisIsDrawn()

bool QGLViewer::axisIsDrawn ( ) const
inline

Returns true if the world axis is drawn by the viewer.

Set by setAxisIsDrawn() or toggleAxisIsDrawn(). Default value is false.

◆ axisIsDrawnChanged

void QGLViewer::axisIsDrawnChanged ( bool  drawn)
signal

This signal is emitted whenever axisIsDrawn() changes value.

◆ backgroundColor()

QColor QGLViewer::backgroundColor ( ) const
inline

Returns the background color of the viewer.

This method is provided for convenience since the background color is an OpenGL state variable set with glClearColor(). However, this internal representation has the advantage that it is saved (resp. restored) with saveStateToFile() (resp. restoreStateFromFile()).

Use setBackgroundColor() to define and activate a background color.

Attention
Each QColor component is an integer ranging from 0 to 255. This differs from the qreal values used by glClearColor() which are in the 0.0-1.0 range. Default value is (51, 51, 51) (dark gray). You may have to change foregroundColor() accordingly.
This method does not return the current OpenGL clear color as glGet() does. Instead, it returns the QGLViewer internal variable. If you directly use glClearColor() or qglClearColor() instead of setBackgroundColor(), the two results will differ.

◆ beginSelection()

void QGLViewer::beginSelection ( const QPoint &  point)
protectedvirtual

This method should prepare the selection.

It is called by select() before drawWithNames().

The default implementation uses the GL_SELECT mode to perform a selection. It uses selectBuffer() and selectBufferSize() to define a glSelectBuffer(). The GL_PROJECTION is then set using gluPickMatrix(), with a window selection size defined by selectRegionWidth() and selectRegionHeight(). Finally, the GL_MODELVIEW matrix is set to the world coordinate system using qglviewer::Camera::loadModelViewMatrix(). See the gluPickMatrix() documentation for details.

You should not need to redefine this method (if you use the GL_SELECT mode to perform your selection), since this code is fairly classical and can be tuned. You are more likely to overload endSelection() if you want to use a more complex select buffer structure.

◆ bufferTextureId()

GLuint QGLViewer::bufferTextureId ( ) const

Returns the texture id of the texture created by copyBufferToTexture().

Use glBindTexture() to use this texture. Note that this is already done by copyBufferToTexture().

Returns 0 is copyBufferToTexture() was never called or if the texure was deleted using glDeleteTextures() since then.

◆ bufferTextureMaxU()

qreal QGLViewer::bufferTextureMaxU ( ) const
inline

Returns the texture coordinate corresponding to the u extremum of the bufferTexture.

The bufferTexture is created by copyBufferToTexture(). The texture size has powers of two dimensions and the buffer image hence only fills a part of it. This value corresponds to the u coordinate of the extremum right side of the buffer image.

Use (0,0) to (bufferTextureMaxU(), bufferTextureMaxV()) texture coordinates to map the entire texture on a quad.

◆ bufferTextureMaxV()

qreal QGLViewer::bufferTextureMaxV ( ) const
inline

Same as bufferTextureMaxU(), but for the v texture coordinate.

◆ camera()

qglviewer::Camera* QGLViewer::camera ( ) const
inline

Returns the associated qglviewer::Camera, never nullptr.

◆ cameraIsEdited()

bool QGLViewer::cameraIsEdited ( ) const
inline

Returns true if the camera() is being edited in the viewer.

Set by setCameraIsEdited() or toggleCameraIsEdited(). Default value is false.

The current implementation is limited: the defined camera() paths (see qglviewer::Camera::keyFrameInterpolator()) are simply displayed using qglviewer::Camera::drawAllPaths(). Actual camera and path edition will be implemented in the future.

◆ cameraIsEditedChanged

void QGLViewer::cameraIsEditedChanged ( bool  edited)
signal

This signal is emitted whenever cameraIsEdited() changes value.

◆ clearMouseBindings

void QGLViewer::clearMouseBindings ( )
slot

Clears all the default mouse bindings.

After this call, you will have to use setMouseBinding() and setWheelBinding() to restore the mouse bindings you are interested in.

◆ clearShortcuts

void QGLViewer::clearShortcuts ( )
slot

Clears all the default keyboard shortcuts.

After this call, you will have to use setShortcut() to define your own keyboard shortcuts.

◆ clickAction() [1/2]

QGLViewer::ClickAction QGLViewer::clickAction ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
) const

Same as mouseAction(), but for the ClickAction set using setMouseBinding().

Returns NO_CLICK_ACTION if no click action is associated with this keyboard and mouse buttons combination.

◆ clickAction() [2/2]

QGLViewer::ClickAction QGLViewer::clickAction ( unsigned int  state,
bool  doubleClick,
Qt::MouseButtons  buttonsBefore 
) const

This method is deprecated since version 2.5.0.

Use clickAction(Qt::KeyboardModifiers, Qt::MouseButtons, bool, Qt::MouseButtons) instead.

◆ closeEvent()

void QGLViewer::closeEvent ( QCloseEvent *  e)
protectedvirtual

Overloading of the QWidget method.

Saves the viewer state using saveStateToFile() and then calls QOpenGLWidget::closeEvent().

◆ copyBufferToTexture

void QGLViewer::copyBufferToTexture ( GLint  internalFormat,
GLenum  format = GL_NONE 
)
slot

Makes a copy of the current buffer into a texture.

Creates a texture (when needed) and uses glCopyTexSubImage2D() to directly copy the buffer in it.

Use internalFormat and format to define the texture format and hence which and how components of the buffer are copied into the texture. See the glTexImage2D() documentation for details.

When format is c GL_NONE (default), its value is set to internalFormat, which fits most cases. Typical internalFormat (and format) values are GL_DEPTH_COMPONENT and GL_RGBA. Use GL_LUMINANCE as the internalFormat and GL_RED, GL_GREEN or GL_BLUE as format to capture a single color component as a luminance (grey scaled) value. Note that GL_STENCIL is not supported as a format.

The texture has dimensions which are powers of two. It is as small as possible while always being larger or equal to the current size of the widget. The buffer image hence does not entirely fill the texture: it is stuck to the lower left corner (corresponding to the (0,0) texture coordinates). Use bufferTextureMaxU() and bufferTextureMaxV() to get the upper right corner maximum u and v texture coordinates. Use bufferTextureId() to retrieve the id of the created texture.

Here is how to display a grey-level image of the z-buffer:

copyBufferToTexture(GL_DEPTH_COMPONENT);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2i(0, 0);
glTexCoord2f(bufferTextureMaxU(), 0.0); glVertex2i(width(), 0);
glTexCoord2f(bufferTextureMaxU(), bufferTextureMaxV()); glVertex2i(width(),
height()); glTexCoord2f(0.0, bufferTextureMaxV()); glVertex2i(0,
height()); glEnd();
glDisable(GL_TEXTURE_2D);
qreal bufferTextureMaxU() const
Returns the texture coordinate corresponding to the u extremum of the bufferTexture.
Definition: qglviewer.h:626
qreal bufferTextureMaxV() const
Same as bufferTextureMaxU(), but for the v texture coordinate.
Definition: qglviewer.h:628
void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE)
Makes a copy of the current buffer into a texture.
Definition: qglviewer.cpp:4134
virtual void stopScreenCoordinatesSystem() const
Stops the pixel coordinate drawing block started by startScreenCoordinatesSystem().
Definition: qglviewer.cpp:965
virtual void startScreenCoordinatesSystem(bool upward=false) const
Modify the projection matrix so that drawing can be done directly with 2D screen coordinates.
Definition: qglviewer.cpp:938

Use glReadBuffer() to select which buffer is copied into the texture. See also glPixelTransfer(), glPixelZoom() and glCopyPixel() for pixel color transformations during copy.

Call makeCurrent() before this method to make the OpenGL context active if needed.

Note
The GL_DEPTH_COMPONENT format may not be supported by all hardware. It may sometimes be emulated in software, resulting in poor performances.
The bufferTextureId() texture is binded at the end of this method.

◆ currentFPS()

qreal QGLViewer::currentFPS ( )
inline

Returns the current averaged viewer frame rate.

This value is computed and averaged over 20 successive frames. It only changes every 20 draw() (previously computed value is otherwise returned).

This method is useful for true real-time applications that may adapt their computational load accordingly in order to maintain a given frequency.

This value is meaningful only when draw() is regularly called, either using a QTimer, when animationIsStarted() or when the camera is manipulated with the mouse.

◆ displayMessage()

void QGLViewer::displayMessage ( const QString &  message,
int  delay = 2000 
)

Briefly displays a message in the lower left corner of the widget.

Convenient to provide feedback to the user.

message is displayed during delay milliseconds (default is 2 seconds) using drawText().

This method should not be called in draw(). If you want to display a text in each draw(), use drawText() instead.

If this method is called when a message is already displayed, the new message replaces the old one. Use setTextIsEnabled() (default shortcut is '?') to enable or disable text (and hence messages) display.

◆ displaysInStereo()

bool QGLViewer::displaysInStereo ( ) const
inline

Returns true if the viewer displays in stereo.

The QGLViewer object must be created with a stereo format to handle stereovision:

QGLFormat format; format.setStereoDisplay( TRUE );
QGLViewer viewer(format);
A versatile 3D OpenGL viewer based on QOpenGLWidget.
Definition: qglviewer.h:70

The hardware needs to support stereo display. Try the stereoViewer example to check.

Set by setStereoDisplay() or toggleStereoDisplay(). Default value is false.

Stereo is performed using the Parallel axis asymmetric frustum perspective projection method. See Camera::loadProjectionMatrixStereo() and Camera::loadModelViewMatrixStereo().

The stereo parameters are defined by the camera(). See qglviewer::Camera::setIODistance(), qglviewer::Camera::setPhysicalScreenWidth() and qglviewer::Camera::setFocusDistance().

◆ domElement()

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

Returns an XML QDomElement that represents the QGLViewer.

Used by saveStateToFile(). restoreStateFromFile() uses initFromDOMElement() to restore the QGLViewer state from the resulting QDomElement.

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

The created QDomElement contains state values (axisIsDrawn(), FPSIsDisplayed(), isFullScreen()...), viewer geometry, as well as camera() (see qglviewer::Camera::domElement()) and manipulatedFrame() (if defined, see qglviewer::ManipulatedFrame::domElement()) states.

Overload this method to add your own attributes to the state file:

QDomElement Viewer::domElement(const QString& name, QDomDocument& document)
const
{
// Creates a custom node for a light
QDomElement de = document.createElement("Light");
de.setAttribute("state", (lightIsOn()?"on":"off"));
// Note the include of the ManipulatedFrame domElement method.
de.appendChild(lightManipulatedFrame()->domElement("LightFrame", document));
// Get default state domElement and append custom node
QDomElement res = QGLViewer::domElement(name, document);
res.appendChild(de);
return res;
}
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Returns an XML QDomElement that represents the QGLViewer.
Definition: qglviewer.cpp:3882

See initFromDOMElement() for the associated restoration code.

Attention
For the manipulatedFrame(), qglviewer::Frame::constraint() and qglviewer::Frame::referenceFrame() are not saved. See qglviewer::Frame::domElement().

◆ draw()

virtual void QGLViewer::draw ( )
inlineprotectedvirtual

The core method of the viewer, that draws the scene.

If you build a class that inherits from QGLViewer, this is the method you want to overload. See the simpleViewer example for an illustration.

The camera modelView matrix set in preDraw() converts from the world to the camera coordinate systems. Vertices given in draw() can then be considered as being given in the world coordinate system. The camera is moved in this world using the mouse. This representation is much more intuitive than the default camera-centric OpenGL standard.

Attention
The GL_PROJECTION matrix should not be modified by this method, to correctly display visual hints (axis, grid, FPS...) in postDraw(). Use push/pop or call camera()->loadProjectionMatrix() at the end of draw() if you need to change the projection matrix (unlikely). On the other hand, the GL_MODELVIEW matrix can be modified and left in a arbitrary state.

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ drawArrow() [1/2]

void QGLViewer::drawArrow ( const qglviewer::Vec from,
const qglviewer::Vec to,
qreal  radius = -1.0,
int  nbSubdivisions = 12 
)
static

Draws a 3D arrow between the 3D point from and the 3D point to, both defined in the current ModelView coordinates system.

See drawArrow(qreal length, qreal radius, int nbSubdivisions) for details.

◆ drawArrow() [2/2]

void QGLViewer::drawArrow ( qreal  length = 1.0,
qreal  radius = -1.0,
int  nbSubdivisions = 12 
)
static

Draws a 3D arrow along the positive Z axis.

length, radius and nbSubdivisions define its geometry. If radius is negative (default), it is set to 0.05 * length.

Use drawArrow(const Vec& from, const Vec& to, qreal radius, int nbSubdivisions) or change the ModelView matrix to place the arrow in 3D.

Uses current color and does not modify the OpenGL state.

◆ drawAxis()

void QGLViewer::drawAxis ( qreal  length = 1.0)
static

Draws an XYZ axis, with a given size (default is 1.0).

The axis position and orientation matches the current modelView matrix state: three arrows (red, green and blue) of length length are drawn along the positive X, Y and Z directions.

Use the following code to display the current position and orientation of a qglviewer::Frame:

glPushMatrix(); glMultMatrixd(frame.matrix());
QGLViewer::drawAxis(sceneRadius() / 5.0); // Or any scale
glPopMatrix();
static void drawAxis(qreal length=1.0)
Draws an XYZ axis, with a given size (default is 1.0).
Definition: qglviewer.cpp:3591
qreal sceneRadius() const
Returns the scene radius.
Definition: qglviewer.h:231

The current color and line width are used to draw the X, Y and Z characters at the extremities of the three arrows. The OpenGL state is not modified by this method.

axisIsDrawn() uses this method to draw a representation of the world coordinate system. See also QGLViewer::drawArrow() and QGLViewer::drawGrid().

◆ drawFinished

void QGLViewer::drawFinished ( bool  automatic)
signal

Signal emitted at the end of the QGLViewer::paintGL() method, when frame is drawn.

Can be used to notify an image grabbing process that the image is ready. A typical example is to connect this signal to the saveSnapshot() method, so that a (numbered) snapshot is generated after each new display, in order to create a movie:

connect(viewer, SIGNAL(drawFinished(bool)),
SLOT(saveSnapshot(bool)));
void drawFinished(bool automatic)
Signal emitted at the end of the QGLViewer::paintGL() method, when frame is drawn.
void saveSnapshot(bool automatic=true, bool overwrite=false)
Saves a snapshot of the current image displayed by the widget.
Definition: saveSnapshot.cpp:553

The automatic bool variable is always true and has been added so that the signal can be connected to saveSnapshot() with an automatic value set to true.

◆ drawGrid()

void QGLViewer::drawGrid ( qreal  size = 1.0,
int  nbSubdivisions = 10 
)
static

Draws a grid in the XY plane, centered on (0,0,0) (defined in the current coordinate system).

size (OpenGL units) and nbSubdivisions define its geometry. Set the GL_MODELVIEW matrix to place and orientate the grid in 3D space (see the drawAxis() documentation).

The OpenGL state is not modified by this method.

◆ drawLight()

void QGLViewer::drawLight ( GLenum  light,
qreal  scale = 1.0 
) const
protectedvirtual

Draws a representation of light.

Called in draw(), this method is useful to debug or display your light setup. Light drawing depends on the type of light (point, spot, directional).

The method retrieves the light setup using glGetLightfv. Position and define your lights before calling this method.

Light is drawn using its diffuse color. Disabled lights are not displayed.

Drawing size is proportional to sceneRadius(). Use scale to rescale it.

See the drawLight example for an illustration.

Attention
You need to enable GL_COLOR_MATERIAL before calling this method. glColor is set to the light diffuse color.

◆ drawNeeded

void QGLViewer::drawNeeded ( )
signal

Signal emitted by the default draw() method.

Connect this signal to your main drawing method or overload draw(). See the callback example for an illustration.

◆ drawText()

void QGLViewer::drawText ( int  x,
int  y,
const QString &  text,
const QFont &  fnt = QFont() 
)

Draws text at position x, y (expressed in screen coordinates pixels, origin in the upper left corner of the widget).

The default QApplication::font() is used to render the text when no fnt is specified. Use QApplication::setFont() to define this default font.

You should disable GL_LIGHTING and GL_DEPTH_TEST before this method so that colors are properly rendered.

This method can be used in conjunction with the qglviewer::Camera::projectedCoordinatesOf() method to display a text attached to an object. In your draw() method use:

qglviewer::Vec screenPos =
camera()->projectedCoordinatesOf(myFrame.position());
drawText((int)screenPos[0], (int)screenPos[1], "My Object");
qglviewer::Camera * camera() const
Returns the associated qglviewer::Camera, never nullptr.
Definition: qglviewer.h:286
void drawText(int x, int y, const QString &text, const QFont &fnt=QFont())
Draws text at position x, y (expressed in screen coordinates pixels, origin in the upper left corner ...
Definition: qglviewer.cpp:842
Vec projectedCoordinatesOf(const Vec &src, const Frame *frame=nullptr) const
Returns the screen projected coordinates of a point src defined in the frame coordinate system.
Definition: camera.cpp:1612
The Vec class represents 3D positions and 3D vectors.
Definition: vec.h:65

See the screenCoordSystem example for an illustration.

Text is displayed only when textIsEnabled() (default). This mechanism allows the user to conveniently remove all the displayed text with a single keyboard shortcut.

See also displayMessage() to drawText() for only a short amount of time.

Use renderText(x,y,z, text) instead if you want to draw a text located at a specific 3D position instead of 2D screen coordinates (fixed size text, facing the camera).

The GL_MODELVIEW and GL_PROJECTION matrices are not modified by this method.

◆ drawVisualHints()

void QGLViewer::drawVisualHints ( )
virtual

Draws viewer related visual hints.

Displays the new qglviewer::Camera::pivotPoint() when it is changed. See the mouse page for details. Also draws a line between qglviewer::Camera::pivotPoint() and mouse cursor when the camera is rotated around the camera Z axis.

See also setVisualHintsMask() and resetVisualHints(). The hint color is foregroundColor().

Note
These methods may become more interesting one day. The current design is too limited and should be improved when other visual hints must be drawn.

Limitation : One needs to have access to visualHint_ to overload this method.

Removed from the documentation for this reason.

◆ drawWithNames()

virtual void QGLViewer::drawWithNames ( )
inlineprotectedvirtual

This method is called by select() and should draw selectable entities.

Default implementation is empty. Overload and draw the different elements of your scene you want to be able to select. The default select() implementation relies on the GL_SELECT, and requires that each selectable element is drawn within a glPushName() - glPopName() block. A typical usage would be (see the select example):

void
Viewer::drawWithNames() { for (int i=0; i<nbObjects; ++i) { glPushName(i);
object(i)->draw();
glPopName();
}
}

The resulting selected name is computed by endSelection(), which setSelectedName() to the integer id pushed by this method (a value of -1 means no selection). Use selectedName() to update your selection, probably in the postSelection() method.

Attention
If your selected objects are points, do not use glBegin(GL_POINTS); and glVertex3fv() in the above draw() method (not compatible with raster mode): use glRasterPos3fv() instead.

◆ endSelection()

void QGLViewer::endSelection ( const QPoint &  point)
protectedvirtual

This method is called by select() after scene elements were drawn by drawWithNames().

It should analyze the selection result to determine which object is actually selected.

The default implementation relies on GL_SELECT mode (see beginSelection()). It assumes that names were pushed and popped in drawWithNames(), and analyzes the selectBuffer() to find the name that corresponds to the closer (z min) object. It then setSelectedName() to this value, or to -1 if the selectBuffer() is empty (no object drawn in selection region). Use selectedName() (probably in the postSelection() method) to retrieve this value and update your data structure accordingly.

This default implementation, although sufficient for many cases is however limited and you may have to overload this method. This will be the case if drawWithNames() uses several push levels in the name heap. A more precise depth selection, for instance privileging points over edges and triangles to avoid z precision problems, will also require an overloading. A typical implementation will look like:

glFlush();
// Get the number of objects that were seen through the pick matrix frustum.
// Resets GL_RENDER mode.
GLint nbHits = glRenderMode(GL_RENDER);
if (nbHits <= 0)
else
{
// Interpret results: each object created values in the selectBuffer().
// See the glSelectBuffer() man page for details on the buffer structure.
// The following code depends on your selectBuffer() structure.
for (int i=0; i<nbHits; ++i)
if ((selectBuffer())[i*4+1] < zMin)
}
void setSelectedName(int id)
Set the selectedName() value.
Definition: qglviewer.h:943
GLuint * selectBuffer()
Returns a pointer to an array of GLuint.
Definition: qglviewer.h:928

See the multiSelect example for a multi-object selection implementation of this method.

◆ fastDraw()

void QGLViewer::fastDraw ( )
protectedvirtual

Draws a simplified version of the scene to guarantee interactive camera displacements.

This method is called instead of draw() when the qglviewer::Camera::frame() is qglviewer::ManipulatedCameraFrame::isManipulated(). Default implementation simply calls draw().

Overload this method if your scene is too complex to allow for interactive camera manipulation. See the fastDraw example for an illustration.

◆ foregroundColor()

QColor QGLViewer::foregroundColor ( ) const
inline

Returns the foreground color used by the viewer.

This color is used when FPSIsDisplayed(), gridIsDrawn(), to display the camera paths when the cameraIsEdited().

Attention
Each QColor component is an integer in the range 0-255. This differs from the qreal values used by glColor3f() which are in the range 0-1. Default value is (180, 180, 180) (light gray).

Use qglColor(foregroundColor()) to set the current OpenGL color to the foregroundColor().

See also backgroundColor().

◆ FPSIsDisplayed()

bool QGLViewer::FPSIsDisplayed ( ) const
inline

Returns true if the viewer displays the current frame rate (Frames Per Second).

Use QApplication::setFont() to define the display font (see drawText()).

Set by setFPSIsDisplayed() or toggleFPSIsDisplayed(). Use currentFPS() to get the current FPS. Default value is false.

◆ FPSIsDisplayedChanged

void QGLViewer::FPSIsDisplayedChanged ( bool  displayed)
signal

This signal is emitted whenever FPSIsDisplayed() changes value.

◆ getClickActionBinding()

void QGLViewer::getClickActionBinding ( ClickAction  action,
Qt::Key &  key,
Qt::KeyboardModifiers &  modifiers,
Qt::MouseButton &  button,
bool doubleClick,
Qt::MouseButtons &  buttonsBefore 
) const

Returns the mouse and keyboard state that triggers action.

If such a binding exists, results are stored in the key, modifiers, button, doubleClick and buttonsBefore parameters. If the ClickAction action is not bound, button is set to Qt::NoButton. If several mouse buttons trigger in the ClickAction, one of them is returned.

See also setMouseBinding(), getMouseActionBinding() and getWheelActionBinding().

◆ getClickButtonState()

void QGLViewer::getClickButtonState ( ClickAction  action,
unsigned int &  state,
bool doubleClick,
Qt::MouseButtons &  buttonsBefore 
) const

This method is deprecated since version 2.5.0.

Use getClickActionState(ClickAction, Qt::Key, Qt::KeyboardModifiers, Qt::MouseButton, bool, Qt::MouseButtons) instead.

◆ getMouseActionBinding()

void QGLViewer::getMouseActionBinding ( MouseHandler  handler,
MouseAction  action,
bool  withConstraint,
Qt::Key &  key,
Qt::KeyboardModifiers &  modifiers,
Qt::MouseButton &  button 
) const

Returns the mouse and keyboard state that triggers action on handler withConstraint.

If such a binding exists, results are stored in the key, modifiers and button parameters. If the MouseAction action is not bound, button is set to Qt::NoButton. If several mouse and keyboard states trigger the MouseAction, one of them is returned.

See also setMouseBinding(), getClickActionBinding() and getWheelActionBinding().

◆ getWheelActionBinding()

void QGLViewer::getWheelActionBinding ( MouseHandler  handler,
MouseAction  action,
bool  withConstraint,
Qt::Key &  key,
Qt::KeyboardModifiers &  modifiers 
) const

Returns the keyboard state that triggers action on handler withConstraint using the mouse wheel.

If such a binding exists, results are stored in the key and modifiers parameters. If the MouseAction action is not bound, key is set to the illegal -1 value. If several keyboard states trigger the MouseAction, one of them is returned.

See also setMouseBinding(), getClickActionBinding() and getMouseActionBinding().

◆ gridIsDrawn()

bool QGLViewer::gridIsDrawn ( ) const
inline

Returns true if a XY grid is drawn by the viewer.

Set by setGridIsDrawn() or toggleGridIsDrawn(). Default value is false.

◆ gridIsDrawnChanged

void QGLViewer::gridIsDrawnChanged ( bool  drawn)
signal

This signal is emitted whenever gridIsDrawn() changes value.

◆ help

void QGLViewer::help ( )
virtualslot

Opens a modal help window that includes four tabs, respectively filled with helpString(), keyboardString(), mouseString() and about libQGLViewer.

Rich html-like text can be used (see the QStyleSheet documentation). This method is called when the user presses the QGLViewer::HELP key (default is 'H').

You can use helpWidget() to access to the help widget (to add/remove tabs, change layout...).

The helpRequired() signal is emitted.

◆ helpRequired

void QGLViewer::helpRequired ( )
signal

Signal emitted by the default QGLViewer::help() method.

Connect this signal to your own help method or overload help().

◆ helpString()

virtual QString QGLViewer::helpString ( ) const
inlinevirtual

Returns the QString displayed in the help() window main tab.

Overload this method to define your own help string, which should shortly describe your application and explain how it works. Rich-text (HTML) tags can be used (see QStyleSheet() documentation for available tags):

QString
myViewer::helpString() const
{
QString text("<h2>M y V i e w e r</h2>");
text += "Displays a <b>Scene</b> using OpenGL. Move the camera using the
mouse."; return text;
}

See also mouseString() and keyboardString().

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ helpWidget()

QTabWidget* QGLViewer::helpWidget ( )
inlineprotected

Returns a pointer to the help widget.

Use this only if you want to directly modify the help widget. Otherwise use helpString(), setKeyDescription() and setMouseBindingDescription() to customize the text displayed in the help window tabs.

◆ init()

virtual void QGLViewer::init ( void  )
inlineprotectedvirtual

Initializes the viewer OpenGL context.

This method is called before the first drawing and should be overloaded to initialize some of the OpenGL flags. The default implementation is empty. See initializeGL().

Typical usage include camera() initialization (showEntireScene()), previous viewer state restoration (restoreStateFromFile()), OpenGL state modification and display list creation.

Note that initializeGL() modifies the standard OpenGL context. These values can be restored back in this method.

Attention
You should not call updateGL() (or any method that calls it) in this method, as it will result in an infinite loop. The different QGLViewer set methods (setAxisIsDrawn(), setFPSIsDisplayed()...) are protected against this problem and can safely be called.
Note
All the OpenGL specific initializations must be done in this method: the OpenGL context is not yet available in your viewer constructor.

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ initFromDOMElement

void QGLViewer::initFromDOMElement ( const QDomElement &  element)
virtualslot

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

Used by restoreStateFromFile() to restore the QGLViewer state from a file.

Overload this method to retrieve custom attributes from the QGLViewer state file. This code corresponds to the one given in the domElement() documentation:

void Viewer::initFromDOMElement(const QDomElement& element)
{
// Restore standard state
QDomElement child=element.firstChild().toElement();
while (!child.isNull())
{
if (child.tagName() == "Light")
{
if (child.hasAttribute("state"))
setLightOn(child.attribute("state").toLower() == "on");
// Assumes there is only one child. Otherwise you need to parse child's children
recursively. QDomElement lf = child.firstChild().toElement(); if (!lf.isNull()
&& lf.tagName() == "LightFrame")
lightManipulatedFrame()->initFromDomElement(lf);
}
child = child.nextSibling().toElement();
}
}
virtual void initFromDOMElement(const QDomElement &element)
Restores the QGLViewer state from a QDomElement created by domElement().
Definition: qglviewer.cpp:3969

See also qglviewer::Camera::initFromDOMElement(), qglviewer::ManipulatedFrame::initFromDOMElement().

Note
The manipulatedFrame() pointer is not modified by this method. If defined, its state is simply set from the element values.

◆ initializeGL()

void QGLViewer::initializeGL ( void  )
protectedvirtual

Initializes the QGLViewer OpenGL context and then calls user-defined init().

This method is automatically called once, before the first call to paintGL().

Overload init() instead of this method to modify viewer specific OpenGL state or to create display lists.

To make beginners' life easier and to simplify the examples, this method slightly modifies the standard OpenGL state:

glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);

If you port an existing application to QGLViewer and your display changes, you probably want to disable these flags in init() to get back to a standard OpenGL state.

◆ isFullScreen()

bool QGLViewer::isFullScreen ( ) const
inline

Returns true if the viewer is in fullScreen mode.

Default value is false. Set by setFullScreen() or toggleFullScreen().

Note that if the QGLViewer is embedded in an other QWidget, it returns true when the top level widget is in full screen mode.

◆ keyboardAccelerator()

unsigned int QGLViewer::keyboardAccelerator ( KeyboardAction  action) const

◆ keyboardString()

QString QGLViewer::keyboardString ( ) const
virtual

Returns a QString that describes the application keyboard shortcut bindings, and that will be displayed in the help() window Keyboard tab.

Default value is a table that describes the custom shortcuts defined using setKeyDescription() as well as the standard QGLViewer::KeyboardAction shortcuts (defined using setShortcut()). See the keyboard page for details on key customization.

See also helpString() and mouseString().

◆ keyFrameKey()

Qt::Key QGLViewer::keyFrameKey ( unsigned int  index) const

◆ keyPressEvent()

void QGLViewer::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

Overloading of the QWidget method.

Default keyboard shortcuts are defined using setShortcut(). Overload this method to implement a specific keyboard binding. Call the original method if you do not catch the event to preserve the viewer default key bindings:

void
Viewer::keyPressEvent(QKeyEvent *e)
{
// Defines the Alt+R shortcut.
if ((e->key() == Qt::Key_R) && (e->modifiers() == Qt::AltModifier))
{
myResetFunction();
update(); // Refresh display
}
else
}
// With Qt 2 or 3, you would retrieve modifiers keys using :
// const Qt::ButtonState modifiers = (Qt::ButtonState)(e->state() &
Qt::KeyButtonMask);
virtual void keyPressEvent(QKeyEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:2268

When you define a new keyboard shortcut, use setKeyDescription() to provide a short description which is displayed in the help() window Keyboard tab. See the keyboardAndMouse example for an illustration.

See also QOpenGLWidget::keyReleaseEvent().

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ keyReleaseEvent()

void QGLViewer::keyReleaseEvent ( QKeyEvent *  e)
protectedvirtual

◆ manipulatedFrame()

qglviewer::ManipulatedFrame* QGLViewer::manipulatedFrame ( ) const
inline

Returns the viewer's qglviewer::ManipulatedFrame.

This qglviewer::ManipulatedFrame can be moved with the mouse when the associated mouse bindings are used (default is when pressing the Control key with any mouse button). Use setMouseBinding() to define new bindings.

See the manipulatedFrame example for a complete implementation.

Default value is nullptr, meaning that no qglviewer::ManipulatedFrame is set.

◆ mouseAction() [1/2]

QGLViewer::MouseAction QGLViewer::mouseAction ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button 
) const

Returns the MouseAction the will be triggered when the mouse button is pressed, while the keyboard modifiers and key are pressed.

Returns QGLViewer::NO_MOUSE_ACTION if no action is associated with this combination. Use 0 for key to indicate that no regular key needs to be pressed.

For instance, to know which motion corresponds to Alt+LeftButton, do:

QGLViewer::MouseAction ma = mouseAction(0, Qt::AltModifier, Qt::LeftButton);
MouseAction
Defines the possible actions that can be binded to a mouse action (a click, followed by a mouse displ...
Definition: qglviewer.h:1082
@ NO_MOUSE_ACTION
Definition: qglviewer.h:1083
MouseAction mouseAction(unsigned int state) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:3008

Use mouseHandler() to know which object (QGLViewer::CAMERA or QGLViewer::FRAME) will execute this action.

◆ mouseAction() [2/2]

QGLViewer::MouseAction QGLViewer::mouseAction ( unsigned int  state) const

This method is deprecated since version 2.5.0.

Use mouseAction(Qt::Key, Qt::KeyboardModifiers, Qt::MouseButtons) instead.

◆ mouseBindingsString()

virtual QString QGLViewer::mouseBindingsString ( ) const
inlinevirtual

This method is deprecated, use mouseString() instead.

◆ mouseButtonState()

int QGLViewer::mouseButtonState ( MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
) const

This method is deprecated since version 2.5.0.

Use mouseButtons() and keyboardModifiers() instead.

◆ mouseDoubleClickEvent()

void QGLViewer::mouseDoubleClickEvent ( QMouseEvent *  e)
protectedvirtual

Overloading of the QWidget method.

The behavior of the mouse double click depends on the mouse binding. See setMouseBinding() and the mouse page.

◆ mouseGrabber()

qglviewer::MouseGrabber* QGLViewer::mouseGrabber ( ) const
inline

Returns the current qglviewer::MouseGrabber, or nullptr if no qglviewer::MouseGrabber currently grabs mouse events.

When qglviewer::MouseGrabber::grabsMouse(), the different mouse events are sent to the mouseGrabber() instead of their usual targets (camera() or manipulatedFrame()).

See the qglviewer::MouseGrabber documentation for details on MouseGrabber's mode of operation.

In order to use MouseGrabbers, you need to enable mouse tracking (so that mouseMoveEvent() is called even when no mouse button is pressed). Add this line in init() or in your viewer constructor:

setMouseTracking(true);

Note that mouse tracking is disabled by default. Use QWidget::hasMouseTracking() to retrieve current state.

◆ mouseGrabberChanged

void QGLViewer::mouseGrabberChanged ( qglviewer::MouseGrabber mouseGrabber)
signal

Signal emitted by setMouseGrabber() when the mouseGrabber() is changed.

mouseGrabber is a pointer to the new MouseGrabber. Note that this signal is emitted with a nullptr parameter each time a MouseGrabber stops grabbing mouse.

◆ mouseGrabberIsEnabled()

bool QGLViewer::mouseGrabberIsEnabled ( const qglviewer::MouseGrabber *const  mouseGrabber)
inline

Returns true if mouseGrabber is enabled.

Default value is true for all MouseGrabbers. When set to false using setMouseGrabberIsEnabled(), the specified mouseGrabber will never become the mouseGrabber() of this QGLViewer. This is useful when you use several viewers: some MouseGrabbers may only have a meaning for some specific viewers and should not be selectable in others.

You can also use qglviewer::MouseGrabber::removeFromMouseGrabberPool() to completely disable a MouseGrabber in all the QGLViewers.

◆ mouseHandler() [1/2]

int QGLViewer::mouseHandler ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button 
) const

Returns the MouseHandler which will be activated when the mouse button is pressed, while the modifiers and key are pressed.

If no action is associated with this combination, returns -1. Use 0 for key and Qt::NoModifier for modifiers to represent the lack of a key press.

For instance, to know which handler receives the Alt+LeftButton, do:

int mh = mouseHandler(0, Qt::AltModifier, Qt::LeftButton);
if (mh == QGLViewer::CAMERA) ...
@ CAMERA
Definition: qglviewer.h:1056
int mouseHandler(unsigned int state) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:3044

Use mouseAction() to know which action (see the MouseAction enum) will be performed on this handler.

◆ mouseHandler() [2/2]

int QGLViewer::mouseHandler ( unsigned int  state) const

This method is deprecated since version 2.5.0.

Use mouseHanler(Qt::Key, Qt::KeyboardModifiers, Qt::MouseButtons) instead.

◆ mouseMoveEvent()

void QGLViewer::mouseMoveEvent ( QMouseEvent *  e)
protectedvirtual

Overloading of the QWidget method.

Mouse move event is sent to the mouseGrabber() (if any) or to the camera() or the manipulatedFrame(), depending on mouse bindings (see setMouseBinding()).

If you want to define your own mouse behavior, do something like this:

void Viewer::mousePressEvent(QMouseEvent* e)
{
if ((e->button() == myButton) && (e->modifiers() == myModifiers))
myMouseBehavior = true;
else
}
void Viewer::mouseMoveEvent(QMouseEvent *e)
{
if (myMouseBehavior)
// Use e->x() and e->y() as you want...
else
}
void Viewer::mouseReleaseEvent(QMouseEvent* e)
{
if (myMouseBehavior)
myMouseBehavior = false;
else
}
virtual void mouseMoveEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1422
virtual void mousePressEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1325
virtual void mouseReleaseEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1473

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ mousePressEvent()

void QGLViewer::mousePressEvent ( QMouseEvent *  e)
protectedvirtual

Overloading of the QWidget method.

When the user clicks on the mouse:

Mouse bindings customization can be achieved using setMouseBinding() and setWheelBinding(). See the mouse page for a complete description of mouse bindings.

See the mouseMoveEvent() documentation for an example of more complex mouse behavior customization using overloading.

Note
When the mouseGrabber() is a manipulatedFrame(), the modifier keys are not taken into account. This allows for a direct manipulation of the manipulatedFrame() when the mouse hovers, which is probably what is expected.

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ mouseReleaseEvent()

void QGLViewer::mouseReleaseEvent ( QMouseEvent *  e)
protectedvirtual

Overloading of the QWidget method.

Calls the mouseGrabber(), camera() or manipulatedFrame mouseReleaseEvent method.

See the mouseMoveEvent() documentation for an example of mouse behavior customization.

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ mouseString()

QString QGLViewer::mouseString ( ) const
virtual

Returns a QString that describes the application mouse bindings, displayed in the help() window Mouse tab.

Result is a table that describes custom application mouse binding descriptions defined using setMouseBindingDescription() as well as standard mouse bindings (defined using setMouseBinding() and setWheelBinding()). See the mouse page for details on mouse bindings.

See also helpString() and keyboardString().

◆ openSnapshotFormatDialog

bool QGLViewer::openSnapshotFormatDialog ( )
slot

Opens a dialog that displays the different available snapshot formats.

Then calls setSnapshotFormat() with the selected one (unless the user cancels).

Returns false if the user presses the Cancel button and true otherwise.

◆ paintGL()

void QGLViewer::paintGL ( )
protectedvirtual

Main paint method, inherited from QOpenGLWidget.

Calls the following methods, in that order:

◆ pathKey()

Qt::Key QGLViewer::pathKey ( unsigned int  index) const

Returns the keyboard key associated to camera Key Frame path index.

Default values are F1..F12 for indexes 1..12.

addKeyFrameKeyboardModifiers() (resp. playPathKeyboardModifiers()) define the state key(s) that must be pressed with this key to add a KeyFrame to (resp. to play) the associated Key Frame path. If you quickly press twice the pathKey(), the path is reset (resp. deleted).

Use camera()->keyFrameInterpolator( index ) to retrieve the KeyFrameInterpolator that defines the path.

If several keys are binded to a given index (see setPathKey()), one of them is returned. Returns 0 if no key is associated with this index.

See also the keyboard page.

◆ playKeyFramePathStateKey()

Qt::KeyboardModifiers QGLViewer::playKeyFramePathStateKey ( ) const

◆ playPathKeyboardModifiers()

Qt::KeyboardModifiers QGLViewer::playPathKeyboardModifiers ( ) const

Returns the keyboard modifiers that must be pressed with a pathKey() to play a camera KeyFrame path.

It can be Qt::NoModifier, Qt::ControlModifier, Qt::ShiftModifier, Qt::AltModifier, Qt::MetaModifier or a combination of these (using the bitwise '|' operator).

Default value is Qt::NoModifier. Defined using setPlayPathKeyboardModifiers().

See also addKeyFrameKeyboardModifiers().

◆ playPathStateKey()

Qt::KeyboardModifiers QGLViewer::playPathStateKey ( ) const

◆ pointSelected

void QGLViewer::pointSelected ( const QMouseEvent *  e)
signal

Signal emitted by select().

Connect this signal to your selection method or overload select(), or more probably simply drawWithNames().

◆ postDraw()

void QGLViewer::postDraw ( )
protectedvirtual

Called after draw() to draw viewer visual hints.

Default implementation displays axis, grid, FPS... when the respective flags are sets.

See the multiSelect and thumbnail examples for an overloading illustration.

The GLContext (color, LIGHTING, BLEND...) is not modified by this method, so that in draw(), the user can rely on the OpenGL context he defined. Respect this convention (by pushing/popping the different attributes) if you overload this method.

◆ postSelection()

virtual void QGLViewer::postSelection ( const QPoint &  point)
inlineprotectedvirtual

This method is called at the end of the select() procedure.

It should finalize the selection process and update the data structure/interface/computation/display... according to the newly selected entity.

The default implementation is empty. Overload this method if needed, and use selectedName() to retrieve the selected entity name (returns -1 if no object was selected). See the select example for an illustration.

◆ preDraw()

void QGLViewer::preDraw ( )
protectedvirtual

Sets OpenGL state before draw().

Default behavior clears screen and sets the projection and modelView matrices:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
virtual void loadProjectionMatrix(bool reset=true) const
Loads the OpenGL GL_PROJECTION matrix with the Camera projection matrix.
Definition: camera.cpp:471
virtual void loadModelViewMatrix(bool reset=true) const
Loads the OpenGL GL_MODELVIEW matrix with the modelView matrix corresponding to the Camera.
Definition: camera.cpp:512

Emits the drawNeeded() signal once this is done (see the callback example).

◆ preDrawStereo()

void QGLViewer::preDrawStereo ( bool  leftBuffer = true)
protectedvirtual

Called before draw() (instead of preDraw()) when viewer displaysInStereo().

Same as preDraw() except that the glDrawBuffer() is set to GL_BACK_LEFT or GL_BACK_RIGHT depending on leftBuffer, and it uses qglviewer::Camera::loadProjectionMatrixStereo() and qglviewer::Camera::loadModelViewMatrixStereo() instead.

◆ QGLViewerIndex()

static int QGLViewer::QGLViewerIndex ( const QGLViewer *const  viewer)
inlinestatic

Returns the index of the QGLViewer viewer in the QGLViewerPool().

This index in unique and can be used to identify the different created QGLViewers (see stateFileName() for an application example).

When a QGLViewer is deleted, the QGLViewers' indexes are preserved and nullptr is set for that index. When a QGLViewer is created, it is placed in the first available position in that list. Returns -1 if the QGLViewer could not be found (which should not be possible).

◆ QGLViewerPool()

static const QList<QGLViewer *>& QGLViewer::QGLViewerPool ( )
inlinestatic

Returns a QList that contains pointers to all the created QGLViewers.

Note that this list may contain nullptr pointers if the associated viewer has been deleted.

Can be useful to apply a method or to connect a signal to all the viewers:

foreach (QGLViewer* viewer, QGLViewer::QGLViewerPool())
connect(myObject, SIGNAL(IHaveChangedSignal()), viewer, SLOT(update()));
static const QList< QGLViewer * > & QGLViewerPool()
Returns a QList that contains pointers to all the created QGLViewers.
Definition: qglviewer.h:1249
Attention
With Qt version 3, this method returns a QPtrList instead. Use a QPtrListIterator to iterate on the list instead.

◆ renderText() [1/2]

void QGLViewer::renderText ( double  x,
double  y,
double  z,
const QString &  str,
const QFont &  font = QFont() 
)

◆ renderText() [2/2]

void QGLViewer::renderText ( int  x,
int  y,
const QString &  str,
const QFont &  font = QFont() 
)

◆ resetVisualHints

void QGLViewer::resetVisualHints ( )
virtualslot

Reset the mask used by drawVisualHints().

Called by setVisualHintsMask() after 2 seconds to reset the display.

◆ resizeGL()

void QGLViewer::resizeGL ( int  width,
int  height 
)
protectedvirtual

Callback method used when the widget size is modified.

If you overload this method, first call the inherited method. Also called when the widget is created, before its first display.

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ restoreFromFile

bool QGLViewer::restoreFromFile ( const QString &  fileName = QString())
slot

This function is deprecated since version 1.3.9-5.

Use restoreStateFromFile() and setStateFileName() instead.

◆ restoreStateFromFile

bool QGLViewer::restoreStateFromFile ( )
virtualslot

Restores the QGLViewer state from the stateFileName() file using initFromDOMElement().

States are saved using saveStateToFile(), which is automatically called on viewer exit.

Returns true when the restoration is successful. Possible problems are an non existing or unreadable stateFileName() file, an empty stateFileName() or an XML syntax error.

A manipulatedFrame() should be defined before calling this method, so that its state can be restored. Initialization code put after this function will override saved values:

void Viewer::init()
{
// Default initialization goes here (including the declaration of a possible
showEntireScene(); // Previous state cannot be restored: fit camera to scene.
// Specific initialization that overrides file savings goes here.
}
void showEntireScene()
Moves the camera so that the entire scene is visible.
Definition: qglviewer.h:276
qglviewer::ManipulatedFrame * manipulatedFrame() const
Returns the viewer's qglviewer::ManipulatedFrame.
Definition: qglviewer.h:299
virtual bool restoreStateFromFile()
Restores the QGLViewer state from the stateFileName() file using initFromDOMElement().
Definition: qglviewer.cpp:3810

◆ saveSnapshot [1/2]

void QGLViewer::saveSnapshot ( bool  automatic = true,
bool  overwrite = false 
)
slot

Saves a snapshot of the current image displayed by the widget.

Options are set using snapshotFormat(), snapshotFileName() and snapshotQuality(). For non vectorial image formats, the image size is equal to the current viewer's dimensions (see width() and height()). See snapshotFormat() for details on supported formats.

If automatic is false (or if snapshotFileName() is empty), a file dialog is opened to ask for the file name.

When automatic is true, the file name is set to NAME-NUMBER, where NAME is snapshotFileName() and NUMBER is snapshotCounter(). The snapshotCounter() is automatically incremented after each snapshot saving. This is useful to create videos from your application:

void Viewer::init()
{
resize(720, 576); // PAL DV format (use 720x480 for NTSC DV)
connect(this, SIGNAL(drawFinished(bool)), SLOT(saveSnapshot(bool)));
}

Then call draw() in a loop (for instance using animate() and/or a camera() KeyFrameInterpolator replay) to create your image sequence.

If you want to create a Quicktime VR panoramic sequence, simply use code like this:

void Viewer::createQuicktime()
{
const int nbImages = 36;
for (int i=0; i<nbImages; ++i)
{
camera()->setOrientation(2.0*M_PI/nbImages, 0.0); // Theta-Phi
orientation showEntireScene(); update(); // calls draw(), which emits
drawFinished(), which calls saveSnapshot()
}
}
void setOrientation(const Quaternion &q)
Sets the Camera orientation(), defined in the world coordinate system.
Definition: camera.cpp:1162

If snapshotCounter() is negative, no number is appended to snapshotFileName() and the snapshotCounter() is not incremented. This is useful to force the creation of a file, overwriting the previous one.

When overwrite is set to false (default), a window asks for confirmation if the file already exists. In automatic mode, the snapshotCounter() is incremented (if positive) until a non-existing file name is found instead. Otherwise the file is overwritten without confirmation.

The VRender library was written by Cyril Soler (Cyril dot Soler at imag dot fr). If the generated PS or EPS file is not properly displayed, remove the anti-aliasing option in your postscript viewer.

Note
In order to correctly grab the frame buffer, the QGLViewer window is raised in front of other windows by this method.

◆ saveSnapshot [2/2]

void QGLViewer::saveSnapshot ( const QString &  fileName,
bool  overwrite = false 
)
slot

Same as saveSnapshot(), except that it uses fileName instead of snapshotFileName().

If fileName is empty, opens a file dialog to select the name.

Snapshot settings are set from snapshotFormat() and snapshotQuality().

Asks for confirmation when fileName already exists and overwrite is false (default).

Attention
If fileName is a char* (as is "myFile.jpg"), it may be casted into a bool, and the other saveSnapshot() method may be used instead. Pass QString("myFile.jpg") as a parameter to prevent this.

◆ saveStateToFile

void QGLViewer::saveStateToFile ( )
virtualslot

Saves in stateFileName() an XML representation of the QGLViewer state, obtained from domElement().

Use restoreStateFromFile() to restore this viewer state.

This method is automatically called when a viewer is closed (using Escape or using the window's upper right x close button). setStateFileName() to QString::null to prevent this.

◆ saveToFile

void QGLViewer::saveToFile ( const QString &  fileName = QString())
slot

This method is deprecated since version 1.3.9-5.

Use saveStateToFile() and setStateFileName() instead.

◆ scaledFont()

QFont QGLViewer::scaledFont ( const QFont &  font) const
inline

Return a possibly scaled version of font, used for snapshot rendering.

From a user's point of view, this method simply returns font and can be used transparently.

However when internally rendering a screen snapshot using saveSnapshot(), it returns a scaled version of the font, so that the size of the rendered text on the snapshot is identical to what is displayed on screen, even if the snapshot uses image tiling to create an image of dimensions different from those of the current window. This scaled version will only be used when saveSnapshot() calls your draw() method to generate the snapshot.

All your calls to renderText() function hence should use this method.

renderText(x, y, z, "My Text", scaledFont(QFont()));
void renderText(int x, int y, const QString &str, const QFont &font=QFont())
Definition: qglviewer.cpp:788
QFont scaledFont(const QFont &font) const
Return a possibly scaled version of font, used for snapshot rendering.
Definition: qglviewer.h:598

will guarantee that this text will be properly displayed on arbitrary sized snapshots.

Note that this method is not needed if you use drawText() which already calls it internally.

◆ sceneCenter()

qglviewer::Vec QGLViewer::sceneCenter ( ) const
inline

Returns the scene center, defined in world coordinates.

See sceneRadius() for details.

Default value is (0,0,0). Simply a wrapper for camera()->sceneCenter(). Set using setSceneCenter().

Do not mismatch this value (that only depends on the scene) with the qglviewer::Camera::pivotPoint().

◆ sceneRadius()

qreal QGLViewer::sceneRadius ( ) const
inline

Returns the scene radius.

The entire displayed scene should be included in a sphere of radius sceneRadius(), centered on sceneCenter().

This approximate value is used by the camera() to set qglviewer::Camera::zNear() and qglviewer::Camera::zFar(). It is also used to showEntireScene() or to scale the world axis display..

Default value is 1.0. This method is equivalent to camera()->sceneRadius(). See setSceneRadius().

◆ select [1/2]

void QGLViewer::select ( const QMouseEvent *  event)
virtualslot

Simple wrapper method: calls select(event->pos()).

Emits pointSelected(e) which is useful only if you rely on the Qt signal-slot mechanism and you did not overload QGLViewer. If you choose to derive your own viewer class, simply overload select() (or probably simply drawWithNames(), see the select example) to implement your selection mechanism.

This method is called when you use the QGLViewer::SELECT mouse binding(s) (default is Shift + left button). Use setMouseBinding() to change this.

◆ select [2/2]

void QGLViewer::select ( const QPoint &  point)
virtualslot

This method performs a selection in the scene from pixel coordinates.

It is called when the user clicks on the QGLViewer::SELECT QGLViewer::ClickAction binded button(s) (default is Shift + LeftButton).

This template method successively calls four other methods:

endSelection(point);
virtual void postSelection(const QPoint &point)
This method is called at the end of the select() procedure.
Definition: qglviewer.h:980
virtual void drawWithNames()
This method is called by select() and should draw selectable entities.
Definition: qglviewer.h:969
virtual void beginSelection(const QPoint &point)
This method should prepare the selection.
Definition: qglviewer.cpp:1130
virtual void endSelection(const QPoint &point)
This method is called by select() after scene elements were drawn by drawWithNames().
Definition: qglviewer.cpp:1195

The default implementation of these methods is as follows (see the methods' documentation for more details):

  • drawWithNames() is empty and should be overloaded. It draws each selectable object of the scene, enclosed by calls to glPushName() / glPopName() to tag the object with an integer id.
  • endSelection() then restores GL_RENDER mode and analyzes the selectBuffer() to set in selectedName() the id of the object that was drawn in the region. If several object are in the region, the closest one in the depth buffer is chosen. If no object has been drawn under cursor, selectedName() is set to -1.
  • postSelection() is empty and can be overloaded for possible signal/display/interface update.

See the glSelectBuffer() man page for details on this GL_SELECT mechanism.

This default implementation is quite limited: only the closer object is selected, and only one level of names can be pushed. However, this reveals sufficient in many cases and you usually only have to overload drawWithNames() to implement a simple object selection process. See the select example for an illustration.

If you need a more complex selection process (such as a point, edge or triangle selection, which is easier with a 2 or 3 levels selectBuffer() heap, and which requires a finer depth sorting to privilege point over edge and edges over triangles), overload the endSelection() method. Use setSelectRegionWidth(), setSelectRegionHeight() and setSelectBufferSize() to tune the select buffer configuration. See the multiSelect example for an illustration.

point is the center pixel (origin in the upper left corner) of the selection region. Use qglviewer::Camera::convertClickToLine() to transform these coordinates in a 3D ray if you want to perform an analytical intersection.

Attention
GL_SELECT mode seems to report wrong results when used in conjunction with backface culling. If you encounter problems try to glDisable(GL_CULL_FACE).

◆ selectBuffer()

GLuint* QGLViewer::selectBuffer ( )
inline

Returns a pointer to an array of GLuint.

This buffer is used by the GL_SELECT mode in select() to perform object selection. The buffer size can be modified using setSelectBufferSize(). If you overload endSelection(), you will analyze the content of this buffer. See the glSelectBuffer() man page for details.

◆ selectBufferSize()

int QGLViewer::selectBufferSize ( ) const
inline

Returns the selectBuffer() size.

See the select() documentation for details. Use setSelectBufferSize() to change this value.

Default value is 4000 (i.e. 1000 objects in selection region, since each object pushes 4 values). This size should be over estimated to prevent a buffer overflow when many objects are drawn under the mouse cursor.

◆ selectedName()

int QGLViewer::selectedName ( ) const
inline

Returns the name (an integer value) of the entity that was last selected by select().

This value is set by endSelection(). See the select() documentation for details.

As a convention, this method returns -1 if the selectBuffer() was empty, meaning that no object was selected.

Return value is -1 before the first call to select(). This value is modified using setSelectedName().

◆ selectRegionHeight()

int QGLViewer::selectRegionHeight ( ) const
inline

See the selectRegionWidth() documentation.

Default value is 3 pixels.

◆ selectRegionWidth()

int QGLViewer::selectRegionWidth ( ) const
inline

Returns the width (in pixels) of a selection frustum, centered on the mouse cursor, that is used to select objects.

The height of the selection frustum is defined by selectRegionHeight().

The objects that will be drawn in this region by drawWithNames() will be recorded in the selectBuffer(). endSelection() then analyzes this buffer and setSelectedName() to the name of the closest object. See the gluPickMatrix() documentation for details.

The default value is 3, which is adapted to standard applications. A smaller value results in a more precise selection but the user has to be careful for small feature selection.

See the multiSelect example for an illustration.

◆ setAddKeyFrameKeyboardModifiers

void QGLViewer::setAddKeyFrameKeyboardModifiers ( Qt::KeyboardModifiers  modifiers)
virtualslot

◆ setAddKeyFrameStateKey

void QGLViewer::setAddKeyFrameStateKey ( unsigned int  buttonState)
virtualslot

◆ setAnimationPeriod

void QGLViewer::setAnimationPeriod ( int  period)
inlineslot

Sets the animationPeriod(), in milliseconds.

◆ setAxisIsDrawn

void QGLViewer::setAxisIsDrawn ( bool  draw = true)
inlineslot

Sets the state of axisIsDrawn().

Emits the axisIsDrawnChanged() signal. See also toggleAxisIsDrawn().

◆ setBackgroundColor

void QGLViewer::setBackgroundColor ( const QColor &  color)
inlineslot

Sets the backgroundColor() of the viewer and calls qglClearColor().

See also setForegroundColor().

◆ setCamera

void QGLViewer::setCamera ( qglviewer::Camera *const  camera)
slot

Associates a new qglviewer::Camera to the viewer.

You should only use this method when you derive a new class from qglviewer::Camera and want to use one of its instances instead of the original class.

It you simply want to save and restore Camera positions, use qglviewer::Camera::addKeyFrameToPath() and qglviewer::Camera::playPath() instead.

This method silently ignores nullptr camera pointers. The calling method is responsible for deleting the previous camera pointer in order to prevent memory leaks if needed.

The sceneRadius() and sceneCenter() of camera are set to the current QGLViewer values.

All the camera qglviewer::Camera::keyFrameInterpolator() qglviewer::KeyFrameInterpolator::interpolated() signals are connected to the viewer update() slot. The connections with the previous viewer's camera are removed.

◆ setCameraIsEdited

void QGLViewer::setCameraIsEdited ( bool  edit = true)
slot

Starts (edit = true, default) or stops (edit=false) the edition of the camera().

Current implementation is limited to paths display. Get current state using cameraIsEdited().

Attention
This method sets the qglviewer::Camera::zClippingCoefficient() to 5.0 when edit is true, so that the Camera paths (see qglviewer::Camera::keyFrameInterpolator()) are not clipped. It restores the previous value when edit is false.

◆ setForegroundColor

void QGLViewer::setForegroundColor ( const QColor &  color)
inlineslot

Sets the foregroundColor() of the viewer, used to draw visual hints.

See also setBackgroundColor().

◆ setFPSIsDisplayed

void QGLViewer::setFPSIsDisplayed ( bool  display = true)
inlineslot

Sets the state of FPSIsDisplayed().

Emits the FPSIsDisplayedChanged() signal. See also toggleFPSIsDisplayed().

◆ setFullScreen

void QGLViewer::setFullScreen ( bool  fullScreen = true)
slot

Sets the isFullScreen() state.

If the QGLViewer is embedded in an other QWidget (see QWidget::topLevelWidget()), this widget is displayed in full screen instead.

◆ setGridIsDrawn

void QGLViewer::setGridIsDrawn ( bool  draw = true)
inlineslot

Sets the state of gridIsDrawn().

Emits the gridIsDrawnChanged() signal. See also toggleGridIsDrawn().

◆ setHandlerKeyboardModifiers

void QGLViewer::setHandlerKeyboardModifiers ( MouseHandler  handler,
Qt::KeyboardModifiers  modifiers 
)
slot

This method has been deprecated since version 2.5.0.

Associates keyboard modifiers to MouseHandler handler.

The modifiers parameter is Qt::AltModifier, Qt::ShiftModifier, Qt::ControlModifier, Qt::MetaModifier or a combination of these using the '|' bitwise operator.

All the handler's associated bindings will then need the specified modifiers key(s) to be activated.

With this code,

void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardModifiers modifiers)
This method has been deprecated since version 2.5.0.
Definition: qglviewer.cpp:2678
@ FRAME
Definition: qglviewer.h:1056

you will have to press the Alt key while pressing mouse buttons in order to move the camera(), while no key will be needed to move the manipulatedFrame().

This method has a very basic implementation: every action binded to handler has its keyboard modifier replaced by modifiers. If handler had some actions binded to different modifiers, these settings will be lost. You should hence consider using setMouseBinding() for finer tuning.

The default binding associates Qt::ControlModifier to all the QGLViewer::FRAME actions and Qt::NoModifier to all QGLViewer::CAMERA actions. See mouse page for details.

Attention
This method calls setMouseBinding(), which ensures that only one action is binded to a given modifiers. If you want to swap the QGLViewer::CAMERA and QGLViewer::FRAME keyboard modifiers, you have to use a temporary dummy modifier (as if you were swapping two variables) or else the first call will overwrite the previous settings:
// Associate FRAME with Alt (temporary value)
// Control is associated with CAMERA
// And finally, FRAME can be associated with NoModifier

◆ setHandlerStateKey

void QGLViewer::setHandlerStateKey ( MouseHandler  handler,
unsigned int  buttonState 
)
slot

◆ setKeyboardAccelerator

void QGLViewer::setKeyboardAccelerator ( KeyboardAction  action,
unsigned int  key 
)
slot

◆ setKeyDescription

void QGLViewer::setKeyDescription ( unsigned int  key,
QString  description 
)
slot

Defines a custom keyboard shortcut description, that will be displayed in the help() window Keyboard tab.

The key definition is given as an int using Qt enumerated values. Set an empty description to remove a shortcut description:

setKeyDescription(Qt::Key_W, "Toggles wireframe display");
setKeyDescription(Qt::CTRL+Qt::Key_L, "Loads a new scene");
// Removes a description
setKeyDescription(Qt::CTRL+Qt::Key_C, "");
void setKeyDescription(unsigned int key, QString description)
Defines a custom keyboard shortcut description, that will be displayed in the help() window Keyboard ...
Definition: qglviewer.cpp:1995

See the keyboardAndMouse example for illustration and the keyboard page for details.

◆ setKeyFrameKey

void QGLViewer::setKeyFrameKey ( unsigned int  index,
int  key 
)
virtualslot

◆ setManipulatedFrame

void QGLViewer::setManipulatedFrame ( qglviewer::ManipulatedFrame frame)
slot

Sets the viewer's manipulatedFrame().

Several objects can be manipulated simultaneously, as is done the multiSelect example.

Defining the own viewer's camera()->frame() as the manipulatedFrame() is possible and will result in a classical camera manipulation. See the luxo example for an illustration.

Note that a qglviewer::ManipulatedCameraFrame can be set as the manipulatedFrame(): it is possible to manipulate the camera of a first viewer in a second viewer.

◆ setMouseBinding [1/6]

void QGLViewer::setMouseBinding ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
ClickAction  action,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

Associates a ClickAction to a button and keyboard key and modifier(s) combination.

The parameters should read: when button is pressed, while the modifiers and key keys are down, and possibly as a doubleClick, then perform action. Use Qt::NoModifier to indicate that no modifier key is needed, and a key value of 0 if no regular key has to be pressed (or simply use setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButton, ClickAction, bool, Qt::MouseButtons)).

If buttonsBefore is specified (valid only when doubleClick is true), then this (or these) other mouse button(s) has (have) to be pressed before the double click occurs in order to execute action.

The list of all possible ClickAction, some binding examples and default bindings are listed in the mouse page. See also the setMouseBinding() documentation.

See the keyboardAndMouse example for an illustration.

The binding is ignored if Qt::NoButton is specified as buttons.

See also setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, MouseHandler, MouseAction, bool), setWheelBinding() and clearMouseBindings().

◆ setMouseBinding [2/6]

void QGLViewer::setMouseBinding ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
)
slot

Associates a MouseAction to any mouse button, while keyboard modifiers and key are pressed.

The receiver of the mouse events is a MouseHandler (QGLViewer::CAMERA or QGLViewer::FRAME).

The parameters should read: when the mouse button is pressed, while the keyboard modifiers and key are down, activate action on handler. Use Qt::NoModifier to indicate that no modifier key is needed, and a key value of 0 if no regular key has to be pressed (or simply use setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButton, MouseHandler, MouseAction, bool)).

Use the '|' operator to combine modifiers:

// The R key combined with the Left mouse button rotates the camera in the
screen plane. setMouseBinding(Qt::Key_R, Qt::NoModifier, Qt::LeftButton, CAMERA,
// Alt + Shift and Left button rotates the manipulatedFrame().
setMouseBinding(Qt::AltModifier | Qt::ShiftModifier, Qt::LeftButton, FRAME,
@ SCREEN_ROTATE
Definition: qglviewer.h:1090
@ ROTATE
Definition: qglviewer.h:1084
void setMouseBinding(unsigned int state, MouseHandler handler, MouseAction action, bool withConstraint=true)
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2751

If withConstraint is true (default), the possible qglviewer::Frame::constraint() of the associated Frame will be enforced during motion.

The list of all possible MouseAction, some binding examples and default bindings are provided in the mouse page.

See the keyboardAndMouse example for an illustration.

If no mouse button is specified, the binding is ignored. If an action was previously associated with this keyboard and button combination, it is silently overwritten (call mouseAction() before to check).

To remove a specific mouse binding, use NO_MOUSE_ACTION as the action.

See also setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, ClickAction, bool, int), setWheelBinding() and clearMouseBindings().

◆ setMouseBinding [3/6]

void QGLViewer::setMouseBinding ( Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
ClickAction  action,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

Defines a ClickAction binding.

Same as calling setMouseBinding(Qt::Key, Qt::KeyboardModifiers, Qt::MouseButton, ClickAction, bool, Qt::MouseButtons), with a key value of Qt::Key(0) (i.e. no regular key needs to be pressed to activate this action).

◆ setMouseBinding [4/6]

void QGLViewer::setMouseBinding ( Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
)
slot

Defines a MouseAction binding.

Same as calling setMouseBinding(Qt::Key, Qt::KeyboardModifiers, Qt::MouseButton, MouseHandler, MouseAction, bool), with a key value of Qt::Key(0) (i.e. no regular extra key needs to be pressed to perform this action).

◆ setMouseBinding [5/6]

void QGLViewer::setMouseBinding ( unsigned int  state,
ClickAction  action,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

This method is deprecated since version 2.5.0.

Use setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, MouseHandler, MouseAction, bool) instead.

◆ setMouseBinding [6/6]

void QGLViewer::setMouseBinding ( unsigned int  state,
MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
)
slot

This method is deprecated since version 2.5.0.

Use setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, MouseHandler, MouseAction, bool) instead.

◆ setMouseBindingDescription [1/3]

void QGLViewer::setMouseBindingDescription ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
QString  description,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

Defines a custom mouse binding description, displayed in the help() window's Mouse tab.

modifiers is a combination of Qt::KeyboardModifiers (Qt::ControlModifier, Qt::AltModifier, Qt::ShiftModifier, Qt::MetaModifier). Possibly combined using the "|" operator.

button is one of the Qt::MouseButtons (Qt::LeftButton, Qt::MidButton, Qt::RightButton...).

doubleClick indicates whether or not the user has to double click this button to perform the described action. buttonsBefore lists the buttons that need to be pressed before the double click.

Set an empty description to remove a mouse binding description.

// The R key combined with the Left mouse button rotates the camera in the
screen plane. setMouseBindingDescription(Qt::Key_R, Qt::NoModifier,
Qt::LeftButton, "Rotates camera in screen plane");
// A left button double click toggles full screen
setMouseBindingDescription(Qt::NoModifier, Qt::LeftButton, "Toggles full screen
mode", true);
// Removes the description of Ctrl+Right button
setMouseBindingDescription(Qt::ControlModifier, Qt::RightButton, "");
void setMouseBindingDescription(unsigned int state, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:1765

Overload mouseMoveEvent() and friends to implement your custom mouse behavior (see the mouseMoveEvent() documentation for an example). See the keyboardAndMouse example for an illustration.

Use setMouseBinding() and setWheelBinding() to change the standard mouse action bindings.

◆ setMouseBindingDescription [2/3]

void QGLViewer::setMouseBindingDescription ( Qt::KeyboardModifiers  modifiers,
Qt::MouseButton  button,
QString  description,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

Defines a custom mouse binding description, displayed in the help() window's Mouse tab.

Same as calling setMouseBindingDescription(Qt::Key, Qt::KeyboardModifiers, Qt::MouseButton, QString, bool, Qt::MouseButtons), with a key value of Qt::Key(0) (i.e. binding description when no regular key needs to be pressed).

◆ setMouseBindingDescription [3/3]

void QGLViewer::setMouseBindingDescription ( unsigned int  state,
QString  description,
bool  doubleClick = false,
Qt::MouseButtons  buttonsBefore = Qt::NoButton 
)
slot

This method is deprecated since version 2.5.0.

Use setMouseBindingDescription(Qt::KeyboardModifiers, Qt::MouseButtons, QString, bool, Qt::MouseButtons) instead.

◆ setMouseGrabber

void QGLViewer::setMouseGrabber ( qglviewer::MouseGrabber mouseGrabber)
slot

Directly defines the mouseGrabber().

You should not call this method directly as it bypasses the qglviewer::MouseGrabber::checkIfGrabsMouse() test performed by mouseMoveEvent().

If the MouseGrabber is disabled (see mouseGrabberIsEnabled()), this method silently does nothing.

◆ setMouseGrabberIsEnabled()

void QGLViewer::setMouseGrabberIsEnabled ( const qglviewer::MouseGrabber *const  mouseGrabber,
bool  enabled = true 
)

Sets the mouseGrabberIsEnabled() state.

◆ setMouseStateKey

void QGLViewer::setMouseStateKey ( MouseHandler  handler,
unsigned int  buttonState 
)
slot

◆ setPathKey

void QGLViewer::setPathKey ( int  key,
unsigned int  index = 0 
)
virtualslot

Sets the pathKey() associated with the camera Key Frame path index.

Several keys can be binded to the same index. Use a negated key value to delete the binding (the index value is then ignored):

// Press 'space' to play/pause/add/delete camera path of index 0.
setPathKey(Qt::Key_Space, 0);
// Remove this binding
setPathKey(-Qt::Key_Space);
virtual void setPathKey(int key, unsigned int index=0)
Sets the pathKey() associated with the camera Key Frame path index.
Definition: qglviewer.cpp:2539

◆ setPlayKeyFramePathStateKey

void QGLViewer::setPlayKeyFramePathStateKey ( unsigned int  buttonState)
virtualslot

◆ setPlayPathKeyboardModifiers

void QGLViewer::setPlayPathKeyboardModifiers ( Qt::KeyboardModifiers  modifiers)
virtualslot

Sets the playPathKeyboardModifiers() value.

◆ setPlayPathStateKey

void QGLViewer::setPlayPathStateKey ( unsigned int  buttonState)
virtualslot

◆ setSceneBoundingBox

void QGLViewer::setSceneBoundingBox ( const qglviewer::Vec min,
const qglviewer::Vec max 
)
inlineslot

Convenient way to call setSceneCenter() and setSceneRadius() from a (world axis aligned) bounding box of the scene.

This is equivalent to:

setSceneCenter((min+max) / 2.0);
setSceneRadius((max-min).norm() / 2.0);
virtual void setSceneRadius(qreal radius)
Sets the sceneRadius().
Definition: qglviewer.h:248
virtual void setSceneCenter(const qglviewer::Vec &center)
Sets the sceneCenter(), defined in world coordinates.
Definition: qglviewer.h:256
SReal norm(const V &v)
Norm of a vector.
Definition: vector_algebra.h:51

◆ setSceneCenter

virtual void QGLViewer::setSceneCenter ( const qglviewer::Vec center)
inlinevirtualslot

Sets the sceneCenter(), defined in world coordinates.

Attention
The qglviewer::Camera::pivotPoint() is set to the sceneCenter() value by this method.

◆ setSceneRadius

virtual void QGLViewer::setSceneRadius ( qreal  radius)
inlinevirtualslot

Sets the sceneRadius().

The camera() qglviewer::Camera::flySpeed() is set to 1% of this value by this method. Simple wrapper around camera()->setSceneRadius().

◆ setSelectBufferSize

void QGLViewer::setSelectBufferSize ( int  size)
slot

Sets the selectBufferSize().

The previous selectBuffer() is deleted and a new one is created.

◆ setSelectedName

void QGLViewer::setSelectedName ( int  id)
inlineslot

Set the selectedName() value.

Used in endSelection() during a selection. You should only call this method if you overload the endSelection() method.

◆ setSelectRegionHeight

void QGLViewer::setSelectRegionHeight ( int  height)
inlineslot

◆ setSelectRegionWidth

void QGLViewer::setSelectRegionWidth ( int  width)
inlineslot

◆ setShortcut

void QGLViewer::setShortcut ( KeyboardAction  action,
unsigned int  key 
)
slot

Defines the shortcut() that triggers a given QGLViewer::KeyboardAction.

Here are some examples:

// Press 'Q' to exit application
// Alt+M toggles camera mode
setShortcut(CAMERA_MODE, Qt::ALT + Qt::Key_M);
// The DISPLAY_FPS action is disabled
@ DISPLAY_FPS
Definition: qglviewer.h:993
@ CAMERA_MODE
Definition: qglviewer.h:997
@ EXIT_VIEWER
Definition: qglviewer.h:995
void setShortcut(KeyboardAction action, unsigned int key)
Defines the shortcut() that triggers a given QGLViewer::KeyboardAction.
Definition: qglviewer.cpp:2461

Only one shortcut can be assigned to a given QGLViewer::KeyboardAction (new bindings replace previous ones). If several KeyboardAction are binded to the same shortcut, only one of them is active.

◆ setSnapshotCounter

void QGLViewer::setSnapshotCounter ( int  counter)
inlineslot

Sets the snapshotCounter().

◆ setSnapshotFileName

void QGLViewer::setSnapshotFileName ( const QString &  name)
slot

◆ setSnapshotFormat

void QGLViewer::setSnapshotFormat ( const QString &  format)
inlineslot

Sets the snapshotFormat().

◆ setSnapshotQuality

void QGLViewer::setSnapshotQuality ( int  quality)
inlineslot

Sets the snapshotQuality().

◆ setStateFileName

void QGLViewer::setStateFileName ( const QString &  name)
inlineslot

Defines the stateFileName() used by saveStateToFile() and restoreStateFromFile().

The file name can have an optional prefix directory (no prefix meaning current directory). If the directory does not exist, it will be created by saveStateToFile().

// Name depends on the displayed 3D model. Saved in current directory.
setStateFileName(3DModelName() + ".xml");
// Files are stored in a dedicated directory under user's home directory.
setStateFileName(QDir::homeDirPath + "/.config/myApp.xml");
void setStateFileName(const QString &name)
Defines the stateFileName() used by saveStateToFile() and restoreStateFromFile().
Definition: qglviewer.h:1223

◆ setStereoDisplay

void QGLViewer::setStereoDisplay ( bool  stereo = true)
slot

Sets the state of displaysInStereo().

See also toggleStereoDisplay().

First checks that the display is able to handle stereovision using QOpenGLWidget::format(). Opens a warning message box in case of failure. Emits the stereoChanged() signal otherwise.

◆ setTextIsEnabled

void QGLViewer::setTextIsEnabled ( bool  enable = true)
inlineslot

Sets the state of textIsEnabled().

Emits the textIsEnabledChanged() signal. See also toggleTextIsEnabled().

◆ setVisualHintsMask()

void QGLViewer::setVisualHintsMask ( int  mask,
int  delay = 2000 
)
virtual

Defines the mask that will be used to drawVisualHints().

The only available mask is currently 1, corresponding to the display of the qglviewer::Camera::pivotPoint(). resetVisualHints() is automatically called after delay milliseconds (default is 2 seconds).

◆ setWheelBinding [1/2]

void QGLViewer::setWheelBinding ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers,
MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
)
slot

Associates a MouseAction and a MouseHandler to a mouse wheel event.

This method is very similar to setMouseBinding(), but specific to the wheel.

In the current implementation only QGLViewer::ZOOM can be associated with QGLViewer::FRAME, while QGLViewer::CAMERA can receive QGLViewer::ZOOM and QGLViewer::MOVE_FORWARD.

The difference between QGLViewer::ZOOM and QGLViewer::MOVE_FORWARD is that QGLViewer::ZOOM speed depends on the distance to the object, while QGLViewer::MOVE_FORWARD moves at a constant speed defined by qglviewer::Camera::flySpeed().

◆ setWheelBinding [2/2]

void QGLViewer::setWheelBinding ( Qt::KeyboardModifiers  modifiers,
MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
)
slot

Defines a mouse wheel binding.

Same as calling setWheelBinding(Qt::Key, Qt::KeyboardModifiers, MouseHandler, MouseAction, bool), with a key value of Qt::Key(0) (i.e. no regular key needs to be pressed to activate this action).

◆ shortcut()

unsigned int QGLViewer::shortcut ( KeyboardAction  action) const

Returns the keyboard shortcut associated to a given QGLViewer::KeyboardAction.

Result is an unsigned int defined using Qt enumerated values, as in Qt::Key_Q or Qt::CTRL + Qt::Key_X. Use Qt::MODIFIER_MASK to separate the key from the state keys. Returns 0 if the KeyboardAction is disabled (not binded). Set using setShortcut().

If you want to define keyboard shortcuts for custom actions (say, open a scene file), overload keyPressEvent() and then setKeyDescription().

These shortcuts and their descriptions are automatically included in the help() window Keyboard tab.

See the keyboard page for details and default values and the keyboardAndMouse example for a practical illustration.

◆ shortcutBindingsString()

virtual QString QGLViewer::shortcutBindingsString ( ) const
inlinevirtual

This method is deprecated, use keyboardString() instead.

◆ showEntireScene

void QGLViewer::showEntireScene ( )
inlineslot

Moves the camera so that the entire scene is visible.

Simple wrapper around qglviewer::Camera::showEntireScene().

◆ sizeHint()

virtual QSize QGLViewer::sizeHint ( ) const
inlinevirtual

Returns the recommended size for the QGLViewer.

Default value is 600x400 pixels.

◆ snapshotCounter()

int QGLViewer::snapshotCounter ( ) const
inline

Returns the value of the counter used to name snapshots in saveSnapshot() when automatic is true.

Set using setSnapshotCounter(). Default value is 0, and it is incremented after each automatic snapshot. See saveSnapshot() for details.

◆ snapshotFileName()

const QString& QGLViewer::snapshotFileName ( ) const
inline

Returns the snapshot file name used by saveSnapshot().

This value is used in automatic mode (see saveSnapshot()). A dialog is otherwise popped-up to set it.

You can also directly provide a file name using saveSnapshot(const QString&, bool).

If the file name is relative, the current working directory at the moment of the method call is used. Set using setSnapshotFileName().

◆ snapshotFilename()

const QString & QGLViewer::snapshotFilename ( ) const

◆ snapshotFormat()

const QString& QGLViewer::snapshotFormat ( ) const
inline

Returns the snapshot file format used by saveSnapshot().

This value is used when saveSnapshot() is passed the automatic flag. It is defined using a saveAs pop-up dialog otherwise.

The available formats are those handled by Qt. Classical values are "JPEG", "PNG", "PPM", "BMP". Use the following code to get the actual list:

QList<QByteArray> formatList = QImageReader::supportedImageFormats();
// or with Qt version 2 or 3:
QStringList formatList = QImage::outputFormatList();

If the library was compiled with the vectorial rendering option (default), three additional vectorial formats are available: "EPS", "PS" and "XFIG". "SVG" and "PDF" formats should soon be available. The VRender library was created by Cyril Soler.

Note that the VRender library has some limitations: vertex shader effects are not reproduced and PASS_THROUGH tokens are not handled so one can not change point and line size in the middle of a drawing.

Default value is the first supported among "JPEG, PNG, EPS, PS, PPM, BMP", in that order.

This value is set using setSnapshotFormat() or with openSnapshotFormatDialog().

Attention
No verification is performed on the provided format validity. The next call to saveSnapshot() may fail if the format string is not supported.

◆ snapshotQuality()

int QGLViewer::snapshotQuality ( )
inline

Defines the image quality of the snapshots produced with saveSnapshot().

Values must be in the range -1..100. Use 0 for lowest quality and 100 for highest quality (and larger files). -1 means use Qt default quality. Default value is 95.

Set using setSnapshotQuality(). See also the QImage::save() documentation.

Note
This value has no impact on the images produced in vectorial format.

◆ snapshotToClipboard

void QGLViewer::snapshotToClipboard ( )
slot

Takes a snapshot of the current display and pastes it to the clipboard.

This action is activated by the KeyboardAction::SNAPSHOT_TO_CLIPBOARD enum, binded to Ctrl+C by default.

◆ startAnimation

void QGLViewer::startAnimation ( )
virtualslot

Starts the animation loop.

See animationIsStarted().

◆ startScreenCoordinatesSystem()

void QGLViewer::startScreenCoordinatesSystem ( bool  upward = false) const
virtual

Modify the projection matrix so that drawing can be done directly with 2D screen coordinates.

Once called, the x and y coordinates passed to glVertex are expressed in pixels screen coordinates. The origin (0,0) is in the upper left corner of the widget by default. This follows the Qt standards, so that you can directly use the pos() provided by for instance QMouseEvent. Set upward to true to place the origin in the lower left corner, thus following the OpenGL and mathematical standards. It is always possible to switch between the two representations using newY = height() - y.

You need to call stopScreenCoordinatesSystem() at the end of the drawing block to restore the previous camera matrix.

In practice, this method should be used in draw(). It sets an appropriate orthographic projection matrix and then sets glMatrixMode to GL_MODELVIEW.

See the screenCoordSystem, multiSelect and backgroundImage examples for an illustration.

You may want to disable GL_LIGHTING, to enable GL_LINE_SMOOTH or GL_BLEND to draw when this method is used.

If you want to link 2D drawings to 3D objects, use qglviewer::Camera::projectedCoordinatesOf() to compute the 2D projection on screen of a 3D point (see the screenCoordSystem example). See also drawText().

In this mode, you should use z values that are in the [0.0, 1.0[ range (0.0 corresponding to the near clipping plane and 1.0 being just beyond the far clipping plane). This interval matches the values that can be read from the z-buffer. Note that if you use the convenient glVertex2i() to provide coordinates, the implicit 0.0 z coordinate will make your drawings appear on top of the rest of the scene.

◆ stateFileName()

QString QGLViewer::stateFileName ( ) const

Returns the state file name.

Default value is .qglviewer.xml.

This is the name of the XML file where saveStateToFile() saves the viewer state (camera state, widget geometry, display flags... see domElement()) on exit. Use restoreStateFromFile() to restore this state later (usually in your init() method).

Setting this value to QString::null will disable the automatic state file saving that normally occurs on exit.

If more than one viewer are created by the application, this function will return a numbered file name (as in ".qglviewer1.xml", ".qglviewer2.xml"... using QGLViewer::QGLViewerIndex()) for extra viewers. Each viewer will then read back its own information in restoreStateFromFile(), provided that the viewers are created in the same order, which is usually the case.

◆ stereoChanged

void QGLViewer::stereoChanged ( bool  on)
signal

This signal is emitted whenever displaysInStereo() changes value.

◆ stopAnimation

void QGLViewer::stopAnimation ( )
virtualslot

Stops animation.

See animationIsStarted().

◆ stopScreenCoordinatesSystem()

void QGLViewer::stopScreenCoordinatesSystem ( ) const
virtual

Stops the pixel coordinate drawing block started by startScreenCoordinatesSystem().

The GL_MODELVIEW and GL_PROJECTION matrices modified in startScreenCoordinatesSystem() are restored. glMatrixMode is set to GL_MODELVIEW.

◆ textIsEnabled()

bool QGLViewer::textIsEnabled ( ) const
inline

Returns true if text display (see drawText()) is enabled.

Set by setTextIsEnabled() or toggleTextIsEnabled(). This feature conveniently removes all the possibly displayed text, cleaning display. Default value is true.

◆ textIsEnabledChanged

void QGLViewer::textIsEnabledChanged ( bool  enabled)
signal

This signal is emitted whenever textIsEnabled() changes value.

◆ timerEvent()

void QGLViewer::timerEvent ( QTimerEvent *  )
protectedvirtual

Overloading of the QObject method.

If animationIsStarted(), calls animate() and draw().

◆ toggleAnimation

void QGLViewer::toggleAnimation ( )
inlineslot

◆ toggleAxisIsDrawn

void QGLViewer::toggleAxisIsDrawn ( )
inlineslot

Toggles the state of axisIsDrawn().

See also setAxisIsDrawn().

◆ toggleCameraIsEdited

void QGLViewer::toggleCameraIsEdited ( )
inlineslot

Toggles the state of cameraIsEdited().

See also setCameraIsEdited().

◆ toggleCameraMode

void QGLViewer::toggleCameraMode ( )
slot

Swaps between two predefined camera mouse bindings.

The first mode makes the camera observe the scene while revolving around the qglviewer::Camera::pivotPoint(). The second mode is designed for walkthrough applications and simulates a flying camera.

Practically, the three mouse buttons are respectively binded to:

The current mode is determined by checking if a mouse button is binded to QGLViewer::ROTATE for the QGLViewer::CAMERA. The state key that was previously used to move the camera is preserved.

◆ toggleFPSIsDisplayed

void QGLViewer::toggleFPSIsDisplayed ( )
inlineslot

Toggles the state of FPSIsDisplayed().

See also setFPSIsDisplayed().

◆ toggleFullScreen

void QGLViewer::toggleFullScreen ( )
inlineslot

Toggles the state of isFullScreen().

See also setFullScreen().

◆ toggleGridIsDrawn

void QGLViewer::toggleGridIsDrawn ( )
inlineslot

Toggles the state of gridIsDrawn().

See also setGridIsDrawn().

◆ toggleStereoDisplay

void QGLViewer::toggleStereoDisplay ( )
inlineslot

Toggles the state of displaysInStereo().

See setStereoDisplay().

◆ toggleTextIsEnabled

void QGLViewer::toggleTextIsEnabled ( )
inlineslot

Toggles the state of textIsEnabled().

See also setTextIsEnabled().

◆ viewerInitialized

void QGLViewer::viewerInitialized ( )
signal

Signal emitted by the default init() method.

Connect this signal to the methods that need to be called to initialize your viewer or overload init().

◆ wheelAction() [1/2]

QGLViewer::MouseAction QGLViewer::wheelAction ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers 
) const

Returns the MouseAction (if any) that is performed when using the wheel, when the modifiers and key keyboard keys are pressed.

Returns NO_MOUSE_ACTION if no such binding has been defined using setWheelBinding().

Same as mouseAction(), but for the wheel action. See also wheelHandler().

◆ wheelAction [2/2]

QGLViewer::MouseAction QGLViewer::wheelAction ( Qt::KeyboardModifiers  modifiers) const
slot

This method is deprecated since version 2.5.0.

Use wheelAction(Qt::Key key, Qt::KeyboardModifiers modifiers) instead.

◆ wheelButtonState()

unsigned int QGLViewer::wheelButtonState ( MouseHandler  handler,
MouseAction  action,
bool  withConstraint = true 
) const

This method is deprecated since version 2.5.0.

Use wheelAction() and wheelHandler() instead.

◆ wheelEvent()

void QGLViewer::wheelEvent ( QWheelEvent *  e)
protectedvirtual

Overloading of the QWidget method.

If defined, the wheel event is sent to the mouseGrabber(). It is otherwise sent according to wheel bindings (see setWheelBinding()).

Reimplemented in sofa::gui::qt::viewer::qgl::QtGLViewer.

◆ wheelHandler() [1/2]

int QGLViewer::wheelHandler ( Qt::Key  key,
Qt::KeyboardModifiers  modifiers 
) const

Returns the MouseHandler (if any) that receives wheel events when the modifiers and key keyboard keys are pressed.

Returns -1 if no no such binding has been defined using setWheelBinding(). See also wheelAction().

◆ wheelHandler [2/2]

int QGLViewer::wheelHandler ( Qt::KeyboardModifiers  modifiers) const
slot

This method is deprecated since version 2.5.0.

Use wheelHandler(Qt::Key key, Qt::KeyboardModifiers modifiers) instead.

Enum details

◆ ClickAction

Defines the possible actions that can be binded to a mouse click using setMouseBinding(Qt::KeyboardModifiers, Qt::MouseButtons, ClickAction, bool, int).

See the mouse page for details.

Enumerator
NO_CLICK_ACTION 
ZOOM_ON_PIXEL 
ZOOM_TO_FIT 
SELECT 
RAP_FROM_PIXEL 
RAP_IS_CENTER 
CENTER_FRAME 
CENTER_SCENE 
SHOW_ENTIRE_SCENE 
ALIGN_FRAME 
ALIGN_CAMERA 

◆ KeyboardAction

Defines the different actions that can be associated with a keyboard shortcut using setShortcut().

See the keyboard page for details.

Enumerator
DRAW_AXIS 
DRAW_GRID 
DISPLAY_FPS 
ENABLE_TEXT 
EXIT_VIEWER 
SAVE_SCREENSHOT 
CAMERA_MODE 
FULL_SCREEN 
STEREO 
ANIMATION 
HELP 
EDIT_CAMERA 
MOVE_CAMERA_LEFT 
MOVE_CAMERA_RIGHT 
MOVE_CAMERA_UP 
MOVE_CAMERA_DOWN 
INCREASE_FLYSPEED 
DECREASE_FLYSPEED 
SNAPSHOT_TO_CLIPBOARD 

◆ MouseAction

Defines the possible actions that can be binded to a mouse action (a click, followed by a mouse displacement).

These actions may be binded to the camera() or to the manipulatedFrame() (see QGLViewer::MouseHandler) using setMouseBinding().

Enumerator
NO_MOUSE_ACTION 
ROTATE 
ZOOM 
TRANSLATE 
MOVE_FORWARD 
LOOK_AROUND 
MOVE_BACKWARD 
SCREEN_ROTATE 
ROLL 
DRIVE 
SCREEN_TRANSLATE 
ZOOM_ON_REGION 

◆ MouseHandler

Defines the different mouse handlers: camera() or manipulatedFrame().

Used by setMouseBinding(), setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButtons, ClickAction, bool, int) and setWheelBinding() to define which handler receives the mouse events.

Enumerator
CAMERA 
FRAME 

Related details

◆ drawVectorial

void drawVectorial ( void *  param)
friend