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 <noreply@anthropic.com>
This commit is contained in:
@@ -206,3 +206,6 @@ constraint = [
|
||||
construction = [
|
||||
"centerline", "construction", "infinite",
|
||||
]
|
||||
mesh = [
|
||||
"mesh_body",
|
||||
]
|
||||
|
||||
@@ -144,6 +144,7 @@ loft false
|
||||
lookat false
|
||||
material false
|
||||
measure false
|
||||
mesh_body false
|
||||
mesh_export false
|
||||
min_radius false
|
||||
mirror false
|
||||
|
||||
@@ -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>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -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": "曲面实体"
|
||||
}
|
||||
}
|
||||
@@ -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 |
|
||||
@@ -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,
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user