From e2a141785fa9170e7d0a5a26d98e793a1833fbdf Mon Sep 17 00:00:00 2001 From: tetektoza Date: Tue, 28 Oct 2025 23:50:11 +0100 Subject: [PATCH] Sketcher: Remember cursor angle for Slot OVPs after OVP is set As the title says. Currently user is able to change geometry if OVP is set on labels. This is because `doEnforceControlParameters` reads mouse position every mouse move and calculates angle from it, resulting in a new angle every time mouse is moved. So, this patch basically reads the position before it was set, and once it is set, locks the position of the mouse and calculates angle from it which will be maintained until user cleans the OVP or makes a new primitive. --- src/Mod/Sketcher/Gui/DrawSketchHandlerSlot.h | 24 +++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSlot.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSlot.h index baf206eeec..de778a4cee 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSlot.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSlot.h @@ -74,6 +74,7 @@ public: , length(0.0) , angle(0.0) , firstCurve(0) + , capturedDirection(0.0, 0.0) {} ~DrawSketchHandlerSlot() override = default; @@ -339,6 +340,9 @@ private: Base::Vector2d startPoint, secondPoint; double radius, length, angle; int firstCurve; + + // Direction tracking to prevent OVP from flipping (issue #23459) + Base::Vector2d capturedDirection; }; template<> @@ -403,20 +407,28 @@ void DSHSlotControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchP } double length = dir.Length(); + if (fourthParam->isSet) { + const double angle = Base::toRadians(fourthParam->getValue()); + const Base::Vector2d ovpDir(cos(angle), sin(angle)); + handler->capturedDirection = ovpDir; + } + else { + handler->capturedDirection = dir.Normalize(); + } + if (thirdParam->isSet) { length = thirdParam->getValue(); if (length < Precision::Confusion() && thirdParam->hasFinishedEditing) { unsetOnViewParameter(thirdParam.get()); + handler->capturedDirection = Base::Vector2d(0.0, 0.0); return; } - onSketchPos = handler->startPoint + length * dir.Normalize(); + onSketchPos = handler->startPoint + length * handler->capturedDirection; } - - if (fourthParam->isSet) { - double angle = Base::toRadians(fourthParam->getValue()); - Base::Vector2d ovpDir(cos(angle), sin(angle)); - onSketchPos.ProjectToLine(onSketchPos - handler->startPoint, ovpDir); + else if (fourthParam->isSet) { + onSketchPos.ProjectToLine(onSketchPos - handler->startPoint, + handler->capturedDirection); onSketchPos += handler->startPoint; } } break;