SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Sketch: preview the whole midpoint line while drawing it (#1371)
DuBearte56622e4be88c
diff --git a/crates/ui-egui/src/sketch_display_preview_tests.rs b/crates/ui-egui/src/sketch_display_preview_tests.rsindex adc9f32b3b..c7fc01e000 100644--- a/crates/ui-egui/src/sketch_display_preview_tests.rs+++ b/crates/ui-egui/src/sketch_display_preview_tests.rs@@ -41,6 +41,8 @@ fn pixel_preview_temporary_curves_match_committed_geometry_and_sampling() {let cases: Vec<(&str, Vec<[f64; 2]>, [f64; 2], Option<f64>, Option<f64>, Value)> = vec![("sketch.circle.center", vec![[0., 0.]], [1., 0.], None, None, json!({"center":[0,0],"radius":1})),("sketch.circle.two_point", vec![[-1., 0.]], [1., 0.], None, None, json!({"p0":[-1,0],"p1":[1,0]})),+ // #1358: the whole line, both sides of the middle.+ ("sketch.line.midpoint", vec![[0., 0.]], [1., 0.5], None, None, json!({"mid":[0,0],"end":[1,0.5]})),("sketch.circle.three_point", vec![[1., 0.], [-1., 0.]], [0., 1.], None, None, json!({"p0":[1,0],"p1":[-1,0],"p2":[0,1]})),("sketch.arc.three_point", vec![[1., 0.], [-1., 0.]], [0., -1.], None, None, json!({"start":[1,0],"end":[-1,0],"through":[0,-1]})),(diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rsindex 1f643373ff..8a8e22ae52 100644--- a/crates/ui-egui/src/tools.rs+++ b/crates/ui-egui/src/tools.rs@@ -586,6 +586,14 @@ pub(crate) fn preview_curve(t: &Tool, hover: Vec2, sweep: Option<f64>, rho: Opti("sketch.circle.two_point", [a]) => {sk.add_circle((*a + hover) * 0.5, a.dist(hover) * 0.5, None, None).ok()?;}+ // The first click is the middle: the line runs from the cursor's mirror image through+ // it to the cursor (#1358), not from the middle to the cursor.+ ("sketch.line.midpoint", [m]) => {+ if m.dist(hover) <= 1e-9 {+ return None;+ }+ sk.add_line(*m * 2.0 - hover, hover, None, None, None).ok()?;+ }("sketch.circle.three_point" | "sketch.arc.three_point", [a, b]) => {let ab = *b - *a;let ah = hover - *a;