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.interference"` (build-spec §9) runs the engine's
30/// pairwise check and opens the results window. Like every workbench button,
31/// "All" carries them automatically via the deduped union.
32static BUTTONS: &[WorkbenchButton] = &[
33    WorkbenchButton {
34        id: "assembly.add_component",
35        // ⊕ (U+2295, circled plus) — ADD a part instance; renders in the
36        // bundled DejaVu font (no tofu).
37        glyph: "\u{2295}",
38        tooltip: "Add component (insert a part from the library or a saved model)",
39    },
40    WorkbenchButton {
41        id: "assembly.step_parts_library",
42        // `menu_book` Material Symbol (base glyph U+1F4DA) — the online
43        // step.parts library. `toolbar_button` auto-renders it as a layered
44        // colour icon straight from the SVG catalog.
45        glyph: "\u{1F4DA}",
46        tooltip: "step.parts library — browse & import an online STEP part as a component",
47    },
48    WorkbenchButton {
49        id: "assembly.interference",
50        // ∩ (U+2229, intersection) — the pairwise-INTERSECT tool; renders in the
51        // bundled DejaVu font (no tofu).
52        glyph: "\u{2229}",
53        tooltip: "Interference check (pairwise intersect)",
54    },
55];
56
57/// The assembly panels this workbench claims (claim-based visibility —
58/// unclaimed panels stay visible everywhere; these show only here + All).
59static PANELS: &[&str] = &[CONSTRAINTS_PANEL_ID, BOM_PANEL_ID];
60
61pub static ASSEMBLY: Workbench = Workbench {
62    id: "assembly",
63    label: "Assembly",
64    includes,
65    buttons: BUTTONS,
66    panels: PANELS,
67};