Skip to content

Commit

Permalink
Clean up headers in OpenSimCreator/ModelGraph (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Nov 17, 2023
1 parent 6492804 commit 7054d9f
Show file tree
Hide file tree
Showing 19 changed files with 251 additions and 175 deletions.
4 changes: 3 additions & 1 deletion src/OpenSimCreator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ add_library(OpenSimCreator STATIC
ModelGraph/CrossrefDirection.hpp
ModelGraph/EdgeEl.cpp
ModelGraph/EdgeEl.hpp
ModelGraph/GroundEl.cpp
ModelGraph/GroundEl.hpp
ModelGraph/ISceneElLookup.hpp
ModelGraph/JointEl.cpp
ModelGraph/JointEl.hpp
ModelGraph/MeshEl.cpp
ModelGraph/MeshEl.hpp
ModelGraph/ModelCreationFlags.hpp
ModelGraph/ModelGraph.cpp
ModelGraph/ModelGraph.hpp
ModelGraph/ModelGraphHelpers.cpp
ModelGraph/ModelGraphHelpers.hpp
Expand Down Expand Up @@ -271,7 +273,7 @@ add_library(OpenSimCreator STATIC
Utils/TPS3D.hpp
Utils/UndoableModelActions.cpp
Utils/UndoableModelActions.hpp
"UI/Tabs/MeshImporter/ImportStationsFromCSVPopup.cpp")
)

# OpenSimCreatorConfig.hpp
#
Expand Down
25 changes: 25 additions & 0 deletions src/OpenSimCreator/ModelGraph/BodyEl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "BodyEl.hpp"

#include <OpenSimCreator/ModelGraph/ModelGraphStrings.hpp>
#include <OpenSimCreator/ModelGraph/SceneElClass.hpp>
#include <OpenSimCreator/Utils/OpenSimHelpers.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/Transform.hpp>
#include <oscar/Utils/UID.hpp>

#include <iostream>
#include <string>
#include <string_view>

Expand All @@ -23,3 +27,24 @@ void osc::BodyEl::implSetLabel(std::string_view sv)
{
m_Name = SanitizeToOpenSimComponentName(sv);
}

osc::SceneElClass osc::BodyEl::CreateClass()
{
return
{
ModelGraphStrings::c_BodyLabel,
ModelGraphStrings::c_BodyLabelPluralized,
ModelGraphStrings::c_BodyLabelOptionallyPluralized,
ICON_FA_CIRCLE,
ModelGraphStrings::c_BodyDescription,
};
}

std::ostream& osc::BodyEl::implWriteToStream(std::ostream& o) const
{
return o << "BodyEl(ID = " << m_ID
<< ", Name = " << m_Name
<< ", m_Transform = " << m_Xform
<< ", Mass = " << Mass
<< ')';
}
27 changes: 4 additions & 23 deletions src/OpenSimCreator/ModelGraph/BodyEl.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#pragma once

#include <OpenSimCreator/ModelGraph/ModelGraphIDs.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphStrings.hpp>
#include <OpenSimCreator/ModelGraph/SceneElClass.hpp>
#include <OpenSimCreator/ModelGraph/SceneElCRTP.hpp>
#include <OpenSimCreator/ModelGraph/SceneElFlags.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/AABB.hpp>
#include <oscar/Maths/Transform.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/UID.hpp>

#include <iostream>
#include <iosfwd>
#include <string>
#include <string_view>

namespace osc
{
Expand Down Expand Up @@ -44,17 +42,7 @@ namespace osc
}
private:
friend class SceneElCRTP<BodyEl>;
static SceneElClass CreateClass()
{
return
{
ModelGraphStrings::c_BodyLabel,
ModelGraphStrings::c_BodyLabelPluralized,
ModelGraphStrings::c_BodyLabelOptionallyPluralized,
ICON_FA_CIRCLE,
ModelGraphStrings::c_BodyDescription,
};
}
static SceneElClass CreateClass();

SceneElFlags implGetFlags() const final
{
Expand All @@ -71,14 +59,7 @@ namespace osc
return m_ID;
}

std::ostream& implWriteToStream(std::ostream& o) const final
{
return o << "BodyEl(ID = " << m_ID
<< ", Name = " << m_Name
<< ", m_Transform = " << m_Xform
<< ", Mass = " << Mass
<< ')';
}
std::ostream& implWriteToStream(std::ostream&) const final;

CStringView implGetLabel() const final
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <OpenSimCreator/ModelGraph/JointEl.hpp>
#include <OpenSimCreator/ModelGraph/MeshEl.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraph.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphIDs.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphHelpers.hpp>
#include <OpenSimCreator/ModelGraph/SceneEl.hpp>
#include <OpenSimCreator/ModelGraph/SceneElHelpers.hpp>
Expand Down
21 changes: 21 additions & 0 deletions src/OpenSimCreator/ModelGraph/EdgeEl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

#include <OpenSimCreator/ModelGraph/ISceneElLookup.hpp>
#include <OpenSimCreator/ModelGraph/SceneEl.hpp>
#include <OpenSimCreator/ModelGraph/SceneElClass.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/AABB.hpp>
#include <oscar/Maths/MathHelpers.hpp>
#include <oscar/Maths/Transform.hpp>
#include <oscar/Maths/Vec3.hpp>

#include <iostream>

osc::SceneElClass osc::EdgeEl::CreateClass()
{
return SceneElClass
{
"Edge",
"Edges",
"Edge(s)",
ICON_FA_ARROWS_ALT,
"An edge between the centers of two other scene elements",
};
}

osc::Transform osc::EdgeEl::implGetXform(ISceneElLookup const& lookup) const
{
SceneEl const* first = lookup.find(m_FirstAttachmentID);
Expand All @@ -23,6 +39,11 @@ osc::Transform osc::EdgeEl::implGetXform(ISceneElLookup const& lookup) const
}
}

std::ostream& osc::EdgeEl::implWriteToStream(std::ostream& out) const
{
return out << "Edge(id = " << m_ID << ", lhs = " << m_FirstAttachmentID << ", rhs = " << m_SecondAttachmentID << ')';
}

osc::AABB osc::EdgeEl::implCalcBounds(ISceneElLookup const& lookup) const
{
SceneEl const* first = lookup.find(m_FirstAttachmentID);
Expand Down
22 changes: 5 additions & 17 deletions src/OpenSimCreator/ModelGraph/EdgeEl.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#pragma once

#include <OpenSimCreator/ModelGraph/CrossrefDescriptor.hpp>
#include <OpenSimCreator/ModelGraph/SceneElClass.hpp>
#include <OpenSimCreator/ModelGraph/SceneElCRTP.hpp>
#include <OpenSimCreator/ModelGraph/SceneElFlags.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/AABB.hpp>
#include <oscar/Maths/Transform.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/UID.hpp>

#include <iostream>
#include <iosfwd>
#include <stdexcept>
#include <string_view>
#include <vector>

Expand Down Expand Up @@ -40,17 +41,7 @@ namespace osc
}
private:
friend class SceneElCRTP<EdgeEl>;
static SceneElClass CreateClass()
{
return SceneElClass
{
"Edge",
"Edges",
"Edge(s)",
ICON_FA_ARROWS_ALT,
"An edge between the centers of two other scene elements",
};
}
static SceneElClass CreateClass();

std::vector<CrossrefDescriptor> implGetCrossReferences() const final
{
Expand Down Expand Up @@ -89,10 +80,7 @@ namespace osc
return m_ID;
}

std::ostream& implWriteToStream(std::ostream& out) const final
{
return out << "Edge(id = " << m_ID << ", lhs = " << m_FirstAttachmentID << ", rhs = " << m_SecondAttachmentID << ')';
}
std::ostream& implWriteToStream(std::ostream&) const final;

CStringView implGetLabel() const
{
Expand Down
38 changes: 38 additions & 0 deletions src/OpenSimCreator/ModelGraph/GroundEl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "GroundEl.hpp"

#include <OpenSimCreator/ModelGraph/ModelGraphStrings.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphIDs.hpp>
#include <OpenSimCreator/ModelGraph/SceneElClass.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/UID.hpp>

#include <iostream>

osc::SceneElClass osc::GroundEl::CreateClass()
{
return
{
ModelGraphStrings::c_GroundLabel,
ModelGraphStrings::c_GroundLabelPluralized,
ModelGraphStrings::c_GroundLabelOptionallyPluralized,
ICON_FA_DOT_CIRCLE,
ModelGraphStrings::c_GroundDescription,
};
}

osc::UID osc::GroundEl::implGetID() const
{
return ModelGraphIDs::Ground();
}

std::ostream& osc::GroundEl::implWriteToStream(std::ostream& o) const
{
return o << ModelGraphStrings::c_GroundLabel << "()";
}

osc::CStringView osc::GroundEl::implGetLabel() const
{
return ModelGraphStrings::c_GroundLabel;
}
32 changes: 5 additions & 27 deletions src/OpenSimCreator/ModelGraph/GroundEl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,32 @@

#include <OpenSimCreator/ModelGraph/SceneElCRTP.hpp>
#include <OpenSimCreator/ModelGraph/SceneElFlags.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphIDs.hpp>
#include <OpenSimCreator/ModelGraph/ModelGraphStrings.hpp>

#include <IconsFontAwesome5.h>
#include <oscar/Maths/AABB.hpp>
#include <oscar/Maths/Transform.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/UID.hpp>

#include <iostream>
#include <iosfwd>

namespace osc
{
// "Ground" of the scene (i.e. origin)
class GroundEl final : public SceneElCRTP<GroundEl> {
private:
friend class SceneElCRTP<GroundEl>;
static SceneElClass CreateClass()
{
return
{
ModelGraphStrings::c_GroundLabel,
ModelGraphStrings::c_GroundLabelPluralized,
ModelGraphStrings::c_GroundLabelOptionallyPluralized,
ICON_FA_DOT_CIRCLE,
ModelGraphStrings::c_GroundDescription,
};
}
static SceneElClass CreateClass();

SceneElFlags implGetFlags() const final
{
return SceneElFlags::None;
}

UID implGetID() const final
{
return ModelGraphIDs::Ground();
}
UID implGetID() const final;

std::ostream& implWriteToStream(std::ostream& o) const final
{
return o << ModelGraphStrings::c_GroundLabel << "()";
}
std::ostream& implWriteToStream(std::ostream&) const final;

CStringView implGetLabel() const final
{
return ModelGraphStrings::c_GroundLabel;
}
CStringView implGetLabel() const final;

Transform implGetXform(ISceneElLookup const&) const final
{
Expand Down
3 changes: 2 additions & 1 deletion src/OpenSimCreator/ModelGraph/ISceneElLookup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

#include <oscar/Utils/UID.hpp>

namespace osc { class SceneEl; }

namespace osc
{
// virtual interface to something that can be used to lookup scene elements in
// some larger document
class SceneEl;
class ISceneElLookup {
protected:
ISceneElLookup() = default;
Expand Down
Loading

0 comments on commit 7054d9f

Please sign in to comment.