61 #include <OpenFlipper/common/OFGLWidget.hh> 63 #include <ACG/GL/GLState.hh> 64 #include <ACG/GL/FBO.hh> 66 #include <ACG/QtWidgets/QtSceneGraphWidget.hh> 68 #include <ACG/ShaderUtils/GLSLShader.hh> 69 #include <ACG/GL/globjects.hh> 75 #include <QGraphicsWidget> 77 #include <QMouseEvent> 79 #include <QElapsedTimer> 88 class QSocketNotifier;
89 class QPropertyAnimation;
90 class QFramebufferObject;
103 class QGraphicsScene;
105 class QtShiftPopupMenu;
110 class QOpenGLFramebufferObject;
111 class QOpenGLFramebufferObjectFormat;
114 class QOpenGLDebugLogger;
115 class QOpenGLDebugMessage;
145 OFGLWidget* _glWidget,
147 QGraphicsWidget* _parent = 0 );
156 virtual void makeCurrent();
158 virtual void swapBuffers();
167 void functionMenuUpdate();
169 void statusMessage (
const QString & message,
int timeout = 0);
174 void trackMouse(
bool _track);
191 unsigned int _maxPasses,
194 const bool _resetTrackBall =
false);
199 PERSPECTIVE_PROJECTION
205 FIRSTPERSON_NAVIGATION
222 void setScenePos(
const ACG::Vec3d& _center,
double _radius,
const bool _resetTrackBall =
false );
248 copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
252 void copyToImage( QImage& _image,
253 unsigned int _left,
unsigned int _top,
254 unsigned int _width,
unsigned int _height,
259 unsigned int glWidth()
const;
261 unsigned int glHeight()
const;
263 QSize glSize()
const;
265 QPoint glMapFromGlobal(
const QPoint& _pos )
const;
267 QPoint glMapToGlobal(
const QPoint& _pos )
const;
269 double field_of_view_vertical()
const;
273 if (isVisible() && glWidth() && glHeight())
274 return (
double) glWidth() / (double) glHeight();
281 return properties_.nearPlane();
286 return properties_.farPlane();
291 return properties_.orthoWidth();
298 void encodeView(QString& _view,
const QSize& _windowSize = QSize(-1,-1),
299 const int _toolBarWidth = -1,
const bool _make_c_string =
false);
313 static bool decodeView(
const QString& _view,
315 QSize *_windowSize = NULL,
316 int* _splitterWidth = NULL, QSize *_viewportSize = NULL);
327 bool decodeView(
const QString& _view, QSize *_windowSize = NULL,
328 int* _toolBarWidth = NULL, QSize *_viewportSize = NULL);
331 void initModelviewMatrix();
337 void releaseGLArea();
344 { rotate(axis, angle, properties_.trackballCenter()); }
353 void updateCursorPosition (QPointF _scenePos);
371 virtual void updateGL();
374 virtual void setHome();
378 virtual void viewAll();
381 virtual void perspectiveProjection();
383 virtual void orthographicProjection();
385 virtual void toggleProjectionMode();
387 virtual void toggleNavigationMode();
390 virtual void setFOVY(
double _fovy);
394 void projectionModeChanged(
bool _ortho );
395 void navigationModeChanged(
bool _normal );
407 void actionPasteView(QSize * _windowSize = NULL,
int *_splitterWidth = NULL);
411 void actionCopyView(
const QSize &_windowSize = QSize(-1,-1),
const int _splitterWidth = -1,
412 const bool _make_c_string =
false);
414 void actionSetView(QString view);
429 void signalMouseEvent(QMouseEvent*,
const std::string&);
432 void signalMouseEvent(QMouseEvent*);
435 void signalWheelEvent(QWheelEvent*,
const std::string&);
440 void signalMouseEventIdentify( QMouseEvent* );
445 void signalMouseEventLight( QMouseEvent* );
452 void signalMouseEventClick ( QMouseEvent*,
bool _double );
461 void signalCustomContextMenuRequested (
const QPoint & );
466 void slotClickTimeout ();
481 virtual void initializeGL();
483 virtual void paintGL(
double _aspect = 0.0);
485 virtual void resizeEvent(QGraphicsSceneResizeEvent * _e);
487 virtual void moveEvent (QGraphicsSceneMoveEvent * _e);
490 virtual void mousePressEvent(QGraphicsSceneMouseEvent* _event);
492 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _event);
494 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _event);
496 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* _event);
498 virtual void wheelEvent(QGraphicsSceneWheelEvent* _event);
500 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* _e);
504 void viewMouseEvent( QMouseEvent* _event);
506 void viewWheelEvent(QWheelEvent* _event);
508 void viewKeyEvent( QKeyEvent* _event);
515 void updateProjectionMatrix(
double _aspect = 0.0);
522 virtual void slotWheelX(
double _dAngle);
524 virtual void slotWheelY(
double _dAngle);
526 virtual void slotWheelZ(
double _dist);
530 { removeEventFilter( sender());}
533 void processGLDebugMessage(
const QOpenGLDebugMessage& msg);
545 void createWidgets();
549 void drawScene(
double _aspect = 0.0);
551 void drawScene_mono();
558 void startGLDebugLogger();
559 void deleteGLDebugLogger();
562 void makeWidgetCurrent();
565 bool createQFBO(QOpenGLFramebufferObject*& _ptr, GLuint* _handle,
int _width,
int _height,
int* _samples);
566 bool bindQFBO(QOpenGLFramebufferObject* _ptr);
567 bool QFBOResized(QOpenGLFramebufferObject* _ptr);
568 void blitQFBO(QOpenGLFramebufferObject* _ptr1,
const QRect& _size1, QOpenGLFramebufferObject* _ptr2,
const QRect& _size2);
569 void deleteQFBO(QOpenGLFramebufferObject* _ptr);
588 home_inverse_modelview_;
589 double homeOrthoWidth_;
607 bool projectionUpdateLocked_;
610 QGraphicsScene* glScene_;
613 OFGLWidget* glWidget_;
619 std::vector< QAction * > drawMenuActions_;
622 QElapsedTimer redrawTime_;
628 QOpenGLDebugLogger* glDebugLogger_;
637 bool wheelsVisible();
640 void slotShowWheels();
641 void slotHideWheels();
666 void signalMakeActive ();
719 void signalKeyPressEvent(QKeyEvent*);
756 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* _e);
759 virtual void dropEvent(QGraphicsSceneDragDropEvent* _e);
765 void startDragEvent( QMouseEvent* _event );
770 void dragEnterEvent(QDragEnterEvent* _event);
775 void dropEvent( QDropEvent* _event );
792 virtual void snapshot(
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
795 virtual void snapshot(QImage& _image,
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
818 const QPoint& _mousePos,
837 const QRegion& _region,
838 QList<QPair<size_t,size_t> >& _list,
839 QVector<float>* _depths = 0,
840 QVector<ACG::Vec3d>* _points = 0);
848 bool fast_pick(
const QPoint& _mousePos,
852 return glstate_->unproject(pt);
859 const QPoint& _mousePos,
866 const QPoint& _mousePos,
905 constrainedRotationAxis_ = axis;
908 return constrainedRotationAxis_[0] == constrainedRotationAxis_[0];
911 return constrainedRotationAxis_;
914 constrainedRotationAxis_[0] = std::numeric_limits<double>::quiet_NaN();
917 updatePickCache_ =
true;
922 void slotAnimation();
941 bool mapToSphere(
const QPoint& _p,
ACG::Vec3d& _result)
const;
944 void handleFirstPersonNavigation( QMouseEvent* _event);
947 void handleNormalNavigation( QMouseEvent* _event);
994 void slotPropertiesUpdated();
1000 void applyProperties();
1017 virtual void flyTo(
const QPoint& _pos,
bool _moveBack);
1032 virtual void flyFrom(
const QPoint& _pos) { flyTo(_pos,
true); }
1039 virtual void flyTo(
const ACG::Vec3d& _position,
1061 Q_PROPERTY(
double currentAnimationPosition READ currentAnimationPos WRITE currentAnimationPos NOTIFY currentAnimationPosChanged)
1064 double currentAnimationPos_;
1067 double currentAnimationPos() {
return currentAnimationPos_;};
1070 void currentAnimationPos(
double _currentAnimationPos) {currentAnimationPos_ = _currentAnimationPos; emit currentAnimationPosChanged(_currentAnimationPos); };
1086 void currentAnimationPosChanged(
double _currentAnimationPos);
1090 void flyAnimationPerspective(QVariant _pos);
1093 void flyAnimationOrthogonal(QVariant _pos);
1096 void flyAnimationPerspectiveFinished();
1099 void flyAnimationOrthogonalFinished();
1120 void computeProjStereo(
int _width,
int _height,
1146 #endif // BASEVIEWER_HH defined double near_plane() const
Returns a chili cheese burger.
QPropertyAnimation * flyAnimationPerspective_
The animation object for flyTo.
void allowRotation(bool _mode)
Lock scene rotation.
NormalsMode normalsMode() const
get treatment of normals
ACG::Vec3d unproject(const ACG::Vec3d &pt)
Framebuffer object that holds the pick cache.
virtual bool viewKeyPressEvent(QKeyEvent *)
Handle key events in view mode.
void lockProjectionUpdate(void)
Lock update of projection matrix.
void setSceneCenter(const ACG::Vec3d &_center)
QMouseEvent clickEvent_
mouse interaction position
bool updatePickCache_
Should the pick cache be updated.
double far_plane() const
Returns a peanut butter sandwich.
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
virtual void keyPressEvent(QKeyEvent *_event)
Get keyPress events from the glArea.
Namespace providing different geometric functions concerning angles.
void rotate(const ACG::Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
ACG::Vec3d constrainedRotationAxis_
mouse interaction position
QPropertyAnimation * flyAnimationOrthogonal_
The animation object for flyTo.
NavigationMode navigationMode() const
get current navigation mode
Viewer::ViewerProperties * properties()
Returns a pointer to the Viewer Status.
double lastAnimationPos_
The last position of the animation to compute the difference vector.
ACG::Vec3d flyTranslation_
Full translation between start and ed of animation.
ACG::Vec3d lastPoint3D_
mouse interaction position
ProjectionMode projectionMode() const
get current projection mode
ACG::Vec3d lastRotationAxis_
mouse interaction position
virtual void flyFrom(const QPoint &_pos)
Animated flight.
ACG::Vec3d flyCenter_
The new center after the flyTo animation.
void disallowConstrainedRotation()
mouse interaction position
ACG::SceneGraph::PickTarget pickCacheTarget_
Pick target stored in pick cache.
const ACG::Vec3d & getConstrainedRotationAxis()
mouse interaction position
NavigationMode
Navigation mode.
PickTarget
What target to use for picking.
virtual void keyReleaseEvent(QKeyEvent *_event)
Get keyRelease events from the glArea.
double lastRotationAngle_
mouse interaction position
void allowConstrainedRotation(const ACG::Vec3d &axis)
mouse interaction position
bool initialized_
Have the viewer gl properties been initalized.
ProjectionMode
projection mode
NormalsMode
Automatically normalize normals?
bool allowConstrainedRotation()
mouse interaction position
double scene_radius() const
void invalidatePickCache()
mouse interaction position
QOpenGLFramebufferObjectFormat QFramebufferObjectFormat
Framebuffer object that holds the pick cache.
void unlockProjectionUpdate(void)
Unlock update of projection matrix.
double ortho_width() const
Get width of the gl scene in orthogonal projection mode.
const ACG::Vec3d scene_center() const
virtual void cleanupEventFilter()
correct ??? (same function as in qt src)
QElapsedTimer lastMoveTime_
mouse interaction position
ACG::Vec3d flyPosition_
The new position after the flyTo animation.
const ACG::Vec3d trackBallCenter()
Get Trackball Center point of scene.
bool pickCacheSupported_
Is pick caching supported.
double flyAngle_
The rotation angle (full angle) for fly to animation.
QPoint lastPoint2D_
mouse interaction position
QFramebufferObject * mouseCache_
Framebuffer object that holds the pick cache.
use provided normals as is
bool allowRotation()
mouse interaction position
bool lastPoint_hitSphere_
mouse interaction position
double fovyModifier_
mouse interaction position
void setTrackBallCenter(const ACG::Vec3d &_center)
Set Trackball Center point of scene.
float startDepth_
mouse interaction depth
double flyOrthoWidthOriginal_
Original orthogonal width during flyTo in orthogonal mode.
ACG::Vec3d flyAxis_
The rotation axis for fly to animation.
void setSceneRadius(double _radius)
QTimer * timer_
mouse interaction position
double aspect_ratio() const
Returns the viewer's aspect ratio.
QElapsedTimer clickTime_
mouse interaction position
bool flyMoveBack_
Flag for fly in orthogonal mode if we move back or forward.
QOpenGLFramebufferObject QFramebufferObject
Framebuffer object that holds the pick cache.
QFramebufferObject * pickCache_
Framebuffer object that holds the pick cache.
bool allowRotation_
mouse interaction position
Viewer::ViewerProperties & properties_
All properties for this viewer.
QTimer clickTimer_
mouse interaction position
virtual void flyTo(const QPoint &_pos)
Animated flight.
ACG::GLState * glstate_
Gl State.
PostProcessing * postproc_
Post-Processing executor.