forked from 1b-agent/opencadstudio-upstream
fix(dyn): an explicit minus keeps its sign in the angle field
The dynamic-input angle field stripped the typed sign and re-signed the value from the cursor's side of the X axis, so a negative angle could not be entered at all — 330 had to stand in for -30 (#417). An explicit -/+ prefix is now taken literally; unsigned entries keep the cursor-side behaviour. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
1c8d6e1978
commit
a7fd9ecb45
1 file changed
+11
-5
@@ -274,14 +274,20 @@ impl OpenCADStudio {
|
||||
let live_a = dy.atan2(dx); // radians, in the UCS plane
|
||||
// A typed angle is shown unsigned (0..180); give it the sign of the
|
||||
// cursor's current side so an entry made below the X axis sweeps
|
||||
// downward to match the arc instead of mirroring up. Untyped → live.
|
||||
// downward to match the arc instead of mirroring up. An EXPLICIT
|
||||
// `-`/`+` prefix keeps its literal sign though — "-30" must mean
|
||||
// −30° (= 330°) regardless of where the cursor sits (#417).
|
||||
// Untyped → live.
|
||||
let angle_rad = |idx: usize| -> f64 {
|
||||
match fields[idx]
|
||||
let raw = fields[idx]
|
||||
.buffer
|
||||
.as_ref()
|
||||
.map(|s| s.trim().replace(',', "."))
|
||||
.and_then(|s| crate::app::expr_eval::eval_number(&s))
|
||||
{
|
||||
.map(|s| s.trim().replace(',', "."));
|
||||
let explicit_sign = raw
|
||||
.as_deref()
|
||||
.is_some_and(|s| s.starts_with('-') || s.starts_with('+'));
|
||||
match raw.and_then(|s| crate::app::expr_eval::eval_number(&s)) {
|
||||
Some(v) if explicit_sign => v.to_radians(),
|
||||
Some(mag) => mag.abs().to_radians().copysign(dy),
|
||||
None => live_a,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user