From f2f7d22b8eb16eb7ceee58a8c73592543e243cac Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 27 Apr 2020 16:13:27 -0400 Subject: [PATCH] [TD]Coordinate inversion for CosmeticVertex --- src/Mod/TechDraw/App/DrawViewPartPyImp.cpp | 21 +++++++++++++++++++-- src/Mod/TechDraw/App/GeometryObject.cpp | 8 ++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp index 08e42ec5d7..a25f510514 100644 --- a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include "DrawViewPart.h" #include "GeometryObject.h" +#include "Geometry.h" #include "Cosmetic.h" #include "CosmeticExtension.h" #include "DrawUtil.h" @@ -677,8 +679,16 @@ PyObject* DrawViewPartPy::getEdgeByIndex(PyObject *args) throw Py::TypeError("expected (edgeIndex)"); } DrawViewPart* dvp = getDrawViewPartPtr(); + + //this is scaled and +Yup + //need unscaled and +Ydown TechDraw::BaseGeom* geom = dvp->getGeomByIndex(edgeIndex); - TopoDS_Edge outEdge = geom->occEdge; + + TopoDS_Shape temp = TechDraw::mirrorShapeVec(geom->occEdge, + Base::Vector3d(0.0, 0.0, 0.0), + 1.0 / dvp->getScale()); + + TopoDS_Edge outEdge = TopoDS::Edge(temp); return new Part::TopoShapeEdgePy(new Part::TopoShape(outEdge)); } @@ -689,8 +699,15 @@ PyObject* DrawViewPartPy::getVertexByIndex(PyObject *args) throw Py::TypeError("expected (vertIndex)"); } DrawViewPart* dvp = getDrawViewPartPtr(); + + //this is scaled and +Yup + //need unscaled and +Ydown TechDraw::Vertex* vert = dvp->getProjVertexByIndex(vertexIndex); - TopoDS_Vertex outVertex = vert->occVertex; + Base::Vector3d point = DrawUtil::invertY(vert->point()) / dvp->getScale(); + + gp_Pnt gPoint(point.x, point.y, point.z); + BRepBuilderAPI_MakeVertex mkVertex(gPoint); + TopoDS_Vertex outVertex = mkVertex.Vertex(); return new Part::TopoShapeVertexPy(new Part::TopoShape(outVertex)); } diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index be47510549..2180d9be7f 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -986,6 +986,14 @@ Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape, //!scales & mirrors a shape about a center +TopoDS_Shape TechDraw::mirrorShapeVec(const TopoDS_Shape &input, + const Base::Vector3d& inputCenter, + double scale) +{ + gp_Pnt gInput(inputCenter.x, inputCenter.y, inputCenter.z); + return TechDraw::mirrorShape(input, gInput, scale); +} + TopoDS_Shape TechDraw::mirrorShape(const TopoDS_Shape &input, const gp_Pnt& inputCenter, double scale)