diff --git a/assets/icons/mesh.hex.blocks.svg b/assets/icons/mesh.cells.svg similarity index 100% rename from assets/icons/mesh.hex.blocks.svg rename to assets/icons/mesh.cells.svg diff --git a/assets/icons/mesh.hex.blocks.vectorcraft b/assets/icons/mesh.cells.vectorcraft similarity index 100% rename from assets/icons/mesh.hex.blocks.vectorcraft rename to assets/icons/mesh.cells.vectorcraft diff --git a/assets/icons/mesh.hex.mapped.svg b/assets/icons/mesh.hex.generate.svg similarity index 100% rename from assets/icons/mesh.hex.mapped.svg rename to assets/icons/mesh.hex.generate.svg diff --git a/assets/icons/mesh.hex.mapped.vectorcraft b/assets/icons/mesh.hex.generate.vectorcraft similarity index 100% rename from assets/icons/mesh.hex.mapped.vectorcraft rename to assets/icons/mesh.hex.generate.vectorcraft diff --git a/assets/icons/mesh.hex.sweep.svg b/assets/icons/mesh.hex.sweep.svg deleted file mode 100644 index 4a5494e..0000000 --- a/assets/icons/mesh.hex.sweep.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - mesh.hex.sweep - - - - - - - diff --git a/assets/icons/mesh.hex.sweep.vectorcraft b/assets/icons/mesh.hex.sweep.vectorcraft deleted file mode 100644 index 82fb4de..0000000 Binary files a/assets/icons/mesh.hex.sweep.vectorcraft and /dev/null differ diff --git a/assets/icons/src/mesh.hex.blocks.json b/assets/icons/src/mesh.cells.json similarity index 100% rename from assets/icons/src/mesh.hex.blocks.json rename to assets/icons/src/mesh.cells.json diff --git a/assets/icons/src/mesh.hex.mapped.json b/assets/icons/src/mesh.hex.generate.json similarity index 100% rename from assets/icons/src/mesh.hex.mapped.json rename to assets/icons/src/mesh.hex.generate.json diff --git a/assets/icons/src/mesh.hex.sweep.json b/assets/icons/src/mesh.hex.sweep.json deleted file mode 100644 index 571b39a..0000000 --- a/assets/icons/src/mesh.hex.sweep.json +++ /dev/null @@ -1 +0,0 @@ -{"shapes": [{"rect": [3, 8, 9, 9], "fill": "soft", "stroke": "line"}, {"d": "M7.5 8 L7.5 17 M3 12.5 L12 12.5", "stroke": "line", "width": 1}, {"d": "M3 8 L8 4 L21 4 L21 13 L12 17 M12 8 L21 4", "stroke": "line", "width": 1.25}, {"d": "M14 13 L20 10 M18.17 12.63 L20 10 L16.8 9.88", "stroke": "accent", "width": 1.5}]} diff --git a/crates/engine/src/cmd/forms.rs b/crates/engine/src/cmd/forms.rs index ccbf518..59ec434 100644 --- a/crates/engine/src/cmd/forms.rs +++ b/crates/engine/src/cmd/forms.rs @@ -999,7 +999,11 @@ pub const HEX_GENERATE: &[Field] = &[ "Method", &[("auto", "Automatic"), ("swept", "Any sweep"), ("extrude", "Extrude"), ("sweep", "Sweep"), ("revolve", "Revolve"), ("mapped", "Mapped")], ) - .help("How to build the hexes: automatic, or a sweep, extrusion, revolution or mapped mesh.") + .help( + "How to build the hexes. Automatic tries, in order, an extrusion, a sweep, a revolution and a mapped block, and \ + uses the first that fits; Any sweep tries the first three.", + ) + .notes(HEX_METHOD_NOTES) .def("\"auto\""), TOLERANCE, WELD, @@ -1007,6 +1011,16 @@ pub const HEX_GENERATE: &[Field] = &[ FEATURE_ANGLE, ]; +/// What each structured hex method needs of the body, one line each. +const HEX_METHOD_NOTES: &[(&str, &str)] = &[ + ("auto", "Automatic: the first of Extrude, Sweep, Revolve and Mapped that fits the body."), + ("swept", "Any sweep: the first of Extrude, Sweep and Revolve that fits the body."), + ("extrude", "Extrude: the body must be one cross-section carried along a straight direction (levels allowed)."), + ("sweep", "Sweep: a source face carried to a target face through four-sided linking faces."), + ("revolve", "Revolve: the body must be one cross-section turned around an axis."), + ("mapped", "Mapped: the body must have six sides, each with four edges (curved faces allowed)."), +]; + pub const HEX_SWEEP: &[Field] = &[ BODY, SURFACE, @@ -1014,6 +1028,7 @@ pub const HEX_SWEEP: &[Field] = &[ HEX_ORDER, choice("method", "Method", &[("swept", "Any sweep"), ("extrude", "Extrude"), ("sweep", "Sweep"), ("revolve", "Revolve")]) .help("How to sweep: any sweep, extrusion, sweep along a path or revolution.") + .notes(HEX_METHOD_NOTES) .def("\"swept\""), TOLERANCE, WELD, @@ -1039,8 +1054,13 @@ pub const CELLS: &[Field] = &[ json("methods", "Methods") .help("The meshing method per cell, as JSON.") .hint(r#"{"cell": "auto | hex | swept | extrude | sweep | revolve | mapped | tet"}"#), - choice("default", "Other cells", &[("auto", "Auto (hex, else tet)"), ("hex", "Hex"), ("swept", "Swept"), ("mapped", "Mapped"), ("tet", "Tet")]) - .help("The method for cells not listed in Methods.") + choice( + "default", + "Other cells", + &[("auto", "Auto (hex, else tet)"), ("hex", "Hex"), ("swept", "Swept"), ("mapped", "Mapped"), ("tet", "Tet"), ("blocks", "All hex (conforming blocks)")], + ) + .help("The method for cells not listed in Methods. All hex meshes every cell as a mapped block, with the division counts of all cells assigned together so shared faces match (mesh.hex.blocks).") + .notes(&[("blocks", "All hex: every cell must have six sides, each with four edges; leave Methods empty.")]) .def("\"auto\""), references("bodies", "Cells", C::Body).help("The cells (bodies) to mesh; every body of the design when empty.").hint("every body of the design"), HEX_SIZE, diff --git a/crates/engine/src/schema.rs b/crates/engine/src/schema.rs index bc60f1f..17154d9 100644 --- a/crates/engine/src/schema.rs +++ b/crates/engine/src/schema.rs @@ -36,6 +36,9 @@ pub struct Field { /// What the field means, in a sentence or two, with a typical value: the form's tooltip and /// the JSON Schema description. The unit is added from the field's dimension ([`Field::help_text`]). pub help: &'static str, + /// For a [`Kind::Choice`]: a one-line note per option value (what it needs), shown under the + /// field for the option chosen. + pub notes: &'static [(&'static str, &'static str)], } /// What a field holds. @@ -306,7 +309,7 @@ impl Dim { // ---- Building fields (const, so schemas are static tables) ---- const fn field(key: &'static str, label: &'static str, kind: Kind) -> Field { - Field { key, label, kind, required: false, default: None, hint: "", help: "" } + Field { key, label, kind, required: false, default: None, hint: "", help: "", notes: &[] } } impl Field { @@ -327,6 +330,16 @@ impl Field { Field { help, ..self } } + /// A one-line note per option value ([`Field::notes`]). + pub const fn notes(self, notes: &'static [(&'static str, &'static str)]) -> Field { + Field { notes, ..self } + } + /// The note for this option value (the default when `None`). + pub fn note(&self, value: Option<&str>) -> Option<&'static str> { + let value = value.or_else(|| self.default.map(|d| d.trim_matches('"')))?; + self.notes.iter().find(|(v, _)| *v == value).map(|(_, n)| *n) + } + /// Its physical dimension, for a number or a vector of numbers. pub fn dim(&self) -> Option { match self.kind { diff --git a/crates/ui-egui/src/form.rs b/crates/ui-egui/src/form.rs index 0b83e24..6656034 100644 --- a/crates/ui-egui/src/form.rs +++ b/crates/ui-egui/src/form.rs @@ -226,6 +226,9 @@ impl Form<'_> { }; self.touch(&path); } + if let Some(note) = f.note(obj.get(f.key).and_then(Value::as_str)) { + fields::note(ui, &self.style, note, self.style.dim); + } if let Kind::Either(options) = f.kind { self.either_value(ui, f, options, obj, &path); }