[TD]Getters/Setters for CosmeticVertex attribs
This commit is contained in:
@@ -43,6 +43,23 @@
|
||||
</Documentation>
|
||||
<Parameter Name="Show" Type="Boolean"/>
|
||||
</Attribute>
|
||||
|
||||
<Attribute Name="Color" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>set/return the vertex's colour using a tuple (rgba).</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Color" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Size" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>set/return the vertex's radius in mm.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Size" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Style" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>set/return the vertex's style as integer.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Style" Type="Object"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -168,6 +168,71 @@ void CosmeticVertexPy::setShow(Py::Boolean arg)
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CosmeticVertexPy::getColor(void) const
|
||||
{
|
||||
App::Color color = getCosmeticVertexPtr()->color;
|
||||
PyObject* pyColor = DrawUtil::colorToPyTuple(color);
|
||||
return Py::asObject(pyColor);
|
||||
}
|
||||
|
||||
void CosmeticVertexPy::setColor(Py::Object arg)
|
||||
{
|
||||
PyObject* pTuple = arg.ptr();
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, green, blue, alpha);
|
||||
if (PyTuple_Check(pTuple)) {
|
||||
c = DrawUtil::pyTupleToColor(pTuple);
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
cv->color = c;
|
||||
} else {
|
||||
Base::Console().Error("CEPI::setColor - not a tuple!\n");
|
||||
std::string error = std::string("type must be 'tuple', not ");
|
||||
error += pTuple->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object CosmeticVertexPy::getSize(void) const
|
||||
{
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
double size = cv->size;
|
||||
PyObject* pSize = PyFloat_FromDouble(size);
|
||||
return Py::asObject(pSize);
|
||||
}
|
||||
|
||||
void CosmeticVertexPy::setSize(Py::Object arg)
|
||||
{
|
||||
double size = 1.0;
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyFloat_Check(p)) {
|
||||
size = PyFloat_AsDouble(p);
|
||||
} else {
|
||||
throw Py::TypeError("expected (float)");
|
||||
}
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
cv->size = size;
|
||||
}
|
||||
|
||||
Py::Object CosmeticVertexPy::getStyle(void) const
|
||||
{
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
double style = cv->style;
|
||||
PyObject* pStyle = PyLong_FromLong((long) style);
|
||||
return Py::asObject(pStyle);
|
||||
}
|
||||
|
||||
void CosmeticVertexPy::setStyle(Py::Object arg)
|
||||
{
|
||||
int style = 1;
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyLong_Check(p)) {
|
||||
style = (int) PyLong_AsLong(p);
|
||||
} else {
|
||||
throw Py::TypeError("expected (float)");
|
||||
}
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
cv->style = style;
|
||||
}
|
||||
|
||||
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user