qglviewer.cpp
72 // qWarning("Unable to get OpenGL version, context may not be available - Check your configuration");
166 QGLViewer::QGLViewer(QGLContext *context, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags flags)
174 QGLViewer::QGLViewer(const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags flags)
185 // See closeEvent comment. Destructor is called (and not closeEvent) only when the widget is embedded.
186 // Hence we saveToFile here. It is however a bad idea if virtual domElement() has been overloaded !
211 // Convertion of keyboard modifiers and mouse buttons as an int is no longer supported : emulate
217 // Convertion of keyboard modifiers and mouse buttons as an int is no longer supported : emulate
383 fpsString_ = tr("%1Hz", "Frames per seconds, in Hertz").arg(f_p_s_, 0, 'f', ((f_p_s_ < 10.0)?1:0));
490 keyboardActionDescription_[DISPLAY_FPS] = tr("Toggles the display of the FPS", "DISPLAY_FPS action description");
491 keyboardActionDescription_[SAVE_SCREENSHOT] = tr("Saves a screenshot", "SAVE_SCREENSHOT action description");
492 keyboardActionDescription_[FULL_SCREEN] = tr("Toggles full screen display", "FULL_SCREEN action description");
493 keyboardActionDescription_[DRAW_AXIS] = tr("Toggles the display of the world axis", "DRAW_AXIS action description");
494 keyboardActionDescription_[DRAW_GRID] = tr("Toggles the display of the XY grid", "DRAW_GRID action description");
495 keyboardActionDescription_[CAMERA_MODE] = tr("Changes camera mode (observe or fly)", "CAMERA_MODE action description");
498 keyboardActionDescription_[ANIMATION] = tr("Starts/stops the animation", "ANIMATION action description");
499 keyboardActionDescription_[EDIT_CAMERA] = tr("Toggles camera paths display", "EDIT_CAMERA action description"); // TODO change
500 keyboardActionDescription_[ENABLE_TEXT] = tr("Toggles the display of the text", "ENABLE_TEXT action description");
501 keyboardActionDescription_[EXIT_VIEWER] = tr("Exits program", "EXIT_VIEWER action description");
502 keyboardActionDescription_[MOVE_CAMERA_LEFT] = tr("Moves camera left", "MOVE_CAMERA_LEFT action description");
503 keyboardActionDescription_[MOVE_CAMERA_RIGHT] = tr("Moves camera right", "MOVE_CAMERA_RIGHT action description");
504 keyboardActionDescription_[MOVE_CAMERA_UP] = tr("Moves camera up", "MOVE_CAMERA_UP action description");
505 keyboardActionDescription_[MOVE_CAMERA_DOWN] = tr("Moves camera down", "MOVE_CAMERA_DOWN action description");
506 keyboardActionDescription_[INCREASE_FLYSPEED] = tr("Increases fly speed", "INCREASE_FLYSPEED action description");
507 keyboardActionDescription_[DECREASE_FLYSPEED] = tr("Decreases fly speed", "DECREASE_FLYSPEED action description");
508 keyboardActionDescription_[SNAPSHOT_TO_CLIPBOARD] = tr("Copies a snapshot to clipboard", "SNAPSHOT_TO_CLIPBOARD action description");
538 Qt::KeyboardModifiers modifiers = (mh == FRAME) ? frameKeyboardModifiers : cameraKeyboardModifiers;
579 setMouseBinding(frameKeyboardModifiers | macKeyboardModifiers, Qt::LeftButton, CENTER_FRAME, true);
580 setMouseBinding(frameKeyboardModifiers | macKeyboardModifiers, Qt::LeftButton, FRAME, TRANSLATE);
626 for (QMap<int, KeyFrameInterpolator*>::ConstIterator it = camera()->kfi_.begin(), end=camera()->kfi_.end(); it != end; ++it)
631 disconnect(camera()->keyFrameInterpolator(it.key()), SIGNAL(interpolated()), this, SLOT(update()));
690 gluCylinder(quadric, 0.0, 0.7 * length * sin(cutOff * M_PI / 180.0), 0.7 * length * cos(cutOff * M_PI / 180.0), 12, 1);
700 Frame fr=Frame(camera()->cameraCoordinatesOf(4.0 * length * camera()->frame()->inverseTransformOf(dir)),
748 (y-tileRegion_->yMin) * height() / (tileRegion_->yMax - tileRegion_->yMin), text, scaledFont(fnt));
793 drawText(10, int(1.5*((QApplication::font().pixelSize()>0)?QApplication::font().pixelSize():QApplication::font().pointSize())), fpsString_);
1079 // Get the number of objects that were seen through the pick matrix frustum. Reset GL_RENDER mode.
1087 // selectBuffer[4*i+1] is the object minimum depth value, while selectBuffer[4*i+3] is the id pushed on the stack.
1088 // Of all the objects that were projected in the pick region, we select the closest one (zMin comparison).
1089 // This code needs to be modified if you use several stack levels. See glSelectBuffer() man page.
1116 if (b & Qt::LeftButton) { result += QGLViewer::tr("Left", "left mouse button"); addAmpersand=true; }
1117 if (b & Qt::MidButton) { if (addAmpersand) result += " & "; result += QGLViewer::tr("Middle", "middle mouse button"); addAmpersand=true; }
1118 if (b & Qt::RightButton) { if (addAmpersand) result += " & "; result += QGLViewer::tr("Right", "right mouse button"); }
1195 ClickBindingPrivate cbp(e->modifiers(), e->button(), false, (Qt::MouseButtons)(e->buttons() & ~(e->button())), currentlyPressedKey_);
1204 for (QMap<MouseBindingPrivate, MouseActionPrivate>::ConstIterator it=mouseBinding_.begin(), end=mouseBinding_.end(); it!=end; ++it)
1303 (dynamic_cast<ManipulatedFrame*>(mouseGrabber()))->ManipulatedFrame::mouseMoveEvent(e, camera());
1358 (dynamic_cast<ManipulatedFrame*>(mouseGrabber()))->ManipulatedFrame::mouseReleaseEvent(e, camera());
1398 for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator it=wheelBinding_.begin(), end=wheelBinding_.end(); it!=end; ++it)
1461 ClickBindingPrivate cbp(e->modifiers(), e->button(), true, (Qt::MouseButtons)(e->buttons() & ~(e->button())), currentlyPressedKey_);
1494 QMessageBox::warning(this, tr("Stereo not supported", "Message box window title"), tr("Stereo is not supported on this display."));
1538 mouseGrabberIsAManipulatedCameraFrame_ = ((dynamic_cast<ManipulatedCameraFrame*>(mouseGrabber) != NULL) &&
1544 void QGLViewer::setMouseGrabberIsEnabled(const qglviewer::MouseGrabber* const mouseGrabber, bool enabled)
1560 case QGLViewer::MOVE_FORWARD : return QGLViewer::tr("Moves forward", "MOVE_FORWARD mouse action");
1561 case QGLViewer::LOOK_AROUND : return QGLViewer::tr("Looks around", "LOOK_AROUND mouse action");
1562 case QGLViewer::MOVE_BACKWARD : return QGLViewer::tr("Moves backward", "MOVE_BACKWARD mouse action");
1563 case QGLViewer::SCREEN_ROTATE : return QGLViewer::tr("Rotates in screen plane", "SCREEN_ROTATE mouse action");
1566 case QGLViewer::SCREEN_TRANSLATE : return QGLViewer::tr("Horizontally/Vertically translates", "SCREEN_TRANSLATE mouse action");
1567 case QGLViewer::ZOOM_ON_REGION : return QGLViewer::tr("Zooms on region for", "ZOOM_ON_REGION mouse action");
1577 case QGLViewer::ZOOM_ON_PIXEL : return QGLViewer::tr("Zooms on pixel", "ZOOM_ON_PIXEL click action");
1578 case QGLViewer::ZOOM_TO_FIT : return QGLViewer::tr("Zooms to fit scene", "ZOOM_TO_FIT click action");
1580 case QGLViewer::RAP_FROM_PIXEL : return QGLViewer::tr("Sets pivot point", "RAP_FROM_PIXEL click action");
1581 case QGLViewer::RAP_IS_CENTER : return QGLViewer::tr("Resets pivot point", "RAP_IS_CENTER click action");
1582 case QGLViewer::CENTER_FRAME : return QGLViewer::tr("Centers manipulated frame", "CENTER_FRAME click action");
1583 case QGLViewer::CENTER_SCENE : return QGLViewer::tr("Centers scene", "CENTER_SCENE click action");
1584 case QGLViewer::SHOW_ENTIRE_SCENE : return QGLViewer::tr("Shows entire scene", "SHOW_ENTIRE_SCENE click action");
1585 case QGLViewer::ALIGN_FRAME : return QGLViewer::tr("Aligns manipulated frame", "ALIGN_FRAME click action");
1586 case QGLViewer::ALIGN_CAMERA : return QGLViewer::tr("Aligns camera", "ALIGN_CAMERA click action");
1606 // modifiers never has a '+' sign. Add one space to clearly separate modifiers (and possible key) from button
1609 // modifiers might be of the form : 'S' or 'Ctrl+S' or 'Ctrl+'. For consistency, add an other '+' if needed, no spaces
1615 return tr("%1%2%3%4%5%6", "Modifier / button or wheel / double click / with / button / pressed")
1617 .arg(mouseButtonsString(cbp.button)+(cbp.button == Qt::NoButton ? tr("Wheel", "Mouse wheel") : ""))
1625 return (key >= Qt::Key_Any && key < Qt::Key_Escape) || (key >= Qt::Key_F1 && key <= Qt::Key_F35);
1633 void QGLViewer::setMouseBindingDescription(int state, QString description, bool doubleClick, Qt::MouseButtons buttonsBefore) {
1634 qWarning("setMouseBindingDescription(int state,...) is deprecated. Use the modifier/button equivalent");
1647 void QGLViewer::setMouseBindingDescription(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick, Qt::MouseButtons buttonsBefore)
1649 setMouseBindingDescription(Qt::Key(0), modifiers, button, description, doubleClick, buttonsBefore);
1681 void QGLViewer::setMouseBindingDescription(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick, Qt::MouseButtons buttonsBefore)
1725 text += QString("<tr bgcolor=\"#aaaacc\"><th align=\"center\">%1</th><th align=\"center\">%2</th></tr>\n").
1726 arg(tr("Button(s)", "Buttons column header in help window mouse tab")).arg(tr("Description", "Description column header in help window mouse tab"));
1731 for (QMap<ClickBindingPrivate, QString>::ConstIterator itm=mouseDescription_.begin(), endm=mouseDescription_.end(); itm!=endm; ++itm)
1734 for (QMap<ClickBindingPrivate, QString>::ConstIterator it=mouseBinding.begin(), end=mouseBinding.end(); it != end; ++it)
1747 text += QString("<tr bgcolor=\"#aaaacc\"><td colspan=2>%1</td></tr>\n").arg(tr("Standard mouse bindings", "In help window mouse tab"));
1751 // The order is significant and corresponds to the priorities set in mousePressEvent() (reverse priority order, last one overwrites previous)
1753 for (QMap<MouseBindingPrivate, MouseActionPrivate>::ConstIterator itmb=mouseBinding_.begin(), endmb=mouseBinding_.end();
1756 ClickBindingPrivate cbp(itmb.key().modifiers, itmb.key().button, false, Qt::NoButton, itmb.key().key);
1773 for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator itw=wheelBinding_.begin(), endw=wheelBinding_.end(); itw != endw; ++itw)
1775 ClickBindingPrivate cbp(itw.key().modifiers, Qt::NoButton, false, Qt::NoButton, itw.key().key);
1793 for (QMap<ClickBindingPrivate, ClickAction>::ConstIterator itcb=clickBinding_.begin(), endcb=clickBinding_.end(); itcb!=endcb; ++itcb)
1796 for (QMap<ClickBindingPrivate, QString>::ConstIterator it2=mouseBinding.begin(), end2=mouseBinding.end(); it2 != end2; ++it2)
1838 for (QMap<Qt::Key, int>::ConstIterator i = pathIndex_.begin(), endi=pathIndex_.end(); i != endi; ++i)
1909 text += QString("<tr bgcolor=\"#aaaacc\"><th align=\"center\">%1</th><th align=\"center\">%2</th></tr>\n").
1910 arg(QGLViewer::tr("Key(s)", "Keys column header in help window mouse tab")).arg(QGLViewer::tr("Description", "Description column header in help window mouse tab"));
1915 for (QMap<int, QString>::ConstIterator kd=keyDescription_.begin(), kdend=keyDescription_.end(); kd!=kdend; ++kd)
1919 for (QMap<int, QString>::ConstIterator kb=keyDescription.begin(), endb=keyDescription.end(); kb!=endb; ++kb)
1927 text += QString("<tr bgcolor=\"#aaaacc\"><td colspan=2>%1</td></tr>\n").arg(QGLViewer::tr("Standard viewer keys", "In help window keys tab"));
1932 for (QMap<KeyboardAction, unsigned int>::ConstIterator it=keyboardBinding_.begin(), end=keyboardBinding_.end(); it != end; ++it)
1933 if ((it.value() != 0) && ((!cameraIsInRotateMode()) || ((it.key() != INCREASE_FLYSPEED) && (it.key() != DECREASE_FLYSPEED))))
1937 for (QMap<int, QString>::ConstIterator kb2=keyDescription.begin(), endb2=keyDescription.end(); kb2!=endb2; ++kb2)
1946 text += QGLViewer::tr("Camera paths are controlled using the %1 keys (noted <i>Fx</i> below):", "Help window key tab camera keys").arg(cpks) + "</td></tr>\n";
1947 text += tableLine(keyString(playPathKeyboardModifiers()) + "<i>" + QGLViewer::tr("Fx", "Generic function key (F1..F12)") + "</i>",
1949 text += tableLine(keyString(addKeyFrameKeyboardModifiers()) + "<i>" + QGLViewer::tr("Fx", "Generic function key (F1..F12)") + "</i>",
1951 text += tableLine(keyString(addKeyFrameKeyboardModifiers()) + "<i>" + QGLViewer::tr("Fx", "Generic function key (F1..F12)") + "</i>+<i>" + QGLViewer::tr("Fx", "Generic function key (F1..F12)") + "</i>",
1983 static QString label[] = {tr("&Help", "Help window tab title"), tr("&Keyboard", "Help window tab title"), tr("&Mouse", "Help window tab title"), tr("&About", "Help window about title")};
2020 "<code>%3</code>").arg(QGLViewerVersionString()).arg("2014").arg("http://www.libqglviewer.com") +
2078 QMap<KeyboardAction, unsigned int>::ConstIterator it=keyboardBinding_.begin(), end=keyboardBinding_.end();
2119 disconnect(camera()->keyFrameInterpolator(index), SIGNAL(interpolated()), this, SLOT(update()));
2170 displayMessage(cameraIsInRotateMode()?tr("Camera in observer mode", "Feedback message"):tr("Camera in fly mode", "Feedback message"));
2174 camera()->frame()->translate(camera()->frame()->inverseTransformOf(Vec(-10.0*camera()->flySpeed(), 0.0, 0.0)));
2178 camera()->frame()->translate(camera()->frame()->inverseTransformOf(Vec( 10.0*camera()->flySpeed(), 0.0, 0.0)));
2182 camera()->frame()->translate(camera()->frame()->inverseTransformOf(Vec(0.0, 10.0*camera()->flySpeed(), 0.0)));
2186 camera()->frame()->translate(camera()->frame()->inverseTransformOf(Vec(0.0, -10.0*camera()->flySpeed(), 0.0)));
2288 for (QMap<Qt::Key, int>::ConstIterator it = pathIndex_.begin(), end=pathIndex_.end(); it != end; ++it)
2444 void QGLViewer::setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardModifiers modifiers)
2480 for (QMap<ClickBindingPrivate, ClickAction>::ConstIterator cb=clickBinding_.begin(), end=clickBinding_.end(); cb != end; ++cb)
2484 ClickBindingPrivate cbp(modifiers, cb.key().button, cb.key().doubleClick, cb.key().buttonsBefore, cb.key().key);
2511 void QGLViewer::setMouseBinding(int state, MouseHandler handler, MouseAction action, bool withConstraint)
2513 qWarning("setMouseBinding(int state, MouseHandler...) is deprecated. Use the modifier/button equivalent");
2526 void QGLViewer::setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, MouseHandler handler, MouseAction action, bool withConstraint) {
2562 void QGLViewer::setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, MouseHandler handler, MouseAction action, bool withConstraint)
2596 void QGLViewer::setMouseBinding(int state, ClickAction action, bool doubleClick, Qt::MouseButtons buttonsBefore) {
2597 qWarning("setMouseBinding(int state, ClickAction...) is deprecated. Use the modifier/button equivalent");
2610 void QGLViewer::setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick, Qt::MouseButtons buttonsBefore)
2635 void QGLViewer::setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick, Qt::MouseButtons buttonsBefore)
2665 void QGLViewer::setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint) {
2679 void QGLViewer::setWheelBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint)
2682 if ((action != ZOOM) && (action != MOVE_FORWARD) && (action != MOVE_BACKWARD) && (action != NO_MOUSE_ACTION)) {
2729 return mouseAction(Qt::Key(0), keyboardModifiersFromState(state), mouseButtonFromState(state));
2746 QGLViewer::MouseAction QGLViewer::mouseAction(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const
2761 return mouseHandler(Qt::Key(0), keyboardModifiersFromState(state), mouseButtonFromState(state));
2776 int QGLViewer::mouseHandler(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const
2791 int QGLViewer::mouseButtonState(MouseHandler handler, MouseAction action, bool withConstraint) const {
2792 qWarning("mouseButtonState() is deprecated. Use mouseButtons() and keyboardModifiers() instead");
2793 for (QMap<MouseBindingPrivate, MouseActionPrivate>::ConstIterator it=mouseBinding_.begin(), end=mouseBinding_.end(); it != end; ++it)
2794 if ( (it.value().handler == handler) && (it.value().action == action) && (it.value().withConstraint == withConstraint) )
2808 void QGLViewer::getWheelActionBinding(MouseHandler handler, MouseAction action, bool withConstraint,
2811 for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator it=wheelBinding_.begin(), end=wheelBinding_.end(); it != end; ++it)
2812 if ( (it.value().handler == handler) && (it.value().action == action) && (it.value().withConstraint == withConstraint) ) {
2829 void QGLViewer::getMouseActionBinding(MouseHandler handler, MouseAction action, bool withConstraint,
2832 for (QMap<MouseBindingPrivate, MouseActionPrivate>::ConstIterator it=mouseBinding_.begin(), end=mouseBinding_.end(); it != end; ++it)
2833 if ( (it.value().handler == handler) && (it.value().action == action) && (it.value().withConstraint == withConstraint) ) {
2851 QGLViewer::MouseAction QGLViewer::wheelAction(Qt::Key key, Qt::KeyboardModifiers modifiers) const
2876 QGLViewer::ClickAction QGLViewer::clickAction(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button,
2890 qWarning("wheelAction() is deprecated. Use the new wheelAction() method with a key parameter instead");
2898 qWarning("wheelHandler() is deprecated. Use the new wheelHandler() method with a key parameter instead");
2905 int QGLViewer::wheelButtonState(MouseHandler handler, MouseAction action, bool withConstraint) const
2907 qWarning("wheelButtonState() is deprecated. Use the wheelAction() and wheelHandler() instead");
2908 for (QMap<WheelBindingPrivate, MouseActionPrivate>::ConstIterator it=wheelBinding_.begin(), end=wheelBinding_.end(); it!=end; ++it)
2909 if ( (it.value().handler == handler) && (it.value().action == action) && (it.value().withConstraint == withConstraint) )
2919 QGLViewer::ClickAction QGLViewer::clickAction(int state, bool doubleClick, Qt::MouseButtons buttonsBefore) const {
2932 void QGLViewer::getClickButtonState(ClickAction action, int& state, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const {
2933 qWarning("getClickButtonState(int state,...) is deprecated. Use the modifier/button equivalent");
2949 void QGLViewer::getClickActionBinding(ClickAction action, Qt::Key& key, Qt::KeyboardModifiers& modifiers, Qt::MouseButton &button, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const
2951 for (QMap<ClickBindingPrivate, ClickAction>::ConstIterator it=clickBinding_.begin(), end=clickBinding_.end(); it != end; ++it)
3384 name = fi.absolutePath() + '/' + fi.completeBaseName() + QString::number(QGLViewer::QGLViewerIndex(this)) + "." + fi.suffix();
3408 QMessageBox::warning(this, tr("Save to file error", "Message box window title"), tr("State file name (%1) references a directory instead of a file.").arg(name));
3418 QMessageBox::warning(this, tr("Save to file error", "Message box window title"), tr("Unable to create directory %1").arg(dirName));
3435 QMessageBox::warning(this, tr("Save to file error", "Message box window title"), tr("Unable to save to file %1").arg(name) + ":\n" + f.errorString());
3473 QMessageBox::warning(this, tr("Problem in state restoration", "Message box window title"), tr("File %1 is not readable.").arg(name));
3489 QMessageBox::warning(this, tr("Open file error", "Message box window title"), tr("Unable to open file %1").arg(name) + ":\n" + f.errorString());
3535 stateNode.appendChild(DomUtils::QColorDomElement(foregroundColor(), "foregroundColor", document));
3536 stateNode.appendChild(DomUtils::QColorDomElement(backgroundColor(), "backgroundColor", document));
3620 qWarning("State file created using QGLViewer version %s may not be correctly read.", version.toLatin1().constData());
3695 // "real" coef BEFORE calling setCameraIsEdited. Hence this temp cameraIsEdited and delayed call
3827 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, bufferTextureWidth_, bufferTextureHeight_, 0, format, GL_UNSIGNED_BYTE, NULL);
QColor foregroundColor() const
Returns the foreground color used by the viewer.
Definition: qglviewer.h:182
QColor backgroundColor() const
Returns the background color of the viewer.
Definition: qglviewer.h:168
KeyFrameInterpolator * keyFrameInterpolator(int i) const
Returns the KeyFrameInterpolator that defines the Camera path number i.
Definition: camera.cpp:1664
virtual void timerEvent(QTimerEvent *)
Overloading of the QObject method.
Definition: qglviewer.cpp:864
A keyFrame Catmull-Rom Frame interpolator.
Definition: keyFrameInterpolator.h:126
Vec projectedCoordinatesOf(const Vec &src, const Frame *frame=NULL) const
Returns the screen projected coordinates of a point src defined in the frame coordinate system...
Definition: camera.cpp:1584
virtual void beginSelection(const QPoint &point)
This method should prepare the selection.
Definition: qglviewer.cpp:1012
virtual void help()
Opens a modal help window that includes four tabs, respectively filled with helpString(), keyboardString(), mouseString() and about libQGLViewer.
Definition: qglviewer.cpp:1975
virtual void drawWithNames()
This method is called by select() and should draw selectable entities.
Definition: qglviewer.h:885
Definition: camera.h:29
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings...
Definition: manipulatedCameraFrame.h:47
virtual QString mouseString() const
Returns a QString that describes the application mouse bindings, displayed in the help() window Mouse...
Definition: qglviewer.cpp:1718
virtual void initFromDOMElement(const QDomElement &element)
Restores the ManipulatedFrame state from a QDomElement created by domElement().
Definition: manipulatedFrame.cpp:138
void toggleCameraMode()
Swaps between two predefined camera mouse bindings.
Definition: qglviewer.cpp:2993
void displayMessage(const QString &message, int delay=2000)
Briefly displays a message in the lower left corner of the widget.
Definition: qglviewer.cpp:764
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.
Definition: qglviewer.cpp:2829
Vec pivotPoint() const
The point the Camera pivots around with the QGLViewer::ROTATE mouse binding.
Definition: camera.cpp:1275
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
Definition: manipulatedFrame.h:95
virtual void select(const QMouseEvent *event)
Simple wrapper method: calls select(event->pos()).
Definition: qglviewer.cpp:936
void setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true)
Defines a mouse wheel binding.
Definition: qglviewer.cpp:2665
Qt::KeyboardModifiers addKeyFrameKeyboardModifiers() const
Returns the keyboard modifiers that must be pressed with a pathKey() to add the current camera positi...
Definition: qglviewer.cpp:2334
virtual void drawLight(GLenum light, float scale=1.0f) const
Draws a representation of light.
Definition: qglviewer.cpp:656
void setForegroundColor(const QColor &color)
Sets the foregroundColor() of the viewer, used to draw visual hints.
Definition: qglviewer.h:188
unsigned int shortcut(KeyboardAction action) const
Returns the keyboard shortcut associated to a given QGLViewer::KeyboardAction.
Definition: qglviewer.cpp:2247
virtual void mouseMoveEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1296
void translate(Vec &t)
Same as translate(const Vec&) but t may be modified to satisfy the translation constraint().
Definition: frame.cpp:335
MouseAction
Defines the possible actions that can be binded to a mouse action (a click, followed by a mouse displ...
Definition: qglviewer.h:969
virtual void fastDraw()
Draws a simplified version of the scene to guarantee interactive camera displacements.
Definition: qglviewer.cpp:437
QFont scaledFont(const QFont &font) const
Return a possibly scaled version of font, used for snapshot rendering.
Definition: qglviewer.h:552
virtual void mousePressEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1191
void saveToFile(const QString &fileName=QString::null)
This method is deprecated since version 1.3.9-5.
Definition: qglviewer.cpp:3708
virtual void checkIfGrabsMouse(int x, int y, const Camera *const camera)=0
Pure virtual method, called by the QGLViewers before they test if the MouseGrabber grabsMouse()...
virtual void preDrawStereo(bool leftBuffer=true)
Called before draw() (instead of preDraw()) when viewer displaysInStereo().
Definition: qglviewer.cpp:410
void alignWithFrame(const Frame *const frame, bool move=false, float threshold=0.0f)
Aligns the Frame with frame, so that two of their axis are parallel.
Definition: frame.cpp:1055
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
Callback method called when the MouseGrabber grabsMouse() and a mouse button is double clicked...
Definition: mouseGrabber.h:235
virtual void drawAllPaths()
Draws all the Camera paths defined by the keyFrameInterpolator().
Definition: camera.cpp:1778
virtual void stopScreenCoordinatesSystem() const
Stops the pixel coordinate drawing block started by startScreenCoordinatesSystem().
Definition: qglviewer.cpp:852
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.
Definition: qglviewer.cpp:2949
int mouseHandler(int state) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2759
const GLdouble * matrix() const
Returns the 4x4 OpenGL transformation matrix represented by the Frame.
Definition: frame.cpp:123
virtual void initFromDOMElement(const QDomElement &element)
Restores the Camera state from a QDomElement created by domElement().
Definition: camera.cpp:1869
void setStateFileName(const QString &name)
Defines the stateFileName() used by saveStateToFile() and restoreStateFromFile(). ...
Definition: qglviewer.h:1059
MouseAction mouseAction(int state) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2727
qglviewer::ManipulatedFrame * manipulatedFrame() const
Returns the viewer's qglviewer::ManipulatedFrame.
Definition: qglviewer.h:262
int wheelButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2905
virtual void loadProjectionMatrixStereo(bool leftBuffer=true) const
Same as loadProjectionMatrix() but for a stereo setup.
Definition: camera.cpp:536
virtual void loadModelViewMatrix(bool reset=true) const
Loads the OpenGL GL_MODELVIEW matrix with the modelView matrix corresponding to the Camera...
Definition: camera.cpp:500
void setZClippingCoefficient(float coef)
Sets the zClippingCoefficient() value.
Definition: camera.h:268
void setMouseGrabberIsEnabled(const qglviewer::MouseGrabber *const mouseGrabber, bool enabled=true)
Sets the mouseGrabberIsEnabled() state.
Definition: qglviewer.cpp:1544
QGLViewer(QWidget *parent=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
Constructor.
Definition: qglviewer.cpp:160
virtual QString keyboardString() const
Returns a QString that describes the application keyboard shortcut bindings, and that will be display...
Definition: qglviewer.cpp:1906
ClickAction clickAction(int state, bool doubleClick, Qt::MouseButtons buttonsBefore) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2919
Qt::KeyboardModifiers playPathKeyboardModifiers() const
Returns the keyboard modifiers that must be pressed with a pathKey() to play a camera KeyFrame path...
Definition: qglviewer.cpp:2347
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:827
KeyboardAction
Defines the different actions that can be associated with a keyboard shortcut using setShortcut()...
Definition: qglviewer.h:905
virtual bool restoreStateFromFile()
Restores the QGLViewer state from the stateFileName() file using initFromDOMElement().
Definition: qglviewer.cpp:3458
void saveSnapshot(bool automatic=true, bool overwrite=false)
Saves a snapshot of the current image displayed by the widget.
Definition: saveSnapshot.cpp:537
bool axisIsDrawn() const
Returns true if the world axis is drawn by the viewer.
Definition: qglviewer.h:97
ManipulatedCameraFrame * frame() const
Returns the ManipulatedCameraFrame attached to the Camera.
Definition: camera.h:334
Abstract class for objects that grab mouse focus in a QGLViewer.
Definition: mouseGrabber.h:130
virtual void setVisualHintsMask(int mask, int delay=2000)
Defines the mask that will be used to drawVisualHints().
Definition: qglviewer.cpp:3179
bool textIsEnabled() const
Returns true if text display (see drawText()) is enabled.
Definition: qglviewer.h:113
virtual void endSelection(const QPoint &point)
This method is called by select() after scene elements were drawn by drawWithNames().
Definition: qglviewer.cpp:1072
virtual void loadModelViewMatrixStereo(bool leftBuffer=true) const
Same as loadModelViewMatrix() but for a stereo setup.
Definition: camera.cpp:591
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...
Definition: qglviewer.cpp:2808
bool isFullScreen() const
Returns true if the viewer is in fullScreen mode.
Definition: qglviewer.h:329
virtual void mouseReleaseEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1353
void resetInterpolation()
Stops the interpolation and resets interpolationTime() to the firstTime().
Definition: keyFrameInterpolator.cpp:156
GLuint bufferTextureId() const
Returns the texture id of the texture created by copyBufferToTexture().
Definition: qglviewer.cpp:3839
void setFullScreen(bool fullScreen=true)
Sets the isFullScreen() state.
Definition: qglviewer.cpp:1503
void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardModifiers modifiers)
This method has been deprecated since version 2.5.0.
Definition: qglviewer.cpp:2444
void showEntireScene()
Moves the Camera so that the entire scene is visible.
Definition: camera.cpp:987
int numberOfKeyFrames() const
Returns the number of keyFrames used by the interpolation.
Definition: keyFrameInterpolator.h:192
bool gridIsDrawn() const
Returns true if a XY grid is drawn by the viewer.
Definition: qglviewer.h:101
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 k...
Definition: qglviewer.cpp:2851
void setScreenWidthAndHeight(int width, int height)
Sets Camera screenWidth() and screenHeight() (expressed in pixels).
Definition: camera.cpp:166
bool displaysInStereo() const
Returns true if the viewer displays in stereo.
Definition: qglviewer.h:349
void setTranslation(const Vec &translation)
Sets the translation() of the frame, locally defined with respect to the referenceFrame().
Definition: frame.h:201
void setStereoDisplay(bool stereo=true)
Sets the state of displaysInStereo().
Definition: qglviewer.cpp:1475
virtual void setPathKey(int key, int index=0)
Sets the pathKey() associated with the camera Key Frame path index.
Definition: qglviewer.cpp:2305
virtual void startAction(int ma, bool withConstraint=true)
Protected internal method used to handle mouse events.
Definition: manipulatedCameraFrame.cpp:194
int mouseButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2791
virtual void addKeyFrameToPath(int i)
Adds the current Camera position() and orientation() as a keyFrame to the path number i...
Definition: camera.cpp:1710
int selectRegionHeight() const
See the selectRegionWidth() documentation.
Definition: qglviewer.h:837
bool interpolationIsStarted() const
Returns true when the interpolation is being performed.
Definition: keyFrameInterpolator.h:266
void setMouseGrabber(qglviewer::MouseGrabber *mouseGrabber)
Directly defines the mouseGrabber().
Definition: qglviewer.cpp:1530
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Returns an XML QDomElement that represents the QGLViewer.
Definition: qglviewer.cpp:3528
void setManipulatedFrame(qglviewer::ManipulatedFrame *frame)
Sets the viewer's manipulatedFrame().
Definition: qglviewer.cpp:3055
virtual void loadProjectionMatrix(bool reset=true) const
Loads the OpenGL GL_PROJECTION matrix with the Camera projection matrix.
Definition: camera.cpp:463
Qt::Key pathKey(int index) const
Returns the keyboard key associated to camera Key Frame path index.
Definition: qglviewer.cpp:2286
void mouseGrabberChanged(qglviewer::MouseGrabber *mouseGrabber)
Signal emitted by setMouseGrabber() when the mouseGrabber() is changed.
virtual void resizeGL(int width, int height)
Callback method used when the widget size is modified.
Definition: qglviewer.cpp:2199
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
Stops the ManipulatedFrame mouse manipulation.
Definition: manipulatedFrame.cpp:461
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
Overloading of MouseGrabber::wheelEvent().
Definition: manipulatedFrame.cpp:497
void setBackgroundColor(const QColor &color)
Sets the backgroundColor() of the viewer and calls qglClearColor().
Definition: qglviewer.h:186
virtual void wheelEvent(QWheelEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1392
void interpolateToFitScene()
Interpolates the Camera on a one second KeyFrameInterpolator path so that the entire scene fits the s...
Definition: camera.cpp:913
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
Callback method called when the MouseGrabber grabsMouse() and the mouse wheel is used.
Definition: mouseGrabber.h:247
virtual void postSelection(const QPoint &point)
This method is called at the end of the select() procedure.
Definition: qglviewer.h:894
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Modifies the ManipulatedFrame according to the mouse motion.
Definition: manipulatedFrame.cpp:329
void projectOnLine(const Vec &origin, const Vec &direction)
Translates the Frame so that its position() lies on the line defined by origin and direction (defined...
Definition: frame.cpp:1133
static void drawGrid(float size=1.0f, int nbSubdivisions=10)
Draws a grid in the XY plane, centered on (0,0,0) (defined in the current coordinate system)...
Definition: qglviewer.cpp:3321
MouseHandler
Defines the different mouse handlers: camera() or manipulatedFrame().
Definition: qglviewer.h:954
float zClippingCoefficient() const
Returns the coefficient used to position the near and far clipping planes.
Definition: camera.h:229
qglviewer::Camera * camera() const
Returns the associated qglviewer::Camera, never NULL.
Definition: qglviewer.h:250
virtual void deletePath(int i)
Deletes the keyFrameInterpolator() of index i.
Definition: camera.cpp:1762
void setShortcut(KeyboardAction action, unsigned int key)
Defines the shortcut() that triggers a given QGLViewer::KeyboardAction.
Definition: qglviewer.cpp:2227
bool FPSIsDisplayed() const
Returns true if the viewer displays the current frame rate (Frames Per Second).
Definition: qglviewer.h:108
ClickAction
Defines the possible actions that can be binded to a mouse click using setMouseBinding(Qt::KeyboardMo...
Definition: qglviewer.h:960
The Quaternion class represents 3D rotations and orientations.
Definition: quaternion.h:66
void setMouseBindingDescription(int state, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton)
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:1633
static const QList< QGLViewer * > & QGLViewerPool()
Returns a QList that contains pointers to all the created QGLViewers.
Definition: qglviewer.h:1085
void setFPSIsDisplayed(bool display=true)
Sets the state of FPSIsDisplayed().
Definition: qglviewer.h:132
void setPivotPoint(const Vec &point)
Changes the pivotPoint() to point (defined in the world coordinate system).
Definition: camera.cpp:770
void snapshotToClipboard()
Takes a snapshot of the current display and pastes it to the clipboard.
Definition: saveSnapshot.cpp:633
void setMouseBinding(int state, MouseHandler handler, MouseAction action, bool withConstraint=true)
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2511
bool grabsMouse() const
Returns true when the MouseGrabber grabs the QGLViewer's mouse events.
Definition: mouseGrabber.h:179
void getClickButtonState(ClickAction action, int &state, bool &doubleClick, Qt::MouseButtons &buttonsBefore) const
This method is deprecated since version 2.5.0.
Definition: qglviewer.cpp:2932
void centerScene()
Moves the Camera so that its sceneCenter() is projected on the center of the window.
Definition: camera.cpp:997
void setCamera(qglviewer::Camera *const camera)
Associates a new qglviewer::Camera to the viewer.
Definition: qglviewer.cpp:600
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
This is an overload of ManipulatedFrame::wheelEvent().
Definition: manipulatedCameraFrame.cpp:413
virtual void playPath(int i)
Makes the Camera follow the path of keyFrameInterpolator() number i.
Definition: camera.cpp:1726
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
Mouse release event callback method.
Definition: mouseGrabber.h:237
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:741
qglviewer::Vec sceneCenter() const
Returns the scene center, defined in world coordinates.
Definition: qglviewer.h:215
void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE)
Makes a copy of the current buffer into a texture.
Definition: qglviewer.cpp:3782
virtual void saveStateToFile()
Saves in stateFileName() an XML representation of the QGLViewer state, obtained from domElement()...
Definition: qglviewer.cpp:3397
bool cameraIsEdited() const
Returns true if the camera() is being edited in the viewer.
Definition: qglviewer.h:123
virtual void mousePressEvent(QMouseEvent *const event, Camera *const camera)
Initiates the ManipulatedFrame mouse manipulation.
Definition: manipulatedFrame.cpp:305
virtual void mouseDoubleClickEvent(QMouseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:1458
virtual void stopSpinning()
Stops the spinning motion started using startSpinning().
Definition: manipulatedFrame.h:239
bool isManipulated() const
Returns true when the ManipulatedFrame is being manipulated with the mouse.
Definition: manipulatedFrame.cpp:174
static void drawArrow(float length=1.0f, float radius=-1.0f, int nbSubdivisions=12)
Draws a 3D arrow along the positive Z axis.
Definition: qglviewer.cpp:3205
virtual void resetVisualHints()
Reset the mask used by drawVisualHints().
Definition: qglviewer.cpp:3186
virtual void closeEvent(QCloseEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:891
void stereoChanged(bool on)
This signal is emitted whenever displaysInStereo() changes value.
void getViewport(GLint viewport[4]) const
Fills viewport with the Camera OpenGL viewport.
Definition: camera.cpp:1502
virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers modifiers)
Sets the addKeyFrameKeyboardModifiers() value.
Definition: qglviewer.cpp:2320
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition: frame.h:121
bool mouseGrabberIsEnabled(const qglviewer::MouseGrabber *const mouseGrabber)
Returns true if mouseGrabber is enabled.
Definition: qglviewer.h:301
qglviewer::MouseGrabber * mouseGrabber() const
Returns the current qglviewer::MouseGrabber, or NULL if no qglviewer::MouseGrabber currently grabs mo...
Definition: qglviewer.h:289
int selectRegionWidth() const
Returns the width (in pixels) of a selection frustum, centered on the mouse cursor, that is used to select objects.
Definition: qglviewer.h:835
virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modifiers)
Sets the playPathKeyboardModifiers() value.
Definition: qglviewer.cpp:2314
void cameraIsEditedChanged(bool edited)
This signal is emitted whenever cameraIsEdited() changes value.
virtual void initFromDOMElement(const QDomElement &element)
Restores the QGLViewer state from a QDomElement created by domElement().
Definition: qglviewer.cpp:3614
void toggleAnimation()
Calls startAnimation() or stopAnimation(), depending on animationIsStarted().
Definition: qglviewer.h:632
virtual void keyPressEvent(QKeyEvent *)
Overloading of the QWidget method.
Definition: qglviewer.cpp:2066
Vec position() const
Returns the position of the Frame, defined in the world coordinate system.
Definition: frame.cpp:537
void setCameraIsEdited(bool edit=true)
Starts (edit = true, default) or stops (edit=false) the edition of the camera().
Definition: qglviewer.cpp:449
static void drawAxis(float length=1.0f)
Draws an XYZ axis, with a given size (default is 1.0).
Definition: qglviewer.cpp:3253
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Callback method called when the MouseGrabber grabsMouse() and the mouse is moved while a button is pr...
Definition: mouseGrabber.h:243
void interpolateToZoomOnPixel(const QPoint &pixel)
Makes the Camera smoothly zoom on the pointUnderPixel() pixel.
Definition: camera.cpp:875
virtual void initializeGL()
Initializes the QGLViewer OpenGL context and then calls user-defined init().
Definition: qglviewer.cpp:239
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...
Definition: qglviewer.cpp:2864
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
This is an overload of ManipulatedFrame::mouseReleaseEvent().
Definition: manipulatedCameraFrame.cpp:396
virtual void mousePressEvent(QMouseEvent *const event, Camera *const camera)
Callback method called when the MouseGrabber grabsMouse() and a mouse button is pressed.
Definition: mouseGrabber.h:231
virtual void startAction(int ma, bool withConstraint=true)
Protected internal method used to handle mouse events.
Definition: manipulatedFrame.cpp:208
virtual void resetPath(int i)
Resets the path of the keyFrameInterpolator() number i.
Definition: camera.cpp:1741
bool animationIsStarted() const
Return true when the animation loop is started.
Definition: qglviewer.h:597
bool restoreFromFile(const QString &fileName=QString::null)
This function is deprecated since version 1.3.9-5.
Definition: qglviewer.cpp:3719
virtual QString helpString() const
Returns the QString displayed in the help() window main tab.
Definition: qglviewer.h:713
void setKeyDescription(int key, QString description)
Defines a custom keyboard shortcut description, that will be displayed in the help() window Keyboard ...
Definition: qglviewer.cpp:1823
virtual void postDraw()
Called after draw() to draw viewer visual hints.
Definition: qglviewer.cpp:339
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Overloading of ManipulatedFrame::mouseMoveEvent().
Definition: manipulatedCameraFrame.cpp:233
void drawFinished(bool automatic)
Signal emitted at the end of the QGLViewer::paintGL() method, when frame is drawn.
static int QGLViewerIndex(const QGLViewer *const viewer)
Returns the index of the QGLViewer viewer in the QGLViewerPool().
Definition: qglviewer.h:1095