Sketch: an arc centred on an existing point shows its Coincident glyph (Refs #7299) (#7346)

* Claim: centre arc on an existing point shows its Coincident glyph (Refs #7299)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Sketch: an arc centred on an existing point shows its Coincident glyph (Refs #7299)

The Centre arc tool sent a centre snapped to an existing point as that point's id, so
the arc shared it with no constraint and the sketch drew no glyph. A plain point snap
now goes as its place, where draw's connect ties the new centre with a Coincident;
midpoint, on-curve, crossing and body-vertex snaps still go as refs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Phanoob <phanoob@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
phanoob
2026-10-27 12:38:15 +00:00
committed by GitHub
parent fb7ca86dc7
commit fac811565b
2 changed files with 48 additions and 4 deletions
@@ -712,6 +712,41 @@ fn centre_circle_clicked_through_a_line_end_stays_on_it() {
);
}
/// #7299: the centre arc tool, its centre snapped to a rectangle's corner, ties the arc to the
/// corner with a Coincident (which the sketch shows as a glyph), not by quietly sharing the corner
/// as its centre.
#[test]
fn centre_arc_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.arc.center_point"})).unwrap();
for at in [[40, 30, 0], [34, 30, 0], [40, 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::Arc { c, .. } => Some(c),
_ => None,
});
let centre = centre.unwrap_or_else(|| panic!("an arc is drawn: {:?}", h.app.status));
assert_ne!(centre, corner, "the arc 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);
}
/// #4691: the Point tool clicked on a line's midpoint makes a point held there (a MidPoint
/// constraint), not a free point that happens to sit on the middle.
#[test]
+13 -4
View File
@@ -534,10 +534,19 @@ fn run_shape(app: &mut SolveApp, t: &Tool) -> Result<Vec<String>, String> {
"sketch.circle.two_point" => json!({"p0": xy(&p[0]), "p1": xy(&p[1])}),
"sketch.circle.three_point" => json!({"p0": xy(&p[0]), "p1": xy(&p[1]), "p2": xy(&p[2])}),
"sketch.arc.three_point" => json!({"start": arg(&p[0]), "end": arg(&p[1]), "through": arg(&p[2])}),
"sketch.arc.center_point" => match crate::sketch_dims::locked_value(app, t, "Sweep") {
Some(sweep) => json!({"center": arg(&p[0]), "start": arg(&p[1]), "sweep": sweep.to_degrees()}),
None => json!({"center": arg(&p[0]), "start": arg(&p[1]), "end": xy(&p[2])}),
},
"sketch.arc.center_point" => {
// 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.
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]),
};
match crate::sketch_dims::locked_value(app, t, "Sweep") {
Some(sweep) => json!({"center": center, "start": arg(&p[1]), "sweep": sweep.to_degrees()}),
None => json!({"center": center, "start": arg(&p[1]), "end": xy(&p[2])}),
}
}
"sketch.polygon.inscribed" | "sketch.polygon.circumscribed" => {
let a = (p[1].0 - p[0].0).angle().to_degrees();
json!({"center": xy(&p[0]), "radius": d(0, 1), "sides": sides, "angle": a})