SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Sketch: a circle centred on an existing point shows its Coincident glyph (#7299) (#7331)
phanoob75c8700724db
diff --git a/crates/ui-egui/src/sketch_corner_ui_tests.rs b/crates/ui-egui/src/sketch_corner_ui_tests.rsindex 1cdead5c12..1a17b4f950 100644--- a/crates/ui-egui/src/sketch_corner_ui_tests.rs+++ b/crates/ui-egui/src/sketch_corner_ui_tests.rs@@ -763,3 +763,38 @@ fn a_point_clicked_on_a_line_midpoint_is_held_there() {let held = sk.constraints.iter().any(|c| matches!(c.kind, solidcraft_engine::sketch::ConstraintKind::Midpoint { .. }));assert!(held, "no MidPoint constraint: {:?}", sk.constraints.iter().map(|c| &c.kind).collect::<Vec<_>>());}++/// #7299: the centre circle tool, its centre snapped to a rectangle's corner, ties the circle+/// to the corner with a Coincident (which the sketch shows as a glyph that can be picked and+/// deleted), not by quietly sharing the corner as its centre.+#[test]+fn centre_circle_on_an_existing_point_is_tied_by_a_coincident() {+ use solidcraft_engine::sketch::ConstraintKind;+ let mut h = crate::scenario::Harness::new();+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0":[10,10],"p1":[40,30]})).unwrap();+ h.step(&json!({"call":"ui.view","params":{"view":"fit"}})).unwrap();+ h.settle();+ let sid = h.app.session.active_sketch.unwrap();+ let sk = h.app.session.model.state().sketch(sid).unwrap().sketch.clone();+ let at_corner = |p: Option<_>| p.is_some_and(|p: Vec2| (p.x - 40.0).abs() < 1e-9 && (p.y - 30.0).abs() < 1e-9);+ let corner = (0..sk.points.len()).find(|&i| at_corner(sk.point(i))).unwrap();+ h.step(&json!({"start":"sketch.circle.center"})).unwrap();+ for at in [[40, 30, 0], [34, 24, 0]] {+ h.step(&json!({"move":{"world":at}})).unwrap();+ h.step(&json!({"click":{"world":at}})).unwrap();+ }+ let sk = h.app.session.model.state().sketch(sid).unwrap().sketch.clone();+ let centre = sk.curves.iter().find_map(|c| match c.kind {+ CurveKind::Circle { c, .. } => Some(c),+ _ => None,+ });+ let centre = centre.unwrap_or_else(|| panic!("a circle is drawn: {:?}", h.app.status));+ assert_ne!(centre, corner, "the circle has a centre of its own");+ assert!(at_corner(sk.point(centre)), "the centre is on the corner");+ let tied = sk+ .constraints+ .iter()+ .any(|k| matches!(k.kind, ConstraintKind::Coincident { p, q } if (p, q) == (corner, centre) || (p, q) == (centre, corner)));+ assert!(tied, "a Coincident ties the centre to the corner: {:?}", sk.constraints);+}diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rsindex 2e1bfcd193..33d67dea0a 100644--- a/crates/ui-egui/src/tools.rs+++ b/crates/ui-egui/src/tools.rs@@ -524,8 +524,15 @@ fn run_shape(app: &mut SolveApp, t: &Tool) -> Result<Vec<String>, String> {}"sketch.rectangle.three_point" => json!({"p0": xy(&p[0]), "p1": xy(&p[1]), "p2": xy(&p[2])}),"sketch.circle.center" => {- // A second click snapped to a point keeps the circle on that point (#3099).- let mut v = json!({"center": arg(&p[0]), "radius": d(0, 1)});+ // A centre snapped to an existing point goes as its place, where `connect` ties+ // them with a Coincident the sketch shows (#7299); a midpoint, on-curve, crossing or+ // body-vertex snap goes as itself, so the centre is held there. A second click+ // snapped to a point keeps the circle on that point (#3099).+ let center = match &p[0].1 {+ Some(id) if ["mid:", "on:", "vertex:", "x:"].iter().any(|k| id.starts_with(k)) => json!(id),+ _ => xy(&p[0]),+ };+ let mut v = json!({"center": center, "radius": d(0, 1)});if p[1].1.is_some() {v["through"] = arg(&p[1]);}