Forms: a one-line note per choice; the hex Method says what each needs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-14 22:35:17 -04:00
1 parent ad84a52ed2
commit 2d5dfb2137
12 files changed
+40 -15

No files matched your search

+23 -3
View File
@@ -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,
+14 -1
View File
@@ -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<Dim> {
match self.kind {