diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt
index 46e1f5d090..30da18df39 100644
--- a/src/Mod/TechDraw/App/CMakeLists.txt
+++ b/src/Mod/TechDraw/App/CMakeLists.txt
@@ -186,6 +186,8 @@ SET(Geometry_SRCS
GeometryObject.h
Cosmetic.cpp
Cosmetic.h
+ CosmeticVertex.cpp
+ CosmeticVertex.h
PropertyGeomFormatList.cpp
PropertyGeomFormatList.h
PropertyCenterLineList.cpp
diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp
index 76fbefcceb..313b9e8e06 100644
--- a/src/Mod/TechDraw/App/Cosmetic.cpp
+++ b/src/Mod/TechDraw/App/Cosmetic.cpp
@@ -45,7 +45,6 @@
#include
#include
#include
-#include
#include
#include "Cosmetic.h"
@@ -118,209 +117,6 @@ int LineFormat::getDefEdgeStyle()
return style;
}
-//****************************************************************************************
-
-TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence)
-
-CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
-{
- point(Base::Vector3d(0.0, 0.0, 0.0));
- permaPoint = Base::Vector3d(0.0, 0.0, 0.0);
- linkGeom = -1;
- color = Preferences::vertexColor();
- size = Preferences::vertexScale() *
- LineGroup::getDefaultWidth("Thin");
- style = 1;
- visible = true;
- hlrVisible = true;
- cosmetic = true;
-
- createNewTag();
-}
-
-CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv)
-{
- permaPoint = cv->permaPoint;
- linkGeom = cv->linkGeom;
- color = cv->color;
- size = cv->size;
- style = cv->style;
- visible = cv->visible;
- hlrVisible = true;
- cosmetic = true;
-
- createNewTag();
-}
-
-CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
-{
- permaPoint = loc;
- linkGeom = -1;
- color = Preferences::vertexColor();
- size = Preferences::vertexScale() *
- LineGroup::getDefaultWidth("Thick");
- style = 1; //TODO: implement styled vertexes
- visible = true;
- hlrVisible = true;
- cosmetic = true;
-
- createNewTag();
-
-}
-
-void CosmeticVertex::move(Base::Vector3d newPos)
-{
- permaPoint = newPos;
-}
-
-void CosmeticVertex::moveRelative(Base::Vector3d movement)
-{
- permaPoint += movement;
-}
-
-std::string CosmeticVertex::toString() const
-{
- std::stringstream ss;
- ss << permaPoint.x << ", " <<
- permaPoint.y << ", " <<
- permaPoint.z << ", " <<
- " / ";
- ss << point().x << ", " <<
- point().y << ", " <<
- point().z << ", " <<
- " / " <<
- linkGeom << ", " <<
- " / " <<
- color.asHexString() << ", " <<
- " / " <<
- size << ", " <<
- " / " <<
- style << ", " <<
- " / " <<
- visible << " / " ;
- ss << getTagAsString();
- return ss.str();
-}
-
-// Persistence implementers
-unsigned int CosmeticVertex::getMemSize () const
-{
- return 1;
-}
-
-void CosmeticVertex::Save(Base::Writer &writer) const
-{
- TechDraw::Vertex::Save(writer);
- writer.Stream() << writer.ind() << "" << endl;
- writer.Stream() << writer.ind() << "" << endl;
- writer.Stream() << writer.ind() << "" << endl;
- writer.Stream() << writer.ind() << "" << endl;
- writer.Stream() << writer.ind() << "" << endl;
- const char v = visible?'1':'0';
- writer.Stream() << writer.ind() << "" << endl;
- writer.Stream() << writer.ind() << "" << endl;
-}
-
-void CosmeticVertex::Restore(Base::XMLReader &reader)
-{
- if (!CosmeticVertex::restoreCosmetic()) {
- return;
- }
- TechDraw::Vertex::Restore(reader);
- reader.readElement("PermaPoint");
- permaPoint.x = reader.getAttributeAsFloat("X");
- permaPoint.y = reader.getAttributeAsFloat("Y");
- permaPoint.z = reader.getAttributeAsFloat("Z");
- reader.readElement("LinkGeom");
- linkGeom = reader.getAttributeAsInteger("value");
- reader.readElement("Color");
- std::string temp = reader.getAttribute("value");
- color.fromHexString(temp);
- reader.readElement("Size");
- size = reader.getAttributeAsFloat("value");
- reader.readElement("Style");
- style = reader.getAttributeAsInteger("value");
- reader.readElement("Visible");
- visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
- reader.readElement("Tag");
- temp = reader.getAttribute("value");
- boost::uuids::string_generator gen;
- boost::uuids::uuid u1 = gen(temp);
- tag = u1;
-}
-
-Base::Vector3d CosmeticVertex::scaled(double factor)
-{
- return permaPoint * factor;
-}
-
-boost::uuids::uuid CosmeticVertex::getTag() const
-{
- return tag;
-}
-
-std::string CosmeticVertex::getTagAsString() const
-{
- return boost::uuids::to_string(getTag());
-}
-
-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(std::time(nullptr)));
- seeded = true;
- }
- static boost::uuids::basic_random_generator 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() const
-{
-// Base::Console().Message("CV::copy()\n");
- return new CosmeticVertex(this);
-}
-
-CosmeticVertex* CosmeticVertex::clone() const
-{
-// Base::Console().Message("CV::clone()\n");
- CosmeticVertex* cpy = this->copy();
- cpy->tag = this->tag;
- return cpy;
-}
-
-PyObject* CosmeticVertex::getPyObject()
-{
- if (PythonObject.is(Py::_None())) {
- // ref counter is set to 1
- PythonObject = Py::Object(new CosmeticVertexPy(this), true);
- }
- return Py::new_reference_to(PythonObject);
-}
-
-
-void CosmeticVertex::dump(const char* title)
-{
- Base::Console().Message("CV::dump - %s \n", title);
- Base::Console().Message("CV::dump - %s \n", toString().c_str());
-}
-
//******************************************
TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge, Base::Persistence)
diff --git a/src/Mod/TechDraw/App/Cosmetic.h b/src/Mod/TechDraw/App/Cosmetic.h
index 04d1d67b82..59731b33ef 100644
--- a/src/Mod/TechDraw/App/Cosmetic.h
+++ b/src/Mod/TechDraw/App/Cosmetic.h
@@ -63,61 +63,6 @@ public:
std::string toString() const;
};
-//********** Cosmetic Vertex ***************************************************
-class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
-{
- TYPESYSTEM_HEADER_WITH_OVERRIDE();
-
-public:
- CosmeticVertex();
- CosmeticVertex(const CosmeticVertex* cv);
- CosmeticVertex(Base::Vector3d loc);
- ~CosmeticVertex() override = default;
-
- void move(Base::Vector3d newPos);
- void moveRelative(Base::Vector3d movement);
-
- std::string toString() const;
- void dump(const char* title) override;
- Base::Vector3d scaled(double factor);
-
- static bool restoreCosmetic();
-
- // Persistence implementer ---------------------
- unsigned int getMemSize() const override;
- void Save(Base::Writer &/*writer*/) const override;
- void Restore(Base::XMLReader &/*reader*/) override;
-
- PyObject *getPyObject() override;
- CosmeticVertex* copy() const;
- CosmeticVertex* clone() const;
-
- Base::Vector3d permaPoint; //permanent, unscaled value
- int linkGeom; //connection to corresponding "geom" Vertex (fragile - index based!)
- //better to do reverse search for CosmeticTag in vertex geometry
- App::Color color;
- double size;
- int style;
- bool visible; //base class vertex also has visible property
-
- boost::uuids::uuid getTag() const;
- std::string getTagAsString() const override;
-
-protected:
- //Uniqueness
- void createNewTag();
- void assignTag(const TechDraw::CosmeticVertex* cv);
-
- boost::uuids::uuid tag;
-
- Py::Object PythonObject;
-
-
-};
-
-
-
-
//********** CosmeticEdge ******************************************************
class TechDrawExport CosmeticEdge : public Base::Persistence, public TechDraw::BaseGeom
diff --git a/src/Mod/TechDraw/App/CosmeticVertex.cpp b/src/Mod/TechDraw/App/CosmeticVertex.cpp
new file mode 100644
index 0000000000..e1ad047b4c
--- /dev/null
+++ b/src/Mod/TechDraw/App/CosmeticVertex.cpp
@@ -0,0 +1,238 @@
+/***************************************************************************
+ * Copyright (c) 2019 WandererFan *
+ * Copyright (c) 2022 Benjamin Bræstrup Sayoc *
+ * *
+ * 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
+#include
+
+#include
+#include
+#include
+
+#include "CosmeticVertex.h"
+#include "CosmeticVertexPy.h"
+#include "LineGroup.h"
+#include "Preferences.h"
+
+using namespace TechDraw;
+using namespace std;
+
+TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence)
+
+CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
+{
+ point(Base::Vector3d(0.0, 0.0, 0.0));
+ permaPoint = Base::Vector3d(0.0, 0.0, 0.0);
+ linkGeom = -1;
+ color = Preferences::vertexColor();
+ size = Preferences::vertexScale() *
+ LineGroup::getDefaultWidth("Thin");
+ style = 1;
+ visible = true;
+ hlrVisible = true;
+ cosmetic = true;
+
+ createNewTag();
+}
+
+CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv)
+{
+ permaPoint = cv->permaPoint;
+ linkGeom = cv->linkGeom;
+ color = cv->color;
+ size = cv->size;
+ style = cv->style;
+ visible = cv->visible;
+ hlrVisible = true;
+ cosmetic = true;
+
+ createNewTag();
+}
+
+CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
+{
+ permaPoint = loc;
+ linkGeom = -1;
+ color = Preferences::vertexColor();
+ size = Preferences::vertexScale() *
+ LineGroup::getDefaultWidth("Thick");
+ style = 1; //TODO: implement styled vertexes
+ visible = true;
+ hlrVisible = true;
+ cosmetic = true;
+
+ createNewTag();
+
+}
+
+void CosmeticVertex::move(Base::Vector3d newPos)
+{
+ permaPoint = newPos;
+}
+
+void CosmeticVertex::moveRelative(Base::Vector3d movement)
+{
+ permaPoint += movement;
+}
+
+std::string CosmeticVertex::toString() const
+{
+ std::stringstream ss;
+ ss << permaPoint.x << ", " <<
+ permaPoint.y << ", " <<
+ permaPoint.z << ", " <<
+ " / ";
+ ss << point().x << ", " <<
+ point().y << ", " <<
+ point().z << ", " <<
+ " / " <<
+ linkGeom << ", " <<
+ " / " <<
+ color.asHexString() << ", " <<
+ " / " <<
+ size << ", " <<
+ " / " <<
+ style << ", " <<
+ " / " <<
+ visible << " / " ;
+ ss << getTagAsString();
+ return ss.str();
+}
+
+// Persistence implementers
+unsigned int CosmeticVertex::getMemSize () const
+{
+ return 1;
+}
+
+void CosmeticVertex::Save(Base::Writer &writer) const
+{
+ TechDraw::Vertex::Save(writer);
+ writer.Stream() << writer.ind() << "" << endl;
+ writer.Stream() << writer.ind() << "" << endl;
+ writer.Stream() << writer.ind() << "" << endl;
+ writer.Stream() << writer.ind() << "" << endl;
+ writer.Stream() << writer.ind() << "" << endl;
+ const char v = visible?'1':'0';
+ writer.Stream() << writer.ind() << "" << endl;
+ writer.Stream() << writer.ind() << "" << endl;
+}
+
+void CosmeticVertex::Restore(Base::XMLReader &reader)
+{
+ if (!CosmeticVertex::restoreCosmetic()) {
+ return;
+ }
+ TechDraw::Vertex::Restore(reader);
+ reader.readElement("PermaPoint");
+ permaPoint.x = reader.getAttributeAsFloat("X");
+ permaPoint.y = reader.getAttributeAsFloat("Y");
+ permaPoint.z = reader.getAttributeAsFloat("Z");
+ reader.readElement("LinkGeom");
+ linkGeom = reader.getAttributeAsInteger("value");
+ reader.readElement("Color");
+ std::string temp = reader.getAttribute("value");
+ color.fromHexString(temp);
+ reader.readElement("Size");
+ size = reader.getAttributeAsFloat("value");
+ reader.readElement("Style");
+ style = reader.getAttributeAsInteger("value");
+ reader.readElement("Visible");
+ visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
+ reader.readElement("Tag");
+ temp = reader.getAttribute("value");
+ boost::uuids::string_generator gen;
+ boost::uuids::uuid u1 = gen(temp);
+ tag = u1;
+}
+
+Base::Vector3d CosmeticVertex::scaled(double factor)
+{
+ return permaPoint * factor;
+}
+
+boost::uuids::uuid CosmeticVertex::getTag() const
+{
+ return tag;
+}
+
+std::string CosmeticVertex::getTagAsString() const
+{
+ return boost::uuids::to_string(getTag());
+}
+
+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(std::time(nullptr)));
+ seeded = true;
+ }
+ static boost::uuids::basic_random_generator 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() const
+{
+// Base::Console().Message("CV::copy()\n");
+ return new CosmeticVertex(this);
+}
+
+CosmeticVertex* CosmeticVertex::clone() const
+{
+// Base::Console().Message("CV::clone()\n");
+ CosmeticVertex* cpy = this->copy();
+ cpy->tag = this->tag;
+ return cpy;
+}
+
+PyObject* CosmeticVertex::getPyObject()
+{
+ if (PythonObject.is(Py::_None())) {
+ // ref counter is set to 1
+ PythonObject = Py::Object(new CosmeticVertexPy(this), true);
+ }
+ return Py::new_reference_to(PythonObject);
+}
+
+
+void CosmeticVertex::dump(const char* title)
+{
+ Base::Console().Message("CV::dump - %s \n", title);
+ Base::Console().Message("CV::dump - %s \n", toString().c_str());
+}
diff --git a/src/Mod/TechDraw/App/CosmeticVertex.h b/src/Mod/TechDraw/App/CosmeticVertex.h
new file mode 100644
index 0000000000..2db09a4eff
--- /dev/null
+++ b/src/Mod/TechDraw/App/CosmeticVertex.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (c) 2019 WandererFan *
+ * *
+ * 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 TECHDRAW_COSMETIC_VERTEX_H
+#define TECHDRAW_COSMETIC_VERTEX_H
+
+#include "PreCompiled.h"
+#ifndef _PreComp_
+ #include
+ #include
+ #include
+#endif
+
+#include "Geometry.h"
+
+
+class TopoDS_Edge;
+
+namespace TechDraw {
+class DrawViewPart;
+
+class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
+{
+ TYPESYSTEM_HEADER_WITH_OVERRIDE();
+
+public:
+ CosmeticVertex();
+ CosmeticVertex(const CosmeticVertex* cv);
+ CosmeticVertex(Base::Vector3d loc);
+ ~CosmeticVertex() override = default;
+
+ void move(Base::Vector3d newPos);
+ void moveRelative(Base::Vector3d movement);
+
+ std::string toString() const;
+ void dump(const char* title) override;
+ Base::Vector3d scaled(double factor);
+
+ static bool restoreCosmetic();
+
+ // Persistence implementer ---------------------
+ unsigned int getMemSize() const override;
+ void Save(Base::Writer &/*writer*/) const override;
+ void Restore(Base::XMLReader &/*reader*/) override;
+
+ PyObject *getPyObject() override;
+ CosmeticVertex* copy() const;
+ CosmeticVertex* clone() const;
+
+ Base::Vector3d permaPoint; //permanent, unscaled value
+ int linkGeom; //connection to corresponding "geom" Vertex (fragile - index based!)
+ //better to do reverse search for CosmeticTag in vertex geometry
+ App::Color color;
+ double size;
+ int style;
+ bool visible; //base class vertex also has visible property
+
+ boost::uuids::uuid getTag() const;
+ std::string getTagAsString() const override;
+
+protected:
+ //Uniqueness
+ void createNewTag();
+ void assignTag(const TechDraw::CosmeticVertex* cv);
+
+ boost::uuids::uuid tag;
+
+ Py::Object PythonObject;
+
+
+};
+
+} //end namespace TechDraw
+
+#endif // TECHDRAW_COSMETIC_VERTEX_H
diff --git a/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp b/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp
index 1d302d4c10..dccce57db1 100644
--- a/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp
+++ b/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp
@@ -32,6 +32,7 @@
#include
#include "Cosmetic.h"
+#include "CosmeticVertex.h"
#include "CosmeticVertexPy.h"
#include "CosmeticVertexPy.cpp"
#include "DrawUtil.h"
diff --git a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h
index 6682761116..c5eec43816 100644
--- a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h
+++ b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h
@@ -28,6 +28,8 @@
#include
#include
+#include "CosmeticVertex.h"
+
namespace Base {
class Writer;