forked from 1b-agent/opencadstudio-upstream
fix(rotate): apply a typed angle right after the centre (#159)
ROTATE's reference-point step prompts "or skip: type angle directly", but on_text_input only handled the later Angle step. So picking a centre and typing the angle did nothing, and the next Enter cancelled the command — the objects never rotated, which reads as the rotate "erasing" / losing them. Accept a typed angle at the reference-point step too, rotating directly about the centre (the reference point stays optional). Added an automation regression test that rotates a line 90° with centre + angle only. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
c599c2ba09
commit
1a78e6c7ff
2 files changed
+43
-15
No files matched your search
@@ -120,21 +120,26 @@ impl CadCommand for RotateCommand {
|
||||
}
|
||||
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
if let Step::Angle { center, .. } = &self.step {
|
||||
// The value already carries the correct sign (the dynamic-input
|
||||
// layer applies the cursor's side for a bare magnitude).
|
||||
let deg: f32 = text.trim().replace(',', ".").parse().ok()?;
|
||||
let center = *center;
|
||||
defaults::set_rotate_angle(deg);
|
||||
return Some(CmdResult::TransformSelected(
|
||||
self.handles.clone(),
|
||||
EntityTransform::Rotate {
|
||||
center,
|
||||
angle_rad: deg.to_radians(),
|
||||
},
|
||||
));
|
||||
}
|
||||
None
|
||||
// A typed angle rotates directly about the centre. Accept it at the
|
||||
// reference-point step too (the prompt offers "skip: type angle
|
||||
// directly") — otherwise typing the angle there did nothing and the
|
||||
// command cancelled on the next Enter, so the objects never rotated.
|
||||
let center = match &self.step {
|
||||
Step::RefPoint { center } => *center,
|
||||
Step::Angle { center, .. } => *center,
|
||||
Step::Center => return None,
|
||||
};
|
||||
// The value already carries the correct sign (the dynamic-input
|
||||
// layer applies the cursor's side for a bare magnitude).
|
||||
let deg: f32 = text.trim().replace(',', ".").parse().ok()?;
|
||||
defaults::set_rotate_angle(deg);
|
||||
Some(CmdResult::TransformSelected(
|
||||
self.handles.clone(),
|
||||
EntityTransform::Rotate {
|
||||
center,
|
||||
angle_rad: deg.to_radians(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
fn on_preview_wires(&mut self, pt: DVec3) -> Vec<WireModel> {
|
||||
|
||||
Reference in new issue
Block a user