[TD]Py routines for CenterLines
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
Delete="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>CenterLine specifies appearance parameters for TechDraw Geometry objects</UserDocu>
|
||||
<UserDocu>CenterLine specifies additional mark up edges in a View</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="clone" Const="true">
|
||||
<Documentation>
|
||||
@@ -25,22 +25,77 @@
|
||||
<UserDocu>Create a copy of this centerline</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setFormat">
|
||||
<Documentation>
|
||||
<UserDocu>Change the appearance of this CenterLine. cl.setFormat(style, color, weight, visible)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
|
||||
<Methode Name="getFormat">
|
||||
<Documentation>
|
||||
<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>
|
||||
<Attribute Name="Type" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>0 - face, 1 - 2 line, 2 - 2 point.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Type" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Mode">
|
||||
<Documentation>
|
||||
<UserDocu>0 - vert/ 1 - horiz/ 2 - aligned.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Mode" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Format">
|
||||
<Documentation>
|
||||
<UserDocu>The appearance attributes (style, color, weight, visible) for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Format" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="HorizShift">
|
||||
<Documentation>
|
||||
<UserDocu>The left/right offset for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="HorizShift" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="VertShift">
|
||||
<Documentation>
|
||||
<UserDocu>The up/down offset for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="VertShift" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Rotation">
|
||||
<Documentation>
|
||||
<UserDocu>The rotation of the Centerline in degrees.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Rotation" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Extension">
|
||||
<Documentation>
|
||||
<UserDocu>The additional length to be added to this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Extension" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Flip">
|
||||
<Documentation>
|
||||
<UserDocu>Reverse the order of points for 2 point CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Flip" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Edges">
|
||||
<Documentation>
|
||||
<UserDocu>The names of source edges for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Edges" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Faces">
|
||||
<Documentation>
|
||||
<UserDocu>The names of source Faces for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Faces" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Points">
|
||||
<Documentation>
|
||||
<UserDocu>The names of source Points for this CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Points" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -108,18 +108,94 @@ PyObject* CenterLinePy::copy(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
PyObject* CenterLinePy::setFormat(PyObject* args)
|
||||
//PyObject* CenterLinePy::setFormat(PyObject* args)
|
||||
//{
|
||||
//// Base::Console().Message("CLPI::setFormat()\n");
|
||||
// PyObject* pTuple;
|
||||
// int style = 1;
|
||||
// double weight = 0.50;
|
||||
// double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
// App::Color c(red, blue, green, alpha);
|
||||
// bool visible = 1;
|
||||
// if (!PyArg_ParseTuple(args, "O", &pTuple)) {
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
// if (PyTuple_Check(pTuple)) {
|
||||
// int tSize = (int) PyTuple_Size(pTuple);
|
||||
// if (tSize > 3) {
|
||||
// PyObject* pStyle = PyTuple_GetItem(pTuple,0);
|
||||
// style = (int) PyLong_AsLong(pStyle);
|
||||
// PyObject* pWeight = PyTuple_GetItem(pTuple,1);
|
||||
// weight = PyFloat_AsDouble(pWeight);
|
||||
// PyObject* pColor = PyTuple_GetItem(pTuple,2);
|
||||
// c = DrawUtil::pyTupleToColor(pColor);
|
||||
// PyObject* pVisible = PyTuple_GetItem(pTuple,3);
|
||||
// visible = (bool) PyLong_AsLong(pVisible);
|
||||
|
||||
// cl->m_format.m_style = style;
|
||||
// cl->m_format.m_weight = weight;
|
||||
// cl->m_format.m_color = c;
|
||||
// cl->m_format.m_visible = visible;
|
||||
// }
|
||||
// } else {
|
||||
// Base::Console().Error("CLPI::setFormat - not a tuple!\n");
|
||||
// }
|
||||
//
|
||||
// return Py_None;
|
||||
//}
|
||||
|
||||
//PyObject* CenterLinePy::getFormat(PyObject *args)
|
||||
//{
|
||||
// (void) args;
|
||||
//// Base::Console().Message("CLPI::getFormat()\n");
|
||||
// TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
// PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style);
|
||||
// PyObject* pWeight = PyFloat_FromDouble(cl->m_format.m_weight);
|
||||
// PyObject* pColor = DrawUtil::colorToPyTuple(cl->m_format.m_color);
|
||||
// PyObject* pVisible = PyBool_FromLong((long) cl->m_format.m_visible);
|
||||
|
||||
// PyObject* result = PyTuple_New(4);
|
||||
|
||||
// PyTuple_SET_ITEM(result, 0, pStyle);
|
||||
// PyTuple_SET_ITEM(result, 1, pWeight);
|
||||
// PyTuple_SET_ITEM(result, 2, pColor);
|
||||
// PyTuple_SET_ITEM(result, 3, pVisible);
|
||||
|
||||
// return result;
|
||||
//}
|
||||
|
||||
Py::Object CenterLinePy::getFormat(void) const
|
||||
{
|
||||
// Base::Console().Message("CLPI::setFormat()\n");
|
||||
PyObject* pTuple;
|
||||
// Base::Console().Message("CLP::getFormat()\n");
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style);
|
||||
PyObject* pWeight = PyFloat_FromDouble(cl->m_format.m_weight);
|
||||
PyObject* pColor = DrawUtil::colorToPyTuple(cl->m_format.m_color);
|
||||
PyObject* pVisible = PyBool_FromLong((long) cl->m_format.m_visible);
|
||||
|
||||
PyObject* result = PyTuple_New(4);
|
||||
|
||||
PyTuple_SET_ITEM(result, 0, pStyle);
|
||||
PyTuple_SET_ITEM(result, 1, pWeight);
|
||||
PyTuple_SET_ITEM(result, 2, pColor);
|
||||
PyTuple_SET_ITEM(result, 3, pVisible);
|
||||
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
void CenterLinePy::setFormat(Py::Object arg)
|
||||
{
|
||||
// Base::Console().Message("CLP::setFormat()\n");
|
||||
PyObject* pTuple = arg.ptr();
|
||||
int style = 1;
|
||||
double weight = 0.50;
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, blue, green, alpha);
|
||||
bool visible = 1;
|
||||
if (!PyArg_ParseTuple(args, "O", &pTuple)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
if (PyTuple_Check(pTuple)) {
|
||||
@@ -142,29 +218,6 @@ PyObject* CenterLinePy::setFormat(PyObject* args)
|
||||
} else {
|
||||
Base::Console().Error("CLPI::setFormat - not a tuple!\n");
|
||||
}
|
||||
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* CenterLinePy::getFormat(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
// Base::Console().Message("CLPI::getFormat()\n");
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style);
|
||||
PyObject* pWeight = PyFloat_FromDouble(cl->m_format.m_weight);
|
||||
PyObject* pColor = DrawUtil::colorToPyTuple(cl->m_format.m_color);
|
||||
PyObject* pVisible = PyBool_FromLong((long) cl->m_format.m_visible);
|
||||
|
||||
PyObject* result = PyTuple_New(4);
|
||||
|
||||
PyTuple_SET_ITEM(result, 0, pStyle);
|
||||
PyTuple_SET_ITEM(result, 1, pWeight);
|
||||
PyTuple_SET_ITEM(result, 2, pColor);
|
||||
PyTuple_SET_ITEM(result, 3, pVisible);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Py::String CenterLinePy::getTag(void) const
|
||||
@@ -173,6 +226,252 @@ Py::String CenterLinePy::getTag(void) const
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
|
||||
Py::Long CenterLinePy::getType(void) const
|
||||
{
|
||||
int tmp = getCenterLinePtr()->m_type;
|
||||
return Py::Long(tmp);
|
||||
}
|
||||
|
||||
Py::Long CenterLinePy::getMode(void) const
|
||||
{
|
||||
int tmp = getCenterLinePtr()->m_mode;
|
||||
return Py::Long(tmp);
|
||||
}
|
||||
|
||||
void CenterLinePy::setMode(Py::Long arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyLong_Check(p)) {
|
||||
long int temp = PyLong_AsLong(p);
|
||||
getCenterLinePtr()->m_mode = (int) temp;
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Integer', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Float CenterLinePy::getHorizShift(void) const
|
||||
{
|
||||
double shift = getCenterLinePtr()->getHShift();
|
||||
return Py::asObject(PyFloat_FromDouble(shift));
|
||||
}
|
||||
|
||||
void CenterLinePy::setHorizShift(Py::Float arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyFloat_Check(p)) {
|
||||
double hshift = PyFloat_AsDouble(p);
|
||||
double vshift = getCenterLinePtr()->getVShift();
|
||||
getCenterLinePtr()->setShifts(hshift, vshift);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Float', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Float CenterLinePy::getVertShift(void) const
|
||||
{
|
||||
double shift = getCenterLinePtr()->getVShift();
|
||||
return Py::asObject(PyFloat_FromDouble(shift));
|
||||
}
|
||||
|
||||
void CenterLinePy::setVertShift(Py::Float arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyFloat_Check(p)) {
|
||||
double vshift = PyFloat_AsDouble(p);
|
||||
double hshift = getCenterLinePtr()->getHShift();
|
||||
getCenterLinePtr()->setShifts(hshift, vshift);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Float', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Float CenterLinePy::getRotation(void) const
|
||||
{
|
||||
double rot = getCenterLinePtr()->getRotate();
|
||||
return Py::asObject(PyFloat_FromDouble(rot));
|
||||
}
|
||||
|
||||
void CenterLinePy::setRotation(Py::Float arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyFloat_Check(p)) {
|
||||
double rot = PyFloat_AsDouble(p);
|
||||
getCenterLinePtr()->setRotate(rot);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Float', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Float CenterLinePy::getExtension(void) const
|
||||
{
|
||||
double rot = getCenterLinePtr()->getExtend();
|
||||
return Py::asObject(PyFloat_FromDouble(rot));
|
||||
}
|
||||
|
||||
void CenterLinePy::setExtension(Py::Float arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyFloat_Check(p)) {
|
||||
double ext = PyFloat_AsDouble(p);
|
||||
getCenterLinePtr()->setExtend(ext);
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Float', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Boolean CenterLinePy::getFlip(void) const
|
||||
{
|
||||
bool flip = getCenterLinePtr()->getFlip();
|
||||
if (flip) {
|
||||
Py_RETURN_TRUE;
|
||||
} else {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void CenterLinePy::setFlip(Py::Boolean arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyBool_Check(p)) {
|
||||
if (p == Py_True) {
|
||||
getCenterLinePtr()->setFlip(true);
|
||||
} else {
|
||||
getCenterLinePtr()->setFlip(false);
|
||||
}
|
||||
} else {
|
||||
std::string error = std::string("type must be 'Boolean', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CenterLinePy::getEdges(void) const
|
||||
{
|
||||
// Base::Console().Message("CLP::getEdges()\n");
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
std::vector<std::string> edges = cl->m_edges;
|
||||
int size = edges.size();
|
||||
|
||||
PyObject* result = PyList_New(size);
|
||||
|
||||
for (auto& e: edges) {
|
||||
PyList_Append(result, PyUnicode_FromString(e.c_str()));
|
||||
}
|
||||
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
void CenterLinePy::setEdges(Py::Object arg)
|
||||
{
|
||||
// Base::Console().Message("CLP::setEdges()\n");
|
||||
PyObject* pList = arg.ptr();
|
||||
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
std::vector<std::string> temp;
|
||||
if (PyList_Check(pList)) {
|
||||
int tSize = (int) PyList_Size(pList);
|
||||
int i = 0;
|
||||
for ( ; i < tSize; i++) {
|
||||
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
|
||||
const char* utf8 = PyUnicode_AsUTF8(item);
|
||||
std::string ssTemp(utf8);
|
||||
temp.push_back(ssTemp);
|
||||
}
|
||||
cl->m_edges = temp;
|
||||
} else {
|
||||
Base::Console().Error("CLPI::setEdges - input not a list!\n");
|
||||
}
|
||||
}
|
||||
Py::Object CenterLinePy::getFaces(void) const
|
||||
{
|
||||
// Base::Console().Message("CLP::getFaces()\n");
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
std::vector<std::string> faces = cl->m_faces;
|
||||
int size = faces.size();
|
||||
|
||||
PyObject* result = PyList_New(size);
|
||||
|
||||
for (auto& f: faces) {
|
||||
PyList_Append(result, PyUnicode_FromString(f.c_str()));
|
||||
}
|
||||
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
void CenterLinePy::setFaces(Py::Object arg)
|
||||
{
|
||||
// Base::Console().Message("CLP::setFaces()\n");
|
||||
PyObject* pList = arg.ptr();
|
||||
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
std::vector<std::string> temp;
|
||||
if (PyList_Check(pList)) {
|
||||
int tSize = (int) PyList_Size(pList);
|
||||
int i = 0;
|
||||
for ( ; i < tSize; i++) {
|
||||
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
|
||||
const char* utf8 = PyUnicode_AsUTF8(item);
|
||||
std::string ssTemp(utf8);
|
||||
temp.push_back(ssTemp);
|
||||
}
|
||||
cl->m_faces = temp;
|
||||
} else {
|
||||
Base::Console().Error("CLPI::setFaces - input not a list!\n");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CenterLinePy::getPoints(void) const
|
||||
{
|
||||
// Base::Console().Message("CLP::getPoints()\n");
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
|
||||
std::vector<std::string> points = cl->m_verts;
|
||||
int size = points.size();
|
||||
|
||||
PyObject* result = PyList_New(size);
|
||||
|
||||
for (auto& p: points) {
|
||||
PyList_Append(result, PyUnicode_FromString(p.c_str()));
|
||||
}
|
||||
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
void CenterLinePy::setPoints(Py::Object arg)
|
||||
{
|
||||
// Base::Console().Message("CLP::setPoints()\n");
|
||||
PyObject* pList = arg.ptr();
|
||||
|
||||
TechDraw::CenterLine* cl = this->getCenterLinePtr();
|
||||
std::vector<std::string> temp;
|
||||
if (PyList_Check(pList)) {
|
||||
int tSize = (int) PyList_Size(pList);
|
||||
int i = 0;
|
||||
for ( ; i < tSize; i++) {
|
||||
PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i);
|
||||
const char* utf8 = PyUnicode_AsUTF8(item);
|
||||
std::string ssTemp(utf8);
|
||||
temp.push_back(ssTemp);
|
||||
}
|
||||
cl->m_verts = temp;
|
||||
} else {
|
||||
Base::Console().Error("CLPI::setPoints - input not a list!\n");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -324,7 +324,7 @@ CosmeticVertex* CosmeticVertex::clone(void) const
|
||||
PyObject* CosmeticVertex::getPyObject(void)
|
||||
{
|
||||
// return new CosmeticVertexPy(new CosmeticVertex(this->copy())); //shouldn't this be clone?
|
||||
PyObject* result = new CosmeticVertexPy(this->clone()); //shouldn't this be clone?
|
||||
PyObject* result = new CosmeticVertexPy(this->clone());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -344,13 +344,15 @@ CosmeticEdge::CosmeticEdge()
|
||||
// Base::Console().Message("CE::CE()\n");
|
||||
m_geometry = new TechDraw::BaseGeom();
|
||||
initialize();
|
||||
|
||||
}
|
||||
|
||||
//TODO: set permaStart/permaEnd in ctors. Need scale.
|
||||
CosmeticEdge::CosmeticEdge(CosmeticEdge* ce)
|
||||
{
|
||||
// Base::Console().Message("CE::CE(ce)\n");
|
||||
TechDraw::BaseGeom* newGeom = ce->m_geometry->copy();
|
||||
permaStart = ce->permaStart;
|
||||
permaEnd = ce->permaEnd;
|
||||
m_geometry = newGeom;
|
||||
m_format = ce->m_format;
|
||||
initialize();
|
||||
@@ -365,6 +367,8 @@ CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
gp_Pnt gp2(p2.x,p2.y,p2.z);
|
||||
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
||||
permaStart = p1;
|
||||
permaEnd = p2;
|
||||
initialize();
|
||||
}
|
||||
|
||||
@@ -372,6 +376,8 @@ CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
// Base::Console().Message("CE::CE(TopoDS_Edge)\n");
|
||||
m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
||||
permaStart = m_geometry->getStartPoint();
|
||||
permaEnd = m_geometry->getEndPoint();
|
||||
initialize();
|
||||
}
|
||||
|
||||
@@ -379,6 +385,8 @@ CosmeticEdge::CosmeticEdge(TechDraw::BaseGeom* g)
|
||||
{
|
||||
// Base::Console().Message("CE::CE(bg)\n");
|
||||
m_geometry = g;
|
||||
permaStart = m_geometry->getStartPoint();
|
||||
permaEnd = m_geometry->getEndPoint();
|
||||
initialize();
|
||||
}
|
||||
|
||||
@@ -400,6 +408,13 @@ void CosmeticEdge::initialize(void)
|
||||
m_geometry->setCosmeticTag(getTagAsString());
|
||||
}
|
||||
|
||||
void CosmeticEdge::unscaleEnds(double scale)
|
||||
{
|
||||
permaStart = permaStart / scale;
|
||||
permaEnd = permaEnd / scale;
|
||||
permaRadius = permaRadius / scale;
|
||||
}
|
||||
|
||||
TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
{
|
||||
TechDraw::BaseGeom* newGeom = nullptr;
|
||||
@@ -418,6 +433,7 @@ TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
|
||||
std::string CosmeticEdge::toString(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << getTagAsString() << ", $$$, ";
|
||||
if (m_geometry != nullptr) {
|
||||
ss << m_geometry->geomType <<
|
||||
",$$$," <<
|
||||
@@ -556,7 +572,7 @@ CosmeticEdge* CosmeticEdge::clone(void) const
|
||||
|
||||
PyObject* CosmeticEdge::getPyObject(void)
|
||||
{
|
||||
return new CosmeticEdgePy(new CosmeticEdge(this->copy()));
|
||||
return new CosmeticEdgePy(this->clone());
|
||||
}
|
||||
|
||||
//*********************************************************
|
||||
@@ -580,28 +596,38 @@ CenterLine::CenterLine(void)
|
||||
initialize();
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(CenterLine* cl)
|
||||
CenterLine::CenterLine(TechDraw::CenterLine* cl)
|
||||
{
|
||||
m_start = cl->m_start;
|
||||
m_end = cl->m_end;
|
||||
m_end = cl->m_end;
|
||||
m_mode = cl->m_mode;
|
||||
m_hShift = cl->m_hShift;
|
||||
m_vShift = cl->m_vShift;
|
||||
m_rotate = cl->m_rotate;
|
||||
m_extendBy = cl->m_extendBy;
|
||||
m_faces = cl->m_faces;
|
||||
m_format = cl->m_format;
|
||||
m_type = cl->m_type;
|
||||
m_flip2Line = cl->m_flip2Line;
|
||||
m_edges = cl->m_edges;
|
||||
m_verts = cl->m_verts;
|
||||
m_flip2Line = m_flip2Line;
|
||||
|
||||
TechDraw::BaseGeom* newGeom = cl->m_geometry->copy();
|
||||
m_geometry = newGeom;
|
||||
m_geometry = cl->m_geometry; //new BaseGeom(cl->m_geometry);??
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(TechDraw::BaseGeom* bg)
|
||||
{
|
||||
m_start = bg->getStartPoint();
|
||||
m_end = bg->getEndPoint();
|
||||
m_mode = CLMODE::VERTICAL;
|
||||
m_hShift = 0.0;
|
||||
m_vShift = 0.0;
|
||||
m_rotate = 0.0;
|
||||
m_extendBy = 0.0;
|
||||
m_type = CLTYPE::FACE;
|
||||
m_flip2Line = false;
|
||||
|
||||
m_geometry = bg;
|
||||
|
||||
initialize();
|
||||
|
||||
m_format = cl->m_format;
|
||||
}
|
||||
|
||||
CenterLine::CenterLine(Base::Vector3d pt1, Base::Vector3d pt2)
|
||||
@@ -674,7 +700,7 @@ CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat,
|
||||
int mode,
|
||||
bool flip)
|
||||
{
|
||||
// Base::Console().Message("CL::CLBuilder()\n");
|
||||
// Base::Console().Message("CL::CLBuilder()\n - subNames: %d", subNames.size());
|
||||
std::pair<Base::Vector3d, Base::Vector3d> ends;
|
||||
std::vector<std::string> faces;
|
||||
std::vector<std::string> edges;
|
||||
@@ -929,7 +955,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
|
||||
double rotate, bool flip)
|
||||
|
||||
{
|
||||
// Base::Console().Message("CL::calc2Lines() - mode: %d flip: %d\n", mode, flip);
|
||||
// Base::Console().Message("CL::calc2Lines() - mode: %d flip: %d edgeNames: %d\n", mode, flip, edgeNames.size());
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
if (edgeNames.empty()) {
|
||||
Base::Console().Warning("CL::calcEndPoints2Lines - no edges!\n");
|
||||
@@ -937,6 +963,7 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
|
||||
}
|
||||
|
||||
double scale = partFeat->getScale();
|
||||
const std::vector<TechDraw::BaseGeom*> dbEdges = partFeat->getEdgeGeometry();
|
||||
|
||||
std::vector<TechDraw::BaseGeom*> edges;
|
||||
for (auto& en: edgeNames) {
|
||||
@@ -947,10 +974,12 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Lines(DrawVi
|
||||
TechDraw::BaseGeom* bg = partFeat->getGeomByIndex(idx);
|
||||
if (bg != nullptr) {
|
||||
edges.push_back(bg);
|
||||
} else {
|
||||
Base::Console().Message("CL::calcEndPoints2Lines - no geom for index: %d\n", idx);
|
||||
}
|
||||
}
|
||||
if (edges.size() != 2) {
|
||||
// Base::Console().Message("CL::calcEndPoints2Lines - wrong number of edges!\n");
|
||||
Base::Console().Message("CL::calcEndPoints2Lines - wrong number of edges: %d!\n", edges.size());
|
||||
// return result;
|
||||
throw Base::IndexError("CenterLine wrong number of edges.");
|
||||
}
|
||||
@@ -1085,8 +1114,8 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints2Points(DrawV
|
||||
|
||||
|
||||
//extend
|
||||
p1 = p1 - (clDir * ext);
|
||||
p2 = p2 + (clDir * ext);
|
||||
p1 = p1 + (clDir * ext);
|
||||
p2 = p2 - (clDir * ext);
|
||||
|
||||
//rotate
|
||||
if (!DrawUtil::fpCompare(rotate, 0.0)) {
|
||||
@@ -1388,7 +1417,7 @@ CenterLine *CenterLine::clone(void) const
|
||||
|
||||
PyObject* CenterLine::getPyObject(void)
|
||||
{
|
||||
return new CenterLinePy(new CenterLine(this->copy()));
|
||||
return new CenterLinePy(this->clone());
|
||||
}
|
||||
|
||||
void CenterLine::setShifts(double h, double v)
|
||||
|
||||
@@ -103,7 +103,6 @@ public:
|
||||
boost::uuids::uuid getTag() const;
|
||||
virtual std::string getTagAsString(void) const;
|
||||
|
||||
|
||||
protected:
|
||||
//Uniqueness
|
||||
void createNewTag();
|
||||
@@ -142,8 +141,10 @@ public:
|
||||
CosmeticEdge* copy(void) const;
|
||||
CosmeticEdge* clone(void) const;
|
||||
|
||||
//Base::Vector3d permaStart; //persistent unscaled start/end points in View coords
|
||||
//Base::Vector3d permaEnd;
|
||||
Base::Vector3d permaStart; //persistent unscaled start/end points in View coords?
|
||||
Base::Vector3d permaEnd;
|
||||
double permaRadius;
|
||||
void unscaleEnds(double scale);
|
||||
TechDraw::BaseGeom* m_geometry;
|
||||
LineFormat m_format;
|
||||
|
||||
@@ -167,7 +168,8 @@ class TechDrawExport CenterLine: public Base::Persistence
|
||||
public:
|
||||
CenterLine();
|
||||
CenterLine(CenterLine* cl);
|
||||
//set m_faces after using next 2 ctors
|
||||
//set m_faces after using next 3 ctors
|
||||
CenterLine(TechDraw::BaseGeom* bg);
|
||||
CenterLine(Base::Vector3d p1, Base::Vector3d p2);
|
||||
CenterLine(Base::Vector3d p1, Base::Vector3d p2,
|
||||
int m,
|
||||
|
||||
@@ -25,22 +25,41 @@
|
||||
<UserDocu>Create a copy of this CosmeticEdge</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setFormat">
|
||||
<Documentation>
|
||||
<UserDocu>Change the appearance of this CometicEdge. edge.setFormat(style, color, weight, visible)</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
|
||||
<Methode Name="getFormat">
|
||||
<Documentation>
|
||||
<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>
|
||||
<!-- <Attribute Name="Owner" ReadOnly="true">-->
|
||||
<!-- <Documentation>-->
|
||||
<!-- <UserDocu>Gives the name of the View which owns this CosmeticEdge as string.</UserDocu>-->
|
||||
<!-- </Documentation>-->
|
||||
<!-- <Parameter Name="Owner" Type="String"/>-->
|
||||
<!-- </Attribute> -->
|
||||
<!-- <Attribute Name="Start">-->
|
||||
<!-- <Documentation>-->
|
||||
<!-- <UserDocu>Gives the position of one end of this CosmeticEdge as vector.</UserDocu>-->
|
||||
<!-- </Documentation>-->
|
||||
<!-- <Parameter Name="Start" Type="Object"/>-->
|
||||
<!-- </Attribute>-->
|
||||
<!-- <Attribute Name="End">-->
|
||||
<!-- <Documentation>-->
|
||||
<!-- <UserDocu>Gives the position of one end of this CosmeticEdge as vector.</UserDocu>-->
|
||||
<!-- </Documentation>-->
|
||||
<!-- <Parameter Name="End" Type="Object"/>-->
|
||||
<!-- </Attribute>-->
|
||||
<!-- <Attribute Name="Geometry">-->
|
||||
<!-- <Documentation>-->
|
||||
<!-- <UserDocu>The edge geometry for this CosmeticEdge.</UserDocu>-->
|
||||
<!-- </Documentation>-->
|
||||
<!-- <Parameter Name="Geometry" Type="Object"/>-->
|
||||
<!-- </Attribute> -->
|
||||
<Attribute Name="Format">
|
||||
<Documentation>
|
||||
<UserDocu>The appearance attributes (style, color, weight, visible) for this CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Format" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -29,7 +29,13 @@
|
||||
|
||||
#include <App/Material.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Geometry.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "CosmeticEdgePy.h"
|
||||
#include "CosmeticEdgePy.cpp"
|
||||
@@ -111,18 +117,18 @@ PyObject* CosmeticEdgePy::copy(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
PyObject* CosmeticEdgePy::setFormat(PyObject* args)
|
||||
void CosmeticEdgePy::setFormat(Py::Object arg)
|
||||
{
|
||||
// Base::Console().Message("CEP::setFormat()\n");
|
||||
PyObject* pTuple;
|
||||
PyObject* pTuple = arg.ptr();
|
||||
int style = 1;
|
||||
double weight = 0.50;
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, blue, green, alpha);
|
||||
bool visible = 1;
|
||||
if (!PyArg_ParseTuple(args, "O", &pTuple)) {
|
||||
return NULL;
|
||||
}
|
||||
// if (!PyArg_ParseTuple(args, "O", &pTuple)) {
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
|
||||
if (PyTuple_Check(pTuple)) {
|
||||
@@ -145,13 +151,10 @@ PyObject* CosmeticEdgePy::setFormat(PyObject* args)
|
||||
} else {
|
||||
Base::Console().Error("CEPI::setFormat - not a tuple!\n");
|
||||
}
|
||||
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* CosmeticEdgePy::getFormat(PyObject *args)
|
||||
Py::Object CosmeticEdgePy::getFormat(void) const
|
||||
{
|
||||
(void) args;
|
||||
// Base::Console().Message("CEP::getFormat()\n");
|
||||
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
|
||||
|
||||
@@ -167,7 +170,7 @@ PyObject* CosmeticEdgePy::getFormat(PyObject *args)
|
||||
PyTuple_SET_ITEM(result, 2, pColor);
|
||||
PyTuple_SET_ITEM(result, 3, pVisible);
|
||||
|
||||
return result;
|
||||
return Py::asObject(result);
|
||||
}
|
||||
|
||||
Py::String CosmeticEdgePy::getTag(void) const
|
||||
@@ -176,6 +179,89 @@ Py::String CosmeticEdgePy::getTag(void) const
|
||||
return Py::String(tmp);
|
||||
}
|
||||
|
||||
//Py::String CosmeticEdgePy::getOwner(void) const
|
||||
//{
|
||||
//// std::string tmp = boost::uuids::to_string(getCosmeticEdgePtr()->getOwner());
|
||||
// std::string tmp = "not implemented yet";
|
||||
// return Py::String(tmp);
|
||||
//}
|
||||
|
||||
//TODO: make BaseGeom py-aware or convert TD geometry to ??Part::Geometry2d?? or other
|
||||
// py-aware class.
|
||||
//Py::Object CosmeticEdgePy::getGeometry(void) const
|
||||
//{
|
||||
//// TechDraw::BaseGeom* bg = getCosmeticEdgePtr()->m_geometry;
|
||||
// Base::Console().Message("Not implemented yet");
|
||||
// return Py::asObject(Py_None);
|
||||
//}
|
||||
|
||||
//void CosmeticEdgePy::setGeometry(Py::Object arg)
|
||||
//{
|
||||
// Base::Console().Message("Not implemented yet");
|
||||
// PyObject* p = arg.ptr();
|
||||
// if (PyObject_TypeCheck(p, &(TechDraw::BaseGeomPy::Type))) {
|
||||
// //TODO
|
||||
// } else {
|
||||
// std::string error = std::string("type must be 'BaseGeom', not ");
|
||||
// error += p->ob_type->tp_name;
|
||||
// throw Py::TypeError(error);
|
||||
// }
|
||||
//}
|
||||
|
||||
//Py::Object CosmeticEdgePy::getStart(void) const
|
||||
//{
|
||||
// Base::Vector3d point = getCosmeticEdgePtr()->permaStart;
|
||||
// point = DrawUtil::invertY(point);
|
||||
// return Py::asObject(new Base::VectorPy(point));
|
||||
//}
|
||||
|
||||
//void CosmeticEdgePy::setStart(Py::Object arg)
|
||||
//{
|
||||
// PyObject* p = arg.ptr();
|
||||
// if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
// Base::Vector3d point = static_cast<Base::VectorPy*>(p)->value();
|
||||
// getCosmeticEdgePtr()->permaStart =
|
||||
// DrawUtil::invertY(point);
|
||||
// }
|
||||
// else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
// Base::Vector3d point = Base::getVectorFromTuple<double>(p);
|
||||
// getCosmeticEdgePtr()->permaStart =
|
||||
// DrawUtil::invertY(point);
|
||||
// }
|
||||
// else {
|
||||
// std::string error = std::string("type must be 'Vector', not ");
|
||||
// error += p->ob_type->tp_name;
|
||||
// throw Py::TypeError(error);
|
||||
// }
|
||||
//}
|
||||
|
||||
//Py::Object CosmeticEdgePy::getEnd(void) const
|
||||
//{
|
||||
// Base::Vector3d point = getCosmeticEdgePtr()->permaEnd;
|
||||
// point = DrawUtil::invertY(point);
|
||||
// return Py::asObject(new Base::VectorPy(point));
|
||||
//}
|
||||
|
||||
//void CosmeticEdgePy::setEnd(Py::Object arg)
|
||||
//{
|
||||
// PyObject* p = arg.ptr();
|
||||
// if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
// Base::Vector3d point = static_cast<Base::VectorPy*>(p)->value();
|
||||
// getCosmeticEdgePtr()->permaEnd =
|
||||
// DrawUtil::invertY(point);
|
||||
// }
|
||||
// else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
// Base::Vector3d point = Base::getVectorFromTuple<double>(p);
|
||||
// getCosmeticEdgePtr()->permaEnd =
|
||||
// DrawUtil::invertY(point);
|
||||
// }
|
||||
// else {
|
||||
// std::string error = std::string("type must be 'Vector', not ");
|
||||
// error += p->ob_type->tp_name;
|
||||
// throw Py::TypeError(error);
|
||||
// }
|
||||
//}
|
||||
|
||||
PyObject *CosmeticEdgePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -49,6 +49,7 @@ CosmeticExtension::CosmeticExtension()
|
||||
|
||||
EXTENSION_ADD_PROPERTY_TYPE(CosmeticVertexes, (0), cgroup, App::Prop_Output, "CosmeticVertex Save/Restore");
|
||||
EXTENSION_ADD_PROPERTY_TYPE(CosmeticEdges, (0), cgroup, App::Prop_Output, "CosmeticEdge Save/Restore");
|
||||
EXTENSION_ADD_PROPERTY_TYPE(CenterLines ,(0),cgroup,App::Prop_Output,"Geometry format Save/Restore");
|
||||
EXTENSION_ADD_PROPERTY_TYPE(GeomFormats ,(0),cgroup,App::Prop_Output,"Geometry format Save/Restore");
|
||||
|
||||
initExtensionType(CosmeticExtension::getExtensionClassTypeId());
|
||||
@@ -180,8 +181,7 @@ bool CosmeticExtension::replaceCosmeticVertex(CosmeticVertex* newCV)
|
||||
std::string CosmeticExtension::addCosmeticEdge(Base::Vector3d start,
|
||||
Base::Vector3d end)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCosmeticEdge(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
// Base::Console().Message("CEx::addCosmeticEdge(s,e)\n");
|
||||
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(start, end);
|
||||
edges.push_back(ce);
|
||||
@@ -201,20 +201,24 @@ std::string CosmeticExtension::addCosmeticEdge(TechDraw::BaseGeom* bg)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//get CE by unique id
|
||||
TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCosmeticEdge(%s)\n", tagString.c_str());
|
||||
CosmeticEdge* result = nullptr;
|
||||
bool found = false;
|
||||
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
|
||||
for (auto& ce: edges) {
|
||||
std::string ceTag = ce->getTagAsString();
|
||||
if (ceTag == tagString) {
|
||||
result = ce;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Base::Console().Message("CEx::getCosmeticEdge - CE for tag: %s not found.\n", tagString.c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -234,6 +238,7 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::strin
|
||||
if (base == nullptr) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!base->getCosmeticTag().empty()) {
|
||||
result = getCosmeticEdge(base->getCosmeticTag());
|
||||
}
|
||||
@@ -272,7 +277,6 @@ void CosmeticExtension::removeCosmeticEdge(std::vector<std::string> delTags)
|
||||
|
||||
bool CosmeticExtension::replaceCosmeticEdge(CosmeticEdge* newCE)
|
||||
{
|
||||
// Base::Console().Message("DVP::replaceCE(%s)\n", newCE->getTagAsString().c_str());
|
||||
bool result = false;
|
||||
std::vector<CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
std::vector<CosmeticEdge*> newEdges;
|
||||
@@ -291,6 +295,131 @@ bool CosmeticExtension::replaceCosmeticEdge(CosmeticEdge* newCE)
|
||||
|
||||
//********** Center Line *******************************************************
|
||||
|
||||
//returns unique CL id
|
||||
//only adds cl to cllist property. does not add to display geometry until dvp executes.
|
||||
std::string CosmeticExtension::addCenterLine(Base::Vector3d start,
|
||||
Base::Vector3d end)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCenterLine(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
TechDraw::CenterLine* cl = new TechDraw::CenterLine(start, end);
|
||||
cLines.push_back(cl);
|
||||
CenterLines.setValues(cLines);
|
||||
std::string result = cl->getTagAsString();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string CosmeticExtension::addCenterLine(TechDraw::CenterLine* cl)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCenterLine(cl: %X)\n", cl);
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
cLines.push_back(cl);
|
||||
CenterLines.setValues(cLines);
|
||||
std::string result = cl->getTagAsString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string CosmeticExtension::addCenterLine(TechDraw::BaseGeom* bg)
|
||||
{
|
||||
// Base::Console().Message("CEx::addCenterLine(bg: %X)\n", bg);
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
TechDraw::CenterLine* cl = new TechDraw::CenterLine(bg);
|
||||
cLines.push_back(cl);
|
||||
CenterLines.setValues(cLines);
|
||||
std::string result = cl->getTagAsString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//get CL by unique id
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLine(std::string tagString) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCenterLine(%s)\n", tagString.c_str());
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> cLines = CenterLines.getValues();
|
||||
for (auto& cl: cLines) {
|
||||
std::string clTag = cl->getTagAsString();
|
||||
if (clTag == tagString) {
|
||||
result = cl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// find the center line corresponding to selection name (Edge5)
|
||||
// used when selecting
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string name) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCLBySelection(%s)\n",name.c_str());
|
||||
CenterLine* result = nullptr;
|
||||
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
|
||||
if (dvp == nullptr) {
|
||||
return result;
|
||||
}
|
||||
int idx = DrawUtil::getIndexFromName(name);
|
||||
TechDraw::BaseGeom* base = dvp->getGeomByIndex(idx);
|
||||
if (base == nullptr) {
|
||||
return result;
|
||||
}
|
||||
if (!base->getCosmeticTag().empty()) {
|
||||
result = getCenterLine(base->getCosmeticTag());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//overload for index only
|
||||
TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(int i) const
|
||||
{
|
||||
// Base::Console().Message("CEx::getCLBySelection(%d)\n", i);
|
||||
std::stringstream ss;
|
||||
ss << "Edge" << i;
|
||||
std::string eName = ss.str();
|
||||
return getCenterLineBySelection(eName);
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCenterLine(std::string delTag)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCL(%s)\n", delTag.c_str());
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
std::vector<CenterLine*> newLines;
|
||||
for (auto& cl: cLines) {
|
||||
if (cl->getTagAsString() != delTag) {
|
||||
newLines.push_back(cl);
|
||||
}
|
||||
}
|
||||
CenterLines.setValues(newLines);
|
||||
}
|
||||
|
||||
void CosmeticExtension::removeCenterLine(std::vector<std::string> delTags)
|
||||
{
|
||||
for (auto& t: delTags) {
|
||||
removeCenterLine(t);
|
||||
}
|
||||
}
|
||||
|
||||
bool CosmeticExtension::replaceCenterLine(CenterLine* newCL)
|
||||
{
|
||||
// Base::Console().Message("DVP::replaceCL(%s)\n", newCL->getTagAsString().c_str());
|
||||
bool result = false;
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
std::vector<CenterLine*> newLines;
|
||||
std::string tag = newCL->getTagAsString();
|
||||
for (auto& cl: cLines) {
|
||||
if (cl->getTagAsString() == tag) {
|
||||
newLines.push_back(newCL);
|
||||
result = true;
|
||||
} else {
|
||||
newLines.push_back(cl);
|
||||
}
|
||||
}
|
||||
CenterLines.setValues(newLines);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//********** Geometry Formats **************************************************
|
||||
//returns unique GF id
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "PropertyCosmeticVertexList.h"
|
||||
#include "PropertyCosmeticEdgeList.h"
|
||||
#include "PropertyCenterLineList.h"
|
||||
#include "PropertyGeomFormatList.h"
|
||||
|
||||
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
|
||||
TechDraw::PropertyCosmeticVertexList CosmeticVertexes;
|
||||
TechDraw::PropertyCosmeticEdgeList CosmeticEdges;
|
||||
// TechDraw::PropertyCenterLineList CenterLines;
|
||||
TechDraw::PropertyCenterLineList CenterLines;
|
||||
TechDraw::PropertyGeomFormatList GeomFormats; //formats for geometric edges
|
||||
|
||||
virtual std::string addCosmeticVertex(Base::Vector3d pos);
|
||||
@@ -69,6 +70,16 @@ public:
|
||||
virtual void removeCosmeticEdge(std::string tag);
|
||||
virtual void removeCosmeticEdge(std::vector<std::string> delTags);
|
||||
|
||||
virtual std::string addCenterLine(Base::Vector3d start, Base::Vector3d end);
|
||||
virtual std::string addCenterLine(TechDraw::CenterLine* cl);
|
||||
virtual std::string addCenterLine(TechDraw::BaseGeom* bg);
|
||||
virtual CenterLine* getCenterLineBySelection(std::string name) const;
|
||||
virtual CenterLine* getCenterLineBySelection(int i) const;
|
||||
virtual CenterLine* getCenterLine(std::string tag) const;
|
||||
virtual bool replaceCenterLine(CenterLine* newLine);
|
||||
virtual void removeCenterLine(std::string tag);
|
||||
virtual void removeCenterLine(std::vector<std::string> delTags);
|
||||
|
||||
virtual std::string addGeomFormat(TechDraw::GeomFormat* gf);
|
||||
virtual GeomFormat* getGeomFormatBySelection(std::string name) const;
|
||||
virtual GeomFormat* getGeomFormatBySelection(int i) const;
|
||||
|
||||
@@ -1080,16 +1080,15 @@ int DrawViewPart::add1CEToGE(std::string tag)
|
||||
//update Edge geometry with current CE's
|
||||
void DrawViewPart::refreshCEGeoms(void)
|
||||
{
|
||||
// Base::Console().Message("CEx::refreshCEGeoms()\n");
|
||||
|
||||
// Base::Console().Message("DVP::refreshCEGeoms()\n");
|
||||
std::vector<TechDraw::BaseGeom *> gEdges = getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *> newGEdges;
|
||||
std::vector<TechDraw::BaseGeom *> oldGEdges;
|
||||
for (auto& ge :gEdges) {
|
||||
if (ge->getTagAsString().empty()) { //keep only non-ce edges
|
||||
newGEdges.push_back(ge);
|
||||
if (ge->getCosmeticTag().empty()) { //keep only non-ce edges
|
||||
oldGEdges.push_back(ge);
|
||||
}
|
||||
}
|
||||
getGeometryObject()->setEdgeGeometry(newGEdges);
|
||||
getGeometryObject()->setEdgeGeometry(oldGEdges);
|
||||
addCosmeticEdgesToGeom();
|
||||
}
|
||||
|
||||
@@ -1101,129 +1100,50 @@ void DrawViewPart::clearCenterLines(void)
|
||||
CenterLines.setValues(noLines);
|
||||
}
|
||||
|
||||
int DrawViewPart::addCenterLine(CenterLine* cl)
|
||||
int DrawViewPart::add1CLToGE(std::string tag)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCL(cl)\n");
|
||||
std::vector<CenterLine*> lines = CenterLines.getValues();
|
||||
int newIdx = (int) lines.size();
|
||||
lines.push_back(cl);
|
||||
CenterLines.setValues(lines);
|
||||
return newIdx;
|
||||
// Base::Console().Message("CEx::add1CLToGE(%s) 2\n", tag.c_str());
|
||||
TechDraw::CenterLine* cl = getCenterLine(tag);
|
||||
if (cl == nullptr) {
|
||||
Base::Console().Message("CEx::add1CLToGE 2 - cl %s not found\n", tag.c_str());
|
||||
return -1;
|
||||
}
|
||||
TechDraw::BaseGeom* scaledGeom = cl->scaledGeometry(this);
|
||||
int iGE = geometryObject->addCenterLine(scaledGeom,
|
||||
tag);
|
||||
|
||||
return iGE;
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(TechDraw::CenterLine* cl)
|
||||
//update Edge geometry with current CL's
|
||||
void DrawViewPart::refreshCLGeoms(void)
|
||||
{
|
||||
bool found = false;
|
||||
int i = 0;
|
||||
std::vector<CenterLine*> lines = CenterLines.getValues();
|
||||
int stop = lines.size();
|
||||
for ( ; i < stop; i++) {
|
||||
TechDraw::CenterLine* l = lines.at(i);
|
||||
if (cl == l) {
|
||||
found = true;
|
||||
break;
|
||||
// Base::Console().Message("DVP::refreshCLGeoms()\n");
|
||||
std::vector<TechDraw::BaseGeom *> gEdges = getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *> newGEdges;
|
||||
for (auto& ge :gEdges) {
|
||||
//TODO: this will keep CE & CL
|
||||
if (ge->getCosmeticTag().empty()) { //keep only non-cl edges
|
||||
newGEdges.push_back(ge);
|
||||
}
|
||||
}
|
||||
if ( (cl != nullptr) &&
|
||||
(found) ) {
|
||||
removeCenterLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(int idx)
|
||||
{
|
||||
std::vector<CenterLine*> lines = CenterLines.getValues();
|
||||
if (idx < (int) lines.size()) {
|
||||
lines.erase(lines.begin() + idx);
|
||||
CenterLines.setValues(lines);
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(std::string delTag)
|
||||
{
|
||||
// Base::Console().Message("DVP::removeCL(%s)\n", delTag.c_str());
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
std::vector<CenterLine*> newLines;
|
||||
for (auto& cl: cLines) {
|
||||
if (cl->getTagAsString() != delTag) {
|
||||
newLines.push_back(cl);
|
||||
}
|
||||
}
|
||||
CenterLines.setValues(newLines);
|
||||
}
|
||||
|
||||
void DrawViewPart::removeCenterLine(std::vector<std::string> delTags)
|
||||
{
|
||||
std::vector<CenterLine*> cLines = CenterLines.getValues();
|
||||
std::vector<CenterLine*> newLines;
|
||||
for (auto& cl: cLines) {
|
||||
bool found = false;
|
||||
for (auto& dt: delTags) {
|
||||
if (cl->getTagAsString() == dt) {
|
||||
found = true; //this cl is in delete list
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
newLines.push_back(cl);
|
||||
}
|
||||
}
|
||||
CenterLines.setValues(newLines);
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCenterLine(int idx, TechDraw::CenterLine* cl)
|
||||
{
|
||||
std::vector<CenterLine*> lines = CenterLines.getValues();
|
||||
if (idx < (int) lines.size()) {
|
||||
lines.at(idx) = cl;
|
||||
recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine* cl)
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(geomIndex)->sourceIndex();
|
||||
replaceCenterLine(sourceIndex, cl);
|
||||
}
|
||||
|
||||
TechDraw::CenterLine* DrawViewPart::getCenterLineByIndex(int idx) const
|
||||
{
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
|
||||
if (idx < (int) lines.size()) {
|
||||
result = lines.at(idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//find the cosmetic edge corresponding to geometry edge idx
|
||||
TechDraw::CenterLine* DrawViewPart::getCenterLineByGeom(int idx) const
|
||||
{
|
||||
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
|
||||
int sourceIndex = geoms.at(idx)->sourceIndex();
|
||||
CenterLine* result = nullptr;
|
||||
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
|
||||
result = lines.at(sourceIndex);
|
||||
return result;
|
||||
getGeometryObject()->setEdgeGeometry(newGEdges);
|
||||
addCenterLinesToGeom();
|
||||
}
|
||||
|
||||
//add the center lines to geometry Edges list
|
||||
void DrawViewPart::addCenterLinesToGeom(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::addCenterLinesToGeom()\n");
|
||||
int i = 0;
|
||||
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
|
||||
int stop = (int) lines.size();
|
||||
for ( ; i < stop; i++) {
|
||||
TechDraw::BaseGeom* scaledGeom = lines.at(i)->scaledGeometry(this);
|
||||
for (auto& cl: lines) {
|
||||
TechDraw::BaseGeom* scaledGeom = cl->scaledGeometry(this);
|
||||
if (scaledGeom == nullptr) {
|
||||
Base::Console().Error("DVP::addCenterLinesToGeom - scaledGeometry is null\n");
|
||||
continue;
|
||||
}
|
||||
// int idx =
|
||||
(void) geometryObject->addCenterLine(scaledGeom, 2, i);
|
||||
(void) geometryObject->addCenterLine(scaledGeom, cl->getTagAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1265,6 +1185,17 @@ void DrawViewPart::dumpCosVerts(std::string text)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewPart::dumpCosEdges(std::string text)
|
||||
{
|
||||
std::vector<TechDraw::CosmeticEdge*> cEdges = CosmeticEdges.getValues();
|
||||
Base::Console().Message("%s - dumping %d CosmeticEdge\n",
|
||||
text.c_str(), cEdges.size());
|
||||
for (auto& ce: cEdges) {
|
||||
ce->dump("a CE");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawViewPart::onDocumentRestored()
|
||||
{
|
||||
|
||||
@@ -111,8 +111,6 @@ public:
|
||||
App::PropertyBool IsoHidden;
|
||||
App::PropertyInteger IsoCount;
|
||||
|
||||
TechDraw::PropertyCenterLineList CenterLines;
|
||||
|
||||
virtual short mustExecute() const override;
|
||||
virtual void onDocumentRestored() override;
|
||||
virtual App::DocumentObjectExecReturn *execute(void) override;
|
||||
@@ -181,22 +179,16 @@ public:
|
||||
void addCosmeticEdgesToGeom(void);
|
||||
int add1CEToGE(std::string tag);
|
||||
|
||||
virtual int addCenterLine(TechDraw::CenterLine*);
|
||||
virtual void removeCenterLine(TechDraw::CenterLine* cl);
|
||||
virtual void removeCenterLine(int idx);
|
||||
void removeCenterLine(std::string delTag);
|
||||
void removeCenterLine(std::vector<std::string> delTags);
|
||||
TechDraw::CenterLine* getCenterLineByIndex(int idx) const;
|
||||
TechDraw::CenterLine* getCenterLineByGeom(int idx) const;
|
||||
void replaceCenterLine(int idx, TechDraw::CenterLine* cl);
|
||||
void replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine* cl);
|
||||
void clearCenterLines(void);
|
||||
void clearCenterLines(void);
|
||||
void refreshCLGeoms(void);
|
||||
void addCenterLinesToGeom(void);
|
||||
int add1CLToGE(std::string tag);
|
||||
|
||||
void clearGeomFormats(void);
|
||||
|
||||
void dumpVerts(const std::string text);
|
||||
void dumpCosVerts(const std::string text);
|
||||
void dumpCosEdges(const std::string text);
|
||||
|
||||
protected:
|
||||
bool checkXDirection(void) const;
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticVertex">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticVertex(id) - returns CosmeticVertex with unique id.</UserDocu>
|
||||
<UserDocu>cv = getCosmeticVertex(id) - returns CosmeticVertex with unique id.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticVertexBySelection">
|
||||
<Documentation>
|
||||
<UserDocu>getCosmeticVertexBySelection(name) - returns CosmeticVertex with name (Vertex6). Used in selections.</UserDocu>
|
||||
<UserDocu>cv = getCosmeticVertexBySelection(name) - returns CosmeticVertex with name (Vertex6). Used in selections.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="replaceCosmeticVertex">
|
||||
<Documentation>
|
||||
<UserDocu>replaceCosmeticVertex(cv) - replaces CosmeticVertex in View. Returns True/False.</UserDocu>
|
||||
<UserDocu>rc = replaceCosmeticVertex(cv) - replaces CosmeticVertex in View. Returns True/False.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeCosmeticVertex">
|
||||
@@ -60,17 +60,17 @@
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticLine">
|
||||
<Documentation>
|
||||
<UserDocu>makeCosmeticLine(p1, p2) - add a CosmeticEdge from p1 to p2(View coordinates). Returns index of created edge.</UserDocu>
|
||||
<UserDocu>tag = makeCosmeticLine(p1, p2) - add a CosmeticEdge from p1 to p2(View coordinates). Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircle">
|
||||
<Documentation>
|
||||
<UserDocu>makeCosmeticCircle(center, radius) - add a CosmeticEdge at center with radius radius(View coordinates). Returns index of created edge.</UserDocu>
|
||||
<UserDocu>tag = makeCosmeticCircle(center, radius) - add a CosmeticEdge at center with radius radius(View coordinates). Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircleArc">
|
||||
<Documentation>
|
||||
<UserDocu>makeCosmeticCircleArc(center, radius, start, end) - add a CosmeticEdge at center with radius radius(View coordinates) from start angle to end angle. Returns index of created edge.</UserDocu>
|
||||
<UserDocu>tag = makeCosmeticCircleArc(center, radius, start, end) - add a CosmeticEdge at center with radius radius(View coordinates) from start angle to end angle. Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticEdge">
|
||||
@@ -95,7 +95,27 @@
|
||||
</Methode>
|
||||
<Methode Name="makeCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>makeCenterLine(subNames, mode) - draw a center line on this viewPart. SubNames is a list of n Faces, 2 Edges or 2 Vertices (ex [Face1,Face2,Face3]. Returns index of added CenterLine.</UserDocu>
|
||||
<UserDocu>makeCenterLine(subNames, mode) - draw a center line on this viewPart. SubNames is a list of n Faces, 2 Edges or 2 Vertices (ex [Face1,Face2,Face3]. Returns unique tag of added CenterLine.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>cl = getCenterLine(id) - returns CenterLine with unique id.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCenterLineBySelection">
|
||||
<Documentation>
|
||||
<UserDocu>cl = getCenterLineBySelection(name) - returns CenterLine by name (Edge25). Used in selections</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="replaceCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>replaceCenterLine(cl) - replacls CenterLine cl in View. Returns True/False.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>removeCenterLine(cl) - remove CenterLine cl from View. Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="clearCosmeticEdges">
|
||||
@@ -113,16 +133,6 @@
|
||||
<UserDocu>clearGeomFormats() - remove all GeomFormats from the View. Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="adjustCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>adjustCenterLine(index, hShift, vShift, rotate, extend [,flip]). Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="formatCenterLine">
|
||||
<Documentation>
|
||||
<UserDocu>formatCenterLine(index, style, weight, color, visible). Returns None.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="formatGeometricEdge">
|
||||
<Documentation>
|
||||
<UserDocu>formatGeometricEdge(index, style, weight, color, visible). Returns None.</UserDocu>
|
||||
|
||||
@@ -310,6 +310,8 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce != nullptr) {
|
||||
ce->permaStart = pnt1;
|
||||
ce->permaEnd = pnt2;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
@@ -322,8 +324,10 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
//int link =
|
||||
dvp->add1CEToGE(newTag);
|
||||
dvp->requestPaint();
|
||||
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
@@ -357,9 +361,11 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
BRepBuilderAPI_MakeEdge aMakeEdge(hCircle, angle1*(M_PI/180), angle2*(M_PI/180));
|
||||
TopoDS_Edge edge = aMakeEdge.Edge();
|
||||
TechDraw::BaseGeom* bg = TechDraw::BaseGeom::baseFactory(edge);
|
||||
std::string tag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce != nullptr) {
|
||||
ce->permaStart = pnt1;
|
||||
ce->permaEnd = pnt1;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
@@ -372,8 +378,10 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
//int link =
|
||||
dvp->add1CEToGE(newTag);
|
||||
dvp->requestPaint();
|
||||
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
@@ -410,9 +418,11 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
|
||||
TopoDS_Edge edge = aMakeEdge.Edge();
|
||||
TechDraw::BaseGeom* bg = TechDraw::BaseGeom::baseFactory(edge);
|
||||
std::string tag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce != nullptr) {
|
||||
ce->permaStart = pnt1;
|
||||
ce->permaEnd = pnt1;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
@@ -426,8 +436,10 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
|
||||
PyObject* result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
return result;
|
||||
//int link =
|
||||
dvp->add1CEToGE(newTag);
|
||||
dvp->requestPaint();
|
||||
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
|
||||
}
|
||||
|
||||
//********** Cosmetic Edge *****************************************************
|
||||
@@ -442,7 +454,9 @@ PyObject* DrawViewPartPy::getCosmeticEdge(PyObject *args)
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(tag);
|
||||
if (ce != nullptr) {
|
||||
result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
// result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
result = new CosmeticEdgePy(ce->clone());
|
||||
// result = ce->getPyObject();
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCosmeticEdge - edge %s not found\n", tag);
|
||||
}
|
||||
@@ -453,18 +467,19 @@ PyObject* DrawViewPartPy::getCosmeticEdge(PyObject *args)
|
||||
PyObject* DrawViewPartPy::getCosmeticEdgeBySelection(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCosmeticEdgeBySelection()\n");
|
||||
char* tag;
|
||||
char* name;
|
||||
PyObject* result = Py_None;
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
if (!PyArg_ParseTuple(args, "s", &name)) {
|
||||
throw Py::TypeError("expected (name)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeBySelection(tag);
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeBySelection(name);
|
||||
if (ce != nullptr) {
|
||||
result = new CosmeticEdgePy(new CosmeticEdge(ce));
|
||||
// result = ce->getPyObject();
|
||||
result = new CosmeticEdgePy(ce->clone());
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCosmeticEdgebySelection - edge for tag %s not found\n", tag);
|
||||
Base::Console().Error("DVPPI::getCosmeticEdgebySelection - edge for name %s not found\n", name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -530,86 +545,94 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
CenterLine* cl = nullptr;
|
||||
int idx = -1;
|
||||
std::string tag;
|
||||
if (!subs.empty()) {
|
||||
cl = CenterLine::CenterLineBuilder(dvp,
|
||||
subs,
|
||||
mode); //vert,horiz,align
|
||||
if (cl != nullptr) {
|
||||
idx = dvp->addCenterLine(cl);
|
||||
tag = dvp->addCenterLine(cl);
|
||||
} else {
|
||||
std::string msg = "DVPPI:makeCenterLine - line creation failed";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
}
|
||||
return PyLong_FromLong(idx);
|
||||
//int link =
|
||||
dvp->add1CLToGE(tag);
|
||||
dvp->requestPaint();
|
||||
|
||||
return PyUnicode_FromString(tag.c_str()); //return tag for new CV
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::adjustCenterLine(PyObject *args)
|
||||
PyObject* DrawViewPartPy::getCenterLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::adjustCenterLine()\n");
|
||||
int idx = -1;
|
||||
double hShift = 0.0;
|
||||
double vShift = 0.0;
|
||||
double rotate = 0.0;
|
||||
double extend = 0.0;
|
||||
bool flip = false;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "idddd|p",&idx, &hShift, &vShift, &rotate, &extend, &flip)) {
|
||||
throw Py::TypeError("expected (index, hShift, vShift, rotate, extend [,flip])");
|
||||
char* tag;
|
||||
PyObject* result = Py_None;
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
}
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
CenterLine* cl = dvp->getCenterLineByIndex(idx);
|
||||
TechDraw::CenterLine* cl = dvp->getCenterLine(tag);
|
||||
if (cl != nullptr) {
|
||||
cl->m_hShift = hShift;
|
||||
cl->m_vShift = vShift;
|
||||
cl->m_rotate = rotate;
|
||||
cl->m_extendBy = extend;
|
||||
cl->m_flip2Line = flip;
|
||||
result = new CenterLinePy(cl->clone());
|
||||
} else {
|
||||
std::string msg = "DVPPI:adjustCenterLine - CenterLine not found";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
Base::Console().Error("DVPPI::getCenterLine - centerLine %s not found\n", tag);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::getCenterLineBySelection(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::getCenterLineBySelection()\n");
|
||||
char* tag;
|
||||
PyObject* result = Py_None;
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (name)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
|
||||
TechDraw::CenterLine* cl = dvp->getCenterLineBySelection(tag);
|
||||
if (cl != nullptr) {
|
||||
result = new CenterLinePy(cl->clone());
|
||||
} else {
|
||||
Base::Console().Error("DVPPI::getCenterLinebySelection - centerLine for tag %s not found\n", tag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::replaceCenterLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::replace CenterLine()\n");
|
||||
PyObject* pNewCL;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CenterLinePy::Type), &pNewCL)) {
|
||||
throw Py::TypeError("expected (CenterLine)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
TechDraw::CenterLinePy* clPy = static_cast<TechDraw::CenterLinePy*>(pNewCL);
|
||||
TechDraw::CenterLine* cl = clPy->getCenterLinePtr();
|
||||
bool result = dvp->replaceCenterLine(cl);
|
||||
dvp->refreshCLGeoms();
|
||||
dvp->requestPaint();
|
||||
return PyBool_FromLong((long) result);
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::removeCenterLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::removeCenterLine()\n");
|
||||
char* tag;
|
||||
if (!PyArg_ParseTuple(args, "s", &tag)) {
|
||||
throw Py::TypeError("expected (tag)");
|
||||
}
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
dvp->removeCenterLine(tag);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::formatCenterLine(PyObject *args)
|
||||
{
|
||||
// Base::Console().Message("DVPPI::formatCenterLine()\n");
|
||||
int idx = -1;
|
||||
int style = Qt::SolidLine;
|
||||
App::Color defColor = LineFormat::getDefEdgeColor();
|
||||
double weight = 0.5;
|
||||
int visible = 1;
|
||||
PyObject* pColor;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iidOi",&idx, &style, &weight, &pColor, &visible)) {
|
||||
throw Py::TypeError("expected (index, style, weight, color, visible)");
|
||||
}
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
CenterLine* cl = dvp->getCenterLineByIndex(idx);
|
||||
if (cl != nullptr) {
|
||||
cl->m_format.m_style = style;
|
||||
cl->m_format.m_weight = weight;
|
||||
if (pColor == nullptr) {
|
||||
cl->m_format.m_color = defColor;
|
||||
} else {
|
||||
cl->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
cl->m_format.m_visible = visible;
|
||||
} else {
|
||||
std::string msg = "DVPPI:formatCenterLine - CenterLine not found";
|
||||
Base::Console().Message("%s\n",msg.c_str());
|
||||
throw Py::RuntimeError(msg);
|
||||
}
|
||||
return Py_None;
|
||||
}
|
||||
//********** Geometry Edge *****************************************************
|
||||
|
||||
PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ class TechDrawExport BaseGeom
|
||||
{
|
||||
public:
|
||||
BaseGeom();
|
||||
//BaseGeom(BaseGeom* bg); //do we need a copy constructor too?
|
||||
virtual ~BaseGeom() = default;
|
||||
|
||||
public:
|
||||
|
||||
@@ -667,6 +667,7 @@ int GeometryObject::addCosmeticEdge(Base::Vector3d start,
|
||||
TechDraw::BaseGeom* base = BaseGeom::baseFactory(occEdge);
|
||||
base->cosmetic = true;
|
||||
base->setCosmeticTag(tagString);
|
||||
base->source(1); //1-CosmeticEdge, 2-CenterLine
|
||||
base->hlrVisible = true;
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(base);
|
||||
@@ -687,15 +688,16 @@ int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base,
|
||||
}
|
||||
|
||||
int GeometryObject::addCenterLine(TechDraw::BaseGeom* base,
|
||||
int s, int si)
|
||||
std::string tag)
|
||||
// int s, int si)
|
||||
{
|
||||
// Base::Console().Message("GO::addCenterLine()\n");
|
||||
base->cosmetic = true;
|
||||
base->source(s); //1-CosmeticEdge, 2-CenterLine
|
||||
base->sourceIndex(si); //index into source;
|
||||
|
||||
base->setCosmeticTag(tag);
|
||||
base->source(2);
|
||||
// base->sourceIndex(si); //index into source;
|
||||
int idx = edgeGeom.size();
|
||||
edgeGeom.push_back(base);
|
||||
int idx = edgeGeom.size() - 1;
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,9 @@ public:
|
||||
int addCosmeticEdge(TechDraw::BaseGeom* base,
|
||||
std::string tagString);
|
||||
|
||||
int addCenterLine(TechDraw::BaseGeom* bg, int s = 0, int si = -1);
|
||||
int addCenterLine(TechDraw::BaseGeom* bg,
|
||||
std::string tag);
|
||||
/* int s = 0, int si = -1);*/
|
||||
|
||||
protected:
|
||||
//HLR output
|
||||
|
||||
@@ -116,7 +116,6 @@ PyObject *PropertyCosmeticEdgeList::getPyObject(void)
|
||||
void PropertyCosmeticEdgeList::setPyObject(PyObject *value)
|
||||
{
|
||||
// check container of this property to notify about changes
|
||||
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
|
||||
|
||||
if (PySequence_Check(value)) {
|
||||
Py_ssize_t nSize = PySequence_Size(value);
|
||||
@@ -135,8 +134,6 @@ void PropertyCosmeticEdgeList::setPyObject(PyObject *value)
|
||||
}
|
||||
|
||||
setValues(values);
|
||||
// if (part2d)
|
||||
// part2d->acceptCosmeticEdge();
|
||||
}
|
||||
else if (PyObject_TypeCheck(value, &(CosmeticEdgePy::Type))) {
|
||||
CosmeticEdgePy *pcObject = static_cast<CosmeticEdgePy*>(value);
|
||||
|
||||
@@ -753,8 +753,10 @@ void execCenterLine(Gui::Command* cmd)
|
||||
int geomIdx = DrawUtil::getIndexFromName(edgeName);
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = baseFeat->getEdgeGeometry();
|
||||
BaseGeom* bg = geoms.at(geomIdx);
|
||||
int clIdx = bg->sourceIndex();
|
||||
TechDraw::CenterLine* cl = baseFeat->getCenterLineByIndex(clIdx);
|
||||
// int clIdx = bg->sourceIndex();
|
||||
// TechDraw::CenterLine* cl = baseFeat->getCenterLineByIndex(clIdx);
|
||||
std::string tag = bg->getCosmeticTag();
|
||||
TechDraw::CenterLine* cl = baseFeat->getCenterLine(tag);
|
||||
if (cl == nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("No CenterLine in selection."));
|
||||
@@ -829,8 +831,10 @@ void exec2LineCenterLine(Gui::Command* cmd)
|
||||
int geomIdx = DrawUtil::getIndexFromName(edgeName);
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = dvp->getEdgeGeometry();
|
||||
BaseGeom* bg = geoms.at(geomIdx);
|
||||
int clIdx = bg->sourceIndex();
|
||||
TechDraw::CenterLine* cl = dvp->getCenterLineByIndex(clIdx);
|
||||
// int clIdx = bg->sourceIndex();
|
||||
// TechDraw::CenterLine* cl = dvp->getCenterLineByIndex(clIdx);
|
||||
std::string tag = bg->getCosmeticTag();
|
||||
TechDraw::CenterLine* cl = dvp->getCenterLine(tag);
|
||||
if (cl == nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"),
|
||||
QObject::tr("No CenterLine in selection."));
|
||||
|
||||
@@ -568,12 +568,12 @@ void QGIViewPart::drawViewPart()
|
||||
item->setStyle(Qt::SolidLine);
|
||||
if ((*itGeom)->cosmetic == true) {
|
||||
int source = (*itGeom)->source();
|
||||
int sourceIndex = (*itGeom)->sourceIndex();
|
||||
if (source == COSMETICEDGE) {
|
||||
std::string cTag = (*itGeom)->getCosmeticTag();
|
||||
showItem = formatGeomFromCosmetic(cTag, item);
|
||||
} else if (source == CENTERLINE) {
|
||||
showItem = formatGeomFromCenterLine(sourceIndex, item);
|
||||
std::string cTag = (*itGeom)->getCosmeticTag();
|
||||
showItem = formatGeomFromCenterLine(cTag, item);
|
||||
} else {
|
||||
Base::Console().Message("QGIVP::drawVP - edge: %d is confused - source: %d\n",i,source);
|
||||
}
|
||||
@@ -702,12 +702,12 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
|
||||
}
|
||||
|
||||
|
||||
bool QGIViewPart::formatGeomFromCenterLine(int sourceIndex, QGIEdge* item)
|
||||
bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n",sourceIndex);
|
||||
bool result = true;
|
||||
auto partFeat( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
TechDraw::CenterLine* cl = partFeat->getCenterLineByIndex(sourceIndex);
|
||||
TechDraw::CenterLine* cl = partFeat->getCenterLine(cTag);
|
||||
if (cl != nullptr) {
|
||||
item->setNormalColor(cl->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
|
||||
@@ -926,6 +926,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: use Cosmetic::CenterLine object for this to make it usable for dims.
|
||||
void QGIViewPart::drawCenterLines(bool b)
|
||||
{
|
||||
TechDraw::DrawViewPart *viewPart = dynamic_cast<TechDraw::DrawViewPart *>(getViewObject());
|
||||
|
||||
@@ -107,7 +107,7 @@ protected:
|
||||
bool prefPrintCenters(void);
|
||||
|
||||
bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(int sourceIndex, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(std::string cTag, QGIEdge* item);
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> deleteItems;
|
||||
|
||||
@@ -91,8 +91,8 @@ TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
|
||||
m_geomIndex = DrawUtil::getIndexFromName(m_edgeName);
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = partFeat->getEdgeGeometry();
|
||||
BaseGeom* bg = geoms.at(m_geomIndex);
|
||||
m_clIdx = bg->sourceIndex();
|
||||
m_cl = partFeat->getCenterLineByIndex(m_clIdx);
|
||||
std::string tag = bg->getCosmeticTag();
|
||||
m_cl = partFeat->getCenterLine(tag);
|
||||
if (m_cl == nullptr) { //checked by CommandAnnotate. Should never happen.
|
||||
Base::Console().Message("TCL::TCL() - no centerline found\n");
|
||||
}
|
||||
@@ -291,7 +291,8 @@ void TaskCenterLine::updateCenterLine(void)
|
||||
m_cl->m_extendBy = ui->qsbExtend->rawValue();
|
||||
m_cl->m_type = m_type;
|
||||
m_cl->m_flip2Line = m_flipped;
|
||||
m_partFeat->replaceCenterLine(m_clIdx, m_cl);
|
||||
m_partFeat->replaceCenterLine(m_cl);
|
||||
m_partFeat->refreshCLGeoms();
|
||||
m_partFeat->requestPaint();
|
||||
|
||||
Gui::Command::updateActive();
|
||||
|
||||
@@ -125,7 +125,8 @@ void TaskLineDecor::getDefaults(void)
|
||||
m_weight = ce->m_format.m_weight;
|
||||
m_visible = ce->m_format.m_visible;
|
||||
} else if (bg->source() == 2) {
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
|
||||
// TechDraw::CenterLine* cl = m_partFeat->getCenterLine(bg->getCosmeticTag);
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineBySelection(m_edges.front());
|
||||
m_style = cl->m_format.m_style;
|
||||
m_color = cl->m_format.m_color;
|
||||
m_weight = cl->m_format.m_weight;
|
||||
@@ -192,7 +193,8 @@ void TaskLineDecor::applyDecorations(void)
|
||||
ce->m_format.m_weight = m_weight;
|
||||
ce->m_format.m_visible = m_visible;
|
||||
} else if (bg->source() == 2) {
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
|
||||
// TechDraw::CenterLine* cl = m_partFeat->getCenterLine(bg->getCosmeticTag());
|
||||
TechDraw::CenterLine* cl = m_partFeat->getCenterLineBySelection(e);
|
||||
cl->m_format.m_style = m_style;
|
||||
cl->m_format.m_color = m_color;
|
||||
cl->m_format.m_weight = m_weight;
|
||||
|
||||
Reference in New Issue
Block a user