* claim: #6039 * Sketch: offer an arc length dimension for a selected arc (#6039) The arc length dimension already existed in the engine (sketch.dimension with type arc_length), but nothing in the UI led to it: the Dimension tool and the context menu always gave an arc its radius. With exactly one arc selected, the sketch context menu now offers Arc Length Dimension next to Sketch Dimension, which adds the dimension through the existing command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FN5eEMrqWWXqi65FcK8GXq * test: move the arc length menu test up to avoid a merge conflict Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: sascha2101 <221609842+sascha2101@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1122,6 +1122,12 @@ fn sketch_entity_items(app: &SolveApp) -> Vec<Item> {
|
||||
v.push(act("ui.paste", "Paste", "paste").key("Ctrl+V").on(app.session.sketch_clipboard.is_some()));
|
||||
v.push(act("ui.delete", "Delete", "delete").key("Del"));
|
||||
v.push(cmd(app, "sketch.dimension", "Sketch Dimension").with(json!({ "entities": ents })).on(ents.len() <= 2));
|
||||
// One arc alone: Sketch Dimension gives its radius, this its length along the curve (#6039).
|
||||
if let [arc] = ents.as_slice()
|
||||
&& ss.sketch.curve_index(arc).and_then(|i| ss.sketch.curves.get(i)).is_some_and(|c| matches!(c.kind, CurveKind::Arc { .. }))
|
||||
{
|
||||
v.push(cmd(app, "sketch.dimension", "Arc Length Dimension").with(json!({ "entities": [arc], "type": "arc_length" })));
|
||||
}
|
||||
let mut c = Vec::new();
|
||||
let n = ents.len();
|
||||
let (l, r, p) = (lines.len(), rounds.len(), points.len());
|
||||
|
||||
@@ -326,6 +326,36 @@ fn sketch_menu_hides_and_moves_to_another_plane() {
|
||||
assert_eq!(app.tree.redefine, Some(id));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_selected_arc_offers_an_arc_length_dimension() {
|
||||
// #6039: the arc length dimension existed as a command, but nothing in the UI led to it.
|
||||
let mut app = sample_app();
|
||||
app.run("sketch.create", json!({"plane": "XY"})).unwrap();
|
||||
app.run("sketch.arc.center_point", json!({"center": [0, 0], "start": [10, 0], "end": [0, 10]})).unwrap();
|
||||
app.run("sketch.circle.center", json!({"center": [40, 0], "radius": 5})).unwrap();
|
||||
let ids: Vec<String> = {
|
||||
let st = app.session.model.state();
|
||||
let ss = st.sketch(app.session.active_sketch.unwrap()).unwrap();
|
||||
ss.sketch.curves.iter().map(|c| c.id.clone()).collect()
|
||||
};
|
||||
let select = |app: &mut SolveApp, id: &str| app.run("select.set", json!({"items": [{"type": "sketch_curve", "id": id}]})).unwrap();
|
||||
select(&mut app, &ids[1]);
|
||||
assert!(!context_menu::items(&app, &Target::Viewport).iter().any(|i| i.label == "Arc Length Dimension"), "a circle has no arc length");
|
||||
select(&mut app, &ids[0]);
|
||||
let item = find(&context_menu::items(&app, &Target::Viewport), "Arc Length Dimension");
|
||||
assert!(item.enabled);
|
||||
context_menu::run_item(&mut app, &item, pos2(0.0, 0.0));
|
||||
let st = app.session.model.state();
|
||||
let ss = st.sketch(app.session.active_sketch.unwrap()).unwrap();
|
||||
let len = ss.sketch.constraints.iter().find_map(|c| match c.kind {
|
||||
solidcraft_engine::sketch::ConstraintKind::ArcLength { value, .. } => Some(value),
|
||||
_ => None,
|
||||
});
|
||||
// A quarter of a circle of radius 10.
|
||||
assert!(len.is_some_and(|l| (l - 5.0 * std::f64::consts::PI).abs() < 1e-5), "{:?}", ss.sketch.constraints);
|
||||
assert!(ss.report.ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sketch_entities_offer_the_constraints_that_fit() {
|
||||
let mut app = sample_app();
|
||||
|
||||
Reference in New Issue
Block a user