qglviewer.h
1 /****************************************************************************
2 
3  Copyright (C) 2002-2008 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.3.10.
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 // Qt::ButtonState was split into Qt::KeyboardModifiers and Qt::MouseButtons in Qt 4.
44 # define QtKeyboardModifiers Qt::KeyboardModifiers
45 # define QtMouseButtons Qt::MouseButtons
46 #else
47 # define QtKeyboardModifiers Qt::ButtonState
48 # define QtMouseButtons Qt::ButtonState
49 #endif
50 
73 class QGLVIEWER_EXPORT QGLViewer : public QGLWidget
74 {
75  Q_OBJECT
76 
77 public:
78  // Complete implementation is provided so that the constructor is defined with QT3_SUPPORT when .h is included.
79  // (Would not be available otherwise since lib is compiled without QT3_SUPPORT).
80 #if QT_VERSION < 0x040000 || defined QT3_SUPPORT
81  explicit QGLViewer(QWidget* parent=NULL, const char* name=0, const QGLWidget* shareWidget=0, Qt::WFlags flags=0)
82  : QGLWidget(parent, name, shareWidget, flags)
83  { defaultConstructor(); }
84 
85  explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const char* name=0, const QGLWidget* shareWidget=0,Qt::WFlags flags=0)
86  : QGLWidget(format, parent, name, shareWidget, flags)
87  { defaultConstructor(); }
88 
89  QGLViewer(QGLContext* context, QWidget* parent, const char* name=0, const QGLWidget* shareWidget=0, Qt::WFlags flags=0)
90 # if QT_VERSION >= 0x030200
91  : QGLWidget(context, parent, name, shareWidget, flags) {
92 # else
93  // MOC_SKIP_BEGIN
94  : QGLWidget(parent, name, shareWidget, flags) {
95  Q_UNUSED(context);
96  // MOC_SKIP_END
97 # endif
98  defaultConstructor(); }
99 
100 #else
101 
102  explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WFlags flags=0);
103  explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WFlags flags=0);
104  explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WFlags flags=0);
105 #endif
106 
107  virtual ~QGLViewer();
108 
111 public:
115  bool axisIsDrawn() const { return axisIsDrawn_; };
119  bool gridIsDrawn() const { return gridIsDrawn_; };
126  bool FPSIsDisplayed() const { return FPSIsDisplayed_; };
131  bool textIsEnabled() const { return textIsEnabled_; };
132 
141  bool cameraIsEdited() const { return cameraIsEdited_; }
142 
143 
144  public Q_SLOTS:
146  void setAxisIsDrawn(bool draw=true) { axisIsDrawn_ = draw; Q_EMIT axisIsDrawnChanged(draw); if (updateGLOK_) updateGL(); };
148  void setGridIsDrawn(bool draw=true) { gridIsDrawn_ = draw; Q_EMIT gridIsDrawnChanged(draw); if (updateGLOK_) updateGL(); };
150  void setFPSIsDisplayed(bool display=true) { FPSIsDisplayed_ = display; Q_EMIT FPSIsDisplayedChanged(display); if (updateGLOK_) updateGL(); };
152  void setTextIsEnabled(bool enable=true) { textIsEnabled_ = enable; Q_EMIT textIsEnabledChanged(enable); if (updateGLOK_) updateGL(); };
153  void setCameraIsEdited(bool edit=true);
154 
156  void toggleAxisIsDrawn() { setAxisIsDrawn(!axisIsDrawn()); };
158  void toggleGridIsDrawn() { setGridIsDrawn(!gridIsDrawn()); };
160  void toggleFPSIsDisplayed() { setFPSIsDisplayed(!FPSIsDisplayed()); };
162  void toggleTextIsEnabled() { setTextIsEnabled(!textIsEnabled()); };
164  void toggleCameraIsEdited() { setCameraIsEdited(!cameraIsEdited()); };
166 
167 
170 public:
186  QColor backgroundColor() const { return backgroundColor_; };
187 
200  QColor foregroundColor() const { return foregroundColor_; };
201  public Q_SLOTS:
204  void setBackgroundColor(const QColor& color) { backgroundColor_=color; qglClearColor(color); };
206  void setForegroundColor(const QColor& color) { foregroundColor_ = color; };
208 
209 
212 public:
224  float sceneRadius() const { return camera()->sceneRadius(); }
233  qglviewer::Vec sceneCenter() const { return camera()->sceneCenter(); }
234 
235  public Q_SLOTS:
240  virtual void setSceneRadius(float radius) { camera()->setSceneRadius(radius); }
241 
246  virtual void setSceneCenter(const qglviewer::Vec& center) { camera()->setSceneCenter(center); }
247 
255  void setSceneBoundingBox(const qglviewer::Vec& min, const qglviewer::Vec& max) { camera()->setSceneBoundingBox(min,max); }
256 
260  void showEntireScene() { camera()->showEntireScene(); if (updateGLOK_) updateGL(); }
262 
263 
266 public:
268  qglviewer::Camera* camera() const { return camera_; };
269 
280  qglviewer::ManipulatedFrame* manipulatedFrame() const { return manipulatedFrame_; };
281 
282  public Q_SLOTS:
283  void setCamera(qglviewer::Camera* const camera);
284  void setManipulatedFrame(qglviewer::ManipulatedFrame* frame);
286 
287 
290 public:
307  qglviewer::MouseGrabber* mouseGrabber() const { return mouseGrabber_; };
308 
309  void setMouseGrabberIsEnabled(const qglviewer::MouseGrabber* const mouseGrabber, bool enabled=true);
319  bool mouseGrabberIsEnabled(const qglviewer::MouseGrabber* const mouseGrabber) { return !disabledMouseGrabbers_.contains(reinterpret_cast<size_t>(mouseGrabber)); };
320  public Q_SLOTS:
321  void setMouseGrabber(qglviewer::MouseGrabber* mouseGrabber);
323 
324 
327 public:
329  float aspectRatio() const { return static_cast<float>(width())/static_cast<float>(height()); };
340  float currentFPS() { return f_p_s_; };
347  bool isFullScreen() const { return fullScreen_; };
368  bool displaysInStereo() const { return stereo_; }
370  virtual QSize sizeHint() const { return QSize(600, 400); }
371 
372  public Q_SLOTS:
373  void setFullScreen(bool fullScreen=true);
374  void setStereoDisplay(bool stereo=true);
376  void toggleFullScreen() { setFullScreen(!isFullScreen()); };
378  void toggleStereoDisplay() { setStereoDisplay(!stereo_); };
379  void toggleCameraMode();
380 
381 private:
382  bool cameraIsInRevolveMode() const;
384 
385 
388 public:
389  static void drawArrow(float length=1.0f, float radius=-1.0f, int nbSubdivisions=12);
390  static void drawArrow(const qglviewer::Vec& from, const qglviewer::Vec& to, float radius=-1.0f, int nbSubdivisions=12);
391  static void drawAxis(float length=1.0f);
392  static void drawGrid(float size=1.0f, int nbSubdivisions=10);
393 
394  virtual void startScreenCoordinatesSystem(bool upward=false) const;
395  virtual void stopScreenCoordinatesSystem() const;
396 
397  void drawText(int x, int y, const QString& text, const QFont& fnt=QFont());
398  void displayMessage(const QString& message, int delay=2000);
399  // void draw3DText(const qglviewer::Vec& pos, const qglviewer::Vec& normal, const QString& string, GLfloat height=0.1f);
400 
401 protected:
402  virtual void drawLight(GLenum light, float scale = 1.0f) const;
403 
404 private:
405  void displayFPS();
407  void drawVectorial() { paintGL(); };
408 
409 #ifndef DOXYGEN
410  friend void drawVectorial(void* param);
411 #endif
412 
413 
414 
415 #ifdef DOXYGEN
416 
418 public:
420  int width() const;
422  int height() const;
424  virtual void updateGL();
427  static QImage convertToGLFormat(const QImage & image);
429  void qglColor(const QColor& color) const;
431  void qglClearColor(const QColor& color) const;
434  bool isValid() const;
437  bool isSharing() const;
440  virtual void makeCurrent();
445  bool hasMouseTracking () const;
446  public Q_SLOTS:
448  virtual void resize(int width, int height);
450  virtual void setMouseTracking(bool enable);
451 protected:
454  bool autoBufferSwap() const;
455  protected Q_SLOTS:
457  void setAutoBufferSwap(bool on);
459 #endif
460 
461 
464 public:
465 #if QT_VERSION < 0x030000
466  virtual QImage grabFrameBuffer(bool withAlpha=false);
467 #endif
468 
477  const QString& snapshotFileName() const { return snapshotFileName_; };
478 #ifndef DOXYGEN
479  const QString& snapshotFilename() const;
480 #endif
481 
509  const QString& snapshotFormat() const { return snapshotFormat_; };
515  int snapshotCounter() const { return snapshotCounter_; };
524  int snapshotQuality() { return snapshotQuality_; };
525 
526  // Qt 2.3 does not support double default value parameters in slots.
527  // Remove "Q_SLOTS" from the following line to compile with Qt 2.3
528  public Q_SLOTS:
529  void saveSnapshot(bool automatic=true, bool overwrite=false);
530 
531  public Q_SLOTS:
532  void saveSnapshot(const QString& fileName, bool overwrite=false);
533  void setSnapshotFileName(const QString& name);
534 
536  void setSnapshotFormat(const QString& format) { snapshotFormat_ = format; };
538  void setSnapshotCounter(int counter) { snapshotCounter_ = counter; };
540  void setSnapshotQuality(int quality) { snapshotQuality_ = quality; };
541  bool openSnapshotFormatDialog();
542  void snapshotToClipboard();
543 
544 private:
545  bool saveImageSnapshot(const QString& fileName);
546 
547 #ifndef DOXYGEN
548  /* This class is used internally for screenshot that require tiling (image size size different
549  from window size). Only in that case, is the private tileRegion_ pointer non null.
550  It then contains the current tiled region, which is used by startScreenCoordinatesSystem
551  to adapt the coordinate system. Not using it would result in a tiled drawing of the parts
552  that use startScreenCoordinatesSystem. Also used by scaledFont for same purposes. */
553  class TileRegion { public : double xMin, yMin, xMax, yMax, textScale; };
554 #endif
555 
556 public:
574  QFont scaledFont(const QFont& font) const {
575  if (tileRegion_ == NULL)
576  return font;
577  else {
578  QFont f(font);
579  if (f.pixelSize() == -1)
580 #if QT_VERSION >= 0x040000
581  f.setPointSizeF(f.pointSizeF() * tileRegion_->textScale);
582 #else
583  f.setPointSizeFloat(f.pointSizeFloat() * tileRegion_->textScale);
584 #endif
585  else
586  f.setPixelSize(f.pixelSize() * tileRegion_->textScale);
587  return f;
588  }
589  }
591 
592 
595 public:
596  GLuint bufferTextureId() const;
605  float bufferTextureMaxU() const { return bufferTextureMaxU_; };
607  float bufferTextureMaxV() const { return bufferTextureMaxV_; };
608  public Q_SLOTS:
609  void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE);
611 
614 public:
623  bool animationIsStarted() const { return animationStarted_; };
638  int animationPeriod() const { return animationPeriod_; };
639 
640  public Q_SLOTS:
642  void setAnimationPeriod(int period) { animationPeriod_ = period; };
643  virtual void startAnimation();
644  virtual void stopAnimation();
656  virtual void animate() { Q_EMIT animateNeeded(); };
658  void toggleAnimation() { if (animationIsStarted()) stopAnimation(); else startAnimation(); };
660 
661 public:
662 Q_SIGNALS:
666  void viewerInitialized();
667 
672  void drawNeeded();
673 
685  void drawFinished(bool automatic);
686 
690  void animateNeeded();
691 
695  void helpRequired();
696 
698  void axisIsDrawnChanged(bool drawn);
700  void gridIsDrawnChanged(bool drawn);
702  void FPSIsDisplayedChanged(bool displayed);
704  void textIsEnabledChanged(bool enabled);
706  void cameraIsEditedChanged(bool edited);
708  void stereoChanged(bool on);
713  void pointSelected(const QMouseEvent* e);
714 
719  void mouseGrabberChanged(qglviewer::MouseGrabber* mouseGrabber);
720 
723 public:
739  virtual QString helpString() const { return tr("No help available."); };
740 
741  virtual QString mouseString() const;
742  virtual QString keyboardString() const;
743 
744 #ifndef DOXYGEN
745 
746  virtual QString mouseBindingsString () const { return mouseString(); }
748  virtual QString shortcutBindingsString () const { return keyboardString(); }
749 #endif
750 
751  public Q_SLOTS:
752  virtual void help();
753  virtual void aboutQGLViewer();
754 
755 protected:
761  QTabWidget* helpWidget() { return helpWidget_; }
763 
764 
767 protected:
768  virtual void resizeGL(int width, int height);
769  virtual void initializeGL();
770 
788  virtual void init() { Q_EMIT viewerInitialized(); };
789 
790  virtual void paintGL();
791  virtual void preDraw();
792  virtual void preDrawStereo(bool leftBuffer=true);
793 
809  virtual void draw() {};
810  virtual void fastDraw();
811  virtual void postDraw();
813 
816 protected:
817  virtual void mousePressEvent(QMouseEvent *);
818  virtual void mouseMoveEvent(QMouseEvent *);
819  virtual void mouseReleaseEvent(QMouseEvent *);
820  virtual void mouseDoubleClickEvent(QMouseEvent *);
821  virtual void wheelEvent(QWheelEvent *);
822  virtual void keyPressEvent(QKeyEvent *);
823  virtual void timerEvent(QTimerEvent *);
824  virtual void closeEvent(QCloseEvent *);
826 
829 public:
837  int selectedName() const { return selectedObjectId_; };
845  int selectBufferSize() const { return selectBufferSize_; };
846 
860  int selectRegionWidth() const { return selectRegionWidth_; };
862  int selectRegionHeight() const { return selectRegionHeight_; };
863 
869  GLuint* selectBuffer() { return selectBuffer_; };
870 
871  public Q_SLOTS:
872  virtual void select(const QMouseEvent* event);
873  virtual void select(const QPoint& point);
874 
875  void setSelectBufferSize(int size);
877  void setSelectRegionWidth(int width) { selectRegionWidth_ = width; };
879  void setSelectRegionHeight(int height) { selectRegionHeight_ = height; };
884  void setSelectedName(int id) { selectedObjectId_=id; };
885 
886 protected:
887  virtual void beginSelection(const QPoint& point);
910  virtual void drawWithNames() {};
911  virtual void endSelection(const QPoint& point);
919  virtual void postSelection(const QPoint& point) { Q_UNUSED(point); };
921 
922 
925 protected:
930  enum KeyboardAction { DRAW_AXIS, DRAW_GRID, DISPLAY_FPS, ENABLE_TEXT, EXIT_VIEWER,
931  SAVE_SCREENSHOT, CAMERA_MODE, FULL_SCREEN, STEREO, ANIMATION, HELP, EDIT_CAMERA,
932  MOVE_CAMERA_LEFT, MOVE_CAMERA_RIGHT, MOVE_CAMERA_UP, MOVE_CAMERA_DOWN,
933  INCREASE_FLYSPEED, DECREASE_FLYSPEED, SNAPSHOT_TO_CLIPBOARD };
934 public:
935  int shortcut(KeyboardAction action) const;
936 #ifndef DOXYGEN
937  // QGLViewer 1.x
938  int keyboardAccelerator(KeyboardAction action) const;
939  Qt::Key keyFrameKey(int index) const;
940  QtKeyboardModifiers playKeyFramePathStateKey() const;
941  // QGLViewer 2.0 without Qt4 support
942  QtKeyboardModifiers addKeyFrameStateKey() const;
943  QtKeyboardModifiers playPathStateKey() const;
944 #endif
945  Qt::Key pathKey(int index) const;
946  QtKeyboardModifiers addKeyFrameKeyboardModifiers() const;
947  QtKeyboardModifiers playPathKeyboardModifiers() const;
948 
949  public Q_SLOTS:
950  void setShortcut(KeyboardAction action, int key);
951 #ifndef DOXYGEN
952  void setKeyboardAccelerator(KeyboardAction action, int key);
953 #endif
954  void setKeyDescription(int key, QString description);
955 
956  // Key Frames shortcut keys
957 #ifndef DOXYGEN
958  // QGLViewer 1.x compatibility methods
959  virtual void setKeyFrameKey(int index, int key);
960  virtual void setPlayKeyFramePathStateKey(int buttonState);
961  // QGLViewer 2.0 without Qt4 support
962  virtual void setPlayPathStateKey(int buttonState);
963  virtual void setAddKeyFrameStateKey(int buttonState);
964 #endif
965  virtual void setPathKey(int key, int index = 0);
966  virtual void setPlayPathKeyboardModifiers(QtKeyboardModifiers modifiers);
967  virtual void setAddKeyFrameKeyboardModifiers(QtKeyboardModifiers modifiers);
969 
970 
973 protected:
978  enum MouseHandler { CAMERA, FRAME };
979 
984  enum ClickAction { NO_CLICK_ACTION, ZOOM_ON_PIXEL, ZOOM_TO_FIT, SELECT, RAP_FROM_PIXEL, RAP_IS_CENTER,
985  CENTER_FRAME, CENTER_SCENE, SHOW_ENTIRE_SCENE, ALIGN_FRAME, ALIGN_CAMERA };
986 
987 #ifndef DOXYGEN
988  // So that it can be used in ManipulatedFrame and ManipulatedCameraFrame.
989 public:
990 #endif
991 
997  enum MouseAction { NO_MOUSE_ACTION,
998  ROTATE, ZOOM, TRANSLATE,
999  MOVE_FORWARD, LOOK_AROUND, MOVE_BACKWARD,
1000  SCREEN_ROTATE, ROLL, DRIVE,
1001  SCREEN_TRANSLATE, ZOOM_ON_REGION };
1002 
1003 #ifdef DOXYGEN
1004 public:
1005 #endif
1006 
1007  MouseAction mouseAction(int state) const;
1008  int mouseHandler(int state) const;
1009  int mouseButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const;
1010  ClickAction clickAction(int state, bool doubleClick, QtMouseButtons buttonsBefore) const;
1011  void getClickButtonState(ClickAction action, int& state, bool& doubleClick, QtMouseButtons& buttonsBefore) const;
1012 
1013  MouseAction wheelAction(QtKeyboardModifiers modifiers) const;
1014  int wheelHandler(QtKeyboardModifiers modifiers) const;
1015  int wheelButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const;
1016 
1017  public Q_SLOTS:
1018  void setMouseBinding(int state, MouseHandler handler, MouseAction action, bool withConstraint=true);
1019 #if QT_VERSION < 0x030000
1020  // Two slots cannot have the same name or two default parameters with Qt 2.3.
1021 public:
1022 #endif
1023  void setMouseBinding(int state, ClickAction action, bool doubleClick=false, QtMouseButtons buttonsBefore=Qt::NoButton);
1024  void setMouseBindingDescription(int state, QString description, bool doubleClick=false, QtMouseButtons buttonsBefore=Qt::NoButton);
1025 #if QT_VERSION < 0x030000
1026  public Q_SLOTS:
1027 #endif
1028  void setWheelBinding(QtKeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true);
1029  void setHandlerKeyboardModifiers(MouseHandler handler, QtKeyboardModifiers modifiers);
1030 #ifndef DOXYGEN
1031  void setHandlerStateKey(MouseHandler handler, int buttonState);
1032  void setMouseStateKey(MouseHandler handler, int buttonState);
1033 #endif
1034 
1035 private:
1036  static QString mouseActionString(QGLViewer::MouseAction ma);
1037  static QString clickActionString(QGLViewer::ClickAction ca);
1039 
1040 
1043 public:
1044  QString stateFileName() const;
1045  virtual QDomElement domElement(const QString& name, QDomDocument& document) const;
1046 
1047  public Q_SLOTS:
1048  virtual void initFromDOMElement(const QDomElement& element);
1049  virtual void saveStateToFile(); // cannot be const because of QMessageBox
1050  virtual bool restoreStateFromFile();
1051 
1064  void setStateFileName(const QString& name) { stateFileName_ = name; };
1065 
1066 #ifndef DOXYGEN
1067  void saveToFile(const QString& fileName=QString::null);
1068  bool restoreFromFile(const QString& fileName=QString::null);
1069 #endif
1070 
1071 private:
1072  static void saveStateToFileForAllViewers();
1074 
1075 
1078 public:
1090 #if QT_VERSION >= 0x040000
1091  static const QList<QGLViewer*>& QGLViewerPool() { return QGLViewer::QGLViewerPool_; };
1092 #else
1093  static const QPtrList<QGLViewer>& QGLViewerPool() { return QGLViewer::QGLViewerPool_; };
1094 #endif
1095 
1096 
1104 #if QT_VERSION >= 0x040000
1105  static int QGLViewerIndex(const QGLViewer* const viewer) { return QGLViewer::QGLViewerPool_.indexOf(const_cast<QGLViewer*>(viewer)); };
1106 #else
1107  static int QGLViewerIndex(const QGLViewer* const viewer) { return QGLViewer::QGLViewerPool_.findRef(viewer); };
1108 #endif
1109 
1110 
1111 #ifndef DOXYGEN
1112 
1114 public:
1115  virtual void setVisualHintsMask(int mask, int delay = 2000);
1116  virtual void drawVisualHints();
1117 
1118  public Q_SLOTS:
1119  virtual void resetVisualHints();
1121 #endif
1122 
1123  private Q_SLOTS:
1124  // Patch for a Qt bug with fullScreen on startup
1125  void delayedFullScreen() { move(prevPos_); setFullScreen(); };
1126  void hideMessage();
1127 
1128 private:
1129  // Copy constructor and operator= are declared private and undefined
1130  // Prevents everyone from trying to use them
1131  QGLViewer(const QGLViewer& v);
1132  QGLViewer& operator=(const QGLViewer& v);
1133 
1134  // Set parameters to their default values. Called by the constructors.
1135  void defaultConstructor();
1136 
1137  void handleKeyboardAction(KeyboardAction id);
1138 
1139  // C a m e r a
1140  qglviewer::Camera* camera_;
1141  bool cameraIsEdited_;
1142  float previousCameraZClippingCoefficient_;
1143  int previousPathId_; // Double key press recognition
1144  void connectAllCameraKFIInterpolatedSignals(bool connection=true);
1145 
1146  // C o l o r s
1147  QColor backgroundColor_, foregroundColor_;
1148 
1149  // D i s p l a y f l a g s
1150  bool axisIsDrawn_; // world axis
1151  bool gridIsDrawn_; // world XY grid
1152  bool FPSIsDisplayed_; // Frame Per Seconds
1153  bool textIsEnabled_; // drawText() actually draws text or not
1154  bool stereo_; // stereo display
1155  bool fullScreen_; // full screen mode
1156  QPoint prevPos_; // Previous window position, used for full screen mode
1157 
1158  // A n i m a t i o n
1159  bool animationStarted_; // animation mode started
1160  int animationPeriod_; // period in msecs
1161  int animationTimerId_;
1162 
1163  // F P S d i s p l a y
1164  QTime fpsTime_;
1165  unsigned int fpsCounter_;
1166  QString fpsString_;
1167  float f_p_s_;
1168 
1169  // M e s s a g e s
1170  QString message_;
1171  bool displayMessage_;
1172  QTimer messageTimer_;
1173 
1174  // M a n i p u l a t e d f r a m e
1175  qglviewer::ManipulatedFrame* manipulatedFrame_;
1176  bool manipulatedFrameIsACamera_;
1177 
1178  // M o u s e G r a b b e r
1179  qglviewer::MouseGrabber* mouseGrabber_;
1180  bool mouseGrabberIsAManipulatedFrame_;
1181  bool mouseGrabberIsAManipulatedCameraFrame_;
1182  QMap<size_t, bool> disabledMouseGrabbers_;
1183 
1184  // S e l e c t i o n
1185  int selectRegionWidth_, selectRegionHeight_;
1186  int selectBufferSize_;
1187  GLuint* selectBuffer_;
1188  int selectedObjectId_;
1189 
1190  // V i s u a l h i n t s
1191  int visualHint_;
1192 
1193  // S h o r t c u t k e y s
1194  void setDefaultShortcuts();
1195  QString cameraPathKeysString() const;
1196  QMap<KeyboardAction, QString> keyboardActionDescription_;
1197  QMap<KeyboardAction, int> keyboardBinding_;
1198  QMap<int, QString> keyDescription_;
1199 
1200  // K e y F r a m e s s h o r t c u t s
1201  QMap<Qt::Key, int> pathIndex_;
1202  QtKeyboardModifiers addKeyFrameKeyboardModifiers_, playPathKeyboardModifiers_;
1203 
1204  // B u f f e r T e x t u r e
1205  GLuint bufferTextureId_;
1206  float bufferTextureMaxU_, bufferTextureMaxV_;
1207  int bufferTextureWidth_, bufferTextureHeight_;
1208  unsigned int previousBufferTextureFormat_;
1209  int previousBufferTextureInternalFormat_;
1210 
1211 #ifndef DOXYGEN
1212  // M o u s e a c t i o n s
1213  struct MouseActionPrivate {
1214  MouseHandler handler;
1215  MouseAction action;
1216  bool withConstraint;
1217  };
1218 
1219  // C l i c k a c t i o n s
1220  struct ClickActionPrivate {
1221  QtKeyboardModifiers modifiers;
1222  QtMouseButtons button;
1223  bool doubleClick;
1224  QtMouseButtons buttonsBefore; // only defined when doubleClick is true
1225 
1226  // This sort order in used in mouseString() to displays sorted mouse bindings
1227  bool operator<(const ClickActionPrivate& cap) const
1228  {
1229  if (buttonsBefore != cap.buttonsBefore)
1230  return buttonsBefore < cap.buttonsBefore;
1231  else
1232  if (modifiers != cap.modifiers)
1233  return modifiers < cap.modifiers;
1234  else
1235  if (button != cap.button)
1236  return button < cap.button;
1237  else
1238  return !doubleClick && cap.doubleClick;
1239  }
1240  };
1241 #endif
1242  static QString formatClickActionPrivate(ClickActionPrivate cap);
1243 
1244  QMap<ClickActionPrivate, QString> mouseDescription_;
1245 
1246  void setDefaultMouseBindings();
1247  void performClickAction(ClickAction ca, const QMouseEvent* const e);
1248  QMap<int, MouseActionPrivate> mouseBinding_;
1249  QMap<QtKeyboardModifiers, MouseActionPrivate> wheelBinding_;
1250  QMap<ClickActionPrivate, ClickAction> clickBinding_;
1251 
1252  // S n a p s h o t s
1253  void initializeSnapshotFormats();
1254  QImage frameBufferSnapshot();
1255  QString snapshotFileName_, snapshotFormat_;
1256  int snapshotCounter_, snapshotQuality_;
1257  TileRegion* tileRegion_;
1258 
1259  // Q G L V i e w e r p o o l
1260 #if QT_VERSION >= 0x040000
1261  static QList<QGLViewer*> QGLViewerPool_;
1262 #else
1263  static QPtrList<QGLViewer> QGLViewerPool_;
1264 #endif
1265 
1266  // S t a t e F i l e
1267  QString stateFileName_;
1268 
1269  // H e l p w i n d o w
1270  QTabWidget* helpWidget_;
1271 
1272  // I n t e r n a l d e b u g
1273  bool updateGLOK_;
1274 };
1275 
1276 #endif // QGLVIEWER_QGLVIEWER_H