Measure: show complete point coordinates (#11069) (#11085)

* Measure: show complete point coordinates (#11069)

Render measurement item details as wrapping text instead of fixed-height cells. Keep the existing values, units and precision. Add a regression test in the existing measurement UI test module.

Local validation: the regression test compiled, but the Windows GNU test binary crashes with 0xc0000005 even for --list, before tests run. Runtime verification and visual evidence remain pending; this contribution is a draft.

* Keep repository LF line endings in the coordinate fix
This commit is contained in:
erman
2026-11-04 06:53:04 +00:00
committed by GitHub
parent 1cbfb889d5
commit 69f202f1c8
2 changed files with 57 additions and 1 deletions
+3 -1
View File
@@ -1111,7 +1111,9 @@ fn measure_rows(app: &SolveApp, ui: &mut egui::Ui, r: Option<&Value>, show: &mut
let lines = crate::quick_measure::item_lines(app, it);
for (k, line) in lines.into_iter().enumerate() {
let label = if k == 0 { crate::i18n::format("measure.item", &[("number", &(i + 1).to_string())]) } else { String::new() };
value(ui, &label, &line);
// Coordinates need all three values; a fixed-height form cell elides the end.
let text = if label.is_empty() { line } else { format!("{label} {line}") };
ui_kit::text(ui, &text, ui_kit::Text::Report(&format!("measure_item_{i}_{k}"), false));
}
}
if let Some((now, d, a, b)) = shown_distance(r, *show) {
@@ -120,6 +120,60 @@ fn painted_text(h: &mut Harness) -> Vec<String> {
output.shapes.iter().filter_map(|s| if let egui::Shape::Text(t) = &s.shape { Some(t.galley.text().to_string()) } else { None }).collect()
}
/// A point's complete position must be painted, not merely retained in an ellipsized galley.
#[test]
fn point_coordinates_are_not_truncated_in_the_measure_panel() {
for layout in ["floating", "compact"] {
for decimals in [2, 8] {
let mut h = Harness::new();
h.app.home.open = false;
h.app.preferences.length_decimals = decimals;
h.call("ui.set", json!({"layout":layout}));
let point = [-99.56, -75.0, 12.345678];
h.app.run("solid.box", json!({"corner":point,"length":1,"width":1,"height":1,"body_name":"Box"})).unwrap();
h.app.session.selection = vec![Sel::Vertex { body: "Box".into(), point: point.into() }];
h.app.start("inspect.measure");
h.call("ui.view", json!({"view":"fit"}));
h.frames(6);
let line = crate::quick_measure::item_lines(&h.app, &result(&h)["items"][0]).remove(0);
h.ctx = egui::Context::default();
crate::fonts::setup_bundled_fonts(&h.ctx);
let mut textures = std::collections::HashMap::new();
let mut last = None;
for frame in 0..6 {
let mut output = h.ctx.run_ui(
egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))),
time: Some(frame as f64 / 60.0),
..Default::default()
},
|ui| h.app.ui(ui),
);
crate::ui_kit::test_textures_update(&mut textures, &output.textures_delta);
output.textures_delta.clear();
last = Some(output);
}
let output = last.unwrap();
if let Ok(dir) = std::env::var("SOLIDCRAFT_MEASURE_EVIDENCE") {
let bounds = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0));
let image = crate::ui_kit::test_raster(&h.ctx, output.shapes.clone(), output.pixels_per_point, bounds, &textures);
std::fs::create_dir_all(&dir).unwrap();
image.save(std::path::Path::new(&dir).join(format!("coordinates-{layout}-{decimals}.png"))).unwrap();
}
let painted = output
.shapes
.iter()
.find_map(|s| match &s.shape {
egui::Shape::Text(t) if t.galley.text().contains(&line) => Some((s.clip_rect, t)),
_ => None,
})
.expect("the position is painted");
assert!(!painted.1.galley.elided, "{layout}, {decimals} decimals: {line}");
assert!(painted.0.expand(1.0).contains_rect(painted.1.visual_bounding_rect()), "the complete position stays inside its clip");
}
}
}
fn component_rects() -> Vec<egui::Rect> {
["measure:label", "measure:label:x", "measure:label:y", "measure:label:z"].into_iter().map(|key| crate::scenario::rect_of(key).unwrap()).collect()
}