Measure picks projected and intersection sketch curves (#4337) (#4427)

* claim: #4337

* Measure picks projected and intersection sketch curves (#4337)

Dialog inputs turned away every curve or point of a sketch that is not the
active one, which includes projected and intersection curves, so Measure
took the nearest item it did accept instead. Give Measure explicit
acceptance for these references, keep the source sketch on a click, and
accept them from a pre-selection and a box selection. Other inputs keep
their restrictions.
This commit is contained in:
raykholo
2026-10-24 22:05:58 +00:00
committed by GitHub
parent 1e81e65e7e
commit 0b91ff8a34
3 changed files with 49 additions and 2 deletions
+14 -2
View File
@@ -604,7 +604,8 @@ fn fits(a: Accept, s: &Sel) -> bool {
// Sketch points go into a sketch command's own inputs (Entities, a base point), so a
// box selection and a pre-selection reach them the way a click already does.
Sel::SketchPoint { .. } => a & (selection::POINTS | selection::SKETCH_POINTS) != 0,
Sel::SketchMidpoint { .. } | Sel::SketchConstraint { .. } | Sel::Occurrence { .. } | Sel::ExternalSketchPoint { .. } => false,
Sel::ExternalSketchPoint { .. } => a & selection::EXTERNAL_POINTS != 0,
Sel::SketchMidpoint { .. } | Sel::SketchConstraint { .. } | Sel::Occurrence { .. } => false,
}
}
@@ -750,7 +751,18 @@ impl Dialog {
),
"inspect.measure" => Dialog::new(
Kind::Measure { result: None, of: Vec::new(), show: None },
vec![SelInput::new("Items", FACES | EDGES | selection::VERTICES | selection::CURVES | PROFILES, true)],
vec![SelInput::new(
"Items",
FACES
| EDGES
| selection::VERTICES
| CURVES
| selection::POINTS
| PROFILES
| selection::SKETCH_LINES
| selection::EXTERNAL_POINTS,
true,
)],
),
"solid.pattern.rectangular" => Dialog::new(
Kind::PatternRect { count: "3".into(), spacing: "20 mm".into(), count2: "1".into(), spacing2: "20 mm".into() },
+32
View File
@@ -2,6 +2,38 @@
use super::*;
use crate::scenario::{self, Harness};
#[test]
fn measure_input_fits_external_sketch_geometry() {
let mut h = Harness::new();
let curve = Sel::ExternalSketchCurve { sketch: 17, id: "line1".into() };
let point = Sel::ExternalSketchPoint { sketch: 17, id: "p1".into() };
h.app.session.selection = vec![curve.clone(), point.clone()];
let mut d = Dialog::for_command(&h.app, "inspect.measure").unwrap();
let accept = d.inputs.first().unwrap().accept;
assert!(fits(accept, &curve));
assert!(fits(accept, &point));
assert_eq!(d.items(), vec![curve.clone(), point.clone()]);
assert_eq!(d.candidate(&h.app.session, &Hit::SketchCurve { sketch: 17, id: "line1".into(), straight: true }), Some(curve.clone()));
assert_eq!(
d.candidate(&h.app.session, &Hit::SketchPoint { sketch: 17, id: "p1".into(), at: solidcraft_engine::geom::Vec2::new(0.0, 0.0) }),
Some(point.clone())
);
d.take_box(&h.app.session, vec![curve.clone(), point.clone()], false);
assert_eq!(d.items(), vec![curve, point]);
}
#[test]
fn feature_inputs_reject_external_sketch_geometry() {
let h = Harness::new();
for (command, sel) in [
("solid.pipe", Sel::ExternalSketchCurve { sketch: 17, id: "line1".into() }),
("solid.hole", Sel::ExternalSketchPoint { sketch: 17, id: "p1".into() }),
] {
let d = Dialog::for_command(&h.app, command).unwrap();
assert!(!fits(d.inputs.first().unwrap().accept, &sel), "{command}");
}
}
fn fixture() -> Harness {
let mut h = Harness::new();
for (name, x) in [("A", 0), ("B", 30), ("C", 60), ("D", 90)] {
+3
View File
@@ -65,6 +65,8 @@ pub const ORIGIN: Accept = 4096;
/// Curves of any sketch, picked with their sketch (`ExternalSketchCurve`): curve ids are a
/// sketch's own, so two sketches can both have a `w2` (frame member lines).
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;
/// One selection input of a command dialog ("Profiles", "Edges", "Plane", ...).
#[derive(Clone, Debug, PartialEq)]
@@ -105,6 +107,7 @@ impl SelInput {
Hit::SketchCurve { id, straight: true, .. } if a & AXES != 0 => Some(Sel::SketchCurve { id: id.clone() }),
Hit::SketchCurve { sketch, id, .. } if a & SKETCH_LINES != 0 => Some(Sel::ExternalSketchCurve { sketch: *sketch, id: id.clone() }),
Hit::SketchCurve { id, .. } if a & CURVES != 0 => Some(Sel::SketchCurve { id: id.clone() }),
Hit::SketchPoint { sketch, id, .. } if a & EXTERNAL_POINTS != 0 => Some(Sel::ExternalSketchPoint { sketch: *sketch, id: id.clone() }),
Hit::SketchPoint { id, .. } if a & SKETCH_POINTS != 0 => Some(Sel::SketchPoint { id: id.clone() }),
Hit::SketchPoint { sketch, id, .. } if a & POINTS != 0 => Some(Sel::SketchPoint { id: format!("{sketch}:{id}") }),
Hit::Vertex { body, point } if body.is_empty() && a & ORIGIN != 0 => Some(Sel::Vertex { body: String::new(), point: *point }),