Radium Engine  1.5.20
Loading...
Searching...
No Matches
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
11namespace Ra {
12namespace Engine {
13namespace Scene {
14struct ItemEntry;
15} // namespace Scene
16} // namespace Engine
17} // namespace Ra
18namespace Ra {
19namespace Gui {
23class RA_GUI_API GizmoManager : public QObject,
24 public Gui::TransformEditor,
25 public KeyMappingManageable<GizmoManager>
26{
27 Q_OBJECT
29
30 public:
31 enum GizmoType { NONE, TRANSLATION, ROTATION, SCALE };
32
33 explicit GizmoManager( QObject* parent = nullptr );
34 ~GizmoManager() = default;
35
36 public:
38 virtual bool handleMousePressEvent( QMouseEvent* event,
39 const Qt::MouseButtons& buttons,
40 const Qt::KeyboardModifiers& modifiers,
41 int key,
42 const Core::Asset::Camera& cam );
43 virtual bool handleMouseReleaseEvent( QMouseEvent* event );
44 virtual bool handleMouseMoveEvent( QMouseEvent* event,
45 const Qt::MouseButtons& buttons,
46 const Qt::KeyboardModifiers& modifiers,
47 int key,
48 const Core::Asset::Camera& cam );
49
50 public slots:
52 void setEditable( const Engine::Scene::ItemEntry& ent ) override;
53
55 void cleanup();
56
58 void handlePickingResult( int drawableId );
59
61 void setLocal( bool useLocal );
62
64 void changeGizmoType( GizmoType type );
65
67 void updateValues() override;
68
69 private:
70 bool isValidAction( const Gui::KeyMappingManager::KeyMappingAction& action ) const;
71
72 // Helper method to change the current gizmo
73 void updateGizmo();
74
75 // Returs the current gizmo
76 Gizmo* currentGizmo();
77
78 private:
80 GizmoType m_currentGizmoType;
81 Gizmo::Mode m_mode;
82
83 static void configureKeyMapping_impl();
84
85#define KeyMappingGizmo \
86 KMA_VALUE( GIZMOMANAGER_MANIPULATION ) \
87 KMA_VALUE( GIZMOMANAGER_STEP ) \
88 KMA_VALUE( GIZMOMANAGER_WHOLE ) \
89 KMA_VALUE( GIZMOMANAGER_STEP_WHOLE )
90
91#define KMA_VALUE( XX ) static KeyMappingManager::KeyMappingAction XX;
92 KeyMappingGizmo
93#undef KMA_VALUE
94};
95} // namespace Gui
96} // 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
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3