From b562e361c33ae3895a7cd771cf52fb2da323551a Mon Sep 17 00:00:00 2001 From: Adam Kewley Date: Tue, 18 Jun 2024 10:01:24 +0200 Subject: [PATCH] Reformat basic pointer usages to west-const --- .../ComponentRegistry/ComponentRegistry.h | 8 +-- .../ComponentRegistry/ComponentRegistryBase.h | 4 +- .../FrameDefinitionActions.cpp | 10 ++-- .../FrameDefinitionHelpers.cpp | 8 +-- .../Documents/MeshImporter/Document.h | 6 +- .../MeshImporter/DocumentHelpers.cpp | 12 ++-- .../Documents/MeshImporter/IObjectFinder.h | 4 +- .../Documents/MeshImporter/OpenSimBridge.cpp | 50 ++++++++-------- .../MeshImporter/UndoableActions.cpp | 16 ++--- .../MeshWarper/TPSDocumentHelpers.cpp | 14 ++--- .../Documents/MeshWarper/TPSDocumentHelpers.h | 10 ++-- .../Documents/Model/IConstModelStatePair.h | 8 +-- .../Documents/Model/IModelStatePair.h | 8 +-- .../Documents/Model/ObjectPropertyEdit.cpp | 2 +- .../Documents/Model/UndoableModelActions.cpp | 40 ++++++------- .../Model/UndoableModelStatePair.cpp | 46 +++++++------- .../Documents/Model/UndoableModelStatePair.h | 8 +-- .../ModelWarper/CachedModelWarper.cpp | 6 +- .../ModelWarper/FrameWarperFactories.h | 8 +-- .../ModelWarper/ModelWarpDocument.cpp | 14 ++--- .../Documents/ModelWarper/ModelWarpDocument.h | 2 +- .../ModelWarper/PointWarperFactories.h | 8 +-- .../TPSLandmarkPairWarperFactory.cpp | 2 +- .../TPSLandmarkPairWarperFactory.h | 2 +- .../ComponentOutputExtractor.cpp | 8 +-- .../ConcatenatingOutputExtractor.cpp | 2 +- .../IntegratorOutputExtractor.cpp | 2 +- .../MultiBodySystemOutputExtractor.cpp | 2 +- .../Simulation/ForwardDynamicSimulator.cpp | 2 +- .../Simulation/SimulationModelStatePair.cpp | 16 ++--- .../Simulation/SimulationModelStatePair.h | 8 +-- .../ComponentAbsPathDecorationTagger.h | 2 +- .../ComponentSceneDecorationFlagsTagger.cpp | 6 +- .../ComponentSceneDecorationFlagsTagger.h | 10 ++-- .../Graphics/CustomRenderingOptions.cpp | 2 +- .../Graphics/ModelRendererParams.cpp | 6 +- .../Graphics/OpenSimDecorationGenerator.cpp | 26 ++++---- .../Graphics/OpenSimGraphicsHelpers.cpp | 2 +- .../Graphics/OverlayDecorationOptions.cpp | 2 +- .../UI/FrameDefinition/FrameDefinitionTab.cpp | 40 ++++++------- .../UI/MeshImporter/ChooseElLayer.h | 4 +- .../UI/MeshImporter/MeshImporterSharedState.h | 16 ++--- .../UI/MeshImporter/MeshImporterTab.cpp | 30 +++++----- .../UI/MeshWarper/MeshWarpingTabContextMenu.h | 6 +- .../UI/ModelEditor/AddBodyPopup.cpp | 2 +- .../UI/ModelEditor/AddComponentPopup.cpp | 24 ++++---- .../UI/ModelEditor/ComponentContextMenu.cpp | 40 ++++++------- .../UI/ModelEditor/CoordinateEditorPanel.cpp | 4 +- .../UI/ModelEditor/EditorTabStatusBar.cpp | 4 +- .../UI/ModelEditor/ExportPointsPopup.cpp | 10 ++-- .../UI/ModelEditor/ModelMusclePlotPanel.cpp | 34 +++++------ .../UI/ModelEditor/ReassignSocketPopup.cpp | 12 ++-- .../UI/ModelEditor/Select1PFPopup.cpp | 2 +- .../UI/ModelEditor/SelectComponentPopup.cpp | 2 +- src/OpenSimCreator/UI/Shared/BasicWidgets.cpp | 18 +++--- src/OpenSimCreator/UI/Shared/BasicWidgets.h | 6 +- .../UI/Shared/ChooseComponentsEditorLayer.cpp | 4 +- .../UI/Shared/GeometryPathEditorPopup.cpp | 10 ++-- .../UI/Shared/GeometryPathEditorPopup.h | 2 +- .../UI/Shared/ModelEditorViewerPanel.cpp | 2 +- .../UI/Shared/ModelSelectionGizmo.cpp | 26 ++++---- .../UI/Shared/NavigatorPanel.cpp | 26 ++++---- .../UI/Shared/ObjectPropertiesEditor.cpp | 60 +++++++++---------- 63 files changed, 388 insertions(+), 388 deletions(-) diff --git a/src/OpenSimCreator/ComponentRegistry/ComponentRegistry.h b/src/OpenSimCreator/ComponentRegistry/ComponentRegistry.h index ccc73eb16..abda52bd3 100644 --- a/src/OpenSimCreator/ComponentRegistry/ComponentRegistry.h +++ b/src/OpenSimCreator/ComponentRegistry/ComponentRegistry.h @@ -24,16 +24,16 @@ namespace osc ComponentRegistryBase{name_, description_} {} - value_type const* begin() const + const value_type* begin() const { const auto& base = static_cast(*this); - return static_cast(base.begin()); + return static_cast(base.begin()); } - value_type const* end() const + const value_type* end() const { const auto& base = static_cast(*this); - return static_cast(base.end()); + return static_cast(base.end()); } const value_type& operator[](size_t i) const diff --git a/src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.h b/src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.h index ae47da179..81306f2bf 100644 --- a/src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.h +++ b/src/OpenSimCreator/ComponentRegistry/ComponentRegistryBase.h @@ -22,8 +22,8 @@ namespace osc CStringView name() const { return m_Name; } CStringView description() const { return m_Description; } - value_type const* begin() const { return m_Entries.data(); } - value_type const* end() const { return m_Entries.data() + m_Entries.size(); } + const value_type* begin() const { return m_Entries.data(); } + const value_type* end() const { return m_Entries.data() + m_Entries.size(); } size_t size() const { return m_Entries.size(); } const value_type& operator[](size_t i) const { return m_Entries[i]; } diff --git a/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionActions.cpp b/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionActions.cpp index cb41f3e62..62f22e230 100644 --- a/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionActions.cpp +++ b/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionActions.cpp @@ -277,28 +277,28 @@ void osc::fd::ActionCreateBodyFromFrame( // validate external inputs log_debug("validate external inputs"); - auto const* const meshFrame = FindComponent(model->getModel(), frameAbsPath); + const auto* const meshFrame = FindComponent(model->getModel(), frameAbsPath); if (!meshFrame) { log_error("%s: cannot find frame: skipping body creation", frameAbsPath.toString().c_str()); return; } - auto const* const mesh = FindComponent(model->getModel(), meshAbsPath); + const auto* const mesh = FindComponent(model->getModel(), meshAbsPath); if (!mesh) { log_error("%s: cannot find mesh: skipping body creation", meshAbsPath.toString().c_str()); return; } - auto const* const jointFrame = FindComponent(model->getModel(), jointFrameAbsPath); + const auto* const jointFrame = FindComponent(model->getModel(), jointFrameAbsPath); if (!jointFrame) { log_error("%s: cannot find joint frame: skipping body creation", jointFrameAbsPath.toString().c_str()); return; } - auto const* const parentFrame = FindComponent(model->getModel(), parentFrameAbsPath); + const auto* const parentFrame = FindComponent(model->getModel(), parentFrameAbsPath); if (!parentFrame) { log_error("%s: cannot find parent frame: skipping body creation", parentFrameAbsPath.toString().c_str()); @@ -386,7 +386,7 @@ void osc::fd::ActionCreateBodyFromFrame( // if the mesh's PoF was only used by the mesh then reassign // everything to the new PoF and delete the old one - if (auto const* pof = GetOwner(*mesh); + if (const auto* pof = GetOwner(*mesh); pof && GetNumChildren(*pof) == 3) // mesh+frame geom+wrap object set { log_debug("reassign sockets"); diff --git a/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionHelpers.cpp b/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionHelpers.cpp index dc5c34a5f..50789b973 100644 --- a/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionHelpers.cpp +++ b/src/OpenSimCreator/Documents/FrameDefinition/FrameDefinitionHelpers.cpp @@ -161,22 +161,22 @@ void osc::fd::SetupDefault3DViewportRenderingParams(ModelRendererParams& renderP bool osc::fd::IsPoint(const OpenSim::Component& component) { - return dynamic_cast(&component) != nullptr; + return dynamic_cast(&component) != nullptr; } bool osc::fd::IsMesh(const OpenSim::Component& component) { - return dynamic_cast(&component) != nullptr; + return dynamic_cast(&component) != nullptr; } bool osc::fd::IsPhysicalFrame(const OpenSim::Component& component) { - return dynamic_cast(&component) != nullptr; + return dynamic_cast(&component) != nullptr; } bool osc::fd::IsEdge(const OpenSim::Component& component) { - return dynamic_cast(&component) != nullptr; + return dynamic_cast(&component) != nullptr; } SimTK::UnitVec3 osc::fd::CalcDirection(const EdgePoints& a) diff --git a/src/OpenSimCreator/Documents/MeshImporter/Document.h b/src/OpenSimCreator/Documents/MeshImporter/Document.h index 64bbe2ebd..6555b98c2 100644 --- a/src/OpenSimCreator/Documents/MeshImporter/Document.h +++ b/src/OpenSimCreator/Documents/MeshImporter/Document.h @@ -233,7 +233,7 @@ namespace osc::mi bool deleteByID(UID id) { - MIObject const* const obj = tryGetByID(id); + const MIObject* const obj = tryGetByID(id); if (!obj) { return false; // ID doesn't exist in the document @@ -291,7 +291,7 @@ namespace osc::mi void select(UID id) { - MIObject const* const e = tryGetByID(id); + const MIObject* const e = tryGetByID(id); if (e && e->canSelect()) { @@ -389,7 +389,7 @@ namespace osc::mi return *ptr; } - MIObject const* implFind(UID id) const final + const MIObject* implFind(UID id) const final { return findByID(m_Objects, id); } diff --git a/src/OpenSimCreator/Documents/MeshImporter/DocumentHelpers.cpp b/src/OpenSimCreator/Documents/MeshImporter/DocumentHelpers.cpp index 11476ae6b..4f8e49d68 100644 --- a/src/OpenSimCreator/Documents/MeshImporter/DocumentHelpers.cpp +++ b/src/OpenSimCreator/Documents/MeshImporter/DocumentHelpers.cpp @@ -68,7 +68,7 @@ bool osc::mi::IsJointAttachedToGround( return true; // it's directly attached to ground } - auto const* const parent = doc.tryGetByID(joint.getParentID()); + const auto* const parent = doc.tryGetByID(joint.getParentID()); if (!parent) { return false; // joint's parent is garbage @@ -185,12 +185,12 @@ bool osc::mi::IsInSelectionGroupOf( return true; } - Body const* body = nullptr; - if (auto const* be = doc.tryGetByID(parent)) + const Body* body = nullptr; + if (const auto* be = doc.tryGetByID(parent)) { body = be; } - else if (auto const* me = doc.tryGetByID(parent)) + else if (const auto* me = doc.tryGetByID(parent)) { body = doc.tryGetByID(me->getParentID()); } @@ -200,11 +200,11 @@ bool osc::mi::IsInSelectionGroupOf( return false; // parent isn't attached to any body (or isn't a body) } - if (auto const* be = doc.tryGetByID(id)) + if (const auto* be = doc.tryGetByID(id)) { return be->getID() == body->getID(); } - else if (auto const* me = doc.tryGetByID(id)) + else if (const auto* me = doc.tryGetByID(id)) { return me->getParentID() == body->getID(); } diff --git a/src/OpenSimCreator/Documents/MeshImporter/IObjectFinder.h b/src/OpenSimCreator/Documents/MeshImporter/IObjectFinder.h index e4e292006..f9425dfd1 100644 --- a/src/OpenSimCreator/Documents/MeshImporter/IObjectFinder.h +++ b/src/OpenSimCreator/Documents/MeshImporter/IObjectFinder.h @@ -17,11 +17,11 @@ namespace osc::mi public: virtual ~IObjectFinder() noexcept = default; - MIObject const* find(UID id) const + const MIObject* find(UID id) const { return implFind(id); } private: - virtual MIObject const* implFind(UID) const = 0; + virtual const MIObject* implFind(UID) const = 0; }; } diff --git a/src/OpenSimCreator/Documents/MeshImporter/OpenSimBridge.cpp b/src/OpenSimCreator/Documents/MeshImporter/OpenSimBridge.cpp index 26e4aa3c8..8373b3d53 100644 --- a/src/OpenSimCreator/Documents/MeshImporter/OpenSimBridge.cpp +++ b/src/OpenSimCreator/Documents/MeshImporter/OpenSimBridge.cpp @@ -132,7 +132,7 @@ namespace struct JointAttachmentCachedLookupResult final { // can be nullptr (indicating Ground) - Body const* bodyEl = nullptr; + const Body* bodyEl = nullptr; // can be nullptr (indicating ground/cache hit) std::unique_ptr createdBody; @@ -216,11 +216,11 @@ namespace // returns the indices of each degree of freedom that the joint supports JointDegreesOfFreedom GetDegreesOfFreedom(const OpenSim::Joint& joint) { - if (dynamic_cast(&joint)) + if (dynamic_cast(&joint)) { return JointDegreesOfFreedom{{0, 1, 2}, {3, 4, 5}}; } - else if (dynamic_cast(&joint)) + else if (dynamic_cast(&joint)) { return JointDegreesOfFreedom{{-1, -1, 0}, {-1, -1, -1}}; } @@ -420,28 +420,28 @@ namespace // tries to find the first body connected to the given PhysicalFrame by assuming // that the frame is either already a body or is an offset to a body - OpenSim::PhysicalFrame const* TryInclusiveRecurseToBodyOrGround( + const OpenSim::PhysicalFrame* TryInclusiveRecurseToBodyOrGround( const OpenSim::Frame& f, - std::unordered_set visitedFrames) + std::unordered_set visitedFrames) { if (!visitedFrames.emplace(&f).second) { return nullptr; } - if (auto const* body = dynamic_cast(&f)) + if (const auto* body = dynamic_cast(&f)) { return body; } - else if (auto const* ground = dynamic_cast(&f)) + else if (const auto* ground = dynamic_cast(&f)) { return ground; } - else if (auto const* pof = dynamic_cast(&f)) + else if (const auto* pof = dynamic_cast(&f)) { return TryInclusiveRecurseToBodyOrGround(pof->getParentFrame(), visitedFrames); } - else if (auto const* station = dynamic_cast(&f)) + else if (const auto* station = dynamic_cast(&f)) { return TryInclusiveRecurseToBodyOrGround(station->getParentFrame(), visitedFrames); } @@ -453,7 +453,7 @@ namespace // tries to find the first body connected to the given PhysicalFrame by assuming // that the frame is either already a body or is an offset to a body - OpenSim::PhysicalFrame const* TryInclusiveRecurseToBodyOrGround(const OpenSim::Frame& f) + const OpenSim::PhysicalFrame* TryInclusiveRecurseToBodyOrGround(const OpenSim::Frame& f) { return TryInclusiveRecurseToBodyOrGround(f, {}); } @@ -468,10 +468,10 @@ namespace Document rv; // used to figure out how a body in the OpenSim::Model maps into the docuemnt - std::unordered_map bodyLookup; + std::unordered_map bodyLookup; // used to figure out how a joint in the OpenSim::Model maps into the document - std::unordered_map jointLookup; + std::unordered_map jointLookup; // import all the bodies from the model file for (const OpenSim::Body& b : m.getComponentList()) @@ -491,8 +491,8 @@ namespace const OpenSim::PhysicalFrame& parentFrame = j.getParentFrame(); const OpenSim::PhysicalFrame& childFrame = j.getChildFrame(); - OpenSim::PhysicalFrame const* const parentBodyOrGround = TryInclusiveRecurseToBodyOrGround(parentFrame); - OpenSim::PhysicalFrame const* const childBodyOrGround = TryInclusiveRecurseToBodyOrGround(childFrame); + const OpenSim::PhysicalFrame* const parentBodyOrGround = TryInclusiveRecurseToBodyOrGround(parentFrame); + const OpenSim::PhysicalFrame* const childBodyOrGround = TryInclusiveRecurseToBodyOrGround(childFrame); if (!parentBodyOrGround || !childBodyOrGround) { @@ -501,13 +501,13 @@ namespace } UID parent = MIIDs::Empty(); - if (dynamic_cast(parentBodyOrGround)) + if (dynamic_cast(parentBodyOrGround)) { parent = MIIDs::Ground(); } else { - if (auto const* body = lookup_or_nullptr(bodyLookup, dynamic_cast(parentBodyOrGround))) { + if (const auto* body = lookup_or_nullptr(bodyLookup, dynamic_cast(parentBodyOrGround))) { parent = *body; } else { @@ -516,14 +516,14 @@ namespace } UID child = MIIDs::Empty(); - if (dynamic_cast(childBodyOrGround)) + if (dynamic_cast(childBodyOrGround)) { // ground can't be a child in a joint continue; } else { - if (auto const* body = lookup_or_nullptr(bodyLookup, dynamic_cast(childBodyOrGround))) { + if (const auto* body = lookup_or_nullptr(bodyLookup, dynamic_cast(childBodyOrGround))) { child = *body; } else { @@ -568,7 +568,7 @@ namespace } const OpenSim::Frame& frame = mesh.getFrame(); - OpenSim::PhysicalFrame const* const frameBodyOrGround = TryInclusiveRecurseToBodyOrGround(frame); + const OpenSim::PhysicalFrame* const frameBodyOrGround = TryInclusiveRecurseToBodyOrGround(frame); if (!frameBodyOrGround) { @@ -577,13 +577,13 @@ namespace } UID attachment = MIIDs::Empty(); - if (dynamic_cast(frameBodyOrGround)) + if (dynamic_cast(frameBodyOrGround)) { attachment = MIIDs::Ground(); } else { - if (auto const* body = lookup_or_nullptr(bodyLookup, dynamic_cast(frameBodyOrGround))) { + if (const auto* body = lookup_or_nullptr(bodyLookup, dynamic_cast(frameBodyOrGround))) { attachment = *body; } else { @@ -609,7 +609,7 @@ namespace for (const OpenSim::Station& station : m.getComponentList()) { // edge-case: it's a path point: ignore it because it will spam the converter - if (dynamic_cast(&station)) + if (dynamic_cast(&station)) { continue; } @@ -620,16 +620,16 @@ namespace } const OpenSim::PhysicalFrame& frame = station.getParentFrame(); - OpenSim::PhysicalFrame const* const frameBodyOrGround = TryInclusiveRecurseToBodyOrGround(frame); + const OpenSim::PhysicalFrame* const frameBodyOrGround = TryInclusiveRecurseToBodyOrGround(frame); UID attachment = MIIDs::Empty(); - if (dynamic_cast(frameBodyOrGround)) + if (dynamic_cast(frameBodyOrGround)) { attachment = MIIDs::Ground(); } else { - if (auto const it = bodyLookup.find(dynamic_cast(frameBodyOrGround)); it != bodyLookup.end()) + if (auto const it = bodyLookup.find(dynamic_cast(frameBodyOrGround)); it != bodyLookup.end()) { attachment = it->second; } diff --git a/src/OpenSimCreator/Documents/MeshImporter/UndoableActions.cpp b/src/OpenSimCreator/Documents/MeshImporter/UndoableActions.cpp index 0c11cf2f1..187a68e5a 100644 --- a/src/OpenSimCreator/Documents/MeshImporter/UndoableActions.cpp +++ b/src/OpenSimCreator/Documents/MeshImporter/UndoableActions.cpp @@ -172,13 +172,13 @@ bool osc::mi::TryTranslateBetweenTwoObjects( return false; } - MIObject const* const objA = doc.tryGetByID(a); + const MIObject* const objA = doc.tryGetByID(a); if (!objA) { return false; } - MIObject const* const objB = doc.tryGetByID(b); + const MIObject* const objB = doc.tryGetByID(b); if (!objB) { return false; @@ -203,7 +203,7 @@ bool osc::mi::TryTranslateObjectToAnotherObject( return false; } - MIObject const* const otherObj = doc.tryGetByID(other); + const MIObject* const otherObj = doc.tryGetByID(other); if (!otherObj) { return false; @@ -228,7 +228,7 @@ bool osc::mi::TryTranslateToMeshAverageCenter( return false; } - auto const* const mesh = doc.tryGetByID(meshID); + const auto* const mesh = doc.tryGetByID(meshID); if (!mesh) { return false; @@ -253,7 +253,7 @@ bool osc::mi::TryTranslateToMeshBoundsCenter( return false; } - auto const* const mesh = doc.tryGetByID(meshID); + const auto* const mesh = doc.tryGetByID(meshID); if (!mesh) { return false; @@ -280,7 +280,7 @@ bool osc::mi::TryTranslateToMeshMassCenter( return false; } - auto const* const mesh = doc.tryGetByID(meshID); + const auto* const mesh = doc.tryGetByID(meshID); if (!mesh) { return false; @@ -379,7 +379,7 @@ bool osc::mi::TryCopyOrientation( return false; } - MIObject const* const otherObj = doc.tryGetByID(other); + const MIObject* const otherObj = doc.tryGetByID(other); if (!otherObj) { return false; @@ -453,7 +453,7 @@ bool osc::mi::AddStationAtLocation( { Document& doc = udoc.upd_scratch(); - auto const* const obj = doc.tryGetByID(attachment); + const auto* const obj = doc.tryGetByID(attachment); if (!obj) { return false; diff --git a/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.cpp b/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.cpp index fc89ab043..522ebe5f6 100644 --- a/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.cpp +++ b/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.cpp @@ -92,7 +92,7 @@ namespace } } -TPSDocumentLandmarkPair const* osc::FindLandmarkPair(const TPSDocument& doc, UID uid) +const TPSDocumentLandmarkPair* osc::FindLandmarkPair(const TPSDocument& doc, UID uid) { return FindLandmarkPairImpl(doc, uid); } @@ -102,7 +102,7 @@ TPSDocumentLandmarkPair* osc::FindLandmarkPair(TPSDocument& doc, UID uid) return FindLandmarkPairImpl(doc, uid); } -TPSDocumentNonParticipatingLandmark const* osc::FindNonParticipatingLandmark(const TPSDocument& doc, UID id) +const TPSDocumentNonParticipatingLandmark* osc::FindNonParticipatingLandmark(const TPSDocument& doc, UID id) { return FindNonParticipatingLandmarkImpl(doc, id); } @@ -112,13 +112,13 @@ TPSDocumentNonParticipatingLandmark* osc::FindNonParticipatingLandmark(TPSDocume return FindNonParticipatingLandmarkImpl(doc, id); } -TPSDocumentElement const* osc::FindElement(const TPSDocument& doc, const TPSDocumentElementID& id) +const TPSDocumentElement* osc::FindElement(const TPSDocument& doc, const TPSDocumentElementID& id) { static_assert(num_options() == 2); switch (id.type) { case TPSDocumentElementType::Landmark: - if (auto const* p = FindLandmarkPair(doc, id.uid); p && GetLocation(*p, id.input)) + if (const auto* p = FindLandmarkPair(doc, id.uid); p && GetLocation(*p, id.input)) { return p; } @@ -131,7 +131,7 @@ TPSDocumentElement const* osc::FindElement(const TPSDocument& doc, const TPSDocu } } -TPSDocumentLandmarkPair const* osc::FindLandmarkPairByName(const TPSDocument& doc, const StringName& name) +const TPSDocumentLandmarkPair* osc::FindLandmarkPairByName(const TPSDocument& doc, const StringName& name) { return find_or_nullptr(doc.landmarkPairs, name, name_of); } @@ -141,7 +141,7 @@ TPSDocumentLandmarkPair* osc::FindLandmarkPairByName(TPSDocument& doc, const Str return find_or_nullptr(doc.landmarkPairs, name, name_of); } -TPSDocumentNonParticipatingLandmark const* osc::FindNonParticipatingLandmarkByName(const TPSDocument& doc, const StringName& name) +const TPSDocumentNonParticipatingLandmark* osc::FindNonParticipatingLandmarkByName(const TPSDocument& doc, const StringName& name) { return find_or_nullptr(doc.nonParticipatingLandmarks, name, name_of); } @@ -335,7 +335,7 @@ CStringView osc::FindElementNameOr( const TPSDocumentElementID& id, CStringView alternative) { - if (auto const* p = FindElement(doc, id)) + if (const auto* p = FindElement(doc, id)) { return p->getName(); } diff --git a/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.h b/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.h index 57cf64ed1..817b259a3 100644 --- a/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.h +++ b/src/OpenSimCreator/Documents/MeshWarper/TPSDocumentHelpers.h @@ -22,20 +22,20 @@ namespace osc { // if it exists in the document, returns a pointer to the identified landmark pair; otherwise, returns `nullptr` - TPSDocumentLandmarkPair const* FindLandmarkPair(const TPSDocument&, UID); + const TPSDocumentLandmarkPair* FindLandmarkPair(const TPSDocument&, UID); TPSDocumentLandmarkPair* FindLandmarkPair(TPSDocument&, UID); // if it exists in the document, returns a pointer to the identified non-participating landmark; otherwise, returns `nullptr` - TPSDocumentNonParticipatingLandmark const* FindNonParticipatingLandmark(const TPSDocument&, UID); + const TPSDocumentNonParticipatingLandmark* FindNonParticipatingLandmark(const TPSDocument&, UID); TPSDocumentNonParticipatingLandmark* FindNonParticipatingLandmark(TPSDocument&, UID); // if it exists in the document, returns a pointer to the identified element; otherwise, returns `nullptr` - TPSDocumentElement const* FindElement(const TPSDocument& doc, const TPSDocumentElementID&); + const TPSDocumentElement* FindElement(const TPSDocument& doc, const TPSDocumentElementID&); // if it exists in the document, returns a pointer to the landmark that has the given name; otherwise, returns `nullptr` - TPSDocumentLandmarkPair const* FindLandmarkPairByName(const TPSDocument&, const StringName&); + const TPSDocumentLandmarkPair* FindLandmarkPairByName(const TPSDocument&, const StringName&); TPSDocumentLandmarkPair* FindLandmarkPairByName(TPSDocument&, const StringName&); - TPSDocumentNonParticipatingLandmark const* FindNonParticipatingLandmarkByName(const TPSDocument&, const StringName&); + const TPSDocumentNonParticipatingLandmark* FindNonParticipatingLandmarkByName(const TPSDocument&, const StringName&); TPSDocumentNonParticipatingLandmark* FindNonParticipatingLandmarkByName(TPSDocument&, const StringName&); // returns `true` if the document contains an element (landmark, non-participating landmark, etc.) with the given name diff --git a/src/OpenSimCreator/Documents/Model/IConstModelStatePair.h b/src/OpenSimCreator/Documents/Model/IConstModelStatePair.h index acaf7cd25..da327a0dc 100644 --- a/src/OpenSimCreator/Documents/Model/IConstModelStatePair.h +++ b/src/OpenSimCreator/Documents/Model/IConstModelStatePair.h @@ -38,7 +38,7 @@ namespace osc return implGetStateVersion(); } - OpenSim::Component const* getSelected() const + const OpenSim::Component* getSelected() const { return implGetSelected(); } @@ -49,7 +49,7 @@ namespace osc return dynamic_cast(getSelected()); } - OpenSim::Component const* getHovered() const + const OpenSim::Component* getHovered() const { return implGetHovered(); } @@ -77,12 +77,12 @@ namespace osc return UID{}; } - virtual OpenSim::Component const* implGetSelected() const + virtual const OpenSim::Component* implGetSelected() const { return nullptr; } - virtual OpenSim::Component const* implGetHovered() const + virtual const OpenSim::Component* implGetHovered() const { return nullptr; } diff --git a/src/OpenSimCreator/Documents/Model/IModelStatePair.h b/src/OpenSimCreator/Documents/Model/IModelStatePair.h index b0f623e9c..a6833815c 100644 --- a/src/OpenSimCreator/Documents/Model/IModelStatePair.h +++ b/src/OpenSimCreator/Documents/Model/IModelStatePair.h @@ -18,12 +18,12 @@ namespace osc public: virtual ~IModelStatePair() noexcept = default; - void setSelected(OpenSim::Component const* newSelection) + void setSelected(const OpenSim::Component* newSelection) { implSetSelected(newSelection); } - void setHovered(OpenSim::Component const* newHover) + void setHovered(const OpenSim::Component* newHover) { implSetHovered(newHover); } @@ -33,8 +33,8 @@ namespace osc implSetFixupScaleFactor(newScaleFactor); } private: - virtual void implSetSelected(OpenSim::Component const*) {} - virtual void implSetHovered(OpenSim::Component const*) {} + virtual void implSetSelected(const OpenSim::Component*) {} + virtual void implSetHovered(const OpenSim::Component*) {} virtual void implSetFixupScaleFactor(float) {} }; } diff --git a/src/OpenSimCreator/Documents/Model/ObjectPropertyEdit.cpp b/src/OpenSimCreator/Documents/Model/ObjectPropertyEdit.cpp index 436b2f6dc..7828b026f 100644 --- a/src/OpenSimCreator/Documents/Model/ObjectPropertyEdit.cpp +++ b/src/OpenSimCreator/Documents/Model/ObjectPropertyEdit.cpp @@ -18,7 +18,7 @@ namespace // an empty string std::string GetAbsPathOrEmptyIfNotAComponent(const OpenSim::Object& obj) { - if (auto const* c = dynamic_cast(&obj)) { + if (const auto* c = dynamic_cast(&obj)) { return GetAbsolutePathString(*c); } else { diff --git a/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp b/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp index 17017b207..70c81165f 100644 --- a/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp +++ b/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp @@ -188,7 +188,7 @@ namespace const OpenSim::Object& newConnectee, const SimTK::State& state) { - auto const* const newFrame = dynamic_cast(&newConnectee); + const auto* const newFrame = dynamic_cast(&newConnectee); if (!newFrame) { return false; // new connectee isn't a frame @@ -305,7 +305,7 @@ bool osc::ActionSaveModel(IMainUIStateAPI&, UndoableModelStatePair& model) void osc::ActionTryDeleteSelectionFromEditedModel(UndoableModelStatePair& uim) { - OpenSim::Component const* const selected = uim.getSelected(); + const OpenSim::Component* const selected = uim.getSelected(); if (!selected) { @@ -670,7 +670,7 @@ bool osc::ActionSimulateAgainstAllIntegrators( bool osc::ActionAddOffsetFrameToPhysicalFrame(UndoableModelStatePair& uim, const OpenSim::ComponentPath& path) { - auto const* const target = FindComponent(uim.getModel(), path); + const auto* const target = FindComponent(uim.getModel(), path); if (!target) { return false; @@ -713,7 +713,7 @@ bool osc::ActionAddOffsetFrameToPhysicalFrame(UndoableModelStatePair& uim, const bool osc::CanRezeroJoint(UndoableModelStatePair& uim, const OpenSim::ComponentPath& jointPath) { - auto const* const joint = FindComponent(uim.getModel(), jointPath); + const auto* const joint = FindComponent(uim.getModel(), jointPath); if (!joint) { return false; @@ -724,18 +724,18 @@ bool osc::CanRezeroJoint(UndoableModelStatePair& uim, const OpenSim::ComponentPa // point is whatever the current arrangement is (effectively, by pre-transforming // the parent into the child and assuming a "zeroed" joint is an identity op) - return dynamic_cast(&joint->getParentFrame()) != nullptr; + return dynamic_cast(&joint->getParentFrame()) != nullptr; } bool osc::ActionRezeroJoint(UndoableModelStatePair& uim, const OpenSim::ComponentPath& jointPath) { - auto const* const target = FindComponent(uim.getModel(), jointPath); + const auto* const target = FindComponent(uim.getModel(), jointPath); if (!target) { return false; // nothing/invalid component type specified } - auto const* const parentPOF = dynamic_cast(&target->getParentFrame()); + const auto* const parentPOF = dynamic_cast(&target->getParentFrame()); if (!parentPOF) { return false; // target has no parent frame @@ -800,7 +800,7 @@ bool osc::ActionRezeroJoint(UndoableModelStatePair& uim, const OpenSim::Componen bool osc::ActionAddParentOffsetFrameToJoint(UndoableModelStatePair& uim, const OpenSim::ComponentPath& jointPath) { - auto const* const target = FindComponent(uim.getModel(), jointPath); + const auto* const target = FindComponent(uim.getModel(), jointPath); if (!target) { return false; @@ -842,7 +842,7 @@ bool osc::ActionAddParentOffsetFrameToJoint(UndoableModelStatePair& uim, const O bool osc::ActionAddChildOffsetFrameToJoint(UndoableModelStatePair& uim, const OpenSim::ComponentPath& jointPath) { - auto const* const target = FindComponent(uim.getModel(), jointPath); + const auto* const target = FindComponent(uim.getModel(), jointPath); if (!target) { return false; @@ -889,7 +889,7 @@ bool osc::ActionSetComponentName(UndoableModelStatePair& uim, const OpenSim::Com return false; } - OpenSim::Component const* const target = FindComponent(uim.getModel(), path); + const OpenSim::Component* const target = FindComponent(uim.getModel(), path); if (!target) { return false; @@ -936,14 +936,14 @@ bool osc::ActionChangeJointTypeTo(UndoableModelStatePair& uim, const OpenSim::Co return false; } - auto const* const target = FindComponent(uim.getModel(), jointPath); + const auto* const target = FindComponent(uim.getModel(), jointPath); if (!target) { log_error("could not find %s in the model", jointPath.toString().c_str()); return false; } - auto const* const owner = GetOwner(*target); + const auto* const owner = GetOwner(*target); if (!owner) { log_error("%s is not owned by an OpenSim::JointSet", jointPath.toString().c_str()); @@ -1004,7 +1004,7 @@ bool osc::ActionChangeJointTypeTo(UndoableModelStatePair& uim, const OpenSim::Co bool osc::ActionAttachGeometryToPhysicalFrame(UndoableModelStatePair& uim, const OpenSim::ComponentPath& physFramePath, std::unique_ptr geom) { - auto const* const target = FindComponent(uim.getModel(), physFramePath); + const auto* const target = FindComponent(uim.getModel(), physFramePath); if (!target) { return false; @@ -1048,13 +1048,13 @@ bool osc::ActionAssignContactGeometryToHCF( const OpenSim::ComponentPath& hcfPath, const OpenSim::ComponentPath& contactGeomPath) { - auto const* const target = FindComponent(uim.getModel(), hcfPath); + const auto* const target = FindComponent(uim.getModel(), hcfPath); if (!target) { return false; } - auto const* const geom = FindComponent(uim.getModel(), contactGeomPath); + const auto* const geom = FindComponent(uim.getModel(), contactGeomPath); if (!geom) { return false; @@ -1142,13 +1142,13 @@ bool osc::ActionAddPathPointToPathActuator( const OpenSim::ComponentPath& pathActuatorPath, const OpenSim::ComponentPath& pointPhysFrame) { - auto const* const pa = FindComponent(uim.getModel(), pathActuatorPath); + const auto* const pa = FindComponent(uim.getModel(), pathActuatorPath); if (!pa) { return false; } - auto const* const pf = FindComponent(uim.getModel(), pointPhysFrame); + const auto* const pf = FindComponent(uim.getModel(), pointPhysFrame); if (!pf) { return false; @@ -1179,7 +1179,7 @@ bool osc::ActionAddPathPointToPathActuator( // try to select the new path point, if possible, so that the user // can immediately see the grab handles etc. (#779) - if (auto const* paAfterFinalization = FindComponent(mutModel, pathActuatorPath)) + if (const auto* paAfterFinalization = FindComponent(mutModel, pathActuatorPath)) { const auto& pps = paAfterFinalization->getGeometryPath().getPathPointSet(); if (!empty(pps)) @@ -1222,7 +1222,7 @@ bool osc::ActionReassignComponentSocket( return false; } - OpenSim::Component const* const target = FindComponent(uim.getModel(), componentAbsPath); + const OpenSim::Component* const target = FindComponent(uim.getModel(), componentAbsPath); if (!target) { return false; @@ -1292,7 +1292,7 @@ osc::BodyDetails::BodyDetails() : bool osc::ActionAddBodyToModel(UndoableModelStatePair& uim, const BodyDetails& details) { - auto const* const parent = FindComponent(uim.getModel(), details.parentFrameAbsPath); + const auto* const parent = FindComponent(uim.getModel(), details.parentFrameAbsPath); if (!parent) { return false; diff --git a/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.cpp b/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.cpp index 358797d04..6af4140e6 100644 --- a/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.cpp +++ b/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.cpp @@ -126,12 +126,12 @@ namespace m_MaybeSelected = p; } - OpenSim::Component const* implGetSelected() const final + const OpenSim::Component* implGetSelected() const final { return FindComponent(*m_Model, m_MaybeSelected); } - void implSetSelected(OpenSim::Component const* c) final + void implSetSelected(const OpenSim::Component* c) final { m_MaybeSelected = GetAbsolutePathOrEmpty(c); } @@ -146,12 +146,12 @@ namespace m_MaybeHovered = p; } - OpenSim::Component const* implGetHovered() const final + const OpenSim::Component* implGetHovered() const final { return FindComponent(*m_Model, m_MaybeHovered); } - void implSetHovered(OpenSim::Component const* c) final + void implSetHovered(const OpenSim::Component* c) final { m_MaybeHovered = GetAbsolutePathOrEmpty(c); } @@ -266,7 +266,7 @@ class osc::UndoableModelStatePair::Impl final { bool canUndo() const { - ModelStateCommit const* c = tryGetCommitByID(m_CurrentHead); + const ModelStateCommit* c = tryGetCommitByID(m_CurrentHead); return c ? hasCommit(c->getParentID()) : false; } @@ -372,22 +372,22 @@ class osc::UndoableModelStatePair::Impl final { m_Scratch.setFixupScaleFactor(v); } - OpenSim::Component const* getSelected() const + const OpenSim::Component* getSelected() const { return m_Scratch.getSelected(); } - void setSelected(OpenSim::Component const* c) + void setSelected(const OpenSim::Component* c) { m_Scratch.setSelected(c); } - OpenSim::Component const* getHovered() const + const OpenSim::Component* getHovered() const { return m_Scratch.getHovered(); } - void setHovered(OpenSim::Component const* c) + void setHovered(const OpenSim::Component* c) { m_Scratch.setHovered(c); } @@ -409,7 +409,7 @@ class osc::UndoableModelStatePair::Impl final { } // try to lookup a commit by its ID - ModelStateCommit const* tryGetCommitByID(UID id) const + const ModelStateCommit* tryGetCommitByID(UID id) const { return lookup_or_nullptr(m_Commits, id); } @@ -425,7 +425,7 @@ class osc::UndoableModelStatePair::Impl final { // try to lookup the *parent* of a given commit, or return an empty (senteniel) ID UID tryGetParentIDOrEmpty(UID id) const { - ModelStateCommit const* commit = tryGetCommitByID(id); + const ModelStateCommit* commit = tryGetCommitByID(id); return commit ? commit->getParentID() : UID::empty(); } @@ -462,14 +462,14 @@ class osc::UndoableModelStatePair::Impl final { // (e.g. n==0 returns `a`, n==1 returns `a`'s parent, n==2 returns `a`'s grandparent) // // returns `nullptr` if there are insufficient ancestors. `n` must be >= 0 - ModelStateCommit const* nthAncestor(UID a, int n) const + const ModelStateCommit* nthAncestor(UID a, int n) const { if (n < 0) { return nullptr; } - ModelStateCommit const* c = tryGetCommitByID(a); + const ModelStateCommit* c = tryGetCommitByID(a); if (!c || n == 0) { @@ -491,14 +491,14 @@ class osc::UndoableModelStatePair::Impl final { // returns the UID that is the nth ancestor from `a`, or empty if there are insufficient ancestors UID nthAncestorID(UID a, int n) const { - ModelStateCommit const* c = nthAncestor(a, n); + const ModelStateCommit* c = nthAncestor(a, n); return c ? c->getID() : UID::empty(); } // returns `true` if `maybeAncestor` is an ancestor of `id` bool isAncestor(UID maybeAncestor, UID id) { - ModelStateCommit const* c = tryGetCommitByID(id); + const ModelStateCommit* c = tryGetCommitByID(id); while (c != nullptr && c->getID() != maybeAncestor) { @@ -580,7 +580,7 @@ class osc::UndoableModelStatePair::Impl final { // scratch space - things like reset and scaling state, which the // user might expect to be maintained even if a crash happened - ModelStateCommit const* c = tryGetCommitByID(m_CurrentHead); + const ModelStateCommit* c = tryGetCommitByID(m_CurrentHead); if (c) { @@ -596,14 +596,14 @@ class osc::UndoableModelStatePair::Impl final { // effectively, checks out HEAD~1 void undo() { - ModelStateCommit const* c = tryGetCommitByID(m_CurrentHead); + const ModelStateCommit* c = tryGetCommitByID(m_CurrentHead); if (!c) { return; } - ModelStateCommit const* parent = tryGetCommitByID(c->getParentID()); + const ModelStateCommit* parent = tryGetCommitByID(c->getParentID()); if (!parent) { @@ -632,7 +632,7 @@ class osc::UndoableModelStatePair::Impl final { return; } - ModelStateCommit const* c = nthAncestor(m_BranchHead, dist - 1); + const ModelStateCommit* c = nthAncestor(m_BranchHead, dist - 1); if (!c) { @@ -853,22 +853,22 @@ void osc::UndoableModelStatePair::implSetFixupScaleFactor(float v) m_Impl->setFixupScaleFactor(v); } -OpenSim::Component const* osc::UndoableModelStatePair::implGetSelected() const +const OpenSim::Component* osc::UndoableModelStatePair::implGetSelected() const { return m_Impl->getSelected(); } -void osc::UndoableModelStatePair::implSetSelected(OpenSim::Component const* c) +void osc::UndoableModelStatePair::implSetSelected(const OpenSim::Component* c) { m_Impl->setSelected(c); } -OpenSim::Component const* osc::UndoableModelStatePair::implGetHovered() const +const OpenSim::Component* osc::UndoableModelStatePair::implGetHovered() const { return m_Impl->getHovered(); } -void osc::UndoableModelStatePair::implSetHovered(OpenSim::Component const* c) +void osc::UndoableModelStatePair::implSetHovered(const OpenSim::Component* c) { m_Impl->setHovered(c); } diff --git a/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.h b/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.h index 8642b7ef8..c9b8cef67 100644 --- a/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.h +++ b/src/OpenSimCreator/Documents/Model/UndoableModelStatePair.h @@ -120,11 +120,11 @@ namespace osc float implGetFixupScaleFactor() const final; void implSetFixupScaleFactor(float) final; - OpenSim::Component const* implGetSelected() const final; - void implSetSelected(OpenSim::Component const* c) final; + const OpenSim::Component* implGetSelected() const final; + void implSetSelected(const OpenSim::Component* c) final; - OpenSim::Component const* implGetHovered() const final; - void implSetHovered(OpenSim::Component const* c) final; + const OpenSim::Component* implGetHovered() const final; + void implSetHovered(const OpenSim::Component* c) final; class Impl; std::unique_ptr m_Impl; diff --git a/src/OpenSimCreator/Documents/ModelWarper/CachedModelWarper.cpp b/src/OpenSimCreator/Documents/ModelWarper/CachedModelWarper.cpp index 73ba3fd0c..5979bbdc3 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/CachedModelWarper.cpp +++ b/src/OpenSimCreator/Documents/ModelWarper/CachedModelWarper.cpp @@ -110,7 +110,7 @@ class osc::mow::CachedModelWarper::Impl final { std::map> baseFrame2meshes; for (const auto& mesh : document.model().getComponentList()) { // try to warp+overwrite - if (auto const* meshWarper = document.findMeshWarp(mesh)) { + if (const auto* meshWarper = document.findMeshWarp(mesh)) { auto warpedMesh = WarpMesh(document, document.model(), document.modelstate().getState(), mesh, *meshWarper); auto* targetMesh = FindComponentMut(warpedModel, mesh.getAbsolutePath()); OSC_ASSERT_ALWAYS(targetMesh && "cannot find target mesh in output model: this should never happen"); @@ -136,7 +136,7 @@ class osc::mow::CachedModelWarper::Impl final { auto baseFramePath = pp.getParentFrame().findBaseFrame().getAbsolutePath(); if (auto it = baseFrame2meshes.find(baseFramePath); it != baseFrame2meshes.end()) { if (it->second.size() == 1) { - if (auto const* mesh = FindComponent(document.model(), it->second.front())) { + if (const auto* mesh = FindComponent(document.model(), it->second.front())) { if (auto const meshWarper = document.findMeshWarp(*mesh)) { // redefine the station's position in the mesh's coordinate system auto posInMeshFrame = pp.getParentFrame().expressVectorInAnotherFrame(warpedModel.getWorkingState(), pp.get_location(), mesh->getFrame()); @@ -165,7 +165,7 @@ class osc::mow::CachedModelWarper::Impl final { auto baseFramePath = station.getParentFrame().findBaseFrame().getAbsolutePath(); if (auto it = baseFrame2meshes.find(baseFramePath); it != baseFrame2meshes.end()) { if (it->second.size() == 1) { - if (auto const* mesh = FindComponent(document.model(), it->second.front())) { + if (const auto* mesh = FindComponent(document.model(), it->second.front())) { if (auto const meshWarper = document.findMeshWarp(*mesh)) { // redefine the station's position in the mesh's coordinate system auto posInMeshFrame = station.getParentFrame().expressVectorInAnotherFrame(warpedModel.getWorkingState(), station.get_location(), mesh->getFrame()); diff --git a/src/OpenSimCreator/Documents/ModelWarper/FrameWarperFactories.h b/src/OpenSimCreator/Documents/ModelWarper/FrameWarperFactories.h index 0579f6c07..900c28752 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/FrameWarperFactories.h +++ b/src/OpenSimCreator/Documents/ModelWarper/FrameWarperFactories.h @@ -31,17 +31,17 @@ namespace osc::mow ); template FrameWarp = IFrameWarperFactory> - FrameWarp const* find(const std::string& absPath) const + const FrameWarp* find(const std::string& absPath) const { - return dynamic_cast(lookup(absPath)); + return dynamic_cast(lookup(absPath)); } [[nodiscard]] bool empty() const { return m_AbsPathToWarpLUT.empty(); } private: - IFrameWarperFactory const* lookup(const std::string& absPath) const + const IFrameWarperFactory* lookup(const std::string& absPath) const { - if (auto const* ptr = lookup_or_nullptr(m_AbsPathToWarpLUT, absPath)) { + if (const auto* ptr = lookup_or_nullptr(m_AbsPathToWarpLUT, absPath)) { return ptr->get(); } else { diff --git a/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.cpp b/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.cpp index b9d39fd2f..79e87ff01 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.cpp +++ b/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.cpp @@ -51,7 +51,7 @@ std::vector osc::mow::ModelWarpDocument::details(const OpenSim::Mesh std::vector rv; rv.emplace_back("OpenSim::Mesh path in the OpenSim::Model", GetAbsolutePathString(mesh)); - if (IPointWarperFactory const* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh))) { + if (const IPointWarperFactory* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh))) { auto inner = p->details(); rv.insert(rv.end(), std::make_move_iterator(inner.begin()), std::make_move_iterator(inner.end())); } @@ -61,7 +61,7 @@ std::vector osc::mow::ModelWarpDocument::details(const OpenSim::Mesh std::vector osc::mow::ModelWarpDocument::validate(const OpenSim::Mesh& mesh) const { - if (IPointWarperFactory const* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh))) { + if (const IPointWarperFactory* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh))) { return p->validate(); } else { @@ -71,18 +71,18 @@ std::vector osc::mow::ModelWarpDocument::validate(const O ValidationCheckState osc::mow::ModelWarpDocument::state(const OpenSim::Mesh& mesh) const { - IPointWarperFactory const* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh)); + const IPointWarperFactory* p = m_MeshWarpLookup->find(GetAbsolutePathString(mesh)); return p ? p->state() : ValidationCheckState::Error; } -IPointWarperFactory const* osc::mow::ModelWarpDocument::findMeshWarp(const OpenSim::Mesh& mesh) const +const IPointWarperFactory* osc::mow::ModelWarpDocument::findMeshWarp(const OpenSim::Mesh& mesh) const { return m_MeshWarpLookup->find(GetAbsolutePathString(mesh)); } std::vector osc::mow::ModelWarpDocument::details(const OpenSim::PhysicalOffsetFrame& pof) const { - if (IFrameWarperFactory const* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof))) { + if (const IFrameWarperFactory* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof))) { return p->details(); } return {}; @@ -90,7 +90,7 @@ std::vector osc::mow::ModelWarpDocument::details(const OpenSim::Phys std::vector osc::mow::ModelWarpDocument::validate(const OpenSim::PhysicalOffsetFrame& pof) const { - if (IFrameWarperFactory const* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof))) { + if (const IFrameWarperFactory* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof))) { return p->validate(); } else { @@ -101,7 +101,7 @@ std::vector osc::mow::ModelWarpDocument::validate(const O ValidationCheckState osc::mow::ModelWarpDocument::state( const OpenSim::PhysicalOffsetFrame& pof) const { - IFrameWarperFactory const* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof)); + const IFrameWarperFactory* p = m_FrameWarpLookup->find(GetAbsolutePathString(pof)); return p ? p->state() : ValidationCheckState::Error; } diff --git a/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.h b/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.h index 116b8fd69..d63e3a8cb 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.h +++ b/src/OpenSimCreator/Documents/ModelWarper/ModelWarpDocument.h @@ -41,7 +41,7 @@ namespace osc::mow std::vector details(const OpenSim::Mesh&) const; std::vector validate(const OpenSim::Mesh&) const; ValidationCheckState state(const OpenSim::Mesh&) const; - IPointWarperFactory const* findMeshWarp(const OpenSim::Mesh&) const; + const IPointWarperFactory* findMeshWarp(const OpenSim::Mesh&) const; std::vector details(const OpenSim::PhysicalOffsetFrame&) const; std::vector validate(const OpenSim::PhysicalOffsetFrame&) const; diff --git a/src/OpenSimCreator/Documents/ModelWarper/PointWarperFactories.h b/src/OpenSimCreator/Documents/ModelWarper/PointWarperFactories.h index 302d92d2c..5d5dc367d 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/PointWarperFactories.h +++ b/src/OpenSimCreator/Documents/ModelWarper/PointWarperFactories.h @@ -32,15 +32,15 @@ namespace osc::mow ); template TMeshWarp = IPointWarperFactory> - TMeshWarp const* find(const std::string& meshComponentAbsPath) const + const TMeshWarp* find(const std::string& meshComponentAbsPath) const { - return dynamic_cast(lookup(meshComponentAbsPath)); + return dynamic_cast(lookup(meshComponentAbsPath)); } private: - IPointWarperFactory const* lookup(const std::string& absPath) const + const IPointWarperFactory* lookup(const std::string& absPath) const { - if (auto const* ptr = lookup_or_nullptr(m_AbsPathToWarpLUT, absPath)) { + if (const auto* ptr = lookup_or_nullptr(m_AbsPathToWarpLUT, absPath)) { return ptr->get(); } else { diff --git a/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.cpp b/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.cpp index 967d131ff..489923a9e 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.cpp +++ b/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.cpp @@ -252,7 +252,7 @@ bool osc::mow::TPSLandmarkPairWarperFactory::hasLandmarkNamed(std::string_view n return cpp23::contains(m_Landmarks, name, &MaybePairedLandmark::name); } -MaybePairedLandmark const* osc::mow::TPSLandmarkPairWarperFactory::tryGetLandmarkPairingByName(std::string_view name) const +const MaybePairedLandmark* osc::mow::TPSLandmarkPairWarperFactory::tryGetLandmarkPairingByName(std::string_view name) const { return find_or_nullptr(m_Landmarks, name, &MaybePairedLandmark::name); } diff --git a/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.h b/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.h index 4d1b929f8..bd61fb482 100644 --- a/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.h +++ b/src/OpenSimCreator/Documents/ModelWarper/TPSLandmarkPairWarperFactory.h @@ -60,7 +60,7 @@ namespace osc::mow bool hasUnpairedLandmarks() const; bool hasLandmarkNamed(std::string_view) const; - MaybePairedLandmark const* tryGetLandmarkPairingByName(std::string_view) const; + const MaybePairedLandmark* tryGetLandmarkPairingByName(std::string_view) const; private: std::unique_ptr implClone() const override; diff --git a/src/OpenSimCreator/Documents/OutputExtractors/ComponentOutputExtractor.cpp b/src/OpenSimCreator/Documents/OutputExtractors/ComponentOutputExtractor.cpp index f74dc91d2..9e2cfec37 100644 --- a/src/OpenSimCreator/Documents/OutputExtractors/ComponentOutputExtractor.cpp +++ b/src/OpenSimCreator/Documents/OutputExtractors/ComponentOutputExtractor.cpp @@ -87,7 +87,7 @@ class osc::ComponentOutputExtractor::Impl final { OutputExtractorDataType const datatype = getOutputType(); NullCallbackFnPointer const nullCallback = datatype == OutputExtractorDataType::Float ? NaNFloatingPointCallback : BlankStringCallback; - OpenSim::AbstractOutput const* const ao = FindOutput(component, m_ComponentAbsPath, m_OutputName); + const OpenSim::AbstractOutput* const ao = FindOutput(component, m_ComponentAbsPath, m_OutputName); if (not ao) { return OutputValueExtractor{nullCallback}; // cannot find output @@ -117,12 +117,12 @@ class osc::ComponentOutputExtractor::Impl final { bool equals(const IOutputExtractor& other) { - auto const* const otherT = dynamic_cast(&other); + const auto* const otherT = dynamic_cast(&other); if (!otherT) { return false; } - ComponentOutputExtractor::Impl const* const otherImpl = otherT->m_Impl.get(); + const ComponentOutputExtractor::Impl* const otherImpl = otherT->m_Impl.get(); if (otherImpl == this) { return true; } @@ -139,7 +139,7 @@ class osc::ComponentOutputExtractor::Impl final { OpenSim::ComponentPath m_ComponentAbsPath; std::string m_OutputName; std::string m_Label; - std::type_info const* m_OutputTypeid; + const std::type_info* m_OutputTypeid; SubfieldExtractorFunc m_ExtractorFunc; }; diff --git a/src/OpenSimCreator/Documents/OutputExtractors/ConcatenatingOutputExtractor.cpp b/src/OpenSimCreator/Documents/OutputExtractors/ConcatenatingOutputExtractor.cpp index 1d6e6d53b..b4586fcca 100644 --- a/src/OpenSimCreator/Documents/OutputExtractors/ConcatenatingOutputExtractor.cpp +++ b/src/OpenSimCreator/Documents/OutputExtractors/ConcatenatingOutputExtractor.cpp @@ -94,7 +94,7 @@ bool osc::ConcatenatingOutputExtractor::implEquals(const IOutputExtractor& other if (&other == this) { return true; } - if (auto* ptr = dynamic_cast(&other)) { + if (auto* ptr = dynamic_cast(&other)) { return ptr->m_First == m_First && ptr->m_Second == m_Second; } return false; diff --git a/src/OpenSimCreator/Documents/OutputExtractors/IntegratorOutputExtractor.cpp b/src/OpenSimCreator/Documents/OutputExtractors/IntegratorOutputExtractor.cpp index 3cf095d8c..d3d252d0e 100644 --- a/src/OpenSimCreator/Documents/OutputExtractors/IntegratorOutputExtractor.cpp +++ b/src/OpenSimCreator/Documents/OutputExtractors/IntegratorOutputExtractor.cpp @@ -135,7 +135,7 @@ bool osc::IntegratorOutputExtractor::implEquals(const IOutputExtractor& other) c return true; } - auto const* const otherT = dynamic_cast(&other); + const auto* const otherT = dynamic_cast(&other); if (!otherT) { return false; diff --git a/src/OpenSimCreator/Documents/OutputExtractors/MultiBodySystemOutputExtractor.cpp b/src/OpenSimCreator/Documents/OutputExtractors/MultiBodySystemOutputExtractor.cpp index c2c753d14..232b38b74 100644 --- a/src/OpenSimCreator/Documents/OutputExtractors/MultiBodySystemOutputExtractor.cpp +++ b/src/OpenSimCreator/Documents/OutputExtractors/MultiBodySystemOutputExtractor.cpp @@ -71,7 +71,7 @@ bool osc::MultiBodySystemOutputExtractor::implEquals(const IOutputExtractor& oth return true; } - auto const* const otherT = dynamic_cast(&other); + const auto* const otherT = dynamic_cast(&other); if (!otherT) { return false; diff --git a/src/OpenSimCreator/Documents/Simulation/ForwardDynamicSimulator.cpp b/src/OpenSimCreator/Documents/Simulation/ForwardDynamicSimulator.cpp index 3aa50efa4..82dc0eda8 100644 --- a/src/OpenSimCreator/Documents/Simulation/ForwardDynamicSimulator.cpp +++ b/src/OpenSimCreator/Documents/Simulation/ForwardDynamicSimulator.cpp @@ -137,7 +137,7 @@ namespace return true; } - auto const* const otherT = dynamic_cast(&other); + const auto* const otherT = dynamic_cast(&other); if (!otherT) { return false; diff --git a/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.cpp b/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.cpp index df5e44820..f42b7cdf5 100644 --- a/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.cpp +++ b/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.cpp @@ -47,22 +47,22 @@ class osc::SimulationModelStatePair::Impl final { return m_StateVersion; } - OpenSim::Component const* getSelected() const + const OpenSim::Component* getSelected() const { return FindComponent(getModel(), m_Selected); } - void setSelected(OpenSim::Component const* c) + void setSelected(const OpenSim::Component* c) { m_Selected = GetAbsolutePathOrEmpty(c); } - OpenSim::Component const* getHovered() const + const OpenSim::Component* getHovered() const { return FindComponent(getModel(), m_Hovered); } - void setHovered(OpenSim::Component const* c) + void setHovered(const OpenSim::Component* c) { m_Hovered = GetAbsolutePathOrEmpty(c); } @@ -171,22 +171,22 @@ UID osc::SimulationModelStatePair::implGetStateVersion() const return m_Impl->getStateVersion(); } -OpenSim::Component const* osc::SimulationModelStatePair::implGetSelected() const +const OpenSim::Component* osc::SimulationModelStatePair::implGetSelected() const { return m_Impl->getSelected(); } -void osc::SimulationModelStatePair::implSetSelected(OpenSim::Component const* c) +void osc::SimulationModelStatePair::implSetSelected(const OpenSim::Component* c) { m_Impl->setSelected(c); } -OpenSim::Component const* osc::SimulationModelStatePair::implGetHovered() const +const OpenSim::Component* osc::SimulationModelStatePair::implGetHovered() const { return m_Impl->getHovered(); } -void osc::SimulationModelStatePair::implSetHovered(OpenSim::Component const* c) +void osc::SimulationModelStatePair::implSetHovered(const OpenSim::Component* c) { m_Impl->setHovered(c); } diff --git a/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.h b/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.h index 442ade549..59aed8cb0 100644 --- a/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.h +++ b/src/OpenSimCreator/Documents/Simulation/SimulationModelStatePair.h @@ -38,11 +38,11 @@ namespace osc const SimTK::State& implGetState() const final; UID implGetStateVersion() const final; - OpenSim::Component const* implGetSelected() const final; - void implSetSelected(OpenSim::Component const*) final; + const OpenSim::Component* implGetSelected() const final; + void implSetSelected(const OpenSim::Component*) final; - OpenSim::Component const* implGetHovered() const final; - void implSetHovered(OpenSim::Component const*) final; + const OpenSim::Component* implGetHovered() const final; + void implSetHovered(const OpenSim::Component*) final; float implGetFixupScaleFactor() const final; void implSetFixupScaleFactor(float) final; diff --git a/src/OpenSimCreator/Graphics/ComponentAbsPathDecorationTagger.h b/src/OpenSimCreator/Graphics/ComponentAbsPathDecorationTagger.h index 77d1b2449..fa4ccfc7b 100644 --- a/src/OpenSimCreator/Graphics/ComponentAbsPathDecorationTagger.h +++ b/src/OpenSimCreator/Graphics/ComponentAbsPathDecorationTagger.h @@ -12,7 +12,7 @@ namespace osc public: void operator()(const OpenSim::Component&, SceneDecoration&); private: - OpenSim::Component const* m_LastComponent = nullptr; + const OpenSim::Component* m_LastComponent = nullptr; std::string m_ID; }; } diff --git a/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.cpp b/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.cpp index d157378bb..9b37cafda 100644 --- a/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.cpp +++ b/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.cpp @@ -7,8 +7,8 @@ using namespace osc; osc::ComponentSceneDecorationFlagsTagger::ComponentSceneDecorationFlagsTagger( - OpenSim::Component const* selected_, - OpenSim::Component const* hovered_) : + const OpenSim::Component* selected_, + const OpenSim::Component* hovered_) : m_Selected{selected_}, m_Hovered{hovered_} { @@ -42,7 +42,7 @@ SceneDecorationFlags osc::ComponentSceneDecorationFlagsTagger::computeFlags( rv |= SceneDecorationFlags::IsHovered; } - for (OpenSim::Component const* p = GetOwner(component); p; p = GetOwner(*p)) + for (const OpenSim::Component* p = GetOwner(component); p; p = GetOwner(*p)) { if (p == m_Selected) { diff --git a/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.h b/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.h index 8eac0af9c..9365e4fff 100644 --- a/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.h +++ b/src/OpenSimCreator/Graphics/ComponentSceneDecorationFlagsTagger.h @@ -11,17 +11,17 @@ namespace osc class ComponentSceneDecorationFlagsTagger final { public: ComponentSceneDecorationFlagsTagger( - OpenSim::Component const* selected_, - OpenSim::Component const* hovered_ + const OpenSim::Component* selected_, + const OpenSim::Component* hovered_ ); void operator()(const OpenSim::Component&, SceneDecoration&); private: SceneDecorationFlags computeFlags(const OpenSim::Component&) const; - OpenSim::Component const* m_Selected; - OpenSim::Component const* m_Hovered; - OpenSim::Component const* m_LastComponent = nullptr; + const OpenSim::Component* m_Selected; + const OpenSim::Component* m_Hovered; + const OpenSim::Component* m_LastComponent = nullptr; SceneDecorationFlags m_Flags = SceneDecorationFlags::None; }; } diff --git a/src/OpenSimCreator/Graphics/CustomRenderingOptions.cpp b/src/OpenSimCreator/Graphics/CustomRenderingOptions.cpp index 89eb9789d..412b4f8b4 100644 --- a/src/OpenSimCreator/Graphics/CustomRenderingOptions.cpp +++ b/src/OpenSimCreator/Graphics/CustomRenderingOptions.cpp @@ -84,7 +84,7 @@ void osc::CustomRenderingOptions::tryUpdFromValues(std::string_view keyPrefix, s for (const auto& metadata : GetAllCustomRenderingOptionFlagsMetadata()) { std::string key = std::string{keyPrefix} + metadata.id; - if (auto const* v = lookup_or_nullptr(lut, key); v->type() == AppSettingValueType::Bool) { + if (const auto* v = lookup_or_nullptr(lut, key); v->type() == AppSettingValueType::Bool) { SetOption(m_Flags, metadata.value, v->to_bool()); } } diff --git a/src/OpenSimCreator/Graphics/ModelRendererParams.cpp b/src/OpenSimCreator/Graphics/ModelRendererParams.cpp index ec793e0c2..cc18b7264 100644 --- a/src/OpenSimCreator/Graphics/ModelRendererParams.cpp +++ b/src/OpenSimCreator/Graphics/ModelRendererParams.cpp @@ -51,10 +51,10 @@ namespace params.decorationOptions.tryUpdFromValues(std::string{prefix} + "decorations/", values); params.overlayOptions.tryUpdFromValues(std::string{prefix} + "overlays/", values); params.renderingOptions.tryUpdFromValues(std::string{prefix} + "graphics/", values); - if (auto const* v = lookup_or_nullptr(values, std::string{prefix} + "light_color")) { + if (const auto* v = lookup_or_nullptr(values, std::string{prefix} + "light_color")) { params.lightColor = v->to_color(); } - if (auto const* v = lookup_or_nullptr(values,std::string{prefix} + "background_color")) { + if (const auto* v = lookup_or_nullptr(values,std::string{prefix} + "background_color")) { params.backgroundColor = v->to_color(); } // TODO: floorLocation @@ -95,7 +95,7 @@ void osc::SaveModelRendererParamsDifference( auto const bVals = ToValues(keyPrefix, b); for (const auto& [aK, aV] : aVals) { - if (auto const* bV = lookup_or_nullptr(bVals, aK)) { + if (const auto* bV = lookup_or_nullptr(bVals, aK)) { if (*bV != aV) { config.set_value(aK, *bV); } diff --git a/src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp b/src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp index 5096590ac..ec25ba3aa 100644 --- a/src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp +++ b/src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp @@ -465,7 +465,7 @@ namespace auto const emitTendonSphere = [&](const GeometryPathPoint& p) { - OpenSim::Component const* c = &muscle; + const OpenSim::Component* c = &muscle; if (p.maybeUnderlyingUserPathPoint) { c = p.maybeUnderlyingUserPathPoint; @@ -479,7 +479,7 @@ namespace }; auto emitFiberSphere = [&](const GeometryPathPoint& p) { - OpenSim::Component const* c = &muscle; + const OpenSim::Component* c = &muscle; if (p.maybeUnderlyingUserPathPoint) { c = p.maybeUnderlyingUserPathPoint; @@ -829,7 +829,7 @@ namespace } // the `GeometryPath` has a owner, which might be a muscle or path actuator - if (auto const* const musc = GetOwner(gp)) + if (const auto* const musc = GetOwner(gp)) { // owner is a muscle, coerce selection "hit" to the muscle @@ -848,13 +848,13 @@ namespace return; } } - else if (auto const* const pa = GetOwner(gp)) + else if (const auto* const pa = GetOwner(gp)) { // owner is a path actuator, coerce selection "hit" to the path actuator (#519) HandleGenericGeometryPath(rs, gp, *pa); return; } - else if (auto const* const pathSpring = GetOwner(gp)) + else if (const auto* const pathSpring = GetOwner(gp)) { // owner is a path spring, coerce selection "hit" to the path spring (#650) HandleGenericGeometryPath(rs, gp, *pathSpring); @@ -983,7 +983,7 @@ void osc::GenerateSubcomponentDecorations( { return; } - else if (auto const* const custom = dynamic_cast(&c)) + else if (const auto* const custom = dynamic_cast(&c)) { // edge-case: it's a component that has an OSC-specific `ICustomDecorationGenerator` // so we can skip the song-and-dance with caches, OpenSim, SimTK, etc. @@ -992,19 +992,19 @@ void osc::GenerateSubcomponentDecorations( rendererState.consume(c, std::move(dec)); }); } - else if (auto const* const gp = dynamic_cast(&c)) + else if (const auto* const gp = dynamic_cast(&c)) { HandleGeometryPath(rendererState, *gp); } - else if (auto const* const b = dynamic_cast(&c)) + else if (const auto* const b = dynamic_cast(&c)) { HandleBody(rendererState, *b); } - else if (auto const* const fg = dynamic_cast(&c)) + else if (const auto* const fg = dynamic_cast(&c)) { HandleFrameGeometry(rendererState, *fg); } - else if (auto const* const p2p = dynamic_cast(&c); p2p && opts.getShouldShowPointToPointSprings()) + else if (const auto* const p2p = dynamic_cast(&c); p2p && opts.getShouldShowPointToPointSprings()) { HandlePointToPointSpring(rendererState, *p2p); } @@ -1013,15 +1013,15 @@ void osc::GenerateSubcomponentDecorations( // CARE: it's a typeid comparison because OpenSim::Marker inherits from OpenSim::Station HandleStation(rendererState, dynamic_cast(c)); } - else if (auto const* const sj = dynamic_cast(&c); sj && opts.getShouldShowScapulo()) + else if (const auto* const sj = dynamic_cast(&c); sj && opts.getShouldShowScapulo()) { HandleScapulothoracicJoint(rendererState, *sj); } - else if (auto const* const hcf = dynamic_cast(&c)) + else if (const auto* const hcf = dynamic_cast(&c)) { HandleHuntCrossleyForce(rendererState, *hcf); } - else if (auto const* const geom = dynamic_cast(&c)) + else if (const auto* const geom = dynamic_cast(&c)) { // EDGE-CASE: // diff --git a/src/OpenSimCreator/Graphics/OpenSimGraphicsHelpers.cpp b/src/OpenSimCreator/Graphics/OpenSimGraphicsHelpers.cpp index a1bce1cc3..03cde10d5 100644 --- a/src/OpenSimCreator/Graphics/OpenSimGraphicsHelpers.cpp +++ b/src/OpenSimCreator/Graphics/OpenSimGraphicsHelpers.cpp @@ -101,7 +101,7 @@ std::optional osc::GetClosestCollision( ); // filter through the collisions list - SceneCollision const* closestCollision = nullptr; + const SceneCollision* closestCollision = nullptr; for (const SceneCollision& c : collisions) { if (closestCollision && c.distance_from_ray_origin > closestCollision->distance_from_ray_origin) diff --git a/src/OpenSimCreator/Graphics/OverlayDecorationOptions.cpp b/src/OpenSimCreator/Graphics/OverlayDecorationOptions.cpp index f6d32a2fb..16e9fcebc 100644 --- a/src/OpenSimCreator/Graphics/OverlayDecorationOptions.cpp +++ b/src/OpenSimCreator/Graphics/OverlayDecorationOptions.cpp @@ -110,7 +110,7 @@ void osc::OverlayDecorationOptions::tryUpdFromValues(std::string_view keyPrefix, const auto& metadata = at(GetAllOverlayDecorationOptionFlagsMetadata(), i); std::string const key = std::string{keyPrefix}+metadata.id; - if (auto const* v = lookup_or_nullptr(lut, key); v and v->type() == osc::AppSettingValueType::Bool) { + if (const auto* v = lookup_or_nullptr(lut, key); v and v->type() == osc::AppSettingValueType::Bool) { SetOption(m_Flags, metadata.value, v->to_bool()); } } diff --git a/src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp b/src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp index c714bab84..7c8756f60 100644 --- a/src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp +++ b/src/OpenSimCreator/UI/FrameDefinition/FrameDefinitionTab.cpp @@ -106,14 +106,14 @@ namespace } const std::string& pointBPath = *choices.begin(); - auto const* pointA = FindComponent(model->getModel(), pointAPath); + const auto* pointA = FindComponent(model->getModel(), pointAPath); if (!pointA) { log_error("point A's component path (%s) does not exist in the model", pointAPath.c_str()); return false; } - auto const* pointB = FindComponent(model->getModel(), pointBPath); + const auto* pointB = FindComponent(model->getModel(), pointBPath); if (!pointB) { log_error("point B's component path (%s) does not exist in the model", pointBPath.c_str()); @@ -157,14 +157,14 @@ namespace } const std::string& pointBPath = *choices.begin(); - auto const* pointA = FindComponent(model->getModel(), pointAPath); + const auto* pointA = FindComponent(model->getModel(), pointAPath); if (!pointA) { log_error("point A's component path (%s) does not exist in the model", pointAPath.c_str()); return false; } - auto const* pointB = FindComponent(model->getModel(), pointBPath); + const auto* pointB = FindComponent(model->getModel(), pointBPath); if (!pointB) { log_error("point B's component path (%s) does not exist in the model", pointBPath.c_str()); @@ -208,14 +208,14 @@ namespace } const std::string& edgeBPath = *choices.begin(); - auto const* edgeA = FindComponent(model->getModel(), edgeAPath); + const auto* edgeA = FindComponent(model->getModel(), edgeAPath); if (!edgeA) { log_error("edge A's component path (%s) does not exist in the model", edgeAPath.c_str()); return false; } - auto const* edgeB = FindComponent(model->getModel(), edgeBPath); + const auto* edgeB = FindComponent(model->getModel(), edgeBPath); if (!edgeB) { log_error("point B's component path (%s) does not exist in the model", edgeBPath.c_str()); @@ -258,21 +258,21 @@ namespace } const std::string& originPath = *choices.begin(); - auto const* firstEdge = FindComponent(model->getModel(), firstEdgeAbsPath); + const auto* firstEdge = FindComponent(model->getModel(), firstEdgeAbsPath); if (!firstEdge) { log_error("the first edge's component path (%s) does not exist in the model", firstEdgeAbsPath.c_str()); return false; } - auto const* otherEdge = FindComponent(model->getModel(), secondEdgeAbsPath); + const auto* otherEdge = FindComponent(model->getModel(), secondEdgeAbsPath); if (!otherEdge) { log_error("the second edge's component path (%s) does not exist in the model", secondEdgeAbsPath.c_str()); return false; } - auto const* originPoint = FindComponent(model->getModel(), originPath); + const auto* originPoint = FindComponent(model->getModel(), originPath); if (!originPoint) { log_error("the origin's component path (%s) does not exist in the model", originPath.c_str()); @@ -377,7 +377,7 @@ namespace &c != bodyFrame && !IsChildOfA(c) && ( - dynamic_cast(&c) != nullptr || + dynamic_cast(&c) != nullptr || IsChildOfA(c) ); }; @@ -395,7 +395,7 @@ namespace return false; } - auto const* const parentFrame = FindComponent(model->getModel(), *choices.begin()); + const auto* const parentFrame = FindComponent(model->getModel(), *choices.begin()); if (!parentFrame) { log_error("user selection from 'choose components' layer did not select a frame: this shouldn't happen?"); @@ -439,7 +439,7 @@ namespace return false; } - auto const* const jointFrame = FindComponent(model->getModel(), *choices.begin()); + const auto* const jointFrame = FindComponent(model->getModel(), *choices.begin()); if (!jointFrame) { log_error("user selection from 'choose components' layer did not select a frame: this shouldn't happen?"); @@ -481,7 +481,7 @@ namespace return false; } - auto const* const mesh = FindComponent(model->getModel(), *choices.begin()); + const auto* const mesh = FindComponent(model->getModel(), *choices.begin()); if (!mesh) { log_error("user selection from 'choose components' layer did not select a mesh: this shouldn't happen?"); @@ -718,7 +718,7 @@ namespace std::optional const& maybeSourceEvent, const OpenSim::Frame& frame) { - OpenSim::Component const* groundOrExistingBody = dynamic_cast(&frame); + const OpenSim::Component* groundOrExistingBody = dynamic_cast(&frame); if (!groundOrExistingBody) { groundOrExistingBody = FindFirstDescendentOfType(frame); @@ -929,28 +929,28 @@ namespace private: void impl_draw_content() final { - OpenSim::Component const* const maybeComponent = FindComponent(m_Model->getModel(), m_ComponentPath); + const OpenSim::Component* const maybeComponent = FindComponent(m_Model->getModel(), m_ComponentPath); if (!maybeComponent) { DrawRightClickedNothingContextMenu(*m_Model); } - else if (auto const* maybeMesh = dynamic_cast(maybeComponent)) + else if (const auto* maybeMesh = dynamic_cast(maybeComponent)) { DrawRightClickedMeshContextMenu(*m_EditorAPI, m_Model, m_MaybeSourceVisualizerEvent, *maybeMesh); } - else if (auto const* maybePoint = dynamic_cast(maybeComponent)) + else if (const auto* maybePoint = dynamic_cast(maybeComponent)) { DrawRightClickedPointContextMenu(*m_EditorAPI, m_Model, m_MaybeSourceVisualizerEvent, *maybePoint); } - else if (auto const* maybeFrame = dynamic_cast(maybeComponent)) + else if (const auto* maybeFrame = dynamic_cast(maybeComponent)) { DrawRightClickedFrameContextMenu(*m_EditorAPI, m_Model, m_MaybeSourceVisualizerEvent, *maybeFrame); } - else if (auto const* maybeP2PEdge = dynamic_cast(maybeComponent)) + else if (const auto* maybeP2PEdge = dynamic_cast(maybeComponent)) { DrawRightClickedPointToPointEdgeContextMenu(*m_EditorAPI, m_Model, m_MaybeSourceVisualizerEvent, *maybeP2PEdge); } - else if (auto const* maybeCPEdge = dynamic_cast(maybeComponent)) + else if (const auto* maybeCPEdge = dynamic_cast(maybeComponent)) { DrawRightClickedCrossProductEdgeContextMenu(*m_EditorAPI, m_Model, m_MaybeSourceVisualizerEvent, *maybeCPEdge); } diff --git a/src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h b/src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h index 736b2bf1a..d2f43122d 100644 --- a/src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h +++ b/src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h @@ -145,7 +145,7 @@ namespace osc::mi void tryToggleSelectionStateOf(UID id) { - MIObject const* el = m_Shared->getModelGraph().tryGetByID(id); + const MIObject* el = m_Shared->getModelGraph().tryGetByID(id); if (el) { @@ -254,7 +254,7 @@ namespace osc::mi return; } - MIObject const* se = m_Shared->getModelGraph().tryGetByID(m_MaybeHover.ID); + const MIObject* se = m_Shared->getModelGraph().tryGetByID(m_MaybeHover.ID); if (se) { diff --git a/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h b/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h index b55858aa1..fb7cc935d 100644 --- a/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h +++ b/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h @@ -472,7 +472,7 @@ namespace osc::mi updColors()[i] = newColorValue; } - std::span getColorLabels() const + std::span getColorLabels() const { return c_ColorNames; } @@ -494,7 +494,7 @@ namespace osc::mi updVisibilityFlags()[i] = newVisibilityValue; } - std::span getVisibilityFlagLabels() const + std::span getVisibilityFlagLabels() const { return c_VisibilityFlagNames; } @@ -540,7 +540,7 @@ namespace osc::mi updInteractivityFlags()[i] = newInteractivityValue; } - std::span getInteractivityFlagLabels() const + std::span getInteractivityFlagLabels() const { return c_InteractivityFlagNames; } @@ -978,7 +978,7 @@ namespace osc::mi continue; } - MIObject const* other = mg.tryGetByID(refID); + const MIObject* other = mg.tryGetByID(refID); if (!other) { @@ -1471,7 +1471,7 @@ namespace osc::mi Color sceneBackground{48.0f/255.0f, 48.0f/255.0f, 48.0f/255.0f, 1.0f}; Color gridLines{0.7f, 0.7f, 0.7f, 0.15f}; } m_Colors; - static constexpr auto c_ColorNames = std::to_array( + static constexpr auto c_ColorNames = std::to_array( { "ground", "meshes", @@ -1497,7 +1497,7 @@ namespace osc::mi bool stationConnectionLines = true; bool floor = true; } m_VisibilityFlags; - static constexpr auto c_VisibilityFlagNames = std::to_array( + static constexpr auto c_VisibilityFlagNames = std::to_array( { "ground", "meshes", @@ -1522,7 +1522,7 @@ namespace osc::mi bool joints = true; bool stations = true; } m_InteractivityFlags; - static constexpr auto c_InteractivityFlagNames = std::to_array( + static constexpr auto c_InteractivityFlagNames = std::to_array( { "ground", "meshes", @@ -1537,7 +1537,7 @@ namespace osc::mi // these are runtime-editable flags that dictate which panels are open static inline constexpr size_t c_NumPanelStates = 4; std::array m_PanelStates{false, true, false, false}; - static constexpr auto c_OpenedPanelNames = std::to_array( + static constexpr auto c_OpenedPanelNames = std::to_array( { "History", "Navigator", diff --git a/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp b/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp index 334ddee07..b02fd6d2c 100644 --- a/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp +++ b/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp @@ -328,7 +328,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { const Document& mg = m_Shared->getModelGraph(); - MIObject const* hoveredMIObject = mg.tryGetByID(m_MaybeHover.ID); + const MIObject* hoveredMIObject = mg.tryGetByID(m_MaybeHover.ID); if (!hoveredMIObject) { @@ -342,7 +342,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { return; // can't attach to it as-if it were a body } - auto const* bodyEl = mg.tryGetByID(maybeID); + const auto* bodyEl = mg.tryGetByID(maybeID); if (!bodyEl) { return; // suggested attachment parent isn't in the current model graph? @@ -687,7 +687,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { return; // invalid index? } - MIObject const* old = m_Shared->getModelGraph().tryGetByID(el.getCrossReferenceConnecteeID(crossrefIdx)); + const MIObject* old = m_Shared->getModelGraph().tryGetByID(el.getCrossReferenceConnecteeID(crossrefIdx)); if (!old) { @@ -695,10 +695,10 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { } ChooseElLayerOptions opts; - opts.canChooseBodies = (dynamic_cast(old) != nullptr) || (dynamic_cast(old) != nullptr); - opts.canChooseGround = (dynamic_cast(old) != nullptr) || (dynamic_cast(old) != nullptr); - opts.canChooseJoints = dynamic_cast(old) != nullptr; - opts.canChooseMeshes = dynamic_cast(old) != nullptr; + opts.canChooseBodies = (dynamic_cast(old) != nullptr) || (dynamic_cast(old) != nullptr); + opts.canChooseGround = (dynamic_cast(old) != nullptr) || (dynamic_cast(old) != nullptr); + opts.canChooseJoints = dynamic_cast(old) != nullptr; + opts.canChooseMeshes = dynamic_cast(old) != nullptr; opts.maybeElsAttachingTo = {el.getID()}; opts.header = "choose what to attach to"; opts.onUserChoice = [shared = m_Shared, id = el.getID(), crossrefIdx](std::span choices) @@ -985,7 +985,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { } ui::draw_tooltip_if_item_hovered("Add body", MIStrings::c_BodyDescription); - if (auto const* mesh = dynamic_cast(&el)) + if (const auto* mesh = dynamic_cast(&el)) { if (ui::draw_menu_item(ICON_FA_BORDER_ALL " at bounds center")) { @@ -1023,7 +1023,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { ui::pop_id(); ui::push_id(imguiID++); - if (auto const* body = dynamic_cast(&el)) + if (const auto* body = dynamic_cast(&el)) { if (ui::draw_menu_item(ICON_FA_LINK " Joint")) { @@ -1058,7 +1058,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { } ui::draw_tooltip_if_item_hovered("Add Station", MIStrings::c_StationDescription); - if (dynamic_cast(&el)) + if (dynamic_cast(&el)) { if (ui::draw_menu_item(ICON_FA_BORDER_ALL " at bounds center")) { @@ -1112,7 +1112,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { ui::end_menu(); } - if (auto const* body = dynamic_cast(&el)) + if (const auto* body = dynamic_cast(&el)) { if (ui::draw_menu_item(ICON_FA_LINK " Join to")) { @@ -1762,7 +1762,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { if (ui::begin_popup_context_menu("##addpainttoscenepopup", ImGuiPopupFlags_MouseButtonLeft)) { std::span colors = m_Shared->colors(); - std::span labels = m_Shared->getColorLabels(); + std::span labels = m_Shared->getColorLabels(); OSC_ASSERT(colors.size() == labels.size() && "every color should have a label"); for (size_t i = 0; i < colors.size(); ++i) @@ -1786,7 +1786,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { if (ui::begin_popup_context_menu("##changevisibilitypopup", ImGuiPopupFlags_MouseButtonLeft)) { std::span visibilities = m_Shared->getVisibilityFlags(); - std::span labels = m_Shared->getVisibilityFlagLabels(); + std::span labels = m_Shared->getVisibilityFlagLabels(); OSC_ASSERT(visibilities.size() == labels.size() && "every visibility flag should have a label"); for (size_t i = 0; i < visibilities.size(); ++i) @@ -1810,7 +1810,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { if (ui::begin_popup_context_menu("##changeinteractionlockspopup", ImGuiPopupFlags_MouseButtonLeft)) { std::span interactables = m_Shared->getIneractivityFlags(); - std::span labels = m_Shared->getInteractivityFlagLabels(); + std::span labels = m_Shared->getInteractivityFlagLabels(); OSC_ASSERT(interactables.size() == labels.size()); for (size_t i = 0; i < interactables.size(); ++i) @@ -2042,7 +2042,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { return; // nothing is hovered } - if (MIObject const* e = m_Shared->getModelGraph().tryGetByID(m_MaybeHover.ID)) + if (const MIObject* e = m_Shared->getModelGraph().tryGetByID(m_MaybeHover.ID)) { drawMIObjectTooltip(*e); } diff --git a/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabContextMenu.h b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabContextMenu.h index 25fbf85f2..15c7f9fec 100644 --- a/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabContextMenu.h +++ b/src/OpenSimCreator/UI/MeshWarper/MeshWarpingTabContextMenu.h @@ -39,16 +39,16 @@ namespace osc private: void impl_draw_content() final { - TPSDocumentElement const* el = FindElement(m_State->getScratch(), m_ElementID); + const TPSDocumentElement* el = FindElement(m_State->getScratch(), m_ElementID); if (!el) { request_close(); // element cannot be found in document (deleted? renamed?) } - else if (auto const* landmarkPair = dynamic_cast(el)) + else if (const auto* landmarkPair = dynamic_cast(el)) { drawContextMenu(*landmarkPair); } - else if (auto const* npl = dynamic_cast(el)) + else if (const auto* npl = dynamic_cast(el)) { drawContextMenu(*npl); } diff --git a/src/OpenSimCreator/UI/ModelEditor/AddBodyPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/AddBodyPopup.cpp index 5231a7dda..4290a025c 100644 --- a/src/OpenSimCreator/UI/ModelEditor/AddBodyPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/AddBodyPopup.cpp @@ -44,7 +44,7 @@ class osc::AddBodyPopup::Impl final : public StandardPopup { { const OpenSim::Model& model = m_Uum->getModel(); - auto const* selectedPf = FindComponent(model, m_BodyDetails.parentFrameAbsPath); + const auto* selectedPf = FindComponent(model, m_BodyDetails.parentFrameAbsPath); if (!selectedPf) { // if nothing selected (or not found), coerce the initial selection to ground diff --git a/src/OpenSimCreator/UI/ModelEditor/AddComponentPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/AddComponentPopup.cpp index ded9bf9fd..29d9aa0d8 100644 --- a/src/OpenSimCreator/UI/ModelEditor/AddComponentPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/AddComponentPopup.cpp @@ -107,7 +107,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { const OpenSim::AbstractSocket& socket = *m_ProtoSockets[i]; const OpenSim::ComponentPath& connecteePath = m_SocketConnecteePaths[i]; - OpenSim::Component const* connectee = FindComponent(model, connecteePath); + const OpenSim::Component* connectee = FindComponent(model, connecteePath); if (!connectee) { @@ -134,7 +134,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { return nullptr; // invalid path slipped through } - auto const* pof = FindComponent(model, pp.actualFrame); + const auto* pof = FindComponent(model, pp.actualFrame); if (!pof) { return nullptr; // invalid path slipped through @@ -157,7 +157,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { bool const hasName = !m_Name.empty(); bool const allSocketsAssigned = rgs::all_of(m_SocketConnecteePaths, std::bind_front(ContainsComponent, std::cref(model))); bool const hasEnoughPathPoints = - dynamic_cast(m_Proto.get()) == nullptr or + dynamic_cast(m_Proto.get()) == nullptr or m_PathPoints.size() >= 2; return hasName and allSocketsAssigned and hasEnoughPathPoints; @@ -252,7 +252,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { continue; // can't connect to it } - if (dynamic_cast(&c) && IsChildOfA(c)) { + if (dynamic_cast(&c) && IsChildOfA(c)) { continue; // it's a muscle point: don't present it (noisy) } @@ -301,8 +301,8 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { continue; // already selected } - OpenSim::Component const* userChoice = nullptr; - OpenSim::PhysicalFrame const* actualFrame = nullptr; + const OpenSim::Component* userChoice = nullptr; + const OpenSim::PhysicalFrame* actualFrame = nullptr; SimTK::Vec3 locationInFrame = {0.0, 0.0, 0.0}; // careful here: the order matters @@ -310,23 +310,23 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { // various OpenSim classes compose some of these. E.g. subclasses of // AbstractPathPoint *also* contain a station object, but named with a // plain name - if (auto const* pof = dynamic_cast(&c)) + if (const auto* pof = dynamic_cast(&c)) { userChoice = pof; actualFrame = pof; } - else if (auto const* pp = dynamic_cast(&c)) + else if (const auto* pp = dynamic_cast(&c)) { userChoice = pp; actualFrame = &pp->getParentFrame(); locationInFrame = pp->get_location(); } - else if (auto const* app = dynamic_cast(&c)) + else if (const auto* app = dynamic_cast(&c)) { userChoice = app; actualFrame = &app->getParentFrame(); } - else if (auto const* station = dynamic_cast(&c)) + else if (const auto* station = dynamic_cast(&c)) { // check name because it might be a child of one of the above and we // don't want to double-count it @@ -416,7 +416,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { ui::draw_text(m_PathPoints[i].userChoice.getComponentName()); if (ui::is_item_hovered()) { - if (OpenSim::Component const* c = FindComponent(model, m_PathPoints[i].userChoice)) + if (const OpenSim::Component* c = FindComponent(model, m_PathPoints[i].userChoice)) { ui::draw_tooltip(c->getName(), GetAbsolutePathString(*c)); } @@ -532,7 +532,7 @@ class osc::AddComponentPopup::Impl final : public StandardPopup { std::shared_ptr m_Proto; // (may be shared with editor popups etc) // cached sequence of OpenSim::PhysicalFrame sockets in the prototype - std::vector m_ProtoSockets{GetAllSockets(*m_Proto)}; + std::vector m_ProtoSockets{GetAllSockets(*m_Proto)}; // user-assigned name for the to-be-added component std::string m_Name{m_Proto->getConcreteClassName()}; diff --git a/src/OpenSimCreator/UI/ModelEditor/ComponentContextMenu.cpp b/src/OpenSimCreator/UI/ModelEditor/ComponentContextMenu.cpp index 14b892ae3..73431bef3 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ComponentContextMenu.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ComponentContextMenu.cpp @@ -54,7 +54,7 @@ namespace UndoableModelStatePair& uim, const OpenSim::ComponentPath& jointPath) { - auto const* joint = FindComponent(uim.getModel(), jointPath); + const auto* joint = FindComponent(uim.getModel(), jointPath); if (!joint) { return; @@ -122,7 +122,7 @@ namespace std::shared_ptr const& uim, const OpenSim::ComponentPath& pfPath) { - if (auto const* pf = FindComponent(uim->getModel(), pfPath)) + if (const auto* pf = FindComponent(uim->getModel(), pfPath)) { DrawCalculateMenu( uim->getModel(), @@ -201,7 +201,7 @@ namespace std::shared_ptr const& uim, const OpenSim::ComponentPath& hcfPath) { - auto const* const hcf = FindComponent(uim->getModel(), hcfPath); + const auto* const hcf = FindComponent(uim->getModel(), hcfPath); if (!hcf) { return; @@ -220,7 +220,7 @@ namespace }; auto filter = [](const OpenSim::Component& c) -> bool { - return dynamic_cast(&c) != nullptr; + return dynamic_cast(&c) != nullptr; }; auto popup = std::make_unique("Select Contact Geometry", uim, onSelection, filter); popup->open(); @@ -371,7 +371,7 @@ namespace bool AnyDescendentInclusiveHasAppearanceProperty(const OpenSim::Component& component) { - OpenSim::Component const* const c = FindFirstDescendentInclusive( + const OpenSim::Component* const c = FindFirstDescendentInclusive( component, [](const OpenSim::Component& desc) -> bool { return TryGetAppearance(desc) != nullptr; } ); @@ -401,7 +401,7 @@ class osc::ComponentContextMenu::Impl final : public StandardPopup { private: void impl_draw_content() final { - OpenSim::Component const* c = FindComponent(m_Model->getModel(), m_Path); + const OpenSim::Component* c = FindComponent(m_Model->getModel(), m_Path); if (!c) { // draw context menu content that's shown when nothing was right-clicked @@ -550,52 +550,52 @@ class osc::ComponentContextMenu::Impl final : public StandardPopup { drawSocketMenu(*c); - if (dynamic_cast(c)) + if (dynamic_cast(c)) { DrawModelContextualActions(*m_Model); } - else if (dynamic_cast(c)) + else if (dynamic_cast(c)) { DrawPhysicalFrameContextualActions(m_EditorAPI, m_Model, m_Path); } - else if (dynamic_cast(c)) + else if (dynamic_cast(c)) { DrawJointContextualActions(*m_Model, m_Path); } - else if (dynamic_cast(c)) + else if (dynamic_cast(c)) { DrawHCFContextualActions(m_EditorAPI, m_Model, m_Path); } - else if (auto const* musclePtr = dynamic_cast(c)) + else if (const auto* musclePtr = dynamic_cast(c)) { drawAddMusclePlotMenu(*musclePtr); DrawPathActuatorContextualParams(m_EditorAPI, m_Model, m_Path); // a muscle is a path actuator } - else if (dynamic_cast(c)) + else if (dynamic_cast(c)) { DrawPathActuatorContextualParams(m_EditorAPI, m_Model, m_Path); } - else if (auto const* stationPtr = dynamic_cast(c)) + else if (const auto* stationPtr = dynamic_cast(c)) { DrawStationContextualActions(*m_Model, *stationPtr); } - else if (auto const* pointPtr = dynamic_cast(c)) + else if (const auto* pointPtr = dynamic_cast(c)) { DrawPointContextualActions(*m_Model, *pointPtr); } - else if (auto const* ellipsoidPtr = dynamic_cast(c)) + else if (const auto* ellipsoidPtr = dynamic_cast(c)) { DrawEllipsoidContextualActions(*m_Model, *ellipsoidPtr); } - else if (auto const* meshPtr = dynamic_cast(c)) + else if (const auto* meshPtr = dynamic_cast(c)) { DrawMeshContextualActions(*m_Model, *meshPtr); } - else if (auto const* geomPtr = dynamic_cast(c)) + else if (const auto* geomPtr = dynamic_cast(c)) { DrawGeometryContextualActions(*m_Model, *geomPtr); } - else if (auto const* geomPathPtr = dynamic_cast(c)) + else if (const auto* geomPathPtr = dynamic_cast(c)) { DrawGeometryPathContextualActions(*m_Model, *geomPathPtr); } @@ -633,10 +633,10 @@ class osc::ComponentContextMenu::Impl final : public StandardPopup { ui::table_set_column_index(column++); if (ui::draw_small_button(socket.getConnecteeAsObject().getName())) { - m_Model->setSelected(dynamic_cast(&socket.getConnecteeAsObject())); + m_Model->setSelected(dynamic_cast(&socket.getConnecteeAsObject())); request_close(); } - if (auto const* connectee = dynamic_cast(&socket.getConnecteeAsObject()); + if (const auto* connectee = dynamic_cast(&socket.getConnecteeAsObject()); connectee && ui::is_item_hovered()) { DrawComponentHoverTooltip(*connectee); diff --git a/src/OpenSimCreator/UI/ModelEditor/CoordinateEditorPanel.cpp b/src/OpenSimCreator/UI/ModelEditor/CoordinateEditorPanel.cpp index 76a232a2e..dd5f8af24 100644 --- a/src/OpenSimCreator/UI/ModelEditor/CoordinateEditorPanel.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/CoordinateEditorPanel.cpp @@ -47,7 +47,7 @@ class osc::CoordinateEditorPanel::Impl final : public StandardPanelImpl { void impl_draw_content() final { // load coords - std::vector coordPtrs = GetCoordinatesInModel(m_Model->getModel()); + std::vector coordPtrs = GetCoordinatesInModel(m_Model->getModel()); // if there's no coordinates in the model, show a warning message and stop drawing if (coordPtrs.empty()) @@ -96,7 +96,7 @@ class osc::CoordinateEditorPanel::Impl final : public StandardPanelImpl { } int id = 0; - for (OpenSim::Coordinate const* coordPtr : coordPtrs) + for (const OpenSim::Coordinate* coordPtr : coordPtrs) { ui::push_id(id++); drawRow(*coordPtr); diff --git a/src/OpenSimCreator/UI/ModelEditor/EditorTabStatusBar.cpp b/src/OpenSimCreator/UI/ModelEditor/EditorTabStatusBar.cpp index 0e977f0b9..1b9292e86 100644 --- a/src/OpenSimCreator/UI/ModelEditor/EditorTabStatusBar.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/EditorTabStatusBar.cpp @@ -38,11 +38,11 @@ class osc::EditorTabStatusBar::Impl final { private: void drawSelectionBreadcrumbs() { - OpenSim::Component const* const c = m_Model->getSelected(); + const OpenSim::Component* const c = m_Model->getSelected(); if (c) { - std::vector const els = GetPathElements(*c); + std::vector const els = GetPathElements(*c); for (ptrdiff_t i = 0; i < std::ssize(els)-1; ++i) { ui::push_id(i); diff --git a/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp index 43c3fe879..676dea306 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp @@ -307,7 +307,7 @@ namespace DrawSelectionManipulatorButtons(uiState, model, state); } - OpenSim::Component const* TryGetMaybeSelectedFrameOrNullptr( + const OpenSim::Component* TryGetMaybeSelectedFrameOrNullptr( const FrameSelectorUiState& uiState, const OpenSim::Model& model) { @@ -320,7 +320,7 @@ namespace const FrameSelectorUiState& uiState, const OpenSim::Model& model) { - OpenSim::Component const* c = TryGetMaybeSelectedFrameOrNullptr(uiState, model); + const OpenSim::Component* c = TryGetMaybeSelectedFrameOrNullptr(uiState, model); return c ? c->getName() : std::string{c_OriginalFrameLabel}; } @@ -393,7 +393,7 @@ namespace return std::nullopt; // caller doesn't want re-expression } - auto const* const frame = FindComponent(model, *maybeAbsPathOfFrameToReexpressPointsIn); + const auto* const frame = FindComponent(model, *maybeAbsPathOfFrameToReexpressPointsIn); if (!frame) { return std::nullopt; // the selected frame doesn't exist in the model (bug?) @@ -422,7 +422,7 @@ namespace const PointInfo& pointInfo, const SimTK::Transform& ground2otherFrame) { - auto const* const frame = FindComponent(model, pointInfo.frameAbsPath); + const auto* const frame = FindComponent(model, pointInfo.frameAbsPath); if (!frame) { return pointInfo.location; // cannot find frame (bug?) @@ -439,7 +439,7 @@ namespace const std::string& pointAbsPath, std::ostream& out) { - OpenSim::Component const* const c = FindComponent(model, pointAbsPath); + const OpenSim::Component* const c = FindComponent(model, pointAbsPath); if (!c) { return; // skip writing: point no longer exists in model diff --git a/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp b/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp index f80ed727c..89b6a837d 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp @@ -474,7 +474,7 @@ namespace return PlottingTaskStatus::Cancelled; } - auto const* maybeMuscle = FindComponent(*model, params.getMusclePath()); + const auto* maybeMuscle = FindComponent(*model, params.getMusclePath()); if (!maybeMuscle) { shared.setErrorMessage(params.getMusclePath().toString() + ": cannot find a muscle with this name"); @@ -482,7 +482,7 @@ namespace } const OpenSim::Muscle& muscle = *maybeMuscle; - OpenSim::Coordinate const* maybeCoord = FindComponentMut(*model, params.getCoordinatePath()); + const OpenSim::Coordinate* maybeCoord = FindComponentMut(*model, params.getCoordinatePath()); if (!maybeCoord) { shared.setErrorMessage(params.getCoordinatePath().toString() + ": cannot find a coordinate with this name"); @@ -629,7 +629,7 @@ namespace return m_Name; } - PlotParameters const* tryGetParameters() const + const PlotParameters* tryGetParameters() const { return m_Parameters.has_value() ? &m_Parameters.value() : nullptr; } @@ -805,8 +805,8 @@ namespace std::span points = *lock; - float const* xPtr = nullptr; - float const* yPtr = nullptr; + const float* xPtr = nullptr; + const float* yPtr = nullptr; if (!points.empty()) { xPtr = &points.front().x; @@ -1091,7 +1091,7 @@ namespace // fetch the to-be-reverted-to curve std::shared_ptr ptr = m_PreviousPlots.at(i); - PlotParameters const* maybeParams = ptr->tryGetParameters(); + const PlotParameters* maybeParams = ptr->tryGetParameters(); // try to revert the current model to use the plot's commit if (maybeParams && model.tryCheckout(maybeParams->getCommit())) @@ -1126,7 +1126,7 @@ namespace // if the current plot doesn't match the latest requested params, kick off // a new plotting task - PlotParameters const* maybeParams = m_ActivePlot->tryGetParameters(); + const PlotParameters* maybeParams = m_ActivePlot->tryGetParameters(); if (!maybeParams || (*maybeParams) != desiredParams) { @@ -1561,7 +1561,7 @@ namespace const PlotParameters& latestParams = getShared().getPlotParams(); auto modelGuard = latestParams.getCommit().getModel(); - auto const* maybeCoord = FindComponent(*modelGuard, latestParams.getCoordinatePath()); + const auto* maybeCoord = FindComponent(*modelGuard, latestParams.getCoordinatePath()); if (!maybeCoord) { ui::draw_text("(no coordinate named %s in model)", latestParams.getCoordinatePath().toString().c_str()); return nullptr; @@ -1657,7 +1657,7 @@ namespace ui::set_next_item_width(muscleNameWidth); if (ui::begin_combobox("##musclename", muscleName, ImGuiComboFlags_NoArrowButton)) { - auto const* current = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getMusclePath()); + const auto* current = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getMusclePath()); for (const OpenSim::Muscle& musc : getShared().getModel().getModel().getComponentList()) { bool selected = &musc == current; @@ -1693,7 +1693,7 @@ namespace ui::set_next_item_width(coordNameWidth); if (ui::begin_combobox("##coordname", coordName, ImGuiComboFlags_NoArrowButton)) { - auto const* current = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getCoordinatePath()); + const auto* current = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getCoordinatePath()); for (const OpenSim::Coordinate& c : getShared().getModel().getModel().getComponentList()) { bool selected = &c == current; @@ -2110,7 +2110,7 @@ namespace // tries to duplicate the current plot (settings etc.) into a new plot panel void actionDuplicateCurrentPlotIntoNewPanel(const OpenSim::Coordinate& coord) { - auto const* musc = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getMusclePath()); + const auto* musc = FindComponent(getShared().getModel().getModel(), getShared().getPlotParams().getMusclePath()); if (musc) { updShared().updEditorAPI().addMusclePlot(coord, *musc); } @@ -2151,16 +2151,16 @@ namespace { std::unique_ptr rv; - std::vector coordinates; + std::vector coordinates; for (const OpenSim::Coordinate& coord : getShared().getModel().getModel().getComponentList()) { coordinates.push_back(&coord); } - rgs::sort(coordinates, rgs::less{}, [](auto const* ptr) { return ptr->getName(); }); + rgs::sort(coordinates, rgs::less{}, [](const auto* ptr) { return ptr->getName(); }); ui::draw_text("select coordinate:"); ui::begin_child_panel("MomentArmPlotCoordinateSelection"); - for (OpenSim::Coordinate const* coord : coordinates) { + for (const OpenSim::Coordinate* coord : coordinates) { if (ui::draw_selectable(coord->getName())) { updShared().updPlotParams().setCoordinatePath(GetAbsolutePath(*coord)); rv = std::make_unique(updShared()); @@ -2187,11 +2187,11 @@ namespace { std::unique_ptr rv; - std::vector muscles; + std::vector muscles; for (const OpenSim::Muscle& musc : getShared().getModel().getModel().getComponentList()) { muscles.push_back(&musc); } - rgs::sort(muscles, rgs::less{}, [](auto const* ptr) { return ptr->getName(); }); + rgs::sort(muscles, rgs::less{}, [](const auto* ptr) { return ptr->getName(); }); ui::draw_text("select muscle:"); @@ -2200,7 +2200,7 @@ namespace } else { ui::begin_child_panel("MomentArmPlotMuscleSelection"); - for (OpenSim::Muscle const* musc : muscles) { + for (const OpenSim::Muscle* musc : muscles) { if (ui::draw_selectable(musc->getName())) { updShared().updPlotParams().setMusclePath(GetAbsolutePath(*musc)); rv = std::make_unique(updShared()); diff --git a/src/OpenSimCreator/UI/ModelEditor/ReassignSocketPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/ReassignSocketPopup.cpp index 3466134a1..1671e7b33 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ReassignSocketPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ReassignSocketPopup.cpp @@ -84,13 +84,13 @@ namespace { std::vector rv; - OpenSim::Component const* component = FindComponent(model, params.componentPath); + const OpenSim::Component* component = FindComponent(model, params.componentPath); if (!component) { return rv; // component isn't in model? } - OpenSim::AbstractSocket const* socket = FindSocket(*component, params.socketName); + const OpenSim::AbstractSocket* socket = FindSocket(*component, params.socketName); if (!socket) { return rv; // socket isn't in model? @@ -150,7 +150,7 @@ class osc::ReassignSocketPopup::Impl final : public StandardPopup { } // check: ensure the "from" side of the socket still exists - OpenSim::Component const* component = FindComponent(m_Model->getModel(), m_Params.componentPath); + const OpenSim::Component* component = FindComponent(m_Model->getModel(), m_Params.componentPath); if (!component) { request_close(); @@ -158,7 +158,7 @@ class osc::ReassignSocketPopup::Impl final : public StandardPopup { } // check: ensure the socket still exists - OpenSim::AbstractSocket const* socket = FindSocket(*component, m_Params.socketName); + const OpenSim::AbstractSocket* socket = FindSocket(*component, m_Params.socketName); if (!socket) { request_close(); @@ -213,7 +213,7 @@ class osc::ReassignSocketPopup::Impl final : public StandardPopup { SocketReassignmentFlags::TryReexpressComponentInNewConnectee : SocketReassignmentFlags::None; - OpenSim::Component const* selected = FindComponent(m_Model->getModel(), *userSelection); + const OpenSim::Component* selected = FindComponent(m_Model->getModel(), *userSelection); if (selected && ActionReassignComponentSocket(*m_Model, m_Params.componentPath, m_Params.socketName, *selected, flags, m_Error)) { @@ -240,7 +240,7 @@ class osc::ReassignSocketPopup::Impl final : public StandardPopup { return std::move(ss).str(); }(); - auto const* const physFrameSocket = + const auto* const physFrameSocket = dynamic_cast const*>(&abstractSocket); if (!physFrameSocket) { diff --git a/src/OpenSimCreator/UI/ModelEditor/Select1PFPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/Select1PFPopup.cpp index 261e703a9..6eaa6607c 100644 --- a/src/OpenSimCreator/UI/ModelEditor/Select1PFPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/Select1PFPopup.cpp @@ -29,7 +29,7 @@ class osc::Select1PFPopup::Impl final : public StandardPopup { private: void impl_draw_content() final { - OpenSim::PhysicalFrame const* selected = nullptr; + const OpenSim::PhysicalFrame* selected = nullptr; ui::begin_child_panel("pflist", Vec2{256.0f, 256.0f}, ImGuiChildFlags_Border, ImGuiWindowFlags_HorizontalScrollbar); for (const auto& pf : m_Model->getModel().getComponentList()) diff --git a/src/OpenSimCreator/UI/ModelEditor/SelectComponentPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/SelectComponentPopup.cpp index 94bc1281b..227f1c780 100644 --- a/src/OpenSimCreator/UI/ModelEditor/SelectComponentPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/SelectComponentPopup.cpp @@ -30,7 +30,7 @@ class osc::SelectComponentPopup::Impl final : public StandardPopup { private: void impl_draw_content() final { - OpenSim::Component const* selected = nullptr; + const OpenSim::Component* selected = nullptr; // iterate through each T in `root` and give the user the option to click it { diff --git a/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp b/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp index 36f659c30..3ba3d9f60 100644 --- a/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp +++ b/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp @@ -328,7 +328,7 @@ void osc::DrawSelectOwnerMenu(IModelStatePair& model, const OpenSim::Component& model.setHovered(nullptr); for ( - OpenSim::Component const* owner = GetOwner(selected); + const OpenSim::Component* owner = GetOwner(selected); owner != nullptr; owner = GetOwner(*owner)) { @@ -379,7 +379,7 @@ bool osc::DrawWatchOutputMenu( // iterate from the selected component upwards to the root int imguiId = 0; - for (OpenSim::Component const* p = &c; p; p = GetOwner(*p)) + for (const OpenSim::Component* p = &c; p; p = GetOwner(*p)) { ui::push_id(imguiId++); @@ -480,7 +480,7 @@ void osc::DrawOutputNameColumn( // (e.g. if the user mouses over the name of a component output it should make // the associated component the current hover to provide immediate feedback to // the user) - if (auto const* co = dynamic_cast(&output); co && maybeActiveSate) + if (const auto* co = dynamic_cast(&output); co && maybeActiveSate) { if (ui::is_item_hovered()) { @@ -503,7 +503,7 @@ void osc::DrawOutputNameColumn( void osc::DrawWithRespectToMenuContainingMenuPerFrame( const OpenSim::Component& root, std::function const& onFrameMenuOpened, - OpenSim::Frame const* maybeParent) + const OpenSim::Frame* maybeParent) { ui::draw_text_disabled("With Respect to:"); ui::draw_separator(); @@ -537,7 +537,7 @@ void osc::DrawWithRespectToMenuContainingMenuPerFrame( void osc::DrawWithRespectToMenuContainingMenuItemPerFrame( const OpenSim::Component& root, std::function const& onFrameMenuItemClicked, - OpenSim::Frame const* maybeParent = nullptr) + const OpenSim::Frame* maybeParent = nullptr) { ui::draw_text_disabled("With Respect to:"); ui::draw_separator(); @@ -632,7 +632,7 @@ void osc::DrawCalculatePositionMenu( const OpenSim::Component& root, const SimTK::State& state, const OpenSim::Point& point, - OpenSim::Frame const* maybeParent) + const OpenSim::Frame* maybeParent) { if (ui::begin_menu("Position")) { @@ -807,7 +807,7 @@ void osc::DrawCalculateMenu( { if (BeginCalculateMenu(flags)) { - if (auto const* spherePtr = dynamic_cast(&geom)) + if (const auto* spherePtr = dynamic_cast(&geom)) { DrawCalculateOriginMenu(root, state, *spherePtr); DrawCalculateRadiusMenu(root, state, *spherePtr); @@ -829,11 +829,11 @@ void osc::TryDrawCalculateMenu( const OpenSim::Component& selected, CalculateMenuFlags flags) { - if (auto const* const frame = dynamic_cast(&selected)) + if (const auto* const frame = dynamic_cast(&selected)) { DrawCalculateMenu(root, state, *frame, flags); } - else if (auto const* const point = dynamic_cast(&selected)) + else if (const auto* const point = dynamic_cast(&selected)) { DrawCalculateMenu(root, state, *point, flags); } diff --git a/src/OpenSimCreator/UI/Shared/BasicWidgets.h b/src/OpenSimCreator/UI/Shared/BasicWidgets.h index afada24e0..6dfe89fc9 100644 --- a/src/OpenSimCreator/UI/Shared/BasicWidgets.h +++ b/src/OpenSimCreator/UI/Shared/BasicWidgets.h @@ -84,7 +84,7 @@ namespace osc void DrawWithRespectToMenuContainingMenuPerFrame( const OpenSim::Component& root, std::function const& onFrameMenuOpened, - OpenSim::Frame const* maybeParent + const OpenSim::Frame* maybeParent ); // draws a "With Respect to" menu that prompts the user to click a frame @@ -95,7 +95,7 @@ namespace osc void DrawWithRespectToMenuContainingMenuItemPerFrame( const OpenSim::Component& root, std::function const& onFrameMenuItemClicked, - OpenSim::Frame const* maybeParent + const OpenSim::Frame* maybeParent ); void DrawPointTranslationInformationWithRespectTo( @@ -132,7 +132,7 @@ namespace osc const OpenSim::Component& root, const SimTK::State&, const OpenSim::Point&, - OpenSim::Frame const* maybeParent + const OpenSim::Frame* maybeParent ); void DrawCalculateMenu( const OpenSim::Component& root, diff --git a/src/OpenSimCreator/UI/Shared/ChooseComponentsEditorLayer.cpp b/src/OpenSimCreator/UI/Shared/ChooseComponentsEditorLayer.cpp index b492d0451..c6875d331 100644 --- a/src/OpenSimCreator/UI/Shared/ChooseComponentsEditorLayer.cpp +++ b/src/OpenSimCreator/UI/Shared/ChooseComponentsEditorLayer.cpp @@ -227,7 +227,7 @@ class osc::ChooseComponentsEditorLayer::Impl final { } // show tooltip - if (OpenSim::Component const* c = FindComponent(m_State.model->getModel(), m_State.hoveredComponent)) + if (const OpenSim::Component* c = FindComponent(m_State.model->getModel(), m_State.hoveredComponent)) { DrawComponentHoverTooltip(*c); } @@ -274,7 +274,7 @@ class osc::ChooseComponentsEditorLayer::Impl final { bool tryToggleHover() { const std::string& absPath = m_State.hoveredComponent; - OpenSim::Component const* component = FindComponent(m_State.model->getModel(), absPath); + const OpenSim::Component* component = FindComponent(m_State.model->getModel(), absPath); if (!component) { diff --git a/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.cpp b/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.cpp index 44f244f71..a12c026b0 100644 --- a/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.cpp +++ b/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.cpp @@ -26,9 +26,9 @@ namespace constexpr auto c_LocationInputIDs = std::to_array({ "##xinput", "##yinput", "##zinput" }); static_assert(c_LocationInputIDs.size() == 3); - OpenSim::GeometryPath CopyOrDefaultGeometryPath(std::function const& accessor) + OpenSim::GeometryPath CopyOrDefaultGeometryPath(std::function const& accessor) { - OpenSim::GeometryPath const* maybeGeomPath = accessor(); + const OpenSim::GeometryPath* maybeGeomPath = accessor(); if (maybeGeomPath) { return *maybeGeomPath; @@ -121,7 +121,7 @@ class osc::GeometryPathEditorPopup::Impl final : public StandardPopup { Impl( std::string_view popupName_, std::shared_ptr targetModel_, - std::function geometryPathGetter_, + std::function geometryPathGetter_, std::function onLocalCopyEdited_) : StandardPopup{popupName_, {768.0f, 0.0f}, ImGuiWindowFlags_AlwaysAutoResize}, @@ -362,7 +362,7 @@ class osc::GeometryPathEditorPopup::Impl final : public StandardPopup { } std::shared_ptr m_TargetModel; - std::function m_GeometryPathGetter; + std::function m_GeometryPathGetter; std::function m_OnLocalCopyEdited; OpenSim::GeometryPath m_EditedGeometryPath; @@ -375,7 +375,7 @@ class osc::GeometryPathEditorPopup::Impl final : public StandardPopup { osc::GeometryPathEditorPopup::GeometryPathEditorPopup( std::string_view popupName_, std::shared_ptr targetModel_, - std::function geometryPathGetter_, + std::function geometryPathGetter_, std::function onLocalCopyEdited_) : m_Impl{std::make_unique(popupName_, std::move(targetModel_), std::move(geometryPathGetter_), std::move(onLocalCopyEdited_))} diff --git a/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.h b/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.h index 8995d456e..74c08eb3b 100644 --- a/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.h +++ b/src/OpenSimCreator/UI/Shared/GeometryPathEditorPopup.h @@ -17,7 +17,7 @@ namespace osc GeometryPathEditorPopup( std::string_view popupName_, std::shared_ptr targetModel_, - std::function geometryPathGetter_, + std::function geometryPathGetter_, std::function onLocalCopyEdited_ ); GeometryPathEditorPopup(const GeometryPathEditorPopup&) = delete; diff --git a/src/OpenSimCreator/UI/Shared/ModelEditorViewerPanel.cpp b/src/OpenSimCreator/UI/Shared/ModelEditorViewerPanel.cpp index 05d125700..03ae0d279 100644 --- a/src/OpenSimCreator/UI/Shared/ModelEditorViewerPanel.cpp +++ b/src/OpenSimCreator/UI/Shared/ModelEditorViewerPanel.cpp @@ -293,7 +293,7 @@ namespace m_IsHandlingMouseInputs && !ui::is_mouse_dragging_with_any_button_down()) { - if (OpenSim::Component const* c = FindComponent(params.getModelSharedPtr()->getModel(), state.maybeHoveredComponentAbsPath)) + if (const OpenSim::Component* c = FindComponent(params.getModelSharedPtr()->getModel(), state.maybeHoveredComponentAbsPath)) { DrawComponentHoverTooltip(*c); } diff --git a/src/OpenSimCreator/UI/Shared/ModelSelectionGizmo.cpp b/src/OpenSimCreator/UI/Shared/ModelSelectionGizmo.cpp index f19743acf..8169ea67a 100644 --- a/src/OpenSimCreator/UI/Shared/ModelSelectionGizmo.cpp +++ b/src/OpenSimCreator/UI/Shared/ModelSelectionGizmo.cpp @@ -122,7 +122,7 @@ namespace OSC_ASSERT(FindComponent(m_Model->getModel(), m_ComponentAbsPath)); } - TComponent const* findSelection() const + const TComponent* findSelection() const { return FindComponent(m_Model->getModel(), m_ComponentAbsPath); } @@ -146,7 +146,7 @@ namespace // perform runtime lookup for `TComponent` and forward into concrete implementation Mat4 implGetCurrentModelMatrix() const final { - TComponent const* maybeSelected = findSelection(); + const TComponent* maybeSelected = findSelection(); if (!maybeSelected) { return identity(); // selection of that type does not exist in the model @@ -157,7 +157,7 @@ namespace // perform runtime lookup for `TComponent` and forward into concrete implementation void implOnApplyTranslation(const Vec3& deltaTranslationInGround) final { - TComponent const* maybeSelected = findSelection(); + const TComponent* maybeSelected = findSelection(); if (!maybeSelected) { return; // selection of that type does not exist in the model @@ -168,7 +168,7 @@ namespace // perform runtime lookup for `TComponent` and forward into concrete implementation void implOnApplyRotation(const Eulers& deltaEulerRadiansInGround) final { - TComponent const* maybeSelected = findSelection(); + const TComponent* maybeSelected = findSelection(); if (!maybeSelected) { return; // selection of that type does not exist in the model @@ -178,7 +178,7 @@ namespace void implOnSave() final { - TComponent const* maybeSelected = findSelection(); + const TComponent* maybeSelected = findSelection(); if (!maybeSelected) { return; // selection of that type does not exist in the model @@ -633,27 +633,27 @@ namespace bool& wasUsingLastFrameStorage) { // use downcasting to figure out which gizmo implementation to use - if (auto const* const maybeStation = dynamic_cast(&selected)) + if (const auto* const maybeStation = dynamic_cast(&selected)) { StationManipulator manipulator{model, *maybeStation}; DrawGizmoOverlayInner(gizmoID, camera, viewportRect, operation, mode, manipulator, wasUsingLastFrameStorage); } - else if (auto const* const maybePathPoint = dynamic_cast(&selected)) + else if (const auto* const maybePathPoint = dynamic_cast(&selected)) { PathPointManipulator manipulator{model, *maybePathPoint}; DrawGizmoOverlayInner(gizmoID, camera, viewportRect, operation, mode, manipulator, wasUsingLastFrameStorage); } - else if (auto const* const maybePof = dynamic_cast(&selected)) + else if (const auto* const maybePof = dynamic_cast(&selected)) { PhysicalOffsetFrameManipulator manipulator{model, *maybePof}; DrawGizmoOverlayInner(gizmoID, camera, viewportRect, operation, mode, manipulator, wasUsingLastFrameStorage); } - else if (auto const* const maybeWrapObject = dynamic_cast(&selected)) + else if (const auto* const maybeWrapObject = dynamic_cast(&selected)) { WrapObjectManipulator manipulator{model, *maybeWrapObject}; DrawGizmoOverlayInner(gizmoID, camera, viewportRect, operation, mode, manipulator, wasUsingLastFrameStorage); } - else if (auto const* const maybeContactGeom = dynamic_cast(&selected)) + else if (const auto* const maybeContactGeom = dynamic_cast(&selected)) { ContactGeometryManipulator manipulator{model, *maybeContactGeom}; DrawGizmoOverlayInner(gizmoID, camera, viewportRect, operation, mode, manipulator, wasUsingLastFrameStorage); @@ -678,7 +678,7 @@ osc::ModelSelectionGizmo::~ModelSelectionGizmo() noexcept = default; bool osc::ModelSelectionGizmo::isUsing() const { - ImGuizmo::SetID(static_cast(std::hash{}(this))); + ImGuizmo::SetID(static_cast(std::hash{}(this))); bool const rv = ImGuizmo::IsUsing(); ImGuizmo::SetID(-1); return rv; @@ -686,7 +686,7 @@ bool osc::ModelSelectionGizmo::isUsing() const bool osc::ModelSelectionGizmo::isOver() const { - ImGuizmo::SetID(static_cast(std::hash{}(this))); + ImGuizmo::SetID(static_cast(std::hash{}(this))); bool const rv = ImGuizmo::IsOver(); ImGuizmo::SetID(-1); return rv; @@ -701,7 +701,7 @@ void osc::ModelSelectionGizmo::onDraw( const Rect& screenRect, const PolarPerspectiveCamera& camera) { - OpenSim::Component const* selected = m_Model->getSelected(); + const OpenSim::Component* selected = m_Model->getSelected(); if (!selected) { return; diff --git a/src/OpenSimCreator/UI/Shared/NavigatorPanel.cpp b/src/OpenSimCreator/UI/Shared/NavigatorPanel.cpp index 12bc85a8f..117885db4 100644 --- a/src/OpenSimCreator/UI/Shared/NavigatorPanel.cpp +++ b/src/OpenSimCreator/UI/Shared/NavigatorPanel.cpp @@ -98,12 +98,12 @@ namespace size_t m_Size = 0; }; - using ComponentPath = SizedArray; + using ComponentPath = SizedArray; // populates `out` with the sequence of nodes between (ancestor..child] void computeComponentPath( - OpenSim::Component const* ancestor, - OpenSim::Component const* child, + const OpenSim::Component* ancestor, + const OpenSim::Component* child, ComponentPath& out) { @@ -124,7 +124,7 @@ namespace rgs::reverse(out); } - bool pathContains(const ComponentPath& p, OpenSim::Component const* c) + bool pathContains(const ComponentPath& p, const OpenSim::Component* c) { auto end = p.begin() == p.end() ? p.end() : p.end()-1; return cpp23::contains(p.begin(), end, c); @@ -137,13 +137,13 @@ namespace }; struct Response final { - OpenSim::Component const* ptr = nullptr; + const OpenSim::Component* ptr = nullptr; ResponseType type = ResponseType::NothingHappened; }; bool isSearchHit(const std::string& searchStr, const ComponentPath& cp) { - return rgs::any_of(cp, [&searchStr](OpenSim::Component const* c) + return rgs::any_of(cp, [&searchStr](const OpenSim::Component* c) { return contains_case_insensitive(c->getName(), searchStr); }); @@ -223,9 +223,9 @@ class osc::NavigatorPanel::Impl final : public StandardPanelImpl { // draw content ui::begin_child_panel("##componentnavigatorvieweritems", {0.0, 0.0}, ImGuiChildFlags_None, ImGuiWindowFlags_NoBackground); - OpenSim::Component const* root = &m_Model->getModel(); - OpenSim::Component const* selection = m_Model->getSelected(); - OpenSim::Component const* hover = m_Model->getHovered(); + const OpenSim::Component* root = &m_Model->getModel(); + const OpenSim::Component* selection = m_Model->getSelected(); + const OpenSim::Component* hover = m_Model->getHovered(); ComponentPath selectionPath{}; if (selection) @@ -245,12 +245,12 @@ class osc::NavigatorPanel::Impl final : public StandardPanelImpl { auto const end = lst.end(); // initially populate lookahead (+ path) - OpenSim::Component const* lookahead = root; + const OpenSim::Component* lookahead = root; ComponentPath lookaheadPath; computeComponentPath(root, root, lookaheadPath); // set cur path empty (first step copies lookahead into this) - OpenSim::Component const* cur = nullptr; + const OpenSim::Component* cur = nullptr; ComponentPath currentPath; int imguiTreeDepth = 0; @@ -280,11 +280,11 @@ class osc::NavigatorPanel::Impl final : public StandardPanelImpl { bool shouldRender = true; - if (!m_ShowFrames && dynamic_cast(&c)) + if (!m_ShowFrames && dynamic_cast(&c)) { shouldRender = false; } - else if (auto const* wos = dynamic_cast(&c)) + else if (const auto* wos = dynamic_cast(&c)) { shouldRender = !empty(*wos); } diff --git a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp index 869312264..c55ebac2b 100644 --- a/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp +++ b/src/OpenSimCreator/UI/Shared/ObjectPropertiesEditor.cpp @@ -367,15 +367,15 @@ namespace struct PropertyEditorArgs final { IPopupAPI* api; std::shared_ptr model; - std::function objectAccessor; - std::function propertyAccessor; + std::function objectAccessor; + std::function propertyAccessor; }; template ConcreteProperty> struct PropertyEditorTraits { static bool IsCompatibleWith(const OpenSim::AbstractProperty& prop) { - return dynamic_cast(&prop) != nullptr; + return dynamic_cast(&prop) != nullptr; } }; @@ -399,16 +399,16 @@ namespace } protected: - property_type const* tryGetProperty() const + const property_type* tryGetProperty() const { - return dynamic_cast(m_Args.propertyAccessor()); + return dynamic_cast(m_Args.propertyAccessor()); } - std::function getPropertyAccessor() const + std::function getPropertyAccessor() const { return [accessor = this->m_Args.propertyAccessor]() { - return dynamic_cast(accessor()); + return dynamic_cast(accessor()); }; } @@ -427,7 +427,7 @@ namespace return m_Args.model->getState(); } - OpenSim::Object const* tryGetObject() const + const OpenSim::Object* tryGetObject() const { return m_Args.objectAccessor(); } @@ -466,7 +466,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -554,7 +554,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -646,7 +646,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -777,13 +777,13 @@ namespace // property's value to ground std::optional getParentToGroundTransform() const { - OpenSim::Object const* const obj = tryGetObject(); + const OpenSim::Object* const obj = tryGetObject(); if (!obj) { return std::nullopt; // cannot find the property's parent object? } - auto const* const component = dynamic_cast(obj); + const auto* const component = dynamic_cast(obj); if (!component) { return std::nullopt; // the object isn't an OpenSim component @@ -831,7 +831,7 @@ namespace } const OpenSim::Model& model = getModel(); - auto const* frame = FindComponent(model, *m_MaybeUserSelectedFrameAbsPath); + const auto* frame = FindComponent(model, *m_MaybeUserSelectedFrameAbsPath); return frame->getTransformInGround(getState()).invert(); } @@ -854,7 +854,7 @@ namespace std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -1072,7 +1072,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -1167,7 +1167,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -1260,7 +1260,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -1379,7 +1379,7 @@ namespace { std::optional> rv; - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; // cannot find property @@ -1440,7 +1440,7 @@ namespace private: std::optional> implOnDraw() final { - property_type const* maybeProp = tryGetProperty(); + const property_type* maybeProp = tryGetProperty(); if (!maybeProp) { return std::nullopt; @@ -1475,18 +1475,18 @@ namespace return std::make_unique( "Edit Geometry Path", getModelPtr(), - [accessor]() -> OpenSim::GeometryPath const* + [accessor]() -> const OpenSim::GeometryPath* { - property_type const* p = accessor(); + const property_type* p = accessor(); if (!p || p->isListProperty()) { return nullptr; } - return dynamic_cast(&p->getValueAsObject()); + return dynamic_cast(&p->getValueAsObject()); }, [shared = m_ReturnValueHolder, accessor](const OpenSim::GeometryPath& gp) mutable { - if (property_type const* prop = accessor()) + if (const property_type* prop = accessor()) { *shared = ObjectPropertyEdit{*prop, MakePropValueSetter(0, gp)}; } @@ -1566,7 +1566,7 @@ namespace public: std::unique_ptr tryCreateEditor(PropertyEditorArgs args) const { - OpenSim::AbstractProperty const* prop = args.propertyAccessor(); + const OpenSim::AbstractProperty* prop = args.propertyAccessor(); if (!prop) { return nullptr; // cannot access the property @@ -1600,7 +1600,7 @@ class osc::ObjectPropertiesEditor::Impl final { Impl( IPopupAPI* api_, std::shared_ptr targetModel_, - std::function objectGetter_) : + std::function objectGetter_) : m_API{api_}, m_TargetModel{std::move(targetModel_)}, @@ -1610,7 +1610,7 @@ class osc::ObjectPropertiesEditor::Impl final { std::optional onDraw() { - if (OpenSim::Object const* maybeObj = m_ObjectGetter()) + if (const OpenSim::Object* maybeObj = m_ObjectGetter()) { // object accessible: draw property editors return drawPropertyEditors(*maybeObj); @@ -1731,8 +1731,8 @@ class osc::ObjectPropertiesEditor::Impl final { IPopupAPI* m_API; std::shared_ptr m_TargetModel; - std::function m_ObjectGetter; - OpenSim::Object const* m_PreviousObject = nullptr; + std::function m_ObjectGetter; + const OpenSim::Object* m_PreviousObject = nullptr; std::unordered_map> m_PropertyEditorsByName; }; @@ -1742,7 +1742,7 @@ class osc::ObjectPropertiesEditor::Impl final { osc::ObjectPropertiesEditor::ObjectPropertiesEditor( IPopupAPI* api_, std::shared_ptr targetModel_, - std::function objectGetter_) : + std::function objectGetter_) : m_Impl{std::make_unique(api_, std::move(targetModel_), std::move(objectGetter_))} {