Skip to main content

brep_app/workbench/
assembly.rs

1//! The "Assembly" workbench — assemblies build-spec §8.1.
2//!
3//! Creatable set: the shared building blocks (sketch `S` / datum `D` / plane
4//! `P`) plus the ASSEMBLY COMPONENT (`ACOMP`) — in-context sketches on
5//! component faces are an allowed reference use (spec §3), so S/D/P stay
6//! creatable here. Everything else (modeling + sheet metal) is filtered out of
7//! the creation UI; the history itself stays fully visible/editable regardless
8//! of workbench (standing rule).
9//!
10//! Claims the two assembly panels (Assembly Structure tree + Assembly
11//! Constraints), which therefore show ONLY under Assembly (and "All").
12
13use super::{FeatureInfo, Workbench, WorkbenchButton};
14
15/// The Assembly Structure tree panel's id (claim + registration key).
16/// The Assembly Constraints panel's id (the requirements-§5 record id).
17pub const CONSTRAINTS_PANEL_ID: &str = "assemblyConstraints";
18/// The BOM panel's id (the columned parts list).
19pub const BOM_PANEL_ID: &str = "assemblyBom";
20
21/// Datum / Plane / Sketch / Component (`ACOMP`).
22fn includes(feature: &FeatureInfo<'_>) -> bool {
23    matches!(feature.type_code, "S" | "D" | "P" | "ACOMP")
24}
25
26/// The assembly toolbar tools. A click surfaces the button id out of the
27/// toolbar to the shell: `"assembly.add_component"` opens the insert-component
28/// modal (the same `FileAction::InsertComponent` flow the ACOMP palette pick
29/// routes through), `"assembly.auto_constrain"` opens the inference window and
30/// scans the current placement, and `"assembly.interference"` (build-spec §9)
31/// runs the engine's pairwise check and opens the results window. Like every workbench button,
32/// "All" carries them automatically via the deduped union.
33static BUTTONS: &[WorkbenchButton] = &[
34    WorkbenchButton {
35        id: "assembly.add_component",
36        // ⊕ (U+2295, circled plus) — ADD a part instance; renders in the
37        // bundled DejaVu font (no tofu).
38        glyph: "\u{2295}",
39        tooltip: "Add component (insert a part from the library or a saved model)",
40    },
41    WorkbenchButton {
42        id: "assembly.step_parts_library",
43        // `menu_book` Material Symbol (base glyph U+1F4DA) — the online
44        // step.parts library. `toolbar_button` auto-renders it as a layered
45        // colour icon straight from the SVG catalog.
46        glyph: "\u{1F4DA}",
47        tooltip: "step.parts library — browse & import an online STEP part as a component",
48    },
49    WorkbenchButton {
50        id: "assembly.auto_constrain",
51        // Our own artwork (U+E067): two parts closing on a shared axis with the
52        // inference spark. Catalogued SVG, like every picture the app draws.
53        glyph: "\u{E067}",
54        tooltip: "Auto constraints \u{2014} infer mates (concentric, touch align, coincident) from where the components already sit",
55    },
56    WorkbenchButton {
57        id: "assembly.interference",
58        // ∩ (U+2229, intersection) — the pairwise-INTERSECT tool; renders in the
59        // bundled DejaVu font (no tofu).
60        glyph: "\u{2229}",
61        tooltip: "Interference check (pairwise intersect)",
62    },
63];
64
65/// The assembly panels this workbench claims (claim-based visibility —
66/// unclaimed panels stay visible everywhere; these show only here + All).
67static PANELS: &[&str] = &[CONSTRAINTS_PANEL_ID, BOM_PANEL_ID];
68
69pub static ASSEMBLY: Workbench = Workbench {
70    id: "assembly",
71    label: "Assembly",
72    glyph: "\u{E064}",
73    includes,
74    buttons: BUTTONS,
75    panels: PANELS,
76};