Table of Contents

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.

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-mech XML 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:
      • Viewer Panel (right) — RenderingCanvas Tool Bar + RenderingCanvas bound to DelegateFuncDisplayee(() => MechService.GeneralMechanism as IDisplayee).

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. TransformerSelectPanel uses a parent-aware onCreate hook that calls POST /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 same Solid.ClearCache() pattern used across the project.
  • DelegateFuncDisplayee. The RenderingCanvas is 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 GeneralMechanism XML 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-builder entry.
  • wwwroot-src/src/layouts/AppMenuBar.vueUtil → Mechanism Builder entry.
  • Mech/MechBuilder/GeneralMechanismService.cs — DI singleton that holds the current mechanism + last BaseDirectory + RelFile.
  • Mech/MechBuilder/GeneralMechanismController.cs/api/general-mechanism/* CRUD over anchors / branches / per-anchor TransformationGeom; XML Save As for both GeneralMechanism and GeneralXyzabcMachineTool envelopes.
  • Mech/MechBuilder/GeneralMechanismDisplayController.cs/api/general-mechanism/display/* view init.
  • Program.cs — registers GeneralMechanismService as 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; DelegateFuncDisplayee bypasses IndexService at render time).
  • general-mechanism.branch.{guid:N}.transformer — stable per-branch transformer key used by TransformerSelectPanel.
  • general-mechanism.anchor.{guid:N}.transformation-geom — stable per-anchor TransformationGeom key used by GeometryEditor.

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 + RelFile held by GeneralMechanismService; 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.