[TD]expose DVP projectPoint to Python

This commit is contained in:
wandererfan
2022-10-19 14:39:21 -04:00
committed by WandererFan
parent 774341fd90
commit e9d988d43c
2 changed files with 23 additions and 1 deletions

View File

@@ -148,7 +148,15 @@
<UserDocu>getVertexBySelection(vertexName). Returns Part.TopoShape.</UserDocu>
</Documentation>
</Methode>
<Methode Name="requestPaint">
<Methode Name="projectPoint">
<Documentation>
<UserDocu>projectPoint(vector3d point, [bool invert]). Returns the projection of point in the
projection coordinate system of this DrawViewPart. Optionally inverts the Y coordinate of the
result.</UserDocu>
</Documentation>
</Methode>
<Methode Name="requestPaint">
<Documentation>
<UserDocu>requestPaint(). Redraw the graphic for this View.</UserDocu>
</Documentation>

View File

@@ -709,6 +709,20 @@ PyObject* DrawViewPartPy::getVertexBySelection(PyObject *args)
return new Part::TopoShapeVertexPy(new Part::TopoShape(outVertex));
}
PyObject* DrawViewPartPy::projectPoint(PyObject *args)
{
PyObject* pPoint = nullptr;
PyObject* pInvert = Py_False;
if (!PyArg_ParseTuple(args, "O!|O!", &(Base::VectorPy::Type), &pPoint, &PyBool_Type, &pInvert)) {
throw Py::TypeError("expected (vector)");
}
bool invert = Base::asBoolean(pInvert);
DrawViewPart* dvp = getDrawViewPartPtr();
Base::Vector3d projection = dvp->projectPoint(static_cast<Base::VectorPy*>(pPoint)->value(), invert);
return new Base::VectorPy(new Base::Vector3d(projection));
}
//==============================================================================
PyObject *DrawViewPartPy::getCustomAttributes(const char* /*attr*/) const