Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Origin plane names: Top / Front / Right (#6491) (#6496)

Lars Jansen83ac98ac76a6
diff --git a/assets/locales/pending/origin-plane-names.json b/assets/locales/pending/origin-plane-names.json
new file mode 100644
index 0000000000..bca13c9e3a
--- /dev/null
+++ b/assets/locales/pending/origin-plane-names.json
@@ -0,0 +1,34 @@
+{
+ "en": {
+ "prefs.origin_plane_names": "Origin plane names",
+ "prefs.origin_plane_names_note": "Names shown in the browser, dialogs and lists. {top} is XY, {front} is XZ and {right} is YZ, with Z up. Commands, scripts and saved designs keep XY, XZ and YZ."
+ },
+ "ja": {
+ "prefs.origin_plane_names": "原点平面の名前",
+ "prefs.origin_plane_names_note": "ブラウザー、ダイアログ、一覧に表示される名前です。{top} は XY、{front} は XZ、{right} は YZ です (Z が上)。コマンド、スクリプト、保存されたデザインでは XY、XZ、YZ のままです。"
+ },
+ "zh": {
+ "prefs.origin_plane_names": "原点平面名称",
+ "prefs.origin_plane_names_note": "浏览器、对话框和列表中显示的名称。{top} 即 XY,{front} 即 XZ,{right} 即 YZ(Z 轴朝上)。命令、脚本和已保存的设计仍使用 XY、XZ 和 YZ。"
+ },
+ "ar": {
+ "prefs.origin_plane_names": "أسماء مستويات الأصل",
+ "prefs.origin_plane_names_note": "الأسماء المعروضة في المستعرض والحوارات والقوائم. {top} هو XY و{front} هو XZ و{right} هو YZ، والمحور Z للأعلى. تحتفظ الأوامر والسكربتات والتصاميم المحفوظة بـ XY وXZ وYZ."
+ },
+ "he": {
+ "prefs.origin_plane_names": "שמות מישורי הראשית",
+ "prefs.origin_plane_names_note": "השמות המוצגים בדפדפן, בתיבות הדו־שיח וברשימות. {top} הוא XY, {front} הוא XZ ו־{right} הוא YZ, כש־Z למעלה. פקודות, סקריפטים ותכנונים שמורים שומרים על XY, XZ ו־YZ."
+ },
+ "de": {
+ "prefs.origin_plane_names": "Namen der Ursprungsebenen",
+ "prefs.origin_plane_names_note": "Namen in Browser, Dialogen und Listen. {top} ist XY, {front} ist XZ und {right} ist YZ, mit Z nach oben. Befehle, Skripte und gespeicherte Konstruktionen behalten XY, XZ und YZ."
+ },
+ "ko": {
+ "prefs.origin_plane_names": "원점 평면 이름",
+ "prefs.origin_plane_names_note": "브라우저, 대화 상자, 목록에 표시되는 이름입니다. {top}은 XY, {front}는 XZ, {right}는 YZ이며 Z가 위쪽입니다. 명령, 스크립트, 저장된 디자인은 XY, XZ, YZ를 유지합니다."
+ },
+ "vi": {
+ "prefs.origin_plane_names": "Tên các mặt phẳng gốc",
+ "prefs.origin_plane_names_note": "Tên hiển thị trong trình duyệt, hộp thoại và danh sách. {top} là XY, {front} là XZ và {right} là YZ, với Z hướng lên. Lệnh, script và thiết kế đã lưu vẫn dùng XY, XZ và YZ."
+ }
+}
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index a8720eb4a5..e801f82438 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -1700,7 +1700,8 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &Actio
return;
}
for (k, icon, thing) in items {
- let label = k;
+ // An origin plane by the name the preferences give it; its key stays the id.
+ let label = app.preferences.origin_plane_names.label(k);
let visible = !app.session.visibility.hidden_origin.iter().any(|h| h == k);
let sel = match icon {
"plane" => Some(Sel::Plane { name: k.into() }),
@@ -1711,8 +1712,19 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &Actio
let r = draw_row(
ui,
ui.id().with(("o", k)),
- // Faded when hidden itself or with the whole Origin.
- &Row { depth: depth + 1, eye: Some(visible), icon, label, selected, dim: !visible || !app.origin_shown(), mark, ..Default::default() },
+ // Faded when hidden itself or with the whole Origin. A renamed plane's label is already
+ // in the interface's language (`name`).
+ &Row {
+ depth: depth + 1,
+ eye: Some(visible),
+ icon,
+ label,
+ name: label != k,
+ selected,
+ dim: !visible || !app.origin_shown(),
+ mark,
+ ..Default::default()
+ },
);
if r.eye {
// Through the command, so the Origin row's eye is an undo step (#2219).
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index dc01b723c0..6ab9fb73c3 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -2307,13 +2307,15 @@ fn placement_row(d: &mut Dialog, ui: &mut egui::Ui, session: &Session) {
}
/// A picked item as its chip shows it. A round edge or face says what it stands for in `inp`:
-/// its axis in an axis input, a circle's centre in a point input.
-pub(crate) fn selection_label(s: &Session, d: &Dialog, inp: &SelInput, item: &Sel) -> String {
+/// its axis in an axis input, a circle's centre in a point input. An origin plane goes by
+/// the name the preferences give it.
+pub(crate) fn selection_label(s: &Session, names: crate::prefs::OriginPlaneNames, d: &Dialog, inp: &SelInput, item: &Sel) -> String {
let axis = inp.accept == selection::AXIS_PICKS && round_axis(s, item).is_some();
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::ConstructionPoint { name } | Sel::Body { name } => name.clone(),
+ Sel::Plane { name } => names.label(name).to_string(),
+ Sel::Axis { name } | Sel::ConstructionPoint { name } | Sel::Body { name } => name.clone(),
Sel::Face { body, index, .. } if axis => format!("{body} · face {index} axis"),
Sel::Face { body, index, .. } => format!("{body} · face {index}"),
Sel::Edge { body, .. } if axis => format!("{body} · circle axis"),
@@ -2336,8 +2338,8 @@ pub(crate) fn selection_label(s: &Session, d: &Dialog, inp: &SelInput, item: &Se
/// Selection input rows: label, "N selected" (or a hint) and a clear button; clicking a row
/// makes it the active input.
-fn input_rows(d: &mut Dialog, ui: &mut egui::Ui, s: &Session) {
- input_rows_range(d, ui, s, 0..d.inputs.len());
+fn input_rows(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, names: crate::prefs::OriginPlaneNames) {
+ input_rows_range(d, ui, s, names, 0..d.inputs.len());
}
/// Saved vectors/axes are real inputs even when they have no origin-axis selection chip.
@@ -2360,7 +2362,7 @@ fn stored_revolve_axis(kind: &Kind) -> Option<&Value> {
}
}
-pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, range: std::ops::Range<usize>) {
+pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, names: crate::prefs::OriginPlaneNames, range: std::ops::Range<usize>) {
// Edit Text shows its Path input among its own rows.
if matches!(d.kind, Kind::Text(_)) {
return;
@@ -2382,7 +2384,7 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, r
RichText::new(if custom_axis || stored_reference.is_some() {
crate::i18n::tr("dialog.custom_axis").into()
} else if !inp.multi {
- inp.items.first().map(|item| selection_label(s, d, inp, item)).unwrap_or_default()
+ inp.items.first().map(|item| selection_label(s, names, d, inp, item)).unwrap_or_default()
} else {
let count = if i == 0 { shell_count.unwrap_or(inp.items.len()) } else { inp.items.len() };
crate::i18n::format("dialog.selected_count", &[("count", &count.to_string())])
@@ -2439,7 +2441,7 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, r
});
if matches!(d.kind, Kind::SketchModify(_)) && inp.multi {
for (index, item) in inp.items.iter().enumerate() {
- if crate::ui_kit::list_row(ui, &format!("{}:{index}", inp.label), &selection_label(s, d, inp, item)).clicked() {
+ if crate::ui_kit::list_row(ui, &format!("{}:{index}", inp.label), &selection_label(s, names, d, inp, item)).clicked() {
remove = Some((i, index));
}
}
diff --git a/crates/ui-egui/src/dialogs_dense.rs b/crates/ui-egui/src/dialogs_dense.rs
index 1c794e2315..50eef02c46 100644
--- a/crates/ui-egui/src/dialogs_dense.rs
+++ b/crates/ui-egui/src/dialogs_dense.rs
@@ -186,9 +186,9 @@ pub(super) fn rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui:
placement_row(d, ui, &app.session);
if crate::hole_refs::takes(d) {
// Each reference edge with its distance (#37, #6380).
- enter |= crate::hole_refs::input_rows(d, ui, &app.session);
+ enter |= crate::hole_refs::input_rows(d, ui, &app.session, app.preferences.origin_plane_names);
} else {
- input_rows(d, ui, &app.session);
+ input_rows(d, ui, &app.session, app.preferences.origin_plane_names);
}
d.sync_material(&app.session);
match &mut d.kind {
diff --git a/crates/ui-egui/src/hole_refs.rs b/crates/ui-egui/src/hole_refs.rs
index b2477da0b3..768a2348a5 100644
--- a/crates/ui-egui/src/hole_refs.rs
+++ b/crates/ui-egui/src/hole_refs.rs
@@ -238,10 +238,10 @@ pub(crate) fn sync(s: &Session, d: &mut Dialog) {
/// The Single hole's (or the Cylinder's) selection rows, each reference edge with its distance on
/// the row below it once it is picked. Whether Enter was pressed in a distance.
-pub(crate) fn input_rows(d: &mut Dialog, ui: &mut egui::Ui, s: &Session) -> bool {
+pub(crate) fn input_rows(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, names: crate::prefs::OriginPlaneNames) -> bool {
let mut enter = false;
for i in 0..d.inputs.len() {
- crate::dialogs::input_rows_range(d, ui, s, i..i + 1);
+ crate::dialogs::input_rows_range(d, ui, s, names, i..i + 1);
let Some(k) = d.inputs.get(i).filter(|inp| !inp.items.is_empty()).and_then(|inp| REFERENCES.iter().position(|l| *l == inp.label)) else {
continue;
};
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 130b9e5411..f5a9226019 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -332,6 +332,35 @@ pub enum HistorySketches {
UnderFeature,
}
+/// What the interface calls the origin planes (Preferences › Interface). Only the names shown
+/// change: the planes' ids (`XY`, `XZ`, `YZ`), commands, scripts and saved designs keep theirs.
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum OriginPlaneNames {
+ /// XY, XZ and YZ. Also what a naming this version doesn't know reads as (`lenient`).
+ #[default]
+ Xyz,
+ /// Top for XY, Front for XZ and Right for YZ (Z up), the engine's aliases for them.
+ TopFrontRight,
+}
+
+impl OriginPlaneNames {
+ pub const ALL: [Self; 2] = [Self::Xyz, Self::TopFrontRight];
+ /// The origin planes' ids, in the order the Preferences list them.
+ pub const PLANES: [&'static str; 3] = ["XY", "XZ", "YZ"];
+
+ /// The name shown for the plane `name`: an origin plane in this naming, in the interface's
+ /// language; any other plane (a construction plane) by its own name.
+ pub fn label(self, name: &str) -> &str {
+ match (self, name) {
+ (Self::TopFrontRight, "XY") => crate::i18n::tr("ui.top"),
+ (Self::TopFrontRight, "XZ") => crate::i18n::tr("ui.front"),
+ (Self::TopFrontRight, "YZ") => crate::i18n::tr("ui.right"),
+ _ => name,
+ }
+ }
+}
+
/// What an orbit turns around (Preferences: "Orbit around").
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
@@ -685,6 +714,8 @@ preference_settings! {
/// Where command dialogs open: at the view's edge, or in the left column in place of the
/// browser and the History there (#6707).
dialog_place: crate::dialog_column::DialogPlace = Default::default(), PAGE_INTERFACE;
+ /// The names the browser, dialogs and lists show for the origin planes (#6491).
+ origin_plane_names: OriginPlaneNames = OriginPlaneNames::default(), PAGE_INTERFACE;
/// The wheel zooms toward the point under the cursor (else toward the view's centre).
zoom_to_cursor: bool = true, PAGE_NAVIGATION => check("Zoom to the cursor", "The wheel zooms toward the point under the cursor (off: toward the view's centre)");
/// Spread discrete wheel input across frames (off: apply each event immediately).
@@ -4322,6 +4353,91 @@ mod tests {
assert_eq!(h.app.session.doc.to_json(), design);
}
+ /// The texts one frame paints.
+ fn painted_texts(h: &mut crate::scenario::Harness) -> Vec<String> {
+ let output = h.ctx.run_ui(egui::RawInput { screen_rect: Some(h.ctx.content_rect()), focused: true, ..Default::default() }, |ui| {
+ h.app.logic(ui.ctx());
+ h.app.ui(ui);
+ });
+ output
+ .shapes
+ .iter()
+ .filter_map(|s| match &s.shape {
+ egui::Shape::Text(t) => Some(t.galley.job.text.clone()),
+ _ => None,
+ })
+ .collect()
+ }
+
+ /// Origin plane names (#6491): Top, Front and Right are names shown in the browser, the
+ /// dialogs' chips and the plane choices; the planes' ids, the commands and the design keep XY,
+ /// XZ and YZ. Saved, refused when unknown, and taken back by Cancel and Restore Defaults.
+ #[test]
+ fn origin_plane_names_change_only_the_names_shown() {
+ use OriginPlaneNames::{TopFrontRight, Xyz};
+ let old: Prefs = serde_json::from_value(json!({"nav":"solidworks"})).unwrap();
+ assert_eq!(old.origin_plane_names, Xyz, "older preferences keep XY, XZ and YZ");
+ assert_eq!(lenient(&json!({"origin_plane_names":"hologram","zoom_reverse":true})).origin_plane_names, Xyz);
+ assert_eq!(OriginPlaneNames::PLANES.map(|p| Xyz.label(p)), ["XY", "XZ", "YZ"]);
+ assert_eq!(OriginPlaneNames::PLANES.map(|p| TopFrontRight.label(p)), ["Top", "Front", "Right"]);
+ assert_eq!(TopFrontRight.label("Plane1"), "Plane1", "construction planes keep their own names");
+
+ let mut h = crate::scenario::Harness::new();
+ let sketch = h.app.run("sketch.create", json!({"plane":"XY"})).unwrap()["sketch"].as_u64().unwrap();
+ h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[20,10]})).unwrap();
+ h.app.run("sketch.finish", json!({})).unwrap();
+ h.frames(2);
+ h.step(&json!({"click":{"chevron":"Origin"}})).unwrap();
+ let rows = || crate::browser::drawn_rows().into_iter().map(|(label, ..)| label).collect::<Vec<_>>();
+ assert!(OriginPlaneNames::PLANES.iter().all(|p| rows().iter().any(|r| r == p)), "{:?}", rows());
+ let design = h.app.session.doc.to_json();
+ h.call("ui.prefs", json!({"open":"Interface"}));
+ super::reveal_preference(&mut h, "prefs:origin_plane_names:top_front_right");
+ h.step(&json!({"click":{"handle":"prefs:origin_plane_names:top_front_right"}})).unwrap();
+ assert_eq!(h.app.preferences.origin_plane_names, TopFrontRight);
+ h.call("ui.prefs", json!({"button":"ok"}));
+ h.frames(2);
+ for (id, name) in [("XY", "Top"), ("XZ", "Front"), ("YZ", "Right")] {
+ assert!(rows().iter().any(|r| r == name) && !rows().iter().any(|r| r == id), "{:?}", rows());
+ }
+ assert_eq!(h.app.session.doc.to_json(), design, "a name shown changes nothing in the design");
+
+ // Picked from its row, the plane is named in the dialog's chip and runs by its id.
+ h.call("ui.start", json!({"command":"construct.plane.offset"}));
+ h.step(&json!({"click":{"browser":"Front"}})).unwrap();
+ let picked = h.app.dialog.as_ref().and_then(|d| d.inputs.first()).map(|i| i.items.clone());
+ assert_eq!(picked, Some(vec![solidcraft_engine::Sel::Plane { name: "XZ".into() }]));
+ assert!(painted_texts(&mut h).iter().any(|t| t == "Front"), "the chip shows the plane's name");
+ h.step(&json!({"widget":"OK"})).unwrap();
+ h.frames(2);
+ let made = h.app.session.doc.features.last().map(|f| serde_json::to_value(&f.kind).unwrap_or_default()).unwrap_or_default();
+ assert!(made.to_string().contains("\"XZ\""), "the command took the id: {made}");
+ // The sketch plane choices of Redefine Sketch Plane: by name, and they run by id.
+ crate::browser::redefine_sketch(&mut h.app, sketch);
+ h.frames(2);
+ let texts = painted_texts(&mut h);
+ assert!(["Use Top plane", "Use Front plane", "Use Right plane"].iter().all(|t| texts.iter().any(|x| x == t)), "{texts:?}");
+ assert!(!texts.iter().any(|t| t == "Use XY plane"));
+ crate::sketch_attachment_ui::clear(&mut h.app);
+
+ let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+ restored.load_prefs(&h.app.prefs());
+ assert_eq!(restored.preferences.origin_plane_names, TopFrontRight, "the choice is saved");
+ let before = h.app.preferences.clone();
+ assert!(control(&mut h.app, &json!({"origin_plane_names":"top", "nav":"solidworks"})).is_err());
+ assert_eq!(h.app.preferences, before, "an unknown naming fails atomically");
+ h.call("ui.prefs", json!({"open":"Interface","origin_plane_names":"xyz"}));
+ h.call("ui.prefs", json!({"button":"cancel"}));
+ assert_eq!(h.app.preferences.origin_plane_names, TopFrontRight, "Cancel takes it back");
+ h.call("ui.prefs", json!({"open":"Interface"}));
+ h.call("ui.prefs", json!({"button":"defaults"}));
+ assert_eq!(h.app.preferences.origin_plane_names, Xyz, "Restore Defaults: XY, XZ and YZ");
+ h.frames(2);
+ assert!(OriginPlaneNames::PLANES.iter().all(|p| rows().iter().any(|r| r == p)), "{:?}", rows());
+ h.call("ui.prefs", json!({"button":"cancel"}));
+ assert_eq!(h.app.preferences.origin_plane_names, TopFrontRight);
+ }
+
#[test]
fn history_sketches_defaults_in_order_and_follows_preferences_transactions() {
let old: Prefs = serde_json::from_value(json!({"timeline_left": true})).unwrap();
diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rs
index bb0ed4f331..c692872be9 100644
--- a/crates/ui-egui/src/prefs/interface.rs
+++ b/crates/ui-egui/src/prefs/interface.rs
@@ -1,5 +1,32 @@
//! Interface settings composition, using shared controls and previews.
use super::*;
+
+/// Origin plane names: each choice shows the three names it gives (`XY / XZ / YZ`), with a note
+/// that only the names shown change.
+fn origin_plane_names(app: &mut SolveApp, ui: &mut egui::Ui) {
+ ui_kit::settings_section(ui, "origin_plane_names", app.tr("prefs.origin_plane_names"), |ui| {
+ let choices: Vec<String> =
+ OriginPlaneNames::ALL.iter().map(|names| OriginPlaneNames::PLANES.map(|plane| names.label(plane)).join(" / ")).collect();
+ let options: Vec<&str> = choices.iter().map(String::as_str).collect();
+ let mut selected = OriginPlaneNames::ALL.iter().position(|names| *names == app.preferences.origin_plane_names).unwrap_or(0);
+ if ui_kit::settings_segments(ui, app.tr("prefs.origin_plane_names"), &mut selected, &options)
+ && let Some(names) = OriginPlaneNames::ALL.get(selected)
+ {
+ app.preferences.origin_plane_names = *names;
+ }
+ // Handles that don't depend on the language, by the choice's saved value.
+ for (choice, key) in choices.iter().zip(["xyz", "top_front_right"]) {
+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{choice}", app.tr("prefs.origin_plane_names"))) {
+ crate::scenario::publish_handle(&format!("prefs:origin_plane_names:{key}"), at);
+ }
+ }
+ let top = OriginPlaneNames::TopFrontRight;
+ let note =
+ crate::i18n::format("prefs.origin_plane_names_note", &[("top", top.label("XY")), ("front", top.label("XZ")), ("right", top.label("YZ"))]);
+ ui_kit::text(ui, &note, ui_kit::Text::Hint("origin_plane_names"));
+ });
+}
+
pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
ui_kit::settings_heading(ui, app.tr("prefs.interface"), app.tr("prefs.interface_note"));
ui_kit::settings_section(ui, "theme", app.tr("ui.theme"), |ui| {
@@ -145,6 +172,7 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
ui_kit::layout_preview,
);
});
+ origin_plane_names(app, ui);
ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| {
ui_kit::settings_pair(
ui,
diff --git a/crates/ui-egui/src/round_pick_tests.rs b/crates/ui-egui/src/round_pick_tests.rs
index 7a55527635..e3c50a911e 100644
--- a/crates/ui-egui/src/round_pick_tests.rs
+++ b/crates/ui-egui/src/round_pick_tests.rs
@@ -182,7 +182,9 @@ fn move_rotates_about_a_cylinder_wall_and_moves_from_a_circle_centre() {
let a: Vec<f64> = serde_json::from_value(p["axis"].clone()).unwrap();
assert!((a[2].abs() - 1.0).abs() < 1e-9, "about the shaft's axis: {a:?}");
// The chips say what the round picks stand for.
- let label = |d: &crate::dialogs::Dialog, i: usize, sel: &Sel| crate::dialogs::selection_label(&h.app.session, d, &d.inputs[i], sel);
+ let label = |d: &crate::dialogs::Dialog, i: usize, sel: &Sel| {
+ crate::dialogs::selection_label(&h.app.session, crate::prefs::OriginPlaneNames::Xyz, d, &d.inputs[i], sel)
+ };
let wall_label = label(&d, 1, &wall);
assert!(wall_label.starts_with("Shaft · face ") && wall_label.ends_with(" axis"), "{wall_label}");
assert!(label(&d, 1, &rim).ends_with("· circle axis"), "{}", label(&d, 1, &rim));
diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rs
index 7176139803..c085b0487c 100644
--- a/crates/ui-egui/src/select_other.rs
+++ b/crates/ui-egui/src/select_other.rs
@@ -310,7 +310,8 @@ fn point_label(sk: &solidcraft_engine::sketch::Sketch, id: &str) -> String {
}
}
-/// A row's name: "Line 3", "Point (arc 2 centre)", "Edge 4 · Body1", "XY Plane"…
+/// A row's name: "Line 3", "Point (arc 2 centre)", "Edge 4 · Body1", "XY Plane" (an origin plane
+/// by the name the preferences give it)…
pub fn label(app: &SolveApp, sel: &Sel) -> String {
let st = app.session.world_state();
let in_sketch =
@@ -331,7 +332,7 @@ pub fn label(app: &SolveApp, sel: &Sel) -> String {
Sel::Occurrence { path } => format!("Occurrence {path:?}"),
Sel::Feature { id } => app.session.doc.feature(*id).map(|f| f.name.clone()).unwrap_or_else(|| format!("Feature {id}")),
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::Plane { name } if matches!(name.as_str(), "XY" | "XZ" | "YZ") => format!("{} Plane", app.preferences.origin_plane_names.label(name)),
Sel::Axis { name } if matches!(name.as_str(), "X" | "Y" | "Z") => format!("{name} Axis"),
Sel::Plane { name } | Sel::Axis { name } | Sel::ConstructionPoint { name } => name.clone(),
}
diff --git a/crates/ui-egui/src/select_other_tests.rs b/crates/ui-egui/src/select_other_tests.rs
index 50fda5df46..b6ac9593d7 100644
--- a/crates/ui-egui/src/select_other_tests.rs
+++ b/crates/ui-egui/src/select_other_tests.rs
@@ -246,6 +246,25 @@ fn overlapping_bodies_list_both_and_the_hidden_one_can_be_picked() {
assert_eq!(h.app.session.selection, [Sel::Body { name: "Inner".into() }]);
}
+/// Origin plane names (#6491): the list names an origin plane as the preferences do, and picking
+/// it still selects the plane by its id.
+#[test]
+fn origin_planes_are_listed_by_the_names_the_preferences_give_them() {
+ let mut h = Harness::new();
+ h.call("ui.view", json!({"view":"top"}));
+ h.settle();
+ h.step(&json!({"hold": {"plane": "XY"}})).unwrap();
+ assert!(labels(&h).iter().any(|r| r == "XY Plane"), "{:?}", labels(&h));
+ h.step(&json!({"key": "Escape"})).unwrap();
+ h.call("ui.prefs", json!({"origin_plane_names": "top_front_right"}));
+ h.step(&json!({"hold": {"plane": "XY"}})).unwrap();
+ let rows = labels(&h);
+ let row = rows.iter().position(|r| r == "Top Plane").unwrap_or_else(|| panic!("{rows:?}"));
+ assert!(!rows.iter().any(|r| r == "XY Plane"), "{rows:?}");
+ h.step(&json!({"click": {"handle": format!("select_other:{row}")}})).unwrap();
+ assert_eq!(h.app.session.selection, vec![Sel::Plane { name: "XY".into() }]);
+}
+
#[test]
fn long_names_stay_inside_the_popup_and_remain_available_on_hover() {
let mut h = Harness::new();
diff --git a/crates/ui-egui/src/sketch_attachment_ui.rs b/crates/ui-egui/src/sketch_attachment_ui.rs
index 73ef926b44..fe6a6b842a 100644
--- a/crates/ui-egui/src/sketch_attachment_ui.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui.rs
@@ -269,9 +269,11 @@ pub fn panel(app: &mut SolveApp, ctx: &egui::Context) {
}
});
ui.horizontal_wrapped(|ui| {
- for plane in ["XY", "XZ", "YZ"] {
- if ui_kit::button(ui, crate::i18n::format("sketch_panel.use_plane", &[("plane", plane)]), ui_kit::Button::Normal).clicked() {
- draft.choose(json!(plane), plane.into());
+ // The command takes the plane's id; the button and the choice show its name.
+ for plane in crate::prefs::OriginPlaneNames::PLANES {
+ let label = app.preferences.origin_plane_names.label(plane);
+ if ui_kit::button(ui, crate::i18n::format("sketch_panel.use_plane", &[("plane", label)]), ui_kit::Button::Normal).clicked() {
+ draft.choose(json!(plane), label.into());
}
}
});
diff --git a/docs/book/src/guide/sketching.md b/docs/book/src/guide/sketching.md
index e2a2b202c7..85ddde37f3 100644
--- a/docs/book/src/guide/sketching.md
+++ b/docs/book/src/guide/sketching.md
@@ -10,6 +10,8 @@ an edited one goes back to how it was, as one step that Undo brings back.
Opening a sketch turns the view to face it. When the sketch ends, the view stays where it is by default. Preferences › Sketch › **When a sketch ends** changes that: **Return to the previous view** goes back to the view from before the sketch, and **Return unless rotated** goes back only when you panned or zoomed the sketch view but didn't turn it.
In scripts, `XY`, `XZ`, `YZ` and their `Top`, `Front`, `Right` aliases name origin planes.
+Preferences › Interface › **Origin plane names** shows them as Top, Front and Right in the
+browser, dialogs and lists; scripts and saved designs keep XY, XZ and YZ.
These names are reserved: a construction plane cannot be created with or renamed to one
(case-insensitive). If an older design already has a construction plane with such a name, a
string argument naming it is ambiguous and is rejected; use the other alias (`XY` for `Top`)
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index aebcfbc15e..870f95fae0 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -303,7 +303,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.
| `ui.home` | `open?`: bool; `sample?`: index | the start page: show or hide it, open a built-in sample (once built); returns `open` and the recent designs |
| `ui.shortcut` | `command`, `key?`, `replace?` | a command's key, or rebinds it (`""` clears; a key another command uses is refused unless `replace`) |
| `ui.help` | `item?`: `about`, `shortcuts` (read only), `report` (opens a report draft for review), `crashes` (the Crash Reports window) | the version, commit, build date and diagnostic text |
-| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `theme_follow` (desktop only, default `""`: a `solidcraft-theme/1` file's path to follow as the theme, reloaded within about a second whenever it changes and when the window gains the focus; the file is read at once, and a file that doesn't read keeps the last good theme; `""` stops following, as does setting `theme`; in the browser it is an error; the launch flag `--theme-file PATH` follows a file for one run without saving it; the reply's `theme_followed` is the path followed now or null, and `theme_follow_error` why its last read was not applied, or null), `language` (`en`, `ar`, `ja`, `de`, `fr`, `he`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order), `dialog_buttons` (`bottom` (default), `top`: a feature dialog's OK, Cancel and Apply sit in its title row instead of under its inputs, #6708; the buttons keep their handles, and `dialog:close` is then Cancel's), `timeline_origin_bodies` (default false: the History on the left or under the browser starts with the active component's Bodies folder and the Origin, the browser's rows with their eyes, folds and menus; the bottom History is unchanged), `dialog_place` (`edge` (default) or `left_column`: command dialogs open in the left column in place of the browser and the History, #6707), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark`, `viewport_dark` (whether the 3D view is dark), `stand_up_offer`, `theme_followed` and `theme_follow_error` |
+| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `theme_follow` (desktop only, default `""`: a `solidcraft-theme/1` file's path to follow as the theme, reloaded within about a second whenever it changes and when the window gains the focus; the file is read at once, and a file that doesn't read keeps the last good theme; `""` stops following, as does setting `theme`; in the browser it is an error; the launch flag `--theme-file PATH` follows a file for one run without saving it; the reply's `theme_followed` is the path followed now or null, and `theme_follow_error` why its last read was not applied, or null), `language` (`en`, `ar`, `ja`, `de`, `fr`, `he`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order), `dialog_buttons` (`bottom` (default), `top`: a feature dialog's OK, Cancel and Apply sit in its title row instead of under its inputs, #6708; the buttons keep their handles, and `dialog:close` is then Cancel's), `timeline_origin_bodies` (default false: the History on the left or under the browser starts with the active component's Bodies folder and the Origin, the browser's rows with their eyes, folds and menus; the bottom History is unchanged), `origin_plane_names` (`xyz` (default) or `top_front_right`: the browser, dialogs and lists call the origin planes Top, Front and Right; their ids, commands and saved designs keep XY, XZ and YZ), `dialog_place` (`edge` (default) or `left_column`: command dialogs open in the left column in place of the browser and the History, #6707), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark`, `viewport_dark` (whether the 3D view is dark), `stand_up_offer`, `theme_followed` and `theme_follow_error` |
| `ui.capture` | `action?`: `capture`, `revert`, `cancel` | answers the Capture Position question (asked when a command starts or the design is saved while components were moved without capturing); without `action`, what waits |
| `ui.window` | `action`: minimize, maximize, restore, toggle, close | what the title bar's caption buttons do (on Windows and Linux the application bar is the title bar); close asks about unsaved designs first |
| `ui.agent_cursor` | `show` (bool), `speed`: a number from 1 to 5 (times the normal speed) or `"instant"` (no animation: the command runs at once and the pointer jumps to where it acted), `follow_camera` (bool); all optional | the settings. While the cursor is shown, `engine.execute` first glides to the command's toolbar button and to each pick, then runs and replies; later requests wait their turn. The pointer shows the command's localized name, including commands inside a closed toolbar group; an animated batch names each command it visits. It also follows the pointer input sent with `ui.move`, `ui.click`, `ui.drag` and `ui.scroll`, as each event reaches the app, and a press leaves a ripple. `"animate": false` on a call skips it |