Save as Mesh: Add all bodies and Add visible bodies buttons (#7297)

* Save as Mesh: Add all bodies and Add visible bodies buttons

Two buttons under the Bodies input fill it with every body of the design,
or with only the bodies the viewport shows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Save as Mesh: translate the two body buttons for every complete catalog

ar, he, ja, vi and zh are complete catalogs, so every English message needs
an entry there; ko as the ui-text skill asks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Steinert
2026-10-27 20:08:27 +00:00
committed by GitHub
parent d2f0627421
commit 0e4c5ae577
4 changed files with 51 additions and 2 deletions
@@ -0,0 +1,10 @@
{
"en": { "Add all bodies": "Add all bodies", "Add visible bodies": "Add visible bodies" },
"ar": { "Add all bodies": "إضافة كل الأجسام", "Add visible bodies": "إضافة الأجسام المرئية" },
"de": { "Add all bodies": "Alle Körper hinzufügen", "Add visible bodies": "Sichtbare Körper hinzufügen" },
"he": { "Add all bodies": "הוספת כל הגופים", "Add visible bodies": "הוספת הגופים הגלויים" },
"ja": { "Add all bodies": "すべてのボディを追加", "Add visible bodies": "表示中のボディを追加" },
"ko": { "Add all bodies": "모든 바디 추가", "Add visible bodies": "보이는 바디 추가" },
"vi": { "Add all bodies": "Thêm tất cả thân khối", "Add visible bodies": "Thêm các thân khối đang hiện" },
"zh": { "Add all bodies": "添加所有实体", "Add visible bodies": "添加可见实体" }
}
+21
View File
@@ -2,6 +2,27 @@ use super::*;
use crate::scenario::{Harness, handle_at, rect_of};
use crate::shell::{LayoutMode, SHELL_GAP};
#[test]
fn save_mesh_add_all_and_add_visible_bodies_fill_the_bodies_input() {
let mut h = Harness::new();
for (name, x) in [("One", 0), ("Two", 20), ("Three", 40)] {
h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"corner":[x,0,0],"operation":"new_body","body_name":name})).unwrap();
}
h.app.run("browser.visibility", json!({"items":["Two"],"visible":false})).unwrap();
h.app.start("file.save_mesh");
h.settle();
for (button, expected) in [("Add all bodies", vec!["One", "Two", "Three"]), ("Add visible bodies", vec!["One", "Three"])] {
let handle = crate::scenario::handles("dialog:button:").into_iter().find(|(n, _)| n.ends_with(&format!(":{button}")));
let (handle, _) = handle.unwrap_or_else(|| panic!("{button} is shown"));
h.step(&json!({"click":{"handle":handle}})).unwrap();
let d = h.app.dialog.as_ref().unwrap();
let crate::dialogs::Kind::SaveMesh(k) = &d.kind else { panic!("Save as Mesh is open") };
let commands = crate::dialogs_save_mesh::commands(k, &d.inputs).unwrap();
assert_eq!(commands[0].1["bodies"], json!(expected), "{button}");
assert!(h.app.session.selection.is_empty(), "the buttons do not change the global selection");
}
}
#[test]
fn browser_body_clicks_fill_and_toggle_save_mesh_inputs() {
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
+1 -1
View File
@@ -197,7 +197,7 @@ pub(super) fn rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui:
Kind::Motion(k) => enter |= crate::dialogs_motion::rows(app, ui, k, &mut d.inputs),
Kind::Part(k) => enter |= crate::dialogs_parts::rows(app, ui, k, &d.inputs),
Kind::PartSize(k) => enter |= crate::dialogs_part_size::rows(app, ui, k),
Kind::SaveMesh(k) => enter |= crate::dialogs_save_mesh::rows(app, ui, k),
Kind::SaveMesh(k) => enter |= crate::dialogs_save_mesh::rows(app, ui, k, &mut d.inputs),
Kind::ViewDxf { dashed, tolerance } => crate::dialogs_view_dxf::rows(app, ui, dashed, tolerance),
Kind::InsertDrawing(p) => crate::dialogs_insert_drawing::rows(ui, p),
Kind::Sketch => {
+19 -1
View File
@@ -21,6 +21,7 @@ use crate::SolveApp;
use crate::dialogs::{Kind, form_row};
use crate::selection::{BODIES, SelInput};
use crate::theme::Tokens;
use solidcraft_engine::Sel;
/// The formats, as shown and as `file.save_mesh` names them.
/// (label, `format` parameter, file extension).
@@ -302,8 +303,25 @@ fn paint_icon(ui: &egui::Ui, rect: egui::Rect, tex: Option<egui::TextureId>, nam
}
}
/// Every body of the design, in model order; with `visible`, only the bodies the viewport shows.
pub(crate) fn body_picks(app: &SolveApp, visible: bool) -> Vec<Sel> {
let st = app.session.world_state();
let shown = |name: &str| !visible || app.session.body_visible(name);
st.bodies.iter().filter(|b| shown(&b.name)).map(|b| Sel::Body { name: b.name.clone() }).collect()
}
/// The rows after the Bodies input; true when Enter was pressed in a field.
pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh) -> bool {
pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh, inputs: &mut [SelInput]) -> bool {
// One row each: the two side by side do not fit the dialog's width.
for (label, visible) in [("Add all bodies", false), ("Add visible bodies", true)] {
form_row(ui, "", |ui| {
if crate::ui_kit::button(ui, crate::i18n::tr_label(label), crate::ui_kit::Button::Small).clicked()
&& let Some(input) = inputs.first_mut()
{
input.items = body_picks(app, visible);
}
});
}
if !k.open {
choice_row(ui, "Format", "sm_format", &mut k.format, &FORMATS.map(|f| f.0));
choice_row(ui, "Quality", "sm_quality", &mut k.quality, &QUALITIES.map(|q| q.0));