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.
This commit is contained in:
tetektoza
2025-10-28 23:50:11 +01:00
committed by Kacper Donat
parent 97ca7d9818
commit e2a141785f

View File

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