23 #ifndef QGLVIEWER_QGLVIEWER_H 24 #define QGLVIEWER_QGLVIEWER_H 28 #if QT_VERSION >= 0x040000 30 # include <QClipboard> 33 # include <qclipboard.h> 42 #if QT_VERSION < 0x040000 43 # define Qt::KeyboardModifiers Qt::ButtonState 44 # define Qt::MouseButtons Qt::ButtonState 45 # define Qt::WindowFlags Qt::WFlags 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(); }
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(); }
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) {
91 : QGLWidget(parent, name, shareWidget, flags) {
95 defaultConstructor(); }
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);
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);
326 float aspectRatio()
const {
return static_cast<float>(width())/static_cast<float>(height()); };
366 virtual QSize
sizeHint()
const {
return QSize(600, 400); }
369 void setFullScreen(
bool fullScreen=
true);
370 void setStereoDisplay(
bool stereo=
true);
375 void toggleCameraMode();
378 bool cameraIsInRevolveMode()
const;
385 static void drawArrow(
float length=1.0f,
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);
390 virtual void startScreenCoordinatesSystem(
bool upward=
false)
const;
391 virtual void stopScreenCoordinatesSystem()
const;
393 void drawText(
int x,
int y,
const QString& text,
const QFont& fnt=QFont());
394 void displayMessage(
const QString& message,
int delay=2000);
398 virtual void drawLight(GLenum light,
float scale = 1.0f)
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;
444 virtual void resize(
int width,
int height);
446 virtual void setMouseTracking(
bool enable);
450 bool autoBufferSwap()
const;
453 void setAutoBufferSwap(
bool on);
461 #if QT_VERSION < 0x030000 462 virtual QImage grabFrameBuffer(
bool withAlpha=
false);
475 const QString& snapshotFilename()
const;
525 void saveSnapshot(
bool automatic=
true,
bool overwrite=
false);
528 void saveSnapshot(
const QString& fileName,
bool overwrite=
false);
529 void setSnapshotFileName(
const QString& name);
537 bool openSnapshotFormatDialog();
538 void snapshotToClipboard();
541 bool saveImageSnapshot(
const QString& fileName);
571 if (tileRegion_ == NULL)
575 if (f.pixelSize() == -1)
576 #
if QT_VERSION >= 0x040000
577 f.setPointSizeF(f.pointSizeF() * tileRegion_->textScale);
579 f.setPointSizeFloat(f.pointSizeFloat() * tileRegion_->textScale);
582 f.setPixelSize(f.pixelSize() * tileRegion_->textScale);
592 GLuint bufferTextureId()
const;
605 void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE);
639 virtual void startAnimation();
640 virtual void stopAnimation();
654 void toggleAnimation() {
if (animationIsStarted()) stopAnimation();
else startAnimation(); };
662 void viewerInitialized();
681 void drawFinished(
bool automatic);
686 void animateNeeded();
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);
735 virtual QString
helpString()
const {
return tr(
"No help available."); };
737 virtual QString mouseString()
const;
738 virtual QString keyboardString()
const;
749 virtual void aboutQGLViewer();
764 virtual void resizeGL(
int width,
int height);
765 virtual void initializeGL();
786 virtual void paintGL();
787 virtual void preDraw();
788 virtual void preDrawStereo(
bool leftBuffer=
true);
806 virtual void fastDraw();
807 virtual void postDraw();
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 *);
868 virtual void select(
const QMouseEvent* event);
869 virtual void select(
const QPoint& point);
871 void setSelectBufferSize(
int size);
883 virtual void beginSelection(
const QPoint& point);
907 virtual void endSelection(
const QPoint& point);
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,
929 INCREASE_FLYSPEED, DECREASE_FLYSPEED, SNAPSHOT_TO_CLIPBOARD };
935 Qt::Key keyFrameKey(
int index)
const;
936 Qt::KeyboardModifiers playKeyFramePathStateKey()
const;
938 Qt::KeyboardModifiers addKeyFrameStateKey()
const;
939 Qt::KeyboardModifiers playPathStateKey()
const;
941 Qt::Key pathKey(
int index)
const;
942 Qt::KeyboardModifiers addKeyFrameKeyboardModifiers()
const;
943 Qt::KeyboardModifiers playPathKeyboardModifiers()
const;
950 void setKeyDescription(
int key, QString description);
955 virtual void setKeyFrameKey(
int index,
int key);
956 virtual void setPlayKeyFramePathStateKey(
int buttonState);
958 virtual void setPlayPathStateKey(
int buttonState);
959 virtual void setAddKeyFrameStateKey(
int buttonState);
961 virtual void setPathKey(
int key,
int index = 0);
962 virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modifiers);
963 virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers modifiers);
997 SCREEN_TRANSLATE, ZOOM_ON_REGION };
1004 int mouseHandler(
int state)
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;
1009 MouseAction wheelAction(Qt::KeyboardModifiers modifiers)
const;
1010 int wheelHandler(Qt::KeyboardModifiers modifiers)
const;
1015 #if QT_VERSION < 0x030000 1019 void setMouseBinding(
int state,
ClickAction action,
bool doubleClick=
false, Qt::MouseButtons buttonsBefore=Qt::NoButton);
1020 #if QT_VERSION < 0x030000 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);
1027 void setHandlerStateKey(
MouseHandler handler,
int buttonState);
1028 void setMouseStateKey(
MouseHandler handler,
int buttonState);
1040 QString stateFileName()
const;
1041 virtual QDomElement domElement(
const QString& name, QDomDocument& document)
const;
1044 virtual void initFromDOMElement(
const QDomElement& element);
1045 virtual void saveStateToFile();
1046 virtual bool restoreStateFromFile();
1063 void saveToFile(
const QString& fileName=QString::null);
1064 bool restoreFromFile(
const QString& fileName=QString::null);
1068 static void saveStateToFileForAllViewers();
1086 #if QT_VERSION >= 0x040000 1100 #if QT_VERSION >= 0x040000 1111 virtual void setVisualHintsMask(
int mask,
int delay = 2000);
1112 virtual void drawVisualHints();
1115 virtual void resetVisualHints();
1131 void defaultConstructor();
1140 void connectAllCameraKFIInterpolatedSignals(
bool connection=
true);
1190 void setDefaultShortcuts();
1191 QString cameraPathKeysString()
const;
1231 if (button != cap.
button)
1232 return button < cap.
button;
1242 void setDefaultMouseBindings();
1243 void performClickAction(
ClickAction ca,
const QMouseEvent*
const e);
1249 void initializeSnapshotFormats();
1250 QImage frameBufferSnapshot();
1256 #if QT_VERSION >= 0x040000 1257 static QList<QGLViewer*> QGLViewerPool_;
1272 #endif // QGLVIEWER_QGLVIEWER_H
int selectRegionHeight() const
QMap< Qt::Key, int > pathIndex_
QMap< Qt::KeyboardModifiers, MouseActionPrivate > wheelBinding_
static QPtrList< QGLViewer > QGLViewerPool_
bool operator<(const ClickActionPrivate &cap) const
QTabWidget * helpWidget()
void toggleFPSIsDisplayed()
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
void drawVectorial(void *param)
void setSnapshotQuality(int quality)
Qt::KeyboardModifiers playPathKeyboardModifiers_
Qt::MouseButtons buttonsBefore
void setForegroundColor(const QColor &color)
virtual QString shortcutBindingsString() const
int previousBufferTextureInternalFormat_
QMap< int, QString > keyDescription_
virtual QString mouseBindingsString() const
QGLViewer(const QGLFormat &format, QWidget *parent=0, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
QColor foregroundColor() const
int selectBufferSize() const
float bufferTextureMaxV() const
QMap< KeyboardAction, QString > keyboardActionDescription_
QGLViewer(QWidget *parent=NULL, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
virtual void setSceneRadius(float radius)
unsigned int previousBufferTextureFormat_
int animationPeriod() const
void setSelectedName(int id)
void toggleCameraIsEdited()
qglviewer::MouseGrabber * mouseGrabber_
void setAnimationPeriod(int period)
qglviewer::Vec sceneCenter() const
Abstract class for objects that grab mouse focus in a QGLViewer.
static int QGLViewerIndex(const QGLViewer *const viewer)
void setGridIsDrawn(bool draw=true)
void setSnapshotFormat(const QString &format)
void setSelectRegionHeight(int height)
qglviewer::MouseGrabber * mouseGrabber() const
QMap< ClickActionPrivate, ClickAction > clickBinding_
bool mouseGrabberIsAManipulatedCameraFrame_
void setTextIsEnabled(bool enable=true)
The Vec class represents 3D positions and 3D vectors.
QColor backgroundColor() const
QFont scaledFont(const QFont &font) const
bool cameraIsEdited() const
static const QPtrList< QGLViewer > & QGLViewerPool()
qglviewer::ManipulatedFrame * manipulatedFrame() const
bool manipulatedFrameIsACamera_
void setAxisIsDrawn(bool draw=true)
virtual QString helpString() const
virtual void drawWithNames()
void setFPSIsDisplayed(bool display=true)
qglviewer::ManipulatedFrame * manipulatedFrame_
void setSelectRegionWidth(int width)
bool displaysInStereo() const
bool mouseGrabberIsAManipulatedFrame_
bool mouseGrabberIsEnabled(const qglviewer::MouseGrabber *const mouseGrabber)
void setStateFileName(const QString &name)
A versatile 3D OpenGL viewer based on QGLWidget.
float bufferTextureMaxU() const
const QString & snapshotFileName() const
QMap< ClickActionPrivate, QString > mouseDescription_
void toggleTextIsEnabled()
void toggleStereoDisplay()
void setBackgroundColor(const QColor &color)
A perspective or orthographic camera.
float sceneRadius() const
int selectRegionWidth() const
QMap< size_t, bool > disabledMouseGrabbers_
Qt::KeyboardModifiers modifiers
int snapshotCounter() const
QGLViewer(QGLContext *context, QWidget *parent, const char *name=0, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
virtual QSize sizeHint() const
bool FPSIsDisplayed() const
virtual void setSceneCenter(const qglviewer::Vec ¢er)
bool isFullScreen() const
float previousCameraZClippingCoefficient_
bool textIsEnabled() const
const QString & snapshotFormat() const
QMap< KeyboardAction, unsigned int > keyboardBinding_
qglviewer::Camera * camera_
void setSceneBoundingBox(const qglviewer::Vec &min, const qglviewer::Vec &max)
virtual void postSelection(const QPoint &point)
void setSnapshotCounter(int counter)
float aspectRatio() const
bool animationIsStarted() const
QMap< int, MouseActionPrivate > mouseBinding_
qglviewer::Camera * camera() const