Sketcher: SketchGeometryExtension - New GeometryMode flags
========================================================== Geometry mode flags are intended to store geometry state, such as Blocked status.
This commit is contained in:
committed by
abdullahtahiriyo
parent
91ac9d2951
commit
e230e60d5f
@@ -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<Part::GeometryExtension> SketchGeometryExtension::copy(void) const
|
||||
@@ -83,6 +87,7 @@ std::unique_ptr<Part::GeometryExtension> SketchGeometryExtension::copy(void) con
|
||||
|
||||
cpy->Id = this->Id;
|
||||
cpy->InternalGeometryType = this->InternalGeometryType;
|
||||
cpy->GeometryModeFlags = this->GeometryModeFlags;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
|
||||
@@ -48,6 +48,13 @@ namespace Sketcher
|
||||
};
|
||||
}
|
||||
|
||||
namespace GeometryMode {
|
||||
enum GeometryMode {
|
||||
Blocked = 0,
|
||||
NumGeometryMode // Must be the last
|
||||
};
|
||||
}
|
||||
|
||||
class ISketchGeometryExtension
|
||||
{
|
||||
|
||||
@@ -58,6 +65,9 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
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<const char *,InternalType::NumInternalGeometryType> internaltype2str {{ "None", "EllipseMajorDiameter", "EllipseMinorDiameter","EllipseFocus1", "EllipseFocus2", "HyperbolaMajor", "HyperbolaMinor", "HyperbolaFocus", "ParabolaFocus", "BSplineControlPoint", "BSplineKnotPoint" }};
|
||||
|
||||
constexpr static std::array<const char *,GeometryMode::NumGeometryMode> 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<long> _GeometryID;
|
||||
|
||||
Reference in New Issue
Block a user