From 77c4da539bbda8577194420a11dfc670bd6adefd Mon Sep 17 00:00:00 2001 From: logari81 Date: Fri, 30 Nov 2012 22:29:06 +0100 Subject: [PATCH] Sketcher: reenable directional autoconstraints --- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index f80e77c39..efe28b6c9 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -157,27 +157,26 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested else if (preSelCrs == 2) // y axis GeoId = -2; - if (GeoId == Constraint::GeoUndef) - return suggestedConstraints.size(); + if (GeoId != Constraint::GeoUndef) { + // Currently only considers objects in current Sketcher + AutoConstraint constr; + constr.Type = Sketcher::None; + constr.GeoId = GeoId; + constr.PosId = PosId; + if (type == AutoConstraint::VERTEX && PosId != Sketcher::none) + constr.Type = Sketcher::Coincident; + else if (type == AutoConstraint::CURVE && PosId != Sketcher::none) + constr.Type = Sketcher::PointOnObject; + else if (type == AutoConstraint::VERTEX && PosId == Sketcher::none) + constr.Type = Sketcher::PointOnObject; + else if (type == AutoConstraint::CURVE && PosId == Sketcher::none) + constr.Type = Sketcher::Tangent; - // Currently only considers objects in current Sketcher - AutoConstraint constr; - constr.Type = Sketcher::None; - constr.GeoId = GeoId; - constr.PosId = PosId; - if (type == AutoConstraint::VERTEX && PosId != Sketcher::none) - constr.Type = Sketcher::Coincident; - else if (type == AutoConstraint::CURVE && PosId != Sketcher::none) - constr.Type = Sketcher::PointOnObject; - else if (type == AutoConstraint::VERTEX && PosId == Sketcher::none) - constr.Type = Sketcher::PointOnObject; - else if (type == AutoConstraint::CURVE && PosId == Sketcher::none) - constr.Type = Sketcher::Tangent; + if (constr.Type != Sketcher::None) + suggestedConstraints.push_back(constr); + } - if (constr.Type != Sketcher::None) - suggestedConstraints.push_back(constr); - - if (Dir.Length() < 1) + if (Dir.Length() < 1e-8) // Direction not set so return; return suggestedConstraints.size(); @@ -187,6 +186,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested const double angleDev = 2; const double angleDevRad = angleDev * M_PI / 180.; + AutoConstraint constr; constr.Type = Sketcher::None; constr.GeoId = Constraint::GeoUndef; constr.PosId = Sketcher::none;