qglviewer.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.4.0.
6 
7  http://www.libqglviewer.com - contact@libqglviewer.com
8 
9  This file may be used under the terms of the GNU General Public License
10  versions 2.0 or 3.0 as published by the Free Software Foundation and
11  appearing in the LICENSE file included in the packaging of this file.
12  In addition, as a special exception, Gilles Debunne gives you certain
13  additional rights, described in the file GPL_EXCEPTION in this package.
14 
15  libQGLViewer uses dual licensing. Commercial/proprietary software must
16  purchase a libQGLViewer Commercial License.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21 *****************************************************************************/
22 
23 #ifndef QGLVIEWER_QGLVIEWER_H
24 #define QGLVIEWER_QGLVIEWER_H
25 
26 #include "camera.h"
27 
28 #if QT_VERSION >= 0x040000
29 # include <QMap>
30 # include <QClipboard>
31 #else
32 # include <qmap.h>
33 # include <qclipboard.h>
34 #endif
35 
36 class QTabWidget;
37 
38 namespace qglviewer {
39  class MouseGrabber;
40 }
41 
42 #if QT_VERSION < 0x040000
43 # define Qt::KeyboardModifiers Qt::ButtonState
44 # define Qt::MouseButtons Qt::ButtonState
45 # define Qt::WindowFlags Qt::WFlags
46 #endif
47 
70 class QGLVIEWER_EXPORT QGLViewer : public QGLWidget
71 {
72  Q_OBJECT
73 
74 public:
75  // Complete implementation is provided so that the constructor is defined with QT3_SUPPORT when .h is included.
76  // (Would not be available otherwise since lib is compiled without QT3_SUPPORT).
77 #if QT_VERSION < 0x040000 || defined QT3_SUPPORT
78  explicit QGLViewer(QWidget* parent=NULL, const char* name=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0)
79  : QGLWidget(parent, name, shareWidget, flags)
80  { defaultConstructor(); }
81 
82  explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const char* name=0, const QGLWidget* shareWidget=0,Qt::WindowFlags flags=0)
83  : QGLWidget(format, parent, name, shareWidget, flags)
84  { defaultConstructor(); }
85 
86  QGLViewer(QGLContext* context, QWidget* parent, const char* name=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0)
87 # if QT_VERSION >= 0x030200
88  : QGLWidget(context, parent, name, shareWidget, flags) {
89 # else
90  // MOC_SKIP_BEGIN
91  : QGLWidget(parent, name, shareWidget, flags) {
92  Q_UNUSED(context);
93  // MOC_SKIP_END
94 # endif
95  defaultConstructor(); }
96 
97 #else
98 
99  explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0);
100  explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0);
101  explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0);
102 #endif
103 
104  virtual ~QGLViewer();
105 
108 public:
112  bool axisIsDrawn() const { return axisIsDrawn_; };
116  bool gridIsDrawn() const { return gridIsDrawn_; };
123  bool FPSIsDisplayed() const { return FPSIsDisplayed_; };
128  bool textIsEnabled() const { return textIsEnabled_; };
129 
138  bool cameraIsEdited() const { return cameraIsEdited_; }
139 
140 
141  public Q_SLOTS:
143  void setAxisIsDrawn(bool draw=true) { axisIsDrawn_ = draw; Q_EMIT axisIsDrawnChanged(draw); if (updateGLOK_) updateGL(); };
145  void setGridIsDrawn(bool draw=true) { gridIsDrawn_ = draw; Q_EMIT gridIsDrawnChanged(draw); if (updateGLOK_) updateGL(); };
147  void setFPSIsDisplayed(bool display=true) { FPSIsDisplayed_ = display; Q_EMIT FPSIsDisplayedChanged(display); if (updateGLOK_) updateGL(); };
149  void setTextIsEnabled(bool enable=true) { textIsEnabled_ = enable; Q_EMIT textIsEnabledChanged(enable); if (updateGLOK_) updateGL(); };
150  void setCameraIsEdited(bool edit=true);
151 
153  void toggleAxisIsDrawn() { setAxisIsDrawn(!axisIsDrawn()); };
155  void toggleGridIsDrawn() { setGridIsDrawn(!gridIsDrawn()); };
157  void toggleFPSIsDisplayed() { setFPSIsDisplayed(!FPSIsDisplayed()); };
159  void toggleTextIsEnabled() { setTextIsEnabled(!textIsEnabled()); };
161  void toggleCameraIsEdited() { setCameraIsEdited(!cameraIsEdited()); };
163 
164 
167 public:
183  QColor backgroundColor() const { return backgroundColor_; };
184 
197  QColor foregroundColor() const { return foregroundColor_; };
198  public Q_SLOTS:
201  void setBackgroundColor(const QColor& color) { backgroundColor_=color; qglClearColor(color); };
203  void setForegroundColor(const QColor& color) { foregroundColor_ = color; };
205 
206 
209 public:
221  float sceneRadius() const { return camera()->sceneRadius(); }
230  qglviewer::Vec sceneCenter() const { return camera()->sceneCenter(); }
231 
232  public Q_SLOTS:
237  virtual void setSceneRadius(float radius) { camera()->setSceneRadius(radius); }
238 
243  virtual void setSceneCenter(const qglviewer::Vec& center) { camera()->setSceneCenter(center); }
244 
252  void setSceneBoundingBox(const qglviewer::Vec& min, const qglviewer::Vec& max) { camera()->setSceneBoundingBox(min,max); }
253 
257  void showEntireScene() { camera()->showEntireScene(); if (updateGLOK_) updateGL(); }
259 
260 
263 public:
265  qglviewer::Camera* camera() const { return camera_; };
266 
277  qglviewer::ManipulatedFrame* manipulatedFrame() const { return manipulatedFrame_; };
278 
279  public Q_SLOTS:
280  void setCamera(qglviewer::Camera* const camera);
281  void setManipulatedFrame(qglviewer::ManipulatedFrame* frame);
283 
284 
287 public:
304  qglviewer::MouseGrabber* mouseGrabber() const { return mouseGrabber_; };
305 
306  void setMouseGrabberIsEnabled(const qglviewer::MouseGrabber* const mouseGrabber, bool enabled=true);
316  bool mouseGrabberIsEnabled(const qglviewer::MouseGrabber* const mouseGrabber) { return !disabledMouseGrabbers_.contains(reinterpret_cast<size_t>(mouseGrabber)); };
317  public Q_SLOTS:
318  void setMouseGrabber(qglviewer::MouseGrabber* mouseGrabber);
320 
321 
324 public:
326  float aspectRatio() const { return static_cast<float>(width())/static_cast<float>(height()); };
337  float currentFPS() { return f_p_s_; };
344  bool isFullScreen() const { return fullScreen_; };
364  bool displaysInStereo() const { return stereo_; }
366  virtual QSize sizeHint() const { return QSize(600, 400); }
367 
368  public Q_SLOTS:
369  void setFullScreen(bool fullScreen=true);
370  void setStereoDisplay(bool stereo=true);
372  void toggleFullScreen() { setFullScreen(!isFullScreen()); };
374  void toggleStereoDisplay() { setStereoDisplay(!stereo_); };
375  void toggleCameraMode();
376 
377 private:
378  bool cameraIsInRevolveMode() const;
380 
381 
384 public:
385  static void drawArrow(float length=1.0f, float radius=-1.0f, int nbSubdivisions=12);
386  static void drawArrow(const qglviewer::Vec& from, const qglviewer::Vec& to, float radius=-1.0f, int nbSubdivisions=12);
387  static void drawAxis(float length=1.0f);
388  static void drawGrid(float size=1.0f, int nbSubdivisions=10);
389 
390  virtual void startScreenCoordinatesSystem(bool upward=false) const;
391  virtual void stopScreenCoordinatesSystem() const;
392 
393  void drawText(int x, int y, const QString& text, const QFont& fnt=QFont());
394  void displayMessage(const QString& message, int delay=2000);
395  // void draw3DText(const qglviewer::Vec& pos, const qglviewer::Vec& normal, const QString& string, GLfloat height=0.1f);
396 
397 protected:
398  virtual void drawLight(GLenum light, float scale = 1.0f) const;
399 
400 private:
401  void displayFPS();
403  void drawVectorial() { paintGL(); };
404 
405 #ifndef DOXYGEN
406  friend void drawVectorial(void* param);
407 #endif
408 
409 
410 
411 #ifdef DOXYGEN
412 
414 public:
416  int width() const;
418  int height() const;
420  virtual void updateGL();
423  static QImage convertToGLFormat(const QImage & image);
425  void qglColor(const QColor& color) const;
427  void qglClearColor(const QColor& color) const;
430  bool isValid() const;
433  bool isSharing() const;
436  virtual void makeCurrent();
441  bool hasMouseTracking () const;
442  public Q_SLOTS:
444  virtual void resize(int width, int height);
446  virtual void setMouseTracking(bool enable);
447 protected:
450  bool autoBufferSwap() const;
451  protected Q_SLOTS:
453  void setAutoBufferSwap(bool on);
455 #endif
456 
457 
460 public:
461 #if QT_VERSION < 0x030000
462  virtual QImage grabFrameBuffer(bool withAlpha=false);
463 #endif
464 
473  const QString& snapshotFileName() const { return snapshotFileName_; };
474 #ifndef DOXYGEN
475  const QString& snapshotFilename() const;
476 #endif
477 
505  const QString& snapshotFormat() const { return snapshotFormat_; };
511  int snapshotCounter() const { return snapshotCounter_; };
520  int snapshotQuality() { return snapshotQuality_; };
521 
522  // Qt 2.3 does not support double default value parameters in slots.
523  // Remove "Q_SLOTS" from the following line to compile with Qt 2.3
524  public Q_SLOTS:
525  void saveSnapshot(bool automatic=true, bool overwrite=false);
526 
527  public Q_SLOTS:
528  void saveSnapshot(const QString& fileName, bool overwrite=false);
529  void setSnapshotFileName(const QString& name);
530 
532  void setSnapshotFormat(const QString& format) { snapshotFormat_ = format; };
534  void setSnapshotCounter(int counter) { snapshotCounter_ = counter; };
536  void setSnapshotQuality(int quality) { snapshotQuality_ = quality; };
537  bool openSnapshotFormatDialog();
538  void snapshotToClipboard();
539 
540 private:
541  bool saveImageSnapshot(const QString& fileName);
542 
543 #ifndef DOXYGEN
544  /* This class is used internally for screenshot that require tiling (image size size different
545  from window size). Only in that case, is the private tileRegion_ pointer non null.
546  It then contains the current tiled region, which is used by startScreenCoordinatesSystem
547  to adapt the coordinate system. Not using it would result in a tiled drawing of the parts
548  that use startScreenCoordinatesSystem. Also used by scaledFont for same purposes. */
549  class TileRegion { public : double xMin, yMin, xMax, yMax, textScale; };
550 #endif
551 
552 public:
570  QFont scaledFont(const QFont& font) const {
571  if (tileRegion_ == NULL)
572  return font;
573  else {
574  QFont f(font);
575  if (f.pixelSize() == -1)
576 #if QT_VERSION >= 0x040000
577  f.setPointSizeF(f.pointSizeF() * tileRegion_->textScale);
578 #else
579  f.setPointSizeFloat(f.pointSizeFloat() * tileRegion_->textScale);
580 #endif
581  else
582  f.setPixelSize(f.pixelSize() * tileRegion_->textScale);
583  return f;
584  }
585  }
587 
588 
591 public:
592  GLuint bufferTextureId() const;
601  float bufferTextureMaxU() const { return bufferTextureMaxU_; };
603  float bufferTextureMaxV() const { return bufferTextureMaxV_; };
604  public Q_SLOTS:
605  void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE);
607 
610 public:
619  bool animationIsStarted() const { return animationStarted_; };
634  int animationPeriod() const { return animationPeriod_; };
635 
636  public Q_SLOTS:
638  void setAnimationPeriod(int period) { animationPeriod_ = period; };
639  virtual void startAnimation();
640  virtual void stopAnimation();
652  virtual void animate() { Q_EMIT animateNeeded(); };
654  void toggleAnimation() { if (animationIsStarted()) stopAnimation(); else startAnimation(); };
656 
657 public:
658 Q_SIGNALS:
662  void viewerInitialized();
663 
668  void drawNeeded();
669 
681  void drawFinished(bool automatic);
682 
686  void animateNeeded();
687 
691  void helpRequired();
692 
694  void axisIsDrawnChanged(bool drawn);
696  void gridIsDrawnChanged(bool drawn);
698  void FPSIsDisplayedChanged(bool displayed);
700  void textIsEnabledChanged(bool enabled);
702  void cameraIsEditedChanged(bool edited);
704  void stereoChanged(bool on);
709  void pointSelected(const QMouseEvent* e);
710 
715  void mouseGrabberChanged(qglviewer::MouseGrabber* mouseGrabber);
716 
719 public:
735  virtual QString helpString() const { return tr("No help available."); };
736 
737  virtual QString mouseString() const;
738  virtual QString keyboardString() const;
739 
740 #ifndef DOXYGEN
741 
742  virtual QString mouseBindingsString () const { return mouseString(); }
744  virtual QString shortcutBindingsString () const { return keyboardString(); }
745 #endif
746 
747  public Q_SLOTS:
748  virtual void help();
749  virtual void aboutQGLViewer();
750 
751 protected:
757  QTabWidget* helpWidget() { return helpWidget_; }
759 
760 
763 protected:
764  virtual void resizeGL(int width, int height);
765  virtual void initializeGL();
766 
784  virtual void init() { Q_EMIT viewerInitialized(); };
785 
786  virtual void paintGL();
787  virtual void preDraw();
788  virtual void preDrawStereo(bool leftBuffer=true);
789 
805  virtual void draw() {};
806  virtual void fastDraw();
807  virtual void postDraw();
809 
812 protected:
813  virtual void mousePressEvent(QMouseEvent *);
814  virtual void mouseMoveEvent(QMouseEvent *);
815  virtual void mouseReleaseEvent(QMouseEvent *);
816  virtual void mouseDoubleClickEvent(QMouseEvent *);
817  virtual void wheelEvent(QWheelEvent *);
818  virtual void keyPressEvent(QKeyEvent *);
819  virtual void timerEvent(QTimerEvent *);
820  virtual void closeEvent(QCloseEvent *);
822 
825 public:
833  int selectedName() const { return selectedObjectId_; };
841  int selectBufferSize() const { return selectBufferSize_; };
842 
856  int selectRegionWidth() const { return selectRegionWidth_; };
858  int selectRegionHeight() const { return selectRegionHeight_; };
859 
865  GLuint* selectBuffer() { return selectBuffer_; };
866 
867  public Q_SLOTS:
868  virtual void select(const QMouseEvent* event);
869  virtual void select(const QPoint& point);
870 
871  void setSelectBufferSize(int size);
873  void setSelectRegionWidth(int width) { selectRegionWidth_ = width; };
875  void setSelectRegionHeight(int height) { selectRegionHeight_ = height; };
880  void setSelectedName(int id) { selectedObjectId_=id; };
881 
882 protected:
883  virtual void beginSelection(const QPoint& point);
906  virtual void drawWithNames() {};
907  virtual void endSelection(const QPoint& point);
915  virtual void postSelection(const QPoint& point) { Q_UNUSED(point); };
917 
918 
921 protected:
926  enum KeyboardAction { DRAW_AXIS, DRAW_GRID, DISPLAY_FPS, ENABLE_TEXT, EXIT_VIEWER,
927  SAVE_SCREENSHOT, CAMERA_MODE, FULL_SCREEN, STEREO, ANIMATION, HELP, EDIT_CAMERA,
928  MOVE_CAMERA_LEFT, MOVE_CAMERA_RIGHT, MOVE_CAMERA_UP, MOVE_CAMERA_DOWN,
929  INCREASE_FLYSPEED, DECREASE_FLYSPEED, SNAPSHOT_TO_CLIPBOARD };
930 public:
931  unsigned int shortcut(KeyboardAction action) const;
932 #ifndef DOXYGEN
933  // QGLViewer 1.x
934  int keyboardAccelerator(KeyboardAction action) const;
935  Qt::Key keyFrameKey(int index) const;
936  Qt::KeyboardModifiers playKeyFramePathStateKey() const;
937  // QGLViewer 2.0 without Qt4 support
938  Qt::KeyboardModifiers addKeyFrameStateKey() const;
939  Qt::KeyboardModifiers playPathStateKey() const;
940 #endif
941  Qt::Key pathKey(int index) const;
942  Qt::KeyboardModifiers addKeyFrameKeyboardModifiers() const;
943  Qt::KeyboardModifiers playPathKeyboardModifiers() const;
944 
945  public Q_SLOTS:
946  void setShortcut(KeyboardAction action, unsigned int key);
947 #ifndef DOXYGEN
948  void setKeyboardAccelerator(KeyboardAction action, int key);
949 #endif
950  void setKeyDescription(int key, QString description);
951 
952  // Key Frames shortcut keys
953 #ifndef DOXYGEN
954  // QGLViewer 1.x compatibility methods
955  virtual void setKeyFrameKey(int index, int key);
956  virtual void setPlayKeyFramePathStateKey(int buttonState);
957  // QGLViewer 2.0 without Qt4 support
958  virtual void setPlayPathStateKey(int buttonState);
959  virtual void setAddKeyFrameStateKey(int buttonState);
960 #endif
961  virtual void setPathKey(int key, int index = 0);
962  virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modifiers);
963  virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers modifiers);
965 
966 
969 protected:
974  enum MouseHandler { CAMERA, FRAME };
975 
980  enum ClickAction { NO_CLICK_ACTION, ZOOM_ON_PIXEL, ZOOM_TO_FIT, SELECT, RAP_FROM_PIXEL, RAP_IS_CENTER,
981  CENTER_FRAME, CENTER_SCENE, SHOW_ENTIRE_SCENE, ALIGN_FRAME, ALIGN_CAMERA };
982 
983 #ifndef DOXYGEN
984  // So that it can be used in ManipulatedFrame and ManipulatedCameraFrame.
985 public:
986 #endif
987 
994  ROTATE, ZOOM, TRANSLATE,
995  MOVE_FORWARD, LOOK_AROUND, MOVE_BACKWARD,
996  SCREEN_ROTATE, ROLL, DRIVE,
997  SCREEN_TRANSLATE, ZOOM_ON_REGION };
998 
999 #ifdef DOXYGEN
1000 public:
1001 #endif
1002 
1003  MouseAction mouseAction(int state) const;
1004  int mouseHandler(int state) const;
1005  int mouseButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const;
1006  ClickAction clickAction(int state, bool doubleClick, Qt::MouseButtons buttonsBefore) const;
1007  void getClickButtonState(ClickAction action, int& state, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const;
1008 
1009  MouseAction wheelAction(Qt::KeyboardModifiers modifiers) const;
1010  int wheelHandler(Qt::KeyboardModifiers modifiers) const;
1011  int wheelButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const;
1012 
1013 public Q_SLOTS:
1014  void setMouseBinding(int state, MouseHandler handler, MouseAction action, bool withConstraint=true);
1015 #if QT_VERSION < 0x030000
1016  // Two slots cannot have the same name or two default parameters with Qt 2.3.
1017 public:
1018 #endif
1019  void setMouseBinding(int state, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton);
1020 #if QT_VERSION < 0x030000
1021 public Q_SLOTS:
1022 #endif
1023  void setMouseBindingDescription(int state, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton);
1024  void setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true);
1025  void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardModifiers modifiers);
1026 #ifndef DOXYGEN
1027  void setHandlerStateKey(MouseHandler handler, int buttonState);
1028  void setMouseStateKey(MouseHandler handler, int buttonState);
1029 #endif
1030 
1031 private:
1032  static QString mouseActionString(QGLViewer::MouseAction ma);
1033  static QString clickActionString(QGLViewer::ClickAction ca);
1035 
1036 
1039 public:
1040  QString stateFileName() const;
1041  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
1042 
1043  public Q_SLOTS:
1044  virtual void initFromDOMElement(const QDomElement& element);
1045  virtual void saveStateToFile(); // cannot be const because of QMessageBox
1046  virtual bool restoreStateFromFile();
1047 
1060  void setStateFileName(const QString& name) { stateFileName_ = name; };
1061 
1062 #ifndef DOXYGEN
1063  void saveToFile(const QString& fileName=QString::null);
1064  bool restoreFromFile(const QString& fileName=QString::null);
1065 #endif
1066 
1067 private:
1068  static void saveStateToFileForAllViewers();
1070 
1071 
1074 public:
1086 #if QT_VERSION >= 0x040000
1087  static const QList<QGLViewer*>& QGLViewerPool() { return QGLViewer::QGLViewerPool_; };
1088 #else
1089  static const QPtrList<QGLViewer>& QGLViewerPool() { return QGLViewer::QGLViewerPool_; };
1090 #endif
1091 
1092 
1100 #if QT_VERSION >= 0x040000
1101  static int QGLViewerIndex(const QGLViewer* const viewer) { return QGLViewer::QGLViewerPool_.indexOf(const_cast<QGLViewer*>(viewer)); };
1102 #else
1103  static int QGLViewerIndex(const QGLViewer* const viewer) { return QGLViewer::QGLViewerPool_.findRef(viewer); };
1104 #endif
1105 
1106 
1107 #ifndef DOXYGEN
1108 
1110 public:
1111  virtual void setVisualHintsMask(int mask, int delay = 2000);
1112  virtual void drawVisualHints();
1113 
1114  public Q_SLOTS:
1115  virtual void resetVisualHints();
1117 #endif
1118 
1119  private Q_SLOTS:
1120  // Patch for a Qt bug with fullScreen on startup
1121  void delayedFullScreen() { move(prevPos_); setFullScreen(); };
1122  void hideMessage();
1123 
1124 private:
1125  // Copy constructor and operator= are declared private and undefined
1126  // Prevents everyone from trying to use them
1127  QGLViewer(const QGLViewer& v);
1128  QGLViewer& operator=(const QGLViewer& v);
1129 
1130  // Set parameters to their default values. Called by the constructors.
1131  void defaultConstructor();
1132 
1133  void handleKeyboardAction(KeyboardAction id);
1134 
1135  // C a m e r a
1139  int previousPathId_; // Double key press recognition
1140  void connectAllCameraKFIInterpolatedSignals(bool connection=true);
1141 
1142  // C o l o r s
1143  QColor backgroundColor_, foregroundColor_;
1144 
1145  // D i s p l a y f l a g s
1146  bool axisIsDrawn_; // world axis
1147  bool gridIsDrawn_; // world XY grid
1148  bool FPSIsDisplayed_; // Frame Per Seconds
1149  bool textIsEnabled_; // drawText() actually draws text or not
1150  bool stereo_; // stereo display
1151  bool fullScreen_; // full screen mode
1152  QPoint prevPos_; // Previous window position, used for full screen mode
1153 
1154  // A n i m a t i o n
1155  bool animationStarted_; // animation mode started
1156  int animationPeriod_; // period in msecs
1158 
1159  // F P S d i s p l a y
1160  QTime fpsTime_;
1161  unsigned int fpsCounter_;
1162  QString fpsString_;
1163  float f_p_s_;
1164 
1165  // M e s s a g e s
1166  QString message_;
1169 
1170  // M a n i p u l a t e d f r a m e
1173 
1174  // M o u s e G r a b b e r
1178  QMap<size_t, bool> disabledMouseGrabbers_;
1179 
1180  // S e l e c t i o n
1181  int selectRegionWidth_, selectRegionHeight_;
1183  GLuint* selectBuffer_;
1185 
1186  // V i s u a l h i n t s
1188 
1189  // S h o r t c u t k e y s
1190  void setDefaultShortcuts();
1191  QString cameraPathKeysString() const;
1192  QMap<KeyboardAction, QString> keyboardActionDescription_;
1193  QMap<KeyboardAction, unsigned int> keyboardBinding_;
1194  QMap<int, QString> keyDescription_;
1195 
1196  // K e y F r a m e s s h o r t c u t s
1197  QMap<Qt::Key, int> pathIndex_;
1198  Qt::KeyboardModifiers addKeyFrameKeyboardModifiers_, playPathKeyboardModifiers_;
1199 
1200  // B u f f e r T e x t u r e
1202  float bufferTextureMaxU_, bufferTextureMaxV_;
1203  int bufferTextureWidth_, bufferTextureHeight_;
1206 
1207 #ifndef DOXYGEN
1208  // M o u s e a c t i o n s
1213  };
1214 
1215  // C l i c k a c t i o n s
1217  Qt::KeyboardModifiers modifiers;
1218  Qt::MouseButtons button;
1220  Qt::MouseButtons buttonsBefore; // only defined when doubleClick is true
1221 
1222  // This sort order in used in mouseString() to displays sorted mouse bindings
1223  bool operator<(const ClickActionPrivate& cap) const
1224  {
1225  if (buttonsBefore != cap.buttonsBefore)
1226  return buttonsBefore < cap.buttonsBefore;
1227  else
1228  if (modifiers != cap.modifiers)
1229  return modifiers < cap.modifiers;
1230  else
1231  if (button != cap.button)
1232  return button < cap.button;
1233  else
1234  return !doubleClick && cap.doubleClick;
1235  }
1236  };
1237 #endif
1238  static QString formatClickActionPrivate(ClickActionPrivate cap);
1239 
1240  QMap<ClickActionPrivate, QString> mouseDescription_;
1241 
1242  void setDefaultMouseBindings();
1243  void performClickAction(ClickAction ca, const QMouseEvent* const e);
1244  QMap<int, MouseActionPrivate> mouseBinding_;
1245  QMap<Qt::KeyboardModifiers, MouseActionPrivate> wheelBinding_;
1246  QMap<ClickActionPrivate, ClickAction> clickBinding_;
1247 
1248  // S n a p s h o t s
1249  void initializeSnapshotFormats();
1250  QImage frameBufferSnapshot();
1251  QString snapshotFileName_, snapshotFormat_;
1252  int snapshotCounter_, snapshotQuality_;
1254 
1255  // Q G L V i e w e r p o o l
1256 #if QT_VERSION >= 0x040000
1257  static QList<QGLViewer*> QGLViewerPool_;
1258 #else
1259  static QPtrList<QGLViewer> QGLViewerPool_;
1260 #endif
1261 
1262  // S t a t e F i l e
1264 
1265  // H e l p w i n d o w
1266  QTabWidget* helpWidget_;
1267 
1268  // I n t e r n a l d e b u g
1270 };
1271 
1272 #endif // QGLVIEWER_QGLVIEWER_H
QString message_
Definition: qglviewer.h:1166
int selectRegionHeight() const
Definition: qglviewer.h:858
QMap< Qt::Key, int > pathIndex_
Definition: qglviewer.h:1197
QMap< Qt::KeyboardModifiers, MouseActionPrivate > wheelBinding_
Definition: qglviewer.h:1245
static QPtrList< QGLViewer > QGLViewerPool_
Definition: qglviewer.h:1259
bool operator<(const ClickActionPrivate &cap) const
Definition: qglviewer.h:1223
bool fullScreen_
Definition: qglviewer.h:1151
float currentFPS()
Definition: qglviewer.h:337
QTabWidget * helpWidget()
Definition: qglviewer.h:757
bool FPSIsDisplayed_
Definition: qglviewer.h:1148
void toggleFPSIsDisplayed()
Definition: qglviewer.h:157
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
void drawVectorial(void *param)
unsigned int fpsCounter_
Definition: qglviewer.h:1161
void setSnapshotQuality(int quality)
Definition: qglviewer.h:536
Qt::KeyboardModifiers playPathKeyboardModifiers_
Definition: qglviewer.h:1198
QString snapshotFormat_
Definition: qglviewer.h:1251
virtual void animate()
Definition: qglviewer.h:652
Qt::MouseButtons buttonsBefore
Definition: qglviewer.h:1220
float f_p_s_
Definition: qglviewer.h:1163
void setForegroundColor(const QColor &color)
Definition: qglviewer.h:203
bool axisIsDrawn() const
Definition: qglviewer.h:112
virtual QString shortcutBindingsString() const
Definition: qglviewer.h:744
bool textIsEnabled_
Definition: qglviewer.h:1149
int previousBufferTextureInternalFormat_
Definition: qglviewer.h:1205
void toggleAnimation()
Definition: qglviewer.h:654
QPoint prevPos_
Definition: qglviewer.h:1152
QMap< int, QString > keyDescription_
Definition: qglviewer.h:1194
virtual QString mouseBindingsString() const
Definition: qglviewer.h:742
QGLViewer(const QGLFormat &format, QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
Definition: qglviewer.h:82
GLuint bufferTextureId_
Definition: qglviewer.h:1201
bool animationStarted_
Definition: qglviewer.h:1155
QColor foregroundColor() const
Definition: qglviewer.h:197
void delayedFullScreen()
Definition: qglviewer.h:1121
int selectBufferSize() const
Definition: qglviewer.h:841
float bufferTextureMaxV() const
Definition: qglviewer.h:603
QMap< KeyboardAction, QString > keyboardActionDescription_
Definition: qglviewer.h:1192
bool gridIsDrawn() const
Definition: qglviewer.h:116
QGLViewer(QWidget *parent=NULL, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
Definition: qglviewer.h:78
virtual void setSceneRadius(float radius)
Definition: qglviewer.h:237
int selectedObjectId_
Definition: qglviewer.h:1184
unsigned int previousBufferTextureFormat_
Definition: qglviewer.h:1204
int animationPeriod() const
Definition: qglviewer.h:634
bool axisIsDrawn_
Definition: qglviewer.h:1146
void setSelectedName(int id)
Definition: qglviewer.h:880
void toggleCameraIsEdited()
Definition: qglviewer.h:161
qglviewer::MouseGrabber * mouseGrabber_
Definition: qglviewer.h:1175
void drawVectorial()
Definition: qglviewer.h:403
void setAnimationPeriod(int period)
Definition: qglviewer.h:638
qglviewer::Vec sceneCenter() const
Definition: qglviewer.h:230
Abstract class for objects that grab mouse focus in a QGLViewer.
Definition: mouseGrabber.h:134
static int QGLViewerIndex(const QGLViewer *const viewer)
Definition: qglviewer.h:1103
void setGridIsDrawn(bool draw=true)
Definition: qglviewer.h:145
#define Q_SLOTS
Definition: config.h:119
void setSnapshotFormat(const QString &format)
Definition: qglviewer.h:532
void setSelectRegionHeight(int height)
Definition: qglviewer.h:875
QString fpsString_
Definition: qglviewer.h:1162
qglviewer::MouseGrabber * mouseGrabber() const
Definition: qglviewer.h:304
#define QGLVIEWER_EXPORT
Definition: config.h:75
QMap< ClickActionPrivate, ClickAction > clickBinding_
Definition: qglviewer.h:1246
bool mouseGrabberIsAManipulatedCameraFrame_
Definition: qglviewer.h:1177
float bufferTextureMaxV_
Definition: qglviewer.h:1202
void setTextIsEnabled(bool enable=true)
Definition: qglviewer.h:149
int visualHint_
Definition: qglviewer.h:1187
The Vec class represents 3D positions and 3D vectors.
Definition: vec.h:69
virtual void draw()
Definition: qglviewer.h:805
#define Q_SIGNALS
Definition: config.h:120
GLuint * selectBuffer()
Definition: qglviewer.h:865
void toggleAxisIsDrawn()
Definition: qglviewer.h:153
QColor backgroundColor() const
Definition: qglviewer.h:183
QFont scaledFont(const QFont &font) const
Definition: qglviewer.h:570
int selectBufferSize_
Definition: qglviewer.h:1182
int selectedName() const
Definition: qglviewer.h:833
bool gridIsDrawn_
Definition: qglviewer.h:1147
int selectRegionWidth_
Definition: qglviewer.h:1181
bool cameraIsEdited() const
Definition: qglviewer.h:138
int previousPathId_
Definition: qglviewer.h:1139
bool stereo_
Definition: qglviewer.h:1150
static const QPtrList< QGLViewer > & QGLViewerPool()
Definition: qglviewer.h:1089
qglviewer::ManipulatedFrame * manipulatedFrame() const
Definition: qglviewer.h:277
virtual void init()
Definition: qglviewer.h:784
bool manipulatedFrameIsACamera_
Definition: qglviewer.h:1172
void setAxisIsDrawn(bool draw=true)
Definition: qglviewer.h:143
virtual QString helpString() const
Definition: qglviewer.h:735
virtual void drawWithNames()
Definition: qglviewer.h:906
void setFPSIsDisplayed(bool display=true)
Definition: qglviewer.h:147
qglviewer::ManipulatedFrame * manipulatedFrame_
Definition: qglviewer.h:1171
void setSelectRegionWidth(int width)
Definition: qglviewer.h:873
bool displaysInStereo() const
Definition: qglviewer.h:364
int animationPeriod_
Definition: qglviewer.h:1156
#define Q_EMIT
Definition: config.h:121
int animationTimerId_
Definition: qglviewer.h:1157
bool mouseGrabberIsAManipulatedFrame_
Definition: qglviewer.h:1176
bool mouseGrabberIsEnabled(const qglviewer::MouseGrabber *const mouseGrabber)
Definition: qglviewer.h:316
void setStateFileName(const QString &name)
Definition: qglviewer.h:1060
A versatile 3D OpenGL viewer based on QGLWidget.
Definition: qglviewer.h:70
float bufferTextureMaxU() const
Definition: qglviewer.h:601
const QString & snapshotFileName() const
Definition: qglviewer.h:473
QMap< ClickActionPrivate, QString > mouseDescription_
Definition: qglviewer.h:1240
void toggleTextIsEnabled()
Definition: qglviewer.h:159
void toggleStereoDisplay()
Definition: qglviewer.h:374
void setBackgroundColor(const QColor &color)
Definition: qglviewer.h:201
A perspective or orthographic camera.
Definition: camera.h:81
float sceneRadius() const
Definition: qglviewer.h:221
int selectRegionWidth() const
Definition: qglviewer.h:856
QMap< size_t, bool > disabledMouseGrabbers_
Definition: qglviewer.h:1178
Qt::KeyboardModifiers modifiers
Definition: qglviewer.h:1217
int snapshotCounter() const
Definition: qglviewer.h:511
QGLViewer(QGLContext *context, QWidget *parent, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
Definition: qglviewer.h:86
virtual QSize sizeHint() const
Definition: qglviewer.h:366
bool FPSIsDisplayed() const
Definition: qglviewer.h:123
TileRegion * tileRegion_
Definition: qglviewer.h:1253
virtual void setSceneCenter(const qglviewer::Vec &center)
Definition: qglviewer.h:243
int snapshotQuality()
Definition: qglviewer.h:520
bool isFullScreen() const
Definition: qglviewer.h:344
float previousCameraZClippingCoefficient_
Definition: qglviewer.h:1138
bool textIsEnabled() const
Definition: qglviewer.h:128
QTabWidget * helpWidget_
Definition: qglviewer.h:1266
const QString & snapshotFormat() const
Definition: qglviewer.h:505
QMap< KeyboardAction, unsigned int > keyboardBinding_
Definition: qglviewer.h:1193
QTimer messageTimer_
Definition: qglviewer.h:1168
bool updateGLOK_
Definition: qglviewer.h:1269
QString stateFileName_
Definition: qglviewer.h:1263
void toggleFullScreen()
Definition: qglviewer.h:372
qglviewer::Camera * camera_
Definition: qglviewer.h:1136
void setSceneBoundingBox(const qglviewer::Vec &min, const qglviewer::Vec &max)
Definition: qglviewer.h:252
virtual void postSelection(const QPoint &point)
Definition: qglviewer.h:915
void setSnapshotCounter(int counter)
Definition: qglviewer.h:534
QTime fpsTime_
Definition: qglviewer.h:1160
float aspectRatio() const
Definition: qglviewer.h:326
void toggleGridIsDrawn()
Definition: qglviewer.h:155
GLuint * selectBuffer_
Definition: qglviewer.h:1183
QColor foregroundColor_
Definition: qglviewer.h:1143
bool animationIsStarted() const
Definition: qglviewer.h:619
void showEntireScene()
Definition: qglviewer.h:257
int bufferTextureWidth_
Definition: qglviewer.h:1203
bool cameraIsEdited_
Definition: qglviewer.h:1137
int snapshotQuality_
Definition: qglviewer.h:1252
bool displayMessage_
Definition: qglviewer.h:1167
QMap< int, MouseActionPrivate > mouseBinding_
Definition: qglviewer.h:1244
qglviewer::Camera * camera() const
Definition: qglviewer.h:265


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Jun 10 2019 14:00:25