SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Browser: mesh bodies get their own icon and a body-kind tooltip (#6907) (#7059)
yhamil04af9772fb3c79
diff --git a/assets/icons/ui/design/palette.toml b/assets/icons/ui/design/palette.tomlindex a8f95ce1a6..00674439bb 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.txtindex baf4a20e2b..eebbcc5906 100644--- a/assets/icons/ui/design/requested_icons.txt+++ b/assets/icons/ui/design/requested_icons.txt@@ -144,6 +144,7 @@ loft falselookat falsematerial falsemeasure false+mesh_body falsemesh_export falsemin_radius falsemirror falsediff --git a/assets/icons/ui/design/svg/model/mesh_body.svg b/assets/icons/ui/design/svg/model/mesh_body.svgnew file mode 100644index 0000000000..5cf51e3b1c--- /dev/null+++ b/assets/icons/ui/design/svg/model/mesh_body.svg@@ -0,0 +1,12 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Mesh body</title>+ <path d="M8.62 18.5L32 32L32 59L8.62 45.5Z" fill="#328bd3"/>+ <path d="M55.38 18.5L32 32L32 59L55.38 45.5Z" fill="#236ead"/>+ <path d="M32 5L55.38 18.5L32 32L8.62 18.5Z" fill="#b9ddf8"/>+ <path d="M8.62 18.5L55.38 18.5" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+ <path d="M8.62 18.5L32 59" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+ <path d="M55.38 18.5L32 59" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+ <path d="M32 5L55.38 18.5L55.38 45.5L32 59L8.62 45.5L8.62 18.5Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+ <path d="M8.62 18.5L32 32L55.38 18.5" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+ <path d="M32 32L32 59" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>+</svg>diff --git a/assets/locales/pending/browser-body-kind.json b/assets/locales/pending/browser-body-kind.jsonnew file mode 100644index 0000000000..c1e23b8179--- /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.mdnew file mode 100644index 0000000000..9a234d69c1--- /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.rsindex a8fbfeef03..a8c361b268 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -2024,6 +2024,8 @@ struct Entry {patterns: Option<String>,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<Color32>,@@ -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.rsindex 3a2cec1213..39bcd43bd5 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.rsindex fb1279865d..64af197146 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),