diff --git a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp index 39145b1c7..e1647ade8 100644 --- a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp +++ b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp @@ -56,20 +56,6 @@ namespace // helper functions namespace { - // unpack a SimTK::Vec6 into an array - std::array ToArray(SimTK::Vec6 const& v) - { - return - { - static_cast(v[0]), - static_cast(v[1]), - static_cast(v[2]), - static_cast(v[3]), - static_cast(v[4]), - static_cast(v[5]), - }; - } - // returns an updater function that deletes an element from a list property template std::function MakePropElementDeleter(int idx) @@ -115,12 +101,11 @@ namespace } // draws the property name and (optionally) comment tooltip - void DrawPropertyName(OpenSim::AbstractProperty const& prop) + void DrawPropertyName(const OpenSim::AbstractProperty& prop) { ui::draw_text_unformatted(prop.getName()); - if (!prop.getComment().empty()) - { + if (!prop.getComment().empty()) { ui::same_line(); ui::draw_help_marker(prop.getComment()); } @@ -128,18 +113,17 @@ namespace // wraps an object accessor with property information so that an individual // property accesssor with the same lifetime semantics as the object can exist - std::function MakePropertyAccessor( - std::function const& objAccessor, - std::string const& propertyName) + std::function MakePropertyAccessor( + const std::function& objAccessor, + const std::string& propertyName) { - return [objAccessor, propertyName]() -> OpenSim::AbstractProperty const* + return [objAccessor, propertyName]() -> const OpenSim::AbstractProperty* { - OpenSim::Object const* maybeObj = objAccessor(); - if (!maybeObj) - { + const OpenSim::Object* maybeObj = objAccessor(); + if (!maybeObj) { return nullptr; } - OpenSim::Object const& obj = *maybeObj; + const OpenSim::Object& obj = *maybeObj; if (!obj.hasProperty(propertyName)) { @@ -159,12 +143,12 @@ namespace // draws a little vertical line, which is usually used to visually indicate // x/y/z to the user - void DrawColoredDimensionHintVerticalLine(Color const& color) + void DrawColoredDimensionHintVerticalLine(const Color& color) { ImDrawList* const l = ui::get_panel_draw_list(); - Vec2 const p = ui::get_cursor_screen_pos(); - float const h = ui::get_text_line_height() + 2.0f*ui::get_style_frame_padding().y + 2.0f*ui::get_style_frame_border_size(); - Vec2 const dims = Vec2{4.0f, h}; + const Vec2 p = ui::get_cursor_screen_pos(); + const float h = ui::get_text_line_height() + 2.0f*ui::get_style_frame_padding().y + 2.0f*ui::get_style_frame_border_size(); + const Vec2 dims = Vec2{4.0f, h}; l->AddRectFilled(p, p + dims, ui::to_ImU32(color)); ui::set_cursor_screen_pos({p.x + 4.0f, p.y}); } @@ -338,7 +322,7 @@ namespace } std::string GenerateVecFrameAnnotationLabel( - OpenSim::AbstractProperty const& backingProperty, + const OpenSim::AbstractProperty& backingProperty, Vec3::size_type ithDimension) { std::stringstream ss; @@ -357,14 +341,14 @@ namespace class IPropertyEditor { protected: IPropertyEditor() = default; - IPropertyEditor(IPropertyEditor const&) = default; + IPropertyEditor(const IPropertyEditor&) = default; IPropertyEditor(IPropertyEditor&&) noexcept = default; - IPropertyEditor& operator=(IPropertyEditor const&) = default; + IPropertyEditor& operator=(const IPropertyEditor&) = default; IPropertyEditor& operator=(IPropertyEditor&&) noexcept = default; public: virtual ~IPropertyEditor() noexcept = default; - bool isCompatibleWith(OpenSim::AbstractProperty const& prop) const + bool isCompatibleWith(const OpenSim::AbstractProperty& prop) const { return implIsCompatibleWith(prop); } @@ -375,7 +359,7 @@ namespace } private: - virtual bool implIsCompatibleWith(OpenSim::AbstractProperty const&) const = 0; + virtual bool implIsCompatibleWith(const OpenSim::AbstractProperty&) const = 0; virtual std::optional> implOnDraw() = 0; }; diff --git a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.h b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.h index 12452cb2d..8fc984fa4 100644 --- a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.h +++ b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.h @@ -16,12 +16,12 @@ namespace osc public: ObjectPropertiesEditor( IPopupAPI*, - std::shared_ptr targetModel, - std::function objectGetter + std::shared_ptr targetModel, + std::function objectGetter ); - ObjectPropertiesEditor(ObjectPropertiesEditor const&) = delete; + ObjectPropertiesEditor(const ObjectPropertiesEditor&) = delete; ObjectPropertiesEditor(ObjectPropertiesEditor&&) noexcept; - ObjectPropertiesEditor& operator=(ObjectPropertiesEditor const&) = delete; + ObjectPropertiesEditor& operator=(const ObjectPropertiesEditor&) = delete; ObjectPropertiesEditor& operator=(ObjectPropertiesEditor&&) noexcept; ~ObjectPropertiesEditor() noexcept; diff --git a/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.cpp b/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.cpp index 1ac66e53d..48c453499 100644 --- a/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.cpp +++ b/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.cpp @@ -137,9 +137,7 @@ class osc::ParamBlockEditorPopup::Impl final : public StandardPopup { osc::ParamBlockEditorPopup::ParamBlockEditorPopup(std::string_view popupName, ParamBlock* paramBlock) : m_Impl{std::make_unique(popupName, paramBlock)} -{ -} - +{} osc::ParamBlockEditorPopup::ParamBlockEditorPopup(ParamBlockEditorPopup&&) noexcept = default; osc::ParamBlockEditorPopup& osc::ParamBlockEditorPopup::operator=(ParamBlockEditorPopup&&) noexcept = default; osc::ParamBlockEditorPopup::~ParamBlockEditorPopup() noexcept = default; diff --git a/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.h b/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.h index 8eebe638f..ce7cd80c2 100644 --- a/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.h +++ b/src/OpenSimCreator/UI/Shared/ParamBlockEditorPopup.h @@ -16,9 +16,9 @@ namespace osc std::string_view popupName, ParamBlock* ); - ParamBlockEditorPopup(ParamBlockEditorPopup const&) = delete; + ParamBlockEditorPopup(const ParamBlockEditorPopup&) = delete; ParamBlockEditorPopup(ParamBlockEditorPopup&&) noexcept; - ParamBlockEditorPopup& operator=(ParamBlockEditorPopup const&) = delete; + ParamBlockEditorPopup& operator=(const ParamBlockEditorPopup&) = delete; ParamBlockEditorPopup& operator=(ParamBlockEditorPopup&&) noexcept; ~ParamBlockEditorPopup() noexcept; diff --git a/src/OpenSimCreator/UI/Shared/PropertiesPanel.cpp b/src/OpenSimCreator/UI/Shared/PropertiesPanel.cpp index 94c77b169..cad6bb5ce 100644 --- a/src/OpenSimCreator/UI/Shared/PropertiesPanel.cpp +++ b/src/OpenSimCreator/UI/Shared/PropertiesPanel.cpp @@ -25,11 +25,10 @@ using namespace osc; namespace { - void DrawActionsMenu(IEditorAPI* editorAPI, std::shared_ptr const& model) + void DrawActionsMenu(IEditorAPI* editorAPI, const std::shared_ptr& model) { - OpenSim::Component const* selection = model->getSelected(); - if (!selection) - { + const OpenSim::Component* const selection = model->getSelected(); + if (!selection) { return; } @@ -57,10 +56,8 @@ namespace void onDraw() { - OpenSim::Component const* const selected = m_Model->getSelected(); - - if (!selected) - { + const OpenSim::Component* const selected = m_Model->getSelected(); + if (!selected) { return; // don't do anything if nothing is selected } @@ -95,7 +92,7 @@ namespace private: std::shared_ptr m_Model; UID m_LastModelVersion; - OpenSim::Component const* m_LastSelected = nullptr; + const OpenSim::Component* m_LastSelected = nullptr; std::string m_EditedName; }; } @@ -111,8 +108,7 @@ class osc::PropertiesPanel::Impl final : public StandardPanelImpl { m_EditorAPI{editorAPI}, m_Model{std::move(model)}, m_SelectionPropertiesEditor{editorAPI, m_Model, [model = m_Model](){ return model->getSelected(); }} - { - } + {} private: void impl_draw_content() final @@ -124,7 +120,7 @@ class osc::PropertiesPanel::Impl final : public StandardPanelImpl { } ui::push_id(m_Model->getSelected()); - ScopeGuard const g{[]() { ui::pop_id(); }}; + const ScopeGuard g{[]() { ui::pop_id(); }}; // draw an actions row with a button that opens the context menu // @@ -155,16 +151,12 @@ class osc::PropertiesPanel::Impl final : public StandardPanelImpl { }; -// public API (PIMPL) - osc::PropertiesPanel::PropertiesPanel( std::string_view panelName, IEditorAPI* editorAPI, std::shared_ptr model) : m_Impl{std::make_unique(panelName, editorAPI, std::move(model))} -{ -} - +{} osc::PropertiesPanel::PropertiesPanel(PropertiesPanel&&) noexcept = default; osc::PropertiesPanel& osc::PropertiesPanel::operator=(PropertiesPanel&&) noexcept = default; osc::PropertiesPanel::~PropertiesPanel() noexcept = default; diff --git a/src/OpenSimCreator/UI/Shared/PropertiesPanel.h b/src/OpenSimCreator/UI/Shared/PropertiesPanel.h index 99d589e9b..578cd1405 100644 --- a/src/OpenSimCreator/UI/Shared/PropertiesPanel.h +++ b/src/OpenSimCreator/UI/Shared/PropertiesPanel.h @@ -18,9 +18,9 @@ namespace osc IEditorAPI*, std::shared_ptr ); - PropertiesPanel(PropertiesPanel const&) = delete; + PropertiesPanel(const PropertiesPanel&) = delete; PropertiesPanel(PropertiesPanel&&) noexcept; - PropertiesPanel& operator=(PropertiesPanel const&) = delete; + PropertiesPanel& operator=(const PropertiesPanel&) = delete; PropertiesPanel& operator=(PropertiesPanel&&) noexcept; ~PropertiesPanel() noexcept; diff --git a/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.cpp b/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.cpp index df55f40fb..11aea8e03 100644 --- a/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.cpp +++ b/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.cpp @@ -61,7 +61,7 @@ class osc::Readonly3DModelViewer::Impl final { return m_MaybeLastHittest && m_MaybeLastHittest->is_hovered; } - std::optional onDraw(IConstModelStatePair const& rs) + std::optional onDraw(const IConstModelStatePair& rs) { // if this is the first frame being rendered, auto-focus the scene if (!m_MaybeLastHittest) @@ -98,7 +98,7 @@ class osc::Readonly3DModelViewer::Impl final { ); // update current+retained hittest - ui::HittestResult const hittest = ui::hittest_last_drawn_item(); + const ui::HittestResult hittest = ui::hittest_last_drawn_item(); m_MaybeLastHittest = hittest; // if allowed, hittest the scene @@ -114,7 +114,7 @@ class osc::Readonly3DModelViewer::Impl final { // draw 2D ImGui overlays auto renderParamsBefore = m_Params; - bool const edited = DrawViewerImGuiOverlays( + const bool edited = DrawViewerImGuiOverlays( m_Params, m_CachedModelRenderer.getDrawlist(), m_CachedModelRenderer.bounds(), @@ -124,7 +124,7 @@ class osc::Readonly3DModelViewer::Impl final { ); if (edited) { - auto const& renderParamsAfter = m_Params; + const auto& renderParamsAfter = m_Params; SaveModelRendererParamsDifference( renderParamsBefore, renderParamsAfter, @@ -152,12 +152,12 @@ class osc::Readonly3DModelViewer::Impl final { std::nullopt; } - PolarPerspectiveCamera const& getCamera() const + const PolarPerspectiveCamera& getCamera() const { return m_Params.camera; } - void setCamera(PolarPerspectiveCamera const& camera) + void setCamera(const PolarPerspectiveCamera& camera) { m_Params.camera = camera; } @@ -230,7 +230,7 @@ bool osc::Readonly3DModelViewer::isMousedOver() const return m_Impl->isMousedOver(); } -std::optional osc::Readonly3DModelViewer::onDraw(IConstModelStatePair const& rs) +std::optional osc::Readonly3DModelViewer::onDraw(const IConstModelStatePair& rs) { return m_Impl->onDraw(rs); } @@ -240,12 +240,12 @@ std::optional osc::Readonly3DModelViewer::getScreenRect() const return m_Impl->getScreenRect(); } -PolarPerspectiveCamera const& osc::Readonly3DModelViewer::getCamera() const +const PolarPerspectiveCamera& osc::Readonly3DModelViewer::getCamera() const { return m_Impl->getCamera(); } -void osc::Readonly3DModelViewer::setCamera(PolarPerspectiveCamera const& camera) +void osc::Readonly3DModelViewer::setCamera(const PolarPerspectiveCamera& camera) { m_Impl->setCamera(camera); } diff --git a/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.h b/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.h index 041d2b1cf..5a2315e29 100644 --- a/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.h +++ b/src/OpenSimCreator/UI/Shared/Readonly3DModelViewer.h @@ -34,19 +34,19 @@ namespace osc std::string_view parentPanelName_, Readonly3DModelViewerFlags = Readonly3DModelViewerFlags::None ); - Readonly3DModelViewer(Readonly3DModelViewer const&) = delete; + Readonly3DModelViewer(const Readonly3DModelViewer&) = delete; Readonly3DModelViewer(Readonly3DModelViewer&&) noexcept; - Readonly3DModelViewer& operator=(Readonly3DModelViewer const&) = delete; + Readonly3DModelViewer& operator=(const Readonly3DModelViewer&) = delete; Readonly3DModelViewer& operator=(Readonly3DModelViewer&&) noexcept; ~Readonly3DModelViewer() noexcept; bool isMousedOver() const; bool isLeftClicked() const; bool isRightClicked() const; - std::optional onDraw(IConstModelStatePair const&); + std::optional onDraw(const IConstModelStatePair&); std::optional getScreenRect() const; - PolarPerspectiveCamera const& getCamera() const; - void setCamera(PolarPerspectiveCamera const&); + const PolarPerspectiveCamera& getCamera() const; + void setCamera(const PolarPerspectiveCamera&); private: class Impl; diff --git a/src/OpenSimCreator/Utils/SimTKHelpers.cpp b/src/OpenSimCreator/Utils/SimTKHelpers.cpp index ceebfe888..8ff6944bb 100644 --- a/src/OpenSimCreator/Utils/SimTKHelpers.cpp +++ b/src/OpenSimCreator/Utils/SimTKHelpers.cpp @@ -157,6 +157,18 @@ Quat osc::ToQuat(const SimTK::Rotation& r) }; } +std::array osc::ToArray(const SimTK::Vec6& v) +{ + return { + static_cast(v[0]), + static_cast(v[1]), + static_cast(v[2]), + static_cast(v[3]), + static_cast(v[4]), + static_cast(v[5]), + }; +} + Transform osc::decompose_to_transform(const SimTK::Transform& t) { return Transform{.rotation = ToQuat(t.R()), .position = ToVec3(t.p())}; diff --git a/src/OpenSimCreator/Utils/SimTKHelpers.h b/src/OpenSimCreator/Utils/SimTKHelpers.h index 75cb57005..644a5231c 100644 --- a/src/OpenSimCreator/Utils/SimTKHelpers.h +++ b/src/OpenSimCreator/Utils/SimTKHelpers.h @@ -11,6 +11,8 @@ #include #include +#include + namespace osc { struct Color; } namespace osc { struct Transform; } @@ -33,5 +35,6 @@ namespace osc Mat3 ToMat3(const SimTK::Mat33&); Mat4 mat4_cast(const SimTK::Rotation&); Quat ToQuat(const SimTK::Rotation&); + std::array ToArray(const SimTK::Vec6&); Transform decompose_to_transform(const SimTK::Transform&); }