58 #ifndef ACG_QTBASEVIEWER_HH
59 #define ACG_QTBASEVIEWER_HH
64 #include "../GL/GLState.hh"
65 #include "../Scenegraph/SceneGraph.hh"
66 #include "../Scenegraph/DrawModes.hh"
70 #include <QtNetwork/QUdpSocket>
71 #include <QWheelEvent>
74 #include <QContextMenuEvent>
75 #include <QDragEnterEvent>
76 #include <QMouseEvent>
98 class QSocketNotifier;
99 class QGraphicsWidget;
100 class QGraphicsGridLayout;
107 namespace QtWidgets {
116 class QtSceneGraphDialog;
117 class QtShiftPopupMenu;
150 ShowPrivateStatusBar=1,
168 ShowQuestionButton=0x10,
183 DefaultOptions = 0xffff & (~ShowPrivateStatusBar)
202 QStatusBar *_statusBar=0,
203 const QGLFormat* _format=0,
205 Options _options=DefaultOptions );
216 virtual QSize sizeHint ()
const;
228 void setStatusBar(QStatusBar* _sb);
231 void applyOptions(
int _options);
237 virtual void makeCurrent();
239 virtual void swapBuffers();
250 glstate_->set_clear_color(_color); updateGL();
261 virtual void lockUpdate();
263 virtual void unlockUpdate();
268 virtual void unlockAndUpdate();
283 void animation(
bool _b);
286 void trackMouse(
bool _track);
289 void enablePopupMenu(
bool _enable);
314 FIRSTPERSON_NAVIGATION
320 PERSPECTIVE_PROJECTION
324 void projectionMode(ProjectionMode _p);
329 void navigationMode(NavigationMode _n);
337 void setScenePos(
const ACG::Vec3d& _center,
double _radius,
const bool _setCenter =
true );
342 void setSceneCenter(
const ACG::Vec3d& _center );
353 void setSceneRadius(
double radius) { scene_radius_ = radius; }
359 void setFovy(
double _fovy );
381 void actionMode(ActionMode);
397 void faceOrientation(FaceOrientation);
402 void backFaceCulling(
bool _b );
407 void twoSidedLighting(
bool _b );
423 void normalsMode(NormalsMode _mode);
431 void rotate_lights(
Vec3d& _axis,
double _angle);
433 void update_lights();
438 copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
442 void copyToImage( QImage& _image,
443 unsigned int _left,
unsigned int _top,
444 unsigned int _width,
unsigned int _height,
449 unsigned int glWidth()
const;
451 unsigned int glHeight()
const;
453 QSize glSize()
const;
455 QPoint glMapFromGlobal(
const QPoint& _pos )
const;
457 QPoint glMapToGlobal(
const QPoint& _pos )
const;
471 void encodeView(QString& _view);
476 bool decodeView(
const QString& _view);
479 void initModelviewMatrix();
485 void releaseGLArea();
491 void translate(
const Vec3d& trans);
495 { rotate(axis, angle, trackball_center_); }
498 void rotate(
const Vec3d& axis,
double angle,
const Vec3d& _center);
502 QMenu * getFuncMenu() {
return funcMenu_; };
503 QMenu * getDrawMenu() {
return drawMenu_; };
506 QToolBar* getToolBar();
509 QToolBar* removeToolBar();
531 virtual void drawNow();
533 virtual void updateGL();
536 virtual void setHome();
540 virtual void viewAll();
542 virtual void flyTo(
const QPoint& _pos,
bool _move_back);
544 virtual void flyTo(
const QPoint& _pos) {
flyTo(_pos,
false); }
546 virtual void flyFrom(
const QPoint& _pos) { flyTo(_pos,
true); }
553 virtual void flyTo(
const Vec3d& _position,
554 const Vec3d& _center,
555 double _time = 1000.0);
565 virtual void perspectiveProjection();
567 virtual void orthographicProjection();
569 virtual void toggleProjectionMode();
571 virtual void toggleNavigationMode();
575 void projectionModeChanged(
bool _ortho );
576 void navigationModeChanged(
bool _normal );
581 virtual void showSceneGraphDialog();
584 virtual void setView(
const GLMatrixd& _modelview,
587 void actionBackground();
588 void actionCopyView();
589 void actionPasteView();
590 void actionPasteDropSize();
591 void actionSynchronize();
592 void actionAnimation();
593 void actionBackfaceCulling();
594 void actionTwoSidedLighting();
595 void actionSynchronize(
bool _enable);
596 void actionAnimation(
bool _enable);
597 void actionBackfaceCulling(
bool _enable);
598 void actionTwoSidedLighting(
bool _enable);
600 void actionDrawMenu( QAction * _action );
601 void actionPickMenu( QAction * _action );
610 void signalInitializeGL();
622 void signalMouseEvent(QMouseEvent*,
const std::string&);
625 void signalMouseEvent(QMouseEvent*);
628 void signalWheelEvent(QWheelEvent*,
const std::string&);
633 void signalMouseEventIdentify( QMouseEvent* );
637 void signalSetView(
const GLMatrixd& _modelview,
655 void signalCustomContextMenuRequested (
const QPoint & );
665 virtual void initializeGL();
667 virtual void paintGL();
669 virtual void resizeGL(
int _w,
int _h);
673 virtual void glMousePressEvent(QMouseEvent* _event);
675 virtual void glMouseDoubleClickEvent(QMouseEvent* _event);
677 virtual void glMouseMoveEvent(QMouseEvent* _event);
679 virtual void glMouseReleaseEvent(QMouseEvent* _event);
681 virtual void glMouseWheelEvent(QWheelEvent* _event);
683 virtual void glContextMenuEvent(QContextMenuEvent* _event);
687 virtual void viewMouseEvent( QMouseEvent* _event) = 0;
689 virtual void viewWheelEvent(QWheelEvent* _event) = 0;
699 void updateProjectionMatrix();
701 void updatePickMenu();
709 virtual void sceneRectChanged(
const QRectF & rect);
712 virtual void slotWheelX(
double _dAngle);
714 virtual void slotWheelY(
double _dAngle);
716 virtual void slotWheelZ(
double _dist);
723 { removeEventFilter( sender());}
730 void hidePopupMenus();
751 QtBaseViewer(
const QtBaseViewer&);
753 QtBaseViewer& operator=(
const QtBaseViewer&);
756 void createWidgets(
const QGLFormat* _format,QStatusBar* _sb,
757 const QtBaseViewer* _share);
763 void drawScene_mono();
765 void drawScene_stereo();
769 void updatePopupMenu();
776 Vec3d scene_center_, trackball_center_;
777 double scene_radius_, trackball_radius_;
781 GLdouble orthoWidth_;
782 GLdouble near_, far_, fovy_;
794 QStatusBar* statusbar_;
806 home_inverse_modelview_;
807 double homeOrthoWidth_;
815 NormalsMode normalsMode_;
816 FaceOrientation faceOrientation_;
817 ProjectionMode projectionMode_;
818 NavigationMode navigationMode_;
820 ActionMode actionMode_, lastActionMode_;
821 bool backFaceCulling_;
822 bool twoSidedLighting_;
843 bool projectionUpdateLocked_;
848 QtSceneGraphDialog* sceneGraphDialog_;
855 QGLWidget* glWidget_;
862 QGraphicsWidget* glBase_;
864 QGraphicsGridLayout* glBaseLayout_;
867 QStatusBar* privateStatusBar_;
870 QGridLayout* glLayout_;
873 QToolBar * buttonBar_;
876 QToolButton* pickButton_;
878 QToolButton* moveButton_;
880 QToolButton* lightButton_;
882 QToolButton* questionButton_;
884 QToolButton* projectionButton_;
886 QToolButton* homeButton_;
888 QToolButton* setHomeButton_;
890 QToolButton* viewAllButton_;
892 QToolButton* sceneGraphButton_;
894 QToolButton* stereoButton_;
904 QMap< QString, QAction * > action_;
907 std::vector< QAction * > drawMenuActions_;
933 virtual void toggleStereoMode();
936 virtual void setStereoMode(
bool _b);
943 void setEyeDistance(
double _distance);
946 double eyeDistance( );
952 void setFocalDistance(
double _distance);
955 double focalDistance( );
978 void signalKeyPressEvent(QKeyEvent*);
986 void disableKeyHandling(
bool _state );
991 bool keyHandlingState();
999 virtual void glKeyPressEvent(QKeyEvent*);
1007 virtual void glKeyReleaseEvent(QKeyEvent* _event);
1016 virtual bool viewKeyPressEvent(QKeyEvent* _event) = 0;
1031 virtual void startDrag();
1033 virtual void glDragEnterEvent(QDragEnterEvent* _event);
1035 virtual void glDropEvent(QDropEvent* _event);
1045 void startDragEvent( QMouseEvent* _event );
1050 void dragEnterEvent(QDragEnterEvent* _event);
1055 void dropEvent( QDropEvent* _event );
1083 virtual void setSynchronization(
bool _b);
1086 bool add_sync_host(
const QString& _name);
1088 void add_sync_host(QHostAddress& _adr);
1090 bool synchronization();
1094 void sync_receive();
1095 void sync_send(
const GLMatrixd& _modelview,
1130 virtual void snapshotBaseFileName(
const QString& _fname);
1136 virtual void snapshot();
1140 void actionSnapshot();
1144 void actionSnapshotName();
1148 void actionSnapshotSavesView();
1177 const QPoint& _mousePos,
1178 unsigned int& _nodeIdx,
1179 unsigned int& _targetIdx,
1180 Vec3d* _hitPointPtr=0 );
1187 bool fast_pick(
const QPoint& _mousePos,
1198 void addPickMode(
const std::string& _name,
1199 bool _mouse_tracking =
false,
1201 bool _visible =
true,
1202 QCursor _cursor = Qt::ArrowCursor );
1206 void clearPickModes();
1210 const std::string& pickMode()
const;
1215 void pickMode(
const std::string& _name);
1220 void pickMode(
int _id );
1233 virtual void pickingMode();
1240 void setPickModeCursor(
const std::string& _name, QCursor _cursor);
1247 void setPickModeMouseTracking(
const std::string& _name,
bool _mouseTracking);
1252 void signalPickModeChanged(
const std::string&);
1261 PickMode(
const std::string& _n,
bool _t,
bool _v, QCursor _c) :
1262 name(_n), tracking(_t), visible(_v), cursor(_c) {}
1311 #endif // ACG_QTBASEVIEWER_HH defined
double focalDist_
Set eye distance for stereo.
QUdpSocket * socket_
socket used for synchronization
bool synchronized_
synchronized with different viewer?
virtual void lightMouseEvent(QMouseEvent *)
optional: hande mouse events to rotate light
QStatusBar * statusBar()
get status bar, guaranteed to be not 0 (QStatusBar may be invisible)
std::vector< PickMode > pick_modes_
void lockProjectionUpdate(void)
Lock update of projection matrix.
Namespace providing different geometric functions concerning angles.
Vec4f backgroundColor()
get background color
PickTarget
What target to use for picking.
ACG::SceneGraph::DrawModes::DrawMode drawMode()
get current draw mode
std::string pick_mode_name_
bool skipNextSync_
Skips the next synch event.
NormalsMode normalsMode() const
get treatment of normals
FaceOrientation
orientation of the faces
const ACG::Vec3d & scene_center() const
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
use provided normals as is
NavigationMode navigationMode() const
get current navigation mode
void setExternalDrag(bool _external)
Enable or disable external dragging controls.
void rotate(const Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
ProjectionMode
projection mode
GLState & glState()
get OpenGL state
NormalsMode
Automatically normalize normals?
virtual void flyTo(const QPoint &_pos)
Fly to, get closer.
void backgroundColor(const Vec4f &_color)
SceneGraph::BaseNode * sceneGraph()
Returns: root node of scene graph.
bool animation() const
Is animation enabled?
virtual void questionMode()
calls actionMode() with QuestionMode (cf. ActionMode)
virtual void lightMode()
calls actionMode() with LightMode (cf. ActionMode)
FaceOrientation faceOrientation() const
get face orientation
QMenu * getPickMenu()
Get the menu pointers (required to add them to the menubar as a temp workaround for a qt 4...
bool disableKeyHandling_
Enable or disable internal Key handling.
const SceneGraph::BaseNode * sceneGraph() const
same but const
bool stereo_
Set eye distance for stereo.
virtual void examineMode()
calls actionMode() with ExamineMode (cf. ActionMode)
ACG::SceneGraph::PickTarget pickRendererMode_
bool backFaceCulling() const
is backface culling enabled?
virtual void cleanupEventFilter()
correct ??? (same function as in qt src)
NavigationMode
Navigation mode.
bool twoSidedLighting() const
is 2-sided lighing enabled?
bool isUpdateLocked() const
virtual void flyFrom(const QPoint &_pos)
Fly to, get more distant.
std::vector< QHostAddress > sync_hosts_
List of hosts which should receive sync information.
double scene_radius() const
ProjectionMode projectionMode() const
get current projection mode
ActionMode lastActionMode()
Return the last action mode.
ActionMode
How to react on mouse events?
int options() const
get current ORed Options
PickMode(const std::string &_n, bool _t, bool _v, QCursor _c)
Constructor.
GLMatrixd & light_matrix()
get light rotation matrix
void drawBlendedObjects(bool _status)
One or two pass Drawing.
counter clockwise (default)
ActionMode actionMode() const
get action mode
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
void unlockProjectionUpdate(void)
Unlock update of projection matrix.