@things-factory/figure-ui 10.1.146 → 10.1.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/bootstrap.ts +10 -2
- package/client/graphql/index.ts +20 -0
- package/client/modeller/canvas.ts +6 -2
- package/client/modeller/carrier-declaration.ts +63 -0
- package/client/modeller/editor.ts +62 -27
- package/client/modeller/figure-carrier.ts +117 -0
- package/client/modeller/figure-cavity-drawing.ts +3 -9
- package/client/modeller/figure-first-save.ts +4 -7
- package/client/modeller/figure-history-panel.ts +2 -3
- package/client/modeller/figure-links.ts +46 -60
- package/client/modeller/figure-material-panel.ts +4 -14
- package/client/modeller/figure-mesh-choice.ts +68 -0
- package/client/modeller/figure-parts.ts +23 -1
- package/client/modeller/figure-preview.ts +2 -2
- package/client/modeller/figure-properties.ts +5 -3
- package/client/modeller/figure-section-editor.ts +12 -33
- package/client/modeller/figure-section-panel.ts +6 -7
- package/client/modeller/figure-slot-layout-panel.ts +208 -0
- package/client/modeller/figure-verdict.ts +21 -31
- package/client/modeller/first-save.ts +23 -0
- package/client/modeller/links.ts +52 -1
- package/client/modeller/material-edit.ts +38 -0
- package/client/modeller/maturity.ts +28 -0
- package/client/modeller/mesh-import.ts +77 -0
- package/client/modeller/modeller-route.ts +9 -0
- package/client/modeller/mounting-part.ts +15 -0
- package/client/modeller/newest-answer.ts +21 -0
- package/client/modeller/preview-model.ts +5 -0
- package/client/modeller/refusals.ts +168 -82
- package/client/modeller/section-controls.ts +25 -1
- package/client/modeller/section-drawing.ts +43 -1
- package/client/modeller/slot-layout-host.ts +140 -0
- package/client/pages/figure-modeller-page.ts +6 -5
- package/client/viewparts/detail-route.ts +7 -0
- package/client/viewparts/figure-detail-dock.ts +1 -3
- package/dist-client/bootstrap.d.ts +1 -1
- package/dist-client/bootstrap.js +9 -2
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/graphql/index.d.ts +5 -0
- package/dist-client/graphql/index.js +19 -0
- package/dist-client/graphql/index.js.map +1 -1
- package/dist-client/modeller/canvas.d.ts +2 -0
- package/dist-client/modeller/canvas.js +10 -2
- package/dist-client/modeller/canvas.js.map +1 -1
- package/dist-client/modeller/carrier-declaration.d.ts +31 -0
- package/dist-client/modeller/carrier-declaration.js +53 -0
- package/dist-client/modeller/carrier-declaration.js.map +1 -0
- package/dist-client/modeller/editor.d.ts +13 -0
- package/dist-client/modeller/editor.js +62 -27
- package/dist-client/modeller/editor.js.map +1 -1
- package/dist-client/modeller/figure-carrier.d.ts +26 -0
- package/dist-client/modeller/figure-carrier.js +123 -0
- package/dist-client/modeller/figure-carrier.js.map +1 -0
- package/dist-client/modeller/figure-cavity-drawing.js +3 -11
- package/dist-client/modeller/figure-cavity-drawing.js.map +1 -1
- package/dist-client/modeller/figure-first-save.d.ts +4 -0
- package/dist-client/modeller/figure-first-save.js +5 -8
- package/dist-client/modeller/figure-first-save.js.map +1 -1
- package/dist-client/modeller/figure-history-panel.js +2 -4
- package/dist-client/modeller/figure-history-panel.js.map +1 -1
- package/dist-client/modeller/figure-links.d.ts +4 -1
- package/dist-client/modeller/figure-links.js +47 -57
- package/dist-client/modeller/figure-links.js.map +1 -1
- package/dist-client/modeller/figure-material-panel.d.ts +0 -1
- package/dist-client/modeller/figure-material-panel.js +4 -14
- package/dist-client/modeller/figure-material-panel.js.map +1 -1
- package/dist-client/modeller/figure-mesh-choice.d.ts +16 -0
- package/dist-client/modeller/figure-mesh-choice.js +75 -0
- package/dist-client/modeller/figure-mesh-choice.js.map +1 -0
- package/dist-client/modeller/figure-parts.d.ts +1 -1
- package/dist-client/modeller/figure-parts.js +22 -0
- package/dist-client/modeller/figure-parts.js.map +1 -1
- package/dist-client/modeller/figure-preview.js +2 -2
- package/dist-client/modeller/figure-preview.js.map +1 -1
- package/dist-client/modeller/figure-properties.d.ts +2 -1
- package/dist-client/modeller/figure-properties.js +5 -3
- package/dist-client/modeller/figure-properties.js.map +1 -1
- package/dist-client/modeller/figure-section-editor.d.ts +2 -2
- package/dist-client/modeller/figure-section-editor.js +12 -33
- package/dist-client/modeller/figure-section-editor.js.map +1 -1
- package/dist-client/modeller/figure-section-panel.js +6 -7
- package/dist-client/modeller/figure-section-panel.js.map +1 -1
- package/dist-client/modeller/figure-slot-layout-panel.d.ts +36 -0
- package/dist-client/modeller/figure-slot-layout-panel.js +198 -0
- package/dist-client/modeller/figure-slot-layout-panel.js.map +1 -0
- package/dist-client/modeller/figure-verdict.d.ts +1 -1
- package/dist-client/modeller/figure-verdict.js +19 -37
- package/dist-client/modeller/figure-verdict.js.map +1 -1
- package/dist-client/modeller/first-save.d.ts +10 -0
- package/dist-client/modeller/first-save.js +16 -0
- package/dist-client/modeller/first-save.js.map +1 -1
- package/dist-client/modeller/links.d.ts +26 -1
- package/dist-client/modeller/links.js +43 -0
- package/dist-client/modeller/links.js.map +1 -1
- package/dist-client/modeller/material-edit.d.ts +11 -0
- package/dist-client/modeller/material-edit.js +28 -0
- package/dist-client/modeller/material-edit.js.map +1 -0
- package/dist-client/modeller/maturity.d.ts +15 -0
- package/dist-client/modeller/maturity.js +23 -0
- package/dist-client/modeller/maturity.js.map +1 -1
- package/dist-client/modeller/mesh-import.d.ts +47 -0
- package/dist-client/modeller/mesh-import.js +47 -0
- package/dist-client/modeller/mesh-import.js.map +1 -0
- package/dist-client/modeller/modeller-route.d.ts +5 -0
- package/dist-client/modeller/modeller-route.js +9 -0
- package/dist-client/modeller/modeller-route.js.map +1 -1
- package/dist-client/modeller/mounting-part.d.ts +14 -0
- package/dist-client/modeller/mounting-part.js +10 -0
- package/dist-client/modeller/mounting-part.js.map +1 -0
- package/dist-client/modeller/newest-answer.d.ts +12 -0
- package/dist-client/modeller/newest-answer.js +21 -0
- package/dist-client/modeller/newest-answer.js.map +1 -0
- package/dist-client/modeller/preview-model.d.ts +2 -0
- package/dist-client/modeller/preview-model.js +4 -0
- package/dist-client/modeller/preview-model.js.map +1 -1
- package/dist-client/modeller/refusals.d.ts +26 -5
- package/dist-client/modeller/refusals.js +184 -86
- package/dist-client/modeller/refusals.js.map +1 -1
- package/dist-client/modeller/section-controls.d.ts +17 -1
- package/dist-client/modeller/section-controls.js +18 -0
- package/dist-client/modeller/section-controls.js.map +1 -1
- package/dist-client/modeller/section-drawing.d.ts +24 -1
- package/dist-client/modeller/section-drawing.js +42 -0
- package/dist-client/modeller/section-drawing.js.map +1 -1
- package/dist-client/modeller/slot-layout-host.d.ts +81 -0
- package/dist-client/modeller/slot-layout-host.js +105 -0
- package/dist-client/modeller/slot-layout-host.js.map +1 -0
- package/dist-client/pages/figure-modeller-page.js +5 -4
- package/dist-client/pages/figure-modeller-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/detail-route.d.ts +5 -0
- package/dist-client/viewparts/detail-route.js +8 -0
- package/dist-client/viewparts/detail-route.js.map +1 -0
- package/dist-client/viewparts/figure-detail-dock.d.ts +0 -1
- package/dist-client/viewparts/figure-detail-dock.js +1 -3
- package/dist-client/viewparts/figure-detail-dock.js.map +1 -1
- package/package.json +9 -8
- package/test/align.test.ts +0 -9
- package/test/browser/assistant-stand-in.js +32 -0
- package/test/browser/build.mjs +6 -1
- package/test/browser/editing-page.js +224 -0
- package/test/browser/editing.check.mjs +550 -0
- package/test/browser/links-page.js +113 -0
- package/test/browser/links.check.mjs +568 -0
- package/test/browser/modeller.check.mjs +21 -0
- package/test/browser/parts-page.js +120 -0
- package/test/browser/parts.check.mjs +328 -0
- package/test/browser/places-mesh-page.js +36 -0
- package/test/browser/places-mesh.check.mjs +239 -0
- package/test/browser/product-page.check.mjs +682 -0
- package/test/browser/product-page.js +276 -0
- package/test/browser/screen-page.js +112 -0
- package/test/browser/screen-product-page.js +62 -0
- package/test/browser/screen.check.mjs +1003 -0
- package/test/browser/section-page.js +256 -0
- package/test/browser/section.check.mjs +719 -0
- package/test/browser/serve.mjs +20 -12
- package/test/carrier-declaration.test.ts +69 -0
- package/test/cavity-drawing.test.ts +2 -18
- package/test/clip-ai-proposal.test.ts +1 -5
- package/test/clip-consent.test.ts +0 -5
- package/test/clips.test.ts +0 -7
- package/test/command-preview.test.ts +0 -68
- package/test/controls.test.ts +0 -9
- package/test/detail-dock.test.ts +6 -25
- package/test/face-mapping.test.ts +1 -20
- package/test/fasten-drawing.test.ts +0 -23
- package/test/fields.test.ts +6 -33
- package/test/figure-assistant-surface.test.ts +32 -38
- package/test/first-minute.test.ts +3 -55
- package/test/first-save-suggest.test.ts +11 -8
- package/test/first-save.test.ts +4 -26
- package/test/gizmo.test.ts +0 -25
- package/test/joint-fan.test.ts +0 -10
- package/test/keys.test.ts +0 -7
- package/test/layout.test.ts +4 -73
- package/test/links.test.ts +48 -67
- package/test/live.test.ts +0 -34
- package/test/material.test.ts +17 -26
- package/test/maturity.test.ts +13 -16
- package/test/mesh-import.test.ts +76 -0
- package/test/modeller-route.test.ts +3 -19
- package/test/package-download.test.ts +6 -7
- package/test/parts-wiring.test.ts +9 -51
- package/test/preview.test.ts +5 -46
- package/test/properties.test.ts +11 -26
- package/test/proposal-record.test.ts +2 -19
- package/test/recipes.test.ts +0 -15
- package/test/refusals.test.ts +257 -151
- package/test/release-entry.test.ts +1 -9
- package/test/release-panel.test.ts +1 -22
- package/test/resize-with-placement.test.ts +0 -32
- package/test/revert-choice.test.ts +1 -22
- package/test/revert-keeping.test.ts +1 -12
- package/test/save-landed.test.ts +16 -14
- package/test/scene-canvas.test.ts +2 -13
- package/test/section-editor.test.ts +30 -83
- package/test/section-panel.test.ts +22 -17
- package/test/slot-layout-host.test.ts +117 -0
- package/test/theme.test.ts +5 -9
- package/test/verdict.test.ts +44 -41
- package/test/view.test.ts +5 -12
- package/translations/en.json +61 -1
- package/translations/es.json +61 -1
- package/translations/ja.json +61 -1
- package/translations/ko.json +61 -1
- package/translations/ms.json +61 -1
- package/translations/zh.json +61 -1
- package/test/thumbnail.test.ts +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-controls.js","sourceRoot":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,CAAC,GAAG,EAAE,CAAA;AAC5G,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,IAA4B,EAAE,IAAY,EAAE,KAAa,EAAE,OAAgB;IACrG,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACxC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAClG,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,KAA2B,EAAE,GAAiC;IACvF,OAAO,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAA;AACnE,CAAC","sourcesContent":["import { FIGURE_SECTION_PLANE, checkFigureSection, figureExtrusionFeaturesOf } from '@hatiolab/figure-model'\nimport type { FigureCavityRequest, FigureEvaluatedShape } from '@hatiolab/figure-model'\n\n/*\n * What the 단면 section of the properties tab reads and asks (ADR-0100 §3.3): a pushed part's corners and its inside.\n * Whether a value can be taken is asked of the kernel's own section checks -- the screen keeps no rule of its own -- and\n * the most it can take is said beside the field, so a refusal names the value to type rather than only that it failed.\n */\n\ntype Axis = 'x' | 'y' | 'z'\ntype End = 'start' | 'end'\ntype Extrusion = NonNullable<FigureEvaluatedShape['extrusion']>\n\n/** The face each side of a section is, and each end of a push: a push's start is its low side. */\nexport const SIDE_FACE: Record<string, string> = { 'x-': 'left', 'x+': 'right', 'y-': 'bottom', 'y+': 'top', 'z-': 'back', 'z+': 'front' }\nexport const END_FACE = (axis: Axis, end: End) => SIDE_FACE[`${axis}${end === 'start' ? '-' : '+'}`]!\n\n/** The one value every entry holds, or undefined when they differ (or there are none). */\nexport const sameOf = (values: readonly (number | undefined)[]) =>\n values.length && values.every(v => v !== undefined && Math.abs(v - values[0]!) < 1e-6) ? values[0] : undefined\n\nexport const mm = (value: number) => Math.round(value * 1000) / 1000\n\n/** The four sides of a push's section, in the kernel's order: the first plane axis low and high, then the second. */\nexport const sidesOf = (axis: Axis) => FIGURE_SECTION_PLANE[axis].flatMap(a => [`${a}-`, `${a}+`])\n\n/** The section's widths across, one per plane axis: a rectangle's sides, an ellipse's diameters. */\nfunction acrossOf(e: Extrusion): number[] {\n const s = e.section\n if (s.kind === 'rectangle') return FIGURE_SECTION_PLANE[e.axis].map(a => s.size[a]!)\n if (s.kind === 'ellipse') return FIGURE_SECTION_PLANE[e.axis].map(a => 2 * s.radius[a]!)\n return []\n}\n\n/** The wall a new inside starts with: a tenth of the section's narrower side, at least 1 mm. */\nexport function defaultWallOf(shape: FigureEvaluatedShape): number {\n return Math.max(1, Math.round(Math.min(...acrossOf(shape.extrusion!)) / 10))\n}\n\n/**\n * The inside as the panel asks for it: the part's own, with one thing changed. A part with none yet gets a default\n * wall all round, a closed start as thick as the wall and an open end -- a tray standing on its floor.\n */\nexport function cavityRequestOf(shape: FigureEvaluatedShape, patch: Partial<FigureCavityRequest> = {}): FigureCavityRequest {\n const cavity = shape.cavity\n return {\n wall: cavity ? (sameOf(Object.values(cavity.wall)) ?? { ...cavity.wall }) : defaultWallOf(shape),\n start: cavity?.start ?? { closed: defaultWallOf(shape) },\n end: cavity?.end ?? 'open',\n ...patch\n }\n}\n\n/** The most a rectangle's corners can reach: half its narrower side (the kernel's CORNER_TOO_LARGE says where). */\nexport function cornerLimitOf(shape: FigureEvaluatedShape): number | undefined {\n const e = shape.extrusion\n if (e?.section.kind !== 'rectangle') return undefined\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const far = 2 * Math.max(...acrossOf(e))\n const issues = checkFigureSection({ kind: 'rectangle', size: e.section.size, corner: { [u]: far, [v]: far } }, e.axis)\n const maxes = issues.flatMap(i => (i.code === 'CORNER_TOO_LARGE' ? [i.max] : []))\n return maxes.length ? Math.min(...maxes) : undefined\n}\n\n/** Whether a corner radius can be taken; if not, the most it can be. */\nexport function cornerRefusalOf(shape: FigureEvaluatedShape, radius: number): { max: number } | null {\n const e = shape.extrusion\n if (e?.section.kind !== 'rectangle' || !(radius > 0)) return null\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const issues = checkFigureSection({ kind: 'rectangle', size: e.section.size, corner: { [u]: radius, [v]: radius } }, e.axis)\n return issues.some(i => i.code === 'CORNER_TOO_LARGE') ? { max: cornerLimitOf(shape)! } : null\n}\n\n/** One side's wall, the others kept: it must leave room inside, so under the width across it less the opposite wall. */\nexport function sideWallLimitOf(shape: FigureEvaluatedShape, wall: Record<string, number>, side: string): number {\n const e = shape.extrusion!\n const axis = side[0] as Axis\n const across = acrossOf(e)[FIGURE_SECTION_PLANE[e.axis].indexOf(axis)]!\n return across - (wall[`${axis}${side[1] === '-' ? '+' : '-'}`] ?? 0)\n}\n\n/** A wall must leave room inside: under half the narrower width the section has. */\nexport const wallLimitOf = (shape: FigureEvaluatedShape) => Math.min(...acrossOf(shape.extrusion!)) / 2\n\nexport type FigureCavityAsk =\n | { code: 'wall-too-thick'; max: number }\n | { code: 'ends-too-thick'; max: number }\n | { code: 'not-positive' }\n\n/** Whether an inside can be taken, asked of the kernel; if not, what to change and the most it can be. */\nexport function cavityRefusalOf(shape: FigureEvaluatedShape, request: FigureCavityRequest): FigureCavityAsk | null {\n const e = shape.extrusion!\n const sides = sidesOf(e.axis)\n const wall = typeof request.wall === 'number' ? Object.fromEntries(sides.map(s => [s, request.wall as number])) : request.wall\n const made = figureExtrusionFeaturesOf(e, [{ id: 'inside', wall: wall as Record<string, number>, start: request.start, end: request.end }])\n if (!('refused' in made)) return null\n const r = made.refused\n if (r.code === 'CAVITY' && r.refused === 'NO_ROOM_INSIDE') return { code: 'wall-too-thick', max: mm(wallLimitOf(shape)) }\n if (r.code === 'CAVITY_NO_LENGTH') return { code: 'ends-too-thick', max: mm(e.end - e.start) }\n return { code: 'not-positive' }\n}\n\n/** What the inside makes of the part (§3.3): open at both ends a pipe, at one a container, at neither a closed space. */\nexport function cavityResultOf(cavity: NonNullable<FigureEvaluatedShape['cavity']>): 'pipe' | 'container' | 'sealed' {\n const open = [cavity.start, cavity.end].filter(e => e === 'open').length\n return open === 2 ? 'pipe' : open === 1 ? 'container' : 'sealed'\n}\n\n/** How deep the inside is along the push: the length less the closed ends. */\nexport function cavityDepthOf(shape: FigureEvaluatedShape): number {\n const e = shape.extrusion!,\n c = shape.cavity!\n const closed = (x: typeof c.start) => (x === 'open' ? 0 : x.closed)\n return mm(e.end - e.start - closed(c.start) - closed(c.end))\n}\n\n/** The inside as it stands, every side's wall written out. */\nexport function cavityWorkingOf(shape: FigureEvaluatedShape): { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] } | undefined {\n const c = shape.cavity\n const e = shape.extrusion\n if (!c || !e) return undefined\n return { wall: Object.fromEntries(sidesOf(e.axis).map(s => [s, c.wall[s]!])), start: c.start, end: c.end }\n}\n\n/** A wall dragged to `value`: that side alone, or every side when the walls are one. */\nexport function wallDragged(wall: Record<string, number>, side: string, value: number, perSide: boolean): Record<string, number> {\n const v = Math.max(1, Math.round(value))\n return perSide ? { ...wall, [side]: v } : Object.fromEntries(Object.keys(wall).map(s => [s, v]))\n}\n\n/** An end pressed: open becomes closed by the default wall, closed becomes open. */\nexport function endToggled(shape: FigureEvaluatedShape, now: FigureCavityRequest['start']): FigureCavityRequest['start'] {\n return now === 'open' ? { closed: defaultWallOf(shape) } : 'open'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"section-controls.js","sourceRoot":"","sources":["../../client/modeller/section-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB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,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAA;AAC5G,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,IAA4B,EAAE,IAAY,EAAE,KAAa,EAAE,OAAgB;IACrG,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACxC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAClG,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,KAA2B,EAAE,GAAiC;IACvF,OAAO,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAA;AACnE,CAAC","sourcesContent":["import { FIGURE_SECTION_PLANE, checkFigureSection, figureExtrusionFeaturesOf } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureCavityRequest, FigureEvaluatedShape } from '@hatiolab/figure-model'\n\n/*\n * What the 단면 section of the properties tab reads and asks (ADR-0100 §3.3): a pushed part's corners and its inside.\n * Whether a value can be taken is asked of the kernel's own section checks -- the screen keeps no rule of its own -- and\n * the most it can take is said beside the field, so a refusal names the value to type rather than only that it failed.\n */\n\ntype Axis = 'x' | 'y' | 'z'\ntype End = 'start' | 'end'\ntype Extrusion = NonNullable<FigureEvaluatedShape['extrusion']>\n\n/** The face each side of a section is, and each end of a push: a push's start is its low side. */\nexport const SIDE_FACE: Record<string, string> = { 'x-': 'left', 'x+': 'right', 'y-': 'bottom', 'y+': 'top', 'z-': 'back', 'z+': 'front' }\nexport const END_FACE = (axis: Axis, end: End) => SIDE_FACE[`${axis}${end === 'start' ? '-' : '+'}`]!\n\n/** The one value every entry holds, or undefined when they differ (or there are none). */\nexport const sameOf = (values: readonly (number | undefined)[]) =>\n values.length && values.every(v => v !== undefined && Math.abs(v - values[0]!) < 1e-6) ? values[0] : undefined\n\nexport const mm = (value: number) => Math.round(value * 1000) / 1000\n\n/** The four sides of a push's section, in the kernel's order: the first plane axis low and high, then the second. */\nexport const sidesOf = (axis: Axis) => FIGURE_SECTION_PLANE[axis].flatMap(a => [`${a}-`, `${a}+`])\n\n/** The section's widths across, one per plane axis: a rectangle's sides, an ellipse's diameters. */\nfunction acrossOf(e: Extrusion): number[] {\n const s = e.section\n if (s.kind === 'rectangle') return FIGURE_SECTION_PLANE[e.axis].map(a => s.size[a]!)\n if (s.kind === 'ellipse') return FIGURE_SECTION_PLANE[e.axis].map(a => 2 * s.radius[a]!)\n return []\n}\n\n/** The wall a new inside starts with: a tenth of the section's narrower side, at least 1 mm. */\nexport function defaultWallOf(shape: FigureEvaluatedShape): number {\n return Math.max(1, Math.round(Math.min(...acrossOf(shape.extrusion!)) / 10))\n}\n\n/**\n * The inside as the panel asks for it: the part's own, with one thing changed. A part with none yet gets a default\n * wall all round, a closed start as thick as the wall and an open end -- a tray standing on its floor.\n */\nexport function cavityRequestOf(shape: FigureEvaluatedShape, patch: Partial<FigureCavityRequest> = {}): FigureCavityRequest {\n const cavity = shape.cavity\n return {\n wall: cavity ? (sameOf(Object.values(cavity.wall)) ?? { ...cavity.wall }) : defaultWallOf(shape),\n start: cavity?.start ?? { closed: defaultWallOf(shape) },\n end: cavity?.end ?? 'open',\n ...patch\n }\n}\n\n/** The most a rectangle's corners can reach: half its narrower side (the kernel's CORNER_TOO_LARGE says where). */\nexport function cornerLimitOf(shape: FigureEvaluatedShape): number | undefined {\n const e = shape.extrusion\n if (e?.section.kind !== 'rectangle') return undefined\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const far = 2 * Math.max(...acrossOf(e))\n const issues = checkFigureSection({ kind: 'rectangle', size: e.section.size, corner: { [u]: far, [v]: far } }, e.axis)\n const maxes = issues.flatMap(i => (i.code === 'CORNER_TOO_LARGE' ? [i.max] : []))\n return maxes.length ? Math.min(...maxes) : undefined\n}\n\n/** A corner radius as the one command: 0 takes the rounding away. */\nexport const cornerActionOf = (part: string, radius: number): FigureAuthoringAction => ({ kind: 'set-section-corner', part, corner: radius > 0 ? radius : null })\n\n/** Whether a corner radius can be taken; if not, the most it can be. */\nexport function cornerRefusalOf(shape: FigureEvaluatedShape, radius: number): { max: number } | null {\n const e = shape.extrusion\n if (e?.section.kind !== 'rectangle' || !(radius > 0)) return null\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const issues = checkFigureSection({ kind: 'rectangle', size: e.section.size, corner: { [u]: radius, [v]: radius } }, e.axis)\n return issues.some(i => i.code === 'CORNER_TOO_LARGE') ? { max: cornerLimitOf(shape)! } : null\n}\n\n/** One side's wall, the others kept: it must leave room inside, so under the width across it less the opposite wall. */\nexport function sideWallLimitOf(shape: FigureEvaluatedShape, wall: Record<string, number>, side: string): number {\n const e = shape.extrusion!\n const axis = side[0] as Axis\n const across = acrossOf(e)[FIGURE_SECTION_PLANE[e.axis].indexOf(axis)]!\n return across - (wall[`${axis}${side[1] === '-' ? '+' : '-'}`] ?? 0)\n}\n\n/** A wall must leave room inside: under half the narrower width the section has. */\nexport const wallLimitOf = (shape: FigureEvaluatedShape) => Math.min(...acrossOf(shape.extrusion!)) / 2\n\nexport type FigureCavityAsk =\n | { code: 'wall-too-thick'; max: number }\n | { code: 'ends-too-thick'; max: number }\n | { code: 'not-positive' }\n\n/** Whether an inside can be taken, asked of the kernel; if not, what to change and the most it can be. */\nexport function cavityRefusalOf(shape: FigureEvaluatedShape, request: FigureCavityRequest): FigureCavityAsk | null {\n const e = shape.extrusion!\n const sides = sidesOf(e.axis)\n const wall = typeof request.wall === 'number' ? Object.fromEntries(sides.map(s => [s, request.wall as number])) : request.wall\n const made = figureExtrusionFeaturesOf(e, [{ id: 'inside', wall: wall as Record<string, number>, start: request.start, end: request.end }])\n if (!('refused' in made)) return null\n const r = made.refused\n if (r.code === 'CAVITY' && r.refused === 'NO_ROOM_INSIDE') return { code: 'wall-too-thick', max: mm(wallLimitOf(shape)) }\n if (r.code === 'CAVITY_NO_LENGTH') return { code: 'ends-too-thick', max: mm(e.end - e.start) }\n return { code: 'not-positive' }\n}\n\n/**\n * What the kernel would refuse of an inside, as words: an i18n key and its values; null when it would take it. For one\n * side's wall with the walls one per side, the most is that side's with the opposite kept, not the kernel's all-round one.\n */\nexport function cavityRefusalWordsOf(\n shape: FigureEvaluatedShape,\n request: { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] },\n perSide: boolean,\n side?: string\n): { key: string; params: Record<string, string> } | null {\n const ask = cavityRefusalOf(shape, { wall: { ...request.wall }, start: request.start, end: request.end })\n if (!ask) return null\n if (ask.code === 'wall-too-thick')\n return { key: 'figure.text.section-wall-over', params: { max: String(perSide && side ? mm(sideWallLimitOf(shape, request.wall, side)) : ask.max) } }\n if (ask.code === 'ends-too-thick') return { key: 'figure.text.section-ends-over', params: { max: String(ask.max) } }\n return { key: 'figure.text.section-not-positive', params: {} }\n}\n\n/** Whether a part can have an inside: a pushed rectangle or ellipse (a drawn section's is a later stage). */\nexport const hollowableOf = (shape: FigureEvaluatedShape) => shape.extrusion?.section.kind === 'rectangle' || shape.extrusion?.section.kind === 'ellipse'\n\n/** What the inside makes of the part (§3.3): open at both ends a pipe, at one a container, at neither a closed space. */\nexport function cavityResultOf(cavity: NonNullable<FigureEvaluatedShape['cavity']>): 'pipe' | 'container' | 'sealed' {\n const open = [cavity.start, cavity.end].filter(e => e === 'open').length\n return open === 2 ? 'pipe' : open === 1 ? 'container' : 'sealed'\n}\n\n/** How deep the inside is along the push: the length less the closed ends. */\nexport function cavityDepthOf(shape: FigureEvaluatedShape): number {\n const e = shape.extrusion!,\n c = shape.cavity!\n const closed = (x: typeof c.start) => (x === 'open' ? 0 : x.closed)\n return mm(e.end - e.start - closed(c.start) - closed(c.end))\n}\n\n/** The inside as it stands, every side's wall written out. */\nexport function cavityWorkingOf(shape: FigureEvaluatedShape): { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] } | undefined {\n const c = shape.cavity\n const e = shape.extrusion\n if (!c || !e) return undefined\n return { wall: Object.fromEntries(sidesOf(e.axis).map(s => [s, c.wall[s]!])), start: c.start, end: c.end }\n}\n\n/** A wall dragged to `value`: that side alone, or every side when the walls are one. */\nexport function wallDragged(wall: Record<string, number>, side: string, value: number, perSide: boolean): Record<string, number> {\n const v = Math.max(1, Math.round(value))\n return perSide ? { ...wall, [side]: v } : Object.fromEntries(Object.keys(wall).map(s => [s, v]))\n}\n\n/** An end pressed: open becomes closed by the default wall, closed becomes open. */\nexport function endToggled(shape: FigureEvaluatedShape, now: FigureCavityRequest['start']): FigureCavityRequest['start'] {\n return now === 'open' ? { closed: defaultWallOf(shape) } : 'open'\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FigureCavityRequest, FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionPoint } from '@hatiolab/figure-model';
|
|
1
|
+
import type { FigureAuthoringAction, FigureCavityRequest, FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionMeasure, FigureSectionPoint } from '@hatiolab/figure-model';
|
|
2
2
|
type Axis = 'x' | 'y' | 'z';
|
|
3
3
|
export type Points = readonly FigureSectionPoint[];
|
|
4
4
|
/** The number a point is shown by: its name's number. */
|
|
@@ -72,4 +72,27 @@ export declare function workingIssuesOf(shape: FigureEvaluatedShape, w: SectionW
|
|
|
72
72
|
params: Record<string, string>;
|
|
73
73
|
}>;
|
|
74
74
|
};
|
|
75
|
+
/** The inside said so two can be compared: its walls by side, its ends. */
|
|
76
|
+
export declare const cavityKeyOf: (w: SectionWorking) => ([string, number][] | "open" | {
|
|
77
|
+
closed: number;
|
|
78
|
+
})[] | null;
|
|
79
|
+
/**
|
|
80
|
+
* The one command for everything changed since the editor opened: a drawn section's points always, and of the rest only
|
|
81
|
+
* what changed -- a measure left alone may follow another value and must not be written; an apex taken away is null
|
|
82
|
+
* (back to a push), an inside taken away is null.
|
|
83
|
+
*/
|
|
84
|
+
export declare function sectionActionOf(part: string, kind: FigureSection['kind'] | undefined, opened: SectionWorking, w: SectionWorking): FigureAuthoringAction;
|
|
85
|
+
/**
|
|
86
|
+
* What a measure's field says under it: that it follows another value, or -- given where along the push a length
|
|
87
|
+
* change keeps the part (1 its start, -1 its end, 0 its centre) -- the face it keeps; null when there is nothing to say.
|
|
88
|
+
*/
|
|
89
|
+
export declare function measureNoteOf(measure: FigureSectionMeasure | undefined, kept: -1 | 0 | 1 | undefined, axis: Axis): {
|
|
90
|
+
key: string;
|
|
91
|
+
face?: string;
|
|
92
|
+
} | null;
|
|
93
|
+
/** The words beside a drawn section's edit button: how many points it has, and the apex when its end is one point. */
|
|
94
|
+
export declare function sectionPointsWordsOf(drawn: ReturnType<typeof drawnOf>): {
|
|
95
|
+
key: string;
|
|
96
|
+
params: Record<string, string>;
|
|
97
|
+
} | null;
|
|
75
98
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FIGURE_SECTION_PLANE, FIGURE_SECTION_POINT_LIMIT, checkFigureSection, figureExtrusionFeaturesOf, figureSectionSidesOf } from '@hatiolab/figure-model';
|
|
2
|
+
import { END_FACE } from './section-controls.js';
|
|
2
3
|
/** The number a point is shown by: its name's number. */
|
|
3
4
|
export const pointLabel = (id) => /^p(\d+)$/.exec(id)?.[1] ?? id;
|
|
4
5
|
/** The next point's name: one past the highest number the loop has, so a new point never takes a gap's number. */
|
|
@@ -157,4 +158,45 @@ export function workingIssuesOf(shape, w) {
|
|
|
157
158
|
}
|
|
158
159
|
return { issues, words };
|
|
159
160
|
}
|
|
161
|
+
/** The inside said so two can be compared: its walls by side, its ends. */
|
|
162
|
+
export const cavityKeyOf = (w) => (w.cavity ? [Object.entries(w.cavity.wall).sort(), w.cavity.start, w.cavity.end] : null);
|
|
163
|
+
/**
|
|
164
|
+
* The one command for everything changed since the editor opened: a drawn section's points always, and of the rest only
|
|
165
|
+
* what changed -- a measure left alone may follow another value and must not be written; an apex taken away is null
|
|
166
|
+
* (back to a push), an inside taken away is null.
|
|
167
|
+
*/
|
|
168
|
+
export function sectionActionOf(part, kind, opened, w) {
|
|
169
|
+
const changed = (a, b) => Math.abs((a ?? 0) - (b ?? 0)) > 1e-9;
|
|
170
|
+
const across = Object.fromEntries(Object.entries(w.across).filter(([k, v]) => changed(v, opened.across[k])));
|
|
171
|
+
const apexMoved = !w.apex !== !opened.apex || (!!w.apex && Object.entries(w.apex).some(([k, v]) => changed(v, opened.apex[k])));
|
|
172
|
+
const cavityMoved = JSON.stringify(cavityKeyOf(w)) !== JSON.stringify(cavityKeyOf(opened));
|
|
173
|
+
return {
|
|
174
|
+
kind: 'set-section',
|
|
175
|
+
part,
|
|
176
|
+
...(kind === 'polygon' ? { points: w.points.map(p => ({ ...p })) } : {}),
|
|
177
|
+
...(Object.keys(across).length ? { across } : {}),
|
|
178
|
+
...(changed(w.length, opened.length) ? { length: w.length } : {}),
|
|
179
|
+
...(apexMoved ? { apex: w.apex ? { ...w.apex } : null } : {}),
|
|
180
|
+
...(cavityMoved ? { cavity: w.cavity ? { wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } : null } : {})
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* What a measure's field says under it: that it follows another value, or -- given where along the push a length
|
|
185
|
+
* change keeps the part (1 its start, -1 its end, 0 its centre) -- the face it keeps; null when there is nothing to say.
|
|
186
|
+
*/
|
|
187
|
+
export function measureNoteOf(measure, kept, axis) {
|
|
188
|
+
if (measure === 'linked')
|
|
189
|
+
return { key: 'figure.text.section-editor-linked' };
|
|
190
|
+
if (kept === undefined)
|
|
191
|
+
return null;
|
|
192
|
+
if (kept === 0)
|
|
193
|
+
return { key: 'figure.text.section-editor-keeps-centre' };
|
|
194
|
+
return { key: 'figure.text.section-editor-keeps', face: END_FACE(axis, kept === 1 ? 'start' : 'end') };
|
|
195
|
+
}
|
|
196
|
+
/** The words beside a drawn section's edit button: how many points it has, and the apex when its end is one point. */
|
|
197
|
+
export function sectionPointsWordsOf(drawn) {
|
|
198
|
+
if (drawn?.section.kind !== 'polygon')
|
|
199
|
+
return null;
|
|
200
|
+
return { key: drawn.apex ? 'figure.text.section-points-apex' : 'figure.text.section-points', params: { points: String(drawn.section.points.length) } };
|
|
201
|
+
}
|
|
160
202
|
//# sourceMappingURL=section-drawing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-drawing.js","sourceRoot":"","sources":["../../client/modeller/section-drawing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAa9J,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAExE,kHAAkH;AAClH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;AAC3F,CAAC;AAED,0HAA0H;AAC1H,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY,EAAE,IAAU;IAClE,MA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C,wCAAwC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;QACvJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import { FIGURE_SECTION_PLANE, FIGURE_SECTION_POINT_LIMIT, checkFigureSection, figureExtrusionFeaturesOf, figureSectionSidesOf } from '@hatiolab/figure-model'\nimport type { FigureCavityRequest, FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionPoint } from '@hatiolab/figure-model'\n\n/*\n * What the section editor does to a drawn section's points, and how it says what is wrong with them (ADR-0100 §3.2).\n * The points are the kernel's own (`{ id, x, z }` for a push along Y), their validity is the kernel's own check, and a\n * point's number on screen is its own name's number (Q9): p3 is 「3」 before and after any edit, and deleting it leaves\n * 1, 2 and 4.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type Points = readonly FigureSectionPoint[]\n\n/** The number a point is shown by: its name's number. */\nexport const pointLabel = (id: string) => /^p(\\d+)$/.exec(id)?.[1] ?? id\n\n/** The next point's name: one past the highest number the loop has, so a new point never takes a gap's number. */\nexport function nextPointId(points: Points): string {\n return `p${Math.max(0, ...points.map(p => Number(/^p(\\d+)$/.exec(p.id)?.[1] ?? 0))) + 1}`\n}\n\n/** A point in the middle of the side from `from` to the point after it, whole millimetres; the new point's id with it. */\nexport function insertAfter(points: Points, from: string, axis: Axis): { points: FigureSectionPoint[]; id: string } {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const i = points.findIndex(p => p.id === from)\n const a = points[i]!,\n b = points[(i + 1) % points.length]!\n const id = nextPointId(points)\n const mid = { id, [u]: Math.round((a[u]! + b[u]!) / 2), [v]: Math.round((a[v]! + b[v]!) / 2) } as FigureSectionPoint\n return { points: [...points.slice(0, i + 1), mid, ...points.slice(i + 1)], id }\n}\n\n/** The points less one, or why not: a section is three points or more. */\nexport function removePoint(points: Points, id: string): FigureSectionPoint[] | { refused: 'too-few' } {\n if (points.length <= 3) return { refused: 'too-few' }\n return points.filter(p => p.id !== id)\n}\n\nexport function movePoint(points: Points, id: string, at: Partial<Record<Axis, number>>): FigureSectionPoint[] {\n return points.map(p => (p.id === id ? { ...p, ...at } : p))\n}\n\n/** What is wrong with the points, by the kernel's own check. */\nexport const issuesOf = (points: Points, axis: Axis) => checkFigureSection({ kind: 'polygon', points: [...points] }, axis)\n\n/** A side said in the loop's order, 3–4 not 4–3: its id is the pair in name order, which a person never sees. */\nfunction sideLabel(points: Points, axis: Axis, side: string): string {\n const s = figureSectionSidesOf({ kind: 'polygon', points: [...points] }, axis).find(x => x.id === side)\n const [a, b] = s?.from ? [s.from, s.to!] : side.split('~')\n return `${pointLabel(a!)}–${pointLabel(b!)}`\n}\n\n/** An issue as the words that say it: an i18n key and its values. */\nexport function issueWords(issue: FigureSectionIssue, points: Points, axis: Axis): { key: string; params: Record<string, string> } {\n const line = (s: string) => sideLabel(points, axis, s)\n switch (issue.code) {\n case 'SIDES_CROSS':\n return { key: 'figure.text.section-issue-cross', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_TOUCH':\n return { key: 'figure.text.section-issue-touch', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_FOLD':\n return { key: 'figure.text.section-issue-fold', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'ZERO_LENGTH_SIDE':\n return { key: 'figure.text.section-issue-zero-length', params: { a: line(issue.side) } }\n case 'ZERO_AREA':\n return { key: 'figure.text.section-issue-zero-area', params: {} }\n case 'TOO_FEW_POINTS':\n return { key: 'figure.text.section-issue-too-few', params: {} }\n case 'TOO_MANY_POINTS':\n return { key: 'figure.text.section-issue-too-many', params: { limit: String(issue.limit) } }\n case 'CORNER_TOO_LARGE':\n return { key: 'figure.text.section-issue-corner', params: { max: String(Math.round(issue.max * 1000) / 1000) } }\n default:\n return { key: 'figure.text.section-issue-number', params: {} }\n }\n}\n\n/** Every side and point an issue names, to mark on the drawing -- by more than colour: the list says them too. */\nexport function markedBy(issues: readonly FigureSectionIssue[]): { sides: Set<string>; points: Set<string> } {\n const sides = new Set<string>(),\n points = new Set<string>()\n for (const i of issues) {\n if ('sides' in i) for (const s of i.sides) sides.add(s)\n if ('side' in i) sides.add(i.side)\n if ('point' in i) points.add(i.point)\n if ('at' in i) points.add(String(i.at).split('.')[0]!)\n }\n for (const s of sides) for (const p of s.split('~')) points.add(p)\n return { sides, points }\n}\n\n/** How far the drawing reaches from the origin: the points' farthest coordinate with room around, in 50 mm steps. */\nexport function extentOf(points: Points, axis: Axis): number {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const far = Math.max(1, ...points.flatMap(p => [Math.abs(p[u] ?? 0), Math.abs(p[v] ?? 0)]))\n return Math.ceil((far * 1.4 + 40) / 50) * 50\n}\n\nexport const POINT_LIMIT = FIGURE_SECTION_POINT_LIMIT\n\n/** What the section editor holds while it is open: the points of a drawn section, the widths across, the length. */\nexport interface SectionWorking {\n points: FigureSectionPoint[]\n /** Along each plane axis: a rectangle's size, an ellipse's diameter. Empty for a drawn section. */\n across: Partial<Record<Axis, number>>\n length: number\n /** A drawn section's end drawn to one point (a pyramid), across the plane axes; null for a push. */\n apex: Partial<Record<Axis, number>> | null\n /** A pushed rectangle's or ellipse's inside, every side's wall written out; null for none or a drawn section. */\n cavity: { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] } | null\n}\n\n/** A pushed part's section, axis and ends -- or a pyramid's, whose end is its apex (figure-model `loft@1`). */\nexport function drawnOf(shape: FigureEvaluatedShape):\n | { axis: Axis; section: FigureSection; start: number; end: number; apex: Partial<Record<Axis, number>> | null }\n | undefined {\n if (shape.extrusion) return { ...shape.extrusion, apex: null }\n if (shape.loft) return { ...shape.loft, apex: shape.loft.apex }\n return undefined\n}\n\n/** Where a new apex goes: over the middle of the points' span, whole millimetres. */\nexport function apexOver(points: Points, axis: Axis): Partial<Record<Axis, number>> {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const mid = (x: Axis) => Math.round((Math.min(...points.map(p => p[x]!)) + Math.max(...points.map(p => p[x]!))) / 2)\n return { [u]: mid(u), [v]: mid(v) }\n}\n\n/** The working state of a pushed part as it stands. */\nexport function workingOf(shape: FigureEvaluatedShape): SectionWorking {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const across =\n s.kind === 'rectangle'\n ? { [u]: s.size[u]!, [v]: s.size[v]! }\n : s.kind === 'ellipse'\n ? { [u]: 2 * s.radius[u]!, [v]: 2 * s.radius[v]! }\n : {}\n const c = shape.extrusion && shape.cavity\n return {\n points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [],\n across,\n length: e.end - e.start,\n apex: e.apex ? { ...e.apex } : null,\n cavity: c ? { wall: { ...c.wall }, start: c.start, end: c.end } : null\n }\n}\n\n/**\n * The part as the working state would make it: its section, its length from the same start, its inside -- what the\n * inside's drawing reads, so its walls are judged against the widths being typed and not the ones the editor opened with.\n */\nexport function workingShapeOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureEvaluatedShape {\n const e = shape.extrusion!\n const { cavity: _, ...rest } = shape\n return {\n ...rest,\n extrusion: { ...e, section: sectionOf(shape, w), end: e.start + w.length },\n ...(w.cavity ? { cavity: { id: shape.cavity?.id ?? 'inside', wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } } : {})\n } as FigureEvaluatedShape\n}\n\n/** The section the working state makes, of the part's own kind: its corners kept, its points or widths the working ones. */\nexport function sectionOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureSection {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n if (s.kind === 'polygon') return { kind: 'polygon', points: w.points }\n if (s.kind === 'ellipse') return { kind: 'ellipse', radius: { [u]: w.across[u]! / 2, [v]: w.across[v]! / 2 } }\n return { kind: 'rectangle', size: { [u]: w.across[u]!, [v]: w.across[v]! }, ...(s.corner ? { corner: s.corner } : {}) }\n}\n\n/** What would be refused, as words, with the section's own issues for marking points and sides. By the kernel's checks. */\nexport function workingIssuesOf(\n shape: FigureEvaluatedShape,\n w: SectionWorking\n): { issues: FigureSectionIssue[]; words: Array<{ key: string; params: Record<string, string> }> } {\n const e = drawnOf(shape)!\n const section = sectionOf(shape, w)\n const issues = checkFigureSection(section, e.axis)\n const words = issues.map(i => issueWords(i, w.points, e.axis))\n if (!(Number.isFinite(w.length) && w.length > 0)) words.push({ key: 'figure.text.section-issue-length', params: {} })\n if (w.apex && !Object.values(w.apex).every(n => Number.isFinite(n))) words.push({ key: 'figure.text.section-issue-number', params: {} })\n if (!issues.length && words.length === 0 && w.cavity) {\n const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [{ id: 'inside', ...w.cavity }])\n if ('refused' in made) {\n const r = made.refused\n words.push({ key: r.code === 'CAVITY_NO_LENGTH' ? 'figure.text.section-issue-cavity-length' : 'figure.text.section-issue-cavity-walls', params: {} })\n }\n }\n return { issues, words }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"section-drawing.js","sourceRoot":"","sources":["../../client/modeller/section-drawing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE9J,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAYhD,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAExE,kHAAkH;AAClH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,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rusionFeaturesOf, figureSectionSidesOf } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureCavityRequest, FigureEvaluatedShape, FigureSection, FigureSectionIssue, FigureSectionMeasure, FigureSectionPoint } from '@hatiolab/figure-model'\nimport { END_FACE } from './section-controls.js'\n\n/*\n * What the section editor does to a drawn section's points, and how it says what is wrong with them (ADR-0100 §3.2).\n * The points are the kernel's own (`{ id, x, z }` for a push along Y), their validity is the kernel's own check, and a\n * point's number on screen is its own name's number (Q9): p3 is 「3」 before and after any edit, and deleting it leaves\n * 1, 2 and 4.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type Points = readonly FigureSectionPoint[]\n\n/** The number a point is shown by: its name's number. */\nexport const pointLabel = (id: string) => /^p(\\d+)$/.exec(id)?.[1] ?? id\n\n/** The next point's name: one past the highest number the loop has, so a new point never takes a gap's number. */\nexport function nextPointId(points: Points): string {\n return `p${Math.max(0, ...points.map(p => Number(/^p(\\d+)$/.exec(p.id)?.[1] ?? 0))) + 1}`\n}\n\n/** A point in the middle of the side from `from` to the point after it, whole millimetres; the new point's id with it. */\nexport function insertAfter(points: Points, from: string, axis: Axis): { points: FigureSectionPoint[]; id: string } {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const i = points.findIndex(p => p.id === from)\n const a = points[i]!,\n b = points[(i + 1) % points.length]!\n const id = nextPointId(points)\n const mid = { id, [u]: Math.round((a[u]! + b[u]!) / 2), [v]: Math.round((a[v]! + b[v]!) / 2) } as FigureSectionPoint\n return { points: [...points.slice(0, i + 1), mid, ...points.slice(i + 1)], id }\n}\n\n/** The points less one, or why not: a section is three points or more. */\nexport function removePoint(points: Points, id: string): FigureSectionPoint[] | { refused: 'too-few' } {\n if (points.length <= 3) return { refused: 'too-few' }\n return points.filter(p => p.id !== id)\n}\n\nexport function movePoint(points: Points, id: string, at: Partial<Record<Axis, number>>): FigureSectionPoint[] {\n return points.map(p => (p.id === id ? { ...p, ...at } : p))\n}\n\n/** What is wrong with the points, by the kernel's own check. */\nexport const issuesOf = (points: Points, axis: Axis) => checkFigureSection({ kind: 'polygon', points: [...points] }, axis)\n\n/** A side said in the loop's order, 3–4 not 4–3: its id is the pair in name order, which a person never sees. */\nfunction sideLabel(points: Points, axis: Axis, side: string): string {\n const s = figureSectionSidesOf({ kind: 'polygon', points: [...points] }, axis).find(x => x.id === side)\n const [a, b] = s?.from ? [s.from, s.to!] : side.split('~')\n return `${pointLabel(a!)}–${pointLabel(b!)}`\n}\n\n/** An issue as the words that say it: an i18n key and its values. */\nexport function issueWords(issue: FigureSectionIssue, points: Points, axis: Axis): { key: string; params: Record<string, string> } {\n const line = (s: string) => sideLabel(points, axis, s)\n switch (issue.code) {\n case 'SIDES_CROSS':\n return { key: 'figure.text.section-issue-cross', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_TOUCH':\n return { key: 'figure.text.section-issue-touch', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'SIDES_FOLD':\n return { key: 'figure.text.section-issue-fold', params: { a: line(issue.sides[0]), b: line(issue.sides[1]) } }\n case 'ZERO_LENGTH_SIDE':\n return { key: 'figure.text.section-issue-zero-length', params: { a: line(issue.side) } }\n case 'ZERO_AREA':\n return { key: 'figure.text.section-issue-zero-area', params: {} }\n case 'TOO_FEW_POINTS':\n return { key: 'figure.text.section-issue-too-few', params: {} }\n case 'TOO_MANY_POINTS':\n return { key: 'figure.text.section-issue-too-many', params: { limit: String(issue.limit) } }\n case 'CORNER_TOO_LARGE':\n return { key: 'figure.text.section-issue-corner', params: { max: String(Math.round(issue.max * 1000) / 1000) } }\n default:\n return { key: 'figure.text.section-issue-number', params: {} }\n }\n}\n\n/** Every side and point an issue names, to mark on the drawing -- by more than colour: the list says them too. */\nexport function markedBy(issues: readonly FigureSectionIssue[]): { sides: Set<string>; points: Set<string> } {\n const sides = new Set<string>(),\n points = new Set<string>()\n for (const i of issues) {\n if ('sides' in i) for (const s of i.sides) sides.add(s)\n if ('side' in i) sides.add(i.side)\n if ('point' in i) points.add(i.point)\n if ('at' in i) points.add(String(i.at).split('.')[0]!)\n }\n for (const s of sides) for (const p of s.split('~')) points.add(p)\n return { sides, points }\n}\n\n/** How far the drawing reaches from the origin: the points' farthest coordinate with room around, in 50 mm steps. */\nexport function extentOf(points: Points, axis: Axis): number {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const far = Math.max(1, ...points.flatMap(p => [Math.abs(p[u] ?? 0), Math.abs(p[v] ?? 0)]))\n return Math.ceil((far * 1.4 + 40) / 50) * 50\n}\n\nexport const POINT_LIMIT = FIGURE_SECTION_POINT_LIMIT\n\n/** What the section editor holds while it is open: the points of a drawn section, the widths across, the length. */\nexport interface SectionWorking {\n points: FigureSectionPoint[]\n /** Along each plane axis: a rectangle's size, an ellipse's diameter. Empty for a drawn section. */\n across: Partial<Record<Axis, number>>\n length: number\n /** A drawn section's end drawn to one point (a pyramid), across the plane axes; null for a push. */\n apex: Partial<Record<Axis, number>> | null\n /** A pushed rectangle's or ellipse's inside, every side's wall written out; null for none or a drawn section. */\n cavity: { wall: Record<string, number>; start: FigureCavityRequest['start']; end: FigureCavityRequest['end'] } | null\n}\n\n/** A pushed part's section, axis and ends -- or a pyramid's, whose end is its apex (figure-model `loft@1`). */\nexport function drawnOf(shape: FigureEvaluatedShape):\n | { axis: Axis; section: FigureSection; start: number; end: number; apex: Partial<Record<Axis, number>> | null }\n | undefined {\n if (shape.extrusion) return { ...shape.extrusion, apex: null }\n if (shape.loft) return { ...shape.loft, apex: shape.loft.apex }\n return undefined\n}\n\n/** Where a new apex goes: over the middle of the points' span, whole millimetres. */\nexport function apexOver(points: Points, axis: Axis): Partial<Record<Axis, number>> {\n const [u, v] = FIGURE_SECTION_PLANE[axis]\n const mid = (x: Axis) => Math.round((Math.min(...points.map(p => p[x]!)) + Math.max(...points.map(p => p[x]!))) / 2)\n return { [u]: mid(u), [v]: mid(v) }\n}\n\n/** The working state of a pushed part as it stands. */\nexport function workingOf(shape: FigureEvaluatedShape): SectionWorking {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n const across =\n s.kind === 'rectangle'\n ? { [u]: s.size[u]!, [v]: s.size[v]! }\n : s.kind === 'ellipse'\n ? { [u]: 2 * s.radius[u]!, [v]: 2 * s.radius[v]! }\n : {}\n const c = shape.extrusion && shape.cavity\n return {\n points: s.kind === 'polygon' ? s.points.map(p => ({ ...p })) : [],\n across,\n length: e.end - e.start,\n apex: e.apex ? { ...e.apex } : null,\n cavity: c ? { wall: { ...c.wall }, start: c.start, end: c.end } : null\n }\n}\n\n/**\n * The part as the working state would make it: its section, its length from the same start, its inside -- what the\n * inside's drawing reads, so its walls are judged against the widths being typed and not the ones the editor opened with.\n */\nexport function workingShapeOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureEvaluatedShape {\n const e = shape.extrusion!\n const { cavity: _, ...rest } = shape\n return {\n ...rest,\n extrusion: { ...e, section: sectionOf(shape, w), end: e.start + w.length },\n ...(w.cavity ? { cavity: { id: shape.cavity?.id ?? 'inside', wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } } : {})\n } as FigureEvaluatedShape\n}\n\n/** The section the working state makes, of the part's own kind: its corners kept, its points or widths the working ones. */\nexport function sectionOf(shape: FigureEvaluatedShape, w: SectionWorking): FigureSection {\n const e = drawnOf(shape)!\n const s = e.section\n const [u, v] = FIGURE_SECTION_PLANE[e.axis]\n if (s.kind === 'polygon') return { kind: 'polygon', points: w.points }\n if (s.kind === 'ellipse') return { kind: 'ellipse', radius: { [u]: w.across[u]! / 2, [v]: w.across[v]! / 2 } }\n return { kind: 'rectangle', size: { [u]: w.across[u]!, [v]: w.across[v]! }, ...(s.corner ? { corner: s.corner } : {}) }\n}\n\n/** What would be refused, as words, with the section's own issues for marking points and sides. By the kernel's checks. */\nexport function workingIssuesOf(\n shape: FigureEvaluatedShape,\n w: SectionWorking\n): { issues: FigureSectionIssue[]; words: Array<{ key: string; params: Record<string, string> }> } {\n const e = drawnOf(shape)!\n const section = sectionOf(shape, w)\n const issues = checkFigureSection(section, e.axis)\n const words = issues.map(i => issueWords(i, w.points, e.axis))\n if (!(Number.isFinite(w.length) && w.length > 0)) words.push({ key: 'figure.text.section-issue-length', params: {} })\n if (w.apex && !Object.values(w.apex).every(n => Number.isFinite(n))) words.push({ key: 'figure.text.section-issue-number', params: {} })\n if (!issues.length && words.length === 0 && w.cavity) {\n const made = figureExtrusionFeaturesOf({ axis: e.axis, section, start: e.start, end: e.start + w.length }, [{ id: 'inside', ...w.cavity }])\n if ('refused' in made) {\n const r = made.refused\n words.push({ key: r.code === 'CAVITY_NO_LENGTH' ? 'figure.text.section-issue-cavity-length' : 'figure.text.section-issue-cavity-walls', params: {} })\n }\n }\n return { issues, words }\n}\n\n/** The inside said so two can be compared: its walls by side, its ends. */\nexport const cavityKeyOf = (w: SectionWorking) => (w.cavity ? [Object.entries(w.cavity.wall).sort(), w.cavity.start, w.cavity.end] : null)\n\n/**\n * The one command for everything changed since the editor opened: a drawn section's points always, and of the rest only\n * what changed -- a measure left alone may follow another value and must not be written; an apex taken away is null\n * (back to a push), an inside taken away is null.\n */\nexport function sectionActionOf(part: string, kind: FigureSection['kind'] | undefined, opened: SectionWorking, w: SectionWorking): FigureAuthoringAction {\n const changed = (a: number | undefined, b: number | undefined) => Math.abs((a ?? 0) - (b ?? 0)) > 1e-9\n const across = Object.fromEntries(Object.entries(w.across).filter(([k, v]) => changed(v, opened.across[k as Axis])))\n const apexMoved = !w.apex !== !opened.apex || (!!w.apex && Object.entries(w.apex).some(([k, v]) => changed(v, opened.apex![k as Axis])))\n const cavityMoved = JSON.stringify(cavityKeyOf(w)) !== JSON.stringify(cavityKeyOf(opened))\n return {\n kind: 'set-section',\n part,\n ...(kind === 'polygon' ? { points: w.points.map(p => ({ ...p })) } : {}),\n ...(Object.keys(across).length ? { across } : {}),\n ...(changed(w.length, opened.length) ? { length: w.length } : {}),\n ...(apexMoved ? { apex: w.apex ? { ...w.apex } : null } : {}),\n ...(cavityMoved ? { cavity: w.cavity ? { wall: { ...w.cavity.wall }, start: w.cavity.start, end: w.cavity.end } : null } : {})\n }\n}\n\n/**\n * What a measure's field says under it: that it follows another value, or -- given where along the push a length\n * change keeps the part (1 its start, -1 its end, 0 its centre) -- the face it keeps; null when there is nothing to say.\n */\nexport function measureNoteOf(measure: FigureSectionMeasure | undefined, kept: -1 | 0 | 1 | undefined, axis: Axis): { key: string; face?: string } | null {\n if (measure === 'linked') return { key: 'figure.text.section-editor-linked' }\n if (kept === undefined) return null\n if (kept === 0) return { key: 'figure.text.section-editor-keeps-centre' }\n return { key: 'figure.text.section-editor-keeps', face: END_FACE(axis, kept === 1 ? 'start' : 'end') }\n}\n\n/** The words beside a drawn section's edit button: how many points it has, and the apex when its end is one point. */\nexport function sectionPointsWordsOf(drawn: ReturnType<typeof drawnOf>): { key: string; params: Record<string, string> } | null {\n if (drawn?.section.kind !== 'polygon') return null\n return { key: drawn.apex ? 'figure.text.section-points-apex' : 'figure.text.section-points', params: { points: String(drawn.section.points.length) } }\n}\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { figureShapeBoundsOf, type FigureAsset, type SlotLayout, type SlotPresetSize } from '@hatiolab/figure-model';
|
|
2
|
+
import type { FigureRenderPart } from './renderer.js';
|
|
3
|
+
export type SlotAnchorFace = 'top' | 'bottom';
|
|
4
|
+
export interface SlotAnchor {
|
|
5
|
+
id: string;
|
|
6
|
+
part: string;
|
|
7
|
+
face: SlotAnchorFace;
|
|
8
|
+
}
|
|
9
|
+
/** What the panel edits besides the tiers: the layout's name, what its slots are, and the anchors they stand on. */
|
|
10
|
+
export interface SlotLayoutForm {
|
|
11
|
+
label: string;
|
|
12
|
+
role: 'seat' | 'grip';
|
|
13
|
+
anchors: SlotAnchor[];
|
|
14
|
+
}
|
|
15
|
+
/** A layout problem as the editor shows it: a code, where, and its values. */
|
|
16
|
+
export interface SlotEditorIssue {
|
|
17
|
+
code: string;
|
|
18
|
+
path: string;
|
|
19
|
+
params?: Record<string, string | number>;
|
|
20
|
+
}
|
|
21
|
+
type Body = {
|
|
22
|
+
id: string;
|
|
23
|
+
shape?: Parameters<typeof figureShapeBoundsOf>[0];
|
|
24
|
+
};
|
|
25
|
+
/** The figure's layout as the form and the layout, or a form to start one from on the selected part's top. */
|
|
26
|
+
export declare function slotLayoutFormOf(asset: FigureAsset, part: string): {
|
|
27
|
+
form: SlotLayoutForm;
|
|
28
|
+
layout?: SlotLayout;
|
|
29
|
+
};
|
|
30
|
+
/** How big each anchor's face is, along the part's own X (width) and Z (depth): what the editor checks slots against. */
|
|
31
|
+
export declare function anchorFacesOf(anchors: readonly SlotAnchor[], geometry: readonly Body[]): Record<string, {
|
|
32
|
+
width: number;
|
|
33
|
+
depth: number;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Where an author starts: the equipment presets (figure-model, ADR-0118 decision 8), laid out on this figure's anchors --
|
|
37
|
+
* a one-anchor preset on the first, a twin fork on the first two. A single slot stands on a top and hangs from a bottom.
|
|
38
|
+
* The editor's own controls then make it what the equipment is.
|
|
39
|
+
*/
|
|
40
|
+
export declare function slotPresetsOf(anchors: readonly SlotAnchor[], say: (key: string) => string): {
|
|
41
|
+
key: import("@hatiolab/figure-model").SlotLayoutPresetKey;
|
|
42
|
+
label: string;
|
|
43
|
+
params: {
|
|
44
|
+
key: string;
|
|
45
|
+
label: string;
|
|
46
|
+
integer: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
build: (size: SlotPresetSize, params: Record<string, number>) => SlotLayout;
|
|
49
|
+
}[];
|
|
50
|
+
export declare function figureSlotIssues(layout: SlotLayout, anchors?: readonly string[]): SlotEditorIssue[];
|
|
51
|
+
/** The command the panel sends: the whole layout, its anchors and its name, as one step of the history. */
|
|
52
|
+
export declare function slotLayoutCommandOf(form: SlotLayoutForm, layout: SlotLayout, fallbackLabel: string): {
|
|
53
|
+
kind: "set-slot-layout";
|
|
54
|
+
label: string;
|
|
55
|
+
role: "seat" | "grip";
|
|
56
|
+
anchors: {
|
|
57
|
+
id: string;
|
|
58
|
+
part: string;
|
|
59
|
+
face: SlotAnchorFace;
|
|
60
|
+
}[];
|
|
61
|
+
layout: SlotLayout;
|
|
62
|
+
};
|
|
63
|
+
/** A new anchor's id: the part's, or the part's with a number when that is taken. */
|
|
64
|
+
export declare function anchorIdFor(part: string, taken: readonly string[]): string;
|
|
65
|
+
export declare const SLOT_MARK = "__slot";
|
|
66
|
+
type Evaluated = {
|
|
67
|
+
id: string;
|
|
68
|
+
pose: {
|
|
69
|
+
r: number[][];
|
|
70
|
+
t: number[];
|
|
71
|
+
};
|
|
72
|
+
region: {
|
|
73
|
+
dimensions: number[];
|
|
74
|
+
} | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The unfolded slots as boxes the canvas draws (ADR-0118 decision 4): each as big as what it allows, standing on its
|
|
78
|
+
* place -- or hanging from it, for a tier that hangs things -- so an author sees where every slot of the rule falls.
|
|
79
|
+
*/
|
|
80
|
+
export declare function slotMarksOf(places: readonly Evaluated[], layout: SlotLayout | undefined): FigureRenderPart[];
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What the Figure modeller gives the shared slot layout editor (`@operato/slot-layout-editor`, the one fmsim hosts too),
|
|
3
|
+
* and what it makes of the editor's result (ADR-0118). The editor edits tiers and slots; the modeller owns the anchors
|
|
4
|
+
* -- a part's top or bottom face, named -- and sends the whole layout as one `set-slot-layout` command.
|
|
5
|
+
*
|
|
6
|
+
* A figure's released slot layout is the only one there is (ADR-0118 decision 8, user): no scene or run overrides it, so
|
|
7
|
+
* this host offers no "use default" and no per-instance value.
|
|
8
|
+
*
|
|
9
|
+
* Kept free of Lit, i18n and the editor's element so node tests read it directly.
|
|
10
|
+
*/
|
|
11
|
+
import { figureShapeBoundsOf, figureSlotLayoutOf, figureSlotLayoutIssues, slotLayoutPreset, SLOT_LAYOUT_PRESET_KEYS, SLOT_LAYOUT_PRESET_PARAMS } from '@hatiolab/figure-model';
|
|
12
|
+
/** The figure's layout as the form and the layout, or a form to start one from on the selected part's top. */
|
|
13
|
+
export function slotLayoutFormOf(asset, part) {
|
|
14
|
+
const had = figureSlotLayoutOf(asset);
|
|
15
|
+
if (had)
|
|
16
|
+
return { form: { label: had.label, role: had.role, anchors: had.anchors.map(a => ({ ...a, face: a.face })) }, layout: had.layout };
|
|
17
|
+
return { form: { label: '', role: 'seat', anchors: part ? [{ id: part, part, face: 'top' }] : [] } };
|
|
18
|
+
}
|
|
19
|
+
/** How big each anchor's face is, along the part's own X (width) and Z (depth): what the editor checks slots against. */
|
|
20
|
+
export function anchorFacesOf(anchors, geometry) {
|
|
21
|
+
const out = {};
|
|
22
|
+
for (const a of anchors) {
|
|
23
|
+
const body = geometry.find(g => g.id === a.part);
|
|
24
|
+
if (!body?.shape)
|
|
25
|
+
continue;
|
|
26
|
+
const b = figureShapeBoundsOf(body.shape);
|
|
27
|
+
out[a.id] = { width: b.x.max - b.x.min, depth: b.z.max - b.z.min };
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Where an author starts: the equipment presets (figure-model, ADR-0118 decision 8), laid out on this figure's anchors --
|
|
33
|
+
* a one-anchor preset on the first, a twin fork on the first two. A single slot stands on a top and hangs from a bottom.
|
|
34
|
+
* The editor's own controls then make it what the equipment is.
|
|
35
|
+
*/
|
|
36
|
+
export function slotPresetsOf(anchors, say) {
|
|
37
|
+
const first = anchors[0];
|
|
38
|
+
const on = { ...(first ? { anchor: first.id } : {}), ...(anchors.length >= 2 ? { forks: [anchors[0].id, anchors[1].id] } : {}) };
|
|
39
|
+
const mount = first?.face === 'bottom' ? 'HANG' : 'ON';
|
|
40
|
+
return SLOT_LAYOUT_PRESET_KEYS.map(key => ({
|
|
41
|
+
key,
|
|
42
|
+
label: say(`figure.label.slot-preset-${key}`),
|
|
43
|
+
params: SLOT_LAYOUT_PRESET_PARAMS[key].map(p => ({ key: p.key, label: say(`figure.label.slot-preset-param-${p.key}`), integer: p.integer })),
|
|
44
|
+
build: (size, params) => slotLayoutPreset(key, size, params, { ...on, mount })
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
/*
|
|
48
|
+
* What figure-model asks beyond the editor's own checks: every slot names the types it takes (ADR-0118 decision 5) -- the
|
|
49
|
+
* editor's "any type" is a board's, not a figure's. The kernel's own check (`figureSlotLayoutIssues`, the one a
|
|
50
|
+
* placement's override is held to as well), said before Apply rather than refused after it; the editor already shows the
|
|
51
|
+
* common findings, so only the figure's own are added.
|
|
52
|
+
*/
|
|
53
|
+
export function figureSlotIssues(layout, anchors = layout.tiers.map(t => t.anchorId)) {
|
|
54
|
+
return figureSlotLayoutIssues(layout, anchors).filter(issue => issue.code === 'ACCEPTS_REQUIRED');
|
|
55
|
+
}
|
|
56
|
+
/** The command the panel sends: the whole layout, its anchors and its name, as one step of the history. */
|
|
57
|
+
export function slotLayoutCommandOf(form, layout, fallbackLabel) {
|
|
58
|
+
return {
|
|
59
|
+
kind: 'set-slot-layout',
|
|
60
|
+
label: form.label.trim() || fallbackLabel,
|
|
61
|
+
role: form.role,
|
|
62
|
+
anchors: form.anchors.map(a => ({ id: a.id.trim(), part: a.part, face: a.face })),
|
|
63
|
+
layout: structuredClone(layout)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** A new anchor's id: the part's, or the part's with a number when that is taken. */
|
|
67
|
+
export function anchorIdFor(part, taken) {
|
|
68
|
+
if (!taken.includes(part))
|
|
69
|
+
return part;
|
|
70
|
+
let n = 2;
|
|
71
|
+
while (taken.includes(`${part}_${n}`))
|
|
72
|
+
n++;
|
|
73
|
+
return `${part}_${n}`;
|
|
74
|
+
}
|
|
75
|
+
/* The token the canvas draws slots in: translucent, never picked, never saved. */
|
|
76
|
+
export const SLOT_MARK = '__slot';
|
|
77
|
+
/**
|
|
78
|
+
* The unfolded slots as boxes the canvas draws (ADR-0118 decision 4): each as big as what it allows, standing on its
|
|
79
|
+
* place -- or hanging from it, for a tier that hangs things -- so an author sees where every slot of the rule falls.
|
|
80
|
+
*/
|
|
81
|
+
export function slotMarksOf(places, layout) {
|
|
82
|
+
if (!layout)
|
|
83
|
+
return [];
|
|
84
|
+
const mountOf = new Map(layout.tiers.map(t => [t.tierNo, t.mount]));
|
|
85
|
+
const marks = [];
|
|
86
|
+
for (const p of places) {
|
|
87
|
+
const slot = /^t(\d+)_s\d+$/.exec(p.id);
|
|
88
|
+
if (!slot || !p.region)
|
|
89
|
+
continue;
|
|
90
|
+
const [width, height, depth] = p.region.dimensions;
|
|
91
|
+
const down = mountOf.get(Number(slot[1])) === 'HANG';
|
|
92
|
+
marks.push({
|
|
93
|
+
id: `${SLOT_MARK}:${p.id}`,
|
|
94
|
+
shape: {
|
|
95
|
+
provider: 'extrude',
|
|
96
|
+
dimensions: { width, height, depth },
|
|
97
|
+
extrusion: { axis: 'y', section: { kind: 'rectangle', size: { x: width, z: depth } }, start: down ? -height : 0, end: down ? 0 : height }
|
|
98
|
+
},
|
|
99
|
+
pose: p.pose,
|
|
100
|
+
material: { token: SLOT_MARK, transparent: true }
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return marks;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=slot-layout-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-layout-host.js","sourceRoot":"","sources":["../../client/modeller/slot-layout-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EAI1B,MAAM,wBAAwB,CAAA;AAwB/B,8GAA8G;AAC9G,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,IAAY;IAC/D,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAc,CAAC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CAAC,IAAI;YACZ,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE;SAClD,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/*\n * What the Figure modeller gives the shared slot layout editor (`@operato/slot-layout-editor`, the one fmsim hosts too),\n * and what it makes of the editor's result (ADR-0118). The editor edits tiers and slots; the modeller owns the anchors\n * -- a part's top or bottom face, named -- and sends the whole layout as one `set-slot-layout` command.\n *\n * A figure's released slot layout is the only one there is (ADR-0118 decision 8, user): no scene or run overrides it, so\n * this host offers no \"use default\" and no per-instance value.\n *\n * Kept free of Lit, i18n and the editor's element so node tests read it directly.\n */\nimport {\n figureShapeBoundsOf,\n figureSlotLayoutOf,\n figureSlotLayoutIssues,\n slotLayoutPreset,\n SLOT_LAYOUT_PRESET_KEYS,\n SLOT_LAYOUT_PRESET_PARAMS,\n type FigureAsset,\n type SlotLayout,\n type SlotPresetSize\n} from '@hatiolab/figure-model'\nimport type { FigureRenderPart } from './renderer.js'\n\nexport type SlotAnchorFace = 'top' | 'bottom'\nexport interface SlotAnchor {\n id: string\n part: string\n face: SlotAnchorFace\n}\n/** What the panel edits besides the tiers: the layout's name, what its slots are, and the anchors they stand on. */\nexport interface SlotLayoutForm {\n label: string\n role: 'seat' | 'grip'\n anchors: SlotAnchor[]\n}\n/** A layout problem as the editor shows it: a code, where, and its values. */\nexport interface SlotEditorIssue {\n code: string\n path: string\n params?: Record<string, string | number>\n}\n\ntype Body = { id: string; shape?: Parameters<typeof figureShapeBoundsOf>[0] }\n\n/** The figure's layout as the form and the layout, or a form to start one from on the selected part's top. */\nexport function slotLayoutFormOf(asset: FigureAsset, part: string): { form: SlotLayoutForm; layout?: SlotLayout } {\n const had = figureSlotLayoutOf(asset as never)\n if (had) return { form: { label: had.label, role: had.role, anchors: had.anchors.map(a => ({ ...a, face: a.face as SlotAnchorFace })) }, layout: had.layout }\n return { form: { label: '', role: 'seat', anchors: part ? [{ id: part, part, face: 'top' }] : [] } }\n}\n\n/** How big each anchor's face is, along the part's own X (width) and Z (depth): what the editor checks slots against. */\nexport function anchorFacesOf(anchors: readonly SlotAnchor[], geometry: readonly Body[]): Record<string, { width: number; depth: number }> {\n const out: Record<string, { width: number; depth: number }> = {}\n for (const a of anchors) {\n const body = geometry.find(g => g.id === a.part)\n if (!body?.shape) continue\n const b = figureShapeBoundsOf(body.shape)\n out[a.id] = { width: b.x.max - b.x.min, depth: b.z.max - b.z.min }\n }\n return out\n}\n\n/**\n * Where an author starts: the equipment presets (figure-model, ADR-0118 decision 8), laid out on this figure's anchors --\n * a one-anchor preset on the first, a twin fork on the first two. A single slot stands on a top and hangs from a bottom.\n * The editor's own controls then make it what the equipment is.\n */\nexport function slotPresetsOf(anchors: readonly SlotAnchor[], say: (key: string) => string) {\n const first = anchors[0]\n const on = { ...(first ? { anchor: first.id } : {}), ...(anchors.length >= 2 ? { forks: [anchors[0]!.id, anchors[1]!.id] as [string, string] } : {}) }\n const mount = first?.face === 'bottom' ? ('HANG' as const) : ('ON' as const)\n return SLOT_LAYOUT_PRESET_KEYS.map(key => ({\n key,\n label: say(`figure.label.slot-preset-${key}`),\n params: SLOT_LAYOUT_PRESET_PARAMS[key].map(p => ({ key: p.key, label: say(`figure.label.slot-preset-param-${p.key}`), integer: p.integer })),\n build: (size: SlotPresetSize, params: Record<string, number>) => slotLayoutPreset(key, size, params, { ...on, mount })\n }))\n}\n\n/*\n * What figure-model asks beyond the editor's own checks: every slot names the types it takes (ADR-0118 decision 5) -- the\n * editor's \"any type\" is a board's, not a figure's. The kernel's own check (`figureSlotLayoutIssues`, the one a\n * placement's override is held to as well), said before Apply rather than refused after it; the editor already shows the\n * common findings, so only the figure's own are added.\n */\nexport function figureSlotIssues(layout: SlotLayout, anchors: readonly string[] = layout.tiers.map(t => t.anchorId)): SlotEditorIssue[] {\n return figureSlotLayoutIssues(layout, anchors).filter(issue => issue.code === 'ACCEPTS_REQUIRED')\n}\n\n/** The command the panel sends: the whole layout, its anchors and its name, as one step of the history. */\nexport function slotLayoutCommandOf(form: SlotLayoutForm, layout: SlotLayout, fallbackLabel: string) {\n return {\n kind: 'set-slot-layout' as const,\n label: form.label.trim() || fallbackLabel,\n role: form.role,\n anchors: form.anchors.map(a => ({ id: a.id.trim(), part: a.part, face: a.face })),\n layout: structuredClone(layout)\n }\n}\n\n/** A new anchor's id: the part's, or the part's with a number when that is taken. */\nexport function anchorIdFor(part: string, taken: readonly string[]): string {\n if (!taken.includes(part)) return part\n let n = 2\n while (taken.includes(`${part}_${n}`)) n++\n return `${part}_${n}`\n}\n\n/* The token the canvas draws slots in: translucent, never picked, never saved. */\nexport const SLOT_MARK = '__slot'\n\ntype Evaluated = { id: string; pose: { r: number[][]; t: number[] }; region: { dimensions: number[] } | null }\n\n/**\n * The unfolded slots as boxes the canvas draws (ADR-0118 decision 4): each as big as what it allows, standing on its\n * place -- or hanging from it, for a tier that hangs things -- so an author sees where every slot of the rule falls.\n */\nexport function slotMarksOf(places: readonly Evaluated[], layout: SlotLayout | undefined) {\n if (!layout) return []\n const mountOf = new Map(layout.tiers.map(t => [t.tierNo, t.mount]))\n const marks: FigureRenderPart[] = []\n for (const p of places) {\n const slot = /^t(\\d+)_s\\d+$/.exec(p.id)\n if (!slot || !p.region) continue\n const [width, height, depth] = p.region.dimensions as [number, number, number]\n const down = mountOf.get(Number(slot[1])) === 'HANG'\n marks.push({\n id: `${SLOT_MARK}:${p.id}`,\n shape: {\n provider: 'extrude',\n dimensions: { width, height, depth },\n extrusion: { axis: 'y', section: { kind: 'rectangle', size: { x: width, z: depth } }, start: down ? -height : 0, end: down ? 0 : height }\n },\n pose: p.pose,\n material: { token: SLOT_MARK, transparent: true }\n })\n }\n return marks\n}\n"]}
|
|
@@ -21,7 +21,7 @@ import '../modeller/figure-first-save.js';
|
|
|
21
21
|
import { activePalette } from '@hatiolab/things-scene';
|
|
22
22
|
import { askAssistant, clearAssistantSurface, notifyAssistantSurface, provideAssistantSurface } from '@things-factory/ai-assistant/dist-client/index.js';
|
|
23
23
|
import { typeOf } from '../modeller/first-save.js';
|
|
24
|
-
import {
|
|
24
|
+
import { editRefusalOf } from '../modeller/refusals.js';
|
|
25
25
|
import { proposalOutcomeFrom, takeFigureOffer, takePendingNewFigure } from '../modeller/ai-proposal.js';
|
|
26
26
|
/**
|
|
27
27
|
* The product page has exactly one authoritative workspace for UI and AI input transactions.
|
|
@@ -379,10 +379,11 @@ let FigureModellerPage = class FigureModellerPage extends PageView {
|
|
|
379
379
|
this.commandError =
|
|
380
380
|
error?.code === 'OCCUPANCY_NO_PARTS'
|
|
381
381
|
? i18next.t('figure.text.fit-needs-parts')
|
|
382
|
-
:
|
|
383
|
-
(error
|
|
382
|
+
: error?.code
|
|
383
|
+
? editRefusalOf(error, (key, params) => i18next.t(key, params))
|
|
384
|
+
: error instanceof Error
|
|
384
385
|
? error.message
|
|
385
|
-
: String(error)
|
|
386
|
+
: String(error);
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
connectedCallback() {
|