From fb2307362dfe9a18fb9f51e992bb133c26f3bd77 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Mon, 25 Aug 2025 18:10:17 +0200 Subject: [PATCH] Sketcher: Set total angle to make evaluation choose it when typing in OVP (#23193) * Sketcher: Set total angle to make evaluation choose it when typing in OVP When typing an angle value (e.g., "315 deg") in the sketcher rotate tool, the result differed from manually moving the mouse to achieve the same rotation. The angle would "flip" to equivalent but opposite directions (315 deg became -45 deg) due to smart angle selection logic choosing the "closer" alternative. The parameter enforcement system (`doEnforceControlParameters`) calculated cursor positions for keyboard input but never directly set the `totalAngle` value. The mouse logic's smart angle selection algorithm then calculated totalAngle independently, potentially choosing equivalent but opposite angle directions (e.g., -45 deg instead of +315 deg) based on proximity to the previous angle value. Solution is to basically predefine `totalAngle` if user has typed it so this "smart logic" will always choose the `totalAngle` that user typed. * Sketcher: Set total angle for arc tool * Sketcher: Set total angle for Arc Slot tool --- src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h | 3 +++ src/Mod/Sketcher/Gui/DrawSketchHandlerArcSlot.h | 2 ++ src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h index 7fcb1efbf2..6faec669ec 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h @@ -627,6 +627,9 @@ void DSHArcControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchPo unsetOnViewParameter(fifthParam.get()); return; } + + handler->arcAngle = arcAngle; + double angle = handler->startAngle + arcAngle; onSketchPos.x = handler->centerPoint.x + cos(angle) * handler->radius; onSketchPos.y = handler->centerPoint.y + sin(angle) * handler->radius; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcSlot.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcSlot.h index c683b40db9..4cb5ff8bf2 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcSlot.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcSlot.h @@ -677,6 +677,8 @@ void DSHArcSlotControllerBase::doEnforceControlParameters(Base::Vector2d& onSket unsetOnViewParameter(fifthParam.get()); } else { + handler->arcAngle = arcAngle; + double length = (onSketchPos - handler->centerPoint).Length(); double angle = handler->startAngleBackup + arcAngle; onSketchPos.x = handler->centerPoint.x + cos(angle) * length; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h index 96feda0345..a9632f540b 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerRotate.h @@ -614,8 +614,10 @@ void DSHRotateControllerBase::doEnforceControlParameters(Base::Vector2d& onSketc return; } - onSketchPos.x = handler->centerPoint.x + cos((handler->startAngle + arcAngle)); - onSketchPos.y = handler->centerPoint.y + sin((handler->startAngle + arcAngle)); + handler->totalAngle = arcAngle; + + onSketchPos.x = handler->centerPoint.x + cos(handler->startAngle + arcAngle); + onSketchPos.y = handler->centerPoint.y + sin(handler->startAngle + arcAngle); } } break; default: