Redefine Sketch Plane names the plane a sketch is on now (#5103) (#5545)

* claim: #5103

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

* Redefine Sketch Plane names the plane a sketch is on now (#5103)

For a sketch with no body-face attachment the panel only said so. It now shows
a Current plane row: the origin plane, a construction plane's name, or the
plane it is offset from, turned from or flipped from. English, Japanese and
Chinese messages added.

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

* Drop needless to_string calls in the plane name format

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
This commit is contained in:
dudedagger42
2026-10-25 18:42:24 +00:00
committed by GitHub
parent 0870d6474a
commit 10124c8ccf
5 changed files with 64 additions and 1 deletions
+6
View File
@@ -143,6 +143,7 @@
"Cube": "Cube",
"Current orthographic view (1:1 mm)": "Current orthographic view (1:1 mm)",
"Current perspective view": "Current perspective view",
"Current plane": "Current plane",
"Curv. Comb": "Curv. Comb",
"Curvature (G2)": "Curvature (G2)",
"Curvature change (G3)": "Curvature change (G3)",
@@ -2151,6 +2152,11 @@
"sketch_panel.author": "Author placement: {path}",
"sketch_panel.dimension_hint": "Enter a value or expression, then press OK.",
"sketch_panel.move_hint": "Enter distances and an angle, then press OK.",
"sketch_panel.plane_angle": "{plane}, turned by {angle}",
"sketch_panel.plane_fixed": "A fixed plane",
"sketch_panel.plane_flipped": "{plane}, from its other side",
"sketch_panel.plane_offset": "{plane}, offset by {distance}",
"sketch_panel.plane_origin": "The {plane} plane",
"sketch_panel.redefine_title": "{command}: {name}",
"sketch_panel.sheet_attachment": "Attached to a flat face of a sheet metal body; it follows that panel when the sheet changes.",
"sketch_panel.text_hint": "Edit the text and its placement, then press OK.",
+6
View File
@@ -143,6 +143,7 @@
"Cube": "キューブ",
"Current orthographic view (1:1 mm)": "現在の平行投影(実寸・mm)",
"Current perspective view": "現在の透視投影",
"Current plane": "現在の平面",
"Curv. Comb": "曲率コーム",
"Curvature (G2)": "曲率 (G2)",
"Curvature change (G3)": "曲率変化 (G3)",
@@ -2151,6 +2152,11 @@
"sketch_panel.author": "作成時の配置: {path}",
"sketch_panel.dimension_hint": "値または式を入力し、OK を押してください。",
"sketch_panel.move_hint": "距離と角度を入力し、OK を押してください。",
"sketch_panel.plane_angle": "{plane}、{angle} 回転",
"sketch_panel.plane_fixed": "固定平面",
"sketch_panel.plane_flipped": "{plane}(裏側から)",
"sketch_panel.plane_offset": "{plane}、{distance} オフセット",
"sketch_panel.plane_origin": "{plane} 平面",
"sketch_panel.redefine_title": "{command}:{name}",
"sketch_panel.sheet_attachment": "板金ボディの平面に接続されています。板金が変更されると、そのパネルに追従します。",
"sketch_panel.text_hint": "テキストと配置を編集し、OK を押してください。",
+6
View File
@@ -143,6 +143,7 @@
"Cube": "立方体",
"Current orthographic view (1:1 mm)": "当前正交视图(1:1毫米)",
"Current perspective view": "当前透视视图",
"Current plane": "当前平面",
"Curv. Comb": "曲率梳",
"Curvature (G2)": "曲率 (G2)",
"Curvature change (G3)": "曲率变化 (G3)",
@@ -2151,6 +2152,11 @@
"sketch_panel.author": "创建时的放置:{path}",
"sketch_panel.dimension_hint": "输入数值或表达式,然后按“确定”。",
"sketch_panel.move_hint": "输入距离和角度,然后按“确定”。",
"sketch_panel.plane_angle": "{plane},旋转 {angle}",
"sketch_panel.plane_fixed": "固定平面",
"sketch_panel.plane_flipped": "{plane}(从另一侧)",
"sketch_panel.plane_offset": "{plane},偏移 {distance}",
"sketch_panel.plane_origin": "{plane} 平面",
"sketch_panel.redefine_title": "{command}:{name}",
"sketch_panel.sheet_attachment": "附着到钣金实体的平面上;钣金变化时会跟随该面板。",
"sketch_panel.text_hint": "编辑文字及其位置,然后按“确定”。",
+27 -1
View File
@@ -4,7 +4,7 @@ use egui::RichText;
use serde_json::{Value, json};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::face_anchor::plane_face_anchor;
use solidcraft_engine::doc::{EmbossFace, FaceAttachmentStatus, FeatureKind, mat_inverse};
use solidcraft_engine::doc::{EmbossFace, FaceAttachmentStatus, FeatureKind, PlaneRef, mat_inverse};
use solidcraft_engine::geom::{Plane, Vec3};
use crate::SolveApp;
@@ -100,6 +100,25 @@ pub fn face_plane(app: &SolveApp, selection: &Sel) -> Option<Value> {
}
}
/// What a sketch's plane is, for the Redefine Sketch Plane panel: `XY`, a construction plane's
/// name, or the plane it's offset from, turned from or flipped from (#5103).
pub(crate) fn plane_description(plane: &PlaneRef) -> String {
fn describe(plane: &PlaneRef, depth: usize) -> String {
let base = |b: &PlaneRef| if depth < 8 { describe(b, depth + 1) } else { crate::i18n::tr("sketch_panel.plane_fixed").to_owned() };
match plane {
PlaneRef::Origin { name } => crate::i18n::format("sketch_panel.plane_origin", &[("plane", name)]),
PlaneRef::Construction { name } => name.to_string(),
PlaneRef::Offset { base: b, distance } => {
crate::i18n::format("sketch_panel.plane_offset", &[("plane", &base(b)), ("distance", distance)])
}
PlaneRef::AtAngle { base: b, angle, .. } => crate::i18n::format("sketch_panel.plane_angle", &[("plane", &base(b)), ("angle", angle)]),
PlaneRef::Flipped { base: b, .. } => crate::i18n::format("sketch_panel.plane_flipped", &[("plane", &base(b))]),
_ => crate::i18n::tr("sketch_panel.plane_fixed").to_owned(),
}
}
describe(plane, 0)
}
fn face_label(app: &SolveApp, selection: &Sel) -> String {
let Sel::Face { body, .. } = selection else { return String::new() };
let placed = app.session.placed_document();
@@ -204,6 +223,13 @@ pub fn panel(app: &mut SolveApp, ctx: &egui::Context) {
*plane
}
FaceAttachmentStatus::Fixed { plane } => {
// Name the plane it's on now: an origin or construction plane (#5103).
if let Some(FeatureKind::Sketch { plane: on, .. }) = app.session.doc.feature(sketch).map(|f| &f.kind) {
let now = plane_description(on);
ui_kit::row(ui, "Current plane", |ui| {
ui.label(now);
});
}
ui.label(crate::i18n::tr_label("Sketch plane has no body-face attachment."));
*plane
}
@@ -400,3 +400,22 @@ fn plane_redefinition_uses_dense_card_and_keeps_command_preview_cancel_and_ok()
assert_eq!(h.app.session.doc.to_json(), before);
}
}
/// #5103: Redefine Sketch Plane names the plane a sketch is on now, not only "no body-face
/// attachment": an origin plane, a construction plane, and planes built from them.
#[test]
fn redefine_panel_names_the_plane_a_sketch_is_on() {
use crate::sketch_attachment_ui::plane_description;
let mut h = Harness::new();
h.app.run("construct.plane.offset", json!({"base": "XY", "offset": 10, "name": "Shelf"})).unwrap();
for (plane, expected) in [("XZ", "The XZ plane"), ("Shelf", "Shelf")] {
let id = h.app.run("sketch.create", json!({"plane": plane})).unwrap()["sketch"].as_u64().unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
let FeatureKind::Sketch { plane: on, .. } = &h.app.session.doc.feature(id).unwrap().kind else { panic!("a sketch") };
assert_eq!(plane_description(on), expected, "{plane}");
}
let xy = Box::new(PlaneRef::Origin { name: "XY".into() });
let offset = PlaneRef::Offset { base: xy.clone(), distance: "12 mm".into() };
assert_eq!(plane_description(&offset), "The XY plane, offset by 12 mm");
assert_eq!(plane_description(&PlaneRef::Flipped { base: xy, about_y: false }), "The XY plane, from its other side");
}