Mechanism Builder Page
The Mechanism Builder page edits a standalone GeneralMechanism — its anchor topology, per-branch ITransformer, and per-anchor optional TransformationGeom inside a Solid. Unlike the project-scoped editors (Fixture / Workpiece / ToolHouse / Spindle Capability), this page is user-scoped — no project needs to be loaded.
- Key Model: GeneralMechanism
- Related Model:
- GeneralXyzabcChain + GeneralXyzabcMachineTool (used by “Save As Machine Tool”)
Layout
- Mechanism Builder Page
- File Menu
- New — discards the current mechanism and starts an empty one.
- Load… —
<input type=file>picks a local XML; POSTs its content to the backend. - Reload — re-reads the file last loaded from disk (only available after a prior disk load).
- Save As General Mechanism — downloads a
.general-mechXML via Blob. - Save As Xyzabc Machine Tool — wraps the mechanism in a GeneralXyzabcMachineTool and downloads as
.mt.
- Three-Column Layout (
<q-splitter>× 2)- Graph Panel (left) — mermaid diagram of anchors (nodes) + branches (edges); node / edge click selects.
- Editor Panel (middle) — content depends on selection:
- Anchor selected: inline rename + “Add Branch ▾” dropdown + optional TransformationGeom attach / detach. While attached, the panel embeds Geometry Management Control restricted to TransformationGeom; the inner
Box3d/Cylindroid/StlFile/CubeTreeFileremain reachable inside theTransformationGeomEditor'sGeomslot. - Branch selected: inline rename + Transformer Select Panel (7 transformer kinds).
- Anchor selected: inline rename + “Add Branch ▾” dropdown + optional TransformationGeom attach / detach. While attached, the panel embeds Geometry Management Control restricted to TransformationGeom; the inner
- Viewer Panel (right) — RenderingCanvas Tool Bar +
RenderingCanvasbound toDelegateFuncDisplayee(() => MechService.GeneralMechanism as IDisplayee).
- File Menu
Behavior
- New-anchor auto-naming. Newly-created anchors receive placeholder names (
NewAnchor-001,NewAnchor-002, …). Inline rename is debounced 400 ms. - Branch add filter. The “Add Branch ▾” dropdown inside the anchor editor filters out the selected anchor itself and anchors already directly connected.
- Root protection. The root anchor cannot be deleted; double-click delete on any other anchor works.
- Branch transformer swap.
TransformerSelectPaneluses a parent-awareonCreatehook that callsPOST /branch/{id}/update-transformer, so the new transformer takes effect on the next frame without a re-init round-trip. Same idiom as Fixture Page. - Geometry cache invalidation. Geometry edits POST to
anchor/{id}/refresh-geom-cache, which triggers the sameSolid.ClearCache()pattern used across the project. - DelegateFuncDisplayee. The
RenderingCanvasis wired through a delegate so edits render next frame without IndexService churn.
Source Code Path
See HiNC App Anatomy for git repository links.
WPF Application Source Code Path
- See Machine Tool Page for the WPF chain editor. The generic
GeneralMechanismXML is typically authored via scripting or hand-edited XML on the WPF side.
Web Page Application Source Code Path
HiNC-2025-webservice (Quasar CLI SPA):
wwwroot-src/src/pages/MechBuilderPage.vue— routed page at/util/mech-builder.wwwroot-src/src/components/mech/MechBuilderGraph.vue— lazy mermaid loader + click-proxy onto mermaid node / edge DOM. Mermaid is dynamic-imported so the first bundle stays slim (~1 MB raw split into its own chunk).wwwroot-src/src/api/generalMechanism.ts— typed wrapper over/api/general-mechanism/*.wwwroot-src/src/router/routes.ts—/util/mech-builderentry.wwwroot-src/src/layouts/AppMenuBar.vue—Util → Mechanism Builderentry.Mech/MechBuilder/GeneralMechanismService.cs— DI singleton that holds the current mechanism + lastBaseDirectory+RelFile.Mech/MechBuilder/GeneralMechanismController.cs—/api/general-mechanism/*CRUD over anchors / branches / per-anchorTransformationGeom; XML Save As for bothGeneralMechanismandGeneralXyzabcMachineToolenvelopes.Mech/MechBuilder/GeneralMechanismDisplayController.cs—/api/general-mechanism/display/*view init.Program.cs— registersGeneralMechanismServiceas a DI singleton.
IndexService Keys
The mechanism state is persistent across pages (unlike Fixture which re-initialises on mount), so mechanism keys are not registered with useCleanupHub. Stale keys are harmless; they are re-pointed on the next index-transformer / index-transformation-geom call.
general-mechanism.current— the mechanism itself (informational;DelegateFuncDisplayeebypasses IndexService at render time).general-mechanism.branch.{guid:N}.transformer— stable per-branch transformer key used byTransformerSelectPanel.general-mechanism.anchor.{guid:N}.transformation-geom— stable per-anchorTransformationGeomkey used byGeometryEditor.
Deferred
- Server-side file picker. Load currently uses a plain
<input type=file>and Save As always streams as a browser download (Blob + <a download>). An in-app picker rooted at the project / resource folders would let users save directly into the server tree; revisit if that workflow is requested. - Plain “Save” (no path prompt, overwrite last path). Needs a dedicated server-side write endpoint that reuses the last
BaseDirectory + RelFileheld byGeneralMechanismService; depends on the server-side file picker above. - G2 Machine Tool page integration. If a dedicated Machine Tool page ships, it should wrap this page with preset Branch names (X / Y / Z / A / B / C) + Table / Tool buckle anchors rather than duplicate the editor.
Related Pages
- Fixture Page — parent-aware
onCreatetransformer rebind pattern reused for Branch. - Transformers — the shared 7-transformer switchboard.
- Geometry Management Control — embedded under the anchor editor.
- Machine Tool Page — future merge candidate for a preset-chain wrapper.