From b4e65f64d048901a08664c82f0e04dd83ea69c2b Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 10 Jun 2017 22:13:17 +0200 Subject: [PATCH] horiz/vert redundant autoconstraint avoidance extended to Polyline tool --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index c44fe41b6d..cf44ecbb26 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -941,6 +941,8 @@ public: EditCurve[0] = onSketchPos; // this may be overwritten if previousCurve is found + virtualsugConstr1 = sugConstr1; // store original autoconstraints. + // here we check if there is a preselected point and // we set up a transition from the neighbouring segment. // (peviousCurve, previousPosId, dirVec, TransitionMode) @@ -1112,6 +1114,14 @@ public: } if (Mode == STATUS_Close) { + + if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints. + if (sugConstr1.size() > 0) + removeRedundantHorizontalVertical(sugConstr1,sugConstr2); + else + removeRedundantHorizontalVertical(virtualsugConstr1,sugConstr2); + } + if (sugConstr2.size() > 0) { // exclude any coincidence constraints std::vector sugConstr; @@ -1163,6 +1173,15 @@ public: createAutoConstraints(sugConstr1, getHighestCurveIndex(), Sketcher::start); sugConstr1.clear(); } + + if (SegmentMode == SEGMENT_MODE_Line) { // avoid redundant constraints. + if (sugConstr1.size() > 0) + removeRedundantHorizontalVertical(sugConstr1,sugConstr2); + else + removeRedundantHorizontalVertical(virtualsugConstr1,sugConstr2); + } + + virtualsugConstr1 = sugConstr2; // these are the initial constraints for the next iteration. if (sugConstr2.size() > 0) { createAutoConstraints(sugConstr2, getHighestCurveIndex(), Sketcher::end); @@ -1252,7 +1271,8 @@ protected: int previousCurve; Sketcher::PointPos firstPosId; Sketcher::PointPos previousPosId; - std::vector sugConstr1, sugConstr2; + // the latter stores those constraints that a first point would have been given in abscence of the transition mechanism + std::vector sugConstr1, sugConstr2, virtualsugConstr1; Base::Vector2d CenterPoint; Base::Vector3d dirVec;