Toponaming: Clean Code adding RefIndex to ExternalGeometry and supporting new migration types.
This commit is contained in:
@@ -35,11 +35,10 @@ TYPESYSTEM_SOURCE_ABSTRACT(Part::GeometryMigrationPersistenceExtension, Part::Ge
|
||||
TYPESYSTEM_SOURCE(Part::GeometryMigrationExtension,Part::GeometryExtension)
|
||||
|
||||
|
||||
void GeometryMigrationExtension::copyAttributes(Part::GeometryExtension * cpy) const
|
||||
{
|
||||
void GeometryMigrationExtension::copyAttributes(Part::GeometryExtension *cpy) const {
|
||||
Part::GeometryExtension::copyAttributes(cpy);
|
||||
static_cast<GeometryMigrationExtension *>(cpy)->ConstructionState = this->ConstructionState;
|
||||
static_cast<GeometryMigrationExtension *>(cpy)->GeometryMigrationFlags = this->GeometryMigrationFlags;
|
||||
static_cast<GeometryMigrationExtension *>(cpy)->GeometryMigrationFlags = this->GeometryMigrationFlags;
|
||||
|
||||
static_cast<GeometryMigrationExtension *>(cpy)->Id = this->Id;
|
||||
static_cast<GeometryMigrationExtension *>(cpy)->Flags = this->Flags;
|
||||
|
||||
@@ -62,16 +62,26 @@ public:
|
||||
PyObject *getPyObject() override;
|
||||
|
||||
|
||||
virtual bool getConstruction() const {return ConstructionState;}
|
||||
virtual void setConstruction(bool construction)
|
||||
{ConstructionState = construction; setMigrationType(Construction);}
|
||||
virtual bool getConstruction() const { return ConstructionState; }
|
||||
|
||||
long getId() const {return Id;}
|
||||
void setId(long id) {Id = id; setMigrationType(GeometryId);}
|
||||
virtual void setConstruction(bool construction) {
|
||||
ConstructionState = construction;
|
||||
setMigrationType(Construction);
|
||||
}
|
||||
|
||||
long getId() const { return Id; }
|
||||
|
||||
void setId(long id) {
|
||||
Id = id;
|
||||
setMigrationType(GeometryId);
|
||||
}
|
||||
|
||||
const std::string &getRef() const { return Ref; }
|
||||
|
||||
int getRefIndex() const { return RefIndex; }
|
||||
|
||||
unsigned long getFlags() const { return Flags; }
|
||||
|
||||
const std::string &getRef() const {return Ref;}
|
||||
int getRefIndex() const {return RefIndex;}
|
||||
unsigned long getFlags() const {return Flags;}
|
||||
void setReference(const char *ref, int index, unsigned long flags) {
|
||||
Ref = ref ? ref : "";
|
||||
RefIndex = index;
|
||||
@@ -103,9 +113,9 @@ class PartExport GeometryMigrationPersistenceExtension : public Part::GeometryPe
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
// Called to save data as attributes in 'Geometry' XML tag
|
||||
// Called to extend 'Geometry' XML tag with additional attributes (eg Id)
|
||||
virtual void preSave(Base::Writer &/*writer*/) const {}
|
||||
// Called to save data after 'GeometryExtensions' XML elements
|
||||
// Called to add additional tag after 'GeometryExtensions' XML elements (eg Construction flag)
|
||||
virtual void postSave(Base::Writer &/*writer*/) const {}
|
||||
};
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ void ExternalGeometryFacade::copyFlags(const Part::Geometry* src, Part::Geometry
|
||||
|
||||
void ExternalGeometryFacade::setRef(const std::string& ref)
|
||||
{
|
||||
if (ref.size() && getId() < 0) {
|
||||
if (ref.empty() && getId() < 0) {
|
||||
FC_ERR("Cannot set reference on root geometries");
|
||||
}
|
||||
else {
|
||||
@@ -178,14 +178,6 @@ void ExternalGeometryFacade::setRef(const std::string& ref)
|
||||
}
|
||||
}
|
||||
|
||||
// void ExternalGeometryFacade::setRef(const std::string &ref)
|
||||
//{
|
||||
// if (ref.size() && getId() < 0)
|
||||
// FC_ERR("Cannot set reference on root geometries");
|
||||
// else
|
||||
// getExternalGeoExt()->setRef(ref);
|
||||
// }
|
||||
|
||||
PyObject* ExternalGeometryFacade::getPyObject()
|
||||
{
|
||||
return new ExternalGeometryFacadePy(new ExternalGeometryFacade(this->Geo));
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
{
|
||||
return getExternalGeoExt()->testFlag(flag);
|
||||
}
|
||||
|
||||
void setFlag(int flag, bool v = true) override
|
||||
{
|
||||
getExternalGeoExt()->setFlag(flag, v);
|
||||
@@ -87,6 +88,7 @@ public:
|
||||
{
|
||||
return getExternalGeoExt()->getFlags();
|
||||
}
|
||||
|
||||
void setFlags(unsigned long flags) override
|
||||
{
|
||||
getExternalGeoExt()->setFlags(flags);
|
||||
@@ -96,6 +98,7 @@ public:
|
||||
{
|
||||
return getExternalGeoExt()->isClear();
|
||||
}
|
||||
|
||||
size_t flagSize() const override
|
||||
{
|
||||
return getExternalGeoExt()->flagSize();
|
||||
@@ -105,6 +108,7 @@ public:
|
||||
{
|
||||
return getExternalGeoExt()->getRef();
|
||||
}
|
||||
|
||||
void setRef(const std::string& ref) override;
|
||||
|
||||
int getRefIndex() const override
|
||||
|
||||
Reference in New Issue
Block a user