SOFA API  3ea83cbd
Open source framework for multi-physics simuation
sofa::gui::qt::viewer::qgl::QtGLViewer Class Reference

#include <QtGLViewer.h>

Inheritance diagram for sofa::gui::qt::viewer::qgl::QtGLViewer:

Public Member Functions

virtual void drawColourPicking (common::ColourPickingVisitor::ColourCode code) override
 
 QtGLViewer (QWidget *parent, const char *name="")
 
 ~QtGLViewer () override
 
QWidgetgetQWidget () override
 
int getWidth () override
 
int getHeight () override
 
bool ready () override
 
void wait () override
 ask the viewer to resume its activity More...
 
void UpdateOBJ (void)
 
void moveRayPickInteractor (int eventX, int eventY) override
 RayCasting PickHandler. More...
 
void setCameraMode (core::visual::VisualParams::CameraType mode) override
 
void screenshot (const std::string &filename, int compression_level=-1) override
 
QString helpString () const override
 Returns the QString displayed in the help() window main tab. More...
 
- Public Member Functions inherited from QGLViewer
 QGLViewer (QWidget *parent=0, Qt::WindowFlags flags=Qt::WindowFlags())
 Constructor. More...
 
virtual ~QGLViewer ()
 Virtual destructor. 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...
 
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...
 
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...
 
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...
 
QColor backgroundColor () const
 Returns the background color of the viewer. More...
 
QColor foregroundColor () const
 Returns the foreground color used by the viewer. More...
 
qreal sceneRadius () const
 Returns the scene radius. More...
 
qglviewer::Vec sceneCenter () const
 Returns the scene center, defined in world coordinates. More...
 
qglviewer::Cameracamera () const
 Returns the associated qglviewer::Camera, never nullptr. More...
 
qglviewer::ManipulatedFramemanipulatedFrame () const
 Returns the viewer's qglviewer::ManipulatedFrame. More...
 
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...
 
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...
 
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...
 
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...
 
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())
 
bool animationIsStarted () const
 Return true when the animation loop is started. More...
 
int animationPeriod () const
 The animation loop period, in milliseconds. 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...
 
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...
 
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...
 
- Public Member Functions inherited from sofa::gui::qt::viewer::CustomPolicySofaViewer< VisualModelPolicyType >
 CustomPolicySofaViewer ()
 
 ~CustomPolicySofaViewer () override
 
- Public Member Functions inherited from sofa::gui::qt::viewer::SofaViewer
 SofaViewer ()
 
 ~SofaViewer () override
 
virtual void removeViewerTab (QTabWidget *)
 Optional QTabWidget GUI for a concreate viewer. More...
 
virtual void configureViewerTab (QTabWidget *)
 Optional QTabWidget GUI for a concreate viewer. More...
 
void captureEvent () override
 
bool isControlPressed () const
 
virtual void configure (sofa::component::setting::ViewerSetting *viewerConf) override
 
const std::string screenshotName () override
 
void setPrefix (const std::string &prefix, bool prependDirectory=true) override
 
virtual void setBackgroundImage (std::string imageFileName=std::string("textures/SOFA_logo.bmp")) override
 
- Public Member Functions inherited from sofa::gui::common::BaseViewer
 BaseViewer ()
 
virtual ~BaseViewer ()
 
virtual sofa::simulation::NodegetScene ()
 
virtual const std::string & getSceneFileName ()
 
virtual void setSceneFileName (const std::string &f)
 
virtual void setScene (sofa::simulation::Node::SPtr scene, const char *filename=nullptr, bool=false)
 
virtual bool load (void)
 Load the viewer. It's the initialisation. More...
 
virtual bool unload (void)
 unload the viewer without delete More...
 
virtual void getView (sofa::type::Vec3 &pos, sofa::type::Quat< SReal > &ori) const
 
virtual void setView (const sofa::type::Vec3 &pos, const sofa::type::Quat< SReal > &ori)
 
virtual void moveView (const sofa::type::Vec3 &pos, const sofa::type::Quat< SReal > &ori)
 
virtual void newView ()
 
virtual void resetView ()
 
virtual void setBackgroundColour (float r, float g, float b)
 
std::string getBackgroundImage ()
 
virtual void saveView ()=0
 
virtual void setSizeW (int)=0
 
virtual void setSizeH (int)=0
 
virtual void fitObjectBBox (sofa::core::objectmodel::BaseObject *)
 
virtual void fitNodeBBox (sofa::core::objectmodel::BaseNode *)
 
virtual void setFullScreen (bool)
 
PickHandlergetPickHandler ()
 

Static Public Member Functions

static QtGLViewercreate (QtGLViewer *, sofa::gui::common::BaseViewerArgument &arg)
 
static const charviewerName ()
 
static const characceleratedName ()
 
- Static Public Member Functions inherited from QGLViewer
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...
 
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...
 

Protected Member Functions

void init () override
 Initializes the viewer OpenGL context. More...
 
void draw () override
 Overloaded from QGLViewer to render the scene. More...
 
virtual void viewAll () override
 Overloaded from SofaViewer. More...
 
void resizeGL (int w, int h) override
 Callback method used when the widget size is modified. More...
 
virtual void drawScene () override
 the rendering pass is done here (have to be called in a loop) More...
 
virtual void DrawLogo (void)
 
void keyPressEvent (QKeyEvent *e) override
 Overloading of the QWidget method. More...
 
void keyReleaseEvent (QKeyEvent *e) override
 
void mousePressEvent (QMouseEvent *e) override
 Overloading of the QWidget method. More...
 
void mouseReleaseEvent (QMouseEvent *e) override
 Overloading of the QWidget method. More...
 
void mouseMoveEvent (QMouseEvent *e) override
 Overloading of the QWidget method. More...
 
void wheelEvent (QWheelEvent *e) override
 Overloading of the QWidget method. More...
 
bool mouseEvent (QMouseEvent *e) override
 
- Protected Member Functions inherited from QGLViewer
virtual void drawLight (GLenum light, qreal scale=1.0) const
 Draws a representation of light. More...
 
QTabWidget * helpWidget ()
 Returns a pointer to the help widget. 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...
 
virtual void initializeGL ()
 Initializes the QGLViewer OpenGL context and then calls user-defined init(). 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 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...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 Overloading of the QWidget method. More...
 
virtual void timerEvent (QTimerEvent *)
 Overloading of the QObject method. More...
 
virtual void closeEvent (QCloseEvent *)
 Overloading of the QWidget method. More...
 
- Protected Member Functions inherited from sofa::gui::qt::viewer::SofaViewer
void redraw () override
 internally called while the actual viewer needs a redraw (ie the camera changed) More...
 

Signals

void redrawn () override
 
void resizeW (int) override
 
void resizeH (int) override
 
void quit ()
 
- Signals inherited from QGLViewer
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...
 
- Signals inherited from sofa::gui::qt::viewer::SofaViewer
virtual void redrawn ()=0
 
virtual void resizeW (int)=0
 
virtual void resizeH (int)=0
 

Public Slots

void resetView () override
 
void saveView () override
 
void setSizeW (int) override
 
void setSizeH (int) override
 
virtual void getView (type::Vec3 &pos, type::Quat< SReal > &ori) const override
 
virtual void setView (const type::Vec3 &pos, const type::Quat< SReal > &ori) override
 
virtual void captureEvent () override
 
void fitObjectBBox (sofa::core::objectmodel::BaseObject *object) override
 
void fitNodeBBox (sofa::core::objectmodel::BaseNode *node) override
 
- Public Slots inherited from QGLViewer
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...
 
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)
 
virtual void resetVisualHints ()
 Reset the mask used by drawVisualHints(). 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...
 
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...
 
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...
 
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...
 
void setMouseGrabber (qglviewer::MouseGrabber *mouseGrabber)
 Directly defines the mouseGrabber(). 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...
 
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...
 
void copyBufferToTexture (GLint internalFormat, GLenum format=GL_NONE)
 Makes a copy of the current buffer into a texture. 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...
 
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...
 
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 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...
 

Additional Inherited Members

- Protected Attributes inherited from sofa::gui::qt::viewer::SofaViewer
std::unique_ptr< EngineBackendm_backend
 
QTimer captureTimer
 
bool m_isControlPressed
 
ColourPickingRenderCallBack colourPickingRenderCallBack
 
- Protected Attributes inherited from sofa::gui::common::BaseViewer
sofa::simulation::Node::SPtr groot
 the sofa root note of the current scene More...
 
sofa::component::visual::BaseCamera::SPtr currentCamera
 
std::string sceneFileName
 
bool _video
 
bool m_isVideoButtonPressed
 
bool m_bShowAxis
 
bool _fullScreen
 
int _background
 
bool initTexturesDone
 
sofa::type::Vec3 backgroundColour
 
std::string backgroundImageFile
 
sofa::type::Vec3 ambientColour
 
PickHandlerpick
 
int _navigationMode
 
bool _mouseInteractorMoving
 
int _mouseInteractorSavedPosX
 
int _mouseInteractorSavedPosY
 
std::string _screenshotDirectory
 

Constructor details

◆ QtGLViewer()

sofa::gui::qt::viewer::qgl::QtGLViewer::QtGLViewer ( QWidget parent,
const char name = "" 
)

◆ ~QtGLViewer()

sofa::gui::qt::viewer::qgl::QtGLViewer::~QtGLViewer ( )
override

Function details

◆ acceleratedName()

static const char* sofa::gui::qt::viewer::qgl::QtGLViewer::acceleratedName ( )
inlinestatic

◆ captureEvent

virtual void sofa::gui::qt::viewer::qgl::QtGLViewer::captureEvent ( )
inlineoverridevirtualslot

◆ create()

static QtGLViewer* sofa::gui::qt::viewer::qgl::QtGLViewer::create ( QtGLViewer ,
sofa::gui::common::BaseViewerArgument arg 
)
inlinestatic

◆ draw()

void sofa::gui::qt::viewer::qgl::QtGLViewer::draw ( )
overrideprotectedvirtual

Overloaded from QGLViewer to render the scene.

Reimplemented from QGLViewer.

◆ drawColourPicking()

void sofa::gui::qt::viewer::qgl::QtGLViewer::drawColourPicking ( common::ColourPickingVisitor::ColourCode  code)
overridevirtual

Reimplemented from sofa::gui::common::BaseViewer.

◆ DrawLogo()

void sofa::gui::qt::viewer::qgl::QtGLViewer::DrawLogo ( void  )
protectedvirtual

◆ drawScene()

void sofa::gui::qt::viewer::qgl::QtGLViewer::drawScene ( )
overrideprotectedvirtual

the rendering pass is done here (have to be called in a loop)

Implements sofa::gui::common::BaseViewer.

◆ fitNodeBBox

void sofa::gui::qt::viewer::qgl::QtGLViewer::fitNodeBBox ( sofa::core::objectmodel::BaseNode node)
inlineoverrideslot

◆ fitObjectBBox

void sofa::gui::qt::viewer::qgl::QtGLViewer::fitObjectBBox ( sofa::core::objectmodel::BaseObject object)
inlineoverrideslot

◆ getHeight()

int sofa::gui::qt::viewer::qgl::QtGLViewer::getHeight ( )
inlineoverridevirtual

◆ getQWidget()

QWidget* sofa::gui::qt::viewer::qgl::QtGLViewer::getQWidget ( )
inlineoverridevirtual

◆ getView

void sofa::gui::qt::viewer::qgl::QtGLViewer::getView ( type::Vec3 pos,
type::Quat< SReal > &  ori 
) const
overridevirtualslot

◆ getWidth()

int sofa::gui::qt::viewer::qgl::QtGLViewer::getWidth ( )
inlineoverridevirtual

◆ helpString()

QString sofa::gui::qt::viewer::qgl::QtGLViewer::helpString ( ) const
overridevirtual

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 from QGLViewer.

◆ init()

void sofa::gui::qt::viewer::qgl::QtGLViewer::init ( void  )
overrideprotectedvirtual

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 from QGLViewer.

◆ keyPressEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::keyPressEvent ( QKeyEvent *  e)
overrideprotectedvirtual

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 from QGLViewer.

◆ keyReleaseEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::keyReleaseEvent ( QKeyEvent *  e)
overrideprotectedvirtual

Reimplemented from QGLViewer.

◆ mouseEvent()

bool sofa::gui::qt::viewer::qgl::QtGLViewer::mouseEvent ( QMouseEvent *  e)
overrideprotectedvirtual

Reimplemented from sofa::gui::qt::viewer::SofaViewer.

◆ mouseMoveEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::mouseMoveEvent ( QMouseEvent *  e)
overrideprotectedvirtual

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 from QGLViewer.

◆ mousePressEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::mousePressEvent ( QMouseEvent *  e)
overrideprotectedvirtual

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 from QGLViewer.

◆ mouseReleaseEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotectedvirtual

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 from QGLViewer.

◆ moveRayPickInteractor()

void sofa::gui::qt::viewer::qgl::QtGLViewer::moveRayPickInteractor ( int  ,
int   
)
overridevirtual

RayCasting PickHandler.

Reimplemented from sofa::gui::common::BaseViewer.

◆ quit

void sofa::gui::qt::viewer::qgl::QtGLViewer::quit ( )
signal

◆ ready()

bool sofa::gui::qt::viewer::qgl::QtGLViewer::ready ( )
inlineoverridevirtual

true when the viewer keep the hand on the render false when it's not in activity

Reimplemented from sofa::gui::common::BaseViewer.

◆ redrawn

void sofa::gui::qt::viewer::qgl::QtGLViewer::redrawn ( )
overridesignal

◆ resetView

void sofa::gui::qt::viewer::qgl::QtGLViewer::resetView ( )
overrideslot

◆ resizeGL()

void sofa::gui::qt::viewer::qgl::QtGLViewer::resizeGL ( int  width,
int  height 
)
overrideprotectedvirtual

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 from QGLViewer.

◆ resizeH

void sofa::gui::qt::viewer::qgl::QtGLViewer::resizeH ( int  )
overridesignal

◆ resizeW

void sofa::gui::qt::viewer::qgl::QtGLViewer::resizeW ( int  )
overridesignal

◆ saveView

void sofa::gui::qt::viewer::qgl::QtGLViewer::saveView ( )
overrideslot

◆ screenshot()

void sofa::gui::qt::viewer::qgl::QtGLViewer::screenshot ( const std::string &  filename,
int  compression_level = -1 
)
overridevirtual

Reimplemented from sofa::gui::qt::viewer::SofaViewer.

◆ setCameraMode()

void sofa::gui::qt::viewer::qgl::QtGLViewer::setCameraMode ( core::visual::VisualParams::CameraType  mode)
overridevirtual

Reimplemented from sofa::gui::common::BaseViewer.

◆ setSizeH

void sofa::gui::qt::viewer::qgl::QtGLViewer::setSizeH ( int  size)
overrideslot

◆ setSizeW

void sofa::gui::qt::viewer::qgl::QtGLViewer::setSizeW ( int  size)
overrideslot

◆ setView

void sofa::gui::qt::viewer::qgl::QtGLViewer::setView ( const type::Vec3 pos,
const type::Quat< SReal > &  ori 
)
overridevirtualslot

◆ UpdateOBJ()

void sofa::gui::qt::viewer::qgl::QtGLViewer::UpdateOBJ ( void  )

◆ viewAll()

void sofa::gui::qt::viewer::qgl::QtGLViewer::viewAll ( void  )
overrideprotectedvirtual

Overloaded from SofaViewer.

Implements sofa::gui::common::BaseViewer.

◆ viewerName()

static const char* sofa::gui::qt::viewer::qgl::QtGLViewer::viewerName ( )
inlinestatic

◆ wait()

void sofa::gui::qt::viewer::qgl::QtGLViewer::wait ( )
inlineoverridevirtual

ask the viewer to resume its activity

Reimplemented from sofa::gui::common::BaseViewer.

◆ wheelEvent()

void sofa::gui::qt::viewer::qgl::QtGLViewer::wheelEvent ( QWheelEvent *  e)
overrideprotectedvirtual

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 from QGLViewer.