Measure: a circle and a line now show 'Line to centre' instead of 'Center to center' (#11524)

* Measure: a circle and a line show 'Line to centre' instead of 'Centre to centre'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Measure: US spelling for Line to center, UK in en-GB

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-11-04 07:38:21 +00:00
1 parent 9e3e403b3f
commit eeb686f164
4 files changed
+62 -3

No files matched your search

@@ -0,0 +1,29 @@
{
"ar": {
"measure.line_to_centre": "من الخط إلى المركز"
},
"de": {
"measure.line_to_centre": "Linie zum Mittelpunkt"
},
"en": {
"measure.line_to_centre": "Line to center"
},
"en-GB": {
"measure.line_to_centre": "Line to centre"
},
"he": {
"measure.line_to_centre": "מהקו למרכז"
},
"ja": {
"measure.line_to_centre": "線から中心まで"
},
"ko": {
"measure.line_to_centre": "선에서 중심까지"
},
"vi": {
"measure.line_to_centre": "Từ đường đến tâm"
},
"zh": {
"measure.line_to_centre": "线到圆心"
}
}
+3 -2
View File
@@ -1119,11 +1119,12 @@ fn measure_rows(app: &SolveApp, ui: &mut egui::Ui, r: Option<&Value>, show: &mut
if let Some((now, d, a, b)) = shown_distance(r, *show) {
if r.get("center_distance").is_some() {
// Centre, min and max all listed; the chosen one is drawn and broken into ΔX/Y/Z.
let centre_label = crate::quick_measure::centre_distance_label(r);
for (which, label, key) in
[(Shown::Centre, "Centre to centre", "center_distance"), (Shown::Min, "Min", "distance_mm"), (Shown::Max, "Max", "max")]
[(Shown::Centre, centre_label, "center_distance"), (Shown::Min, tr("Min"), "distance_mm"), (Shown::Max, tr("Max"), "max")]
{
let Some(v) = r.get(key).filter(|v| v.is_number()) else { continue };
if ui_kit::list_picker(ui, key, &format!("{} {}", tr(label), mm(v)), now == which).clicked() {
if ui_kit::list_picker(ui, key, &format!("{} {}", label, mm(v)), now == which).clicked() {
*show = Some(which);
}
}
+12 -1
View File
@@ -173,6 +173,17 @@ pub(crate) fn item_lines(app: &SolveApp, it: &Value) -> Vec<String> {
lines
}
/// The label of a pair's centre distance: from a straight edge to a circle's centre, or
/// centre to centre.
pub(crate) fn centre_distance_label(r: &Value) -> &'static str {
let is_circle = |item: &Value| item.get("round").and_then(Value::as_str) == Some("circle");
let is_line = |item: &Value| matches!(item.get("type").and_then(Value::as_str), Some("edge" | "sketch_curve")) && item.get("round").is_none();
match r["items"].as_array().map(Vec::as_slice) {
Some([a, b]) if (is_circle(a) && is_line(b)) || (is_circle(b) && is_line(a)) => crate::i18n::tr("measure.line_to_centre"),
_ => crate::i18n::tr("Centre to centre"),
}
}
/// The readout's rows for a measurement.
fn lines(app: &SolveApp, r: &Value) -> Vec<(String, String)> {
let split = |line: String| match line.split_once(" ") {
@@ -193,7 +204,7 @@ fn lines(app: &SolveApp, r: &Value) -> Vec<(String, String)> {
}
let mut rows = Vec::new();
if let Some(d) = r["center_distance"].as_f64() {
rows.push((crate::i18n::tr("Centre to centre").to_string(), crate::prefs::show_mm(app, d, 1)));
rows.push((centre_distance_label(r).to_string(), crate::prefs::show_mm(app, d, 1)));
}
if let Some(d) = r["distance_mm"].as_f64() {
rows.push((crate::i18n::tr_label("Distance").to_string(), crate::prefs::show_mm(app, d, 1)));
+18
View File
@@ -131,6 +131,24 @@ fn two_points_show_their_distance() {
assert!(rows.contains(&row("Distance", crate::prefs::show_mm(&h.app, 1400f64.sqrt(), 1))), "{rows:?}");
}
/// A circle and a line: the distance from the line to the circle's centre is named so.
#[test]
fn a_circle_and_a_line_show_the_distance_from_the_line_to_the_centre() {
let mut h = harness();
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
h.app.run("sketch.circle.center", json!({"center": [0, 0], "radius": 5})).unwrap();
h.app.run("sketch.line", json!({"points": [[20, 0], [30, 0]]})).unwrap();
h.app.session.selection = ["c1", "l1"].into_iter().map(|id| Sel::SketchCurve { id: id.into(), sketch: None }).collect();
let rows = readout(&mut h);
assert!(rows.contains(&row("Line to center", crate::prefs::show_mm(&h.app, 20.0, 1))), "{rows:?}");
assert!(!rows.iter().any(|(l, _)| l == crate::i18n::tr("Centre to centre")), "{rows:?}");
h.app.run("sketch.circle.center", json!({"center": [50, 0], "radius": 5})).unwrap();
h.app.session.selection = ["c1", "c2"].into_iter().map(|id| Sel::SketchCurve { id: id.into(), sketch: None }).collect();
let rows = readout(&mut h);
assert!(rows.iter().any(|(l, _)| l == crate::i18n::tr("Centre to centre")), "two circles still measure centre to centre: {rows:?}");
}
#[test]
fn several_edges_show_their_count_and_total_length() {
let mut h = block();