00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GUI_GL_CANVAS_HH
00020 #define OST_GUI_GL_CANVAS_HH
00021
00022
00023
00024 #include <ost/gui/tools/tool.hh>
00025 #include <ost/gui/scene_menu.hh>
00026 #include <ost/gfx/glwin_base.hh>
00027 #include <ost/gfx/input.hh>
00028 #include <ost/gfx/gfx_object_fw.hh>
00029
00030
00031
00032 #include <QGLWidget>
00033 #include <QBasicTimer>
00034 class QMenu;
00035 class QMouseEvent;
00036
00037 namespace ost { namespace gui {
00038
00039 class GLCanvas;
00040
00041 class GLWin;
00042
00043 class DLLEXPORT_OST_GUI GLCanvas : public QGLWidget, public gfx::GLWinBase
00044 {
00045 Q_OBJECT;
00046 public:
00047 GLCanvas(GLWin *gl_win, QWidget* parent,
00048 const QGLFormat& f = QGLFormat::defaultFormat());
00049
00050
00051 virtual void MakeActive();
00052 virtual void DoRefresh();
00053 virtual void StatusMessage(const String& m);
00054 virtual bool HasStereo() const {return format().stereo();};
00055 virtual bool HasMultisample() const {return format().sampleBuffers();}
00056
00057
00058 void OnTransform(gfx::InputCommand, int indx,
00059 gfx::TransformTarget, Real val);
00060
00061 void SetTestMode(bool f);
00062
00063 signals:
00064 void ReleaseFocus();
00065
00066 protected:
00067 void Select(const String& query);
00068 void CopySelectionToClipboard();
00069
00070 virtual void initializeGL();
00071 virtual void resizeGL(int w, int h);
00072 virtual void paintGL();
00073
00074 virtual void mouseMoveEvent(QMouseEvent* event);
00075 virtual void mousePressEvent(QMouseEvent* event);
00076 virtual void mouseReleaseEvent(QMouseEvent* event);
00077 virtual void mouseDoubleClickEvent(QMouseEvent* event);
00078
00079 virtual void keyPressEvent(QKeyEvent* event);
00080 virtual void keyReleaseEvent(QKeyEvent* event);
00081 virtual void timerEvent(QTimerEvent * event);
00082 virtual void wheelEvent(QWheelEvent* event);
00083 virtual bool event(QEvent* event);
00084 private slots:
00085 virtual void RequestContextMenu(const QPoint& pos);
00086
00087 private:
00088 #if QT_VERSION >= 0x040600
00089 bool GestureEvent(QGestureEvent* event);
00090 #endif
00091 bool IsToolEvent(QInputEvent* event) const;
00092 MouseEvent::Buttons TranslateButtons(Qt::MouseButtons buttons) const;
00093 void HandleMousePressEvent(QMouseEvent* event);
00094 void HandleMouseReleaseEvent(QMouseEvent* event);
00095 void HandleMouseMoveEvent(QMouseEvent* event);
00096 void build_context_menu();
00097 void prepare_context_menu(const QPoint& pos);
00098 GLWin* glwin_;
00099 int mouse_key_mask_;
00100 bool refresh_;
00101 QBasicTimer master_timer_;
00102 bool bench_flag_;
00103 QPoint last_pos_;
00104 SceneMenu* scene_menu_;
00105 bool show_beacon_;
00106 float angular_speed_;
00107 #if QT_VERSION>=0x04600
00108 QBasicTimer gesture_timer_;
00109 #endif
00110 };
00111
00112 }}
00113
00114 #endif