Radium Engine  1.5.20
Loading...
Searching...
No Matches
RotateAroundCameraManipulator.hpp
1#pragma once
2
3#include <Gui/Viewer/TrackballCameraManipulator.hpp>
4
5namespace Ra {
6namespace Gui {
7class Viewer;
8
9class RA_GUI_API RotateAroundCameraManipulator
11 public Ra::Gui::KeyMappingManageable<RotateAroundCameraManipulator>
12{
13 friend class Ra::Gui::KeyMappingManageable<RotateAroundCameraManipulator>;
14
15 public:
16 using KeyMapping = KeyMappingManageable<RotateAroundCameraManipulator>;
17 explicit RotateAroundCameraManipulator( Ra::Gui::Viewer* viewer );
18 explicit RotateAroundCameraManipulator( const CameraManipulator& cm, Ra::Gui::Viewer* viewer );
19
21 bool handleMouseMoveEvent( QMouseEvent* event,
22 const Qt::MouseButtons& buttons,
23 const Qt::KeyboardModifiers& modifiers,
24 int key ) override;
26 bool handleKeyPressEvent( QKeyEvent* event,
27 const Ra::Gui::KeyMappingManager::KeyMappingAction& action ) override;
28
29 void setPivot( Ra::Core::Vector3 pivot );
31 void setPivotFromPixel( Scalar x, Scalar y );
32
35 void alignOnClosestAxis();
36
37 KeyMappingManager::Context mappingContext() override;
38
39 public slots:
40 void fitScene( const Core::Aabb& aabb ) override;
41
42 protected:
43 virtual void handleCameraRotate( Scalar dx, Scalar dy ) override;
44 virtual void handleCameraForward( Scalar z );
45 virtual void handleCameraPan( Scalar dx, Scalar dy ) override;
46
49 Ra::Core::Quaternion deformedBallQuaternion( Scalar x, Scalar y, Scalar cx, Scalar cy );
50 Scalar projectOnBall( Scalar x, Scalar y );
51
52 private:
53 void setupKeyMappingCallbacks();
54 void alignWithClosestAxisCallback( QEvent* event );
55 void moveForwardCallback( QEvent* event );
56 void panCallback( QEvent* event );
57 void rotateCallback( QEvent* event );
58 void setPivotCallback( QEvent* event );
59 void zoomCallback( QEvent* event );
60
61 KeyMappingCallbackManager m_keyMappingCallbackManager;
62 Ra::Gui::Viewer* m_viewer;
63
64 Ra::Core::Vector3 m_pivot { 0.0_ra, 0.0_ra, 0.0_ra };
65
66 static void configureKeyMapping_impl();
67
68#define KeyMappingRotateAroundCamera \
69 KMA_VALUE( ROTATEAROUND_ALIGN_WITH_CLOSEST_AXIS ) \
70 KMA_VALUE( ROTATEAROUND_SET_PIVOT )
71
72#define KMA_VALUE( XX ) static KeyMappingManager::KeyMappingAction XX;
73 KeyMappingRotateAroundCamera
74#undef KMA_VALUE
75};
76
77} // namespace Gui
78} // namespace Ra
KeyMappingManageable decorator to use as CRTP.
Ra::Core::Utils::Index KeyMappingAction
handle to an action
A Trackball manipulator for Cameras.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3