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:
Abdullah Tahiri
2021-01-08 14:18:52 +01:00
committed by abdullahtahiriyo
parent 6c6790e8b5
commit b69b3c71c0
14 changed files with 141 additions and 84 deletions

View File

@@ -41,16 +41,20 @@ SolverGeometryExtension::SolverGeometryExtension():
}
void SolverGeometryExtension::copyAttributes(Part::GeometryExtension * cpy) const
{
Part::GeometryExtension::copyAttributes(cpy);
static_cast<SolverGeometryExtension *>(cpy)->Edge = this->Edge;
static_cast<SolverGeometryExtension *>(cpy)->Start = this->Start;
static_cast<SolverGeometryExtension *>(cpy)->End = this->End;
static_cast<SolverGeometryExtension *>(cpy)->Mid = this->Mid;
}
std::unique_ptr<Part::GeometryExtension> SolverGeometryExtension::copy(void) const
{
auto cpy = std::make_unique<SolverGeometryExtension>();
cpy->Edge = this->Edge;
cpy->Start = this->Start;
cpy->End = this->End;
cpy->Mid = this->Mid;
cpy->setName(this->getName()); // Base Class
copyAttributes(cpy.get());
#if defined (__GNUC__) && (__GNUC__ <=4)
return std::move(cpy);