67 #include <ACG/GL/GLState.hh>
68 #include <ACG/GL/FBO.hh>
70 #include <ACG/QtWidgets/QtSceneGraphWidget.hh>
72 #include <ACG/ShaderUtils/GLSLShader.hh>
73 #include <ACG/GL/globjects.hh>
79 #include <QGraphicsWidget>
81 #include <QMouseEvent>
91 class QSocketNotifier;
92 class QPropertyAnimation;
102 namespace QtWidgets {
106 class QGraphicsScene;
108 class QtShiftPopupMenu;
112 #if QT_VERSION < 0x050000
113 class QGLFramebufferObject;
114 class QGLFramebufferObjectFormat;
116 class QOpenGLFramebufferObject;
117 class QOpenGLFramebufferObjectFormat;
148 QGLWidget* _glWidget,
150 QGraphicsWidget* _parent = 0 );
159 virtual void makeCurrent();
161 virtual void swapBuffers();
170 void functionMenuUpdate();
172 void statusMessage (
const QString & message,
int timeout = 0);
177 void trackMouse(
bool _track);
194 unsigned int _maxPasses,
197 const bool _resetTrackBall =
false);
202 PERSPECTIVE_PROJECTION
208 FIRSTPERSON_NAVIGATION
212 void projectionMode(ProjectionMode _p);
217 void navigationMode(NavigationMode _n);
225 void setScenePos(
const ACG::Vec3d& _center,
double _radius,
const bool _resetTrackBall =
false );
245 void normalsMode(NormalsMode _mode);
251 copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
255 void copyToImage( QImage& _image,
256 unsigned int _left,
unsigned int _top,
257 unsigned int _width,
unsigned int _height,
262 unsigned int glWidth()
const;
264 unsigned int glHeight()
const;
266 QSize glSize()
const;
268 QPoint glMapFromGlobal(
const QPoint& _pos )
const;
270 QPoint glMapToGlobal(
const QPoint& _pos )
const;
272 double field_of_view_vertical()
const;
276 if (isVisible() && glWidth() && glHeight())
277 return (
double) glWidth() / (double) glHeight();
284 return properties_.nearPlane();
289 return properties_.farPlane();
294 return properties_.orthoWidth();
301 void encodeView(QString& _view,
const QSize& _windowSize = QSize(-1,-1),
302 const int _toolBarWidth = -1,
const bool _make_c_string =
false);
316 static bool decodeView(
const QString& _view,
318 QSize *_windowSize = NULL,
319 int* _splitterWidth = NULL, QSize *_viewportSize = NULL);
330 bool decodeView(
const QString& _view, QSize *_windowSize = NULL,
331 int* _toolBarWidth = NULL, QSize *_viewportSize = NULL);
334 void initModelviewMatrix();
340 void releaseGLArea();
347 { rotate(axis, angle, properties_.trackballCenter()); }
356 void updateCursorPosition (QPointF _scenePos);
374 virtual void updateGL();
377 virtual void setHome();
381 virtual void viewAll();
384 virtual void perspectiveProjection();
386 virtual void orthographicProjection();
388 virtual void toggleProjectionMode();
390 virtual void toggleNavigationMode();
393 virtual void setFOVY(
double _fovy);
397 void projectionModeChanged(
bool _ortho );
398 void navigationModeChanged(
bool _normal );
410 void actionPasteView(QSize * _windowSize = NULL,
int *_splitterWidth = NULL);
414 void actionCopyView(
const QSize &_windowSize = QSize(-1,-1),
const int _splitterWidth = -1,
415 const bool _make_c_string =
false);
417 void actionSetView(QString view);
432 void signalMouseEvent(QMouseEvent*,
const std::string&);
435 void signalMouseEvent(QMouseEvent*);
438 void signalWheelEvent(QWheelEvent*,
const std::string&);
443 void signalMouseEventIdentify( QMouseEvent* );
448 void signalMouseEventLight( QMouseEvent* );
455 void signalMouseEventClick ( QMouseEvent*,
bool _double );
464 void signalCustomContextMenuRequested (
const QPoint & );
469 void slotClickTimeout ();
484 virtual void initializeGL();
486 virtual void paintGL();
488 virtual void resizeEvent(QGraphicsSceneResizeEvent * _e);
490 virtual void moveEvent (QGraphicsSceneMoveEvent * _e);
493 virtual void mousePressEvent(QGraphicsSceneMouseEvent* _event);
495 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _event);
497 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _event);
499 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* _event);
501 virtual void wheelEvent(QGraphicsSceneWheelEvent* _event);
503 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* _e);
507 void viewMouseEvent( QMouseEvent* _event);
509 void viewWheelEvent(QWheelEvent* _event);
511 void viewKeyEvent( QKeyEvent* _event);
518 void updateProjectionMatrix();
525 virtual void slotWheelX(
double _dAngle);
527 virtual void slotWheelY(
double _dAngle);
529 virtual void slotWheelZ(
double _dist);
533 { removeEventFilter( sender());}
544 void createWidgets();
550 void drawScene_mono();
574 home_inverse_modelview_;
575 double homeOrthoWidth_;
579 NormalsMode normalsMode_;
580 ProjectionMode projectionMode_;
581 NavigationMode navigationMode_;
593 bool projectionUpdateLocked_;
596 QGraphicsScene* glScene_;
599 QGLWidget* glWidget_;
605 std::vector< QAction * > drawMenuActions_;
616 bool wheelsVisible();
619 void slotShowWheels();
620 void slotHideWheels();
645 void signalMakeActive ();
698 void signalKeyPressEvent(QKeyEvent*);
735 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* _e);
738 virtual void dropEvent(QGraphicsSceneDragDropEvent* _e);
744 void startDragEvent( QMouseEvent* _event );
749 void dragEnterEvent(QDragEnterEvent* _event);
754 void dropEvent( QDropEvent* _event );
771 virtual void snapshot(
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
774 virtual void snapshot(QImage& _image,
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
797 const QPoint& _mousePos,
798 unsigned int& _nodeIdx,
799 unsigned int& _targetIdx,
816 const QRegion& _region,
817 QList<QPair<unsigned int, unsigned int> >& _list,
818 QVector<float>* _depths = 0,
819 QVector<ACG::Vec3d>* _points = 0);
827 bool fast_pick(
const QPoint& _mousePos,
831 return glstate_->unproject(pt);
838 const QPoint& _mousePos,
839 unsigned int& _nodeIdx,
840 unsigned int& _targetIdx,
845 const QPoint& _mousePos,
846 unsigned int& _nodeIdx,
847 unsigned int& _targetIdx,
852 #if QT_VERSION < 0x050000
856 typedef QOpenGLFramebufferObjectFormat QFramebufferObjectFormat;
857 typedef QOpenGLFramebufferObject QFramebufferObject;
886 constrainedRotationAxis_ = axis;
889 return constrainedRotationAxis_[0] == constrainedRotationAxis_[0];
892 return constrainedRotationAxis_;
895 constrainedRotationAxis_[0] = std::numeric_limits<double>::quiet_NaN();
898 updatePickCache_ =
true;
903 void slotAnimation();
922 bool mapToSphere(
const QPoint& _p,
ACG::Vec3d& _result)
const;
925 void handleFirstPersonNavigation( QMouseEvent* _event);
928 void handleNormalNavigation( QMouseEvent* _event);
975 void slotPropertiesUpdated();
981 void applyProperties();
998 virtual void flyTo(
const QPoint& _pos,
bool _moveBack);
1013 virtual void flyFrom(
const QPoint& _pos) { flyTo(_pos,
true); }
1020 virtual void flyTo(
const ACG::Vec3d& _position,
1042 Q_PROPERTY(
double currentAnimationPosition READ currentAnimationPos WRITE currentAnimationPos NOTIFY currentAnimationPosChanged)
1045 double currentAnimationPos_;
1048 double currentAnimationPos() {
return currentAnimationPos_;};
1051 void currentAnimationPos(
double _currentAnimationPos) {currentAnimationPos_ = _currentAnimationPos; emit currentAnimationPosChanged(_currentAnimationPos); };
1067 void currentAnimationPosChanged(
double _currentAnimationPos);
1071 void flyAnimationPerspective(QVariant _pos);
1074 void flyAnimationOrthogonal(QVariant _pos);
1077 void flyAnimationPerspectiveFinished();
1080 void flyAnimationOrthogonalFinished();
1101 void computeProjStereo(
int _width,
int _height,
1127 #endif // BASEVIEWER_HH defined
ACG::Vec3d flyPosition_
The new position after the flyTo animation.
PostProcessing * postproc_
Post-Processing executor.
const ACG::Vec3d trackBallCenter()
Get Trackball Center point of scene.
Namespace providing different geometric functions concerning angles.
bool flyMoveBack_
Flag for fly in orthogonal mode if we move back or forward.
bool initialized_
Have the viewer gl properties been initalized.
ACG::Vec3d lastRotationAxis_
mouse interaction position
PickTarget
What target to use for picking.
ACG::Vec3d lastPoint3D_
mouse interaction position
void setSceneRadius(double _radius)
double scene_radius() const
virtual void keyPressEvent(QKeyEvent *_event)
Get keyPress events from the glArea.
NavigationMode
Navigation mode.
double lastAnimationPos_
The last position of the animation to compute the difference vector.
QPoint lastPoint2D_
mouse interaction position
double lastRotationAngle_
mouse interaction position
QPropertyAnimation * flyAnimationPerspective_
The animation object for flyTo.
QGLFramebufferObjectFormat QFramebufferObjectFormat
Framebuffer object that holds the pick cache.
virtual void cleanupEventFilter()
correct ??? (same function as in qt src)
ProjectionMode projectionMode() const
get current projection mode
NavigationMode navigationMode() const
get current navigation mode
double far_plane() const
Returns a peanut butter sandwich.
ACG::Vec3d unproject(const ACG::Vec3d &pt)
Framebuffer object that holds the pick cache.
void disallowConstrainedRotation()
mouse interaction position
const ACG::Vec3d & getConstrainedRotationAxis()
mouse interaction position
void setTrackBallCenter(const ACG::Vec3d &_center)
Set Trackball Center point of scene.
double flyAngle_
The rotation angle (full angle) for fly to animation.
ACG::SceneGraph::PickTarget pickCacheTarget_
Pick target stored in pick cache.
bool allowRotation()
mouse interaction position
QTimer clickTimer_
mouse interaction position
ACG::Vec3d flyTranslation_
Full translation between start and ed of animation.
const ACG::Vec3d scene_center() const
void allowRotation(bool _mode)
Lock scene rotation.
virtual void keyReleaseEvent(QKeyEvent *_event)
Get keyRelease events from the glArea.
QGLFramebufferObject QFramebufferObject
Framebuffer object that holds the pick cache.
virtual void flyFrom(const QPoint &_pos)
Animated flight.
void allowConstrainedRotation(const ACG::Vec3d &axis)
mouse interaction position
virtual bool viewKeyPressEvent(QKeyEvent *)
Handle key events in view mode.
ACG::Vec3d flyAxis_
The rotation axis for fly to animation.
ACG::Vec3d constrainedRotationAxis_
mouse interaction position
NormalsMode normalsMode() const
get treatment of normals
NormalsMode
Automatically normalize normals?
bool lastPoint_hitSphere_
mouse interaction position
QMouseEvent clickEvent_
mouse interaction position
QTime lastMoveTime_
mouse interaction position
ProjectionMode
projection mode
bool pickCacheSupported_
Is pick caching supported.
ACG::GLState * glstate_
Gl State.
double aspect_ratio() const
Returns the viewer's aspect ratio.
QFramebufferObject * pickCache_
Framebuffer object that holds the pick cache.
float startDepth_
mouse interaction depth
bool allowConstrainedRotation()
mouse interaction position
void lockProjectionUpdate(void)
Lock update of projection matrix.
double near_plane() const
Returns a chili cheese burger.
Viewer::ViewerProperties * properties()
Returns a pointer to the Viewer Status.
QTimer * timer_
mouse interaction position
bool updatePickCache_
Should the pick cache be updated.
void rotate(const ACG::Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
bool allowRotation_
mouse interaction position
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
QPropertyAnimation * flyAnimationOrthogonal_
The animation object for flyTo.
virtual void flyTo(const QPoint &_pos)
Animated flight.
void setSceneCenter(const ACG::Vec3d &_center)
double ortho_width() const
Get width of the gl scene in orthogonal projection mode.
double fovyModifier_
mouse interaction position
void unlockProjectionUpdate(void)
Unlock update of projection matrix.
void invalidatePickCache()
mouse interaction position
QTime clickTime_
mouse interaction position
use provided normals as is
double flyOrthoWidthOriginal_
Original orthogonal width during flyTo in orthogonal mode.