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
This commit is contained in:
tetektoza
2025-08-25 18:10:17 +02:00
committed by GitHub
parent ac02b86521
commit fb2307362d
3 changed files with 9 additions and 2 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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: