forked from 1b-agent/fieldcraft-upstream
Forms: a one-line note per choice; the hex Method says what each needs
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
1 parent
ad84a52ed2
commit
2d5dfb2137
12 files changed
+40
-15
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
|
||||
<title>mesh.hex.sweep</title>
|
||||
<g id="Layer_1" data-name="Layer 1">
|
||||
<path d="M3 8 L12 8 L12 17 L3 17 Z" fill="#2d4e70" stroke="#dde2ea" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M7.5 8 L7.5 17 M3 12.5 L12 12.5" fill="none" stroke="#dde2ea" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M3 8 L8 4 L21 4 L21 13 L12 17 M12 8 L21 4" fill="none" stroke="#dde2ea" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M14 13 L20 10 M18.17 12.63 L20 10 L16.8 9.88" fill="none" stroke="#4f9ce8" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 825 B |
Binary file not shown.
File renamed without changes.
File renamed without changes.
@@ -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}]}
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user