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> 87 class QSocketNotifier;
88 class QPropertyAnimation;
89 class QFramebufferObject;
102 class QGraphicsScene;
104 class QtShiftPopupMenu;
109 class QOpenGLFramebufferObject;
110 class QOpenGLFramebufferObjectFormat;
113 class QOpenGLDebugLogger;
114 class QOpenGLDebugMessage;
144 OFGLWidget* _glWidget,
146 QGraphicsWidget* _parent = 0 );
155 virtual void makeCurrent();
157 virtual void swapBuffers();
166 void functionMenuUpdate();
168 void statusMessage (
const QString & message,
int timeout = 0);
173 void trackMouse(
bool _track);
190 unsigned int _maxPasses,
193 const bool _resetTrackBall =
false);
198 PERSPECTIVE_PROJECTION
204 FIRSTPERSON_NAVIGATION
221 void setScenePos(
const ACG::Vec3d& _center,
double _radius,
const bool _resetTrackBall =
false );
247 copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
251 void copyToImage( QImage& _image,
252 unsigned int _left,
unsigned int _top,
253 unsigned int _width,
unsigned int _height,
258 unsigned int glWidth()
const;
260 unsigned int glHeight()
const;
262 QSize glSize()
const;
264 QPoint glMapFromGlobal(
const QPoint& _pos )
const;
266 QPoint glMapToGlobal(
const QPoint& _pos )
const;
268 double field_of_view_vertical()
const;
272 if (isVisible() && glWidth() && glHeight())
273 return (
double) glWidth() / (double) glHeight();
280 return properties_.nearPlane();
285 return properties_.farPlane();
290 return properties_.orthoWidth();
297 void encodeView(QString& _view,
const QSize& _windowSize = QSize(-1,-1),
298 const int _toolBarWidth = -1,
const bool _make_c_string =
false);
312 static bool decodeView(
const QString& _view,
314 QSize *_windowSize = NULL,
315 int* _splitterWidth = NULL, QSize *_viewportSize = NULL);
326 bool decodeView(
const QString& _view, QSize *_windowSize = NULL,
327 int* _toolBarWidth = NULL, QSize *_viewportSize = NULL);
330 void initModelviewMatrix();
336 void releaseGLArea();
343 { rotate(axis, angle, properties_.trackballCenter()); }
352 void updateCursorPosition (QPointF _scenePos);
370 virtual void updateGL();
373 virtual void setHome();
377 virtual void viewAll();
380 virtual void perspectiveProjection();
382 virtual void orthographicProjection();
384 virtual void toggleProjectionMode();
386 virtual void toggleNavigationMode();
389 virtual void setFOVY(
double _fovy);
393 void projectionModeChanged(
bool _ortho );
394 void navigationModeChanged(
bool _normal );
406 void actionPasteView(QSize * _windowSize = NULL,
int *_splitterWidth = NULL);
410 void actionCopyView(
const QSize &_windowSize = QSize(-1,-1),
const int _splitterWidth = -1,
411 const bool _make_c_string =
false);
413 void actionSetView(QString view);
428 void signalMouseEvent(QMouseEvent*,
const std::string&);
431 void signalMouseEvent(QMouseEvent*);
434 void signalWheelEvent(QWheelEvent*,
const std::string&);
439 void signalMouseEventIdentify( QMouseEvent* );
444 void signalMouseEventLight( QMouseEvent* );
451 void signalMouseEventClick ( QMouseEvent*,
bool _double );
460 void signalCustomContextMenuRequested (
const QPoint & );
465 void slotClickTimeout ();
480 virtual void initializeGL();
482 virtual void paintGL(
double _aspect = 0.0);
484 virtual void resizeEvent(QGraphicsSceneResizeEvent * _e);
486 virtual void moveEvent (QGraphicsSceneMoveEvent * _e);
489 virtual void mousePressEvent(QGraphicsSceneMouseEvent* _event);
491 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _event);
493 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _event);
495 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* _event);
497 virtual void wheelEvent(QGraphicsSceneWheelEvent* _event);
499 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* _e);
503 void viewMouseEvent( QMouseEvent* _event);
505 void viewWheelEvent(QWheelEvent* _event);
507 void viewKeyEvent( QKeyEvent* _event);
514 void updateProjectionMatrix(
double _aspect = 0.0);
521 virtual void slotWheelX(
double _dAngle);
523 virtual void slotWheelY(
double _dAngle);
525 virtual void slotWheelZ(
double _dist);
529 { removeEventFilter( sender());}
532 void processGLDebugMessage(
const QOpenGLDebugMessage& msg);
544 void createWidgets();
548 void drawScene(
double _aspect = 0.0);
550 void drawScene_mono();
557 void startGLDebugLogger();
558 void deleteGLDebugLogger();
561 void makeWidgetCurrent();
564 bool createQFBO(QOpenGLFramebufferObject*& _ptr, GLuint* _handle,
int _width,
int _height,
int* _samples);
565 bool bindQFBO(QOpenGLFramebufferObject* _ptr);
566 bool QFBOResized(QOpenGLFramebufferObject* _ptr);
567 void blitQFBO(QOpenGLFramebufferObject* _ptr1,
const QRect& _size1, QOpenGLFramebufferObject* _ptr2,
const QRect& _size2);
568 void deleteQFBO(QOpenGLFramebufferObject* _ptr);
587 home_inverse_modelview_;
588 double homeOrthoWidth_;
606 bool projectionUpdateLocked_;
609 QGraphicsScene* glScene_;
612 OFGLWidget* glWidget_;
618 std::vector< QAction * > drawMenuActions_;
627 QOpenGLDebugLogger* glDebugLogger_;
636 bool wheelsVisible();
639 void slotShowWheels();
640 void slotHideWheels();
665 void signalMakeActive ();
718 void signalKeyPressEvent(QKeyEvent*);
755 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* _e);
758 virtual void dropEvent(QGraphicsSceneDragDropEvent* _e);
764 void startDragEvent( QMouseEvent* _event );
769 void dragEnterEvent(QDragEnterEvent* _event);
774 void dropEvent( QDropEvent* _event );
791 virtual void snapshot(
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
794 virtual void snapshot(QImage& _image,
int _width = 0,
int _height = 0,
bool _alpha =
false,
bool _hideCoordsys =
false,
int samples = 1);
817 const QPoint& _mousePos,
836 const QRegion& _region,
837 QList<QPair<size_t,size_t> >& _list,
838 QVector<float>* _depths = 0,
839 QVector<ACG::Vec3d>* _points = 0);
847 bool fast_pick(
const QPoint& _mousePos,
851 return glstate_->unproject(pt);
858 const QPoint& _mousePos,
865 const QPoint& _mousePos,
904 constrainedRotationAxis_ = axis;
907 return constrainedRotationAxis_[0] == constrainedRotationAxis_[0];
910 return constrainedRotationAxis_;
913 constrainedRotationAxis_[0] = std::numeric_limits<double>::quiet_NaN();
916 updatePickCache_ =
true;
921 void slotAnimation();
940 bool mapToSphere(
const QPoint& _p,
ACG::Vec3d& _result)
const;
943 void handleFirstPersonNavigation( QMouseEvent* _event);
946 void handleNormalNavigation( QMouseEvent* _event);
993 void slotPropertiesUpdated();
999 void applyProperties();
1016 virtual void flyTo(
const QPoint& _pos,
bool _moveBack);
1031 virtual void flyFrom(
const QPoint& _pos) { flyTo(_pos,
true); }
1038 virtual void flyTo(
const ACG::Vec3d& _position,
1060 Q_PROPERTY(
double currentAnimationPosition READ currentAnimationPos WRITE currentAnimationPos NOTIFY currentAnimationPosChanged)
1063 double currentAnimationPos_;
1066 double currentAnimationPos() {
return currentAnimationPos_;};
1069 void currentAnimationPos(
double _currentAnimationPos) {currentAnimationPos_ = _currentAnimationPos; emit currentAnimationPosChanged(_currentAnimationPos); };
1085 void currentAnimationPosChanged(
double _currentAnimationPos);
1089 void flyAnimationPerspective(QVariant _pos);
1092 void flyAnimationOrthogonal(QVariant _pos);
1095 void flyAnimationPerspectiveFinished();
1098 void flyAnimationOrthogonalFinished();
1119 void computeProjStereo(
int _width,
int _height,
1145 #endif // BASEVIEWER_HH defined ACG::Vec3d flyTranslation_
Full translation between start and ed of animation.
void invalidatePickCache()
mouse interaction position
Namespace providing different geometric functions concerning angles.
ACG::Vec3d flyCenter_
The new center after the flyTo animation.
QMouseEvent clickEvent_
mouse interaction position
const ACG::Vec3d scene_center() const
QOpenGLFramebufferObjectFormat QFramebufferObjectFormat
Framebuffer object that holds the pick cache.
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
float startDepth_
mouse interaction depth
double lastRotationAngle_
mouse interaction position
double flyOrthoWidthOriginal_
Original orthogonal width during flyTo in orthogonal mode.
virtual void keyReleaseEvent(QKeyEvent *_event)
Get keyRelease events from the glArea.
QFramebufferObject * mouseCache_
Framebuffer object that holds the pick cache.
virtual void flyFrom(const QPoint &_pos)
Animated flight.
void setSceneCenter(const ACG::Vec3d &_center)
virtual bool viewKeyPressEvent(QKeyEvent *)
Handle key events in view mode.
bool allowRotation()
mouse interaction position
double ortho_width() const
Get width of the gl scene in orthogonal projection mode.
NavigationMode navigationMode() const
get current navigation mode
ACG::Vec3d constrainedRotationAxis_
mouse interaction position
ProjectionMode
projection mode
QOpenGLFramebufferObject QFramebufferObject
Framebuffer object that holds the pick cache.
bool allowConstrainedRotation()
mouse interaction position
virtual void flyTo(const QPoint &_pos)
Animated flight.
ACG::SceneGraph::PickTarget pickCacheTarget_
Pick target stored in pick cache.
void rotate(const ACG::Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
bool allowRotation_
mouse interaction position
bool updatePickCache_
Should the pick cache be updated.
void unlockProjectionUpdate(void)
Unlock update of projection matrix.
QTimer * timer_
mouse interaction position
double aspect_ratio() const
Returns the viewer's aspect ratio.
ACG::GLState * glstate_
Gl State.
QPropertyAnimation * flyAnimationPerspective_
The animation object for flyTo.
bool flyMoveBack_
Flag for fly in orthogonal mode if we move back or forward.
QTime clickTime_
mouse interaction position
QPoint lastPoint2D_
mouse interaction position
ACG::Vec3d lastRotationAxis_
mouse interaction position
Viewer::ViewerProperties * properties()
Returns a pointer to the Viewer Status.
double fovyModifier_
mouse interaction position
QPropertyAnimation * flyAnimationOrthogonal_
The animation object for flyTo.
Viewer::ViewerProperties & properties_
All properties for this viewer.
const ACG::Vec3d & getConstrainedRotationAxis()
mouse interaction position
bool pickCacheSupported_
Is pick caching supported.
void lockProjectionUpdate(void)
Lock update of projection matrix.
ProjectionMode projectionMode() const
get current projection mode
virtual void keyPressEvent(QKeyEvent *_event)
Get keyPress events from the glArea.
double lastAnimationPos_
The last position of the animation to compute the difference vector.
const ACG::Vec3d trackBallCenter()
Get Trackball Center point of scene.
use provided normals as is
bool initialized_
Have the viewer gl properties been initalized.
QTime lastMoveTime_
mouse interaction position
void allowConstrainedRotation(const ACG::Vec3d &axis)
mouse interaction position
void disallowConstrainedRotation()
mouse interaction position
double flyAngle_
The rotation angle (full angle) for fly to animation.
void setSceneRadius(double _radius)
QTimer clickTimer_
mouse interaction position
double scene_radius() const
NavigationMode
Navigation mode.
QFramebufferObject * pickCache_
Framebuffer object that holds the pick cache.
PickTarget
What target to use for picking.
ACG::Vec3d flyPosition_
The new position after the flyTo animation.
ACG::Vec3d unproject(const ACG::Vec3d &pt)
Framebuffer object that holds the pick cache.
double near_plane() const
Returns a chili cheese burger.
NormalsMode
Automatically normalize normals?
bool lastPoint_hitSphere_
mouse interaction position
void setTrackBallCenter(const ACG::Vec3d &_center)
Set Trackball Center point of scene.
void allowRotation(bool _mode)
Lock scene rotation.
double far_plane() const
Returns a peanut butter sandwich.
PostProcessing * postproc_
Post-Processing executor.
ACG::Vec3d lastPoint3D_
mouse interaction position
virtual void cleanupEventFilter()
correct ??? (same function as in qt src)
ACG::Vec3d flyAxis_
The rotation axis for fly to animation.
NormalsMode normalsMode() const
get treatment of normals