Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Move: after picking a body, go on to From, Point or Axis (#6170) (#6171)

Frank65366ba13179
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index c9c1a5312e..97d7903420 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -1472,6 +1472,17 @@ impl Dialog {
if !inp.multi && !inp.items.is_empty() && self.active + 1 < self.inputs.len() {
self.advance();
}
+ // Move by points or about an axis: once a body is in, go on to the empty From, Point or
+ // Axis (#6170), so the next click picks it instead of another body. Free Move's Pivot is
+ // optional and stays unvisited.
+ if let Kind::Move { mode: crate::dialogs_move::ROTATE | crate::dialogs_move::POINT_TO_POINT | crate::dialogs_move::POINT_TO_POSITION, .. } =
+ self.kind
+ && self.active == 0
+ && self.inputs.first().is_some_and(|i| !i.items.is_empty())
+ && self.inputs.get(1).is_some_and(|i| i.items.is_empty())
+ {
+ self.active = 1;
+ }
self.error = None;
self.sync_thread(s);
}
diff --git a/crates/ui-egui/src/dialogs_move_tests.rs b/crates/ui-egui/src/dialogs_move_tests.rs
index 042bb76217..5dcd45b138 100644
--- a/crates/ui-egui/src/dialogs_move_tests.rs
+++ b/crates/ui-egui/src/dialogs_move_tests.rs
@@ -373,3 +373,44 @@ fn inch_move_lengths_agree_in_the_triad_and_every_numeric_move_route() {
}
}
}
+
+/// After a body is picked, Point to Point, Point to Position and Rotate go on to their empty
+/// From, Point or Axis, so the next click picks that instead of another body (#6170). Free
+/// Move stays on Bodies: its Pivot is optional.
+#[test]
+fn a_body_pick_goes_on_to_the_point_or_axis() {
+ for (mode, next) in [(POINT_TO_POINT, Some(1)), (POINT_TO_POSITION, Some(1)), (ROTATE, Some(1)), (FREE, None)] {
+ let mut h = crate::scenario::Harness::new();
+ h.app.home.open = false;
+ h.app.run("solid.box", json!({"length": 60, "width": 40, "height": 10})).unwrap();
+ h.app.run("select.clear", json!({})).unwrap();
+ h.app.cam.distance = 160.0;
+ h.settle();
+ h.app.start("solid.move");
+ let d = h.app.dialog.as_mut().unwrap();
+ d.kind = kind(mode, &h.app.session.doc);
+ d.inputs = inputs(mode);
+ d.active = 0;
+ h.step(&json!({ "click": { "world": [30, 20, 10] } })).unwrap();
+ let d = h.app.dialog.as_ref().unwrap();
+ assert_eq!(d.inputs[0].items, vec![Sel::Body { name: "Body1".into() }], "{}", TYPES[mode]);
+ assert_eq!(d.active, next.unwrap_or(0), "{} goes on after the body", TYPES[mode]);
+ }
+ // Point to Point: the click after the body is the From point, the body stays picked.
+ let mut h = crate::scenario::Harness::new();
+ h.app.home.open = false;
+ h.app.run("solid.box", json!({"length": 60, "width": 40, "height": 10})).unwrap();
+ h.app.run("select.clear", json!({})).unwrap();
+ h.app.cam.distance = 160.0;
+ h.settle();
+ h.app.start("solid.move");
+ let d = h.app.dialog.as_mut().unwrap();
+ d.kind = kind(POINT_TO_POINT, &h.app.session.doc);
+ d.inputs = inputs(POINT_TO_POINT);
+ d.active = 0;
+ h.step(&json!({ "click": { "world": [30, 30, 10] } })).unwrap();
+ h.step(&json!({ "click": { "world": [60, 0, 10] } })).unwrap();
+ let d = h.app.dialog.as_ref().unwrap();
+ assert_eq!(d.inputs[0].items.len(), 1, "the body is still picked");
+ assert!(matches!(d.inputs[1].items.as_slice(), [Sel::Vertex { .. }]), "{:?}", d.inputs[1].items);
+}