diff --git a/lib/ui/include/ui/core/animation/animation_system.hpp b/lib/ui/include/ui/core/animation/animation_system.hpp index 15762b2a4..87c6bc4d0 100644 --- a/lib/ui/include/ui/core/animation/animation_system.hpp +++ b/lib/ui/include/ui/core/animation/animation_system.hpp @@ -21,6 +21,7 @@ namespace VTX::UI::Core::Animation void play(); void stop(); + bool isPlaying() const; void update( const float p_deltaTime ); diff --git a/lib/ui/include/ui/qt/controller/freefly.hpp b/lib/ui/include/ui/internal/controller/camera/freefly.hpp similarity index 84% rename from lib/ui/include/ui/qt/controller/freefly.hpp rename to lib/ui/include/ui/internal/controller/camera/freefly.hpp index 31e2f432c..36b450b40 100644 --- a/lib/ui/include/ui/qt/controller/freefly.hpp +++ b/lib/ui/include/ui/internal/controller/camera/freefly.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_FREEFLY__ -#define __VTX_UI_QT_CONTROLLER_FREEFLY__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_CAMERA_FREEFLY__ +#define __VTX_UI_INTERNAL_CONTROLLER_CAMERA_FREEFLY__ #include "ui/core/input/key_mapping.hpp" #include "ui/internal/all_settings.hpp" @@ -7,8 +7,11 @@ #include "ui/qt/controller/controller_manager.hpp" #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Camera { + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + class Freefly : public BaseCameraController { public: @@ -52,7 +55,7 @@ namespace VTX::UI::QT::Controller void _updateInputs( const float & p_deltaTime ) override; private: - Core::Input::KeyMapping _mapping; + UI::Core::Input::KeyMapping _mapping; }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Camera #endif diff --git a/lib/ui/include/ui/qt/controller/trackball.hpp b/lib/ui/include/ui/internal/controller/camera/trackball.hpp similarity index 88% rename from lib/ui/include/ui/qt/controller/trackball.hpp rename to lib/ui/include/ui/internal/controller/camera/trackball.hpp index e49ce9edf..70e517433 100644 --- a/lib/ui/include/ui/qt/controller/trackball.hpp +++ b/lib/ui/include/ui/internal/controller/camera/trackball.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_TRACKBALL__ -#define __VTX_UI_QT_CONTROLLER_TRACKBALL__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_CAMERA_TRACKBALL__ +#define __VTX_UI_INTERNAL_CONTROLLER_CAMERA_TRACKBALL__ #include "ui/core/input/key_mapping.hpp" #include "ui/internal/all_settings.hpp" @@ -9,8 +9,11 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Camera { + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + class Trackball : public BaseCameraController { public: @@ -68,5 +71,5 @@ namespace VTX::UI::QT::Controller bool _needUpdate = false; }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Camera #endif diff --git a/lib/ui/include/ui/qt/controller/measurement_picker.hpp b/lib/ui/include/ui/internal/controller/picker/measurement.hpp similarity index 97% rename from lib/ui/include/ui/qt/controller/measurement_picker.hpp rename to lib/ui/include/ui/internal/controller/picker/measurement.hpp index 938e9db55..8ba8f33dd 100644 --- a/lib/ui/include/ui/qt/controller/measurement_picker.hpp +++ b/lib/ui/include/ui/internal/controller/picker/measurement.hpp @@ -1,3 +1,5 @@ +// TODO Move this controller in dedicated tool + // #ifndef __VTX_UI_QT_CONTROLLER_MEASUREMENT_PICKER__ // #define __VTX_UI_QT_CONTROLLER_MEASUREMENT_PICKER__ // diff --git a/lib/ui/include/ui/qt/controller/selection_picker.hpp b/lib/ui/include/ui/internal/controller/picker/selection.hpp similarity index 69% rename from lib/ui/include/ui/qt/controller/selection_picker.hpp rename to lib/ui/include/ui/internal/controller/picker/selection.hpp index 823efaa76..e35b71107 100644 --- a/lib/ui/include/ui/qt/controller/selection_picker.hpp +++ b/lib/ui/include/ui/internal/controller/picker/selection.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_SELECTION_PICKER__ -#define __VTX_UI_QT_CONTROLLER_SELECTION_PICKER__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_PICKER_SELECTION_PICKER__ +#define __VTX_UI_INTERNAL_CONTROLLER_PICKER_SELECTION_PICKER__ #include "ui/qt/controller/base_picker_controller.hpp" #include "ui/qt/controller/controller_manager.hpp" @@ -7,9 +7,12 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Picker { - class SelectionPicker : public BasePickerController + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + + class Selection : public BasePickerController { public: using PickingInfo = App::Application::Selection::PickingInfo; @@ -18,17 +21,17 @@ namespace VTX::UI::QT::Controller inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: - inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; + inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; public: - SelectionPicker() = default; - SelectionPicker( const SelectionPicker & p_source ) = default; - ~SelectionPicker() = default; + Selection() = default; + Selection( const Selection & p_source ) = default; + ~Selection() = default; void init() override; inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; + std::unique_ptr clone() const { return std::make_unique( *this ); }; protected: void _onMouseLeftClick( const Vec2i & p_mousePos ); @@ -41,6 +44,6 @@ namespace VTX::UI::QT::Controller private: PickingInfo _lastPickingInfo = PickingInfo(); }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Picker #endif diff --git a/lib/ui/include/ui/qt/controller/debug_shortcut.hpp b/lib/ui/include/ui/internal/controller/shortcut/debug.hpp similarity index 53% rename from lib/ui/include/ui/qt/controller/debug_shortcut.hpp rename to lib/ui/include/ui/internal/controller/shortcut/debug.hpp index 01641fa48..8595e00d2 100644 --- a/lib/ui/include/ui/qt/controller/debug_shortcut.hpp +++ b/lib/ui/include/ui/internal/controller/shortcut/debug.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_DEBUG_SHORTCUT__ -#define __VTX_UI_QT_CONTROLLER_DEBUG_SHORTCUT__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__ +#define __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__ #include "ui/core/input/keys.hpp" #include "ui/qt/controller/base_shortcut_controller.hpp" @@ -7,26 +7,29 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - class DebugShortcut final : public BaseShortcutController + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + + class Debug final : public BaseShortcutController { public: inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_DEBUG"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: - inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; + inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; public: - DebugShortcut() = default; - DebugShortcut( const DebugShortcut & p_source ) = default; - ~DebugShortcut() = default; + Debug() = default; + Debug( const Debug & p_source ) = default; + ~Debug() = default; void init() override; inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; + std::unique_ptr clone() const { return std::make_unique( *this ); }; }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut #endif diff --git a/lib/ui/include/ui/qt/controller/global_shortcut.hpp b/lib/ui/include/ui/internal/controller/shortcut/global.hpp similarity index 55% rename from lib/ui/include/ui/qt/controller/global_shortcut.hpp rename to lib/ui/include/ui/internal/controller/shortcut/global.hpp index 8853bf26d..55e806b23 100644 --- a/lib/ui/include/ui/qt/controller/global_shortcut.hpp +++ b/lib/ui/include/ui/internal/controller/shortcut/global.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_GLOBAL_SHORTCUT__ -#define __VTX_UI_QT_CONTROLLER_GLOBAL_SHORTCUT__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_GLOBAL_SHORTCUT__ +#define __VTX_UI_INTERNAL_CONTROLLER_GLOBAL_SHORTCUT__ #include "ui/core/input/keys.hpp" #include "ui/qt/controller/base_controller.hpp" @@ -8,26 +8,29 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - class GlobalShortcut final : public BaseShortcutController + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + + class Global final : public BaseShortcutController { public: inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_GLOBAL"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: - inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; + inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; public: - GlobalShortcut() = default; - GlobalShortcut( const GlobalShortcut & p_source ) = default; - ~GlobalShortcut() = default; + Global() = default; + Global( const Global & p_source ) = default; + ~Global() = default; void init() override; inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; + std::unique_ptr clone() const { return std::make_unique( *this ); }; }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut #endif diff --git a/lib/ui/include/ui/qt/controller/visualization_shortcut.hpp b/lib/ui/include/ui/internal/controller/shortcut/visualization.hpp similarity index 60% rename from lib/ui/include/ui/qt/controller/visualization_shortcut.hpp rename to lib/ui/include/ui/internal/controller/shortcut/visualization.hpp index fe500ff5f..7e1e4d28b 100644 --- a/lib/ui/include/ui/qt/controller/visualization_shortcut.hpp +++ b/lib/ui/include/ui/internal/controller/shortcut/visualization.hpp @@ -1,5 +1,5 @@ -#ifndef __VTX_UI_QT_CONTROLLER_VISUALIZATION_SHORTCUT__ -#define __VTX_UI_QT_CONTROLLER_VISUALIZATION_SHORTCUT__ +#ifndef __VTX_UI_INTERNAL_CONTROLLER_VISUALIZATION_SHORTCUT__ +#define __VTX_UI_INTERNAL_CONTROLLER_VISUALIZATION_SHORTCUT__ #include "ui/core/input/keys.hpp" #include "ui/qt/controller/base_controller.hpp" @@ -8,30 +8,33 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - class VisualizationShortcut final : public BaseShortcutController + using namespace VTX::UI::QT; + using namespace VTX::UI::QT::Controller; + + class Visualization final : public BaseShortcutController { public: inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_VISUALIZATION"; inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); private: - inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; + inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; public: - VisualizationShortcut() = default; - VisualizationShortcut( const VisualizationShortcut & p_source ) = default; - ~VisualizationShortcut() = default; + Visualization() = default; + Visualization( const Visualization & p_source ) = default; + ~Visualization() = default; void init() override; inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; + std::unique_ptr clone() const { return std::make_unique( *this ); }; private: void _callOrientOnScene() const; void _callOrientOnSelection() const; }; -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut #endif diff --git a/lib/ui/include/ui/internal/init_visualization_mode.hpp b/lib/ui/include/ui/internal/init_visualization_mode.hpp new file mode 100644 index 000000000..0ac73375d --- /dev/null +++ b/lib/ui/include/ui/internal/init_visualization_mode.hpp @@ -0,0 +1,11 @@ +#ifndef __VTX_UI_INTERNAL_INIT_VISUALIZATION_MODE__ +#define __VTX_UI_INTERNAL_INIT_VISUALIZATION_MODE__ + +#include "ui/qt/mode/visualization.hpp" + +namespace VTX::UI::Internal +{ + void init( QT::Mode::Visualization & p_visualization ); +} // namespace VTX::UI::Internal + +#endif diff --git a/lib/ui/include/ui/qt/controller/_fwd.hpp b/lib/ui/include/ui/qt/controller/_fwd.hpp index 779152074..40f6778eb 100644 --- a/lib/ui/include/ui/qt/controller/_fwd.hpp +++ b/lib/ui/include/ui/qt/controller/_fwd.hpp @@ -3,6 +3,7 @@ namespace VTX::UI::QT::Controller class BaseController; class BaseCameraController; class BasePickerController; + class BaseShortcutController; class ControllerManager; } // namespace VTX::UI::QT::Controller diff --git a/lib/ui/include/ui/qt/controller/camera_animation_controller.hpp b/lib/ui/include/ui/qt/controller/camera_animation_controller.hpp deleted file mode 100644 index e08660a34..000000000 --- a/lib/ui/include/ui/qt/controller/camera_animation_controller.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __VTX_UI_QT_CONTROLLER_CAMERA_ANIMATION_CONTROLLER__ -#define __VTX_UI_QT_CONTROLLER_CAMERA_ANIMATION_CONTROLLER__ - -#include "ui/core/input/keys.hpp" -#include "ui/qt/controller/base_controller.hpp" -#include "ui/qt/controller/controller_manager.hpp" -#include - -namespace VTX::UI::QT::Controller -{ - class CameraAnimationController : public BaseController - { - public: - inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_CAMERA_ANIMATION"; - inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID ); - - private: - inline static const ControllerCollection::Registration _reg { COLLECTION_ID }; - - public: - CameraAnimationController() = default; - CameraAnimationController( const CameraAnimationController & p_source ) = default; - ~CameraAnimationController() = default; - - void update( const float & p_deltaTime ) override; - - inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const override - { - return std::make_unique( *this ); - }; - }; -} // namespace VTX::UI::QT::Controller -#endif diff --git a/lib/ui/include/ui/qt/controller/camera_animator.hpp b/lib/ui/include/ui/qt/controller/camera_animator.hpp deleted file mode 100644 index b007a6a35..000000000 --- a/lib/ui/include/ui/qt/controller/camera_animator.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// #ifndef __VTX_UI_QT_CONTROLLER_CAMERA_ANIMATOR__ -// #define __VTX_UI_QT_CONTROLLER_CAMERA_ANIMATOR__ -// -// #include -// #include -// #include -// #include -// -// namespace VTX::UI::QT::Controller -//{ -// class CameraAnimator -// { -// public: -// explicit CameraAnimator( VTX::App::Component::Render::Camera & p_camera ); -// virtual ~CameraAnimator() = default; -// -// void setTarget( const QWidget * const p_widget ); -// -// inline const bool isOrienting() const { return _isOrienting; } -// inline const Vec3f & getOrientStartingPosition() const { return _orientStartingPosition; } -// inline const Vec3f & getOrientTargetPosition() const { return _orientTargetPosition; } -// -// void update( const float & p_deltaTime ) override; -// -// virtual void reset() { _isOrienting = false; } -// -// virtual void orient( const Util::Math::AABB & p_aabb ) -// { -// _orientTime = 0.f; -// _computeOrientPositions( p_aabb ); -// } -// virtual void orient( const Vec3f & p_position, const Quatf & p_orientation ) -// { -// _orientTime = 0.f; -// _computeOrientPositions( p_position, p_orientation ); -// } -// -// protected: -// const float ORIENT_DURATION = 0.5f; -// const float ORIENT_THRESHOLD = 1e-4f; -// -// App::Component::Render::Camera & _camera; -// const QWidget * _widgetTarget = nullptr; -// -// bool _isOrienting = false; -// float _orientTime = 0.f; -// Vec3f _orientStartingPosition = VEC3F_ZERO; -// Vec3f _orientTargetPosition = VEC3F_ZERO; -// Quatf _orientStartingRotation = QUATF_ID; -// Quatf _orientTargetRotation = QUATF_ID; -// -// virtual void _updateInputs( const float & ) = 0; -// virtual void _computeOrientPositions( const Util::Math::AABB & p_aabb ) = 0; -// virtual void _computeOrientPositions( const Vec3f & p_position, const Quatf & p_orientation ) = 0; -// virtual void _updateOrient( const float & ) = 0; -// }; -// } // namespace VTX::UI::QT::Controller -// #endif diff --git a/lib/ui/include/ui/qt/mode/visualization.hpp b/lib/ui/include/ui/qt/mode/visualization.hpp index c1acb451f..aa24387a5 100644 --- a/lib/ui/include/ui/qt/mode/visualization.hpp +++ b/lib/ui/include/ui/qt/mode/visualization.hpp @@ -49,7 +49,6 @@ namespace VTX::UI::QT::Mode void setCameraController( const App::Core::CollectionKey & p_controllerKey ); void setPickerController( const Util::Hashing::Hash & p_controllerHash ); void setPickerController( const App::Core::CollectionKey & p_controllerKey ); - void resetCameraController(); const std::set> & getCameraControllers() const { diff --git a/lib/ui/src/ui/core/animation/animation_system.cpp b/lib/ui/src/ui/core/animation/animation_system.cpp index aaca24a52..60410497c 100644 --- a/lib/ui/src/ui/core/animation/animation_system.cpp +++ b/lib/ui/src/ui/core/animation/animation_system.cpp @@ -1,10 +1,4 @@ #include "ui/core/animation/animation_system.hpp" -#include "ui/qt/application_qt.hpp" -#include "ui/qt/controller/base_camera_controller.hpp" -#include "ui/qt/controller/base_picker_controller.hpp" -#include "ui/qt/controller/controller_manager.hpp" -#include "ui/qt/mode/base_mode.hpp" -#include "ui/qt/mode/visualization.hpp" namespace VTX::UI::Core::Animation { @@ -24,12 +18,19 @@ namespace VTX::UI::Core::Animation } void AnimationSystem::stop() { + if ( _isPlaying && _currentAnimationIt != _animationSequence.end() ) + { + ( *_currentAnimationIt )->stop(); + } + _isPlaying = false; _currentAnimationIt = _animationSequence.end(); onStopped(); } + bool AnimationSystem::isPlaying() const { return _isPlaying; } + void AnimationSystem::update( const float p_deltaTime ) { if ( !_isPlaying ) diff --git a/lib/ui/src/ui/internal/animation/orient.cpp b/lib/ui/src/ui/internal/animation/orient.cpp index fd217cbd3..9ddcdf034 100644 --- a/lib/ui/src/ui/internal/animation/orient.cpp +++ b/lib/ui/src/ui/internal/animation/orient.cpp @@ -4,7 +4,6 @@ #include "ui/qt/controller/base_camera_controller.hpp" #include "ui/qt/controller/base_controller.hpp" #include "ui/qt/controller/base_picker_controller.hpp" -#include "ui/qt/controller/camera_animation_controller.hpp" #include "ui/qt/mode/visualization.hpp" #include #include diff --git a/lib/ui/src/ui/internal/animation/reset_camera.cpp b/lib/ui/src/ui/internal/animation/reset_camera.cpp index 3f6bfb274..9a94cc478 100644 --- a/lib/ui/src/ui/internal/animation/reset_camera.cpp +++ b/lib/ui/src/ui/internal/animation/reset_camera.cpp @@ -4,7 +4,6 @@ #include "ui/qt/controller/base_camera_controller.hpp" #include "ui/qt/controller/base_controller.hpp" #include "ui/qt/controller/base_picker_controller.hpp" -#include "ui/qt/controller/camera_animation_controller.hpp" #include "ui/qt/mode/visualization.hpp" #include #include diff --git a/lib/ui/src/ui/qt/controller/freefly.cpp b/lib/ui/src/ui/internal/controller/camera/freefly.cpp similarity index 94% rename from lib/ui/src/ui/qt/controller/freefly.cpp rename to lib/ui/src/ui/internal/controller/camera/freefly.cpp index 09833f5c3..551285ba9 100644 --- a/lib/ui/src/ui/qt/controller/freefly.cpp +++ b/lib/ui/src/ui/internal/controller/camera/freefly.cpp @@ -1,12 +1,11 @@ -#include "ui/qt/controller/freefly.hpp" -#include "ui/internal/all_settings.hpp" +#include "ui/internal/controller/camera/freefly.hpp" #include "ui/qt/application_qt.hpp" #include "ui/qt/input/input_manager.hpp" #include "ui/qt/main_window.hpp" #include "ui/qt/style.hpp" #include "ui/qt/tool/render/widget/render_widget.hpp" -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Camera { void Freefly::init() { @@ -101,4 +100,4 @@ namespace VTX::UI::QT::Controller getCamera().getTransform().localMove( translation ); } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Camera diff --git a/lib/ui/src/ui/qt/controller/trackball.cpp b/lib/ui/src/ui/internal/controller/camera/trackball.cpp similarity index 97% rename from lib/ui/src/ui/qt/controller/trackball.cpp rename to lib/ui/src/ui/internal/controller/camera/trackball.cpp index d07072e22..39a147fe0 100644 --- a/lib/ui/src/ui/qt/controller/trackball.cpp +++ b/lib/ui/src/ui/internal/controller/camera/trackball.cpp @@ -1,4 +1,4 @@ -#include "ui/qt/controller/trackball.hpp" +#include "ui/internal/controller/camera/trackball.hpp" #include "ui/qt/application_qt.hpp" #include "ui/qt/input/input_manager.hpp" #include "ui/qt/main_window.hpp" @@ -10,7 +10,7 @@ #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Camera { void Trackball::init() { @@ -209,4 +209,4 @@ namespace VTX::UI::QT::Controller _velocity = VEC3F_ZERO; } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Camera diff --git a/lib/ui/src/ui/qt/controller/measurement_picker.cpp b/lib/ui/src/ui/internal/controller/picker/measurement.cpp similarity index 100% rename from lib/ui/src/ui/qt/controller/measurement_picker.cpp rename to lib/ui/src/ui/internal/controller/picker/measurement.cpp diff --git a/lib/ui/src/ui/qt/controller/selection_picker.cpp b/lib/ui/src/ui/internal/controller/picker/selection.cpp similarity index 87% rename from lib/ui/src/ui/qt/controller/selection_picker.cpp rename to lib/ui/src/ui/internal/controller/picker/selection.cpp index e0a6adf34..415a27daf 100644 --- a/lib/ui/src/ui/qt/controller/selection_picker.cpp +++ b/lib/ui/src/ui/internal/controller/picker/selection.cpp @@ -1,4 +1,4 @@ -#include "ui/qt/controller/selection_picker.hpp" +#include "ui/internal/controller/picker/selection.hpp" #include "ui/qt/application_qt.hpp" #include "ui/qt/input/input_manager.hpp" #include "ui/qt/main_window.hpp" @@ -31,9 +31,9 @@ namespace } } // namespace -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Picker { - void SelectionPicker::init() + void Selection::init() { INPUT_MANAGER().onMouseLeftClicked += [ this ]( const Vec2i & p_mousePosition ) { _onMouseLeftClick( p_mousePosition ); }; @@ -45,16 +45,18 @@ namespace VTX::UI::QT::Controller [ this ]( const Vec2i & p_mousePosition ) { _onMouseRightClick( p_mousePosition ); }; } - void SelectionPicker::_onMouseLeftClick( const Vec2i & p_mousePos ) + void Selection::_onMouseLeftClick( const Vec2i & p_mousePos ) { const PickingInfo pickingInfo = PickingInfo( App::RENDERER().facade().getPickedIds( p_mousePos.x, p_mousePos.y ) ); + VTX_INFO( "PickingInfo : {}, {}.", pickingInfo.getFirst(), pickingInfo.getSecond() ); + _performSelection( pickingInfo ); _lastPickingInfo = pickingInfo; } - void SelectionPicker::_onMouseRightClick( const Vec2i & p_mousePos ) + void Selection::_onMouseRightClick( const Vec2i & p_mousePos ) { const PickingInfo pickingInfo = PickingInfo( App::RENDERER().facade().getPickedIds( p_mousePos.x, p_mousePos.y ) ); @@ -80,7 +82,7 @@ namespace VTX::UI::QT::Controller } } - void SelectionPicker::_onMouseLeftDoubleClick( const Vec2i & p_mousePos ) + void Selection::_onMouseLeftDoubleClick( const Vec2i & p_mousePos ) { const PickingInfo pickingInfo = PickingInfo( App::RENDERER().facade().getPickedIds( p_mousePos.x, p_mousePos.y ) ); @@ -94,7 +96,7 @@ namespace VTX::UI::QT::Controller } } - void SelectionPicker::_performSelection( const PickingInfo & p_pickingInfo ) const + void Selection::_performSelection( const PickingInfo & p_pickingInfo ) const { // Append to selection if CTRL modifier pressed. const App::Component::Scene::Pickable::PickType pickType @@ -119,7 +121,7 @@ namespace VTX::UI::QT::Controller } } - bool SelectionPicker::_isTargetSelected( const PickingInfo & p_pickingInfo ) const + bool Selection::_isTargetSelected( const PickingInfo & p_pickingInfo ) const { bool res = false; @@ -142,4 +144,4 @@ namespace VTX::UI::QT::Controller return res; } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Picker diff --git a/lib/ui/src/ui/qt/controller/debug_shortcut.cpp b/lib/ui/src/ui/internal/controller/shortcut/debug.cpp similarity index 79% rename from lib/ui/src/ui/qt/controller/debug_shortcut.cpp rename to lib/ui/src/ui/internal/controller/shortcut/debug.cpp index 85783cf00..ef00c923e 100644 --- a/lib/ui/src/ui/qt/controller/debug_shortcut.cpp +++ b/lib/ui/src/ui/internal/controller/shortcut/debug.cpp @@ -1,10 +1,10 @@ -#include "ui/qt/controller/debug_shortcut.hpp" +#include "ui/internal/controller/shortcut/debug.hpp" #include "ui/core/input/keys.hpp" #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - void DebugShortcut::init() + void Debug::init() { BaseShortcutController::init(); @@ -18,4 +18,4 @@ namespace VTX::UI::QT::Controller Core::Input::Shortcut::callAction() } ); } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut diff --git a/lib/ui/src/ui/qt/controller/global_shortcut.cpp b/lib/ui/src/ui/internal/controller/shortcut/global.cpp similarity index 78% rename from lib/ui/src/ui/qt/controller/global_shortcut.cpp rename to lib/ui/src/ui/internal/controller/shortcut/global.cpp index 01e3890e9..f6667dfce 100644 --- a/lib/ui/src/ui/qt/controller/global_shortcut.cpp +++ b/lib/ui/src/ui/internal/controller/shortcut/global.cpp @@ -1,10 +1,10 @@ -#include "ui/qt/controller/global_shortcut.hpp" +#include "ui/internal/controller/shortcut/global.hpp" #include "ui/core/input/keys.hpp" #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - void GlobalShortcut::init() + void Global::init() { BaseShortcutController::init(); @@ -18,4 +18,4 @@ namespace VTX::UI::QT::Controller Core::Input::Shortcut::callAction() } ); } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut diff --git a/lib/ui/src/ui/qt/controller/visualization_shortcut.cpp b/lib/ui/src/ui/internal/controller/shortcut/visualization.cpp similarity index 59% rename from lib/ui/src/ui/qt/controller/visualization_shortcut.cpp rename to lib/ui/src/ui/internal/controller/shortcut/visualization.cpp index d7618f23c..5902d6d6e 100644 --- a/lib/ui/src/ui/qt/controller/visualization_shortcut.cpp +++ b/lib/ui/src/ui/internal/controller/shortcut/visualization.cpp @@ -1,13 +1,14 @@ -#include "ui/qt/controller/visualization_shortcut.hpp" -#include "ui/action/animation.hpp" #include "ui/action/visualization.hpp" +#include "ui/action/animation.hpp" +#include "ui/core/animation/animation_system.hpp" +#include "ui/internal/controller/shortcut/visualization.hpp" #include #include #include -namespace VTX::UI::QT::Controller +namespace VTX::UI::Internal::Controller::Shortcut { - void VisualizationShortcut::init() + void Visualization::init() { BaseShortcutController::init(); @@ -25,15 +26,26 @@ namespace VTX::UI::QT::Controller else _callOrientOnSelection(); } } ); + + // TODO Maybe move that in a controller dedicated for the animator which activate / deactivate itself when the + // Animator Play / Stop + referenceShortcut( { { Core::Input::Key::Key_Escape }, + [ this ]() + { + if ( ANIMATION_SYSTEM().isPlaying() ) + { + ANIMATION_SYSTEM().stop(); + } + } } ); } - void VisualizationShortcut::_callOrientOnScene() const + void Visualization::_callOrientOnScene() const { App::VTX_ACTION().execute( App::SCENE().getAABB() ); } - void VisualizationShortcut::_callOrientOnSelection() const + void Visualization::_callOrientOnSelection() const { App::VTX_ACTION().execute( App::CURRENT_SELECTION().getAABB() ); } -} // namespace VTX::UI::QT::Controller +} // namespace VTX::UI::Internal::Controller::Shortcut diff --git a/lib/ui/src/ui/internal/init_visualization_mode.cpp b/lib/ui/src/ui/internal/init_visualization_mode.cpp new file mode 100644 index 000000000..2053c7d5a --- /dev/null +++ b/lib/ui/src/ui/internal/init_visualization_mode.cpp @@ -0,0 +1,57 @@ +#include "ui/internal/init_visualization_mode.hpp" +#include "ui/internal/controller/camera/freefly.hpp" +#include "ui/internal/controller/camera/trackball.hpp" +#include "ui/internal/controller/picker/selection.hpp" +#include "ui/internal/controller/shortcut/debug.hpp" +#include "ui/internal/controller/shortcut/global.hpp" +#include "ui/internal/controller/shortcut/visualization.hpp" +#include "ui/qt/controller/controller_manager.hpp" + +namespace VTX::UI::Internal +{ + void init( QT::Mode::Visualization & p_visualization ) + { + // TODO replace that with an initialisation with custom data. + std::unique_ptr ptr + = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Camera::Freefly::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addCameraController( ptr ); + + ptr = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Camera::Trackball::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addCameraController( ptr ); + + ptr = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Picker::Selection::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addPickerController( ptr ); + + ptr = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Shortcut::Global::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addController( ptr ); + + ptr = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Shortcut::Visualization::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addController( ptr ); + +#ifndef VTX_PRODUCTION + ptr = QT::Controller::ControllerCollection::get().instantiateItem( + Controller::Shortcut::Debug::HASHED_COLLECTION_ID + ); + ptr->init(); + p_visualization.addController( ptr ); +#endif + + p_visualization.setCameraController( Controller::Camera::Trackball::HASHED_COLLECTION_ID ); + p_visualization.setPickerController( Controller::Picker::Selection::HASHED_COLLECTION_ID ); + } +} // namespace VTX::UI::Internal diff --git a/lib/ui/src/ui/qt/application_qt.cpp b/lib/ui/src/ui/qt/application_qt.cpp index 65ca185f6..4c215d7d5 100644 --- a/lib/ui/src/ui/qt/application_qt.cpp +++ b/lib/ui/src/ui/qt/application_qt.cpp @@ -1,4 +1,6 @@ #include "ui/qt/application_qt.hpp" +#include "ui/internal/init_settings.hpp" +#include "ui/internal/init_visualization_mode.hpp" #include "ui/qt/main_window.hpp" #include "ui/qt/mode/base_mode.hpp" #include "ui/qt/mode/visualization.hpp" @@ -10,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -63,8 +65,10 @@ namespace VTX::UI::QT void ApplicationQt::_initUI( const std::vector & p_args ) { + Internal::initSettings( App::SETTINGS() ); + //// Init Modes. - //_currentMode = Mode::ModeCollection::get().instantiateItem( _currentModeKey ); + Internal::init( dynamic_cast( *_currentMode ) ); _currentMode->enter(); // Create UI. diff --git a/lib/ui/src/ui/qt/controller/camera_animator.cpp b/lib/ui/src/ui/qt/controller/camera_animator.cpp deleted file mode 100644 index 19ce48801..000000000 --- a/lib/ui/src/ui/qt/controller/camera_animator.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "ui/qt/controller/camera_animator.hpp" - -namespace VTX::UI::QT::Controller -{ - -} // namespace VTX::UI::QT::Controller diff --git a/lib/ui/src/ui/qt/mode/visualization.cpp b/lib/ui/src/ui/qt/mode/visualization.cpp index 77ac1e6ed..1722b46c7 100644 --- a/lib/ui/src/ui/qt/mode/visualization.cpp +++ b/lib/ui/src/ui/qt/mode/visualization.cpp @@ -3,87 +3,22 @@ #include "ui/qt/controller/base_camera_controller.hpp" #include "ui/qt/controller/base_controller.hpp" #include "ui/qt/controller/base_picker_controller.hpp" -#include "ui/qt/controller/controller_manager.hpp" -#include "ui/qt/controller/debug_shortcut.hpp" -#include "ui/qt/controller/freefly.hpp" -#include "ui/qt/controller/global_shortcut.hpp" -#include "ui/qt/controller/selection_picker.hpp" -#include "ui/qt/controller/trackball.hpp" -#include "ui/qt/controller/visualization_shortcut.hpp" #include -#include -#include #include namespace VTX::UI::QT::Mode { - Visualization::Visualization() : BaseMode() - { - // TODO replace that with an initialisation with custom data. - std::unique_ptr ptr - = Controller::ControllerCollection::get().instantiateItem( Controller::Freefly::HASHED_COLLECTION_ID ); - ptr->init(); - addCameraController( ptr ); - - ptr = Controller::ControllerCollection::get().instantiateItem( Controller::Trackball::HASHED_COLLECTION_ID ); - ptr->init(); - addCameraController( ptr ); - - ptr = Controller::ControllerCollection::get().instantiateItem( Controller::SelectionPicker::HASHED_COLLECTION_ID - ); - ptr->init(); - addPickerController( ptr ); - - ptr = Controller::ControllerCollection::get().instantiateItem( Controller::GlobalShortcut::HASHED_COLLECTION_ID - ); - ptr->init(); - addController( ptr ); - - ptr = Controller::ControllerCollection::get().instantiateItem( - Controller::VisualizationShortcut::HASHED_COLLECTION_ID - ); - ptr->init(); - addController( ptr ); - -#ifndef VTX_PRODUCTION - ptr = Controller::ControllerCollection::get().instantiateItem( Controller::DebugShortcut::HASHED_COLLECTION_ID - ); - ptr->init(); - addController( ptr ); -#endif - } + Visualization::Visualization() : BaseMode() {} void Visualization::enter() { BaseMode::enter(); if ( _currentCameraController != nullptr ) - { _currentCameraController->setActive( true ); - } - else - { - if ( _cameraControllers.size() > 0 ) - { - _affectCameraController( - dynamic_cast( _cameraControllers.begin()->get() ) - ); - } - } if ( _currentPickerController != nullptr ) - { _currentPickerController->setActive( true ); - } - else - { - if ( _pickerControllers.size() > 0 ) - { - _affectPickerController( - dynamic_cast( _pickerControllers.begin()->get() ) - ); - } - } for ( const std::unique_ptr & controller : _otherControllers ) { @@ -133,11 +68,23 @@ namespace VTX::UI::QT::Mode { assert( dynamic_cast( p_cameraControllerPtr.get() ) != nullptr ); _cameraControllers.emplace( std::move( p_cameraControllerPtr ) ); + + if ( _currentCameraController == nullptr ) + { + _affectCameraController( dynamic_cast( _cameraControllers.begin()->get() + ) ); + } } void Visualization::addPickerController( std::unique_ptr & p_pickerControllerPtr ) { assert( dynamic_cast( p_pickerControllerPtr.get() ) != nullptr ); _pickerControllers.emplace( std::move( p_pickerControllerPtr ) ); + + if ( _currentPickerController == nullptr ) + { + _affectPickerController( dynamic_cast( _pickerControllers.begin()->get() + ) ); + } } void Visualization::addController( std::unique_ptr & p_controllerPtr ) { @@ -217,18 +164,4 @@ namespace VTX::UI::QT::Mode _currentPickerController->setActive( true ); } - void Visualization::resetCameraController() - { - App::Component::Render::Camera & camera = App::SCENE().getCamera(); - const Util::Math::AABB & sceneAABB = App::SCENE().getAABB(); - - const Vec3f resetPos = UI::Helper::Animation::computeCameraOrientPosition( - App::Internal::CAMERA_FRONT_DEFAULT, camera.getFov(), sceneAABB - ); - - camera.reset( resetPos ); - - _currentCameraController->reset(); - } - } // namespace VTX::UI::QT::Mode diff --git a/lib/ui/src/ui/qt/tool/ui_features/visualization_tool.cpp b/lib/ui/src/ui/qt/tool/ui_features/visualization_tool.cpp index 631b15b2c..0a3a7c2ac 100644 --- a/lib/ui/src/ui/qt/tool/ui_features/visualization_tool.cpp +++ b/lib/ui/src/ui/qt/tool/ui_features/visualization_tool.cpp @@ -1,9 +1,9 @@ #include "ui/qt/tool/ui_features/visualization_tool.hpp" #include "ui/action/animation.hpp" #include "ui/action/visualization.hpp" +#include "ui/internal/controller/camera/freefly.hpp" +#include "ui/internal/controller/camera/trackball.hpp" #include "ui/qt/application_qt.hpp" -#include "ui/qt/controller/freefly.hpp" -#include "ui/qt/controller/trackball.hpp" #include "ui/qt/main_window.hpp" #include "ui/qt/mode/visualization.hpp" #include "ui/qt/tool/pytx/details/include_python_binding.hpp" @@ -80,12 +80,15 @@ namespace VTX::UI::QT::Tool::UIFeatures void VisualizationTool::_setTrackball() const { - App::VTX_ACTION().execute( Controller::Trackball::COLLECTION_ID + App::VTX_ACTION().execute( + Internal::Controller::Camera::Trackball::COLLECTION_ID ); } void VisualizationTool::_setFreefly() const { - App::VTX_ACTION().execute( Controller::Freefly::COLLECTION_ID ); + App::VTX_ACTION().execute( + Internal::Controller::Camera::Freefly::COLLECTION_ID + ); } namespace Visualization