OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gl_canvas.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GUI_GL_CANVAS_HH
20 #define OST_GUI_GL_CANVAS_HH
21 
22 
23 
24 #include <ost/gui/tools/tool.hh>
25 #include <ost/gui/scene_menu.hh>
26 #include <ost/gfx/glwin_base.hh>
27 #include <ost/gfx/input.hh>
28 #include <ost/gfx/gfx_object_fw.hh>
29 
30 
31 // Qt includes must come last
32 #include <QGLWidget>
33 #include <QBasicTimer>
34 class QMenu;
35 class QMouseEvent;
36 
37 namespace ost { namespace gui {
38 
39 class GLCanvas;
40 
41 class GLWin;
42 
43 class DLLEXPORT_OST_GUI GLCanvas : public QGLWidget, public gfx::GLWinBase
44 {
45  Q_OBJECT;
46 public:
47  GLCanvas(GLWin *gl_win, QWidget* parent,
48  const QGLFormat& f = QGLFormat::defaultFormat());
49 
50  // gfx::GLWinBase interface
51  virtual void MakeActive();
52  virtual void DoRefresh();
53  virtual void StatusMessage(const String& m);
54  virtual bool HasStereo() const {return format().stereo();};
55  virtual bool HasMultisample() const {return format().sampleBuffers();}
56 
57  // central point for sending input to the gfx layer
58  void OnTransform(gfx::InputCommand, int indx,
60 
61  void SetTestMode(bool f);
62 
63 signals:
64  void ReleaseFocus();
65 
66 protected:
67  void Select(const String& query);
68  void CopySelectionToClipboard();
69  // QGLWidget interface
70  virtual void initializeGL();
71  virtual void resizeGL(int w, int h);
72  virtual void paintGL();
73 
74  virtual void mouseMoveEvent(QMouseEvent* event);
75  virtual void mousePressEvent(QMouseEvent* event);
76  virtual void mouseReleaseEvent(QMouseEvent* event);
77  virtual void mouseDoubleClickEvent(QMouseEvent* event);
78 
79  virtual void keyPressEvent(QKeyEvent* event);
80  virtual void keyReleaseEvent(QKeyEvent* event);
81  virtual void timerEvent(QTimerEvent * event);
82  virtual void wheelEvent(QWheelEvent* event);
83  virtual bool event(QEvent* event);
84 private slots:
85  virtual void RequestContextMenu(const QPoint& pos);
86 
87 private:
88 #if QT_VERSION >= 0x040600
89  bool GestureEvent(QGestureEvent* event);
90 #endif
91  bool IsToolEvent(QInputEvent* event) const;
92  MouseEvent::Buttons TranslateButtons(Qt::MouseButtons buttons) const;
93  void HandleMousePressEvent(QMouseEvent* event);
94  void HandleMouseReleaseEvent(QMouseEvent* event);
95  void HandleMouseMoveEvent(QMouseEvent* event);
96  void build_context_menu();
97  void prepare_context_menu(const QPoint& pos);
98  GLWin* glwin_;
99  int mouse_key_mask_;
100  bool refresh_;
101  QBasicTimer master_timer_;
102  bool bench_flag_;
103  QPoint last_pos_;
104  SceneMenu* scene_menu_;
105  bool show_beacon_;
106  float angular_speed_;
107 #if QT_VERSION>=0x04600
108  QBasicTimer gesture_timer_;
109 #endif
110 };
111 
112 }} // ns
113 
114 #endif
virtual bool HasMultisample() const
Definition: gl_canvas.hh:55
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
#define DLLEXPORT_OST_GUI
TransformTarget
Definition: input.hh:57
virtual bool HasStereo() const
Definition: gl_canvas.hh:54
InputCommand
Definition: input.hh:39