Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
view_handler_horizontal.hpp
1 // Copyright [2015] Albert Huang
2 
3 #ifndef SCENEVIEW_VIEW_HANDLER_HORIZONTAL__
4 #define SCENEVIEW_VIEW_HANDLER_HORIZONTAL__
5 
6 #include <QVector3D>
7 
8 #include <sceneview/input_handler.hpp>
9 
10 class QComboBox;
11 class QMouseEvent;
12 class QTimer;
13 
14 namespace sv {
15 
16 class CameraNode;
17 class DrawNode;
18 class Viewport;
19 
54 class ViewHandlerHorizontal : public QObject, public InputHandler {
55  Q_OBJECT
56 
57  public:
66  const QVector3D& zenith_dir,
67  QObject* parent = nullptr);
68 
69  virtual ~ViewHandlerHorizontal() {}
70 
74  QString Name() const { return "Camera controls"; }
75 
79  void SetZenithDir(const QVector3D& dir);
80 
84  const QVector3D& ZenithDir() const { return zenith_dir_; }
85 
89  void MousePressEvent(QMouseEvent *event) override;
90 
94  void MouseMoveEvent(QMouseEvent *event) override;
95 
99  void WheelEvent(QWheelEvent* event) override;
100 
104  void KeyPressEvent(QKeyEvent* event) override;
105 
110  QWidget* GetWidget() override;
111 
119  void SetShowLookAtPoint(bool val);
120 
126  void SetAllowAzimuthElevationControl(bool val);
127 
128  private slots:
129  void OnProjectionSelectionChanged();
130 
131  private:
132  CameraNode* camera_;
133 
134  Viewport* viewport_;
135 
136  void MakeShape();
137 
138  void UpdateShapeTransform();
139 
140  void UpdateNearFarPlanes();
141 
142  double PivotDistance() const;
143 
144  double mouse_speed_;
145  QVector3D zenith_dir_;
146 
147  int first_mouse_x_;
148  int first_mouse_y_;
149 
150  double movement_scale_;
151  QVector3D eye_start_;
152  QVector3D look_start_;
153  QVector3D up_start_;
154 
155  bool show_look_at_point_;
156  DrawNode* look_at_shape_;
157  QTimer* hide_shape_timer_;
158 
159  bool allow_azimuth_elevation_control_;
160 
161  // Input handler widget
162  QWidget* widget_;
163  QComboBox* projection_combo_;
164 };
165 
166 } // namespace sv
167 
168 #endif // SCENEVIEW_VIEW_HANDLER_HORIZONTAL__
A view handler that has a notion of a fundamental plane (e.g., a ground plane) and a zenith direction...
Definition: view_handler_horizontal.hpp:54
void WheelEvent(QWheelEvent *event) override
Handles a mouse wheel event.
Scene node that contains a list of drawable objects.
Definition: draw_node.hpp:26
void KeyPressEvent(QKeyEvent *event) override
Handles a key press event.
Camera.
Definition: camera_node.hpp:25
const QVector3D & ZenithDir() const
Retrieve the zenith direction.
Definition: view_handler_horizontal.hpp:84
QWidget * GetWidget() override
Retrieve the widget for the input handler.
void SetZenithDir(const QVector3D &dir)
Sets the zenith direction.
Receive and handle mouse/keyboard input events.
Definition: input_handler.hpp:26
Widget that draws a scene and manages Renderer and InputHandler objects.
Definition: viewport.hpp:27
void SetAllowAzimuthElevationControl(bool val)
Enables / disables azimuth and elevation control.
ViewHandlerHorizontal(Viewport *viewport, const QVector3D &zenith_dir, QObject *parent=nullptr)
Constructor.
void SetShowLookAtPoint(bool val)
Set whether or not the look at point is shown in the scene during a mouse or key event.
void MousePressEvent(QMouseEvent *event) override
Handles a mouse press event.
QString Name() const
Retrieve the name of this view handler.
Definition: view_handler_horizontal.hpp:74
void MouseMoveEvent(QMouseEvent *event) override
Handles a mouse movement event.