[TD]Py functions for CenterLines and formatting
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <App/Material.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "CosmeticEdgePy.h"
|
||||
#include "CosmeticEdgePy.cpp"
|
||||
@@ -52,13 +55,13 @@ int CosmeticEdgePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//From Part::GeometryPy.cpp
|
||||
PyObject* CosmeticEdgePy::clone(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
|
||||
geom->dump("CEPYI::clone");
|
||||
PyTypeObject* type = this->GetType();
|
||||
PyObject* cpy = 0;
|
||||
// let the type object decide
|
||||
@@ -86,7 +89,6 @@ PyObject* CosmeticEdgePy::copy(PyObject *args)
|
||||
return NULL;
|
||||
|
||||
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
|
||||
geom->dump("CEPYI::copy");
|
||||
PyTypeObject* type = this->GetType();
|
||||
PyObject* cpy = 0;
|
||||
// let the type object decide
|
||||
@@ -108,6 +110,66 @@ PyObject* CosmeticEdgePy::copy(PyObject *args)
|
||||
return cpy;
|
||||
}
|
||||
|
||||
PyObject* CosmeticEdgePy::setFormat(PyObject* args)
|
||||
{
|
||||
// Base::Console().Message("CEP::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::CosmeticEdge* ce = this->getCosmeticEdgePtr();
|
||||
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);
|
||||
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
ce->m_format.m_color = c;
|
||||
ce->m_format.m_visible = visible;
|
||||
}
|
||||
} else {
|
||||
Base::Console().Error("CEPI::setFormat - not a tuple!\n");
|
||||
}
|
||||
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* CosmeticEdgePy::getFormat(PyObject *args)
|
||||
{
|
||||
(void) args;
|
||||
// Base::Console().Message("CEP::getFormat()\n");
|
||||
TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr();
|
||||
|
||||
PyObject* pStyle = PyLong_FromLong((long) ce->m_format.m_style);
|
||||
PyObject* pWeight = PyFloat_FromDouble(ce->m_format.m_weight);
|
||||
PyObject* pColor = DrawUtil::colorToPyTuple(ce->m_format.m_color);
|
||||
PyObject* pVisible = PyBool_FromLong((long) ce->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;
|
||||
}
|
||||
|
||||
|
||||
PyObject *CosmeticEdgePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
@@ -117,3 +179,4 @@ int CosmeticEdgePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user