CameraInputHandler.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Visualization
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2014, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeVisualization/Base.h"
16 #include "CeeCore/RefCountedObject.h"
17 #include "CeeVisualization/MouseEvent.h"
18 #include "CeeVisualization/WheelEvent.h"
19 
20 namespace cee {
21 class Vec3d;
22 
23 namespace vis {
24 class Camera;
25 
26 //==================================================================================================
27 //
28 // Base class for CameraInputHandler
29 //
30 //==================================================================================================
31 class CEE_VIS_EXPORT CameraInputHandler : public RefCountedObject
32 {
33 public:
36  {
37  NONE,
38  PAN,
39  WALK,
40  ZOOM,
42  ROLL
43  };
44 
45 public:
47  virtual ~CameraInputHandler();
48 
49  virtual void mousePressEvent(MouseButton buttonPressed, const MouseEvent& mouseEvent);
50  virtual bool mouseMoveEvent(const MouseEvent& mouseEvent);
51  virtual void mouseReleaseEvent(MouseButton buttonReleased, const MouseEvent& mouseEvent);
52  virtual void wheelEvent(const WheelEvent& theWheelEvent);
53  virtual void wheelEvent(const WheelEvent& theWheelEvent, const cee::Vec3d& position);
54 
55  Vec3d rotationPoint() const;
56  virtual void setRotationPoint(const Vec3d& rotationPoint);
57  double rotationSensitivity() const;
58  void setRotationSensitivity(double sensitivity);
59  double rollSensitivity() const;
60  void setRollSensitivity(double sensitivity);
61  double walkSensitivity() const;
62  void setWalkSensitivity(double sensitivity);
63 
64  NavigationType activeNavigation() const;
65  void startNavigation(NavigationType navigationType, int x, int y);
66  bool updateNavigation(int x, int y);
67  void endNavigation();
68 
69  virtual NavigationType navigationTypeFromInputState(MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers) const = 0;
70  virtual bool reverseZoom() const;
71 
72 protected:
73  virtual NavigationType wheelNavigationType() const;
74 
75  Camera* camera();
76  void setMinimumWalkTargetDistance(double distance);
77 
78 private:
79  CEE_BASE_F(Camera);
80  CEE_PRIVATE_IMPL(CameraInputHandler);
81  CEE_DISALLOW_COPY_AND_ASSIGN(CameraInputHandler);
82 };
83 
84 
85 
86 //==================================================================================================
87 //
88 // Standard Ceetron style Zoom navigation
89 //
90 //==================================================================================================
91 class CEE_VIS_EXPORT CameraInputHandlerZoom : public CameraInputHandler
92 {
93 public:
94  CameraInputHandlerZoom(bool updateEyePositionOnSetRotationPoint = true);
95 
96  virtual void wheelEvent(const WheelEvent& theWheelEvent);
97  virtual void wheelEvent(const WheelEvent& theWheelEvent, const cee::Vec3d& pos);
98  virtual void setRotationPoint(const Vec3d& rotationPoint);
99 
100 protected:
101  virtual NavigationType navigationTypeFromInputState(MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers) const;
102  virtual NavigationType wheelNavigationType() const;
103 
104 private:
105  bool m_updateEyeOnNewRotationPoint;
106 };
107 
108 
109 
110 //==================================================================================================
111 //
112 // Standard Ceetron style Walk navigation
113 //
114 //==================================================================================================
115 class CEE_VIS_EXPORT CameraInputHandlerWalk : public CameraInputHandler
116 {
117 public:
119 
120  virtual void wheelEvent(const WheelEvent& theWheelEvent);
121  virtual void wheelEvent(const WheelEvent& theWheelEvent, const cee::Vec3d& pos);
122 
123  void setMinimumTargetDistance(double minDistance);
124 
125 protected:
126  virtual NavigationType navigationTypeFromInputState(MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers) const;
127  virtual NavigationType wheelNavigationType() const;
128 };
129 
130 } // namespace vis
131 } // namespace cee
No navigation.
Definition: CameraInputHandler.h:37
Mouse wheel event.
Definition: WheelEvent.h:27
Camera input handler implementing standard Ceetron style Zoom navigation.
Definition: CameraInputHandler.h:91
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
The camera configuration of a view.
Definition: Camera.h:33
Class for manipulating a camera from input events (typically mouse interaction).
Definition: CameraInputHandler.h:31
Pan. Move the model in the screen plane.
Definition: CameraInputHandler.h:38
Walk. Move the camera position (eye) forward or backward in the view direction.
Definition: CameraInputHandler.h:39
Mouse event.
Definition: MouseEvent.h:47
NavigationType
Navigation types.
Definition: CameraInputHandler.h:35
Base class for all reference counted objects with built-in support for intrusive reference counting...
Definition: RefCountedObject.h:34
Camera input handler implementing standard Ceetron style Walk navigation.
Definition: CameraInputHandler.h:115
int MouseButtons
Mouse button state. The button state is a combination of LeftButton, RightButton and MiddleButton usi...
Definition: MouseEvent.h:29
Rotate the model around the current rotation point.
Definition: CameraInputHandler.h:41
Vector class for a 3D double vector.
Definition: Vec3d.h:26
Adjust the Field of view (perspective projection) or frustum height (orthographic projection) to resi...
Definition: CameraInputHandler.h:40
MouseButton
List of mouse buttons states.
Definition: MouseEvent.h:21
int KeyboardModifiers
Keyboard modifier state. The modifier state is a combination of ShiftModifier and ControlModifier usi...
Definition: MouseEvent.h:39