[TD]Cosmetic function overhaul (#14216)

* [TD]Cosmetic geometry and tools update

- all cosmetics to store geometry in same form
- all cosmetics to survive scaling and rotation
- extension functions to survive scaling and rotation

* [TD]overhaul leader point storage and editing

- add py routine makeLeader(points)

* [TD]add leader conversion utility

* [TD]Set Leader RotateWithView default to true

* [TD]fix intersection vertex position

* [TD]add CosmeticEdge::makeLineFromCanonicalPoints

* [TD]fix 2 Extension tools

- positioning in DrawCosmeticCircle
- mishandling of points in execLineParallelPerpendicular

* [TD]Remove duplicate constexpr

* [TD]fix 2x Cosmetic arc tools

* [TD]refactor LineFormat out of Cosmetic

* [TD]move cosmetic appearance settings to LineFormat

* [TD]remove 2 unused methods

* [TD]apply format to blue line & circle tools

* [TD]fix ballon arrowhead does not rotate with view

* [TD]fix CosmeticCircle3Points

* [TD]allow multiple cosmetic object deletions

* [TD]fix extend/shorten centerline
This commit is contained in:
WandererFan
2024-05-23 09:41:42 -04:00
committed by GitHub
parent a8d093280e
commit 50f970efd7
56 changed files with 1812 additions and 1076 deletions

View File

@@ -62,59 +62,59 @@ int CosmeticEdgePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
}
//From Part::GeometryPy.cpp
PyObject* CosmeticEdgePy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
// PyObject* CosmeticEdgePy::clone(PyObject *args)
// {
// if (!PyArg_ParseTuple(args, ""))
// return nullptr;
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_RuntimeError, "failed to create clone of CosmeticEdge");
return nullptr;
}
// TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
// PyTypeObject* type = this->GetType();
// PyObject* cpy = nullptr;
// // let the type object decide
// if (type->tp_new)
// cpy = type->tp_new(type, this, nullptr);
// if (!cpy) {
// PyErr_SetString(PyExc_RuntimeError, "failed to create clone of CosmeticEdge");
// return nullptr;
// }
TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticEdge* clone = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
// TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// // the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// // so delete it now to avoid a memory leak
// if (geompy->_pcTwinPointer) {
// TechDraw::CosmeticEdge* clone = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
// delete clone;
// }
// geompy->_pcTwinPointer = geom->clone();
// return cpy;
// }
PyObject* CosmeticEdgePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;
// PyObject* CosmeticEdgePy::copy(PyObject *args)
// {
// if (!PyArg_ParseTuple(args, ""))
// return nullptr;
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = nullptr;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, nullptr);
if (!cpy) {
PyErr_SetString(PyExc_RuntimeError, "failed to create copy of CosmeticEdge");
return nullptr;
}
// TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
// PyTypeObject* type = this->GetType();
// PyObject* cpy = nullptr;
// // let the type object decide
// if (type->tp_new)
// cpy = type->tp_new(type, this, nullptr);
// if (!cpy) {
// PyErr_SetString(PyExc_RuntimeError, "failed to create copy of CosmeticEdge");
// return nullptr;
// }
TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticEdge* copy = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
// TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// // the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// // so delete it now to avoid a memory leak
// if (geompy->_pcTwinPointer) {
// TechDraw::CosmeticEdge* copy = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
// delete copy;
// }
// geompy->_pcTwinPointer = ce->copy();
// return cpy;
// }
void CosmeticEdgePy::setFormat(Py::Dict arg)
{
@@ -131,10 +131,10 @@ void CosmeticEdgePy::setFormat(Py::Dict arg)
}
TechDraw::LineFormat* format = &(this->getCosmeticEdgePtr()->m_format);
format->m_style = style;
format->m_weight = weight;
format->m_color = DrawUtil::pyTupleToColor(pColor);
format->m_visible = Base::asBoolean(visible);
format->setStyle(style);
format->setWidth(weight);
format->setColor(DrawUtil::pyTupleToColor(pColor));
format->setVisible(Base::asBoolean(visible));
}
Py::Dict CosmeticEdgePy::getFormat() const
@@ -142,10 +142,10 @@ Py::Dict CosmeticEdgePy::getFormat() const
TechDraw::LineFormat* format= &(this->getCosmeticEdgePtr()->m_format);
Py::Dict dict;
dict.setItem("style", Py::Long(format->m_style));
dict.setItem("weight", Py::Float(format->m_weight));
dict.setItem("color", Py::Tuple(DrawUtil::colorToPyTuple(format->m_color), true));
dict.setItem("visible", Py::Boolean(format->m_visible));
dict.setItem("style", Py::Long(format->getStyle()));
dict.setItem("weight", Py::Float(format->getWidth()));
dict.setItem("color", Py::Tuple(DrawUtil::colorToPyTuple(format->getColor()), true));
dict.setItem("visible", Py::Boolean(format->getVisible()));
return dict;
}