52 #ifndef ACG_QTBASEVIEWER_HH 53 #define ACG_QTBASEVIEWER_HH 58 #include "../Scenegraph/DrawModes.hh" 59 #include "../Config/ACGDefines.hh" 60 #include "../Math/VectorT.hh" 61 #include "../Math/GLMatrixT.hh" 62 #include "../Scenegraph/PickTarget.hh" 63 #include "../GL/gl.hh" 66 #include <QtNetwork/QUdpSocket> 67 #include <QWheelEvent> 70 #include <QContextMenuEvent> 71 #include <QDragEnterEvent> 72 #include <QMouseEvent> 94 class QSocketNotifier;
95 class QGraphicsWidget;
96 class QGraphicsGridLayout;
107 namespace QtWidgets {
116 class QtSceneGraphDialog;
117 class QtShiftPopupMenu;
149 ShowPrivateStatusBar=1,
167 ShowQuestionButton=0x10,
182 DefaultOptions = 0xffff & (~ShowPrivateStatusBar)
201 QStatusBar *_statusBar=0,
202 const QGLFormat* _format=0,
204 Options _options=DefaultOptions );
215 virtual QSize sizeHint ()
const;
227 void setStatusBar(QStatusBar* _sb);
230 void applyOptions(
int _options);
236 virtual void makeCurrent();
238 virtual void swapBuffers();
248 void backgroundColor(
const Vec4f& _color);
250 Vec4f backgroundColor();
258 virtual void lockUpdate();
260 virtual void unlockUpdate();
265 virtual void unlockAndUpdate();
280 void animation(
bool _b);
283 void trackMouse(
bool _track);
286 void enablePopupMenu(
bool _enable);
311 FIRSTPERSON_NAVIGATION
317 PERSPECTIVE_PROJECTION
334 void setScenePos(
const ACG::Vec3d& _center,
double _radius,
const bool _setCenter =
true );
339 void setSceneCenter(
const ACG::Vec3d& _center );
350 void setSceneRadius(
double radius) { scene_radius_ = radius; }
356 void setFovy(
double _fovy );
399 void backFaceCulling(
bool _b );
404 void twoSidedLighting(
bool _b );
428 void rotate_lights(
Vec3d& _axis,
double _angle);
430 void update_lights();
435 copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
439 void copyToImage( QImage& _image,
440 unsigned int _left,
unsigned int _top,
441 unsigned int _width,
unsigned int _height,
446 unsigned int glWidth()
const;
448 unsigned int glHeight()
const;
450 QSize glSize()
const;
452 QPoint glMapFromGlobal(
const QPoint& _pos )
const;
454 QPoint glMapToGlobal(
const QPoint& _pos )
const;
468 void encodeView(QString& _view);
473 bool decodeView(
const QString& _view);
476 void initModelviewMatrix();
482 void releaseGLArea();
488 void translate(
const Vec3d& trans);
492 { rotate(axis, angle, trackball_center_); }
495 void rotate(
const Vec3d& axis,
double angle,
const Vec3d& _center);
499 QMenu * getFuncMenu() {
return funcMenu_; };
500 QMenu * getDrawMenu() {
return drawMenu_; };
503 QToolBar* getToolBar();
506 QToolBar* removeToolBar();
528 virtual void drawNow();
530 virtual void updateGL();
533 virtual void setHome();
537 virtual void viewAll();
539 virtual void flyTo(
const QPoint& _pos,
bool _move_back);
541 virtual void flyTo(
const QPoint& _pos) {
flyTo(_pos,
false); }
543 virtual void flyFrom(
const QPoint& _pos) { flyTo(_pos,
true); }
550 virtual void flyTo(
const Vec3d& _position,
551 const Vec3d& _center,
552 double _time = 1000.0);
562 virtual void perspectiveProjection();
564 virtual void orthographicProjection();
566 virtual void toggleProjectionMode();
568 virtual void toggleNavigationMode();
572 void projectionModeChanged(
bool _ortho );
573 void navigationModeChanged(
bool _normal );
578 virtual void showSceneGraphDialog();
581 virtual void setView(
const GLMatrixd& _modelview,
584 void actionBackground();
585 void actionCopyView();
586 void actionPasteView();
587 void actionPasteDropSize();
588 void actionSynchronize();
589 void actionAnimation();
590 void actionBackfaceCulling();
591 void actionTwoSidedLighting();
592 void actionSynchronize(
bool _enable);
593 void actionAnimation(
bool _enable);
594 void actionBackfaceCulling(
bool _enable);
595 void actionTwoSidedLighting(
bool _enable);
597 void actionDrawMenu( QAction * _action );
598 void actionPickMenu( QAction * _action );
607 void signalInitializeGL();
619 void signalMouseEvent(QMouseEvent*,
const std::string&);
622 void signalMouseEvent(QMouseEvent*);
625 void signalWheelEvent(QWheelEvent*,
const std::string&);
630 void signalMouseEventIdentify( QMouseEvent* );
634 void signalSetView(
const GLMatrixd& _modelview,
652 void signalCustomContextMenuRequested (
const QPoint & );
662 virtual void initializeGL();
664 virtual void paintGL();
666 virtual void resizeGL(
int _w,
int _h);
670 virtual void glMousePressEvent(QMouseEvent* _event);
672 virtual void glMouseDoubleClickEvent(QMouseEvent* _event);
674 virtual void glMouseMoveEvent(QMouseEvent* _event);
676 virtual void glMouseReleaseEvent(QMouseEvent* _event);
678 virtual void glMouseWheelEvent(QWheelEvent* _event);
680 virtual void glContextMenuEvent(QContextMenuEvent* _event);
684 virtual void viewMouseEvent( QMouseEvent* _event) = 0;
686 virtual void viewWheelEvent(QWheelEvent* _event) = 0;
696 void updateProjectionMatrix();
698 void updatePickMenu();
706 virtual void sceneRectChanged(
const QRectF & rect);
709 virtual void slotWheelX(
double _dAngle);
711 virtual void slotWheelY(
double _dAngle);
713 virtual void slotWheelZ(
double _dist);
720 { removeEventFilter( sender());}
727 void hidePopupMenus();
753 void createWidgets(
const QGLFormat* _format,QStatusBar* _sb,
760 void drawScene_mono();
762 void drawScene_stereo();
768 void updatePopupMenu();
775 Vec3d scene_center_, trackball_center_;
776 double scene_radius_, trackball_radius_;
780 GLdouble orthoWidth_;
781 GLdouble near_, far_, fovy_;
793 QStatusBar* statusbar_;
805 home_inverse_modelview_;
806 double homeOrthoWidth_;
820 bool backFaceCulling_;
821 bool twoSidedLighting_;
842 bool projectionUpdateLocked_;
854 QGLWidget* glWidget_;
861 QGraphicsWidget* glBase_;
863 QGraphicsGridLayout* glBaseLayout_;
866 QStatusBar* privateStatusBar_;
869 QGridLayout* glLayout_;
872 QToolBar * buttonBar_;
875 QToolButton* pickButton_;
877 QToolButton* moveButton_;
879 QToolButton* lightButton_;
881 QToolButton* questionButton_;
883 QToolButton* projectionButton_;
885 QToolButton* homeButton_;
887 QToolButton* setHomeButton_;
889 QToolButton* viewAllButton_;
891 QToolButton* sceneGraphButton_;
893 QToolButton* stereoButton_;
903 QMap< QString, QAction * > action_;
906 std::vector< QAction * > drawMenuActions_;
932 virtual void toggleStereoMode();
935 virtual void setStereoMode(
bool _b);
942 void setEyeDistance(
double _distance);
945 double eyeDistance( );
951 void setFocalDistance(
double _distance);
954 double focalDistance( );
977 void signalKeyPressEvent(QKeyEvent*);
985 void disableKeyHandling(
bool _state );
990 bool keyHandlingState();
998 virtual void glKeyPressEvent(QKeyEvent*);
1006 virtual void glKeyReleaseEvent(QKeyEvent* _event);
1015 virtual bool viewKeyPressEvent(QKeyEvent* _event) = 0;
1030 virtual void startDrag();
1032 virtual void glDragEnterEvent(QDragEnterEvent* _event);
1034 virtual void glDropEvent(QDropEvent* _event);
1044 void startDragEvent( QMouseEvent* _event );
1049 void dragEnterEvent(QDragEnterEvent* _event);
1054 void dropEvent( QDropEvent* _event );
1082 virtual void setSynchronization(
bool _b);
1085 bool add_sync_host(
const QString& _name);
1087 void add_sync_host(QHostAddress& _adr);
1089 bool synchronization();
1093 void sync_receive();
1094 void sync_send(
const GLMatrixd& _modelview,
1129 virtual void snapshotBaseFileName(
const QString& _fname);
1135 virtual void snapshot();
1139 void actionSnapshot();
1143 void actionSnapshotName();
1147 void actionSnapshotSavesView();
1176 const QPoint& _mousePos,
1177 unsigned int& _nodeIdx,
1178 unsigned int& _targetIdx,
1179 Vec3d* _hitPointPtr=0 );
1186 bool fast_pick(
const QPoint& _mousePos,
1197 void addPickMode(
const std::string& _name,
1198 bool _mouse_tracking =
false,
1200 bool _visible =
true,
1201 QCursor _cursor = Qt::ArrowCursor );
1205 void clearPickModes();
1209 const std::string& pickMode()
const;
1214 void pickMode(
const std::string& _name);
1219 void pickMode(
int _id );
1232 virtual void pickingMode();
1239 void setPickModeCursor(
const std::string& _name, QCursor _cursor);
1246 void setPickModeMouseTracking(
const std::string& _name,
bool _mouseTracking);
1251 void signalPickModeChanged(
const std::string&);
1260 PickMode(
const std::string& _n,
bool _t,
bool _v, QCursor _c) :
1261 name(_n), tracking(_t), visible(_v), cursor(_c) {}
1310 #endif // ACG_QTBASEVIEWER_HH defined
PickMode(const std::string &_n, bool _t, bool _v, QCursor _c)
Constructor.
ProjectionMode
projection mode
virtual void flyFrom(const QPoint &_pos)
Fly to, get more distant.
FaceOrientation
orientation of the faces
Namespace providing different geometric functions concerning angles.
virtual void lightMouseEvent(QMouseEvent *)
optional: hande mouse events to rotate light
GLState & glState()
get OpenGL state
std::vector< PickMode > pick_modes_
std::vector< QHostAddress > sync_hosts_
List of hosts which should receive sync information.
bool synchronized_
synchronized with different viewer?
bool isUpdateLocked() const
virtual void cleanupEventFilter()
correct ??? (same function as in qt src)
NavigationMode
Navigation mode.
QStatusBar * statusBar()
get status bar, guaranteed to be not 0 (QStatusBar may be invisible)
void rotate(const Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
NormalsMode
Automatically normalize normals?
NormalsMode normalsMode() const
get treatment of normals
NavigationMode navigationMode() const
get current navigation mode
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
void setExternalDrag(bool _external)
Enable or disable external dragging controls.
void lockProjectionUpdate(void)
Lock update of projection matrix.
bool stereo_
Set eye distance for stereo.
bool backFaceCulling() const
is backface culling enabled?
double focalDist_
Set eye distance for stereo.
virtual void questionMode()
calls actionMode() with QuestionMode (cf. ActionMode)
QMenu * getPickMenu()
Get the menu pointers (required to add them to the menubar as a temp workaround for a qt 4...
virtual void lightMode()
calls actionMode() with LightMode (cf. ActionMode)
use provided normals as is
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
const ACG::Vec3d & scene_center() const
int options() const
get current ORed Options
virtual void examineMode()
calls actionMode() with ExamineMode (cf. ActionMode)
ActionMode
How to react on mouse events?
FaceOrientation faceOrientation() const
get face orientation
counter clockwise (default)
QUdpSocket * socket_
socket used for synchronization
ProjectionMode projectionMode() const
get current projection mode
const SceneGraph::BaseNode * sceneGraph() const
same but const
ACG::SceneGraph::DrawModes::DrawMode drawMode()
get current draw mode
std::string pick_mode_name_
bool skipNextSync_
Skips the next synch event.
PickTarget
What target to use for picking.
bool animation() const
Is animation enabled?
ACG::SceneGraph::PickTarget pickRendererMode_
void unlockProjectionUpdate(void)
Unlock update of projection matrix.
ActionMode actionMode() const
get action mode
void drawBlendedObjects(bool _status)
One or two pass Drawing.
ActionMode lastActionMode()
Return the last action mode.
double scene_radius() const
bool disableKeyHandling_
Enable or disable internal Key handling.
virtual void flyTo(const QPoint &_pos)
Fly to, get closer.
GLMatrixd & light_matrix()
get light rotation matrix
SceneGraph::BaseNode * sceneGraph()
Returns: root node of scene graph.
bool twoSidedLighting() const
is 2-sided lighing enabled?