Radium Engine  1.5.0
GizmoManager.hpp
1 #pragma once
2 
3 #include <memory>
4 
5 #include <Gui/TransformEditor/TransformEditor.hpp>
6 #include <Gui/Utils/KeyMappingManager.hpp>
7 #include <Gui/Viewer/Gizmo/Gizmo.hpp>
8 #include <QMouseEvent>
9 #include <QObject>
10 
11 namespace Ra {
12 namespace Engine {
13 namespace Scene {
14 struct ItemEntry;
15 } // namespace Scene
16 } // namespace Engine
17 } // namespace Ra
18 namespace Ra {
19 namespace Gui {
23 class RA_GUI_API GizmoManager : public QObject,
24  public Gui::TransformEditor,
25  public KeyMappingManageable<GizmoManager>
26 {
27  Q_OBJECT
28  friend class KeyMappingManageable<GizmoManager>;
29 
30  public:
31  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
32 
33  enum GizmoType { NONE, TRANSLATION, ROTATION, SCALE };
34 
35  explicit GizmoManager( QObject* parent = nullptr );
36  ~GizmoManager() = default;
37 
38  public:
40  virtual bool handleMousePressEvent( QMouseEvent* event,
41  const Qt::MouseButtons& buttons,
42  const Qt::KeyboardModifiers& modifiers,
43  int key,
44  const Core::Asset::Camera& cam );
45  virtual bool handleMouseReleaseEvent( QMouseEvent* event );
46  virtual bool handleMouseMoveEvent( QMouseEvent* event,
47  const Qt::MouseButtons& buttons,
48  const Qt::KeyboardModifiers& modifiers,
49  int key,
50  const Core::Asset::Camera& cam );
51 
52  public slots:
54  void setEditable( const Engine::Scene::ItemEntry& ent ) override;
55 
57  void cleanup();
58 
60  void handlePickingResult( int drawableId );
61 
63  void setLocal( bool useLocal );
64 
66  void changeGizmoType( GizmoType type );
67 
69  void updateValues() override;
70 
71  private:
72  bool isValidAction( const Gui::KeyMappingManager::KeyMappingAction& action ) const;
73 
74  // Helper method to change the current gizmo
75  void updateGizmo();
76 
77  // Returs the current gizmo
78  Gizmo* currentGizmo();
79 
80  private:
81  std::array<std::unique_ptr<Gizmo>, 3> m_gizmos;
82  GizmoType m_currentGizmoType;
83  Gizmo::Mode m_mode;
84 
85  static void configureKeyMapping_impl();
86 
87 #define KeyMappingGizmo \
88  KMA_VALUE( GIZMOMANAGER_MANIPULATION ) \
89  KMA_VALUE( GIZMOMANAGER_STEP ) \
90  KMA_VALUE( GIZMOMANAGER_WHOLE ) \
91  KMA_VALUE( GIZMOMANAGER_STEP_WHOLE )
92 
93 #define KMA_VALUE( XX ) static KeyMappingManager::KeyMappingAction XX;
94  KeyMappingGizmo
95 #undef KMA_VALUE
96 };
97 } // namespace Gui
98 } // namespace Ra
Camera class storing the Camera frame and the projection properties The view direction is -z in camer...
Definition: Camera.hpp:16
KeyMappingManageable decorator to use as CRTP.
Ra::Core::Utils::Index KeyMappingAction
handle to an action
Definition: Cage.cpp:3