diff --git a/src/Mod/TechDraw/App/DrawDimHelper.cpp b/src/Mod/TechDraw/App/DrawDimHelper.cpp index 45470aa991..250c069971 100644 --- a/src/Mod/TechDraw/App/DrawDimHelper.cpp +++ b/src/Mod/TechDraw/App/DrawDimHelper.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -185,10 +187,14 @@ std::pair DrawDimHelper::minMax(DrawViewPart* dv selEdges = dvp->getEdgeGeometry(); //do the whole View } + Bnd_Box edgeBbx; + edgeBbx.SetGap(0.0); + std::vector selCurves; std::vector hTCurve2dList; for (auto& bg: selEdges) { TopoDS_Edge e = bg->occEdge; + BRepBndLib::Add(e, edgeBbx); double first = 0.0; double last = 0.0; Handle(Geom_Curve) hCurve = BRep_Tool::Curve(e, first, last); @@ -198,19 +204,18 @@ std::pair DrawDimHelper::minMax(DrawViewPart* dv } //can't use Bnd_Box2d here as BndLib_Add2dCurve::Add adds the poles of splines to the box. - //poles are not necessarily on the curve! 3d Bnd_Box does it properly. FC bbx3 is already calculated - //bbx3 is scaled?? -// double scale = dvp->getScale(); + //poles are not necessarily on the curve! 3d Bnd_Box does it properly. + //this has to be the bbx of the selected edges, not the dvp!!! + double minX, minY, minZ, maxX, maxY, maxZ; + edgeBbx.Get(minX, minY, minZ, maxX, maxY, maxZ); + double xMid = (maxX + minX) / 2.0; + double yMid = (maxY + minY) / 2.0; - Base::BoundBox3d bbx3 = dvp->getBoundingBox(); + gp_Pnt2d rightMid(maxX, yMid); + gp_Pnt2d leftMid(minX, yMid); + gp_Pnt2d topMid(xMid, maxY); + gp_Pnt2d bottomMid(xMid, minY); - double xMid = (bbx3.MaxX + bbx3.MinX) / 2.0; - double yMid = (bbx3.MaxY + bbx3.MinY) / 2.0; - - gp_Pnt2d rightMid(bbx3.MaxX, yMid); - gp_Pnt2d leftMid(bbx3.MinX, yMid); - gp_Pnt2d topMid(xMid, bbx3.MaxY); - gp_Pnt2d bottomMid(xMid, bbx3.MinY); gp_Dir2d xDir(1.0, 0.0); gp_Dir2d yDir(0.0, 1.0);