@floless/app 0.143.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 +177152 -160760
- 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/aware.js +423 -46
- package/dist/web/commands-revit.js +4 -0
- package/dist/web/commands-shell.js +136 -3
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/commands-tekla-parser.js +48 -0
- package/dist/web/commands.js +1 -1
- package/dist/web/grid-core.js +15 -0
- package/dist/web/index.html +40 -2
- package/dist/web/instructor.js +13 -3
- 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 +231 -8
- 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
package/dist/web/revit-editor.js
CHANGED
|
@@ -2,17 +2,21 @@ import { mountInspectorShell } from './model-inspector.js';
|
|
|
2
2
|
import { mountModelEditorShell, mountSidePanel } from './model-editor-shell.js';
|
|
3
3
|
import { mountToolbarChrome, renderToolbarMarkup } from './model-viewport-toolbar.js';
|
|
4
4
|
import { mountModelLightingPanel } from './model-viewport-lighting.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createReadOnlyModelEditorAdapter, readOnlyModelRenderPlan, revitRenderPlan,
|
|
7
|
+
} from './model-editor-revit-adapter.js';
|
|
6
8
|
import {
|
|
7
9
|
buildRevitClassificationTree, filterRevitPropertyGroups, groupRevitProperties,
|
|
8
10
|
renderRevitNoModelState, revitExplorerTabs, revitInitialAuthority, revitNoModelCopy, revitPropertyEncodingLabel,
|
|
11
|
+
teklaNoSnapshotCopy,
|
|
9
12
|
} from './model-revit-module.js';
|
|
10
13
|
import { createRevitViewport } from './model-viewport-revit-adapter.js';
|
|
14
|
+
import { findTeklaStructuralGrid } from './tekla-structural-grid-adapter.js';
|
|
11
15
|
import { mountModelOrientationOverlay } from './model-orientation-overlay.js';
|
|
12
16
|
import { mountModelMeasureTool } from './model-measure.js';
|
|
13
17
|
import { createModelCadToolController } from './model-cad-tools.js';
|
|
14
18
|
import { createModelSelectionTools } from './model-selection-tools.js';
|
|
15
|
-
import { mountModelPointerDock, REVIT_POINTER_DOCK_PLAN } from './model-pointer-dock.js';
|
|
19
|
+
import { mountModelPointerDock, readOnlyModelPointerDockPlan, REVIT_POINTER_DOCK_PLAN } from './model-pointer-dock.js';
|
|
16
20
|
import { createModelSpatialTools } from './model-spatial-tools.js';
|
|
17
21
|
import { mountModelSpatialPanel } from './model-spatial-panel.js';
|
|
18
22
|
import { createModelClipSession } from './model-clip-session.js';
|
|
@@ -20,12 +24,31 @@ import { mountModelClipList } from './model-clip-list.js';
|
|
|
20
24
|
import { createModelEditorStateRecoveryStore } from './model-editor-state-recovery.js';
|
|
21
25
|
import {
|
|
22
26
|
MODEL_EXPLORER_ENTITY_CAP, MODEL_EXPLORER_GROUP_CAP, assertModelViewerRowBudget,
|
|
23
|
-
preflightModelJsonReceipt, readModelBinaryArtifact, readModelJsonArtifact,
|
|
27
|
+
preflightModelJsonReceipt, readModelBinaryArtifact, readModelJsonArtifact, readModelJsonDocument,
|
|
24
28
|
} from './model-artifact-loader.js';
|
|
25
|
-
import { createModelPanelBridge, createModelSelectionOriginGuard, createPanelHost, expandModelPanelGroup, serializeModelPanelNodes } from './model-panel-bridge.js';
|
|
29
|
+
import { createModelPanelBridge, createModelSelectionOriginGuard, createPanelHost, expandModelPanelGroup, selectModelPanelGroup, serializeModelPanelNodes } from './model-panel-bridge.js';
|
|
30
|
+
import { mountModelDisplayUnits } from './model-display-units.js';
|
|
31
|
+
import { formatModelProperty, teklaObjectFields, teklaObjectLabel, teklaPropertyGroups, teklaTypeGroups } from './model-property-display.js';
|
|
32
|
+
import { formatLength, parseLengthMm } from './display-units.js';
|
|
33
|
+
import { teklaAssemblyMembership, teklaGeometrySelection } from './model-tekla-selection.js';
|
|
26
34
|
|
|
27
35
|
const $ = (id) => document.getElementById(id);
|
|
28
36
|
const projectId = new URLSearchParams(location.search).get('project') || '';
|
|
37
|
+
const isTeklaParser = document.body.dataset.modelKind === 'tekla-parser';
|
|
38
|
+
const modelExplorerTabs = isTeklaParser
|
|
39
|
+
? Object.freeze([{ key: 'type', bodyId: 'revitExplorerTypes' }])
|
|
40
|
+
: revitExplorerTabs;
|
|
41
|
+
const hostThemeKey = 'floless-demo-theme-v1';
|
|
42
|
+
function syncHostTheme() {
|
|
43
|
+
document.documentElement.dataset.theme = localStorage.getItem(hostThemeKey) === 'light' ? 'light' : 'dark';
|
|
44
|
+
}
|
|
45
|
+
syncHostTheme();
|
|
46
|
+
window.addEventListener('storage', (event) => { if (event.key === hostThemeKey) syncHostTheme(); });
|
|
47
|
+
const modelProduct = isTeklaParser ? 'Tekla Parser' : 'Revit Parser';
|
|
48
|
+
const sourceProduct = isTeklaParser ? 'Tekla' : 'Revit';
|
|
49
|
+
const commandPrefix = isTeklaParser ? 'tekla-parser' : 'revit';
|
|
50
|
+
const editorProjectRoute = isTeklaParser ? '/api/editor/tekla-projects' : '/api/editor/revit-projects';
|
|
51
|
+
const contractRoute = isTeklaParser ? '/api/contract/tekla-parser' : '/api/contract/revit-model';
|
|
29
52
|
let entities = [], properties = [], relationships = [], entityById = new Map(), propertyByEntity = new Map(), selectedId = null, selectedIds = [], selectionOrigin = 'tree', classificationFollowedId = null, facade = null, viewport = null, inspector = null;
|
|
30
53
|
let selectionTools = null;
|
|
31
54
|
let selectionFilterChrome = null;
|
|
@@ -48,7 +71,13 @@ let editorStateSavedGeneration = 0;
|
|
|
48
71
|
let editorStateSaveQueue = Promise.resolve();
|
|
49
72
|
let editorStateDirtyPayload = null;
|
|
50
73
|
let projectContract = null;
|
|
74
|
+
let teklaAudit = null;
|
|
51
75
|
let sharedTools = null;
|
|
76
|
+
let displayUnitControl = null, displayUnitEvents = null, lastCursorCoordinates = null;
|
|
77
|
+
let propertyDisplayRefresh = new Set();
|
|
78
|
+
let toolbarChrome = null;
|
|
79
|
+
let teklaAssemblyMembers = new Map();
|
|
80
|
+
let geometrySelectionIds = [];
|
|
52
81
|
let terminalDisposed = false;
|
|
53
82
|
let bfcacheSuspended = false;
|
|
54
83
|
let revisionLoadToken = 0;
|
|
@@ -57,24 +86,45 @@ const MODEL_VIEWER_MAX_TILE_BYTES = 256 * 1024 * 1024;
|
|
|
57
86
|
const MODEL_VIEWER_MAX_AGGREGATE_BYTES = MODEL_VIEWER_MAX_TILE_BYTES + (128 * 1024 * 1024 * 5);
|
|
58
87
|
const editorStateRecovery = createModelEditorStateRecoveryStore({
|
|
59
88
|
storage: localStorage,
|
|
60
|
-
key: 'floless:revit-editor-dirty:v1',
|
|
61
|
-
schema: 'floless.revit-editor-dirty/v1',
|
|
89
|
+
key: isTeklaParser ? 'floless:tekla-parser-editor-dirty:v1' : 'floless:revit-editor-dirty:v1',
|
|
90
|
+
schema: isTeklaParser ? 'floless.tekla-parser-editor-dirty/v1' : 'floless.revit-editor-dirty/v1',
|
|
62
91
|
maxBytes: 512 * 1024,
|
|
63
92
|
});
|
|
64
93
|
let modelPanelBridge = null;
|
|
94
|
+
const modelSearchQueries = new Map();
|
|
95
|
+
const modelSearchResults = new Map();
|
|
65
96
|
const selectionOriginGuard = createModelSelectionOriginGuard();
|
|
66
97
|
|
|
67
98
|
function modelPanelSnapshot() {
|
|
68
99
|
const bodies = {};
|
|
69
|
-
for (const tab of
|
|
100
|
+
for (const tab of modelExplorerTabs) bodies[tab.key] = serializeModelPanelNodes($(tab.bodyId), tab.key);
|
|
101
|
+
const gridEntity = entities.find((entity) => entity?.structuralGrid?.mapping?.kind === 'symmetric');
|
|
102
|
+
const gridLevels = gridEntity && viewport?.gridLevels?.();
|
|
103
|
+
const displayedUnits = $('modelUnits')?.querySelector('[data-unit-choice][aria-pressed="true"]')?.dataset.unitChoice
|
|
104
|
+
|| displayUnitControl?.units?.();
|
|
105
|
+
const displayGridLength = (mm) => `${formatLength(mm, displayedUnits)}${displayedUnits === 'mm' ? ' mm' : ''}`;
|
|
70
106
|
return { context: $('modelName')?.textContent || 'Project model', selectedId, selectedIds: [...selectedIds], selectionOrigin,
|
|
71
|
-
|
|
72
|
-
|
|
107
|
+
...(isTeklaParser ? { focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds] } : {}),
|
|
108
|
+
...(gridEntity && Array.isArray(gridLevels) && gridLevels.length ? { gridVisibility: {
|
|
109
|
+
entityId: gridEntity.id,
|
|
110
|
+
levels: gridLevels.map((level) => ({ key: String(level.key), mm: level.mm, label: level.label || '', authored: level.authored || '',
|
|
111
|
+
visible: level.visible === true, display: displayGridLength(level.mm) })),
|
|
112
|
+
} } : {}),
|
|
113
|
+
tabs: modelExplorerTabs.map((tab) => ({ key: tab.key, label: tab.key[0].toUpperCase() + tab.key.slice(1) })), bodies,
|
|
114
|
+
panelTabs: REVIT_PANEL_TABS,
|
|
115
|
+
searches: Object.fromEntries(modelExplorerTabs.map((tab) => [tab.key, {
|
|
116
|
+
query: modelSearchQueries.get(tab.key) || '', ...(modelSearchResults.get(tab.key) || {}),
|
|
117
|
+
}])) };
|
|
73
118
|
}
|
|
74
119
|
|
|
75
120
|
let realisticFallbackAnnounced = false;
|
|
76
|
-
function toast(message) { const el = $('toast'); el.textContent = message; el.classList.add('show'); clearTimeout(toast.timer); toast.timer = setTimeout(() => el.classList.remove('show'),
|
|
77
|
-
function
|
|
121
|
+
function toast(message, durationMs = 2400) { const el = $('toast'); el.textContent = message; el.classList.add('show'); clearTimeout(toast.timer); toast.timer = setTimeout(() => el.classList.remove('show'), durationMs); }
|
|
122
|
+
function modelUnavailableCopy() {
|
|
123
|
+
return isTeklaParser
|
|
124
|
+
? 'This verified Tekla snapshot could not be opened. Open Source to check the read, then choose the Tekla source again if needed.'
|
|
125
|
+
: 'This verified Revit snapshot could not be opened. Open Source to check the import, then choose the Revit file again if needed.';
|
|
126
|
+
}
|
|
127
|
+
function fail() { const state = $('loadingState'); state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy); }
|
|
78
128
|
async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw new Error(value.message || value.error || `Request failed (${response.status})`); return value; }
|
|
79
129
|
|
|
80
130
|
function propertySection(heading, rows) {
|
|
@@ -84,52 +134,113 @@ function propertySection(heading, rows) {
|
|
|
84
134
|
}
|
|
85
135
|
|
|
86
136
|
function importedPropertySection(groups) {
|
|
87
|
-
return { id: 'imported-parameters', heading: 'Imported parameters', editable: false, render(host) {
|
|
137
|
+
return { id: 'imported-parameters', heading: isTeklaParser ? null : 'Imported parameters', editable: false, render(host) {
|
|
138
|
+
const refreshers = propertyDisplayRefresh;
|
|
88
139
|
const search = document.createElement('input'); search.type = 'search'; search.className = 'revit-property-search';
|
|
89
140
|
search.placeholder = 'Search selected object'; search.setAttribute('aria-label', 'Search selected object properties');
|
|
90
141
|
const results = document.createElement('div'); results.className = 'revit-property-groups';
|
|
142
|
+
const expandedGroups = new Map(groups.map((group, index) => [group.key || group.name,
|
|
143
|
+
group.expanded ?? (groups.length === 1 || index === 0)]));
|
|
91
144
|
const paint = (query = '') => {
|
|
145
|
+
refreshers.clear();
|
|
92
146
|
results.replaceChildren();
|
|
93
147
|
const visible = filterRevitPropertyGroups(groups, query);
|
|
94
|
-
if (!visible.length) { const empty = document.createElement('div'); empty.className = 'insp-note'; empty.textContent =
|
|
95
|
-
|
|
148
|
+
if (!visible.length) { const empty = document.createElement('div'); empty.className = 'insp-note'; empty.textContent = isTeklaParser
|
|
149
|
+
? (query ? 'No properties match this search.' : 'No verified properties were supplied for this object.')
|
|
150
|
+
: (query ? 'No matching imported parameters.' : 'No imported parameters were supplied for this object.'); results.append(empty); return; }
|
|
151
|
+
for (const group of visible) {
|
|
152
|
+
const groupKey = group.key || group.name;
|
|
153
|
+
const isUdaGroup = isTeklaParser && groupKey === 'tekla-udas';
|
|
96
154
|
const section = document.createElement('section'); section.className = 'revit-property-group';
|
|
155
|
+
section.dataset.propertyGroup = groupKey;
|
|
156
|
+
if (isUdaGroup) section.classList.add('tekla-uda-group');
|
|
97
157
|
const trigger = document.createElement('button'); trigger.type = 'button'; trigger.className = 'revit-property-group-trigger';
|
|
98
158
|
const label = document.createElement('span'); label.textContent = group.name;
|
|
99
159
|
const count = document.createElement('span'); count.className = 'explorer-count'; count.textContent = String(group.rows.length);
|
|
100
|
-
trigger.append(label, count); trigger.setAttribute('aria-expanded', String(
|
|
160
|
+
trigger.append(label, count); trigger.setAttribute('aria-expanded', String(query ? true : expandedGroups.get(groupKey)));
|
|
101
161
|
const body = document.createElement('div'); body.className = 'revit-property-group-body'; body.hidden = trigger.getAttribute('aria-expanded') !== 'true';
|
|
102
162
|
for (const item of group.rows) {
|
|
103
163
|
const row = document.createElement('div'); row.className = 'revit-imported-property';
|
|
164
|
+
if (isUdaGroup) row.classList.add('tekla-uda-property');
|
|
104
165
|
const key = document.createElement('span'); key.className = 'property-key'; key.textContent = item.name || item.parameterId || 'Unnamed parameter';
|
|
105
166
|
const value = document.createElement('bdi'); value.className = 'property-value';
|
|
106
|
-
const rendered =
|
|
167
|
+
const rendered = () => formatModelProperty(item, displayUnitControl.units(), { canonicalMillimetres: isTeklaParser && !isUdaGroup });
|
|
168
|
+
const visibleValue = () => {
|
|
169
|
+
if (!isUdaGroup) return rendered();
|
|
170
|
+
if (item.value == null) return '(not provided)';
|
|
171
|
+
if (typeof item.value === 'string' && item.value.length === 0) return '(empty)';
|
|
172
|
+
if (typeof item.value === 'string' && item.value.trim().length === 0) return '(whitespace only)';
|
|
173
|
+
return rendered();
|
|
174
|
+
};
|
|
175
|
+
const refresh = () => { value.textContent = visibleValue(); }; refresh(); refreshers.add(refresh);
|
|
107
176
|
const provenance = document.createElement('span'); provenance.className = 'revit-property-provenance'; provenance.textContent = revitPropertyEncodingLabel(item);
|
|
108
177
|
const copy = document.createElement('button'); copy.type = 'button'; copy.className = 'revit-property-copy'; copy.textContent = 'Copy';
|
|
109
|
-
copy.dataset.tip = 'Copy this
|
|
110
|
-
copy.
|
|
111
|
-
|
|
178
|
+
copy.dataset.tip = isUdaGroup ? 'Copy this exact UDA value' : 'Copy this imported display value';
|
|
179
|
+
copy.setAttribute('aria-label', `Copy value for ${key.textContent}`);
|
|
180
|
+
if (isUdaGroup && item.value == null) { copy.disabled = true; copy.dataset.tip = 'No value was provided'; }
|
|
181
|
+
copy.addEventListener('click', async () => { try {
|
|
182
|
+
const copied = isUdaGroup ? String(item.value ?? '') : rendered();
|
|
183
|
+
await navigator.clipboard.writeText(copied);
|
|
184
|
+
toast(isUdaGroup && copied.length === 0 ? 'Empty value copied.' : 'Value copied.');
|
|
185
|
+
} catch { toast('Could not copy this property value.'); } });
|
|
186
|
+
row.append(key, value, ...(!isTeklaParser ? [provenance] : []), copy); body.append(row);
|
|
112
187
|
}
|
|
113
|
-
trigger.addEventListener('click', () => { const open = trigger.getAttribute('aria-expanded') !== 'true'; trigger.setAttribute('aria-expanded', String(open)); body.hidden = !open; });
|
|
188
|
+
trigger.addEventListener('click', () => { const open = trigger.getAttribute('aria-expanded') !== 'true'; expandedGroups.set(groupKey, open); trigger.setAttribute('aria-expanded', String(open)); body.hidden = !open; });
|
|
114
189
|
section.append(trigger, body); results.append(section);
|
|
115
190
|
}
|
|
116
191
|
};
|
|
117
192
|
let timer = null; search.addEventListener('input', () => { clearTimeout(timer); timer = setTimeout(() => paint(search.value), 120); });
|
|
118
|
-
host.append(search, results);
|
|
193
|
+
host.append(search, results);
|
|
194
|
+
if (isTeklaParser) { const note = document.createElement('p'); note.className = 'model-property-coverage'; note.textContent = 'Verified source properties from this snapshot. This is not the complete Tekla Properties pane; fields without proven database mappings are omitted.'; host.append(note); }
|
|
195
|
+
paint();
|
|
196
|
+
} };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const TEKLA_AUDIT_COPY = Object.freeze({
|
|
200
|
+
'part-geometry-missing': Object.freeze({ group: 'not-shown', title: 'Not shown in 3D', detail: 'This part is present in the Tekla database but has no verified display geometry in this import.' }),
|
|
201
|
+
'bolt-geometry-missing': Object.freeze({ group: 'not-shown', title: 'Not shown in 3D', detail: 'This bolt object is present in the Tekla database but has no verified display geometry in this import.' }),
|
|
202
|
+
'weld-geometry-missing': Object.freeze({ group: 'not-shown', title: 'Not shown in 3D', detail: 'This weld is present in the Tekla database but has no verified display geometry in this import.' }),
|
|
203
|
+
'bolt-placement-unconfirmed': Object.freeze({ group: 'fit-not-confirmed', title: 'Fit not confirmed', detail: 'The parser could not prove the bolt placement from the available database records.' }),
|
|
204
|
+
'part-operations-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'Some part operations were preserved as database facts but were not evaluated into the displayed shape.' }),
|
|
205
|
+
'weld-recipes-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'Some weld-shape instructions were preserved as database facts but were not evaluated into display geometry.' }),
|
|
206
|
+
'grid-mapping-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Grid not shown in 3D', detail: 'This grid is present in the Tekla database, but its display extents could not be mapped safely.' }),
|
|
207
|
+
'unsupported-native-type': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'This native Tekla object type is recorded but is not yet interpreted by the parser.' }),
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
function auditFindingsFor(entityId) { return teklaAudit?.findings?.filter((finding) => finding.entityId === entityId) ?? []; }
|
|
211
|
+
|
|
212
|
+
function auditInspectorSection(findings) {
|
|
213
|
+
return { id: 'import-audit', heading: 'Import audit', editable: false, render(host) {
|
|
214
|
+
if (!findings.length) { const ok = document.createElement('div'); ok.className = 'tekla-audit-inspector-ok'; ok.textContent = 'No open import findings for this object.'; host.append(ok); return; }
|
|
215
|
+
for (const finding of findings) {
|
|
216
|
+
const copy = TEKLA_AUDIT_COPY[finding.code];
|
|
217
|
+
const item = document.createElement('article'); item.className = 'tekla-audit-inspector-item';
|
|
218
|
+
const heading = document.createElement('strong'); heading.textContent = copy?.title ?? 'Import finding';
|
|
219
|
+
const detail = document.createElement('p'); detail.textContent = copy?.detail ?? 'The import audit recorded an unsupported finding code.';
|
|
220
|
+
const technical = document.createElement('details'); technical.className = 'tekla-audit-technical';
|
|
221
|
+
const summary = document.createElement('summary'); summary.textContent = 'Technical details';
|
|
222
|
+
const pre = document.createElement('pre'); pre.textContent = JSON.stringify({ code: finding.code, check: finding.check, evidence: finding.evidence }, null, 2);
|
|
223
|
+
technical.append(summary, pre); item.append(heading, detail, technical); host.append(item);
|
|
224
|
+
}
|
|
119
225
|
} };
|
|
120
226
|
}
|
|
121
227
|
|
|
122
228
|
function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
|
|
229
|
+
propertyDisplayRefresh = new Set();
|
|
123
230
|
selectedId = id;
|
|
124
231
|
selectionOrigin = origin;
|
|
125
232
|
if (syncViewport) selectedIds = id ? [id] : [];
|
|
126
233
|
window.__revitInstructorState = { ...(window.__revitInstructorState || {}), selected: id };
|
|
127
234
|
if (syncViewport) {
|
|
128
235
|
if (id) clipSession?.clearSelection?.();
|
|
129
|
-
|
|
236
|
+
if (isTeklaParser) {
|
|
237
|
+
const entity = id ? entityById.get(id) : null;
|
|
238
|
+
geometrySelectionIds = entity && (entity.geometry?.length || entity.structuralGrid?.mapping?.kind === 'symmetric') ? [id] : [];
|
|
239
|
+
}
|
|
240
|
+
selectionOriginGuard.run(() => viewport.setSelection({ ids: isTeklaParser ? geometrySelectionIds : id ? [id] : [] }));
|
|
130
241
|
}
|
|
131
242
|
updateSelectionActions();
|
|
132
|
-
const modelHostId =
|
|
243
|
+
const modelHostId = modelExplorerTabs.find((tab) => tab.key === 'model')?.bodyId;
|
|
133
244
|
const nextFollowedId = selectedIds.length === 1 && entities.slice(MODEL_EXPLORER_ENTITY_CAP).some((item) => item.id === selectedIds[0]) ? selectedIds[0] : null;
|
|
134
245
|
const classificationChanged = nextFollowedId !== classificationFollowedId;
|
|
135
246
|
if (classificationChanged && modelHostId) {
|
|
@@ -141,39 +252,77 @@ function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
|
|
|
141
252
|
const entity = entityById.get(id);
|
|
142
253
|
if (!entity) { inspector.render({ state: 'unavailable', message: 'This object is not in the loaded revision.' }); if (publish) modelPanelBridge?.publishSelection(selectionOrigin); return false; }
|
|
143
254
|
const own = propertyByEntity.get(id) || [];
|
|
144
|
-
const groups = groupRevitProperties(own);
|
|
145
|
-
const sections = [
|
|
255
|
+
const groups = isTeklaParser ? teklaPropertyGroups(own) : groupRevitProperties(own);
|
|
256
|
+
const sections = [];
|
|
257
|
+
if (isTeklaParser && auditFindingsFor(id).length) sections.push(auditInspectorSection(auditFindingsFor(id)));
|
|
258
|
+
if (!isTeklaParser) sections.push(propertySection('Identity', [['Element', entity.id], ['Name', entity.name], ['Category', entity.categoryName ?? entity.category], ['Family', entity.familyName ?? entity.family], ['Type', entity.typeName], ['Level', entity.levelName]]));
|
|
146
259
|
sections.push(importedPropertySection(groups));
|
|
147
|
-
inspector.render({ state: 'ready', heading: entity.name || entity.typeName || entity.id, sections });
|
|
260
|
+
inspector.render({ state: 'ready', heading: isTeklaParser ? (teklaObjectFields(entity, own).name || entity.typeName || 'Tekla object') : (entity.name || entity.typeName || entity.id), sections });
|
|
148
261
|
if (publish) modelPanelBridge?.publishSelection(selectionOrigin);
|
|
149
262
|
window.__instructor?.notifyChanged();
|
|
150
263
|
return true;
|
|
151
264
|
}
|
|
152
265
|
|
|
153
|
-
function
|
|
266
|
+
function selectTeklaObjects(id, ids, visibleOnly = false) {
|
|
267
|
+
if (!ids.every((each) => entityById.has(each))) return false;
|
|
268
|
+
const visible = visibleOnly
|
|
269
|
+
? new Set((viewport.selectionTools?.allHits() || []).map((hit) => hit.entity.sourceId)) : null;
|
|
270
|
+
const resolvedGeometryIds = teklaGeometrySelection(ids, entityById, teklaAssemblyMembers, visible);
|
|
271
|
+
if (resolvedGeometryIds === null) { toast('Selection is too large; narrow the Type list.'); return false; }
|
|
272
|
+
const gridIds = ids.filter((entityId) => entityById.get(entityId)?.structuralGrid?.mapping?.kind === 'symmetric'
|
|
273
|
+
&& (!visible || visible.has(entityId)));
|
|
274
|
+
const geometryIds = [...new Set([...resolvedGeometryIds, ...gridIds])];
|
|
275
|
+
geometrySelectionIds = geometryIds;
|
|
276
|
+
selectedIds = geometryIds.length ? [...ids] : [];
|
|
277
|
+
if (ids.length) clipSession?.clearSelection?.();
|
|
278
|
+
selectionOriginGuard.run(() => viewport.setSelection({ ids: geometryIds }));
|
|
279
|
+
const selected = ids.includes(id) ? id : (ids.at(-1) ?? null);
|
|
280
|
+
const result = inspect(selected, false, true, 'tree');
|
|
281
|
+
if (geometryIds.length) facade.dispatch('model.fit-selection');
|
|
282
|
+
else if (ids.length) toast(visibleOnly ? 'This type has no visible geometry to select.' : 'This object has no verified geometry to frame.');
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function row(label, count, entityId, objectFields = null) {
|
|
154
287
|
const button = document.createElement('button'); button.type = 'button'; button.className = 'explorer-row';
|
|
155
288
|
if (entityId) button.dataset.entityId = entityId;
|
|
156
289
|
const text = document.createElement('span'); text.className = 'row-label'; text.textContent = label;
|
|
157
|
-
|
|
290
|
+
if (objectFields) {
|
|
291
|
+
button.classList.add('model-object-row');
|
|
292
|
+
const summary = document.createElement('span'); summary.className = 'model-object-summary';
|
|
293
|
+
text.classList.add('model-object-name'); text.id = `tekla-object-name-${entityId}`;
|
|
294
|
+
if (objectFields.name != null) text.dataset.objectField = 'name';
|
|
295
|
+
summary.append(text); button.setAttribute('aria-labelledby', text.id);
|
|
296
|
+
const details = document.createElement('span'); details.className = 'model-object-details'; details.id = `tekla-object-details-${entityId}`;
|
|
297
|
+
for (const [key, label] of [['profile', 'Profile'], ['id', 'ID']]) {
|
|
298
|
+
if (objectFields[key] == null) continue;
|
|
299
|
+
const field = document.createElement('span'); field.className = 'model-object-field';
|
|
300
|
+
const caption = document.createElement('span'); caption.className = 'model-object-field-label'; caption.textContent = `${label}: `;
|
|
301
|
+
const value = document.createElement('span'); value.dataset.objectField = key; value.textContent = String(objectFields[key]);
|
|
302
|
+
field.append(caption, value); details.append(field);
|
|
303
|
+
}
|
|
304
|
+
if (details.children.length) { summary.append(details); button.setAttribute('aria-describedby', details.id); }
|
|
305
|
+
button.append(summary);
|
|
306
|
+
} else button.append(text);
|
|
158
307
|
if (count != null) { const number = document.createElement('span'); number.className = 'explorer-count'; number.textContent = String(count); button.append(number); }
|
|
159
|
-
if (entityId) button.addEventListener('click', () => inspect(entityId));
|
|
308
|
+
if (entityId) button.addEventListener('click', () => isTeklaParser ? selectTeklaObjects(entityId, [entityId]) : inspect(entityId));
|
|
160
309
|
return button;
|
|
161
310
|
}
|
|
162
311
|
|
|
163
|
-
function renderTreeNodes(host, nodes, depth = 0) {
|
|
312
|
+
function renderTreeNodes(host, nodes, depth = 0, expandAll = false) {
|
|
164
313
|
for (const node of nodes) {
|
|
165
314
|
if (node.kind === 'element') { const item = row(node.label, null, node.entityId); item.style.setProperty('--tree-depth', String(depth)); item.setAttribute('role', 'treeitem'); host.append(item); continue; }
|
|
166
315
|
const branch = document.createElement('div'); branch.className = 'revit-tree-branch'; branch.setAttribute('role', 'treeitem');
|
|
167
316
|
const trigger = row(node.label, node.children.length); trigger.classList.add('revit-tree-trigger'); trigger.style.setProperty('--tree-depth', String(depth));
|
|
168
|
-
trigger.setAttribute('aria-expanded',
|
|
317
|
+
trigger.setAttribute('aria-expanded', String(expandAll));
|
|
169
318
|
if (node.groupedByName) { trigger.dataset.tip = 'Grouped by provider-supplied name; this is not a source relationship.'; }
|
|
170
|
-
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden =
|
|
319
|
+
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden = !expandAll;
|
|
171
320
|
trigger.addEventListener('click', () => { const open = trigger.getAttribute('aria-expanded') !== 'true'; trigger.setAttribute('aria-expanded', String(open)); children.hidden = !open; });
|
|
172
|
-
renderTreeNodes(children, node.children, depth + 1); branch.append(trigger, children); host.append(branch);
|
|
321
|
+
renderTreeNodes(children, node.children, depth + 1, expandAll); branch.append(trigger, children); host.append(branch);
|
|
173
322
|
}
|
|
174
323
|
}
|
|
175
324
|
|
|
176
|
-
function renderClassification(host, values = entities, relationValues = [], followedId = undefined) {
|
|
325
|
+
function renderClassification(host, values = entities, relationValues = [], followedId = undefined, expandAll = false) {
|
|
177
326
|
host.replaceChildren(); host.setAttribute('role', 'tree'); host.setAttribute('aria-label', 'Browse by classification');
|
|
178
327
|
const label = document.createElement('div'); label.className = 'revit-explorer-label'; label.textContent = 'Browse by classification'; host.append(label);
|
|
179
328
|
const visibleValues = values.slice(0, MODEL_EXPLORER_ENTITY_CAP);
|
|
@@ -181,8 +330,8 @@ function renderClassification(host, values = entities, relationValues = [], foll
|
|
|
181
330
|
const followed = requestedFollowedId ? values.find((entity) => entity.id === requestedFollowedId) : null;
|
|
182
331
|
if (followed && !visibleValues.some((entity) => entity.id === followed.id)) visibleValues.push(followed);
|
|
183
332
|
const nodes = buildRevitClassificationTree(visibleValues);
|
|
184
|
-
if (nodes.length) renderTreeNodes(host, nodes); else { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = 'No objects in this classification index.'; host.append(empty); }
|
|
185
|
-
if (values.length > MODEL_EXPLORER_ENTITY_CAP) { const note = document.createElement('div'); note.className = 'explorer-empty explorer-limit'; note.textContent = `Showing the first ${MODEL_EXPLORER_ENTITY_CAP.toLocaleString()} of ${values.length.toLocaleString()} classified objects${followed && visibleValues.length > MODEL_EXPLORER_ENTITY_CAP ? ', plus the selected object' : ''}. Use the Level, Category, or Type index to narrow the model.`; host.append(note); }
|
|
333
|
+
if (nodes.length) renderTreeNodes(host, nodes, 0, expandAll); else { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = expandAll ? 'No objects match this search.' : 'No objects in this classification index.'; host.append(empty); }
|
|
334
|
+
if (values.length > MODEL_EXPLORER_ENTITY_CAP) { const note = document.createElement('div'); note.className = 'explorer-empty explorer-limit'; note.textContent = `Showing the first ${MODEL_EXPLORER_ENTITY_CAP.toLocaleString()} of ${values.length.toLocaleString()} classified objects${followed && visibleValues.length > MODEL_EXPLORER_ENTITY_CAP ? ', plus the selected object' : ''}. Use the ${isTeklaParser ? 'Type' : 'Level, Category, or Type'} index to narrow the model.`; host.append(note); }
|
|
186
335
|
if (!relationValues.length) return;
|
|
187
336
|
const relationLabel = document.createElement('div'); relationLabel.className = 'revit-explorer-label'; relationLabel.textContent = 'Source relationships'; host.append(relationLabel);
|
|
188
337
|
for (const relation of relationValues.slice(0, 500)) {
|
|
@@ -193,48 +342,242 @@ function renderClassification(host, values = entities, relationValues = [], foll
|
|
|
193
342
|
if (relationValues.length > 500) { const note = document.createElement('div'); note.className = 'explorer-empty'; note.textContent = `Showing 500 of ${relationValues.length.toLocaleString()} supplied relationships.`; host.append(note); }
|
|
194
343
|
}
|
|
195
344
|
|
|
196
|
-
function renderEntityList(host, values) {
|
|
345
|
+
function renderEntityList(host, values, ownProperties = propertyByEntity, memberships = teklaAssemblyMembers) {
|
|
197
346
|
host.replaceChildren();
|
|
198
347
|
if (!values.length) { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = 'No objects in this index.'; host.append(empty); return; }
|
|
199
348
|
const fragment = document.createDocumentFragment();
|
|
200
|
-
|
|
349
|
+
const limit = 500;
|
|
350
|
+
for (const entity of values.slice(0, limit)) {
|
|
351
|
+
const memberCount = isTeklaParser && memberships.has(entity.id) ? memberships.get(entity.id).length : null;
|
|
352
|
+
const fields = isTeklaParser ? teklaObjectFields(entity, ownProperties.get(entity.id)) : null;
|
|
353
|
+
const item = row(isTeklaParser ? (fields.name ?? entity.nativeKind ?? entity.typeName ?? 'Tekla object') : (entity.name || entity.typeName || entity.id), memberCount, entity.id, fields);
|
|
354
|
+
if (memberCount != null) item.dataset.tip = `${memberCount} assembly members; selects all signed member geometry`;
|
|
355
|
+
fragment.append(item);
|
|
356
|
+
}
|
|
201
357
|
host.append(fragment);
|
|
202
|
-
if (values.length > 500) {
|
|
358
|
+
if (values.length > 500) {
|
|
359
|
+
const note = document.createElement('div'); note.className = 'explorer-empty';
|
|
360
|
+
note.textContent = isTeklaParser ? `Showing first 500 of ${values.length.toLocaleString()} objects. Select the Type to select all visible matching geometry.` : `Showing 500 of ${values.length.toLocaleString()} objects.`;
|
|
361
|
+
host.append(note);
|
|
362
|
+
}
|
|
203
363
|
}
|
|
204
364
|
|
|
205
|
-
function renderGroupList(host, key, fallback, values = entities) {
|
|
365
|
+
function renderGroupList(host, key, fallback, values = entities, ownProperties = propertyByEntity, expandAll = false) {
|
|
206
366
|
host.replaceChildren(); const groups = new Map();
|
|
207
367
|
for (const entity of values) { const label = (typeof key === 'function' ? key(entity) : entity[key]) || fallback; const grouped = groups.get(label) || []; grouped.push(entity); groups.set(label, grouped); }
|
|
208
368
|
host.setAttribute('role', 'tree');
|
|
209
369
|
const ordered = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0]));
|
|
210
370
|
for (const [label, grouped] of ordered.slice(0, MODEL_EXPLORER_GROUP_CAP)) {
|
|
211
371
|
const branch = document.createElement('div'); branch.className = 'revit-tree-branch'; branch.setAttribute('role', 'treeitem');
|
|
212
|
-
const item = row(label, grouped.length); item.classList.add('revit-tree-trigger'); item.setAttribute('aria-expanded',
|
|
213
|
-
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden =
|
|
372
|
+
const item = row(label, grouped.length); item.classList.add('revit-tree-trigger'); item.setAttribute('aria-expanded', String(expandAll));
|
|
373
|
+
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden = !expandAll;
|
|
214
374
|
let populated = false;
|
|
215
|
-
item.addEventListener('click', () => { const open = item.getAttribute('aria-expanded') !== 'true'; if (open && !populated) { renderEntityList(children, grouped); populated = true; } item.setAttribute('aria-expanded', String(open)); children.hidden = !open; });
|
|
375
|
+
item.addEventListener('click', () => { const open = item.getAttribute('aria-expanded') !== 'true'; if (open && !populated) { renderEntityList(children, grouped, ownProperties); populated = true; } item.setAttribute('aria-expanded', String(open)); children.hidden = !open; });
|
|
376
|
+
if (expandAll) { renderEntityList(children, grouped, ownProperties); populated = true; }
|
|
216
377
|
branch.append(item, children); host.append(branch);
|
|
217
378
|
}
|
|
218
379
|
if (ordered.length > MODEL_EXPLORER_GROUP_CAP) { const note = document.createElement('div'); note.className = 'explorer-empty explorer-limit'; note.textContent = `Showing ${MODEL_EXPLORER_GROUP_CAP} of ${ordered.length.toLocaleString()} groups. Refine the model before browsing the remaining groups.`; host.append(note); }
|
|
219
380
|
}
|
|
220
381
|
|
|
382
|
+
function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemblyMembers, { query = '', followedId = null } = {}) {
|
|
383
|
+
host.replaceChildren(); host.setAttribute('role', 'tree'); host.setAttribute('aria-label', 'Browse Tekla objects by Type');
|
|
384
|
+
const valuesById = new Map(values.map((entity) => [entity.id, entity]));
|
|
385
|
+
const branch = (parent, label, values, populate, { expanded = false, populated = expanded } = {}) => {
|
|
386
|
+
const node = document.createElement('div'); node.className = 'revit-tree-branch'; node.setAttribute('role', 'treeitem');
|
|
387
|
+
const trigger = row(label, values.length); trigger.classList.add('revit-tree-trigger'); trigger.setAttribute('aria-expanded', String(expanded));
|
|
388
|
+
trigger.dataset.selectable = 'true';
|
|
389
|
+
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden = !expanded;
|
|
390
|
+
let hasChildren = false;
|
|
391
|
+
const selectGroup = () => selectTeklaObjects(values[0]?.id ?? null, values.map((entity) => entity.id), true);
|
|
392
|
+
trigger.addEventListener('model-group-select', selectGroup);
|
|
393
|
+
trigger.addEventListener('click', () => {
|
|
394
|
+
const open = trigger.getAttribute('aria-expanded') !== 'true';
|
|
395
|
+
if (open && !hasChildren) { populate(children); hasChildren = true; }
|
|
396
|
+
trigger.setAttribute('aria-expanded', String(open)); children.hidden = !open;
|
|
397
|
+
selectGroup();
|
|
398
|
+
});
|
|
399
|
+
if (populated) { populate(children); hasChildren = true; }
|
|
400
|
+
node.append(trigger, children); parent.append(node);
|
|
401
|
+
};
|
|
402
|
+
const allBrowsable = values.filter((entity) => {
|
|
403
|
+
if (entity.geometry?.length) return true;
|
|
404
|
+
if (entity.structuralGrid?.mapping?.kind === 'symmetric') return true;
|
|
405
|
+
if ((entity.nativeKind || entity.typeName) !== 'Assembly' || entity.assemblyActionable === false) return false;
|
|
406
|
+
return memberships.get(entity.id)?.some((memberId) => valuesById.get(memberId)?.geometry?.length) === true;
|
|
407
|
+
});
|
|
408
|
+
const normalized = query.trim().toLocaleLowerCase();
|
|
409
|
+
const browsable = normalized ? allBrowsable.filter((entity) => {
|
|
410
|
+
const fields = teklaObjectFields(entity, ownProperties.get(entity.id));
|
|
411
|
+
return [fields.name, fields.profile, fields.id, entity.nativeKind, entity.typeName]
|
|
412
|
+
.some((value) => value != null && String(value).toLocaleLowerCase().includes(normalized));
|
|
413
|
+
}) : allBrowsable;
|
|
414
|
+
for (const group of teklaTypeGroups(browsable)) {
|
|
415
|
+
const grouped = [...group.values, ...group.subtypes.flatMap((subtype) => subtype.values)];
|
|
416
|
+
branch(host, group.label, grouped, (children) => {
|
|
417
|
+
if (group.values.length) renderEntityList(children, group.values, ownProperties, memberships);
|
|
418
|
+
for (const subtype of group.subtypes) {
|
|
419
|
+
const containsFollowed = subtype.values.some((entity) => entity.id === followedId);
|
|
420
|
+
branch(children, subtype.label, subtype.values, (body) => renderEntityList(body, subtype.values, ownProperties, memberships),
|
|
421
|
+
{ expanded: !!normalized, populated: !!normalized || containsFollowed });
|
|
422
|
+
}
|
|
423
|
+
}, { expanded: !!normalized, populated: !!normalized || grouped.some((entity) => entity.id === followedId) });
|
|
424
|
+
}
|
|
425
|
+
if (!browsable.length) { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = normalized ? 'No objects match this search.' : 'No verified model objects are available.'; host.append(empty); }
|
|
426
|
+
return { shown: browsable.length, total: allBrowsable.length };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function explorerSearchMatch(entity, query, ownProperties = propertyByEntity) {
|
|
430
|
+
const normalized = query.trim().toLocaleLowerCase(); if (!normalized) return true;
|
|
431
|
+
const values = isTeklaParser
|
|
432
|
+
? Object.values(teklaObjectFields(entity, ownProperties.get(entity.id)))
|
|
433
|
+
: [entity.name, entity.label, entity.typeName, entity.id];
|
|
434
|
+
return values.some((value) => value != null && String(value).toLocaleLowerCase().includes(normalized));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function renderExplorerSearch(tab, query, followedId = null) {
|
|
438
|
+
const host = $(modelExplorerTabs.find((candidate) => candidate.key === tab)?.bodyId); if (!host) return false;
|
|
439
|
+
const clean = query.trim(); modelSearchQueries.set(tab, clean);
|
|
440
|
+
if (isTeklaParser) {
|
|
441
|
+
const result = renderTeklaTypes(host, entities, propertyByEntity, teklaAssemblyMembers, { query: clean, followedId });
|
|
442
|
+
modelSearchResults.set(tab, result); return true;
|
|
443
|
+
}
|
|
444
|
+
const matches = entities.filter((entity) => explorerSearchMatch(entity, clean));
|
|
445
|
+
if (tab === 'model') renderClassification(host, matches, clean ? [] : relationships, followedId, !!clean);
|
|
446
|
+
else if (tab === 'levels') renderGroupList(host, 'levelName', 'No level', matches, propertyByEntity, !!clean);
|
|
447
|
+
else if (tab === 'categories') renderGroupList(host, (entity) => entity.categoryName ?? entity.category, 'No category', matches, propertyByEntity, !!clean);
|
|
448
|
+
else if (tab === 'types') renderGroupList(host, 'typeName', 'No type', matches, propertyByEntity, !!clean);
|
|
449
|
+
else return false;
|
|
450
|
+
modelSearchResults.set(tab, { shown: matches.length, total: entities.length }); return true;
|
|
451
|
+
}
|
|
452
|
+
|
|
221
453
|
function receipt(manifest, logicalName, legacySchema) {
|
|
222
454
|
return manifest.receipts.find((item) => item.logicalName === logicalName || item.schema === legacySchema || item.kind === logicalName);
|
|
223
455
|
}
|
|
224
456
|
|
|
457
|
+
function validateTeklaAuditDocument(value, manifest, auditReceipt, snapshotEntities) {
|
|
458
|
+
const failAudit = () => { throw new Error('The authenticated Tekla import audit is malformed.'); };
|
|
459
|
+
const exactKeys = (candidate, expected) => candidate && typeof candidate === 'object' && !Array.isArray(candidate)
|
|
460
|
+
&& Object.keys(candidate).sort().join('\0') === [...expected].sort().join('\0');
|
|
461
|
+
const snapshotEntityIds = new Set(snapshotEntities.map((entity) => entity.id));
|
|
462
|
+
const omissions = value?.summary?.decoderOmissions;
|
|
463
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)
|
|
464
|
+
|| !exactKeys(value, ['schemaVersion', 'summary', 'sourcePropertyDigests', 'findings'])
|
|
465
|
+
|| value.schemaVersion !== 'floless.tekla-import-audit/v1'
|
|
466
|
+
|| !exactKeys(value.summary, ['findings', 'affectedObjects', 'open', 'legacyCounts', 'unsupportedNativeTypes', ...(omissions === undefined ? [] : ['decoderOmissions'])])
|
|
467
|
+
|| !Array.isArray(value.sourcePropertyDigests) || value.sourcePropertyDigests.some((digest) => !/^[0-9a-f]{64}$/.test(digest))
|
|
468
|
+
|| !Array.isArray(value.summary.legacyCounts) || value.summary.legacyCounts.length !== 6
|
|
469
|
+
|| value.summary.legacyCounts.some((count) => !Number.isSafeInteger(count) || count < 0)
|
|
470
|
+
|| !Number.isSafeInteger(value.summary.unsupportedNativeTypes) || value.summary.unsupportedNativeTypes < 0
|
|
471
|
+
|| !Array.isArray(value.findings)
|
|
472
|
+
|| value.findings.length !== auditReceipt.items || value.findings.length !== manifest.audit?.findings
|
|
473
|
+
|| value.summary.findings !== value.findings.length || value.summary.open !== value.findings.length
|
|
474
|
+
|| !Number.isSafeInteger(value.summary.affectedObjects) || value.summary.affectedObjects < 0
|
|
475
|
+
|| value.summary.affectedObjects !== manifest.audit?.affectedObjects || value.summary.open !== manifest.audit?.open) failAudit();
|
|
476
|
+
if (omissions !== undefined && (!exactKeys(omissions, ['staleOrphanUdaAssignments', 'staleOrphanAssemblyDefinitions', 'description'])
|
|
477
|
+
|| ![omissions.staleOrphanUdaAssignments, omissions.staleOrphanAssemblyDefinitions].every((count) => Number.isSafeInteger(count) && count >= 0 && count <= 0xffffffff)
|
|
478
|
+
|| omissions.description !== 'Ignored stale database records not attached to model objects')) failAudit();
|
|
479
|
+
const ids = new Set(); const affected = new Set();
|
|
480
|
+
for (const finding of value.findings) {
|
|
481
|
+
if (!exactKeys(finding, ['issueId', 'entityId', 'objectGuid', 'objectKind', 'check', 'code', 'group', 'hasGeometry', 'evidence'])
|
|
482
|
+
|| typeof finding.issueId !== 'string' || !/^[0-9a-f]{64}$/.test(finding.issueId)
|
|
483
|
+
|| ids.has(finding.issueId) || typeof finding.entityId !== 'string' || !snapshotEntityIds.has(finding.entityId)
|
|
484
|
+
|| typeof finding.objectGuid !== 'string' || !/^[0-9a-f-]{36}$/.test(finding.objectGuid)
|
|
485
|
+
|| typeof finding.objectKind !== 'string' || typeof finding.check !== 'string'
|
|
486
|
+
|| typeof finding.code !== 'string' || !Object.hasOwn(TEKLA_AUDIT_COPY, finding.code)
|
|
487
|
+
|| TEKLA_AUDIT_COPY[finding.code].group !== finding.group || typeof finding.hasGeometry !== 'boolean'
|
|
488
|
+
|| !finding.evidence || typeof finding.evidence !== 'object' || Array.isArray(finding.evidence)
|
|
489
|
+
|| JSON.stringify(finding.evidence).length > 4096) failAudit();
|
|
490
|
+
ids.add(finding.issueId); affected.add(finding.entityId);
|
|
491
|
+
}
|
|
492
|
+
if (affected.size !== value.summary.affectedObjects) failAudit();
|
|
493
|
+
return value;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function selectAuditFinding(finding) {
|
|
497
|
+
if (!entityById.has(finding.entityId)) throw new Error('This audited object is not present in the authenticated snapshot.');
|
|
498
|
+
if (finding.hasGeometry) {
|
|
499
|
+
inspect(finding.entityId, true, true, 'audit');
|
|
500
|
+
facade.dispatch('model.fit-selection');
|
|
501
|
+
} else {
|
|
502
|
+
selectedIds = []; geometrySelectionIds = [];
|
|
503
|
+
selectionOriginGuard.run(() => viewport.setSelection({ ids: [] }));
|
|
504
|
+
inspect(finding.entityId, false, true, 'audit');
|
|
505
|
+
}
|
|
506
|
+
renderTeklaAudit();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function renderTeklaAudit() {
|
|
510
|
+
const host = $('teklaAuditHost'); if (!host || !isTeklaParser) return;
|
|
511
|
+
host.replaceChildren();
|
|
512
|
+
if (!teklaAudit) { const empty = document.createElement('div'); empty.className = 'tekla-audit-state'; empty.textContent = 'Import audit is not loaded.'; host.append(empty); return; }
|
|
513
|
+
if (teklaAudit.legacy) {
|
|
514
|
+
const state = document.createElement('div'); state.className = 'tekla-audit-state';
|
|
515
|
+
const heading = document.createElement('strong'); heading.textContent = 'Legacy snapshot';
|
|
516
|
+
const copy = document.createElement('span'); copy.textContent = 'Import audit is unavailable for snapshots created before database coverage auditing was added.';
|
|
517
|
+
state.append(heading, copy); host.append(state); return;
|
|
518
|
+
}
|
|
519
|
+
const summary = document.createElement('section'); summary.className = 'tekla-audit-summary'; summary.setAttribute('aria-label', 'Import audit summary');
|
|
520
|
+
for (const [value, label] of [[teklaAudit.summary.findings, 'Findings'], [teklaAudit.summary.affectedObjects, 'Affected objects']]) {
|
|
521
|
+
const metric = document.createElement('div'); const number = document.createElement('strong'); number.textContent = Number(value).toLocaleString(); const text = document.createElement('span'); text.textContent = label; metric.append(number, text); summary.append(metric);
|
|
522
|
+
}
|
|
523
|
+
const omissions = teklaAudit.summary.decoderOmissions;
|
|
524
|
+
if (omissions && (omissions.staleOrphanUdaAssignments || omissions.staleOrphanAssemblyDefinitions)) {
|
|
525
|
+
const note = document.createElement('p'); note.className = 'tekla-audit-omissions';
|
|
526
|
+
note.textContent = `${omissions.description}: ${omissions.staleOrphanUdaAssignments} UDA assignments and ${omissions.staleOrphanAssemblyDefinitions} assembly definitions. These records are not selectable model objects.`;
|
|
527
|
+
summary.append(note);
|
|
528
|
+
}
|
|
529
|
+
const filters = document.createElement('div'); filters.className = 'tekla-audit-filters'; filters.setAttribute('role', 'group'); filters.setAttribute('aria-label', 'Filter import findings');
|
|
530
|
+
const filterSpecs = [
|
|
531
|
+
['all', 'All'], ['not-shown', 'Not shown'], ['fit-not-confirmed', 'Fit not confirmed'], ['shape-not-evaluated', 'Shape detail not evaluated'],
|
|
532
|
+
];
|
|
533
|
+
let active = host.dataset.filter || 'all';
|
|
534
|
+
const list = document.createElement('div'); list.className = 'tekla-audit-list'; list.setAttribute('role', 'listbox'); list.setAttribute('aria-label', 'Import findings');
|
|
535
|
+
const paintRows = () => {
|
|
536
|
+
list.replaceChildren();
|
|
537
|
+
const visible = teklaAudit.findings.filter((finding) => active === 'all' || finding.group === active);
|
|
538
|
+
if (!visible.length) { const empty = document.createElement('div'); empty.className = 'tekla-audit-empty'; empty.textContent = 'No findings in this group.'; list.append(empty); return; }
|
|
539
|
+
for (const finding of visible) {
|
|
540
|
+
const copy = TEKLA_AUDIT_COPY[finding.code]; const entity = entityById.get(finding.entityId);
|
|
541
|
+
const button = document.createElement('button'); button.type = 'button'; button.className = 'tekla-audit-row'; button.setAttribute('role', 'option');
|
|
542
|
+
button.setAttribute('aria-selected', String(selectedId === finding.entityId)); button.dataset.issueId = finding.issueId;
|
|
543
|
+
const heading = document.createElement('strong'); heading.textContent = copy.title;
|
|
544
|
+
const name = document.createElement('span'); name.textContent = entity?.name || entity?.typeName || finding.entityId;
|
|
545
|
+
const location = document.createElement('span'); location.className = finding.hasGeometry ? 'tekla-audit-location' : 'tekla-audit-location missing'; location.textContent = finding.hasGeometry ? 'Shown in 3D' : 'No 3D location';
|
|
546
|
+
button.dataset.commandId = 'tekla-parser.audit-finding'; button.dataset.commandInstanceLabel = `${copy.title}: ${name.textContent}`;
|
|
547
|
+
button.append(heading, name, location); button.addEventListener('click', () => { try { selectAuditFinding(finding); window.__instructor?.notifyChanged(); } catch (error) { toast(error.message); } }); list.append(button);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
for (const [key, label] of filterSpecs) {
|
|
551
|
+
const button = document.createElement('button'); button.type = 'button'; button.className = 'tekla-audit-filter'; button.textContent = label; button.setAttribute('aria-pressed', String(active === key));
|
|
552
|
+
button.dataset.commandId = 'tekla-parser.audit-filter'; button.dataset.commandInstanceLabel = label;
|
|
553
|
+
button.addEventListener('click', () => { active = key; host.dataset.filter = key; for (const item of filters.children) item.setAttribute('aria-pressed', String(item === button)); paintRows(); window.__instructor?.notifyChanged(); }); filters.append(button);
|
|
554
|
+
}
|
|
555
|
+
list.addEventListener('keydown', (event) => {
|
|
556
|
+
const rows = [...list.querySelectorAll('.tekla-audit-row')]; if (!rows.length) return;
|
|
557
|
+
const index = Math.max(0, rows.indexOf(document.activeElement)); let next = null;
|
|
558
|
+
if (event.key === 'ArrowDown') next = rows[Math.min(rows.length - 1, index + 1)];
|
|
559
|
+
else if (event.key === 'ArrowUp') next = rows[Math.max(0, index - 1)];
|
|
560
|
+
else if (event.key === 'Home') next = rows[0]; else if (event.key === 'End') next = rows.at(-1);
|
|
561
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
562
|
+
});
|
|
563
|
+
paintRows(); host.append(summary, filters, list);
|
|
564
|
+
}
|
|
565
|
+
|
|
225
566
|
function updateSelectionActions() {
|
|
226
|
-
const blocked = !selectedId;
|
|
227
|
-
for (const command of [
|
|
567
|
+
const blocked = !selectedId || (isTeklaParser ? geometrySelectionIds : selectedIds).length === 0;
|
|
568
|
+
for (const command of [`${commandPrefix}.fit-selection`]) {
|
|
228
569
|
const control = [...document.querySelectorAll('[data-command-id]')].find((item) => item.dataset.commandId === command);
|
|
229
570
|
if (!control) continue;
|
|
230
|
-
if (command ===
|
|
571
|
+
if (command === `${commandPrefix}.fit-selection`) {
|
|
231
572
|
control.disabled = blocked;
|
|
232
|
-
if (blocked) control.dataset.blockedReason = 'Select a model object first.'; else delete control.dataset.blockedReason;
|
|
573
|
+
if (blocked) control.dataset.blockedReason = selectedId ? 'This audit object has no 3D location to frame.' : 'Select a model object first.'; else delete control.dataset.blockedReason;
|
|
233
574
|
}
|
|
234
575
|
}
|
|
235
576
|
}
|
|
236
577
|
|
|
237
|
-
const SELECTION_FACETS = Object.freeze([
|
|
578
|
+
const SELECTION_FACETS = Object.freeze(isTeklaParser ? [
|
|
579
|
+
Object.freeze({ id: 'type', label: 'Type', value: (entity) => entity.typeName ?? 'No type' }),
|
|
580
|
+
] : [
|
|
238
581
|
Object.freeze({ id: 'category', label: 'Categories', value: (entity) => entity.categoryName ?? entity.category ?? 'No category' }),
|
|
239
582
|
Object.freeze({ id: 'type', label: 'Types', value: (entity) => entity.typeName ?? 'No type' }),
|
|
240
583
|
Object.freeze({ id: 'family', label: 'Families or classes', value: (entity) => entity.familyName ?? entity.family ?? 'No family or class' }),
|
|
@@ -310,7 +653,7 @@ function reflectSelectionHover(hit) {
|
|
|
310
653
|
const id = hit?.entity?.sourceId ?? null; viewport?.setHover?.(id);
|
|
311
654
|
const summary = $('modelHoverSummary');
|
|
312
655
|
if (!id) { summary.hidden = true; summary.textContent = ''; return; }
|
|
313
|
-
const entity = entityById.get(id); summary.textContent = entity?.name || entity?.typeName || id; summary.hidden = false;
|
|
656
|
+
const entity = entityById.get(id); summary.textContent = isTeklaParser && entity ? teklaObjectLabel(entity, propertyByEntity.get(id)) : (entity?.name || entity?.typeName || id); summary.hidden = false;
|
|
314
657
|
}
|
|
315
658
|
|
|
316
659
|
function reflectSelectionMarquee(rect) {
|
|
@@ -423,30 +766,50 @@ function scheduleEditorStateSave(reason) {
|
|
|
423
766
|
editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => toast(error.message || 'Could not save model view state.')); }, 350);
|
|
424
767
|
}
|
|
425
768
|
|
|
426
|
-
async function
|
|
769
|
+
async function prepareSpatialForRevision(state, handle) {
|
|
427
770
|
await flushEditorStateSave();
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
771
|
+
let modelId;
|
|
772
|
+
if (isTeklaParser) {
|
|
773
|
+
modelId = handle.revisionId;
|
|
774
|
+
} else {
|
|
775
|
+
const primary = projectContract?.models?.find((model) => model.modelId === projectContract.primaryModelId);
|
|
776
|
+
if (!primary || typeof projectContract.primaryModelId !== 'string') throw new Error('The model contract does not identify its primary model.');
|
|
777
|
+
modelId = projectContract.primaryModelId;
|
|
778
|
+
}
|
|
779
|
+
const binding = { projectUuid: state.projectUuid, modelId, baseRevisionId: handle.revisionId, sourceDigest: handle.sourceSha256 };
|
|
780
|
+
// This read is also the authority probe: the server resolves this exact revision against its draft or
|
|
781
|
+
// approved contract and immutable manifest before it reads optional view state. Do it before staging
|
|
782
|
+
// geometry so a stale/mismatched authority cannot replace the last good scene.
|
|
783
|
+
const url = editorStateUrl(binding);
|
|
436
784
|
const response = await fetch(url, { credentials: 'same-origin' }); let stored = null;
|
|
437
|
-
if (response.ok) { const value = await response.json()
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
785
|
+
if (!response.ok) { const value = await response.json().catch(() => ({})); throw new Error(value.message || value.error || `Editor state read failed (${response.status})`); }
|
|
786
|
+
const value = await response.json(); stored = value.state;
|
|
787
|
+
const etag = response.headers.get('etag') || stored?.etag || null;
|
|
788
|
+
const recovered = readEditorStateRecovery(binding, etag);
|
|
789
|
+
if (recovered) stored = { ...(stored || {}), ...recovered, annotations: stored?.annotations ?? recovered.annotations ?? [] };
|
|
790
|
+
const loaded = payloadOnly(stored);
|
|
791
|
+
let candidateTools = null;
|
|
792
|
+
candidateTools = createModelSpatialTools({ initial: spatialInitialFromStored(stored),
|
|
793
|
+
onChange: (_value, reason) => { if (spatialTools === candidateTools) scheduleEditorStateSave(reason); } });
|
|
794
|
+
const candidateClip = createModelClipSession({
|
|
795
|
+
tools: candidateTools,
|
|
445
796
|
placementOwnsKeyboard: () => !!facade?.clipMode?.(),
|
|
446
797
|
dragOwnsKeyboard: () => !!viewport?.clipDragActive?.(),
|
|
447
798
|
onArmPlane: () => { facade?.dispatch('model.clip.arm', 'plane'); },
|
|
448
799
|
onArmBox: () => { facade?.dispatch('model.clip.arm', 'box'); },
|
|
449
800
|
});
|
|
801
|
+
return { binding, etag, loaded, recovered, tools: candidateTools, clip: candidateClip, committed: false,
|
|
802
|
+
dispose() { if (this.committed) return; candidateClip.dispose(); candidateTools.dispose(); } };
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function commitSpatialForRevision(candidate) {
|
|
806
|
+
editorStateBindingToken += 1; clearTimeout(editorStateSaveTimer); editorStateSaveTimer = null;
|
|
807
|
+
editorStateBinding = candidate.binding; editorStateEtag = candidate.etag; editorStateLoaded = candidate.loaded;
|
|
808
|
+
editorStateDirtyPayload = null; editorStateDirtyGeneration = 0; editorStateSavedGeneration = 0;
|
|
809
|
+
clipList?.destroy(); clipList = null; releaseClipEditor?.(); releaseClipEditor = null; releaseClipViewport?.(); releaseClipViewport = null; clipSession?.dispose(); clipSession = null;
|
|
810
|
+
spatialPanel?.destroy(); spatialPanel = null; releaseSpatialViewport?.(); releaseSpatialViewport = null; spatialTools?.dispose(); spatialTools = null;
|
|
811
|
+
spatialTools = candidate.tools; clipSession = candidate.clip; candidate.committed = true;
|
|
812
|
+
releaseSpatialViewport = viewport.bindSpatialTools(spatialTools);
|
|
450
813
|
releaseClipViewport = viewport.bindClipSession(clipSession);
|
|
451
814
|
clipList = mountModelClipList({ session: clipSession, host: revitClipListHost, onError: toast });
|
|
452
815
|
releaseClipEditor = clipSession.subscribe((value) => {
|
|
@@ -455,8 +818,9 @@ async function activateSpatialForRevision(state, handle) {
|
|
|
455
818
|
});
|
|
456
819
|
spatialTools.subscribe((value) => { $('modelFrameStatus').textContent = spatialTools.activeFrame().label; window.__revitInstructorState = { ...(window.__revitInstructorState || {}), activeFrame: value.activeFrameId }; reflectToolbarState(); });
|
|
457
820
|
spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: closeSpatialDialog,
|
|
821
|
+
lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
|
|
458
822
|
onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
|
|
459
|
-
if (recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => toast(error.message || 'Could not restore model view state.')), 0); }
|
|
823
|
+
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => toast(error.message || 'Could not restore model view state.')), 0); }
|
|
460
824
|
}
|
|
461
825
|
|
|
462
826
|
function positionDialog(panel, anchor) {
|
|
@@ -499,10 +863,11 @@ function openSavedViews() {
|
|
|
499
863
|
function openPlaneOffset(plane, anchor) {
|
|
500
864
|
spatialPanel?.close({ restoreFocus: false }); closeSpatialDialog(); const panel = document.createElement('section'); panel.className = 'model-spatial-dialog'; panel.setAttribute('aria-label', `${plane.toUpperCase()} working plane offset`);
|
|
501
865
|
const headingLabel = document.createElement('strong'); headingLabel.textContent = `${plane.toUpperCase()} working plane`;
|
|
502
|
-
const
|
|
503
|
-
const
|
|
866
|
+
const units = displayUnitControl.units();
|
|
867
|
+
const note = document.createElement('div'); note.className = 'model-dialog-note'; note.textContent = `Offset along the plane normal (${units}).`;
|
|
868
|
+
const input = document.createElement('input'); input.type = 'text'; input.inputMode = 'decimal'; input.autocomplete = 'off'; input.value = formatLength(0, units); input.setAttribute('aria-label', `Working plane offset in ${units}`); input.dataset.commandId = `${commandPrefix}.work-plane-offset`; input.dataset.commandInstanceLabel = plane.toUpperCase();
|
|
504
869
|
const actions = document.createElement('div'); actions.className = 'model-spatial-dialog-actions'; const cancel = document.createElement('button'); cancel.type = 'button'; cancel.textContent = 'Cancel'; cancel.addEventListener('click', closeSpatialDialog);
|
|
505
|
-
const apply = document.createElement('button'); apply.type = 'button'; apply.textContent = 'Set plane'; apply.addEventListener('click', () => { const offsetMm =
|
|
870
|
+
const apply = document.createElement('button'); apply.type = 'button'; apply.textContent = 'Set plane'; apply.dataset.commandId = `${commandPrefix}.work-plane-set`; apply.dataset.commandInstanceLabel = plane.toUpperCase(); apply.addEventListener('click', () => { const offsetMm = parseLengthMm(input.value, units); if (offsetMm === null) { input.setAttribute('aria-invalid', 'true'); return; } facade.dispatch('model.work-plane.principal', { plane, offsetMm }); closeSpatialDialog(); });
|
|
506
871
|
actions.append(cancel, apply); panel.append(headingLabel, note, input, actions); positionDialog(panel, anchor); input.focus(); input.select();
|
|
507
872
|
}
|
|
508
873
|
|
|
@@ -557,9 +922,23 @@ function reflectToolbarState() {
|
|
|
557
922
|
if (clearClips) clearClips.disabled = clips.length === 0;
|
|
558
923
|
}
|
|
559
924
|
|
|
925
|
+
function syncGridVisibilityAction() {
|
|
926
|
+
const filtered = viewport?.gridLevels?.().some((level) => !level.visible) === true;
|
|
927
|
+
const show = $('revitVisibilityMenu')?.querySelector('[data-vis="show-all"]');
|
|
928
|
+
const divider = $('revitVisibilityMenu')?.querySelector('[data-vis-divider]');
|
|
929
|
+
if (show) { show.hidden = !filtered; show.style.display = filtered ? '' : 'none'; }
|
|
930
|
+
if (divider) { divider.hidden = !filtered; divider.style.display = filtered ? '' : 'none'; }
|
|
931
|
+
}
|
|
932
|
+
|
|
560
933
|
function wireToolbar() {
|
|
561
|
-
const
|
|
562
|
-
|
|
934
|
+
const plan = isTeklaParser
|
|
935
|
+
? readOnlyModelRenderPlan({ commandPrefix, sourceLabel: 'Tekla' })
|
|
936
|
+
: revitRenderPlan();
|
|
937
|
+
const bar = $('m3dBar'); bar.innerHTML = renderToolbarMarkup(plan); const chrome = mountToolbarChrome({ toolbar: bar, port: facade });
|
|
938
|
+
const lightingChrome = mountModelLightingPanel({
|
|
939
|
+
trigger: $('revitLighting'), anchor: $('revitDisplay'), target: facade,
|
|
940
|
+
profile: isTeklaParser ? 'tekla-parser' : 'revit',
|
|
941
|
+
});
|
|
563
942
|
const clipButton = $('revitClip');
|
|
564
943
|
const cancelArmedClip = (event) => {
|
|
565
944
|
if (!facade.clipMode?.()) return;
|
|
@@ -576,18 +955,20 @@ function wireToolbar() {
|
|
|
576
955
|
else if (control.id === 'revitFitSelection') facade.dispatch('model.fit-selection');
|
|
577
956
|
else if (control.id === 'revitSavedViews') facade.dispatch('model.saved-views');
|
|
578
957
|
else if (control.dataset.spatial) handleSpatialAction(control.dataset.spatial, control);
|
|
958
|
+
if (control.dataset.vis === 'show-all') viewport.setGridHiddenLevels([]);
|
|
579
959
|
for (const radio of control.parentElement?.querySelectorAll('[role="menuitemradio"]') || []) radio.setAttribute('aria-checked', String(radio === control));
|
|
580
960
|
reflectToolbarState();
|
|
961
|
+
modelPanelBridge?.publishSnapshot();
|
|
581
962
|
window.__instructor?.notifyChanged();
|
|
582
963
|
} catch (error) { toast(error.message || 'That view action is unavailable.'); }
|
|
583
964
|
});
|
|
584
965
|
updateSelectionActions();
|
|
585
966
|
reflectToolbarState();
|
|
586
|
-
const release = facade.subscribe(() => { try { reflectToolbarState(); } catch (_) {} });
|
|
967
|
+
const release = facade.subscribe(() => { try { syncGridVisibilityAction(); reflectToolbarState(); } catch (_) {} });
|
|
587
968
|
return { destroy() { clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
|
|
588
969
|
}
|
|
589
970
|
|
|
590
|
-
async function loadRevision(state, authority) {
|
|
971
|
+
async function loadRevision(state, authority, spatialCandidate) {
|
|
591
972
|
revisionLoadController?.abort();
|
|
592
973
|
const controller = new AbortController(); revisionLoadController = controller;
|
|
593
974
|
const token = ++revisionLoadToken;
|
|
@@ -597,48 +978,65 @@ async function loadRevision(state, authority) {
|
|
|
597
978
|
const base = `/api/editor/model/${encodeURIComponent(state.projectUuid)}/${encodeURIComponent(handle.revisionId)}`;
|
|
598
979
|
const manifest = (await json(`${base}/manifest`)).manifest;
|
|
599
980
|
if (token !== revisionLoadToken) return false;
|
|
981
|
+
if (manifest.revisionId !== handle.revisionId || manifest.projectUuid !== state.projectUuid
|
|
982
|
+
|| manifest.sourceSha256 !== handle.sourceSha256 || manifest.manifestRoot !== handle.manifestRoot) {
|
|
983
|
+
throw new Error('The selected model authority does not match its verified snapshot package.');
|
|
984
|
+
}
|
|
600
985
|
const entityReceipt = receipt(manifest, 'entities-000000', 'aware-package:entities-000000');
|
|
601
986
|
const propertyReceipt = receipt(manifest, 'properties-000000', 'aware-package:properties-000000');
|
|
602
987
|
const relationshipReceipt = receipt(manifest, 'relationships-000000', 'aware-package:relationships-000000');
|
|
988
|
+
const auditReceipt = manifest.schema === 'floless.model-cas-manifest/v3' ? receipt(manifest, 'tekla-audit-000000', 'floless.tekla-import-audit/v1') : null;
|
|
603
989
|
const tileId = manifest.tiles.ids[0];
|
|
604
990
|
const tileReceipt = manifest.receipts.find((item) => item.kind === 'tile' && item.digest === tileId);
|
|
605
|
-
if (!entityReceipt || !propertyReceipt || !relationshipReceipt || !tileId || !tileReceipt
|
|
991
|
+
if (!entityReceipt || !propertyReceipt || !relationshipReceipt || !tileId || !tileReceipt
|
|
992
|
+
|| (isTeklaParser && manifest.schema === 'floless.model-cas-manifest/v3' && (!auditReceipt || auditReceipt.digest !== manifest.audit?.digest))) throw new Error('The verified snapshot package is incomplete.');
|
|
606
993
|
preflightModelJsonReceipt(entityReceipt); preflightModelJsonReceipt(propertyReceipt); preflightModelJsonReceipt(relationshipReceipt);
|
|
607
|
-
|
|
994
|
+
if (auditReceipt) preflightModelJsonReceipt(auditReceipt);
|
|
995
|
+
const aggregateBytes = entityReceipt.bytes + propertyReceipt.bytes + relationshipReceipt.bytes + tileReceipt.bytes + (auditReceipt?.bytes ?? 0);
|
|
608
996
|
if (!Number.isSafeInteger(aggregateBytes) || aggregateBytes > MODEL_VIEWER_MAX_AGGREGATE_BYTES) throw new Error('This model exceeds the bounded viewer package limit.');
|
|
609
997
|
// Read large artifacts sequentially so their authenticated byte buffers are released before the
|
|
610
998
|
// next download starts. The parsed rows remain, but four simultaneous 100+ MiB buffers do not.
|
|
611
999
|
const entityArtifact = await readModelJsonArtifact({ url: `${base}/entities/${entityReceipt.digest}`, receipt: entityReceipt, rowKey: 'entities', expectedItems: manifest.entities.count, signal: controller.signal });
|
|
612
1000
|
const propertyArtifact = await readModelJsonArtifact({ url: `${base}/entities/${propertyReceipt.digest}`, receipt: propertyReceipt, rowKey: 'properties', signal: controller.signal });
|
|
613
1001
|
const relationshipArtifact = await readModelJsonArtifact({ url: `${base}/entities/${relationshipReceipt.digest}`, receipt: relationshipReceipt, rowKey: 'relationships', signal: controller.signal });
|
|
1002
|
+
const auditArtifact = auditReceipt ? await readModelJsonDocument({ url: `${base}/entities/${auditReceipt.digest}`, receipt: auditReceipt, signal: controller.signal }) : null;
|
|
614
1003
|
const tile = await readModelBinaryArtifact({ url: `${base}/tiles/${tileId}`, receipt: tileReceipt, maxBytes: MODEL_VIEWER_MAX_TILE_BYTES, signal: controller.signal });
|
|
615
1004
|
if (token !== revisionLoadToken) return false;
|
|
616
1005
|
const nextEntities = entityArtifact.rows; const nextProperties = propertyArtifact.rows; const nextRelationships = relationshipArtifact.rows;
|
|
1006
|
+
const nextAudit = auditArtifact ? validateTeklaAuditDocument(auditArtifact.document, manifest, auditReceipt, nextEntities) : (isTeklaParser ? { legacy: true } : null);
|
|
617
1007
|
assertModelViewerRowBudget(nextEntities, nextProperties, nextRelationships);
|
|
618
1008
|
const nextEntityById = new Map(nextEntities.map((entity) => [entity.id, entity]));
|
|
619
1009
|
const nextPropertyByEntity = new Map();
|
|
620
1010
|
for (const item of nextProperties) { const values = nextPropertyByEntity.get(item.entityId) || []; values.push(item); nextPropertyByEntity.set(item.entityId, values); }
|
|
621
1011
|
const owners = new Map(); for (const entity of nextEntities) for (const geometry of entity.geometry || []) if (geometry.nodeName) owners.set(geometry.nodeName, entity.id);
|
|
622
|
-
const staged = {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
1012
|
+
const staged = { model: document.createElement('div'), types: document.createElement('div'),
|
|
1013
|
+
...(!isTeklaParser ? { levels: document.createElement('div'), categories: document.createElement('div') } : {}) };
|
|
1014
|
+
if (!isTeklaParser) renderClassification(staged.model, nextEntities, nextRelationships, null);
|
|
1015
|
+
if (!isTeklaParser) {
|
|
1016
|
+
renderGroupList(staged.levels, 'levelName', 'No level', nextEntities);
|
|
1017
|
+
renderGroupList(staged.categories, (entity) => entity.categoryName ?? entity.category, 'No category', nextEntities);
|
|
1018
|
+
}
|
|
1019
|
+
if (isTeklaParser) renderTeklaTypes(staged.types, nextEntities, nextPropertyByEntity, teklaAssemblyMembership(nextRelationships));
|
|
1020
|
+
else renderGroupList(staged.types, 'typeName', 'No type', nextEntities, nextPropertyByEntity);
|
|
630
1021
|
if (token !== revisionLoadToken) return false;
|
|
631
|
-
|
|
1022
|
+
const nextStructuralGrid = isTeklaParser ? findTeklaStructuralGrid(nextEntities) : null;
|
|
1023
|
+
await viewport.load(tile, owners, { schema: manifest.schema, providerKind: manifest.provider.kind, geometryToRenderMatrix: manifest.geometryToRenderMatrix }, nextStructuralGrid);
|
|
632
1024
|
if (token !== revisionLoadToken) return false;
|
|
633
|
-
|
|
1025
|
+
commitSpatialForRevision(spatialCandidate);
|
|
1026
|
+
teklaAudit = null; selectedId = null; selectedIds = []; geometrySelectionIds = [];
|
|
1027
|
+
entities = nextEntities; properties = nextProperties; relationships = nextRelationships; entityById = nextEntityById; propertyByEntity = nextPropertyByEntity; teklaAudit = nextAudit;
|
|
1028
|
+
teklaAssemblyMembers = isTeklaParser ? teklaAssemblyMembership(nextRelationships) : new Map();
|
|
634
1029
|
selectionTools?.generationChanged();
|
|
635
1030
|
selectionFilterChrome?.refresh();
|
|
636
1031
|
$('revitExplorerClassification').replaceChildren(...staged.model.childNodes);
|
|
637
1032
|
classificationFollowedId = null;
|
|
638
|
-
|
|
639
|
-
|
|
1033
|
+
if (!isTeklaParser) {
|
|
1034
|
+
$('revitExplorerLevels').replaceChildren(...staged.levels.childNodes);
|
|
1035
|
+
$('revitExplorerCategories').replaceChildren(...staged.categories.childNodes);
|
|
1036
|
+
}
|
|
640
1037
|
$('revitExplorerTypes').replaceChildren(...staged.types.childNodes);
|
|
641
1038
|
inspect(null, true, false, 'tree');
|
|
1039
|
+
renderTeklaAudit();
|
|
642
1040
|
modelPanelBridge?.ready(handle.revisionId);
|
|
643
1041
|
$('loadingState').style.display = 'none';
|
|
644
1042
|
return true;
|
|
@@ -650,25 +1048,44 @@ async function loadRevision(state, authority) {
|
|
|
650
1048
|
}
|
|
651
1049
|
|
|
652
1050
|
// The main window's left Model section shows the clip list as a PANEL tab (web/model-panel-bridge.js).
|
|
653
|
-
const REVIT_PANEL_TABS = Object.freeze([
|
|
1051
|
+
const REVIT_PANEL_TABS = Object.freeze([
|
|
1052
|
+
Object.freeze({ key: 'clips', label: 'Clips', tip: 'Clips — the planes and boxes cutting the model: select, rename, switch on or off, remove' }),
|
|
1053
|
+
...(isTeklaParser ? [Object.freeze({ key: 'audit', label: 'Audit', tip: 'Audit — database objects whose displayed shape or placement could not be fully verified' })] : []),
|
|
1054
|
+
]);
|
|
654
1055
|
// Held, not looked up: once shown, the Clips tab lives in the main window's frame, where $() cannot find it.
|
|
655
1056
|
const revitClipListHost = $('revitClipListHost');
|
|
656
|
-
const
|
|
1057
|
+
const teklaAuditHost = $('teklaAuditHost');
|
|
1058
|
+
const revitPanelHost = createPanelHost({ win: window, root: $('revitPanelTabs'), bodies: { clips: revitClipListHost, ...(teklaAuditHost ? { audit: teklaAuditHost } : {}) }, install: installTooltips });
|
|
657
1059
|
|
|
658
1060
|
function mountPanels() {
|
|
659
1061
|
inspector = mountInspectorShell({ panel: $('inspectorBody'), doc: document, win: window, placement: 'docked', readOnly: true, emptyMessage: 'Select an object to see its imported properties.' });
|
|
660
|
-
|
|
1062
|
+
const storagePrefix = isTeklaParser ? 'floless:tekla-parser' : 'floless:revit';
|
|
1063
|
+
mountSidePanel({ panel: $('inspectorPanel'), resizer: $('inspectorResizer'), toggle: $('inspectorToggle'), root: $('editorRoot'), doc: document, win: window, widthKey: `${storagePrefix}:inspector-width`, collapsedKey: `${storagePrefix}:inspector-collapsed`, label: (collapsed) => (collapsed ? 'Expand Properties' : 'Collapse Properties') });
|
|
661
1064
|
modelPanelBridge = createModelPanelBridge({
|
|
662
1065
|
win: window, origin: location.origin, snapshot: modelPanelSnapshot, selectedId: () => selectedId, selectedIds: () => [...selectedIds],
|
|
1066
|
+
selectionState: () => isTeklaParser ? { focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds] } : {},
|
|
663
1067
|
// ids: what a list click selects (Ctrl/Shift can make it several, or none). The Properties panel shows the row clicked
|
|
664
1068
|
// when it stays selected, else the last one; the viewport shows them all.
|
|
665
1069
|
select: (id, ids = [id]) => {
|
|
1070
|
+
if (isTeklaParser) return selectTeklaObjects(id, ids);
|
|
666
1071
|
if (!ids.every((each) => entityById.has(each))) return false;
|
|
667
1072
|
selectedIds = [...ids]; if (ids.length) clipSession?.clearSelection?.();
|
|
668
1073
|
selectionOriginGuard.run(() => viewport.setSelection({ ids }));
|
|
669
1074
|
return inspect(ids.includes(id) ? id : (ids.at(-1) ?? null), false, false, 'tree');
|
|
670
1075
|
},
|
|
671
|
-
expand: (groupId) => expandModelPanelGroup(
|
|
1076
|
+
expand: (groupId) => expandModelPanelGroup(modelExplorerTabs, $, groupId),
|
|
1077
|
+
selectGroup: (groupId) => isTeklaParser && selectModelPanelGroup(modelExplorerTabs, $, groupId),
|
|
1078
|
+
search: (tab, query) => renderExplorerSearch(tab, query, selectedIds.length === 1 ? selectedIds[0] : null),
|
|
1079
|
+
gridVisibility: ({ levelKey, visible }) => {
|
|
1080
|
+
const levels = viewport?.gridLevels?.() || [];
|
|
1081
|
+
if (!levels.length || (levelKey !== null && !levels.some((level) => String(level.key) === levelKey))) return false;
|
|
1082
|
+
const hidden = levelKey === null
|
|
1083
|
+
? (visible ? [] : levels.map((level) => level.mm))
|
|
1084
|
+
: levels.filter((level) => String(level.key) === levelKey ? !visible : !level.visible).map((level) => level.mm);
|
|
1085
|
+
viewport.setGridHiddenLevels(hidden);
|
|
1086
|
+
syncGridVisibilityAction(); reflectToolbarState();
|
|
1087
|
+
return true;
|
|
1088
|
+
},
|
|
672
1089
|
panel: (tab) => tab === null || revitPanelHost.show(tab),
|
|
673
1090
|
});
|
|
674
1091
|
}
|
|
@@ -687,8 +1104,19 @@ function mountSharedModelTools() {
|
|
|
687
1104
|
own(() => orientation.destroy());
|
|
688
1105
|
const nextMeasureTool = mountModelMeasureTool({
|
|
689
1106
|
surface: $('modelCanvas'), host: $('modelDimensionOverlay'), viewport,
|
|
1107
|
+
formatDistance: (mm) => displayUnitControl.length(mm),
|
|
690
1108
|
snapIndex: () => viewport.snapIndex(),
|
|
691
|
-
onState(state) {
|
|
1109
|
+
onState(state) {
|
|
1110
|
+
for (const listener of measureListeners) listener(state);
|
|
1111
|
+
for (const listener of snapListeners) listener(state.snapModes);
|
|
1112
|
+
const previous = window.__revitInstructorState || {};
|
|
1113
|
+
const armed = state.armed ? `${commandPrefix}.measure` : null;
|
|
1114
|
+
const step = state.armed ? state.step - 1 : null;
|
|
1115
|
+
if (previous.armed !== armed || previous.step !== step) {
|
|
1116
|
+
window.__revitInstructorState = { ...previous, armed, step };
|
|
1117
|
+
window.__instructor?.notifyChanged();
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
692
1120
|
});
|
|
693
1121
|
const destroyMeasure = own(() => nextMeasureTool.destroy());
|
|
694
1122
|
const nextCadTools = createModelCadToolController({ provider: {
|
|
@@ -729,7 +1157,7 @@ function mountSharedModelTools() {
|
|
|
729
1157
|
const subscribe = (set) => (listener) => { set.add(listener); let live = true; return () => { if (live) { live = false; set.delete(listener); } }; };
|
|
730
1158
|
const dock = mountModelPointerDock({
|
|
731
1159
|
selectionHost: $('modelSelectBar'), snapHost: $('modelSnapBar'), actionsHost: $('modelModuleActions'),
|
|
732
|
-
plan: REVIT_POINTER_DOCK_PLAN,
|
|
1160
|
+
plan: isTeklaParser ? readOnlyModelPointerDockPlan(commandPrefix, 'Tekla') : REVIT_POINTER_DOCK_PLAN,
|
|
733
1161
|
ports: {
|
|
734
1162
|
selection: nextSelectionFilterChrome?.port,
|
|
735
1163
|
snap: {
|
|
@@ -753,13 +1181,34 @@ function mountSharedModelTools() {
|
|
|
753
1181
|
function authorityButtons(state) {
|
|
754
1182
|
const host = $('authorityChoices'); host.replaceChildren(); const available = ['draft', 'approved'].filter((key) => state[key]); const initial = revitInitialAuthority(state);
|
|
755
1183
|
window.__revitInstructorState = { ...(window.__revitInstructorState || {}), authority: initial };
|
|
756
|
-
for (const key of available) { const button = document.createElement('button'); button.type = 'button'; button.dataset.commandId =
|
|
1184
|
+
for (const key of available) { const button = document.createElement('button'); button.type = 'button'; button.dataset.commandId = `${commandPrefix}.authority`; button.dataset.commandInstanceLabel = key; button.textContent = key === 'draft' ? (isTeklaParser ? 'Working snapshot' : 'Working model') : (isTeklaParser ? 'Approved snapshot' : 'Approved model'); button.setAttribute('aria-pressed', String(key === initial)); button.addEventListener('click', async () => {
|
|
1185
|
+
if (button.getAttribute('aria-pressed') === 'true' || host.getAttribute('aria-busy') === 'true') return;
|
|
1186
|
+
let candidate = null; host.setAttribute('aria-busy', 'true'); host.querySelectorAll('button').forEach((item) => { item.disabled = true; });
|
|
1187
|
+
try {
|
|
1188
|
+
candidate = await prepareSpatialForRevision(state, state[key]);
|
|
1189
|
+
if (!await loadRevision(state, key, candidate)) return;
|
|
1190
|
+
host.querySelectorAll('button').forEach((item) => item.setAttribute('aria-pressed', String(item === button)));
|
|
1191
|
+
window.__revitInstructorState = { ...(window.__revitInstructorState || {}), authority: key }; window.__instructor?.notifyChanged();
|
|
1192
|
+
} catch (error) {
|
|
1193
|
+
const current = host.querySelector('[aria-pressed="true"]')?.textContent || 'The current model';
|
|
1194
|
+
console.error(error);
|
|
1195
|
+
const check = isTeklaParser ? 'open Source and check the read' : 'open Source and check the import';
|
|
1196
|
+
toast(`Couldn’t open ${button.textContent}. ${current} is still shown. Try again. If it still won’t open, ${check}.`, 8000);
|
|
1197
|
+
} finally {
|
|
1198
|
+
candidate?.dispose(); host.removeAttribute('aria-busy'); host.querySelectorAll('button').forEach((item) => { item.disabled = false; });
|
|
1199
|
+
}
|
|
1200
|
+
}); host.append(button); }
|
|
757
1201
|
return initial;
|
|
758
1202
|
}
|
|
759
1203
|
|
|
1204
|
+
function renderCursorCoordinates() {
|
|
1205
|
+
if (!displayUnitControl) return;
|
|
1206
|
+
$('modelCursorCoordinates').textContent = ['X', 'Y', 'Z'].map((axis, index) => `${axis} ${lastCursorCoordinates ? displayUnitControl.length(lastCursorCoordinates[index]) : '—'}`).join(' · ');
|
|
1207
|
+
}
|
|
1208
|
+
|
|
760
1209
|
async function boot() {
|
|
761
1210
|
// Refuse an invalid direct-open before creating any of the three WebGL contexts (provider + chrome).
|
|
762
|
-
if (!projectId) throw new Error(
|
|
1211
|
+
if (!projectId) throw new Error(`Open this viewer from a ${modelProduct} project workspace.`);
|
|
763
1212
|
modelShellMount = mountModelEditorShell({
|
|
764
1213
|
root: $('editorRoot'), viewport: $('modelStage'), surface: $('modelCanvas'), toolbar: $('m3dBar'),
|
|
765
1214
|
orientation: $('modelViewCube'), axes: $('modelWorldAxes'), explorer: $('modelExplorer'),
|
|
@@ -769,42 +1218,69 @@ async function boot() {
|
|
|
769
1218
|
// Read the project before creating any WebGL context: a project with no revision yet (its RVT is
|
|
770
1219
|
// importing, stopped importing, or was never added) is an ordinary state with nothing to render.
|
|
771
1220
|
await json('/api/editor/session', { method: 'POST' });
|
|
772
|
-
const state = (await json(
|
|
1221
|
+
const state = (await json(`${editorProjectRoute}/${encodeURIComponent(projectId)}`)).state;
|
|
773
1222
|
$('modelName').textContent = state.projectName || projectId;
|
|
774
|
-
|
|
1223
|
+
const sourceFilename = state.source?.filename || state.pendingSource?.filename;
|
|
1224
|
+
$('sourceName').textContent = sourceFilename || (isTeklaParser ? '' : 'No RVT source');
|
|
1225
|
+
$('sourceName').hidden = isTeklaParser && !sourceFilename;
|
|
775
1226
|
if (!revitInitialAuthority(state)) {
|
|
776
|
-
const copy = revitNoModelCopy(state);
|
|
1227
|
+
const copy = isTeklaParser ? teklaNoSnapshotCopy(state) : revitNoModelCopy(state);
|
|
777
1228
|
// A published source with no revision behind it is not one of the ordinary states: stay loud.
|
|
778
|
-
if (!copy) throw new Error(
|
|
1229
|
+
if (!copy) throw new Error(isTeklaParser
|
|
1230
|
+
? 'This project lists a Tekla source, but no read-only snapshot was saved from it. Open the Source tab to check the import and choose the source again.'
|
|
1231
|
+
: 'This project lists an RVT file, but no model was saved from it, so there is nothing to open. On the Source tab, choose the RVT again to rebuild the model.');
|
|
779
1232
|
$('editorRoot').dataset.modelState = 'empty';
|
|
780
1233
|
renderRevitNoModelState($('loadingState'), copy);
|
|
781
1234
|
return;
|
|
782
1235
|
}
|
|
1236
|
+
displayUnitControl = mountModelDisplayUnits({ host: $('modelUnits'), doc: document, projectId, commandPrefix, request: json,
|
|
1237
|
+
onError: toast, onChange() {
|
|
1238
|
+
for (const refresh of propertyDisplayRefresh) refresh();
|
|
1239
|
+
measureTool?.refresh();
|
|
1240
|
+
spatialPanel?.refreshDisplay(); viewport?.refreshDisplay();
|
|
1241
|
+
modelPanelBridge?.publishSnapshot();
|
|
1242
|
+
renderCursorCoordinates();
|
|
1243
|
+
} });
|
|
1244
|
+
displayUnitEvents = new EventSource('/api/events');
|
|
1245
|
+
let unitsConnected = false;
|
|
1246
|
+
displayUnitEvents.onopen = () => { if (unitsConnected) displayUnitControl.reconnect(); unitsConnected = true; };
|
|
1247
|
+
displayUnitEvents.onerror = () => { unitsConnected = true; displayUnitControl.connectionLost(); };
|
|
1248
|
+
displayUnitEvents.onmessage = (event) => {
|
|
1249
|
+
let message; try { message = JSON.parse(event.data); } catch { return; }
|
|
1250
|
+
if (message.type === 'display-units-changed' && message.project === projectId) displayUnitControl.adopt(message.displayUnits);
|
|
1251
|
+
};
|
|
1252
|
+
await displayUnitControl.load();
|
|
783
1253
|
mountPanels();
|
|
784
|
-
viewport = createRevitViewport({ canvas: $('modelCanvas'),
|
|
1254
|
+
viewport = createRevitViewport({ canvas: $('modelCanvas'), formatDistance: (mm) => displayUnitControl.length(mm), includeHiddenSelectionBounds: isTeklaParser,
|
|
785
1255
|
// A big model takes a few seconds to convert, and the first moment shows nothing happening
|
|
786
1256
|
// yet. After that the parts converting one by one are their own progress indicator.
|
|
787
1257
|
onOutlineBuild: () => toast('Building the wireframe… large models take a few seconds.'),
|
|
788
1258
|
onSelect: (ids) => {
|
|
789
1259
|
if (selectionOriginGuard.isProgrammatic()) return;
|
|
790
|
-
selectedIds = [...ids]; if (ids.length) clipSession?.clearSelection?.();
|
|
1260
|
+
selectedIds = [...ids]; geometrySelectionIds = [...ids]; if (ids.length) clipSession?.clearSelection?.();
|
|
1261
|
+
if (isTeklaParser && ids.length === 1) {
|
|
1262
|
+
renderExplorerSearch('type', modelSearchQueries.get('type') || '', ids[0]);
|
|
1263
|
+
modelPanelBridge?.publishSnapshot();
|
|
1264
|
+
}
|
|
791
1265
|
inspect(ids.at(-1) || null, false, true, 'viewport');
|
|
792
1266
|
} });
|
|
793
|
-
facade =
|
|
1267
|
+
facade = createReadOnlyModelEditorAdapter({ viewport, host: { openSavedViews } }); toolbarChrome = wireToolbar();
|
|
794
1268
|
window.__revitEditorTest = { dispatchLog: () => facade.dispatchLog(), selected: () => selectedId, entityCount: () => entities.length,
|
|
1269
|
+
selectionState: () => ({ focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds] }),
|
|
795
1270
|
selectionCapabilities: () => selectionTools?.capabilities() ?? null, spatialState: () => spatialTools?.state() ?? null,
|
|
796
1271
|
editorState: () => facade.getState(), presentation: () => viewport.presentationProbe(),
|
|
797
|
-
lighting: () => facade.lightingState(),
|
|
1272
|
+
lighting: () => facade.lightingState(), gridLevels: () => viewport.gridLevels(),
|
|
798
1273
|
// Wireframe must be probed on the DRAWN outline, never the hidden fill: the fill carries state in
|
|
799
1274
|
// every mode, so reading it reports a picture the user is not looking at.
|
|
800
1275
|
outline: () => viewport.outlineState?.() ?? null,
|
|
801
1276
|
realistic: () => viewport.realisticState?.() ?? null };
|
|
802
|
-
projectContract = await json(
|
|
803
|
-
const authority = authorityButtons(state);
|
|
1277
|
+
projectContract = await json(`${contractRoute}?project=${encodeURIComponent(projectId)}&quietMissing=1`);
|
|
1278
|
+
const authority = authorityButtons(state); const initialSpatial = await prepareSpatialForRevision(state, state[authority]);
|
|
1279
|
+
try { await loadRevision(state, authority, initialSpatial); } finally { initialSpatial.dispose(); }
|
|
1280
|
+
mountSharedModelTools();
|
|
804
1281
|
const releasePointerCoordinates = viewport.onPointerWorld((renderPoint) => {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
$('modelCursorCoordinates').textContent = `X ${coords[0].toFixed(1)} · Y ${coords[1].toFixed(1)} · Z ${coords[2].toFixed(1)} mm`;
|
|
1282
|
+
lastCursorCoordinates = renderPoint && spatialTools ? spatialTools.coordinates(viewport.renderToCanonicalPoint(renderPoint)) : null;
|
|
1283
|
+
renderCursorCoordinates();
|
|
808
1284
|
});
|
|
809
1285
|
window.addEventListener('pagehide', releasePointerCoordinates, { once: true });
|
|
810
1286
|
}
|
|
@@ -812,6 +1288,8 @@ async function boot() {
|
|
|
812
1288
|
function disposeEditor() {
|
|
813
1289
|
if (terminalDisposed) return;
|
|
814
1290
|
terminalDisposed = true; bfcacheSuspended = false;
|
|
1291
|
+
displayUnitEvents?.close(); displayUnitControl?.destroy(); propertyDisplayRefresh.clear();
|
|
1292
|
+
toolbarChrome?.destroy(); toolbarChrome = null;
|
|
815
1293
|
revisionLoadController?.abort(); revisionLoadController = null; revisionLoadToken += 1;
|
|
816
1294
|
sharedTools?.destroy(); sharedTools = null;
|
|
817
1295
|
modelPanelBridge?.dispose(); modelPanelBridge = null;
|
|
@@ -845,9 +1323,9 @@ installTooltips(document);
|
|
|
845
1323
|
boot().catch((error) => {
|
|
846
1324
|
if (terminalDisposed) return;
|
|
847
1325
|
console.error(error);
|
|
848
|
-
modelPanelBridge?.failed(
|
|
1326
|
+
modelPanelBridge?.failed(modelUnavailableCopy());
|
|
849
1327
|
// A failed session fetch, project read, or first revision load is terminal for this editor instance.
|
|
850
1328
|
// Release the provider renderer and both shared mini-renderers instead of waiting for page navigation.
|
|
851
1329
|
disposeEditor();
|
|
852
|
-
fail(
|
|
1330
|
+
fail();
|
|
853
1331
|
});
|