@floless/app 0.142.0 → 0.144.0
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/dist/floless-server.cjs +218260 -189290
- package/dist/schemas/steel.model.v2.schema.json +50 -2
- package/dist/schemas/tekla.model.v1.schema.json +66 -0
- package/dist/schemas/tekla.model.v2.schema.json +69 -0
- package/dist/schemas/tekla.source-package.v1.schema.json +37 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +24 -1
- package/dist/skills/floless-app-workflows/SKILL.md +8 -2
- package/dist/skills/floless-app-workflows/references/workspace-data.md +25 -4
- package/dist/templates/floless-workspace-model-report.flo +27 -23
- package/dist/templates/revit-model.flo +6 -2
- package/dist/templates/tekla-model-report.flo +60 -0
- package/dist/templates/tekla-parser.flo +61 -0
- package/dist/web/app.css +89 -2
- package/dist/web/app.js +5 -4
- package/dist/web/aware.js +441 -47
- package/dist/web/chat.css +2 -0
- package/dist/web/chat.js +37 -3
- package/dist/web/commands-revit.js +4 -0
- package/dist/web/commands-shell.js +136 -3
- package/dist/web/commands-steel.js +8 -2
- package/dist/web/commands-tekla-parser.js +48 -0
- package/dist/web/commands.js +1 -1
- package/dist/web/filter-ai-context.js +35 -6
- package/dist/web/filter-ai-proposal.js +40 -4
- package/dist/web/grid-core.js +15 -0
- package/dist/web/index.html +40 -2
- package/dist/web/instructor.js +26 -14
- package/dist/web/left-pane.js +160 -10
- package/dist/web/model-artifact-loader.js +15 -0
- package/dist/web/model-display-units.js +89 -0
- package/dist/web/model-editor-revit-adapter.js +21 -4
- package/dist/web/model-editor.css +4 -2
- package/dist/web/model-measure.js +10 -6
- package/dist/web/model-panel-bridge.js +46 -3
- package/dist/web/model-pointer-dock.js +21 -1
- package/dist/web/model-property-display.js +91 -0
- package/dist/web/model-revit-module.js +9 -0
- package/dist/web/model-selection-tools.js +11 -0
- package/dist/web/model-spatial-panel.js +52 -21
- package/dist/web/model-structural-grid-view.js +334 -0
- package/dist/web/model-tekla-selection.js +32 -0
- package/dist/web/model-viewport-revit-adapter.js +119 -32
- package/dist/web/revit-editor.css +11 -1
- package/dist/web/revit-editor.html +4 -3
- package/dist/web/revit-editor.js +589 -111
- package/dist/web/steel-3d-view.js +58 -372
- package/dist/web/steel-editor.html +258 -17
- package/dist/web/steel-filter.html +17 -3
- package/dist/web/tekla-editor.html +71 -0
- package/dist/web/tekla-structural-grid-adapter.js +56 -0
- package/dist/web/workspaces.js +872 -97
- package/distribution-profile-production.mjs +4 -0
- package/distribution-resource-inventory.mjs +4 -2
- package/package.json +5 -2
|
@@ -89,16 +89,31 @@ const CONTROLS = Object.freeze({
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
export function revitRenderPlan(entries = revitCapabilityEntries()) {
|
|
92
|
+
return readOnlyModelRenderPlan({ entries, commandPrefix: 'revit', sourceLabel: 'Revit' });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const mappedText = (value, commandPrefix, sourceLabel) => typeof value === 'string'
|
|
96
|
+
? value.replaceAll('revit.', `${commandPrefix}.`).replaceAll('Revit', sourceLabel)
|
|
97
|
+
: value;
|
|
98
|
+
|
|
99
|
+
/** Reuse the authenticated read-only model chrome without leaking Revit product language. */
|
|
100
|
+
export function readOnlyModelRenderPlan({
|
|
101
|
+
entries = revitCapabilityEntries(), commandPrefix = 'revit', sourceLabel = 'Revit',
|
|
102
|
+
} = {}) {
|
|
92
103
|
const resolved = resolveToolbar(capabilityMap(entries));
|
|
93
104
|
const clusters = toolbarClusters(resolved).map((cluster) => ({
|
|
94
105
|
...cluster,
|
|
95
106
|
controls: cluster.controls.map((control) => {
|
|
96
107
|
const descriptor = CONTROLS[control.id];
|
|
97
108
|
if (!descriptor) throw new Error(`revitRenderPlan: no descriptor for "${control.id}"`);
|
|
98
|
-
const withCommand =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
const withCommand = Object.fromEntries(Object.entries({
|
|
110
|
+
...descriptor, semantic: control.id, cmd: descriptor.cmd ?? REVIT_COMMAND_BINDING_V1[control.id],
|
|
111
|
+
}).map(([key, value]) => [key, mappedText(value, commandPrefix, sourceLabel)]));
|
|
112
|
+
if (!descriptor.items) return withCommand;
|
|
113
|
+
const live = control.items ? new Set(control.items) : null;
|
|
114
|
+
return { ...withCommand, items: descriptor.items.filter((item) => !item.cap || !live || live.has(item.cap)).map((item) => (
|
|
115
|
+
Object.fromEntries(Object.entries(item).map(([key, value]) => [key, mappedText(value, commandPrefix, sourceLabel)]))
|
|
116
|
+
)) };
|
|
102
117
|
}),
|
|
103
118
|
}));
|
|
104
119
|
const plan = { schema: 'floless.model-toolbar-plan/v1', clusters };
|
|
@@ -139,3 +154,5 @@ export function createRevitEditorAdapter({ viewport, host = {} }) {
|
|
|
139
154
|
const capabilities = capabilityMap(revitCapabilityEntries());
|
|
140
155
|
return createModelEditorFacade({ provider: provider(viewport), capabilities, host });
|
|
141
156
|
}
|
|
157
|
+
|
|
158
|
+
export const createReadOnlyModelEditorAdapter = createRevitEditorAdapter;
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
.model-view-cube-host canvas:focus-visible,#m3dCube canvas:focus-visible{outline:2px solid var(--brand,var(--accent,#60a5fa));outline-offset:3px;border-radius:8px}
|
|
118
118
|
.model-view-cube-status{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
119
119
|
|
|
120
|
-
.model-clip-list{border-top:1px solid var(--line);margin-top:8px;padding-top:4px}.model-clip-list-header{height:30px;display:flex;align-items:center;gap:7px;padding:0 5px;color:var(--text)}.model-clip-list-header strong{font-size:11px;text-transform:uppercase;letter-spacing:.08em}.model-clip-count{min-width:18px;height:18px;display:grid;place-items:center;border-radius:9px;background:var(--btn);color:var(--muted);font-size:10px}.model-clip-enable-all{width:24px;min-width:24px;min-height:24px;padding:0;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-enable-all[data-state="on"]{color:var(--brand,#60a5fa)}.model-clip-enable-all[data-state="mixed"]{color:#64748b}.model-clip-clear{margin-left:auto}.model-clip-list-rows{display:grid;gap:2px}.model-clip-row{min-height:30px;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:4px;border-radius:5px;padding:2px 3px}.model-clip-row:hover,.model-clip-row.is-selected{background:var(--accent-soft)}.model-clip-row.is-selected{outline:1px solid color-mix(in srgb,var(--brand,#3b82f6) 58%,transparent)}.model-clip-row button{min-width:0;min-height:24px;padding:2px 5px;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-row button:hover{background:var(--btn-hover);color:var(--text)}.model-clip-enable{width:22px;border:1px solid var(--line)!important;color:var(--brand,#60a5fa)!important}.model-clip-enable[aria-pressed="false"]{color:transparent!important}.model-clip-label{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)!important}.model-clip-remove{font-size:16px;line-height:1}.model-clip-rename{width:100%;min-width:0;height:25px;border:1px solid var(--brand,#3b82f6);border-radius:4px;background:var(--bg,#020817);color:var(--text);padding:2px 6px;font:inherit;outline:none}.model-clip-list-empty{padding:10px 7px 12px;color:var(--muted);font-size:11px;line-height:1.45}.model-clip-drag-readout{position:fixed;z-index:60;pointer-events:none;padding:5px 9px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);box-shadow:0 3px 10px rgba(0,0,0,.45);font:11px var(--mono,monospace)}
|
|
120
|
+
.model-clip-list{border-top:1px solid var(--line);margin-top:8px;padding-top:4px}.model-clip-list-header{height:30px;display:flex;align-items:center;gap:7px;padding:0 5px;color:var(--text)}.model-clip-list-header strong{font-size:11px;text-transform:uppercase;letter-spacing:.08em}.model-clip-count{min-width:18px;height:18px;display:grid;place-items:center;border-radius:9px;background:var(--btn);color:var(--muted);font-size:10px}.model-clip-enable-all{width:24px;min-width:24px;min-height:24px;padding:0;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-enable-all[data-state="on"]{color:var(--brand,#60a5fa)}.model-clip-enable-all[data-state="mixed"]{color:#64748b}.model-clip-clear{margin-left:auto}.model-clip-list-rows{display:grid;align-content:start;gap:2px}.model-clip-row{min-height:30px;display:grid;grid-template-columns:24px minmax(0,1fr) 24px;align-items:center;gap:4px;border-radius:5px;padding:2px 3px}.model-clip-row:hover,.model-clip-row.is-selected{background:var(--accent-soft)}.model-clip-row.is-selected{outline:1px solid color-mix(in srgb,var(--brand,#3b82f6) 58%,transparent)}.model-clip-row button{min-width:0;min-height:24px;padding:2px 5px;border:0;background:transparent;color:var(--muted);box-shadow:none}.model-clip-row button:hover{background:var(--btn-hover);color:var(--text)}.model-clip-enable{width:22px;border:1px solid var(--line)!important;color:var(--brand,#60a5fa)!important}.model-clip-enable[aria-pressed="false"]{color:transparent!important}.model-clip-label{text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)!important}.model-clip-remove{font-size:16px;line-height:1}.model-clip-rename{width:100%;min-width:0;height:25px;border:1px solid var(--brand,#3b82f6);border-radius:4px;background:var(--bg,#020817);color:var(--text);padding:2px 6px;font:inherit;outline:none}.model-clip-list-empty{padding:10px 7px 12px;color:var(--muted);font-size:11px;line-height:1.45}.model-clip-drag-readout{position:fixed;z-index:60;pointer-events:none;padding:5px 9px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);box-shadow:0 3px 10px rgba(0,0,0,.45);font:11px var(--mono,monospace)}
|
|
121
121
|
|
|
122
122
|
/* Inspector seam, stub and grip are shared with master Steel. */
|
|
123
123
|
.model-inspector-resizer{flex:none;width:11px;cursor:col-resize;background:transparent;position:relative;z-index:6;touch-action:none;align-self:stretch}
|
|
@@ -162,7 +162,9 @@ body:has(.model-inspector-resizer.drag) .model-inspector-panel,body:has(.model-i
|
|
|
162
162
|
.model-module-actions{gap:5px}
|
|
163
163
|
.model-module-actions button{min-height:28px;padding:3px 9px;font-size:11px}
|
|
164
164
|
.model-module-actions button.on{background:var(--brand,var(--accent,#60a5fa));border-color:var(--brand,var(--accent,#60a5fa));color:#0f172a}
|
|
165
|
-
|
|
165
|
+
/* One line, width-capped: a sentence-long status (a snap refusal) must never widen the actions bar enough to
|
|
166
|
+
wrap the dock (#1738). The full text is in the pill's data-tip and its role=status announcement. */
|
|
167
|
+
.model-dock-status{min-width:52px;max-width:320px;padding:0 5px;color:var(--mut,var(--muted));font-size:10px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
166
168
|
|
|
167
169
|
/* Shared model-space dimension and acquisition overlay. Providers supply points; this presentation,
|
|
168
170
|
including witness lines, ticks, reticle and acquired-target readout, is identical in every module. */
|
|
@@ -156,11 +156,11 @@ function constrainedPoint(anchor, target, lockSet, frame, verticalOnly) {
|
|
|
156
156
|
* Session-only, provider-neutral point → point → placement dimension tool.
|
|
157
157
|
* @param {{surface:any,host:any,viewport:any,snapIndex?:()=>any,onState?:(state:any)=>void,
|
|
158
158
|
* onChange?:(value:any,reason:string)=>void,onEditRequest?:((dimension:any,index:number)=>void)|null,
|
|
159
|
-
* initialDimensions?:any[],initialPresentation?:any}} options
|
|
159
|
+
* initialDimensions?:any[],initialPresentation?:any,formatDistance?:((mm:number)=>string)|null}} options
|
|
160
160
|
*/
|
|
161
161
|
export function mountModelMeasureTool({
|
|
162
162
|
surface, host, viewport, snapIndex = () => null, onState = () => {}, onChange = () => {},
|
|
163
|
-
onEditRequest = null, initialDimensions = [], initialPresentation = null,
|
|
163
|
+
onEditRequest = null, initialDimensions = [], initialPresentation = null, formatDistance = null,
|
|
164
164
|
}) {
|
|
165
165
|
if (!surface || !host || !viewport) throw new Error('Model measurement needs a surface, overlay host, and viewport.');
|
|
166
166
|
const svg = document.createElementNS(SVG_NS, 'svg'); svg.classList.add('model-dim-overlay'); svg.setAttribute('aria-hidden', 'true'); host.append(svg);
|
|
@@ -208,7 +208,7 @@ export function mountModelMeasureTool({
|
|
|
208
208
|
const distance = viewport.distanceMm?.(dimension.a, dimension.b) ?? Math.hypot(...dimension.b.map((value, axis) => value - dimension.a[axis]));
|
|
209
209
|
const style = { ...presentation, ...(dimension.presentation ?? {}) };
|
|
210
210
|
const converted = distanceInUnits(distance, style.units);
|
|
211
|
-
label.textContent = `${converted.toLocaleString(undefined, { minimumFractionDigits: style.precision, maximumFractionDigits: style.precision })} ${style.units}`;
|
|
211
|
+
label.textContent = formatDistance ? formatDistance(distance) : `${converted.toLocaleString(undefined, { minimumFractionDigits: style.precision, maximumFractionDigits: style.precision })} ${style.units}`;
|
|
212
212
|
group.append(label); svg.append(group);
|
|
213
213
|
};
|
|
214
214
|
const drawGuide = (guide) => {
|
|
@@ -255,7 +255,10 @@ export function mountModelMeasureTool({
|
|
|
255
255
|
};
|
|
256
256
|
const notify = () => {
|
|
257
257
|
const index = snapIndex(); const step = !armed ? 0 : first === null ? 1 : second === null ? 2 : 3;
|
|
258
|
-
|
|
258
|
+
// The snap refusal is about picking points, so it is shown only while the tool is armed. Disarmed, the
|
|
259
|
+
// status returns to the session (Ready / N placed / selected) — a sentence-long refusal left behind there
|
|
260
|
+
// kept the dock's actions bar wide enough to strand it on its own upper row (#1738).
|
|
261
|
+
const status = armed && index?.available === false ? index.refusal?.message : (step === 1 ? 'Pick point 1' : step === 2 ? 'Pick point 2' : step === 3 ? 'Place dimension'
|
|
259
262
|
: selectedIndex !== null ? 'Dimension selected · Enter to edit · Delete to remove' : (dimensions.length ? `${dimensions.length} placed` : 'Ready'));
|
|
260
263
|
onState({ armed, hasDraft: !!first, step, count: dimensions.length, selectedIndex, status, visible,
|
|
261
264
|
presentation: { ...presentation }, snapModes: { ...snapModes }, locks: [...lockSet],
|
|
@@ -314,8 +317,8 @@ export function mountModelMeasureTool({
|
|
|
314
317
|
}
|
|
315
318
|
dialog.append(group);
|
|
316
319
|
};
|
|
317
|
-
choice('Units', ['mm', 'cm', 'm', 'in', 'ft'], dimension.presentation.units, (units) => api.update(index, { presentation: { units } }));
|
|
318
|
-
choice('Precision', [0, 1, 2, 3, 4], dimension.presentation.precision, (precision) => api.update(index, { presentation: { precision } }));
|
|
320
|
+
if (!formatDistance) choice('Units', ['mm', 'cm', 'm', 'in', 'ft'], dimension.presentation.units, (units) => api.update(index, { presentation: { units } }));
|
|
321
|
+
if (!formatDistance) choice('Precision', [0, 1, 2, 3, 4], dimension.presentation.precision, (precision) => api.update(index, { presentation: { precision } }));
|
|
319
322
|
choice('Label', ['above', 'center', 'below'], dimension.presentation.labelPlacement, (labelPlacement) => api.update(index, { presentation: { labelPlacement } }));
|
|
320
323
|
const actions = document.createElement('div'); actions.className = 'model-dimension-editor-actions';
|
|
321
324
|
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Delete'; remove.dataset.tip = 'Delete selected dimension';
|
|
@@ -384,6 +387,7 @@ export function mountModelMeasureTool({
|
|
|
384
387
|
selectedIndex, visible, presentation: { ...presentation }, snapModes: { ...snapModes }, locks: [...lockSet], activeFrame: resolveFrame(viewport).label, onePickKind }; },
|
|
385
388
|
dimensions() { return session.dimensions(); },
|
|
386
389
|
serialize() { return session.serialize(); },
|
|
390
|
+
refresh() { render(); },
|
|
387
391
|
destroy() { closeOnePickMenu(); closeEditor(); unsubscribe(); releaseInput(); session.dispose(); svg.remove(); },
|
|
388
392
|
};
|
|
389
393
|
notify(); return api;
|
|
@@ -49,13 +49,15 @@ export function serializeModelPanelNodes(host, path = 'root') {
|
|
|
49
49
|
nodes.push({ label: trigger.querySelector('.row-label')?.textContent || trigger.textContent || '',
|
|
50
50
|
count: trigger.querySelector('.explorer-count')?.textContent || null, children,
|
|
51
51
|
tip: trigger.dataset.tip || null,
|
|
52
|
+
...(trigger.dataset.selectable === 'true' ? { selectable: true } : {}),
|
|
52
53
|
lazy: !children.length && Number(trigger.querySelector('.explorer-count')?.textContent || 0) > 0,
|
|
53
54
|
expanded: trigger.getAttribute('aria-expanded') === 'true', groupId: `${path}.${index}` });
|
|
54
55
|
}
|
|
55
56
|
continue;
|
|
56
57
|
}
|
|
57
|
-
if (child.classList.contains('explorer-row')) nodes.push({ label: child.querySelector('.row-label')?.textContent
|
|
58
|
+
if (child.classList.contains('explorer-row')) nodes.push({ label: child.querySelector('.row-label')?.textContent ?? child.textContent ?? '',
|
|
58
59
|
count: child.querySelector('.explorer-count')?.textContent || null, entityId: child.dataset.entityId || null,
|
|
60
|
+
...(child.classList.contains('model-object-row') ? { objectFields: Object.fromEntries(['name', 'profile', 'id'].map((key) => [key, child.querySelector(`[data-object-field="${key}"]`)?.textContent ?? null])) } : {}),
|
|
59
61
|
tip: child.dataset.tip || null });
|
|
60
62
|
}
|
|
61
63
|
return nodes;
|
|
@@ -80,6 +82,24 @@ export function expandModelPanelGroup(tabs, byId, groupId) {
|
|
|
80
82
|
return true;
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
/** Select an already-populated selectable group without changing its disclosure state. */
|
|
86
|
+
export function selectModelPanelGroup(tabs, byId, groupId) {
|
|
87
|
+
const parts = String(groupId || '').split('.'), key = parts.shift();
|
|
88
|
+
const tab = tabs.find((item) => item.key === key); if (!tab || !parts.length) return false;
|
|
89
|
+
let host = byId(tab.bodyId), trigger = null;
|
|
90
|
+
for (const raw of parts) {
|
|
91
|
+
if (!/^\d+$/.test(raw)) return false;
|
|
92
|
+
const branch = [...(host?.children || [])][Number(raw)];
|
|
93
|
+
if (!branch?.classList.contains('revit-tree-branch')) return false;
|
|
94
|
+
trigger = branch.querySelector(':scope > .explorer-row');
|
|
95
|
+
host = branch.querySelector(':scope > .revit-tree-children');
|
|
96
|
+
if (!trigger || !host) return false;
|
|
97
|
+
}
|
|
98
|
+
if (trigger?.dataset.selectable !== 'true') return false;
|
|
99
|
+
trigger.dispatchEvent(new trigger.ownerDocument.defaultView.Event('model-group-select'));
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
83
103
|
// The main window's panel frame is an about:blank iframe, so it shares this origin and an editor may move its
|
|
84
104
|
// own elements into it. It gets the editor's stylesheets and follows the editor's <html> attributes (the
|
|
85
105
|
// theme), so what moves renders as it did at home. Returns the function that stops following.
|
|
@@ -151,7 +171,9 @@ export function createPanelHost({ win = window, root, bodies, install = (_doc) =
|
|
|
151
171
|
|
|
152
172
|
export function createModelPanelBridge({ win = window, origin = location.origin, snapshot, selectedId, selectedIds = () => {
|
|
153
173
|
const id = selectedId(); return typeof id === 'string' ? [id] : [];
|
|
154
|
-
},
|
|
174
|
+
}, select, expand, selectGroup = (_groupId) => false, search = (_tab, _query) => false,
|
|
175
|
+
selectionState = () => ({}), panel = (_tab, _person, _follow) => false,
|
|
176
|
+
gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksChanged = null }) {
|
|
155
177
|
let requested = false;
|
|
156
178
|
let generation = null;
|
|
157
179
|
let revision = 0;
|
|
@@ -172,7 +194,7 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
|
|
|
172
194
|
// `subjects` is the selection as model objects a chat message may be about (#1653): {source, revision, total,
|
|
173
195
|
// items: [{kind, id, label}]}, or null. Raw selected ids stay beside it for the tree's own rows.
|
|
174
196
|
const publishSelection = (selectionOrigin = 'tree') => lifecycle === 'ready' && send({ type: 'selection', selectedId: selectedId(), selectedIds: selectedIds(),
|
|
175
|
-
subjects: selectedSubjects(), selectionOrigin });
|
|
197
|
+
subjects: selectedSubjects(), selectionOrigin, ...selectionState() });
|
|
176
198
|
const actionResult = (requestId, ok, message = '') => send({ type: 'action-result', requestId, ok, message });
|
|
177
199
|
|
|
178
200
|
const receive = (event) => {
|
|
@@ -209,6 +231,27 @@ export function createModelPanelBridge({ win = window, origin = location.origin,
|
|
|
209
231
|
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try opening it again.');
|
|
210
232
|
return;
|
|
211
233
|
}
|
|
234
|
+
if (data.action === 'select-group' && typeof data.groupId === 'string') {
|
|
235
|
+
let ok = false;
|
|
236
|
+
try { ok = data.datasetKey === datasetKey && !!selectGroup(data.groupId); if (ok) { publishSnapshot(); publishSelection('tree'); } }
|
|
237
|
+
catch (error) { try { win.console?.error?.('[model-panel] group selection failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
238
|
+
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try selecting it again.');
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (data.action === 'search' && typeof data.tab === 'string' && typeof data.query === 'string' && data.query.length <= 200) {
|
|
242
|
+
let ok = false;
|
|
243
|
+
try { ok = data.datasetKey === datasetKey && !!search(data.tab, data.query); if (ok) publishSnapshot(); }
|
|
244
|
+
catch (error) { try { win.console?.error?.('[model-panel] search action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
245
|
+
actionResult(data.requestId, ok, ok ? '' : 'Object search could not be updated. Reopen the model and try again.');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (data.action === 'grid-visibility' && (data.levelKey === null || typeof data.levelKey === 'string') && typeof data.visible === 'boolean') {
|
|
249
|
+
let ok = false;
|
|
250
|
+
try { ok = data.datasetKey === datasetKey && !!gridVisibility({ levelKey: data.levelKey, visible: data.visible }); if (ok) publishSnapshot(); }
|
|
251
|
+
catch (error) { try { win.console?.error?.('[model-panel] grid visibility action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
252
|
+
actionResult(data.requestId, ok, ok ? '' : 'Grid visibility could not be updated. Try again.');
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
212
255
|
// The main window shows one of the snapshot's panelTabs (tab: its key) or has left them (tab: null). `person` is
|
|
213
256
|
// true when a person chose it (a click on the tab), not the main window restoring or following the editor's reveal.
|
|
214
257
|
// `follow` is the Follow selection switch, for a panel tab that declared `follows` (it re-arrives when the switch flips).
|
|
@@ -64,6 +64,22 @@ export const REVIT_POINTER_DOCK_PLAN = frozen({
|
|
|
64
64
|
]),
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
/** Re-label the shared authenticated-mesh controls for another read-only model source. */
|
|
68
|
+
export function readOnlyModelPointerDockPlan(commandPrefix = 'revit', sourceLabel = 'Revit') {
|
|
69
|
+
const map = (item) => frozen({
|
|
70
|
+
...item,
|
|
71
|
+
command: item.command.replace(/^revit\./, `${commandPrefix}.`),
|
|
72
|
+
carrier: item.carrier.replaceAll('revit.', `${commandPrefix}.`),
|
|
73
|
+
tip: item.tip.replaceAll('Revit', sourceLabel),
|
|
74
|
+
});
|
|
75
|
+
return frozen({
|
|
76
|
+
schema: REVIT_POINTER_DOCK_PLAN.schema,
|
|
77
|
+
selection: frozen(REVIT_POINTER_DOCK_PLAN.selection.map(map)),
|
|
78
|
+
snaps: frozen(REVIT_POINTER_DOCK_PLAN.snaps.map(map)),
|
|
79
|
+
actions: frozen(REVIT_POINTER_DOCK_PLAN.actions.map(map)),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
67
83
|
function escapeAttr(value) {
|
|
68
84
|
return String(value ?? '').replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
69
85
|
}
|
|
@@ -128,7 +144,11 @@ export function mountModelPointerDock({ selectionHost = null, snapHost = null, a
|
|
|
128
144
|
const button = actionsHost?.querySelector('[data-model-action="measure"]');
|
|
129
145
|
if (button) { button.classList.toggle('on', state.armed === true); button.setAttribute('aria-pressed', String(state.armed === true)); }
|
|
130
146
|
const status = actionsHost?.querySelector('[data-model-action-status]');
|
|
131
|
-
if (status)
|
|
147
|
+
if (status) {
|
|
148
|
+
const text = state.status ?? (state.armed ? (state.hasDraft ? 'Pick point 2' : 'Pick point 1') : (state.count ? `${state.count} placed` : 'Ready'));
|
|
149
|
+
// The pill is width-capped with an ellipsis (model-editor.css); the tooltip carries the same full sentence.
|
|
150
|
+
status.textContent = text; status.dataset.tip = text;
|
|
151
|
+
}
|
|
132
152
|
const locks = new Set(state.locks ?? []);
|
|
133
153
|
actionsHost?.querySelectorAll('[data-model-axis]').forEach((axisButton) => {
|
|
134
154
|
const on = axisButton.dataset.modelAxis === 'f' ? locks.size === 0 : locks.has(axisButton.dataset.modelAxis);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { formatLength, MM } from './display-units.js';
|
|
2
|
+
|
|
3
|
+
/** Property-only decimal policy; Steel's length/elevation formatting is unchanged. */
|
|
4
|
+
export function formatPropertyNumber(value, decimals) {
|
|
5
|
+
const factor = 10 ** decimals;
|
|
6
|
+
const quantum = Math.round(Math.abs(value) * factor);
|
|
7
|
+
const rounded = Math.sign(value) * quantum / factor;
|
|
8
|
+
return String(rounded === 0 ? 0 : rounded);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Display only: the authenticated source value is never rounded or rewritten. */
|
|
12
|
+
export function formatModelProperty(row, units, { canonicalMillimetres = false } = {}) {
|
|
13
|
+
const value = row?.value;
|
|
14
|
+
if (value == null) return '—';
|
|
15
|
+
if (row.valueEncoding === 'provider-display') return String(value);
|
|
16
|
+
if (row.semantic === 'boolean' && row.valueType === 'boolean' && typeof value === 'boolean') return value ? 'Yes' : 'No';
|
|
17
|
+
// A source string may be a mark, a padded ID, or already formatted by its host. Never parse it.
|
|
18
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return String(value);
|
|
19
|
+
const unit = row.unit;
|
|
20
|
+
// Current signed parser rows identify lengths explicitly. Older trusted Tekla
|
|
21
|
+
// snapshots only carried a numeric value plus `unit: mm`; that is still a
|
|
22
|
+
// canonical millimetre value, so keep the shared unit switch useful there too.
|
|
23
|
+
if (unit === 'mm' && ((row.semantic === 'length' && row.dimension === 'length') || canonicalMillimetres)) {
|
|
24
|
+
const text = formatLength(value, units);
|
|
25
|
+
return units === MM ? `${text} mm` : text;
|
|
26
|
+
}
|
|
27
|
+
if (row.semantic === 'identifier' || row.semantic === 'integer') return String(value);
|
|
28
|
+
// A source-storage double plus an arbitrary unit label is not a canonical length.
|
|
29
|
+
if (!['angle', 'scalar'].includes(row.semantic)) return unit ? `${value} ${unit}` : String(value);
|
|
30
|
+
const decimals = row.semantic === 'angle' ? 2 : 3;
|
|
31
|
+
const text = Number.isInteger(value) ? String(value) : formatPropertyNumber(value, decimals);
|
|
32
|
+
return unit ? `${text} ${unit}` : text;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Tekla source names are retained; parser bookkeeping is not an object property. */
|
|
36
|
+
export function teklaPropertyGroups(rows) {
|
|
37
|
+
const properties = [], udas = [], nativeGroups = new Map();
|
|
38
|
+
for (const row of Array.isArray(rows) ? rows : []) {
|
|
39
|
+
const isUda = row.isUda === true || row.groupName === 'User-defined attributes' || row.groupName === 'User-defined attributes (UDA)' || row.groupName === 'UDA';
|
|
40
|
+
if (isUda) { udas.push(row); continue; }
|
|
41
|
+
if (row.semantic && Number.isSafeInteger(row.groupOrdinal)) {
|
|
42
|
+
const key = `${row.groupOrdinal}\0${row.groupName}`;
|
|
43
|
+
const group = nativeGroups.get(key) || { key, name: row.groupName, ordinal: row.groupOrdinal, rows: [], expanded: true };
|
|
44
|
+
group.rows.push(row); nativeGroups.set(key, group); continue;
|
|
45
|
+
}
|
|
46
|
+
if (/^(?:Raw\b|provenance|Reader coverage|Technical details|System)/i.test(row.groupName || '')) continue;
|
|
47
|
+
if (row.groupName === 'Overview' && ['Object kind', 'Subtype'].includes(row.name)) continue;
|
|
48
|
+
if (row.groupName === 'Source identity' && row.name === 'Native type') continue;
|
|
49
|
+
const item = row.name === 'Object ID' ? { ...row, name: 'ID' } : row;
|
|
50
|
+
properties.push(item);
|
|
51
|
+
}
|
|
52
|
+
const ordered = (values) => values.slice().sort((a, b) => (a.propertyOrdinal ?? 0) - (b.propertyOrdinal ?? 0));
|
|
53
|
+
return [
|
|
54
|
+
...[...nativeGroups.values()].sort((a, b) => a.ordinal - b.ordinal).map((group) => ({ ...group, rows: ordered(group.rows) })),
|
|
55
|
+
...(properties.length ? [{ key: 'tekla-properties', name: 'Properties', rows: properties, expanded: true }] : []),
|
|
56
|
+
...(udas.length ? [{ key: 'tekla-udas', name: 'User-defined attributes (UDA)', rows: ordered(udas), expanded: false }] : []),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Never recover Name by splitting a composite label: only a supplied property is authoritative. */
|
|
61
|
+
export function teklaObjectFields(entity, rows = []) {
|
|
62
|
+
const source = teklaPropertyGroups(rows).filter((group) => group.key !== 'tekla-udas').flatMap((group) => group.rows);
|
|
63
|
+
const value = (name) => source.find((row) => row.name === name)?.value;
|
|
64
|
+
return { name: value('Name') ?? null, profile: value('Profile') ?? null,
|
|
65
|
+
id: value('ID') ?? entity.objectId ?? (/^element:([0-9]+)$/.exec(entity.id || '')?.[1] ?? null) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function teklaObjectLabel(entity, rows = []) {
|
|
69
|
+
const fields = teklaObjectFields(entity, rows);
|
|
70
|
+
return [fields.name != null ? `Name: ${fields.name}` : null,
|
|
71
|
+
fields.profile != null ? `Profile: ${fields.profile}` : null,
|
|
72
|
+
fields.id != null ? `ID: ${fields.id}` : null].filter(Boolean).join(' · ') || entity.typeName || 'Tekla object';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Native kind → optional native subtype; no borrowed Revit classification levels. */
|
|
76
|
+
export function teklaTypeGroups(entities) {
|
|
77
|
+
const groups = new Map();
|
|
78
|
+
for (const entity of entities || []) {
|
|
79
|
+
const label = entity.nativeKind || entity.typeName || 'Type unavailable';
|
|
80
|
+
const group = groups.get(label) || { label, values: [], subtypes: new Map() };
|
|
81
|
+
const subtype = entity.nativeSubtype;
|
|
82
|
+
if (subtype && subtype !== label) {
|
|
83
|
+
const values = group.subtypes.get(subtype) || []; values.push(entity); group.subtypes.set(subtype, values);
|
|
84
|
+
} else group.values.push(entity);
|
|
85
|
+
groups.set(label, group);
|
|
86
|
+
}
|
|
87
|
+
const sorted = (a, b) => a[0].localeCompare(b[0], undefined, { numeric: true });
|
|
88
|
+
return [...groups.entries()].sort(sorted).map(([, group]) => ({ ...group,
|
|
89
|
+
subtypes: [...group.subtypes.entries()].sort(sorted).map(([label, values]) => ({ label, values })),
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
@@ -124,6 +124,15 @@ export function revitNoModelCopy(state) {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/** The Tekla editor shares the Revit viewport's empty-state treatment, not its RVT-specific copy. */
|
|
128
|
+
export function teklaNoSnapshotCopy(state) {
|
|
129
|
+
if (!state || revitInitialAuthority(state) || state.source) return null;
|
|
130
|
+
return {
|
|
131
|
+
kind: 'no-source', title: 'No Tekla snapshot to show',
|
|
132
|
+
body: 'There is no read-only snapshot for this project yet. Open the Source tab to see the source status and next step.',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
128
137
|
/**
|
|
129
138
|
* Render the no-model state into the viewport's status overlay: a muted outline cube, a title and
|
|
@@ -23,6 +23,17 @@ function entityToken(hit) {
|
|
|
23
23
|
return entity ? JSON.stringify([entity.kind, entity.sourceId]) : null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** Grid/depth arbitration chooses the first candidate; it must not collapse the overlap cycle behind it. */
|
|
27
|
+
export function orderModelSelectionHits(primary, candidates = []) {
|
|
28
|
+
const ordered = primary ? [primary, ...(Array.isArray(candidates) ? candidates : [])] : (Array.isArray(candidates) ? candidates : []);
|
|
29
|
+
const seen = new Set(); const out = [];
|
|
30
|
+
for (const hit of ordered) {
|
|
31
|
+
const token = entityToken(hit); if (!token || seen.has(token)) continue;
|
|
32
|
+
seen.add(token); out.push(hit);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
function visibleHits(value) {
|
|
27
38
|
return (Array.isArray(value) ? value : []).filter((hit) => hit && hit.rawVisible !== false && hit.visible !== false);
|
|
28
39
|
}
|
|
@@ -42,15 +42,18 @@ function button(doc, label, { action, tip, pressed = null, disabled = false } =
|
|
|
42
42
|
return control;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function numberField(doc, label, value, name, step = '1') {
|
|
45
|
+
function numberField(doc, label, value, name, step = '1', presentation = null) {
|
|
46
46
|
const field = doc.createElement('label'); field.className = 'model-spatial-number-field';
|
|
47
47
|
const caption = doc.createElement('span'); caption.textContent = label;
|
|
48
|
-
const input = doc.createElement('input'); input.type = '
|
|
48
|
+
const input = doc.createElement('input'); input.type = presentation ? 'text' : 'number';
|
|
49
|
+
if (!presentation) input.step = step;
|
|
50
|
+
input.value = presentation ? presentation.format(value) : rounded(value); input.dataset.field = name;
|
|
51
|
+
if (presentation) { input.dataset.displayText = input.value; input.dataset.originalMm = String(value); }
|
|
49
52
|
input.setAttribute('aria-label', label); field.append(caption, input); return field;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
function vectorFields(doc, host, prefix, values, names = ['X', 'Y', 'Z']) {
|
|
53
|
-
values.forEach((value, index) => host.append(numberField(doc, names[index], value, `${prefix}-${index}
|
|
55
|
+
function vectorFields(doc, host, prefix, values, names = ['X', 'Y', 'Z'], presentation = null) {
|
|
56
|
+
values.forEach((value, index) => host.append(numberField(doc, names[index], value, `${prefix}-${index}`, '1', presentation)));
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
function valuesFrom(host, prefix, label) {
|
|
@@ -68,16 +71,35 @@ function actionRow(doc) { const row = doc.createElement('div'); row.className =
|
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* @param {{tools:any, trigger:HTMLElement, ports?:Record<string,Function>, documentRef?:Document,
|
|
71
|
-
* windowRef?:Window, onBeforeOpen?:()=>void, onError?:(error:Error)=>void
|
|
74
|
+
* windowRef?:Window, onBeforeOpen?:()=>void, onError?:(error:Error)=>void,
|
|
75
|
+
* lengthDisplay?:{format:(mm:number)=>string,parse:(text:string)=>number|null,unitLabel:()=>string}} options
|
|
72
76
|
*/
|
|
73
77
|
export function mountModelSpatialPanel({
|
|
74
78
|
tools, trigger, ports = {}, documentRef = document, windowRef = window, onError = () => {},
|
|
75
|
-
onBeforeOpen = () => {},
|
|
79
|
+
onBeforeOpen = () => {}, lengthDisplay = null,
|
|
76
80
|
}) {
|
|
77
81
|
if (!tools?.state || !tools?.subscribe || !tools?.activeFrame) throw new TypeError('Spatial panel requires createModelSpatialTools APIs.');
|
|
78
82
|
if (!trigger?.addEventListener) throw new TypeError('Spatial panel requires a trigger element.');
|
|
83
|
+
if (lengthDisplay && (typeof lengthDisplay.format !== 'function' || typeof lengthDisplay.parse !== 'function' || typeof lengthDisplay.unitLabel !== 'function')) {
|
|
84
|
+
throw new TypeError('Spatial panel length display requires format, parse, and unitLabel functions.');
|
|
85
|
+
}
|
|
79
86
|
const panelId = `modelSpatialPanel-${++panelSequence}`;
|
|
80
87
|
let dialog = null, body = null, status = null, destroyed = false;
|
|
88
|
+
const units = () => lengthDisplay ? String(lengthDisplay.unitLabel()) : 'mm';
|
|
89
|
+
const formattedLength = (mm) => lengthDisplay ? String(lengthDisplay.format(mm)) : rounded(mm);
|
|
90
|
+
const lengthPresentation = lengthDisplay ? { format: formattedLength } : null;
|
|
91
|
+
const readLength = (source, label) => {
|
|
92
|
+
const text = typeof source === 'string' ? source : source?.value;
|
|
93
|
+
if (!lengthDisplay) return finite(text, label);
|
|
94
|
+
// Architectural strings round to sixteenths. An untouched field is the original canonical
|
|
95
|
+
// quantity, so clicking Apply to change another field must not move this one by the rounding gap.
|
|
96
|
+
if (typeof source !== 'string' && source?.dataset?.displayText === text) return Number(source.dataset.originalMm);
|
|
97
|
+
const mm = lengthDisplay.parse(text);
|
|
98
|
+
if (typeof mm !== 'number' || !Number.isFinite(mm)) throw new TypeError(`${label} must be a finite length.`);
|
|
99
|
+
return mm;
|
|
100
|
+
};
|
|
101
|
+
const lengthValuesFrom = (host, prefix, label) => [0, 1, 2].map((index) =>
|
|
102
|
+
readLength(host.querySelector(`[data-field="${prefix}-${index}"]`), `${label} ${'XYZ'[index]}`));
|
|
81
103
|
|
|
82
104
|
trigger.setAttribute('aria-haspopup', 'dialog'); trigger.setAttribute('aria-controls', panelId); trigger.setAttribute('aria-expanded', 'false');
|
|
83
105
|
|
|
@@ -98,7 +120,7 @@ export function mountModelSpatialPanel({
|
|
|
98
120
|
const frameSection = section(documentRef, 'Coordinate frame');
|
|
99
121
|
const summary = documentRef.createElement('div'); summary.className = 'model-spatial-panel-summary';
|
|
100
122
|
const active = tools.activeFrame(); const label = documentRef.createElement('strong'); label.textContent = active.label;
|
|
101
|
-
const origin = documentRef.createElement('span'); origin.textContent = `Origin ${active.origin.map(
|
|
123
|
+
const origin = documentRef.createElement('span'); origin.textContent = `Origin ${active.origin.map(formattedLength).join(', ')} ${units()}`;
|
|
102
124
|
summary.append(label, origin); frameSection.append(summary);
|
|
103
125
|
|
|
104
126
|
const frameActions = actionRow(documentRef);
|
|
@@ -122,15 +144,15 @@ export function mountModelSpatialPanel({
|
|
|
122
144
|
const local = state.frames.find((item) => item.id === 'local') || state.frames.find((item) => item.id === 'global');
|
|
123
145
|
const rotation = eulerDegreesFromFrame(local);
|
|
124
146
|
const localGrid = documentRef.createElement('div'); localGrid.className = 'model-spatial-panel-grid';
|
|
125
|
-
const originLabel = documentRef.createElement('div'); originLabel.className = 'model-spatial-panel-grid-label'; originLabel.textContent =
|
|
126
|
-
localGrid.append(originLabel); vectorFields(documentRef, localGrid, 'local-origin', local.origin);
|
|
147
|
+
const originLabel = documentRef.createElement('div'); originLabel.className = 'model-spatial-panel-grid-label'; originLabel.textContent = `Local origin · ${units()}`;
|
|
148
|
+
localGrid.append(originLabel); vectorFields(documentRef, localGrid, 'local-origin', local.origin, ['X', 'Y', 'Z'], lengthPresentation);
|
|
127
149
|
const rotationLabel = documentRef.createElement('div'); rotationLabel.className = 'model-spatial-panel-grid-label'; rotationLabel.textContent = 'Rotation · degrees';
|
|
128
150
|
localGrid.append(rotationLabel); vectorFields(documentRef, localGrid, 'local-rotation', rotation, ['X°', 'Y°', 'Z°']);
|
|
129
151
|
frameSection.append(localGrid);
|
|
130
152
|
const localActions = actionRow(documentRef);
|
|
131
153
|
const apply = button(documentRef, 'Apply local frame', { action: 'frame-local-apply', tip: 'Create or update the local frame from these numeric values' });
|
|
132
154
|
apply.addEventListener('click', () => run(() => {
|
|
133
|
-
const nextOrigin =
|
|
155
|
+
const nextOrigin = lengthValuesFrom(frameSection, 'local-origin', 'Local origin');
|
|
134
156
|
const nextRotation = valuesFrom(frameSection, 'local-rotation', 'Local rotation');
|
|
135
157
|
tools.setLocalTransform({ origin: nextOrigin, ...axesFromEulerDegrees(...nextRotation) });
|
|
136
158
|
}, 'Local frame active.'));
|
|
@@ -139,11 +161,18 @@ export function mountModelSpatialPanel({
|
|
|
139
161
|
if (typeof ports.acceptCoordinates === 'function') {
|
|
140
162
|
const coordinateSection = section(documentRef, 'Typed coordinates');
|
|
141
163
|
const coordinateRow = documentRef.createElement('div'); coordinateRow.className = 'model-spatial-coordinate-row';
|
|
142
|
-
const input = documentRef.createElement('input'); input.type = 'text'; input.dataset.field = 'typed-coordinates'; input.placeholder = 'X, Y, Z or @dX, dY, dZ'; input.setAttribute('aria-label',
|
|
164
|
+
const input = documentRef.createElement('input'); input.type = 'text'; input.dataset.field = 'typed-coordinates'; input.placeholder = 'X, Y, Z or @dX, dY, dZ'; input.setAttribute('aria-label', `Absolute or relative coordinates in the active frame (${units()})`);
|
|
143
165
|
const accept = button(documentRef, 'Accept point', { action: 'coordinate-accept', tip: 'Accept absolute coordinates, or prefix with @ for a relative offset' });
|
|
144
166
|
accept.addEventListener('click', () => run(() => {
|
|
145
167
|
const basePoint = typeof ports.coordinateBasePoint === 'function' ? ports.coordinateBasePoint() : undefined;
|
|
146
|
-
|
|
168
|
+
let text = input.value;
|
|
169
|
+
if (lengthDisplay) {
|
|
170
|
+
const raw = text.trim(), relative = raw.startsWith('@');
|
|
171
|
+
const parts = (relative ? raw.slice(1) : raw).split(',').map((part) => part.trim());
|
|
172
|
+
if (parts.length !== 3) throw new TypeError('Enter X, Y, Z as three finite lengths.');
|
|
173
|
+
text = `${relative ? '@' : ''}${parts.map((part, axis) => readLength(part, `Coordinate ${'XYZ'[axis]}`)).join(',')}`;
|
|
174
|
+
}
|
|
175
|
+
const point = tools.parseCoordinates(text, basePoint);
|
|
147
176
|
return ports.acceptCoordinates(point, { relative: input.value.trim().startsWith('@'), frame: tools.activeFrame() });
|
|
148
177
|
}, 'Coordinate accepted.'));
|
|
149
178
|
input.addEventListener('keydown', (event) => { if (event.key === 'Enter') { event.preventDefault(); accept.click(); } });
|
|
@@ -154,10 +183,10 @@ export function mountModelSpatialPanel({
|
|
|
154
183
|
function renderWorkPlane(root, state) {
|
|
155
184
|
const planeSection = section(documentRef, 'Working plane');
|
|
156
185
|
const controls = documentRef.createElement('div'); controls.className = 'model-spatial-panel-inline';
|
|
157
|
-
const offset = numberField(documentRef,
|
|
186
|
+
const offset = numberField(documentRef, `Offset · ${units()}`, state.workPlane?.offsetMm ?? 0, 'plane-offset', '1', lengthPresentation); controls.append(offset);
|
|
158
187
|
for (const plane of ['xy', 'xz', 'yz']) {
|
|
159
188
|
const control = button(documentRef, plane.toUpperCase(), { action: `plane-${plane}`, tip: `Set the principal ${plane.toUpperCase()} working plane`, pressed: state.workPlane?.principal === plane });
|
|
160
|
-
control.addEventListener('click', () => run(() => tools.setPrincipalWorkPlane({ plane, offsetMm:
|
|
189
|
+
control.addEventListener('click', () => run(() => tools.setPrincipalWorkPlane({ plane, offsetMm: readLength(offset.querySelector('input'), 'Working-plane offset') }), `${plane.toUpperCase()} working plane active.`));
|
|
161
190
|
controls.append(control);
|
|
162
191
|
}
|
|
163
192
|
planeSection.append(controls);
|
|
@@ -190,17 +219,17 @@ export function mountModelSpatialPanel({
|
|
|
190
219
|
const identity = documentRef.createElement('code'); identity.textContent = clip.id; heading.append(name, identity); card.append(heading);
|
|
191
220
|
const grid = documentRef.createElement('div'); grid.className = 'model-spatial-panel-grid';
|
|
192
221
|
if (clip.kind === 'plane') {
|
|
193
|
-
const a = documentRef.createElement('div'); a.className = 'model-spatial-panel-grid-label'; a.textContent =
|
|
222
|
+
const a = documentRef.createElement('div'); a.className = 'model-spatial-panel-grid-label'; a.textContent = `Origin · ${units()}`; grid.append(a); vectorFields(documentRef, grid, 'clip-origin', clip.origin, ['X', 'Y', 'Z'], lengthPresentation);
|
|
194
223
|
const b = documentRef.createElement('div'); b.className = 'model-spatial-panel-grid-label'; b.textContent = 'Normal'; grid.append(b); vectorFields(documentRef, grid, 'clip-normal', clip.normal);
|
|
195
224
|
} else {
|
|
196
|
-
const a = documentRef.createElement('div'); a.className = 'model-spatial-panel-grid-label'; a.textContent =
|
|
197
|
-
const b = documentRef.createElement('div'); b.className = 'model-spatial-panel-grid-label'; b.textContent =
|
|
225
|
+
const a = documentRef.createElement('div'); a.className = 'model-spatial-panel-grid-label'; a.textContent = `Minimum · ${units()}`; grid.append(a); vectorFields(documentRef, grid, 'clip-min', clip.min, ['X', 'Y', 'Z'], lengthPresentation);
|
|
226
|
+
const b = documentRef.createElement('div'); b.className = 'model-spatial-panel-grid-label'; b.textContent = `Maximum · ${units()}`; grid.append(b); vectorFields(documentRef, grid, 'clip-max', clip.max, ['X', 'Y', 'Z'], lengthPresentation);
|
|
198
227
|
}
|
|
199
228
|
card.append(grid); const actions = actionRow(documentRef);
|
|
200
229
|
const update = button(documentRef, 'Update', { action: 'clip-update', tip: `Apply edited values to ${name.textContent}` });
|
|
201
230
|
update.addEventListener('click', () => run(() => tools.updateClip(clip.id, clip.kind === 'plane'
|
|
202
|
-
? { origin:
|
|
203
|
-
: { min:
|
|
231
|
+
? { origin: lengthValuesFrom(card, 'clip-origin', 'Clip origin'), normal: valuesFrom(card, 'clip-normal', 'Clip normal') }
|
|
232
|
+
: { min: lengthValuesFrom(card, 'clip-min', 'Clip minimum'), max: lengthValuesFrom(card, 'clip-max', 'Clip maximum') }), 'Clip updated.'));
|
|
204
233
|
const remove = button(documentRef, 'Remove', { action: 'clip-remove', tip: `Remove ${name.textContent}` });
|
|
205
234
|
remove.addEventListener('click', () => run(() => tools.removeClip(clip.id), 'Clip removed.'));
|
|
206
235
|
const enabled = button(documentRef, clip.enabled === false ? 'Disabled' : 'Enabled', { action: 'clip-enabled', tip: `Enable or disable ${name.textContent}`, pressed: clip.enabled !== false });
|
|
@@ -219,7 +248,7 @@ export function mountModelSpatialPanel({
|
|
|
219
248
|
if (!area) { areaSection.append(note(documentRef, 'No work area. Create one from the model or current selection in the toolbar.')); root.append(areaSection); return; }
|
|
220
249
|
const bounds = documentRef.createElement('div'); bounds.className = 'model-spatial-panel-summary';
|
|
221
250
|
const label = documentRef.createElement('strong'); label.textContent = area.wholeParts ? 'Whole intersecting parts' : 'Physical section cut';
|
|
222
|
-
const value = documentRef.createElement('span'); value.textContent = `${area.min.map(
|
|
251
|
+
const value = documentRef.createElement('span'); value.textContent = `${area.min.map(formattedLength).join(', ')} → ${area.max.map(formattedLength).join(', ')} ${units()}`; bounds.append(label, value); areaSection.append(bounds);
|
|
223
252
|
const actions = actionRow(documentRef);
|
|
224
253
|
const whole = button(documentRef, 'Whole parts', { action: 'area-whole', tip: 'Show complete parts intersecting the work area', pressed: area.wholeParts });
|
|
225
254
|
whole.addEventListener('click', () => run(() => tools.setWorkAreaWhole(true)));
|
|
@@ -234,7 +263,9 @@ export function mountModelSpatialPanel({
|
|
|
234
263
|
function paint(state = tools.state()) {
|
|
235
264
|
const active = tools.activeFrame(); trigger.textContent = active.label; trigger.setAttribute('aria-label', `Spatial controls. Active frame: ${active.label}`);
|
|
236
265
|
if (!body) return;
|
|
266
|
+
const scrollTop = body.scrollTop;
|
|
237
267
|
body.replaceChildren(); renderFrame(body, state); renderWorkPlane(body, state); renderClips(body, state); renderWorkArea(body, state);
|
|
268
|
+
body.scrollTop = scrollTop;
|
|
238
269
|
}
|
|
239
270
|
|
|
240
271
|
function position() {
|
|
@@ -284,7 +315,7 @@ export function mountModelSpatialPanel({
|
|
|
284
315
|
const unsubscribe = tools.subscribe((state) => paint(state));
|
|
285
316
|
|
|
286
317
|
return Object.freeze({
|
|
287
|
-
open, close, toggle, isOpen: () => !!dialog,
|
|
318
|
+
open, close, toggle, isOpen: () => !!dialog, refreshDisplay: () => { if (!destroyed) paint(); },
|
|
288
319
|
destroy() {
|
|
289
320
|
if (destroyed) return; destroyed = true; close({ restoreFocus: false }); unsubscribe();
|
|
290
321
|
trigger.removeEventListener('click', triggerClick); documentRef.removeEventListener('pointerdown', outside); windowRef.removeEventListener?.('resize', resize);
|