Skip to content

Commit

Permalink
[TD]Add getEdges Py functions
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Nov 12, 2019
1 parent c021ff7 commit 0c99d32
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Mod/TechDraw/App/DrawViewPartPy.xml
Expand Up @@ -13,6 +13,16 @@
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>Feature for creating and manipulating Technical Drawing Part Views</UserDocu>
</Documentation>
<Methode Name="getVisibleEdges">
<Documentation>
<UserDocu>getVisibleEdges() - get the visible edges in the View as Part::TopoShapeEdges</UserDocu>
</Documentation>
</Methode>
<Methode Name="getHiddenEdges">
<Documentation>
<UserDocu>getHiddenEdges() - get the hidden edges in the View as Part::TopoShapeEdges</UserDocu>
</Documentation>
</Methode>
<Methode Name="makeCosmeticVertex">
<Documentation>
<UserDocu>makeCosmeticVertex(p1) - add a CosmeticVertex at p1 (View coordinates). Returns index of created vertex.</UserDocu>
Expand Down
38 changes: 35 additions & 3 deletions src/Mod/TechDraw/App/DrawViewPartPyImp.cpp
Expand Up @@ -70,6 +70,38 @@ std::string DrawViewPartPy::representation(void) const
}
//TODO: gets & sets for geometry

PyObject* DrawViewPartPy::getVisibleEdges(PyObject *args)
{
(void) args;
DrawViewPart* dvp = getDrawViewPartPtr();
PyObject* pEdgeList = PyList_New(0);
std::vector<TechDraw::BaseGeom*> geoms = dvp->getEdgeGeometry();
for (auto& g: geoms) {
if (g->hlrVisible) {
PyObject* pEdge = new Part::TopoShapeEdgePy(new Part::TopoShape(g->occEdge));
PyList_Append(pEdgeList, pEdge);
}
}

return pEdgeList;
}

PyObject* DrawViewPartPy::getHiddenEdges(PyObject *args)
{
(void) args;
DrawViewPart* dvp = getDrawViewPartPtr();
PyObject* pEdgeList = PyList_New(0);
std::vector<TechDraw::BaseGeom*> geoms = dvp->getEdgeGeometry();
for (auto& g: geoms) {
if (!g->hlrVisible) {
PyObject* pEdge = new Part::TopoShapeEdgePy(new Part::TopoShape(g->occEdge));
PyList_Append(pEdgeList, pEdge);
}
}

return pEdgeList;
}

PyObject* DrawViewPartPy::clearCosmeticVertices(PyObject *args)
{
(void) args;
Expand Down Expand Up @@ -238,7 +270,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
// right result, but ugly:
// Qt angles are cw, OCC angles are CCW
// Qt -y is up, OCC -y is down

TopoDS_Edge edge = aMakeEdge.Edge();
int idx = dvp->addCosmeticEdge(edge);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
Expand Down Expand Up @@ -314,7 +346,7 @@ PyObject* DrawViewPartPy::getCosmeticEdgeByGeom(PyObject *args)
throw Py::TypeError("expected (index)");
}
DrawViewPart* dvp = getDrawViewPartPtr();

TechDraw::BaseGeom* bg = dvp->getGeomByIndex(idx);
if (bg == nullptr) {
Base::Console().Error("DVPPI::getCEbyGeom - geom: %d not found\n",idx);
Expand Down Expand Up @@ -502,7 +534,7 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
visible);
TechDraw::GeomFormat* newGF = new TechDraw::GeomFormat(idx,
fmt);
// int idx =
// int idx =
dvp->addGeomFormat(newGF);
}
return Py_None;
Expand Down

0 comments on commit 0c99d32

Please sign in to comment.