diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 49429e88c..9dd1e11b5 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -1035,6 +1035,7 @@ impl Dialog { | Kind::PatternCirc { .. } | Kind::Loft { .. } | Kind::Sweep { .. } + | Kind::AnglePlane { .. } | Kind::PathPlane { .. } | Kind::Midplane | Kind::Construct { .. } @@ -5413,6 +5414,29 @@ mod refused_ok_tests { } } + #[test] + fn selected_plane_axis_and_angle_build_a_preview() { + let app = SolveApp::new(Session::default(), Default::default()); + let mut dialog = Dialog::for_command(&app, "construct.plane.at_angle").expect("the command has a dialog"); + dialog.inputs[0].items = vec![Sel::Plane { name: "XY".into() }]; + dialog.inputs[1].items = vec![Sel::Axis { name: "X".into() }]; + if let Kind::AnglePlane { angle } = &mut dialog.kind { + *angle = "30 deg".into(); + } + + assert!(dialog.previews()); + let commands = preview_commands(&app, &dialog).expect("the selected inputs form a command"); + assert_eq!(commands.first().map(|(_, params)| params["angle"].as_str()), Some(Some("30 deg"))); + let preview = crate::preview::compute( + &app.session, + &commands, + crate::preview::Colors { body: [1; 4], added: [2; 4], new_body: [3; 4], removed: [4; 4], edge: [5; 4], ghost: false }, + ) + .expect("the angled plane previews"); + + assert!(!preview.scene.xray.is_empty(), "the preview contains the translucent construction plane"); + } + /// A box, and a hole dialog with a position picked on its top. fn hole_dialog() -> Harness { let mut h = Harness::new(); diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs index 4a603bb98..cbcb9b8d1 100644 --- a/crates/ui-egui/src/preselect_tests.rs +++ b/crates/ui-egui/src/preselect_tests.rs @@ -2155,6 +2155,27 @@ fn offset_plane_through_a_picked_vertex() { assert!(matches!(reopened.inputs[1].items.as_slice(), [Sel::Vertex { body, .. }] if body == "Box"), "{:?}", reopened.inputs[1].items); } +/// Plane at Angle draws the tilted plane while its dialog is open, when created and when edited, +/// and redraws it when the angle changes (it used to show only the picked plane and the label). +#[test] +fn plane_at_angle_previews_the_tilted_plane_when_edited() { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + let id = h.app.run("construct.plane.at_angle", json!({"base":"XY","axis":"Y","angle":"45 deg"})).unwrap()["feature"].as_u64().unwrap(); + h.app.edit_feature(id); + h.frames(2); + let d = h.app.dialog.as_ref().unwrap(); + assert!(matches!(d.kind, Kind::AnglePlane { .. }) && d.editing.is_some(), "{d:?}"); + assert!(d.previews(), "the edited plane is previewed"); + wait_feature_preview(&mut h); + let first = h.app.preview.key; + if let Kind::AnglePlane { angle } = &mut h.app.dialog.as_mut().unwrap().kind { + *angle = "30 deg".into(); + } + wait_feature_preview(&mut h); + assert_ne!(h.app.preview.key, first, "a new angle redraws the preview"); +} + /// #2474, #2494: every construct tool asks for what it needs. Started from the toolbar with /// nothing selected, none of them runs its command and reports that `a` (or `face`, `edge`…) /// is required; a construct command added later without a dialog fails here too.