From 48c5a413a3cac01f0a9c74854c089f347fc8e06c Mon Sep 17 00:00:00 2001 From: Paddle Date: Fri, 3 Nov 2023 18:27:19 +0100 Subject: [PATCH] Line DSH : syntax and remove potential issues. For example in width+length mode, if user input 0 and 0, instead of validating it will unset the spinboxes. Preventing creation of null lines. --- src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h index 7d004ca9a5..65a5e98891 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h @@ -336,20 +336,19 @@ void DSHLineControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchP else if (handler->constructionMethod() == ConstructionMethod::OnePointLengthAngle) { Base::Vector2d dir = onSketchPos - handler->startPoint; + if (dir.Length() < Precision::Confusion()) { + dir.x = 1.0; // if direction null, default to (1,0) + } double length = dir.Length(); if (onViewParameters[OnViewParameter::Third]->isSet) { length = onViewParameters[OnViewParameter::Third]->getValue(); if (length < Precision::Confusion()) { unsetOnViewParameter(onViewParameters[OnViewParameter::Third].get()); + return; } - else { - if (dir.Length() < Precision::Confusion()) { - dir.x = 1; // if direction cannot be determined, default to (1,0) - } - onSketchPos = handler->startPoint + length * dir.Normalize(); - } + onSketchPos = handler->startPoint + length * dir.Normalize(); } if (onViewParameters[OnViewParameter::Fourth]->isSet) { @@ -367,6 +366,13 @@ void DSHLineControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchP onSketchPos.y = onViewParameters[OnViewParameter::Fourth]->getValue(); } } + + if (onViewParameters[OnViewParameter::Third]->isSet + && onViewParameters[OnViewParameter::Fourth]->isSet + && (onSketchPos - handler->startPoint).Length() < Precision::Confusion()) { + unsetOnViewParameter(onViewParameters[OnViewParameter::Third].get()); + unsetOnViewParameter(onViewParameters[OnViewParameter::Fourth].get()); + } } break; default: break;