From 31f64d3a3aefeb7c261b7b22603fc310646a5d70 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 18 Jun 2020 13:55:50 -0400 Subject: [PATCH] [TD]Fix jumping section view --- src/Mod/TechDraw/App/DrawViewSection.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 510f14909b88..8e2cdd4473f3 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -286,7 +286,6 @@ void DrawViewSection::replacePatIncluded(std::string newPatFile) App::DocumentObjectExecReturn *DrawViewSection::execute(void) { -// Base::Console().Message("DVS::execute() - %s/%s \n", getNameInDocument(), Label.getValue()); if (!keepUpdated()) { return App::DocumentObject::StdReturn; } @@ -420,23 +419,30 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) if (testBox.IsVoid()) { //prism & input don't intersect. rawShape is garbage, don't bother. Base::Console().Warning("DVS::execute - prism & input don't intersect - %s\n", Label.getValue()); return; + } // build display geometry as in DVP, with minor mods gp_Ax2 viewAxis; TopoDS_Shape centeredShape; try { - Base::Vector3d sectionOrigin = SectionOrigin.getValue(); + Base::Vector3d origin(0.0, 0.0, 0.0); + viewAxis = getProjectionCS(origin); + gp_Pnt inputCenter; + inputCenter = TechDraw::findCentroid(rawShape, + viewAxis); + Base::Vector3d centroid(inputCenter.X(), + inputCenter.Y(), + inputCenter.Z()); + centeredShape = TechDraw::moveShape(rawShape, - sectionOrigin * -1.0); + centroid * -1.0); m_cutShape = centeredShape; - m_saveCentroid = sectionOrigin; + m_saveCentroid = centroid; TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape, getScale()); - Base::Vector3d origin(0.0, 0.0, 0.0); - viewAxis = getProjectionCS(origin); if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { scaledShape = TechDraw::rotateShape(scaledShape, viewAxis, @@ -462,13 +468,9 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) //display geometry for cut shape is in geometryObject as in DVP // build section face geometry -// try { - //sectionFaces = build sectionFaces(rawShape); TopoDS_Compound faceIntersections = findSectionPlaneIntersections(rawShape); - - Base::Vector3d sectionOrigin = SectionOrigin.getValue(); TopoDS_Shape centeredShapeF = TechDraw::moveShape(faceIntersections, - sectionOrigin * -1.0); + m_saveCentroid * -1.0); TopoDS_Shape scaledSection = TechDraw::scaleShape(centeredShapeF, getScale());