[TD]Add uuid tags for cosmetics
This commit is contained in:
@@ -36,5 +36,11 @@
|
||||
<UserDocu>returns the appearance attributes of this CenterLine. returns tuple(style, color, weight, visible).</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Tag" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Gives the tag of the CenterLine as string.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Tag" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
|
||||
//# include <boost/uuid/uuid_io.hpp>
|
||||
# include <boost/uuid/uuid_io.hpp>
|
||||
#endif
|
||||
|
||||
#include "DrawUtil.h"
|
||||
@@ -167,6 +167,12 @@ PyObject* CenterLinePy::getFormat(PyObject *args)
|
||||
return result;
|
||||
}
|
||||
|
||||
Py::String CenterLinePy::getTag(void) const
|
||||
{
|
||||
std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag());
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -145,6 +145,8 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
|
||||
size = 3.0;
|
||||
style = 1;
|
||||
visible = true;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv)
|
||||
@@ -154,6 +156,8 @@ CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::V
|
||||
size = cv->size;
|
||||
style = cv->style;
|
||||
visible = cv->visible;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
@@ -169,6 +173,9 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
size = 30.0;
|
||||
style = 1; //TODO: implement styled vertexes
|
||||
visible = true;
|
||||
|
||||
createNewTag();
|
||||
|
||||
}
|
||||
|
||||
std::string CosmeticVertex::toString(void) const
|
||||
@@ -219,6 +226,40 @@ void CosmeticVertex::Restore(Base::XMLReader &reader)
|
||||
visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
|
||||
}
|
||||
|
||||
boost::uuids::uuid CosmeticVertex::getTag() const
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
std::string CosmeticVertex::getTagAsString(void) const
|
||||
{
|
||||
std::string tmp = boost::uuids::to_string(getTag());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void CosmeticVertex::createNewTag()
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
static bool seeded = false;
|
||||
|
||||
if (!seeded) {
|
||||
ran.seed(static_cast<unsigned int>(std::time(0)));
|
||||
seeded = true;
|
||||
}
|
||||
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
|
||||
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
void CosmeticVertex::assignTag(const TechDraw::CosmeticVertex * cv)
|
||||
{
|
||||
if(cv->getTypeId() == this->getTypeId())
|
||||
this->tag = cv->tag;
|
||||
else
|
||||
throw Base::TypeError("CosmeticVertex tag can not be assigned as types do not match.");
|
||||
}
|
||||
|
||||
CosmeticVertex* CosmeticVertex::copy(void) const
|
||||
{
|
||||
// Base::Console().Message("CV::copy()\n");
|
||||
@@ -230,6 +271,7 @@ CosmeticVertex* CosmeticVertex::clone(void) const
|
||||
{
|
||||
// Base::Console().Message("CV::clone()\n");
|
||||
CosmeticVertex* cpy = this->copy();
|
||||
cpy->tag = this->tag;
|
||||
return cpy;
|
||||
}
|
||||
|
||||
@@ -304,6 +346,9 @@ void CosmeticEdge::initialize(void)
|
||||
m_geometry->classOfEdge = ecHARD;
|
||||
m_geometry->visible = true;
|
||||
m_geometry->cosmetic = true;
|
||||
|
||||
createNewTag();
|
||||
|
||||
}
|
||||
|
||||
TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
@@ -402,6 +447,34 @@ void CosmeticEdge::Restore(Base::XMLReader &reader)
|
||||
}
|
||||
}
|
||||
|
||||
boost::uuids::uuid CosmeticEdge::getTag() const
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
void CosmeticEdge::createNewTag()
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
static bool seeded = false;
|
||||
|
||||
if (!seeded) {
|
||||
ran.seed(static_cast<unsigned int>(std::time(0)));
|
||||
seeded = true;
|
||||
}
|
||||
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
|
||||
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
void CosmeticEdge::assignTag(const TechDraw::CosmeticEdge * ce)
|
||||
{
|
||||
if(ce->getTypeId() == this->getTypeId())
|
||||
this->tag = ce->tag;
|
||||
else
|
||||
throw Base::TypeError("CosmeticEdge tag can not be assigned as types do not match.");
|
||||
}
|
||||
|
||||
CosmeticEdge* CosmeticEdge::copy(void) const
|
||||
{
|
||||
// Base::Console().Message("CE::copy()\n");
|
||||
@@ -416,6 +489,7 @@ CosmeticEdge* CosmeticEdge::clone(void) const
|
||||
{
|
||||
// Base::Console().Message("CE::clone()\n");
|
||||
CosmeticEdge* cpy = this->copy();
|
||||
cpy->tag = this->tag;
|
||||
return cpy;
|
||||
}
|
||||
|
||||
@@ -440,6 +514,7 @@ CenterLine::CenterLine(void)
|
||||
m_type = CLTYPE::FACE;
|
||||
m_flip2Line = false;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(CenterLine* cl)
|
||||
@@ -457,6 +532,8 @@ CenterLine::CenterLine(CenterLine* cl)
|
||||
m_flip2Line = cl->m_flip2Line;
|
||||
m_edges = cl->m_edges;
|
||||
m_verts = cl->m_verts;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
|
||||
@@ -470,6 +547,8 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
|
||||
m_extendBy = 0.0;
|
||||
m_type = CLTYPE::FACE;
|
||||
m_flip2Line = false;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
@@ -488,6 +567,8 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
m_extendBy = x;
|
||||
m_type = CLTYPE::FACE;
|
||||
m_flip2Line = false;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
CenterLine::~CenterLine()
|
||||
@@ -1102,9 +1183,39 @@ CenterLine* CenterLine::copy(void) const
|
||||
return newCL;
|
||||
}
|
||||
|
||||
CenterLine* CenterLine::clone(void) const
|
||||
boost::uuids::uuid CenterLine::getTag() const
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
void CenterLine::createNewTag()
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
static bool seeded = false;
|
||||
|
||||
if (!seeded) {
|
||||
ran.seed(static_cast<unsigned int>(std::time(0)));
|
||||
seeded = true;
|
||||
}
|
||||
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
|
||||
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
void CenterLine::assignTag(const TechDraw::CenterLine * ce)
|
||||
{
|
||||
if(ce->getTypeId() == this->getTypeId())
|
||||
this->tag = ce->tag;
|
||||
else
|
||||
throw Base::TypeError("CenterLine tag can not be assigned as types do not match.");
|
||||
}
|
||||
|
||||
CenterLine *CenterLine::clone(void) const
|
||||
{
|
||||
CenterLine* cpy = this->copy();
|
||||
cpy->tag = this->tag;
|
||||
|
||||
return cpy;
|
||||
}
|
||||
|
||||
@@ -1169,6 +1280,8 @@ GeomFormat::GeomFormat() :
|
||||
m_format.m_weight = LineFormat::getDefEdgeWidth();
|
||||
m_format.m_color = LineFormat::getDefEdgeColor();
|
||||
m_format.m_visible = true;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
GeomFormat::GeomFormat(GeomFormat* gf)
|
||||
@@ -1178,6 +1291,8 @@ GeomFormat::GeomFormat(GeomFormat* gf)
|
||||
m_format.m_weight = gf->m_format.m_weight;
|
||||
m_format.m_color = gf->m_format.m_color;
|
||||
m_format.m_visible = gf->m_format.m_visible;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
GeomFormat::GeomFormat(int idx,
|
||||
@@ -1189,6 +1304,7 @@ GeomFormat::GeomFormat(int idx,
|
||||
m_format.m_color = fmt.m_color;
|
||||
m_format.m_visible = fmt.m_visible;
|
||||
|
||||
createNewTag();
|
||||
}
|
||||
|
||||
GeomFormat::~GeomFormat()
|
||||
@@ -1243,6 +1359,42 @@ void GeomFormat::Restore(Base::XMLReader &reader)
|
||||
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
|
||||
}
|
||||
|
||||
boost::uuids::uuid GeomFormat::getTag() const
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
void GeomFormat::createNewTag()
|
||||
{
|
||||
// Initialize a random number generator, to avoid Valgrind false positives.
|
||||
static boost::mt19937 ran;
|
||||
static bool seeded = false;
|
||||
|
||||
if (!seeded) {
|
||||
ran.seed(static_cast<unsigned int>(std::time(0)));
|
||||
seeded = true;
|
||||
}
|
||||
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
|
||||
|
||||
tag = gen();
|
||||
}
|
||||
|
||||
void GeomFormat::assignTag(const TechDraw::GeomFormat * ce)
|
||||
{
|
||||
if(ce->getTypeId() == this->getTypeId())
|
||||
this->tag = ce->tag;
|
||||
else
|
||||
throw Base::TypeError("GeomFormat tag can not be assigned as types do not match.");
|
||||
}
|
||||
|
||||
GeomFormat *GeomFormat::clone(void) const
|
||||
{
|
||||
GeomFormat* cpy = this->copy();
|
||||
cpy->tag = this->tag;
|
||||
|
||||
return cpy;
|
||||
}
|
||||
|
||||
GeomFormat* GeomFormat::copy(void) const
|
||||
{
|
||||
GeomFormat* newFmt = new GeomFormat();
|
||||
@@ -1254,15 +1406,8 @@ GeomFormat* GeomFormat::copy(void) const
|
||||
return newFmt;
|
||||
}
|
||||
|
||||
GeomFormat* GeomFormat::clone(void) const
|
||||
{
|
||||
GeomFormat* cpy = this->copy();
|
||||
return cpy;
|
||||
}
|
||||
|
||||
PyObject* GeomFormat::getPyObject(void)
|
||||
{
|
||||
return new GeomFormatPy(new GeomFormat(this->copy()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
#ifndef TECHDRAW_COSMETIC_H
|
||||
#define TECHDRAW_COSMETIC_H
|
||||
|
||||
# include <boost/uuid/uuid_io.hpp>
|
||||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
|
||||
#include <App/FeaturePython.h>
|
||||
|
||||
#include <Base/Persistence.h>
|
||||
@@ -57,7 +62,6 @@ public:
|
||||
|
||||
void dump(char* title);
|
||||
std::string toString() const;
|
||||
/* bool fromCSV(std::string& lineSpec);*/
|
||||
};
|
||||
|
||||
class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
|
||||
@@ -89,7 +93,16 @@ public:
|
||||
int style;
|
||||
bool visible;
|
||||
|
||||
boost::uuids::uuid getTag() const;
|
||||
std::string getTagAsString(void) const;
|
||||
|
||||
|
||||
protected:
|
||||
//Uniqueness
|
||||
void createNewTag();
|
||||
void assignTag(const TechDraw::CosmeticVertex* cv);
|
||||
|
||||
boost::uuids::uuid tag;
|
||||
|
||||
};
|
||||
|
||||
@@ -123,8 +136,14 @@ public:
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
LineFormat m_format;
|
||||
|
||||
protected:
|
||||
boost::uuids::uuid getTag() const;
|
||||
|
||||
protected:
|
||||
//Uniqueness
|
||||
void createNewTag();
|
||||
void assignTag(const TechDraw::CosmeticEdge* ce);
|
||||
|
||||
boost::uuids::uuid tag;
|
||||
};
|
||||
|
||||
class TechDrawExport CenterLine: public Base::Persistence
|
||||
@@ -216,7 +235,13 @@ public:
|
||||
LineFormat m_format;
|
||||
bool m_flip2Line;
|
||||
|
||||
//Uniqueness
|
||||
boost::uuids::uuid getTag() const;
|
||||
protected:
|
||||
void createNewTag();
|
||||
void assignTag(const TechDraw::CenterLine* cl);
|
||||
|
||||
boost::uuids::uuid tag;
|
||||
|
||||
};
|
||||
|
||||
@@ -241,14 +266,18 @@ public:
|
||||
GeomFormat* clone(void) const;
|
||||
|
||||
std::string toString(void) const;
|
||||
/* bool fromCSV(std::string& lineSpec);*/
|
||||
void dump(char* title) const;
|
||||
|
||||
int m_geomIndex;
|
||||
LineFormat m_format;
|
||||
|
||||
//Uniqueness
|
||||
boost::uuids::uuid getTag() const;
|
||||
protected:
|
||||
void createNewTag();
|
||||
void assignTag(const TechDraw::GeomFormat* gf);
|
||||
|
||||
boost::uuids::uuid tag;
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
@@ -36,5 +36,11 @@
|
||||
<UserDocu>returns the appearance attributes of this CometicEdge. returns tuple(style, color, weight, visible).</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Tag" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Gives the tag of the CosmeticEdge as string.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Tag" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
|
||||
# include <boost/uuid/uuid_io.hpp>
|
||||
#endif
|
||||
|
||||
#include <App/Material.h>
|
||||
@@ -169,6 +170,11 @@ PyObject* CosmeticEdgePy::getFormat(PyObject *args)
|
||||
return result;
|
||||
}
|
||||
|
||||
Py::String CosmeticEdgePy::getTag(void) const
|
||||
{
|
||||
std::string tmp = boost::uuids::to_string(getCosmeticEdgePtr()->getTag());
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
PyObject *CosmeticEdgePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
|
||||
@@ -25,5 +25,11 @@
|
||||
<UserDocu>Create a copy of this CosmeticVertex</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Tag" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Gives the tag of the CosmeticVertex as string.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Tag" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
|
||||
# include <boost/uuid/uuid_io.hpp>
|
||||
#endif
|
||||
|
||||
#include "Cosmetic.h"
|
||||
@@ -108,6 +109,12 @@ PyObject* CosmeticVertexPy::copy(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
Py::String CosmeticVertexPy::getTag(void) const
|
||||
{
|
||||
std::string tmp = boost::uuids::to_string(getCosmeticVertexPtr()->getTag());
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -25,5 +25,11 @@
|
||||
<UserDocu>Create a copy of this geomformat</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Tag" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Gives the tag of the GeomFormat as string.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Tag" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -23,37 +23,14 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
//# include <gp_Ax1.hxx>
|
||||
//# include <gp_Dir.hxx>
|
||||
//# include <gp_Pnt.hxx>
|
||||
//# include <gp_Vec.hxx>
|
||||
//# include <gp_Trsf.hxx>
|
||||
//# include <Geom_GeometryFormat.hxx>
|
||||
//# include <Geom_Curve.hxx>
|
||||
//# include <Geom_Surface.hxx>
|
||||
//# include <Precision.hxx>
|
||||
//# include <Standard_Failure.hxx>
|
||||
|
||||
# include <boost/uuid/uuid_io.hpp>
|
||||
#endif
|
||||
|
||||
//#include <Base/GeomFormatPyCXX.h>
|
||||
//#include <Base/Matrix.h>
|
||||
//#include <Base/MatrixPy.h>
|
||||
//#include <Base/Vector3D.h>
|
||||
//#include <Base/VectorPy.h>
|
||||
//#include <Base/Rotation.h>
|
||||
//#include <Base/Placement.h>
|
||||
//#include <Base/PlacementPy.h>
|
||||
|
||||
//#include "OCCError.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "GeomFormatPy.h"
|
||||
#include "GeomFormatPy.cpp"
|
||||
|
||||
//#include "TopoShape.h"
|
||||
//#include "TopoShapePy.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
@@ -130,6 +107,12 @@ PyObject* GeomFormatPy::copy(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
Py::String GeomFormatPy::getTag(void) const
|
||||
{
|
||||
std::string tmp = boost::uuids::to_string(getGeomFormatPtr()->getTag());
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
PyObject *GeomFormatPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <set>
|
||||
#include <bitset>
|
||||
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
|
||||
// OpenCasCade =====================================================================================
|
||||
#include <Mod/Part/App/OpenCascadeAll.h>
|
||||
|
||||
Reference in New Issue
Block a user