201 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mechanism Builder Page | HiAPI-C# 2025 </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Mechanism Builder Page | HiAPI-C# 2025 ">
<link rel="icon" href="../../img/HiAPI.favicon.ico">
<link rel="stylesheet" href="../../public/docfx.min.css">
<link rel="stylesheet" href="../../public/main.css">
<meta name="docfx:navrel" content="../../toc.html">
<meta name="docfx:tocrel" content="../toc.html">
<meta name="docfx:rel" content="../../">
<meta name="loc:inThisArticle" content="In this article">
<meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<meta name="loc:tocFilter" content="Filter by title">
<meta name="loc:nextArticle" content="Next">
<meta name="loc:prevArticle" content="Previous">
<meta name="loc:themeLight" content="Light">
<meta name="loc:themeDark" content="Dark">
<meta name="loc:themeAuto" content="Auto">
<meta name="loc:changeTheme" content="Change theme">
<meta name="loc:copy" content="Copy">
<meta name="loc:downloadPdf" content="Download PDF">
<script type="module" src="./../../public/docfx.min.js"></script>
<script>
const theme = localStorage.getItem('theme') || 'auto'
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
</script>
</head>
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../img/HiAPI.logo.png" alt="">
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
</form>
</div>
</div>
</div>
</nav>
</header>
<main class="container-xxl">
<div class="toc-offcanvas">
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<nav class="toc" id="toc"></nav>
</div>
</div>
</div>
<div class="content">
<div class="actionbar">
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
<i class="bi bi-list"></i>
</button>
<nav id="breadcrumb"></nav>
</div>
<article data-uid="">
<h1 id="mechanism-builder-page">Mechanism Builder Page</h1>
<p>The Mechanism Builder page edits a standalone <a class="xref" href="../../api/Hi.Mech.GeneralMechanism.html">GeneralMechanism</a> — its anchor topology, per-branch <code>ITransformer</code>, and per-anchor optional <a class="xref" href="../../api/Hi.Geom.TransformationGeom.html">TransformationGeom</a> inside a <code>Solid</code>. Unlike the project-scoped editors (Fixture / Workpiece / ToolHouse / Spindle Capability), this page is <strong>user-scoped</strong> — no project needs to be loaded.</p>
<ul>
<li>Key Model: <a class="xref" href="../../api/Hi.Mech.GeneralMechanism.html">GeneralMechanism</a></li>
<li>Related Model:
<ul>
<li><a class="xref" href="../../api/Hi.Numerical.Xyzabc.GeneralXyzabcChain.html">GeneralXyzabcChain</a> + <a class="xref" href="../../api/Hi.NcMech.Xyzabc.GeneralXyzabcMachineTool.html">GeneralXyzabcMachineTool</a> (used by &ldquo;Save As Machine Tool&rdquo;)</li>
</ul>
</li>
</ul>
<h2 id="layout">Layout</h2>
<ul>
<li>Mechanism Builder Page
<ul>
<li>File Menu
<ul>
<li>New — discards the current mechanism and starts an empty one.</li>
<li>Load&hellip;<code>&lt;input type=file&gt;</code> picks a local XML; POSTs its content to the backend.</li>
<li>Reload — re-reads the file last loaded from disk (only available after a prior disk load).</li>
<li>Save As General Mechanism — downloads a <code>.general-mech</code> XML via Blob.</li>
<li>Save As Xyzabc Machine Tool — wraps the mechanism in a <a class="xref" href="../../api/Hi.NcMech.Xyzabc.GeneralXyzabcMachineTool.html">GeneralXyzabcMachineTool</a> and downloads as <code>.mt</code>.</li>
</ul>
</li>
<li>Three-Column Layout (<code>&lt;q-splitter&gt;</code> × 2)
<ul>
<li>Graph Panel (left) — mermaid diagram of anchors (nodes) + branches (edges); node / edge click selects.</li>
<li>Editor Panel (middle) — content depends on selection:
<ul>
<li><strong>Anchor selected:</strong> inline rename + &ldquo;Add Branch ▾&rdquo; dropdown + optional <a class="xref" href="../../api/Hi.Geom.TransformationGeom.html">TransformationGeom</a> attach / detach. While attached, the panel embeds <a href="../geom/geom-manage-control.html">Geometry Management Control</a> restricted to <a class="xref" href="../../api/Hi.Geom.TransformationGeom.html">TransformationGeom</a>; the inner <code>Box3d</code> / <code>Cylindroid</code> / <code>StlFile</code> / <code>CubeTreeFile</code> remain reachable inside the <code>TransformationGeomEditor</code>'s <code>Geom</code> slot.</li>
<li><strong>Branch selected:</strong> inline rename + <a href="topo/transformers.html">Transformer Select Panel</a> (7 transformer kinds).</li>
</ul>
</li>
<li>Viewer Panel (right) — <a href="../renderingcanvas-tool-bar.html">RenderingCanvas Tool Bar</a> + <code>RenderingCanvas</code> bound to <code>DelegateFuncDisplayee(() =&gt; MechService.GeneralMechanism as IDisplayee)</code>.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="behavior">Behavior</h2>
<ul>
<li><strong>New-anchor auto-naming.</strong> Newly-created anchors receive placeholder names (<code>NewAnchor-001</code>, <code>NewAnchor-002</code>, …). Inline rename is debounced 400 ms.</li>
<li><strong>Branch add filter.</strong> The &ldquo;Add Branch ▾&rdquo; dropdown inside the anchor editor filters out the selected anchor itself and anchors already directly connected.</li>
<li><strong>Root protection.</strong> The root anchor cannot be deleted; double-click delete on any other anchor works.</li>
<li><strong>Branch transformer swap.</strong> <code>TransformerSelectPanel</code> uses a parent-aware <code>onCreate</code> hook that calls <code>POST /branch/{id}/update-transformer</code>, so the new transformer takes effect on the next frame without a re-init round-trip. Same idiom as <a href="fixture-page.html">Fixture Page</a>.</li>
<li><strong>Geometry cache invalidation.</strong> Geometry edits POST to <code>anchor/{id}/refresh-geom-cache</code>, which triggers the same <code>Solid.ClearCache()</code> pattern used across the project.</li>
<li><strong>DelegateFuncDisplayee.</strong> The <code>RenderingCanvas</code> is wired through a delegate so edits render next frame without IndexService churn.</li>
</ul>
<h2 id="source-code-path">Source Code Path</h2>
<p>See <a href="../index.html">HiNC App Anatomy</a> for git repository links.</p>
<h3 id="wpf-application-source-code-path">WPF Application Source Code Path</h3>
<ul>
<li>See <a href="machining-chain-page.html">Machine Tool Page</a> for the WPF chain editor. The generic <code>GeneralMechanism</code> XML is typically authored via scripting or hand-edited XML on the WPF side.</li>
</ul>
<h3 id="web-page-application-source-code-path">Web Page Application Source Code Path</h3>
<p>HiNC-2025-webservice (Quasar CLI SPA):</p>
<ul>
<li><code>wwwroot-src/src/pages/MechBuilderPage.vue</code> — routed page at <code>/util/mech-builder</code>.</li>
<li><code>wwwroot-src/src/components/mech/MechBuilderGraph.vue</code> — 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).</li>
<li><code>wwwroot-src/src/api/generalMechanism.ts</code> — typed wrapper over <code>/api/general-mechanism/*</code>.</li>
<li><code>wwwroot-src/src/router/routes.ts</code><code>/util/mech-builder</code> entry.</li>
<li><code>wwwroot-src/src/layouts/AppMenuBar.vue</code><code>Util → Mechanism Builder</code> entry.</li>
<li><code>Mech/MechBuilder/GeneralMechanismService.cs</code> — DI singleton that holds the current mechanism + last <code>BaseDirectory</code> + <code>RelFile</code>.</li>
<li><code>Mech/MechBuilder/GeneralMechanismController.cs</code><code>/api/general-mechanism/*</code> CRUD over anchors / branches / per-anchor <code>TransformationGeom</code>; XML Save As for both <code>GeneralMechanism</code> and <code>GeneralXyzabcMachineTool</code> envelopes.</li>
<li><code>Mech/MechBuilder/GeneralMechanismDisplayController.cs</code><code>/api/general-mechanism/display/*</code> view init.</li>
<li><code>Program.cs</code> — registers <code>GeneralMechanismService</code> as a DI singleton.</li>
</ul>
<h2 id="indexservice-keys">IndexService Keys</h2>
<p>The mechanism state is persistent across pages (unlike Fixture which re-initialises on mount), so mechanism keys are <strong>not</strong> registered with <code>useCleanupHub</code>. Stale keys are harmless; they are re-pointed on the next <code>index-transformer</code> / <code>index-transformation-geom</code> call.</p>
<ul>
<li><code>general-mechanism.current</code> — the mechanism itself (informational; <code>DelegateFuncDisplayee</code> bypasses IndexService at render time).</li>
<li><code>general-mechanism.branch.{guid:N}.transformer</code> — stable per-branch transformer key used by <code>TransformerSelectPanel</code>.</li>
<li><code>general-mechanism.anchor.{guid:N}.transformation-geom</code> — stable per-anchor <code>TransformationGeom</code> key used by <code>GeometryEditor</code>.</li>
</ul>
<h2 id="deferred">Deferred</h2>
<ul>
<li><strong>Server-side file picker.</strong> Load currently uses a plain <code>&lt;input type=file&gt;</code> and Save As always streams as a browser download (<code>Blob + &lt;a download&gt;</code>). 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.</li>
<li><strong>Plain &ldquo;Save&rdquo;</strong> (no path prompt, overwrite last path). Needs a dedicated server-side write endpoint that reuses the last <code>BaseDirectory + RelFile</code> held by <code>GeneralMechanismService</code>; depends on the server-side file picker above.</li>
<li><strong>G2 Machine Tool page integration.</strong> 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.</li>
</ul>
<h2 id="related-pages">Related Pages</h2>
<ul>
<li><a href="fixture-page.html">Fixture Page</a> — parent-aware <code>onCreate</code> transformer rebind pattern reused for Branch.</li>
<li><a href="topo/transformers.html">Transformers</a> — the shared 7-transformer switchboard.</li>
<li><a href="../geom/geom-manage-control.html">Geometry Management Control</a> — embedded under the anchor editor.</li>
<li><a href="machining-chain-page.html">Machine Tool Page</a> — future merge candidate for a preset-chain wrapper.</li>
</ul>
</article>
<div class="contribution d-print-none">
</div>
<div class="next-article d-print-none border-top" id="nextArticle"></div>
</div>
<div class="affix">
<nav id="affix"></nav>
</div>
</main>
<div class="container-xxl search-results" id="search-results"></div>
<footer class="border-top text-secondary">
<div class="container-xxl">
<div class="flex-fill">
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
</div>
</div>
</footer>
</body>
</html>