Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.6.3
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotateAroundCameraManipulator.hpp
1#pragma once
2
3#include <Core/CoreMacros.hpp>
4#include <Core/Types.hpp>
5#include <Gui/RaGui.hpp>
6#include <Gui/Utils/KeyMappingManager.hpp>
7#include <Gui/Viewer/TrackballCameraManipulator.hpp>
8
9class QEvent;
10class QKeyEvent;
11class QMouseEvent;
12
13namespace Ra {
14namespace Gui {
15class CameraManipulator;
16
17class Viewer;
18
19class RA_GUI_API RotateAroundCameraManipulator
21 public Ra::Gui::KeyMappingManageable<RotateAroundCameraManipulator>
22{
23 friend class Ra::Gui::KeyMappingManageable<RotateAroundCameraManipulator>;
24
25 public:
26 using KeyMapping = KeyMappingManageable<RotateAroundCameraManipulator>;
27 explicit RotateAroundCameraManipulator( Ra::Gui::Viewer* viewer );
28 explicit RotateAroundCameraManipulator( const CameraManipulator& cm, Ra::Gui::Viewer* viewer );
29
31 bool handleMouseMoveEvent( QMouseEvent* event,
32 const Qt::MouseButtons& buttons,
33 const Qt::KeyboardModifiers& modifiers,
34 int key ) override;
36 bool handleKeyPressEvent( QKeyEvent* event,
37 const Ra::Gui::KeyMappingManager::KeyMappingAction& action ) override;
38
39 void setPivot( Ra::Core::Vector3 pivot );
41 void setPivotFromPixel( Scalar x, Scalar y );
42
45 void alignOnClosestAxis();
46
47 KeyMappingManager::Context mappingContext() override;
48
49 public slots:
50 void fitScene( const Core::Aabb& aabb ) override;
51
52 protected:
53 virtual void handleCameraRotate( Scalar dx, Scalar dy ) override;
54 virtual void handleCameraForward( Scalar z );
55 virtual void handleCameraPan( Scalar dx, Scalar dy ) override;
56
59 Ra::Core::Quaternion deformedBallQuaternion( Scalar x, Scalar y, Scalar cx, Scalar cy );
60 Scalar projectOnBall( Scalar x, Scalar y );
61
62 private:
63 void setupKeyMappingCallbacks();
64 void alignWithClosestAxisCallback( QEvent* event );
65 void moveForwardCallback( QEvent* event );
66 void panCallback( QEvent* event );
67 void rotateCallback( QEvent* event );
68 void setPivotCallback( QEvent* event );
69 void zoomCallback( QEvent* event );
70
71 KeyMappingCallbackManager m_keyMappingCallbackManager;
72 Ra::Gui::Viewer* m_viewer;
73
74 Ra::Core::Vector3 m_pivot { 0.0_ra, 0.0_ra, 0.0_ra };
75
76 static void configureKeyMapping_impl();
77
78#define KeyMappingRotateAroundCamera \
79 KMA_VALUE( ROTATEAROUND_ALIGN_WITH_CLOSEST_AXIS ) \
80 KMA_VALUE( ROTATEAROUND_SET_PIVOT )
81
82#define KMA_VALUE( XX ) static KeyMappingManager::KeyMappingAction XX;
83 KeyMappingRotateAroundCamera
84#undef KMA_VALUE
85};
86
87} // namespace Gui
88} // 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:4