Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
qtfreecamerawidget.hpp
Go to the documentation of this file.
1 
23 #ifndef __QTFREECAMERAWIDGET__
24 #define __QTFREECAMERAWIDGET__
25 
27 #include "utils/freecamera.hpp"
28 
29 namespace Tucano
30 {
31 
38 {
39 
40 public:
41 
42  explicit QtFreecameraWidget(QWidget *parent) : QtFlycameraWidget(parent)
43  {
44  camera = new Freecamera();
45  }
46 
47  void mousePressEvent (QMouseEvent * event) override
48  {
49  setFocus ();
50  Eigen::Vector2f screen_pos (event->x(), event->y());
51  if (event->button() == Qt::LeftButton)
52  {
53  camera->startRotation(screen_pos);
55  }
56  if (event->button() == Qt::MiddleButton)
57  {
58  camera->startRotation(screen_pos);
60  }
61  if (event->button() == Qt::RightButton)
62  {
63  light_trackball.rotateCamera(screen_pos);
64  }
65  updateGL ();
66  }
67 
68  void mouseMoveEvent (QMouseEvent * event) override
69  {
70  Eigen::Vector2f screen_pos (event->x(), event->y());
71  if (event->buttons() & Qt::LeftButton)
72  {
73  camera->rotate(screen_pos);
75  }
76  if(event->buttons() & Qt::MiddleButton)
77  {
78  camera->rotateZ(screen_pos);
80  }
81  if (event->buttons() & Qt::RightButton)
82  {
83  light_trackball.rotateCamera(screen_pos);
84  }
85 
86  updateGL ();
87 
88  }
89 
96  virtual void mouseReleaseEvent (QMouseEvent * event)
97  {
98  if (event->button() == Qt::RightButton)
99  {
101  }
102 
103  updateGL ();
104  }
105 };
106 
107 }
108 #endif
virtual Eigen::Quaternion< float > rotateCamera(const Eigen::Vector2f &pos)
Computes and applies the rotation transformations to the trackball given new position.
Definition: trackball.hpp:455
Definition: bufferobject.hpp:34
void mousePressEvent(QMouseEvent *event) override
Definition: qtfreecamerawidget.hpp:47
virtual void rotate(Eigen::Vector2f new_mouse_pos)
Rotates the camera view direction.
Definition: flycamera.hpp:269
virtual void mouseReleaseEvent(QMouseEvent *event)
Callback for mouse release event.
Definition: qtfreecamerawidget.hpp:96
A widget with a trackball iteration for a single mesh and a single light source. Extends QGLWidget cl...
Definition: qtflycamerawidget.hpp:66
A widget with a free camera. Extends QGLWidget class to include common methods for using Tucano this ...
Definition: qtfreecamerawidget.hpp:37
QtFreecameraWidget(QWidget *parent)
Definition: qtfreecamerawidget.hpp:42
virtual void endRotation(void)
Indicates that a rotation has ended. Disables the rotating flag, indicating that the mouse callback f...
Definition: trackball.hpp:279
Free camera class for manipulating a camera.
Definition: freecamera.hpp:38
virtual void rotateZ(Eigen::Vector2f new_mouse_pos)
Rotates the camera view direction around Z axis. Default implementation does nothing.
Definition: flycamera.hpp:297
void startRotation(Eigen::Vector2f pos)
Begin view direction rotation.
Definition: flycamera.hpp:260
Trackball light_trackball
Trackball for manipulating the light position.
Definition: qtflycamerawidget.hpp:79
virtual void updateViewMatrix()
Compose rotation and translation.
Definition: flycamera.hpp:166
void mouseMoveEvent(QMouseEvent *event) override
Definition: qtfreecamerawidget.hpp:68
Flycamera * camera
Flycamera.
Definition: qtflycamerawidget.hpp:76