diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 565510c220..ba88abce23 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -228,3 +228,13 @@ void Constraint::substituteIndex(int fromGeoId, int toGeoId) this->Third = toGeoId; } } + +std::string Constraint::typeToString(ConstraintType type) +{ + return type2str[type]; +} + +std::string Constraint::internalAlignmentTypeToString(InternalAlignmentType alignment) +{ + return internalAlignmentType2str[alignment]; +} diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index 290db7e05c..46b462b0de 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -24,6 +24,7 @@ #ifndef SKETCHER_CONSTRAINT_H #define SKETCHER_CONSTRAINT_H +#include #include #include @@ -75,6 +76,7 @@ enum InternalAlignmentType { ParabolaFocus = 8, BSplineControlPoint = 9, BSplineKnotPoint = 10, + NumInternalAlignmentType // must be the last item! }; class SketcherExport Constraint : public Base::Persistence @@ -121,6 +123,12 @@ public: /// utility function to swap the index in First/Second/Third of the provided constraint from the fromGeoId GeoId to toGeoId void substituteIndex(int fromGeoId, int toGeoId); + std::string typeToString() const {return typeToString(Type);} + static std::string typeToString(ConstraintType type); + + std::string internalAlignmentTypeToString() const {return internalAlignmentTypeToString(AlignmentType);} + static std::string internalAlignmentTypeToString(InternalAlignmentType alignment); + friend class PropertyConstraintList; private: @@ -128,6 +136,17 @@ private: private: double Value; + + constexpr static std::array type2str { + { "None", "Horizontal", "Vertical","Parallel", "Tangent", "Distance", "DistanceX", "DistanceY", "Angle", "Perpendicular", "Radius", + "Equal", "PointOnObject", "Symmetric", "InternalAlignment", "SnellsLaw", "Block", "Diameter", "Weight"} + }; + + constexpr static std::array internalAlignmentType2str { + { "Undef", "EllipseMajorDiameter", "EllipseMinorDiameter", "EllipseFocus1", "EllipseFocus2", "HyperbolaMajor", "HyperbolaMinor", + "HyperbolaFocus", "ParabolaFocus", "BSplineControlPoint", "BSplineKnotPoint"} + }; + public: ConstraintType Type; InternalAlignmentType AlignmentType;