Part: GeometryMigrationExtension classes
======================================== This is a light-weight c++ only geometry extension to enable migration of information that was stored within the Part WB and should be migrated to another WB (for example Sketcher WB) It is designed so that a single extension can migrate different types of data (current and future). When new data needs to be migrated, first a new enum bit is to be added to the class enum and new data members are to be added to store the information within GeometryMigrationExtension class. In the Restore() function restoring the data to be migrated, a GeometryMigrationExtension extension is added to the geometry to be migrated with the data information and the corresponding enum bit set. In the object to receive the migration data, onDocumentRestored() it is checked whether an extension of type GeometryMigrationExtension is present, if yes, it is checked whether a bit used for migration is set and, if yes, the data is retrieved and the GeometryMigrationExtension extension (preferably) removed from the Geometry object.
This commit is contained in:
committed by
abdullahtahiriyo
parent
6a02496860
commit
ec5976ec28
76
src/Mod/Part/App/GeometryMigrationExtension.cpp
Normal file
76
src/Mod/Part/App/GeometryMigrationExtension.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2020 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "GeometryMigrationExtension.h"
|
||||
|
||||
#include <Base/Exception.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
||||
//---------- Geometry Extension
|
||||
TYPESYSTEM_SOURCE(Part::GeometryMigrationExtension,Part::GeometryExtension)
|
||||
|
||||
GeometryMigrationExtension::GeometryMigrationExtension():ConstructionState(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int GeometryMigrationExtension::getMemSize (void) const
|
||||
{
|
||||
return sizeof(long int);
|
||||
}
|
||||
|
||||
void GeometryMigrationExtension::Save(Base::Writer &writer) const
|
||||
{
|
||||
(void) writer;
|
||||
}
|
||||
|
||||
void GeometryMigrationExtension::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
(void) reader;
|
||||
}
|
||||
|
||||
std::unique_ptr<Part::GeometryExtension> GeometryMigrationExtension::copy(void) const
|
||||
{
|
||||
auto cpy = std::make_unique<GeometryMigrationExtension>();
|
||||
|
||||
cpy->ConstructionState = this->ConstructionState;
|
||||
cpy->GeometryMigrationFlags = this->GeometryMigrationFlags;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
#if defined (__GNUC__) && (__GNUC__ <=4)
|
||||
return std::move(cpy);
|
||||
#else
|
||||
return cpy;
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject * GeometryMigrationExtension::getPyObject(void)
|
||||
{
|
||||
THROWM(Base::NotImplementedError, "GeometryMigrationExtension does not have a Python counterpart");
|
||||
}
|
||||
Reference in New Issue
Block a user