Part/Sketcher: Refactor Geometry Extensions copy/save/restore AND attachment notification
========================================================================================= - Long overdue refactor to avoid repetition during save/restore and copy. - New interface to notify an extension when it is attached. It also enables the extension to gain a pointer to the geometry container. This is intended to extend the functionality already existing in Part::Geometry.
This commit is contained in:
committed by
abdullahtahiriyo
parent
927fdc9edc
commit
e6af511f39
@@ -45,12 +45,39 @@ PyObject* GeometryExtension::copyPyObject() const
|
||||
return static_cast<GeometryExtensionPy *>(obj.ptr())->copy(tuple.ptr());
|
||||
}
|
||||
|
||||
void GeometryExtension::copyAttributes(Part::GeometryExtension * cpy) const
|
||||
{
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
}
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeometryPersistenceExtension,Part::GeometryExtension)
|
||||
|
||||
void GeometryPersistenceExtension::restoreNameAttribute(Base::XMLReader &reader)
|
||||
void GeometryPersistenceExtension::restoreAttributes(Base::XMLReader &reader)
|
||||
{
|
||||
if(reader.hasAttribute("name")) {
|
||||
std::string name = reader.getAttribute("name");
|
||||
setName(name);
|
||||
}
|
||||
}
|
||||
void GeometryPersistenceExtension::saveAttributes(Base::Writer &writer) const
|
||||
{
|
||||
const std::string name = getName();
|
||||
|
||||
if(name.size() > 0)
|
||||
writer.Stream() << "\" name=\"" << name;
|
||||
|
||||
}
|
||||
|
||||
void GeometryPersistenceExtension::Save(Base::Writer &writer) const
|
||||
{
|
||||
writer.Stream() << writer.ind() << "<GeoExtension type=\"" << this->getTypeId().getName();
|
||||
|
||||
saveAttributes(writer);
|
||||
|
||||
writer.Stream() << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
void GeometryPersistenceExtension::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
restoreAttributes(reader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user