diff --git a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp index f03e87baecbc..3ee98a66c918 100644 --- a/src/Mod/Sketcher/App/SketchGeometryExtension.cpp +++ b/src/Mod/Sketcher/App/SketchGeometryExtension.cpp @@ -66,7 +66,9 @@ void SketchGeometryExtension::Save(Base::Writer &writer) const writer.Stream() << "\" name=\"" << name; writer.Stream() << "\" id=\"" << Id - << "\" internalGeometryType=\"" << (int) InternalGeometryType << "\"/>" << std::endl; + << "\" internalGeometryType=\"" << (int) InternalGeometryType + << "\" geometryModeFlags=\"" << GeometryModeFlags.to_string() + << "\"/>" << std::endl; } void SketchGeometryExtension::Restore(Base::XMLReader &reader) @@ -75,6 +77,8 @@ void SketchGeometryExtension::Restore(Base::XMLReader &reader) Id = reader.getAttributeAsInteger("id"); InternalGeometryType = (InternalType::InternalType) reader.getAttributeAsInteger("internalGeometryType"); + + GeometryModeFlags = GeometryModeFlagType(reader.getAttribute("geometryModeFlags")); } std::unique_ptr SketchGeometryExtension::copy(void) const @@ -83,6 +87,7 @@ std::unique_ptr SketchGeometryExtension::copy(void) con cpy->Id = this->Id; cpy->InternalGeometryType = this->InternalGeometryType; + cpy->GeometryModeFlags = this->GeometryModeFlags; cpy->setName(this->getName()); // Base Class diff --git a/src/Mod/Sketcher/App/SketchGeometryExtension.h b/src/Mod/Sketcher/App/SketchGeometryExtension.h index 187a37abfa6e..b4896be63f33 100644 --- a/src/Mod/Sketcher/App/SketchGeometryExtension.h +++ b/src/Mod/Sketcher/App/SketchGeometryExtension.h @@ -48,6 +48,13 @@ namespace Sketcher }; } + namespace GeometryMode { + enum GeometryMode { + Blocked = 0, + NumGeometryMode // Must be the last + }; + } + class ISketchGeometryExtension { @@ -58,6 +65,9 @@ class ISketchGeometryExtension virtual InternalType::InternalType getInternalType() const = 0; virtual void setInternalType(InternalType::InternalType type) = 0; + + virtual bool testGeometryMode(int flag) const = 0; + virtual void setGeometryMode(int flag, bool v=true) = 0; }; class SketcherExport SketchGeometryExtension : public Part::GeometryExtension, private ISketchGeometryExtension @@ -84,16 +94,23 @@ class SketcherExport SketchGeometryExtension : public Part::GeometryExtension, p virtual InternalType::InternalType getInternalType() const override {return InternalGeometryType;} virtual void setInternalType(InternalType::InternalType type) override {InternalGeometryType = type;} + virtual bool testGeometryMode(int flag) const override { return GeometryModeFlags.test((size_t)(flag)); }; + virtual void setGeometryMode(int flag, bool v=true) override { GeometryModeFlags.set((size_t)(flag), v); }; + constexpr static std::array internaltype2str {{ "None", "EllipseMajorDiameter", "EllipseMinorDiameter","EllipseFocus1", "EllipseFocus2", "HyperbolaMajor", "HyperbolaMinor", "HyperbolaFocus", "ParabolaFocus", "BSplineControlPoint", "BSplineKnotPoint" }}; + constexpr static std::array geometrymode2str {{ "Blocked" }}; + static bool getInternalTypeFromName(std::string str, InternalType::InternalType &type); private: SketchGeometryExtension(const SketchGeometryExtension&) = default; private: - long Id; + using GeometryModeFlagType = std::bitset<32>; + long Id; InternalType::InternalType InternalGeometryType; + GeometryModeFlagType GeometryModeFlags; private: static std::atomic _GeometryID;