[TD]Add uuid tags for cosmetics

This commit is contained in:
wandererfan
2019-07-22 11:48:40 -04:00
committed by WandererFan
parent 0f714e00f1
commit b5464ccf4d
11 changed files with 236 additions and 35 deletions

View File

@@ -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()));
}