Sketcher: GeometryExtension and ExternalGeometryExtension
This commit is contained in:
@@ -32,13 +32,17 @@
|
||||
#include "SketchObjectSF.h"
|
||||
#include "SketchObject.h"
|
||||
#include "SketchGeometryExtension.h"
|
||||
#include "ExternalGeometryExtension.h"
|
||||
#include "Constraint.h"
|
||||
#include "Sketch.h"
|
||||
#include "ConstraintPy.h"
|
||||
#include "SketchPy.h"
|
||||
#include "SketchGeometryExtensionPy.h"
|
||||
#include "ExternalGeometryExtensionPy.h"
|
||||
#include "PropertyConstraintList.h"
|
||||
|
||||
|
||||
|
||||
namespace Sketcher {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
@@ -58,8 +62,10 @@ PyMOD_INIT_FUNC(Sketcher)
|
||||
PyObject* sketcherModule = Sketcher::initModule();
|
||||
|
||||
// Add Types to module
|
||||
Base::Interpreter().addType(&Sketcher::ConstraintPy ::Type,sketcherModule,"Constraint");
|
||||
Base::Interpreter().addType(&Sketcher::SketchPy ::Type,sketcherModule,"Sketch");
|
||||
Base::Interpreter().addType(&Sketcher::ConstraintPy ::Type,sketcherModule,"Constraint");
|
||||
Base::Interpreter().addType(&Sketcher::SketchPy ::Type,sketcherModule,"Sketch");
|
||||
Base::Interpreter().addType(&Sketcher::ExternalGeometryExtensionPy ::Type,sketcherModule,"ExternalGeometryExtension");
|
||||
Base::Interpreter().addType(&Sketcher::SketchGeometryExtensionPy ::Type,sketcherModule,"SketchGeometryExtension");
|
||||
|
||||
|
||||
// NOTE: To finish the initialization of our own type objects we must
|
||||
@@ -67,6 +73,7 @@ PyMOD_INIT_FUNC(Sketcher)
|
||||
// This function is responsible for adding inherited slots from a type's base class.
|
||||
|
||||
Sketcher::SketchGeometryExtension ::init();
|
||||
Sketcher::ExternalGeometryExtension ::init();
|
||||
Sketcher::SketchObjectSF ::init();
|
||||
Sketcher::SketchObject ::init();
|
||||
Sketcher::SketchObjectPython ::init();
|
||||
|
||||
@@ -37,6 +37,7 @@ set(Sketcher_LIBS
|
||||
generate_from_xml(SketchObjectSFPy)
|
||||
generate_from_xml(SketchObjectPy)
|
||||
generate_from_xml(SketchGeometryExtensionPy)
|
||||
generate_from_xml(ExternalGeometryExtensionPy)
|
||||
generate_from_xml(ConstraintPy)
|
||||
generate_from_xml(SketchPy)
|
||||
|
||||
@@ -53,6 +54,8 @@ SET(Features_SRCS
|
||||
SketchObjectSF.h
|
||||
SketchGeometryExtension.cpp
|
||||
SketchGeometryExtension.h
|
||||
ExternalGeometryExtension.cpp
|
||||
ExternalGeometryExtension.h
|
||||
SketchObject.cpp
|
||||
SketchObject.h
|
||||
SketchAnalysis.h
|
||||
@@ -76,6 +79,8 @@ SET(Python_SRCS
|
||||
SketchObjectPyImp.cpp
|
||||
SketchGeometryExtensionPy.xml
|
||||
SketchGeometryExtensionPyImp.cpp
|
||||
ExternalGeometryExtensionPy.xml
|
||||
ExternalGeometryExtensionPyImp.cpp
|
||||
ConstraintPyImp.cpp
|
||||
ConstraintPy.xml
|
||||
SketchPy.xml
|
||||
|
||||
83
src/Mod/Sketcher/App/ExternalGeometryExtension.cpp
Normal file
83
src/Mod/Sketcher/App/ExternalGeometryExtension.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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 <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
|
||||
#include <Mod/Sketcher/App/ExternalGeometryExtensionPy.h>
|
||||
|
||||
#include "ExternalGeometryExtension.h"
|
||||
|
||||
using namespace Sketcher;
|
||||
|
||||
//---------- Geometry Extension
|
||||
|
||||
constexpr std::array<const char *,ExternalGeometryExtension::NumFlags> ExternalGeometryExtension::flag2str;
|
||||
|
||||
TYPESYSTEM_SOURCE(Sketcher::ExternalGeometryExtension,Part::GeometryExtension)
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int ExternalGeometryExtension::getMemSize (void) const
|
||||
{
|
||||
return sizeof(long int);
|
||||
}
|
||||
|
||||
void ExternalGeometryExtension::Save(Base::Writer &writer) const
|
||||
{
|
||||
writer.Stream() << writer.ind() << "<GeoExtension type=\"" << this->getTypeId().getName();
|
||||
|
||||
const std::string name = getName();
|
||||
|
||||
if(name.size() > 0)
|
||||
writer.Stream() << "\" name=\"" << name;
|
||||
|
||||
writer.Stream() << "\" Ref=\"" << Ref << "\" Flags=\"" << Flags.to_string() << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
void ExternalGeometryExtension::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
restoreNameAttribute(reader);
|
||||
|
||||
Ref = reader.getAttribute("Ref");
|
||||
Flags = FlagType(reader.getAttribute("Flags"));
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<Part::GeometryExtension> ExternalGeometryExtension::copy(void) const
|
||||
{
|
||||
std::unique_ptr<ExternalGeometryExtension> cpy = std::make_unique<ExternalGeometryExtension>();
|
||||
|
||||
cpy->Ref = this->Ref;
|
||||
cpy->Flags = this->Flags;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
return std::move(cpy);
|
||||
}
|
||||
|
||||
PyObject * ExternalGeometryExtension::getPyObject(void)
|
||||
{
|
||||
return new ExternalGeometryExtensionPy(new ExternalGeometryExtension(*this));
|
||||
}
|
||||
|
||||
87
src/Mod/Sketcher/App/ExternalGeometryExtension.h
Normal file
87
src/Mod/Sketcher/App/ExternalGeometryExtension.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SKETCHER_EXTERNALGEOMETRYEXTENSION_H
|
||||
#define SKETCHER_EXTERNALGEOMETRYEXTENSION_H
|
||||
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
|
||||
namespace Sketcher
|
||||
{
|
||||
|
||||
class SketcherExport ExternalGeometryExtension : public Part::GeometryExtension
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
public:
|
||||
// START_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
enum Flag {
|
||||
Defining = 0, // allow an external geometry to build shape
|
||||
Frozen = 1, // freeze an external geometry
|
||||
Detached = 2, // signal the intentions of detaching the geometry from external reference
|
||||
Missing = 3, // geometry with missing external reference
|
||||
Sync = 4, // signal the intension to synchronize a frozen geometry
|
||||
NumFlags // Must be the last type
|
||||
};
|
||||
// END_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
|
||||
constexpr static std::array<const char *,NumFlags> flag2str { "Defining", "Frozen", "Detached","Missing", "Sync" };
|
||||
|
||||
ExternalGeometryExtension() = default;
|
||||
virtual ~ExternalGeometryExtension() = default;
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
virtual void Save(Base::Writer &/*writer*/) const;
|
||||
virtual void Restore(Base::XMLReader &/*reader*/);
|
||||
|
||||
virtual std::unique_ptr<Part::GeometryExtension> copy(void) const;
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
// START_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
bool testFlag(int flag) const { return Flags.test((size_t)(flag)); }
|
||||
void setFlag(int flag, bool v=true) { Flags.set((size_t)(flag),v); }
|
||||
// END_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
|
||||
bool isClear() const {return Flags.none();}
|
||||
size_t flagSize() const {return Flags.size();}
|
||||
|
||||
const std::string& getRef() const {return Ref;}
|
||||
void setRef(const std::string & ref) {Ref = ref;}
|
||||
|
||||
private:
|
||||
ExternalGeometryExtension(const ExternalGeometryExtension&) = default;
|
||||
|
||||
private:
|
||||
using FlagType = std::bitset<32>;
|
||||
// START_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
std::string Ref;
|
||||
FlagType Flags;
|
||||
// END_CREDIT_BLOCK: Credit under LGPL for this block to Zheng, Lei (realthunder) <realthunder.dev@gmail.com>
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace Sketcher
|
||||
|
||||
|
||||
#endif // SKETCHER_EXTERNALGEOMETRYEXTENSION_H
|
||||
37
src/Mod/Sketcher/App/ExternalGeometryExtensionPy.xml
Normal file
37
src/Mod/Sketcher/App/ExternalGeometryExtensionPy.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="GeometryExtensionPy"
|
||||
Name="ExternalGeometryExtensionPy"
|
||||
PythonName="Sketcher.ExternalGeometryExtension"
|
||||
Twin="ExternalGeometryExtension"
|
||||
TwinPointer="ExternalGeometryExtension"
|
||||
Include="Mod/Sketcher/App/ExternalGeometryExtension.h"
|
||||
Namespace="Sketcher"
|
||||
FatherInclude="Mod/Part/App/GeometryExtensionPy.h"
|
||||
FatherNamespace="Part"
|
||||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Abdullah Tahiri" EMail="abdullah.tahiri.yo@gmail.com" />
|
||||
<UserDocu>Describes a ExternalGeometryExtension</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="testFlag" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>returns a boolean indicating whether the given bit is set.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setFlag" Const="false">
|
||||
<Documentation>
|
||||
<UserDocu>sets the given bit to true/false.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Ref" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
returns the reference string of this external geometry.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Ref" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
172
src/Mod/Sketcher/App/ExternalGeometryExtensionPyImp.cpp
Normal file
172
src/Mod/Sketcher/App/ExternalGeometryExtensionPyImp.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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"
|
||||
|
||||
//#ifndef _PreComp_
|
||||
//# include <gp.hxx>
|
||||
//#endif
|
||||
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include "SketchObject.h"
|
||||
#include "ExternalGeometryExtensionPy.h"
|
||||
#include "ExternalGeometryExtensionPy.cpp"
|
||||
|
||||
using namespace Sketcher;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ExternalGeometryExtensionPy::representation(void) const
|
||||
{
|
||||
std::stringstream str;
|
||||
|
||||
std::string ref = getExternalGeometryExtensionPtr()->getRef();
|
||||
|
||||
|
||||
|
||||
str << "<ExternalGeometryExtension (";
|
||||
|
||||
if(getExternalGeometryExtensionPtr()->getName().size()>0)
|
||||
str << "\'" << getExternalGeometryExtensionPtr()->getName() << "\', ";
|
||||
|
||||
str << "\"" << ref;
|
||||
|
||||
if(!getExternalGeometryExtensionPtr()->isClear()) {
|
||||
str<< "\",{";
|
||||
|
||||
bool first=true;
|
||||
|
||||
for(size_t i=0;i<ExternalGeometryExtension::NumFlags;i++) {
|
||||
if(getExternalGeometryExtensionPtr()->testFlag(i)) {
|
||||
if(first) {
|
||||
first=false;
|
||||
}
|
||||
else {
|
||||
str << ", ";
|
||||
}
|
||||
|
||||
str << getExternalGeometryExtensionPtr()->flag2str[i];
|
||||
}
|
||||
}
|
||||
|
||||
str<< "}";
|
||||
}
|
||||
else {
|
||||
str << "\") >";
|
||||
}
|
||||
|
||||
str << ") >";
|
||||
|
||||
return str.str();
|
||||
}
|
||||
|
||||
PyObject *ExternalGeometryExtensionPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of PointPy and the Twin object
|
||||
return new ExternalGeometryExtensionPy(new ExternalGeometryExtension);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int ExternalGeometryExtensionPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
{
|
||||
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
// default extension
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "ExternalGeometryExtension constructor accepts:\n"
|
||||
"-- empty parameter list\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryExtensionPy::testFlag(PyObject *args)
|
||||
{
|
||||
char* flag;
|
||||
if (PyArg_ParseTuple(args, "s",&flag)) {
|
||||
|
||||
auto pos = std::find_if(getExternalGeometryExtensionPtr()->flag2str.begin(),
|
||||
getExternalGeometryExtensionPtr()->flag2str.end(),
|
||||
[flag](const char * val) { return strcmp(val,flag) == 0;});
|
||||
|
||||
if( pos != getExternalGeometryExtensionPtr()->flag2str.end()) {
|
||||
int index = std::distance( getExternalGeometryExtensionPtr()->flag2str.begin(), pos );
|
||||
|
||||
return new_reference_to(Py::Boolean(this->getExternalGeometryExtensionPtr()->testFlag(index)));
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "Flag string does not exist.");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "No flag string provided.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject* ExternalGeometryExtensionPy::setFlag(PyObject *args)
|
||||
{
|
||||
char * flag;
|
||||
PyObject * bflag = Py_True;
|
||||
if (PyArg_ParseTuple(args, "s|O!", &flag, &PyBool_Type, &bflag)) {
|
||||
|
||||
auto pos = std::find_if(getExternalGeometryExtensionPtr()->flag2str.begin(),
|
||||
getExternalGeometryExtensionPtr()->flag2str.end(),
|
||||
[flag](const char * val) {
|
||||
return strcmp(val,flag)==0;}
|
||||
);
|
||||
|
||||
if( pos != getExternalGeometryExtensionPtr()->flag2str.end()) {
|
||||
int index = std::distance( getExternalGeometryExtensionPtr()->flag2str.begin(), pos );
|
||||
|
||||
this->getExternalGeometryExtensionPtr()->setFlag(index,PyObject_IsTrue(bflag) ? true : false);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "Flag string does not exist.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "No flag string provided.");
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
Py::String ExternalGeometryExtensionPy::getRef(void) const
|
||||
{
|
||||
return Py::String(this->getExternalGeometryExtensionPtr()->getRef());
|
||||
}
|
||||
|
||||
void ExternalGeometryExtensionPy::setRef(Py::String value)
|
||||
{
|
||||
this->getExternalGeometryExtensionPtr()->setRef(value.as_std_string());
|
||||
}
|
||||
|
||||
|
||||
PyObject *ExternalGeometryExtensionPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ExternalGeometryExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -35,20 +35,19 @@ using namespace Sketcher;
|
||||
|
||||
TYPESYSTEM_SOURCE(Sketcher::SketchGeometryExtension,Part::GeometryExtension)
|
||||
|
||||
SketchGeometryExtension::SketchGeometryExtension():id(0)
|
||||
// scoped within the class, multithread ready
|
||||
std::atomic<long> SketchGeometryExtension::_GeometryID;
|
||||
|
||||
SketchGeometryExtension::SketchGeometryExtension():Id(++SketchGeometryExtension::_GeometryID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SketchGeometryExtension::SketchGeometryExtension(long cid):id(cid)
|
||||
SketchGeometryExtension::SketchGeometryExtension(long cid):Id(cid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SketchGeometryExtension::~SketchGeometryExtension()
|
||||
{
|
||||
}
|
||||
|
||||
// Persistence implementer
|
||||
unsigned int SketchGeometryExtension::getMemSize (void) const
|
||||
{
|
||||
@@ -57,27 +56,36 @@ unsigned int SketchGeometryExtension::getMemSize (void) const
|
||||
|
||||
void SketchGeometryExtension::Save(Base::Writer &writer) const
|
||||
{
|
||||
writer.Stream() << writer.ind() << "<GeoExtension type=\"" << this->getTypeId().getName();
|
||||
|
||||
writer.Stream() << writer.ind() << "<GeoExtension type=\"" << this->getTypeId().getName()
|
||||
<< "\" id=\"" << id << "\"/>" << endl;
|
||||
const std::string name = getName();
|
||||
|
||||
if(name.size() > 0)
|
||||
writer.Stream() << "\" name=\"" << name;
|
||||
|
||||
writer.Stream() << "\" id=\"" << Id << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
void SketchGeometryExtension::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
id = reader.getAttributeAsInteger("id");
|
||||
restoreNameAttribute(reader);
|
||||
|
||||
Id = reader.getAttributeAsInteger("id");
|
||||
}
|
||||
|
||||
std::unique_ptr<Part::GeometryExtension> SketchGeometryExtension::copy(void) const
|
||||
{
|
||||
std::unique_ptr<SketchGeometryExtension> cpy = std::make_unique<SketchGeometryExtension>();
|
||||
|
||||
cpy->id = this->id;
|
||||
cpy->Id = this->Id;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
return std::move(cpy);
|
||||
}
|
||||
|
||||
PyObject * SketchGeometryExtension::getPyObject(void)
|
||||
{
|
||||
return new SketchGeometryExtensionPy(new SketchGeometryExtension(this->id));
|
||||
return new SketchGeometryExtensionPy(new SketchGeometryExtension(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define SKETCHER_SKETCHGEOMETRYEXTENSION_H
|
||||
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <atomic>
|
||||
|
||||
namespace Sketcher
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class SketcherExport SketchGeometryExtension : public Part::GeometryExtension
|
||||
public:
|
||||
SketchGeometryExtension();
|
||||
SketchGeometryExtension(long cid);
|
||||
virtual ~SketchGeometryExtension();
|
||||
virtual ~SketchGeometryExtension() = default;
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
virtual unsigned int getMemSize(void) const;
|
||||
@@ -45,8 +46,17 @@ public:
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
public:
|
||||
long int id;
|
||||
long getId() const {return Id;}
|
||||
void setId(long id) {Id = id;}
|
||||
|
||||
private:
|
||||
SketchGeometryExtension(const SketchGeometryExtension&) = default;
|
||||
|
||||
private:
|
||||
long Id;
|
||||
|
||||
private:
|
||||
static std::atomic<long> _GeometryID;
|
||||
};
|
||||
|
||||
} //namespace Sketcher
|
||||
|
||||
@@ -38,8 +38,14 @@ using namespace Sketcher;
|
||||
std::string SketchGeometryExtensionPy::representation(void) const
|
||||
{
|
||||
std::stringstream str;
|
||||
long id = getSketchGeometryExtensionPtr()->id;
|
||||
str << "<SketchGeometryExtension (" << id << ") >";
|
||||
str << "<SketchGeometryExtension (";
|
||||
|
||||
if(getSketchGeometryExtensionPtr()->getName().size()>0)
|
||||
str << "\'" << getSketchGeometryExtensionPtr()->getName() << "\', ";
|
||||
|
||||
str << "\"";
|
||||
|
||||
str << getSketchGeometryExtensionPtr()->getId() << "\") >";
|
||||
return str.str();
|
||||
}
|
||||
|
||||
@@ -61,7 +67,7 @@ int SketchGeometryExtensionPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyErr_Clear();
|
||||
int Id;
|
||||
if (PyArg_ParseTuple(args, "i", &Id)) {
|
||||
this->getSketchGeometryExtensionPtr()->id=Id;
|
||||
this->getSketchGeometryExtensionPtr()->setId(Id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,12 +81,12 @@ int SketchGeometryExtensionPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
Py::Long SketchGeometryExtensionPy::getId(void) const
|
||||
{
|
||||
return Py::Long(this->getSketchGeometryExtensionPtr()->id);
|
||||
return Py::Long(this->getSketchGeometryExtensionPtr()->getId());
|
||||
}
|
||||
|
||||
void SketchGeometryExtensionPy::setId(Py::Long Id)
|
||||
{
|
||||
this->getSketchGeometryExtensionPtr()->id=long(Id);
|
||||
this->getSketchGeometryExtensionPtr()->setId(long(Id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user