SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Sketch: the Sketch Grid box in the Sketch panel turns the sketch's grid off (#9147) (#9187)
austin62jakec9935007e8f9
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rsindex b97d075bed..db6aae908d 100644--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@ -434,7 +434,7 @@ pub(crate) fn view_scene(app: &SolveApp, guides: solidcraft_engine::view::Guides/// The grid and the origin's axes as the window shows them (the Grid and Origin switches).pub(crate) fn window_guides(app: &SolveApp) -> solidcraft_engine::view::Guides {solidcraft_engine::view::Guides {- grid: app.session.active_sketch.is_some() || (app.ui.show_grid && !crate::viewport::active_view(app).hide_grid),+ grid: (app.session.active_sketch.is_some() || app.ui.show_grid) && !crate::viewport::active_view(app).hide_grid,axes: app.origin_visible(),}}diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex 07d32f0233..a7735c7a8f 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -1672,12 +1672,14 @@ fn build_sketch_scene(app: &SolveApp, proj: &Proj) -> GpuScene {let st = crate::open_meshing::shown_world(app);let mut fill_budget = 131_072;let sketch_plane = solidcraft_engine::view::open_sketch_plane(s).or_else(|| previewed_sketch_plane(app));- if sketch_plane.is_some() || (app.ui.show_grid && !active_view(app).hide_grid) {+ // An open sketch has its grid whatever the Grid switch says, unless the sketch's own Sketch+ // Grid option (Sketch panel) is off (#9147); outside a sketch that option is never off.+ if (sketch_plane.is_some() || app.ui.show_grid) && !active_view(app).hide_grid {let (minor, major) = grid_step(app.cam.half_height());- // An open sketch always has its grid on its own plane, and so does the plane Create- // Sketch would take; otherwise the ground plane: XY with Z up, XZ with Y up (laid out in- // the camera's Z-up frame), or the upright origin plane facing the view when the ground- // is seen edge-on.+ // An open sketch has its grid on its own plane, and so does the plane Create Sketch+ // would take; otherwise the ground plane: XY with Z up, XZ with Y up (laid out in the+ // camera's Z-up frame), or the upright origin plane facing the view when the ground is+ // seen edge-on.let (c, u, v, slant, ext, far_reach, w3): (Vec3, Vec3, Vec3, f64, f64, f64, Box<dyn Fn(Vec3) -> [f32; 3]>) = if let Some(pl) = &sketch_plane {let (c, u, v) = solidcraft_engine::view::sketch_grid_frame(pl, app.cam.target, major);// How steeply the sketch's plane is seen: the grid reaches as far on it as the view@@ -11216,7 +11218,7 @@ mod grid_plane_tests {);}- /// An open sketch always has its grid, on its own plane, whatever the Grid switch and the+ /// An open sketch has its grid, on its own plane, whatever the Grid switch and the/// follow-the-view preference say; outside a sketch the switch decides.#[test]fn an_open_sketch_always_shows_a_grid_on_its_plane() {@@ -11239,6 +11241,29 @@ mod grid_plane_tests {assert!(!grid(&app).is_empty());}+ /// The Sketch panel's Sketch Grid box turns the open sketch's grid off, whatever the Grid+ /// switch says, in the window and in what renders and the control channel are told; on+ /// again, it is back, and outside the sketch the switch decides as before (#9147).+ #[test]+ fn the_sketch_grid_option_turns_the_open_sketchs_grid_off() {+ let rect = Rect::from_min_size(Pos2::ZERO, egui::vec2(800.0, 600.0));+ let grid = |app: &SolveApp| !build_sketch_scene(app, &projection(app, rect)).under.is_empty();+ for switch in [false, true] {+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());+ app.ui.show_grid = switch;+ app.run("sketch.create", json!({"plane": "XY"})).unwrap();+ assert!(grid(&app) && crate::control::window_guides(&app).grid, "switch {switch}: the sketch's grid shows");+ app.run("sketch.options", json!({"grid": false})).unwrap();+ assert!(!grid(&app), "switch {switch}: the option turned the grid off");+ assert!(!crate::control::window_guides(&app).grid, "switch {switch}");+ app.run("sketch.options", json!({"grid": true})).unwrap();+ assert!(grid(&app) && crate::control::window_guides(&app).grid, "switch {switch}: on again");+ app.run("sketch.options", json!({"grid": false})).unwrap();+ app.run("sketch.finish", json!({})).unwrap();+ assert_eq!(grid(&app), switch, "outside the sketch the switch decides");+ }+ }+#[test]fn imported_scene_projection_toggle_keeps_front_components_in_clip_range() {use solidcraft_engine::doc::{Document, FeatureKind, MeshData};