From af9772fb3c79ee04ed30aad030167cbc5f06e77a Mon Sep 17 00:00:00 2001 From: yhamil04 <147720712+yhamil04@users.noreply.github.com> Date: Thu, 29 Oct 2026 00:26:01 +0000 Subject: [PATCH] Browser: mesh bodies get their own icon and a body-kind tooltip (#6907) (#7059) A mesh body's row (an imported STL, 3MF, OBJ, ...) now shows a new mesh_body icon, a triangulated cube in the mesh accent, instead of the solid body's grey cube. Hovering a body row says Mesh body, Surface body or Solid body. Body::is_mesh() decides; nothing new is saved. Co-authored-by: Claude Opus 5.5 --- assets/icons/ui/design/palette.toml | 3 ++ assets/icons/ui/design/requested_icons.txt | 1 + .../icons/ui/design/svg/model/mesh_body.svg | 12 ++++++ assets/locales/pending/browser-body-kind.json | 37 ++++++++++++++++++ attribution/pending/mesh-body-icon.md | 1 + crates/ui-egui/src/browser.rs | 18 ++++++++- crates/ui-egui/src/browser_card_tests.rs | 38 +++++++++++++++++++ crates/ui-egui/src/ui_kit/tree.rs | 5 ++- 8 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 assets/icons/ui/design/svg/model/mesh_body.svg create mode 100644 assets/locales/pending/browser-body-kind.json create mode 100644 attribution/pending/mesh-body-icon.md diff --git a/assets/icons/ui/design/palette.toml b/assets/icons/ui/design/palette.toml index a8f95ce1a..00674439b 100644 --- a/assets/icons/ui/design/palette.toml +++ b/assets/icons/ui/design/palette.toml @@ -206,3 +206,6 @@ constraint = [ construction = [ "centerline", "construction", "infinite", ] +mesh = [ + "mesh_body", +] diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt index baf4a20e2..eebbcc590 100644 --- a/assets/icons/ui/design/requested_icons.txt +++ b/assets/icons/ui/design/requested_icons.txt @@ -144,6 +144,7 @@ loft false lookat false material false measure false +mesh_body false mesh_export false min_radius false mirror false diff --git a/assets/icons/ui/design/svg/model/mesh_body.svg b/assets/icons/ui/design/svg/model/mesh_body.svg new file mode 100644 index 000000000..5cf51e3b1 --- /dev/null +++ b/assets/icons/ui/design/svg/model/mesh_body.svg @@ -0,0 +1,12 @@ + + Mesh body + + + + + + + + + + diff --git a/assets/locales/pending/browser-body-kind.json b/assets/locales/pending/browser-body-kind.json new file mode 100644 index 000000000..c1e23b817 --- /dev/null +++ b/assets/locales/pending/browser-body-kind.json @@ -0,0 +1,37 @@ +{ + "en": { + "ui.body_kind_mesh": "Mesh body", + "ui.body_kind_solid": "Solid body", + "ui.body_kind_surface": "Surface body" + }, + "ar": { + "ui.body_kind_mesh": "جسم شبكي", + "ui.body_kind_solid": "جسم مصمت", + "ui.body_kind_surface": "جسم سطحي" + }, + "de": { + "ui.body_kind_mesh": "Netzkörper", + "ui.body_kind_solid": "Volumenkörper", + "ui.body_kind_surface": "Flächenkörper" + }, + "he": { + "ui.body_kind_mesh": "גוף רשת משולשים", + "ui.body_kind_solid": "גוף מוצק", + "ui.body_kind_surface": "גוף משטח" + }, + "ja": { + "ui.body_kind_mesh": "メッシュボディ", + "ui.body_kind_solid": "ソリッドボディ", + "ui.body_kind_surface": "サーフェスボディ" + }, + "vi": { + "ui.body_kind_mesh": "Khối lưới (Mesh)", + "ui.body_kind_solid": "Khối đặc", + "ui.body_kind_surface": "Thân bề mặt" + }, + "zh": { + "ui.body_kind_mesh": "网格实体", + "ui.body_kind_solid": "实体", + "ui.body_kind_surface": "曲面实体" + } +} diff --git a/attribution/pending/mesh-body-icon.md b/attribution/pending/mesh-body-icon.md new file mode 100644 index 000000000..9a234d69c --- /dev/null +++ b/attribution/pending/mesh-body-icon.md @@ -0,0 +1 @@ +| assets/icons/ui/design/svg/model/mesh_body.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 | diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index a8fbfeef0..a8c361b26 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -2024,6 +2024,8 @@ struct Entry { patterns: Option, label: String, icon: &'static str, + /// The tooltip's message id, if the row has one ([`Row::tip`]). + tip: Option<&'static str>, visible: bool, selected: bool, color: Option, @@ -2038,14 +2040,23 @@ struct Entry { impl Entry { fn body(app: &SolveApp, b: &solidcraft_engine::doc::ModelBody, world: String) -> Self { + // A mesh body (an imported STL, 3MF, OBJ, …) has no faces to model on; an open shell is a + // surface body, not a solid. + let (icon, tip) = if b.body.is_mesh() { + ("mesh_body", "ui.body_kind_mesh") + } else if b.is_surface() { + ("surface", "ui.body_kind_surface") + } else { + ("body", "ui.body_kind_solid") + }; Self { thing: Thing::Body(world.clone()), key: b.name.clone(), row_key: format!("b:{world}"), patterns: None, label: b.name.clone(), - // An open shell is a surface body, not a solid. - icon: if b.is_surface() { "surface" } else { "body" }, + icon, + tip: Some(tip), visible: !app.session.visibility.hidden_bodies.contains(&world), selected: app.session.selection.iter().any(|s| matches!(s, Sel::Body { name } if name == &world)), color: None, @@ -2076,6 +2087,7 @@ impl Entry { f.name.clone() }, icon: "sketch", + tip: None, visible: sketch_visible(app, f.id), selected: active || app.session.selection.iter().any(|s| matches!(s, Sel::Feature { id } if *id == f.id)), color: if lost { Some(t.error) } else { active.then_some(t.sketch_accent) }, @@ -2101,6 +2113,7 @@ impl Entry { patterns: None, label: f.name.clone(), icon: crate::timeline::icon_of(&f.kind), + tip: None, visible: !app.session.visibility.hidden_origin.contains(&f.name), selected: app.session.selection.contains(&sel), color: None, @@ -2491,6 +2504,7 @@ fn entry_row( fold: pattern_key.map(|_| patterns_open), eye: Some(visible), icon: e.icon, + kind_tip: e.tip, label: &e.label, name: true, selected, diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs index 3a2cec121..39bcd43bd 100644 --- a/crates/ui-egui/src/browser_card_tests.rs +++ b/crates/ui-egui/src/browser_card_tests.rs @@ -443,3 +443,41 @@ fn collapsed_rail_shares_header_hover_inset_and_expands_from_its_whole_card() { } crate::theme::set_dark(previous); } + +/// #6907: a mesh body's row has its own icon and tooltip, so it can be told from a solid one. +#[test] +fn mesh_and_solid_body_rows_have_different_icons_and_tooltips() { + use solidcraft_engine::doc::{Document, FeatureKind, MeshData}; + use solidcraft_engine::geom::Vec3; + let solid = solidcraft_engine::kernel::box_solid(Vec3::ZERO, Vec3::new(10., 10., 10.)).unwrap(); + let mesh = solid.tessellate(0.01).unwrap(); + let mut doc = Document::default(); + doc.add_feature( + FeatureKind::MeshImport { + file: "box.stl".into(), + meshes: vec![MeshData { + name: "Mesh".into(), + positions: mesh.positions.iter().flat_map(|p| [p.x, p.y, p.z]).collect(), + triangles: mesh.triangles.iter().flatten().copied().collect(), + color: None, + }], + }, + Some("Imported mesh"), + ) + .unwrap(); + let mut h = Harness::new(); + h.app.session = solidcraft_engine::Session::new(doc); + h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"corner":[20,0,0],"operation":"new_body","body_name":"Solid"})).unwrap(); + h.settle(); + let rows = entries(&h.app, 0, "bodies"); + let row = |name: &str| rows.iter().find(|e| e.key == name).unwrap_or_else(|| panic!("no {name} row in {:?}", body_rows(&h.app))); + assert_eq!((row("Mesh").icon, row("Mesh").tip), ("mesh_body", Some("ui.body_kind_mesh"))); + assert_eq!((row("Solid").icon, row("Solid").tip), ("body", Some("ui.body_kind_solid"))); + assert_eq!(crate::i18n::tr("ui.body_kind_mesh"), "Mesh body"); + assert_eq!(crate::i18n::tr("ui.body_kind_solid"), "Solid body"); + // Its own drawing in the mesh colours, not the solid body's grey cube. + let icon = crate::icon_svg::resolve("mesh_body"); + assert!(!icon.placeholder); + assert_ne!(icon.master, crate::icon_svg::resolve("body").master); + assert_eq!(icon.accent, crate::icon_svg::accent_index("mesh")); +} diff --git a/crates/ui-egui/src/ui_kit/tree.rs b/crates/ui-egui/src/ui_kit/tree.rs index fb1279865..64af19714 100644 --- a/crates/ui-egui/src/ui_kit/tree.rs +++ b/crates/ui-egui/src/ui_kit/tree.rs @@ -42,6 +42,8 @@ pub(crate) struct Row<'a> { pub(crate) badges: &'a [&'a str], /// A button right after the name: (icon, tooltip label), e.g. a feature's profile sketch. pub(crate) action: Option<(&'a str, &'a str)>, + /// A message id the row's tooltip names it by (a body row: mesh, surface or solid body). + pub(crate) kind_tip: Option<&'a str>, /// Lit by the selection or the 3D view's pointer: the item's own row, or a row leading to it. pub(crate) mark: Mark, /// Optional document appearance and shared trailing text slots. @@ -306,7 +308,8 @@ pub(crate) fn tree_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp { 3 => Some(if row.radio == Some(true) { crate::i18n::tr("ui.active_component") } else { crate::i18n::tr("ui.activate") }), _ => None, }; - let resp = match (tip, row.tip) { + let state = row.kind_tip.map(crate::i18n::tr).or(row.tip); + let resp = match (tip, state) { (Some(t), _) => resp.on_hover_text(t), (None, Some(state)) if elided => resp.on_hover_text(format!("{label_display}\n{state}")), (None, Some(state)) => resp.on_hover_text(state),