SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
History: the sketch at the marker is shown while it's the current step (#5202) (#5204)
raykholoab889a8fff29
diff --git a/crates/engine/src/view.rs b/crates/engine/src/view.rsindex 895dca6dd8..b8a8a53e87 100644--- a/crates/engine/src/view.rs+++ b/crates/engine/src/view.rs@@ -638,15 +638,27 @@ impl SectionIndex {}}-/// Is a sketch drawn? The sketch being edited always is; otherwise not when hidden, nor in a-/// hidden component, Sketches folder or group (even one shown on its own), and one used by a-/// feature only when shown on its own.+/// Is a sketch drawn? The sketch being edited always is; otherwise not in a hidden component,+/// Sketches folder or group (even one shown on its own). The sketch immediately before a+/// rollback marker is shown regardless of its individual visibility; other hidden sketches, and+/// ones used by a feature unless shown on their own, retain their stored visibility.pub fn sketch_shown(s: &Session, id: u64) -> bool {let v = &s.visibility;if s.active_sketch == Some(id) {return true;}- if v.hidden_sketches.contains(&id) || !sketch_component_visible(s, id) || s.feature_folder_hidden(id, "sketches") {+ if !sketch_component_visible(s, id) || s.feature_folder_hidden(id, "sketches") {+ return false;+ }+ if s.doc+ .marker+ .and_then(|position| position.checked_sub(1))+ .and_then(|index| s.doc.features.get(index))+ .is_some_and(|f| f.id == id && matches!(f.kind, solidcraft_doc::FeatureKind::Sketch { .. }))+ {+ return true;+ }+ if v.hidden_sketches.contains(&id) {return false;}v.shown_sketches.contains(&id) || !sketch_consumed(s, id)diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex ee86718747..2ccfce42ca 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -5399,6 +5399,36 @@ mod tests {}}+ #[test]+ fn history_marker_shows_only_its_sketch_without_changing_visibility() -> Result<(), Box<dyn std::error::Error>> {+ for explicitly_hidden in [false, true] {+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());+ app.ui.show_grid = false;+ let mut sketches = Vec::new();+ for (name, x) in [("First", 0), ("Second", 30)] {+ app.run("sketch.create", json!({"plane":"XY","name":name}))?;+ app.run("sketch.rectangle.two_point", json!({"p0":[x,0],"p1":[x+10,10]}))?;+ app.run("sketch.finish", json!({}))?;+ let id = app.session.doc.find_feature(name).ok_or("missing sketch")?.id;+ sketches.push(id);+ app.run("solid.extrude", json!({"sketch":name,"distance":5,"body_name":name}))?;+ }+ if explicitly_hidden {+ app.session.visibility.hidden_sketches.clone_from(&sketches);+ }+ let stored = app.session.visibility.clone();+ let rect = Rect::from_min_size(Pos2::ZERO, vec2(640., 480.));+ for (position, expected) in [(0, None), (1, sketches.first().copied()), (2, None), (3, sketches.get(1).copied()), (4, None)] {+ app.run("timeline.roll_to", json!({"position":position}))?;+ assert_eq!(visible_sketches(&app), expected.into_iter().collect::<Vec<_>>(), "position {position}, hidden {explicitly_hidden}");+ let scene = build_sketch_scene(&app, &projection(&app, rect)).merged();+ assert_eq!(!scene.lines.is_empty(), expected.is_some(), "sketch lines at position {position}");+ assert_eq!(app.session.visibility, stored, "stepping must preserve stored visibility");+ }+ }+ Ok(())+ }+#[test]fn timeline_modifier_highlight_follows_edits_and_rollback() {let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());