diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index c4a1b76..469c115 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -164,6 +164,8 @@ pub enum Def { ReferencePoint, Coupling, Contact, + /// A tie between two surfaces (`interaction.tie`). + Tie, FluidDomain, /// A datum plane, axis or point. Datum, @@ -171,7 +173,7 @@ pub enum Def { } impl Def { - pub const ALL: [Def; 12] = [ + pub const ALL: [Def; 13] = [ Def::Set, Def::Material, Def::Section, @@ -181,6 +183,7 @@ impl Def { Def::ReferencePoint, Def::Coupling, Def::Contact, + Def::Tie, Def::FluidDomain, Def::Datum, Def::Partition, @@ -195,6 +198,7 @@ impl Def { Def::ReferencePoint => Definition::ReferencePoint, Def::Coupling => Definition::Coupling, Def::Contact => Definition::Contact, + Def::Tie => Definition::Tie, Def::Step => Definition::Step, Def::Set | Def::Material | Def::Section | Def::FluidDomain | Def::Datum | Def::Partition => return None, }) @@ -212,6 +216,7 @@ impl Def { Def::ReferencePoint => Collection::ReferencePoint, Def::Coupling => Collection::Coupling, Def::Contact => Collection::Contact, + Def::Tie => Collection::Tie, Def::FluidDomain => Collection::FluidDomain, Def::Datum => Collection::Datum, Def::Partition => Collection::Partition, @@ -230,6 +235,7 @@ impl Def { Def::ReferencePoint => "reference_point", Def::Coupling => "coupling", Def::Contact => "contact", + Def::Tie => "tie", Def::FluidDomain => "fluid_domain", Def::Datum => "datum", Def::Partition => "partition", @@ -247,6 +253,7 @@ impl Def { Def::ReferencePoint => "Reference Point", Def::Coupling => "Coupling", Def::Contact => "Contact", + Def::Tie => "Tie", Def::FluidDomain => "Fluid Domain", Def::Datum => "Datum", Def::Partition => "Partition", @@ -265,6 +272,7 @@ impl Def { Def::ReferencePoint => "model.reference_point.create", Def::Coupling => "model.coupling.create", Def::Contact => "interaction.contact.pair", + Def::Tie => "interaction.tie", Def::FluidDomain => "model.fluid_domain.create", Def::Datum => "geometry.datum", Def::Partition => "geometry.partition", @@ -278,6 +286,8 @@ impl Def { match (self, verb) { (Def::Contact, "create") => "interaction.contact.pair".into(), (Def::Contact, _) => format!("interaction.contact.{verb}"), + (Def::Tie, "create") => "interaction.tie".into(), + (Def::Tie, _) => format!("interaction.tie.{verb}"), (Def::Datum | Def::Partition, "create") => self.icon().into(), (Def::Datum | Def::Partition, _) => format!("geometry.{}.{verb}", self.stem()), _ => format!("model.{}.{verb}", self.stem()), @@ -331,7 +341,7 @@ impl Def { Def::ReferencePoint => m.reference_point_users(name), Def::FluidDomain => m.fluid_domain_users(name), Def::Datum => m.datum_users(name), - Def::Section | Def::Step | Def::Coupling | Def::Contact | Def::Partition => Vec::new(), + Def::Section | Def::Step | Def::Coupling | Def::Contact | Def::Tie | Def::Partition => Vec::new(), } } @@ -347,6 +357,7 @@ impl Def { Def::ReferencePoint => m.reference_points().len(), Def::Coupling => m.couplings().len(), Def::Contact => m.contacts().len(), + Def::Tie => m.ties().len(), Def::FluidDomain => m.fluid_domains().len(), Def::Datum => m.datums().len(), Def::Partition => m.partitions().len(), @@ -365,6 +376,7 @@ impl Def { Def::ReferencePoint => m.reference_points().contains_key(name), Def::Coupling => m.couplings().contains_key(name), Def::Contact => m.contacts().contains_key(name), + Def::Tie => m.tie(name).is_some(), Def::FluidDomain => m.fluid_domain(name).is_some(), Def::Datum => m.datum(name).is_some(), Def::Partition => m.partitions().iter().any(|p| p.name == name), @@ -383,6 +395,7 @@ impl Def { Def::ReferencePoint => m.reference_points().keys().cloned().collect(), Def::Coupling => m.couplings().keys().cloned().collect(), Def::Contact => m.contacts().keys().cloned().collect(), + Def::Tie => m.ties().keys().cloned().collect(), Def::FluidDomain => m.fluid_domains().keys().cloned().collect(), Def::Datum => m.datums().keys().cloned().collect(), Def::Partition => m.partitions().iter().map(|p| p.name.clone()).collect(), @@ -402,6 +415,7 @@ pub fn definition(m: &Model, kind: Def, name: &str) -> Option { Def::ReferencePoint => serde_json::to_value(m.reference_points().get(name)?), Def::Coupling => serde_json::to_value(m.couplings().get(name)?), Def::Contact => serde_json::to_value(m.contacts().get(name)?), + Def::Tie => serde_json::to_value(m.tie(name)?), Def::FluidDomain => serde_json::to_value(m.fluid_domain(name)?), Def::Datum => serde_json::to_value(m.datum(name)?), Def::Partition => serde_json::to_value(m.partitions().iter().find(|p| p.name == name)?), @@ -932,7 +946,7 @@ fn rows(app: &mut ModelApp, ui: &mut egui::Ui, acts: &mut Vec) { ("sections", "Sections", &[Def::Section]), ("steps", "Steps", &[Def::Step]), ("loads", "Loads & BCs", &[Def::BoundaryCondition, Def::Load]), - ("interactions", "Interactions", &[Def::ReferencePoint, Def::Coupling, Def::Contact]), + ("interactions", "Interactions", &[Def::ReferencePoint, Def::Coupling, Def::Contact, Def::Tie]), ("fluids", "Fluid Domains", &[Def::FluidDomain]), ]; for (key, label, kinds) in groups { @@ -1101,6 +1115,18 @@ mod tests { assert_eq!(item_icon(&s.model, Def::Load, "Air").0, "model.step.heat"); } + /// Ties are listed under Interactions, read back and edited like the others (#366). + #[test] + fn ties_are_interactions() { + let mut app = ModelApp::new(Session::default()); + app.run_script(&fieldcraft_engine::sample::cantilever()).unwrap(); + let sets = Def::Set.names(&app.session.model); + app.run("interaction.tie", json!({"name": "glue", "main": sets[0], "secondary": sets[1]})).unwrap(); + assert_eq!(Def::Tie.names(&app.session.model), ["glue"]); + assert_eq!(Def::Tie.edit(&app.session.model, "glue").map(|(c, _)| c).as_deref(), Some("interaction.tie.edit")); + assert!(crate::describe::rows(&app.session.model, Def::Tie, "glue").is_some_and(|r| !r.is_empty())); + } + #[test] fn definitions_read_back_as_their_parameters() { let mut app = ModelApp::new(Session::default()); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 58d912c..46565cd 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -41,13 +41,13 @@ commands (files, undo, `model.info`) leave the ribbon where it is. | Method | Params | Notes | |---|---|---| -| `ui.inspect` | — | view settings (`ui`), camera, viewport rect (points), renderer (`gpu`/`cpu`) and adapter, open command form, status bar, node and element counts, the results display (`results`: what the `results.*` commands reply: view, `stale`, contour range, modes), the probed node (`probe`), `solve` (the title bar's Solve: `enabled`, and `unavailable` as `ui.toolbar`'s entries give it, listing everything `solve.run` misses), `busy` (the background job: a file opening, a solve, a mesher run from its form by a click on OK), `prompt` (`{"unsaved": path}`, `{"design": path}` (a design of another part opened over a meshed or defined model), `"recover"`, `"samples"`), `recent` (recent files), `updates` (docs/updates.md: `automatic`, `checked_at`, `skip`, `available` (a newer version the status bar offers), `busy`, `staged`, `unsupported`; null when the run does not check), `selected` (the browser's selected definition), `browser` (each top-level browser node's setup state: `[{node, state, tip, add}]`, `state` `done`, `next`, `blocked` (⚠: its command cannot run yet; `tip` says what it needs and where), `todo`, `optional` or null for nodes that are no setup stage, `add` its ghost rows `{stage, label, command, status}`; a ghost row's region is `layout`'s `browser/add/`), `nav` (the left-drag mode), `layout` (each region of the window drawn last frame as `[x, y, w, h]` in points: `app_bar`, `ribbon`, `workspace_switcher`, `document_tab`, `app_bar:`, `browser`, `viewport`, `nav_bar`, `axis_view`, `selection_bar`, `legend` (while results are shown), `context`, `command_line`, `timeline`, `toolbar_dropdown`, `palette`), version | +| `ui.inspect` | — | view settings (`ui`), camera, viewport rect (points), renderer (`gpu`/`cpu`) and adapter, open command form, status bar, node and element counts, the results display (`results`: what the `results.*` commands reply: view, `stale`, contour range, modes), the probed node (`probe`), `solve` (the title bar's Solve: `enabled`, and `unavailable` as `ui.toolbar`'s entries give it, listing everything `solve.run` misses), `busy` (the background job: a file opening, a solve, a mesher run from its form by a click on OK), `prompt` (`{"unsaved": path}`, `{"design": path}` (a design of another part opened over a meshed or defined model), `"recover"`, `"samples"`), `recent` (recent files), `updates` (docs/updates.md: `automatic`, `checked_at`, `skip`, `available` (a newer version the status bar offers), `busy`, `staged`, `unsupported`; null when the run does not check), `selected` (the browser's selected definition `{kind, name}`, or seed `{kind: "seed", edge}`), `browser` (each top-level browser node's setup state: `[{node, state, tip, add}]`, `state` `done`, `next`, `blocked` (⚠: its command cannot run yet; `tip` says what it needs and where), `todo`, `optional` or null for nodes that are no setup stage, `add` its ghost rows `{stage, label, command, status}`; a ghost row's region is `layout`'s `browser/add/`), `nav` (the left-drag mode), `layout` (each region of the window drawn last frame as `[x, y, w, h]` in points: `app_bar`, `ribbon`, `workspace_switcher`, `document_tab`, `app_bar:`, `browser`, `viewport`, `nav_bar`, `axis_view`, `selection_bar`, `legend` (while results are shown), `context`, `command_line`, `timeline`, `toolbar_dropdown`, `palette`), version | | `ui.set` | any view setting: `style` (`shaded_edges`, `shaded`, `wireframe`), `show_nodes`, `show_geometry`, `show_mesh`, `show_loads` (boundary condition and load symbols), `show_interactions` (reference points, couplings, contact and tie surfaces, rigid walls), `symbol_size` (the setup symbols' size on screen in points, 6–48, at any zoom), `perspective`, `dark`, `show_tree` (the browser), `show_timeline`, `nav_preset` (the mouse navigation: `fieldcraft`, `fusion`, `solidworks`, `inventor`, `alias`, `tinkercad`, `openscad`; an unknown id acts as `fieldcraft`) and `reverse_zoom` (both remembered per user), `workspace` (`prepare`, `model`, `analysis`, `results`), `tab` (the toolbar tab: `geometry`, `mesh`, `properties`, `assembly`, `steps`, `loads`, `interactions`, `solve`, `results`, `tools`; a tab of another workspace brings that workspace), `palette` (the command search open), `menu` (the open menu: `file`, `help`, `workspace`, `view`, `more`, or a panel's drop-down as `/` such as `mesh/Tet`; `null` closes it) | an unknown setting or value is an error; returns the settings | | `ui.view` | `view`: `front`, `back`, `left`, `right`, `top`, `bottom`, `iso`, `home` (iso and fit), `fit` | every view frames the model as drawn (the deformed shape included; the setup's symbols keep their size on screen and are not framed) in the part of the viewport the overlays (`layout`'s `legend`, `selection_bar`, `axis_view`, `nav_bar`) leave free; `fit` keeps the direction of view. Opening another model, sample or design frames it in the home view (the same design opened again after an edit keeps the camera), and results that come up with part of the model out of sight are framed. Returns the camera | | `ui.camera` | `yaw`, `pitch` (degrees), `distance?` (model units) | turns the camera to any orientation about its target: `yaw` about Z (0 looks along +Y, the front view; −45 is the iso view's, −90 the right view's), `pitch` the elevation above the XY plane; `distance` moves the eye (the zoom of an orthographic view). Angles must be finite and the distance above 0: the yaw is wrapped, the pitch clamped to ±90 and the distance to 0.001–10⁹; anything else is an error. A sequence of calls orbits smoothly. Returns the camera (`ui.inspect`'s, angles in radians) | | `ui.toolbar` | — | the ribbon: `workspace`, `workspaces`, `tab`, `tabs` (the workspace's), `menu` (the open menu), `panels` (each panel label's `menu` key and `rect`), and every catalogue entry (docs/features.md) with `id`, `label`, `tab`, `panel`, `command` (null while coming soon), `more` (its related commands), `coming_soon` (the milestone, or null), `enabled` (false while coming soon or while its command misses what it needs), `unavailable` (null, or what its command misses: `reason`, the tooltip's lines such as "Needs a material — Properties › Material", and `missing`, each with `requirement`, `what`, `provider` (the command that provides it) and `place` (its toolbar entry)), `fit` — `full` (a button), `collapsed` (its panel is one button), `more` (its panel is in the » menu) or `menu` (in its panel's drop-down) — and `rect` (screen points, last frame, on the shown tab; for `menu` entries the row while the drop-down is open) | | `ui.start` | `command`: a command or toolbar entry id | like a click on the toolbar, a drop-down row or a search result: a command without parameters runs, one with parameters opens its form in the context panel; an entry that is coming soon is an error naming its milestone. Never opens a native file picker: file entries (open, save as, write deck) open their command's form | -| `ui.select` | `kind` (`set`, `material`, `section`, `step`, `boundary_condition`, `load`, `reference_point`, `coupling`, `fluid_domain`), `name`; nothing to deselect | selects a definition as a browser click does; its properties (with Edit and Delete) show in the context panel | +| `ui.select` | `kind` (`set`, `material`, `section`, `step`, `boundary_condition`, `load`, `reference_point`, `coupling`, `contact`, `tie`, `fluid_domain`), `name`; nothing to deselect | selects a definition as a browser click does; its properties (with Edit and Delete) show in the context panel | | `ui.select` (viewport) | any of `filter`, `box_mode`, `mode`, `clear`, `at`, `box`, `geometry`, `nodes`, `elements`, `faces` (and no `kind`) | changes the viewport's selection (see [Selection](#selection)); returns `ui.selection`'s reply | | `ui.selection` | — | the viewport's selection: `filter`, `box_mode` (box selection on), `count`, `capped`, `summary`, `items`, `params` (the selection as a set's members), `hover` (what a click would pick under the pointer) | | `ui.prompt` | `answer`: for `unsaved` `save`, `discard` or `cancel`; for `design` `new` (a new model with the design), `keep` (the design over the current model) or `cancel`; for `replace_mesh` `replace` (runs the form, replacing the mesh) or `cancel` (the form stays open); for `delete` (the item menu's Delete… or the Delete key: `{delete: question, kind, name, users, allowed}`) `delete` (with a datum's partitions when it has any; refused when `allowed` is false) or `cancel`; for `recover` `recover` (with `id` from `file.recovery.list`) or `close`; for `samples` `open` (with `name`) or `close`; for `crashed` (the start after a crash: `{crashed: [reports]}`) `report` (opens Report a Bug for the newest) or `close`; for `report_bug` (`{report_bug: draft}`) `set` (any of `title`, `observed`, `share_session`, `include_model`; replies with the draft) or `close` — the browser opens only from a click (docs/crash-reports.md); for `consent` (the first run's question about anonymous usage) `share` or `decline`; for `settings` (Help › Settings…) `set` (any of `usage_sharing`, `usage_automation`; or `update_check`, `update_skip` (a version, `""` for none)) or `close` (docs/privacy.md, docs/updates.md); for `update` (a downloaded and verified update: `{update: state}`) `restart` (saves or asks about unsaved changes first, then closes the window to install) or `later` (installs when the app quits) | answers the window's question (`ui.inspect`'s `prompt`) |