SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Construction points and axes: Browser rows, and pickable in the view and dialogs (#4312) (#4320)
raykholoc8314687fc8f
diff --git a/crates/engine/src/cmd/delete.rs b/crates/engine/src/cmd/delete.rsindex fe6dac96f6..f471c67f71 100644--- a/crates/engine/src/cmd/delete.rs+++ b/crates/engine/src/cmd/delete.rs@@ -104,6 +104,10 @@ fn apply(s: &mut Session, p: &Value) -> Result<Value> {_ => skip("the origin axes can't be deleted".into()),},Sel::SketchMidpoint { .. } => skip("a midpoint belongs to its sketch edge".into()),+ Sel::ConstructionPoint { name } => match s.doc.find_feature(name) {+ Some(f) if matches!(f.kind, FeatureKind::ConstructionPoint { .. }) => features.push(f.id),+ _ => skip(format!("no construction point named \"{name}\"")),+ },Sel::Body { name } => bodies.push(name.clone()),Sel::Face { body, point, .. } => match faces.iter_mut().find(|(b, _)| b == body) {Some((_, ps)) => ps.push(*point),diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rsindex ed747e44e7..8f8e493441 100644--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@ -150,6 +150,10 @@ pub enum Sel {Plane {name: String,},+ /// A construction point, by feature name.+ ConstructionPoint {+ name: String,+ },/// An origin axis (X, Y, Z) or a construction axis (by feature name).Axis {name: String,diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex 6b7ce8900d..ef1e7f4fc2 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -664,8 +664,10 @@ enum Thing {Sketch(u64),/// An origin or construction plane, by name.Plane(String),- /// An origin axis.+ /// An origin or construction axis.Axis(String),+ /// A construction point.+ Point(String),}/// What the tree lights for the selection and the 3D view's pointer: each lit item's row (in@@ -704,6 +706,7 @@ impl Lit {}Sel::Plane { name } => Thing::Plane(name.clone()),Sel::Axis { name } => Thing::Axis(name.clone()),+ Sel::ConstructionPoint { name } => Thing::Point(name.clone()),Sel::Occurrence { .. } => continue,});}@@ -714,6 +717,7 @@ impl Lit {) => Some(Thing::Sketch(*sketch)),Some(Hit::Plane { name, .. }) => Some(Thing::Plane(name.clone())),Some(Hit::Axis { name }) => Some(Thing::Axis(name.clone())),+ Some(Hit::ConstructionPoint { name }) => Some(Thing::Point(name.clone())),None => None,};let doc = app.session.doc.clone();@@ -728,10 +732,20 @@ impl Lit {Thing::Sketch(id) => {components.extend(doc.features.iter().find(|f| f.id == *id && matches!(f.kind, FeatureKind::Sketch { .. })).map(|f| f.component))}- Thing::Plane(name) => components.extend(- doc.features.iter().find(|f| f.name == *name && matches!(f.kind, FeatureKind::ConstructionPlane { .. })).map(|f| f.component),+ Thing::Plane(name) | Thing::Axis(name) | Thing::Point(name) => components.extend(+ doc.features+ .iter()+ .find(|f| {+ f.name == *name+ && matches!(+ f.kind,+ FeatureKind::ConstructionPlane { .. }+ | FeatureKind::ConstructionAxis { .. }+ | FeatureKind::ConstructionPoint { .. }+ )+ })+ .map(|f| f.component),),- Thing::Axis(_) => {}}}Lit { selected, hovered, paths, components }@@ -1038,8 +1052,14 @@ fn model_feature_indices(app: &SolveApp, component: u64, sketches: bool) -> Vec<.iter().enumerate().filter_map(|(i, f)| {- let kind =- if sketches { matches!(f.kind, FeatureKind::Sketch { .. }) } else { matches!(f.kind, FeatureKind::ConstructionPlane { .. }) };+ let kind = if sketches {+ matches!(f.kind, FeatureKind::Sketch { .. })+ } else {+ matches!(+ f.kind,+ FeatureKind::ConstructionPlane { .. } | FeatureKind::ConstructionAxis { .. } | FeatureKind::ConstructionPoint { .. }+ )+ };(f.component == component && kind).then_some(i)}).collect(),@@ -1780,6 +1800,7 @@ fn pick_from_browser(app: &mut SolveApp, x: Sel) {let hit = match &x {Sel::Plane { name } => crate::viewport::Hit::Plane { name: name.clone(), point: solidcraft_engine::geom::Vec3::ZERO },Sel::Axis { name } => crate::viewport::Hit::Axis { name: name.clone() },+ Sel::ConstructionPoint { name } => crate::viewport::Hit::ConstructionPoint { name: name.clone() },// The origin point goes only into a dialog input that takes it.Sel::Vertex { body, point } if body.is_empty() && app.dialog.is_some() => crate::viewport::Hit::Vertex { body: String::new(), point: *point },_ => return,@@ -1864,18 +1885,24 @@ impl Entry {}fn plane(app: &SolveApp, f: &solidcraft_engine::doc::Feature) -> Self {+ let sel = construction_sel(f);+ let thing = match &sel {+ Sel::Axis { name } => Thing::Axis(name.clone()),+ Sel::ConstructionPoint { name } => Thing::Point(name.clone()),+ _ => Thing::Plane(f.name.clone()),+ };Self {key: f.id.to_string(),row_key: format!("p:{}", f.id),- thing: Thing::Plane(f.name.clone()),+ thing,patterns: None,label: f.name.clone(),icon: crate::timeline::icon_of(&f.kind),visible: !app.session.visibility.hidden_origin.contains(&f.name),- selected: app.session.selection.iter().any(|s| matches!(s, Sel::Plane { name } if name == &f.name)),+ selected: app.session.selection.contains(&sel),color: None,locked: false,- sel: Some(Sel::Plane { name: f.name.clone() }),+ sel: Some(sel),target: Some(Target::Plane { id: f.id }),bodies: Vec::new(),}@@ -1921,6 +1948,15 @@ fn entries(app: &SolveApp, comp: u64, folder: &str) -> Vec<Entry> {}}+fn construction_sel(f: &solidcraft_engine::doc::Feature) -> Sel {+ let name = f.name.clone();+ match f.kind {+ FeatureKind::ConstructionPoint { .. } => Sel::ConstructionPoint { name },+ FeatureKind::ConstructionAxis { .. } => Sel::Axis { name },+ _ => Sel::Plane { name },+ }+}+/// A folder's groups (with their items) and the items in no group, in browser order.fn arrange<'a>(doc: &'a solidcraft_engine::doc::Document,diff --git a/crates/ui-egui/src/browser_model.rs b/crates/ui-egui/src/browser_model.rsindex 9dbe6655e4..1def459676 100644--- a/crates/ui-egui/src/browser_model.rs+++ b/crates/ui-egui/src/browser_model.rs@@ -40,7 +40,7 @@ impl Model {}let index = match feature.kind {FeatureKind::Sketch { .. } => &mut sketches,- FeatureKind::ConstructionPlane { .. } => &mut planes,+ FeatureKind::ConstructionPlane { .. } | FeatureKind::ConstructionAxis { .. } | FeatureKind::ConstructionPoint { .. } => &mut planes,_ => continue,};index.entry(feature.component).or_default().push(i);diff --git a/crates/ui-egui/src/browser_model_tests.rs b/crates/ui-egui/src/browser_model_tests.rsindex 504ef7603b..e709855910 100644--- a/crates/ui-egui/src/browser_model_tests.rs+++ b/crates/ui-egui/src/browser_model_tests.rs@@ -163,3 +163,35 @@ fn bodies_folder_tells_surfaces_from_solids() {assert_eq!(icons[..2], [("Tube".to_string(), "surface"), ("Ring".to_string(), "body")]);assert_eq!(icons[2].1, "body", "the box is a solid");}++#[test]+fn construction_rows_include_points_and_axes() {+ let mut h = crate::scenario::Harness::new();+ h.app.run("construct.point.vertex", json!({"point":{"point":[20,15,10]},"name":"Point1"})).unwrap();+ h.app.run("construct.axis.two_points", json!({"a":{"point":[0,0,0]},"b":{"point":[0,0,30]},"name":"Axis1"})).unwrap();+ for cached in [false, true] {+ if cached {+ super::prepare_model(&mut h.app);+ }+ let rows = super::entries(&h.app, 0, "construction");+ assert_eq!(rows.iter().map(|r| r.label.as_str()).collect::<Vec<_>>(), ["Point1", "Axis1"]);+ for row in &rows {+ assert!(row.visible && row.sel.is_some() && row.target.is_some());+ }+ }+ let rows = super::entries(&h.app, 0, "construction");+ for row in &rows {+ super::pick_from_browser(&mut h.app, row.sel.clone().unwrap());+ assert!(super::entries(&h.app, 0, "construction").iter().find(|r| r.label == row.label).unwrap().selected);+ let items = crate::context_menu::items(&h.app, row.target.as_ref().unwrap());+ for id in ["ui.rename", "ui.delete", "ui.editFeature", "ui.originPart"] {+ assert!(items.iter().any(|i| i.id == id), "{} lacks {id}", row.label);+ }+ assert!(!items.iter().any(|i| i.id == "sketch.create"));+ }+ h.app.session.visibility.hidden_origin.push("Point1".into());+ assert!(!super::entries(&h.app, 0, "construction")[0].visible);+ h.app.run("selection.delete", json!({"items": rows.iter().map(|r| r.sel.clone().unwrap()).collect::<Vec<_>>()})).unwrap();+ super::prepare_model(&mut h.app);+ assert!(super::entries(&h.app, 0, "construction").is_empty());+}diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex 9e63fdddce..af00984137 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -32,7 +32,7 @@ pub enum Target {Sketch {id: u64,},- /// A construction plane (its feature id).+ /// Construction geometry (its feature id).Plane {id: u64,},@@ -675,22 +675,26 @@ fn sketch_items(app: &SolveApp, id: u64) -> Vec<Item> {]}-/// A construction plane's row in the browser: sketch on it, edit, delete, rename, show or hide.+/// Construction geometry's row: edit, delete, rename, show or hide; sketch on planes.fn plane_items(app: &SolveApp, id: u64) -> Vec<Item> {let Some(f) = app.session.doc.feature(id) else { return Vec::new() };let visible = !app.session.visibility.hidden_origin.contains(&f.name);- vec![- cmd(app, "sketch.create", "Create Sketch").with(json!({ "plane": f.name })),- Item::sep(),- act("ui.editFeature", "Edit Feature", "plane").with(json!({ "feature": id })),- Item::sep(),+ let mut items = Vec::new();+ if matches!(f.kind, solidcraft_engine::doc::FeatureKind::ConstructionPlane { .. }) {+ items.push(cmd(app, "sketch.create", "Create Sketch").with(json!({ "plane": f.name })));+ items.push(Item::sep());+ }+ items.push(act("ui.editFeature", "Edit Feature", crate::timeline::icon_of(&f.kind)).with(json!({ "feature": id })));+ items.push(Item::sep());+ items.extend([act("ui.delete", "Delete", "delete").key("Del").with(json!({ "items": [{"type": "feature", "id": id}] })),act("ui.rename", "Rename", "rename").with(json!({ "feature": id })),Item::sep(),act("ui.originPart", "Show/Hide", "eye").key("V").with(json!({ "keys": [f.name], "show": !visible })),Item::sep(),act("ui.findTimeline", "Find in Timeline", "rollback").with(json!({ "feature": id })),- ]+ ]);+ items}/// An origin plane's row in the browser: sketch on it, show or hide.@@ -1489,7 +1493,7 @@ pub fn toggle_visibility(app: &mut SolveApp) {.selection.iter().filter_map(|s| match s {- Sel::Plane { name } | Sel::Axis { name } => Some(name.clone()),+ Sel::Plane { name } | Sel::Axis { name } | Sel::ConstructionPoint { name } => Some(name.clone()),_ => None,}).collect();@@ -1527,7 +1531,7 @@ pub fn rename_selection(app: &mut SolveApp, at: Pos2) -> bool {Ok(p) => RenameWhat::Component(p.component),Err(_) => return false,},- ([Sel::Plane { name }], [], []) => match app.session.doc.find_feature(name) {+ ([Sel::Plane { name } | Sel::Axis { name } | Sel::ConstructionPoint { name }], [], []) => match app.session.doc.find_feature(name) {Some(f) => RenameWhat::Feature(f.id),None => return false,},diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex 44083c3b5a..08cf2dc985 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -610,6 +610,7 @@ fn fits(a: Accept, s: &Sel) -> bool {Sel::Body { .. } => a & BODIES != 0,Sel::Plane { .. } => a & PLANES != 0,Sel::Axis { .. } => a & AXES != 0,+ Sel::ConstructionPoint { .. } => a & selection::CONSTRUCTION_POINTS != 0,Sel::SketchCurve { .. } => a & (AXES | CURVES | selection::SKETCH_LINES) != 0,Sel::ExternalSketchCurve { .. } => a & selection::SKETCH_LINES != 0,Sel::Vertex { .. } => a & selection::VERTICES != 0,@@ -2055,7 +2056,7 @@ fn selection_label(s: &Session, item: &Sel) -> String {match item {Sel::SketchCurve { id, .. } => id.clone(),Sel::SketchPoint { id } => crate::sketch_modify_ui::point_id(s, item).unwrap_or(id).to_string(),- Sel::Plane { name } | Sel::Axis { name } | Sel::Body { name } => name.clone(),+ Sel::Plane { name } | Sel::Axis { name } | Sel::ConstructionPoint { name } | Sel::Body { name } => name.clone(),Sel::Face { body, index, .. } => format!("{body} · face {index}"),Sel::Edge { body, index, .. } => format!("{body} · edge {index}"),Sel::Feature { id } => s.doc.feature(*id).map(|f| f.name.clone()).unwrap_or_else(|| format!("Feature {id}")),@@ -4480,7 +4481,7 @@ fn emboss_face_sel(s: &Session, component: u64, face: &solidcraft_engine::doc::E/// Plane At Angle have dialogs of their own.fn construct_picks(id: &str) -> Option<(&'static str, &'static str, &'static [(&'static str, Accept, &'static str)])> {const PLANE: Accept = PLANES | PLANAR_FACES;- const POINT: Accept = selection::VERTICES | selection::POINTS;+ const POINT: Accept = selection::VERTICES | selection::POINTS | selection::CONSTRUCTION_POINTS;const LINE: Accept = EDGES | AXES;const CURVE: Accept = EDGES | CURVES;Some(match id {@@ -4534,6 +4535,7 @@ fn construct_ref(app: &SolveApp, sel: &Sel) -> Result<Value, String> {Sel::Vertex { point, .. } => json!({"vertex": pt(*point)}),Sel::Plane { name } => json!({"plane": name}),Sel::Axis { name } => json!({"axis": name}),+ Sel::ConstructionPoint { name } => json!({"construct_point": name}),// Picked across sketches as "<sketch id>:<point id>".Sel::SketchPoint { id } => match id.split_once(':').and_then(|(sk, p)| Some((sk.parse::<u64>().ok()?, p))) {Some((sketch, point)) => json!({"sketch": sketch, "point": point}),diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rsindex 697dd736c6..058903b32b 100644--- a/crates/ui-egui/src/preselect_tests.rs+++ b/crates/ui-egui/src/preselect_tests.rs@@ -2527,3 +2527,34 @@ fn a_pipe_cuts_from_its_window_and_keeps_the_cut_when_edited() {assert_eq!(edit, "timeline.redefine");assert_eq!(p["params"]["operation"], "cut", "{p}");}++#[test]+fn construction_points_fill_three_point_plane_dialog() {+ let mut h = crate::scenario::Harness::new();+ let points = [[20, 15, 10], [40, 15, 10], [20, 35, 10]];+ for (i, point) in points.iter().enumerate() {+ h.app.run("construct.point.vertex", json!({"point":{"point":point},"name":format!("Point{}", i+1)})).unwrap();+ }+ h.app.start("construct.plane.three_points");+ let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1000.0, 800.0));+ let proj = crate::viewport::projection(&h.app, rect);+ for point in points {+ let pos = proj.to_screen(Vec3::new(point[0] as f64, point[1] as f64, point[2] as f64)).unwrap();+ let hits = crate::viewport::pick(&h.app, &proj, pos);+ let mut d = h.app.dialog.take().unwrap();+ let sel = hits.iter().find_map(|hit| d.candidate(&h.app.session, hit)).expect("construction point accepted");+ d.pick(&h.app.session, sel);+ h.app.dialog = Some(d);+ }+ let commands = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();+ assert_eq!(commands[0].1["a"], json!({"construct_point":"Point1"}));+ assert_eq!(commands[0].1["b"], json!({"construct_point":"Point2"}));+ assert_eq!(commands[0].1["c"], json!({"construct_point":"Point3"}));+ for (cmd, params) in commands {+ h.app.run(&cmd, params).unwrap();+ }+ let planes = solidcraft_engine::view::construction_planes(&h.app.session);+ assert_eq!(planes.len(), 1);+ assert!((planes[0].2.origin.z - 10.0).abs() < 1e-9);+ assert!(planes[0].2.normal().dot(Vec3::Z).abs() > 1.0 - 1e-9);+}diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rsindex 5938b01d98..3824349707 100644--- a/crates/ui-egui/src/select_other.rs+++ b/crates/ui-egui/src/select_other.rs@@ -156,7 +156,7 @@ fn rank(s: &Sel, sketching: bool) -> (u8, u8) {Sel::SketchPoint { .. } | Sel::SketchMidpoint { .. } | Sel::ExternalSketchPoint { .. } => 0,Sel::SketchCurve { .. } | Sel::ExternalSketchCurve { .. } => 1,Sel::SketchConstraint { .. } => 2,- Sel::Vertex { .. } => 3,+ Sel::Vertex { .. } | Sel::ConstructionPoint { .. } => 3,Sel::Edge { .. } => 4,Sel::Face { .. } | Sel::Feature { .. } => 5,Sel::Body { .. } | Sel::Occurrence { .. } => 6,@@ -256,7 +256,7 @@ pub fn label(app: &SolveApp, sel: &Sel) -> String {Sel::Profile { sketch, index } => format!("Profile {} · {}", index + 1, sketch_name(app, *sketch)),Sel::Plane { name } if matches!(name.as_str(), "XY" | "XZ" | "YZ") => format!("{name} Plane"),Sel::Axis { name } if matches!(name.as_str(), "X" | "Y" | "Z") => format!("{name} Axis"),- Sel::Plane { name } | Sel::Axis { name } => name.clone(),+ Sel::Plane { name } | Sel::Axis { name } | Sel::ConstructionPoint { name } => name.clone(),}}@@ -274,7 +274,11 @@ fn icon(app: &SolveApp, sel: &Sel) -> &'static str {}};match sel {- Sel::SketchPoint { .. } | Sel::SketchMidpoint { .. } | Sel::ExternalSketchPoint { .. } | Sel::Vertex { .. } => "point",+ Sel::SketchPoint { .. }+ | Sel::SketchMidpoint { .. }+ | Sel::ExternalSketchPoint { .. }+ | Sel::Vertex { .. }+ | Sel::ConstructionPoint { .. } => "point",Sel::SketchCurve { id, .. } => curve(app.session.active_sketch, id),Sel::ExternalSketchCurve { sketch, id } => curve(Some(*sketch), id),Sel::SketchConstraint { .. } => "dimension",diff --git a/crates/ui-egui/src/selection.rs b/crates/ui-egui/src/selection.rsindex 51605526b3..5fd6a04ac3 100644--- a/crates/ui-egui/src/selection.rs+++ b/crates/ui-egui/src/selection.rs@@ -67,6 +67,8 @@ pub const ORIGIN: Accept = 4096;pub const SKETCH_LINES: Accept = 8192;/// Sketch points with an explicit source sketch; only for commands that consume external references.pub const EXTERNAL_POINTS: Accept = 16384;+/// Named construction points.+pub const CONSTRUCTION_POINTS: Accept = 32768;/// One selection input of a command dialog ("Profiles", "Edges", "Plane", ...).#[derive(Clone, Debug, PartialEq)]@@ -105,6 +107,7 @@ impl SelInput {Hit::Face { body, .. } if a & BODIES != 0 => Some(Sel::Body { name: body.clone() }),Hit::Plane { name, .. } if a & PLANES != 0 => Some(Sel::Plane { name: name.clone() }),Hit::Axis { name } if a & AXES != 0 => Some(Sel::Axis { name: name.clone() }),+ Hit::ConstructionPoint { name } if a & CONSTRUCTION_POINTS != 0 => Some(Sel::ConstructionPoint { name: name.clone() }),Hit::SketchCurve { sketch, id, straight: true, .. } if a & AXES != 0 => Some(curve_pick(id, *sketch, active)),Hit::SketchCurve { sketch, id, .. } if a & SKETCH_LINES != 0 => Some(Sel::ExternalSketchCurve { sketch: *sketch, id: id.clone() }),Hit::SketchCurve { sketch, id, .. } if a & CURVES != 0 => Some(curve_pick(id, *sketch, active)),diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex 20726a9e7e..8572525b1c 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -223,7 +223,11 @@ pub enum Hit {name: String,point: Vec3,},- /// An origin axis (X, Y, Z).+ /// A construction point (by feature name).+ ConstructionPoint {+ name: String,+ },+ /// An origin or construction axis.Axis {name: String,},@@ -1601,7 +1605,9 @@ pub fn same_target(a: &Hit, b: &Hit) -> bool {(Hit::Edge { body: a, index: i, .. }, Hit::Edge { body: b, index: j, .. })| (Hit::Face { body: a, index: i, .. }, Hit::Face { body: b, index: j, .. }) => a == b && i == j,(Hit::Profile { sketch: s, index: i }, Hit::Profile { sketch: t, index: j }) => s == t && i == j,- (Hit::Plane { name: a, .. }, Hit::Plane { name: b, .. }) | (Hit::Axis { name: a }, Hit::Axis { name: b }) => a == b,+ (Hit::Plane { name: a, .. }, Hit::Plane { name: b, .. })+ | (Hit::Axis { name: a }, Hit::Axis { name: b })+ | (Hit::ConstructionPoint { name: a }, Hit::ConstructionPoint { name: b }) => a == b,_ => false,}}@@ -1706,6 +1712,15 @@ fn pick_hits(app: &SolveApp, proj: &Proj, pos: Pos2, other_sketch_points: bool,}}}+ for (name, point) in construction_points(app) {+ if let Some(sp) = proj.to_screen(point) {+ let dd = sp.distance(pos);+ let rank = (dd, prefer_free);+ if dd < 8.0 && best.wants(rank) {+ best.offer(rank, Hit::ConstructionPoint { name });+ }+ }+ }hits.extend(best.hits());// Sketch curves: the active sketch's own before projected and other sketches' ones, then// nearest (the active sketch wins ties).@@ -2238,6 +2253,7 @@ pub fn hit_sel(h: &Hit) -> Option<Sel> {Hit::Face { body, index, point } => Sel::Face { body: body.clone(), index: *index, point: *point },Hit::Plane { name, .. } => Sel::Plane { name: name.clone() },Hit::Axis { name } => Sel::Axis { name: name.clone() },+ Hit::ConstructionPoint { name } => Sel::ConstructionPoint { name: name.clone() },})}@@ -2278,7 +2294,7 @@ fn pick_allowed(app: &SolveApp, h: &Hit) -> bool {Hit::Vertex { .. } => !off("vertices") && !app.ui.pick_bodies,Hit::Edge { .. } => !off("edges") && !app.ui.pick_bodies,Hit::Face { .. } => !off("faces") || app.ui.pick_bodies,- Hit::Plane { .. } | Hit::Axis { .. } => true,+ Hit::Plane { .. } | Hit::Axis { .. } | Hit::ConstructionPoint { .. } => true,}}@@ -2747,10 +2763,13 @@ pub(crate) fn build_highlight(app: &SolveApp) -> GpuScene {s += dash * 1.6;}}- for (_, p) in construction_points(app) {+ for (name, p) in construction_points(app) {+ let on = sel.iter().any(|x| matches!(x, Sel::ConstructionPoint { name: n } if *n == name))+ || matches!(hover, Some(Hit::ConstructionPoint { name: n }) if *n == name);+ let col = c4(if on { t.sel_edge } else { t.construction_geom });let r = size * 0.04;for d in [Vec3::X, Vec3::Y, Vec3::Z] {- sc.line((p - d * r).to_f32(), (p + d * r).to_f32(), c4(t.construction_geom), 2.0, true);+ sc.line((p - d * r).to_f32(), (p + d * r).to_f32(), col, 2.0, true);}}// Reference widgets follow zoom; the often much larger world-space feedback does not.@@ -8788,6 +8807,34 @@ mod tests {assert!(h.app.viewport.boxsel.is_none());}+ #[test]+ fn construction_point_is_pickable_only_while_visible() {+ let mut s = solidcraft_engine::Session::default();+ s.execute("construct.point.vertex", &json!({"point":{"point":[20,15,10]},"name":"Point1"})).unwrap();+ s.execute("construct.axis.two_points", &json!({"a":{"point":[-20,0,10]},"b":{"point":[-20,0,30]},"name":"Axis1"})).unwrap();+ let mut app = SolveApp::new(s, crate::Services::default());+ let proj = projection(&app, Rect::from_min_size(Pos2::ZERO, vec2(1000.0, 800.0)));+ let pos = proj.to_screen(Vec3::new(20.0, 15.0, 10.0)).unwrap();+ let is_point =+ |hit: &Hit| hit_sel(hit).is_some_and(|sel| serde_json::to_value(sel).unwrap() == json!({"type":"construction_point","name":"Point1"}));+ for prefer_free in [false, true] {+ app.preferences.prefer_free_sketch_points = prefer_free;+ assert!(pick(&app, &proj, pos).iter().any(is_point));+ assert!(pick_all(&app, &proj, pos).iter().any(is_point));+ }+ let axis_pos = proj.to_screen(Vec3::new(-20.0, 0.0, 20.0)).unwrap();+ let axis = Hit::Axis { name: "Axis1".into() };+ assert!(pick(&app, &proj, axis_pos).contains(&axis));+ assert_eq!(+ crate::selection::SelInput::new("Axis", crate::selection::AXES, false).accepts(&axis, None, |_, _| false),+ Some(Sel::Axis { name: "Axis1".into() })+ );+ app.session.visibility.hidden_origin.extend(["Point1".into(), "Axis1".into()]);+ assert!(!pick(&app, &proj, axis_pos).contains(&axis));+ assert!(!pick(&app, &proj, pos).iter().any(is_point));+ assert!(!pick_all(&app, &proj, pos).iter().any(is_point));+ }+#[test]fn construction_axes_span_the_model_and_points_show() {let mut s = solidcraft_engine::Session::default();