@floless/app 0.111.2 → 0.111.3
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 +7175 -6314
- package/dist/schemas/steel.model.v2.schema.json +12 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +40 -4
- package/dist/web/aware.js +18 -0
- package/dist/web/grid-core.js +41 -16
- package/dist/web/renderers.js +11 -0
- package/dist/web/steel-3d-view.js +79 -36
- package/dist/web/steel-editor.html +677 -114
- package/package.json +1 -1
|
@@ -21,6 +21,19 @@
|
|
|
21
21
|
.seg-group button{border:0;border-radius:0;border-right:1px solid #475569}
|
|
22
22
|
.seg-group button:last-child{border-right:0}
|
|
23
23
|
#m3dDimAxis button{min-width:5.2em;white-space:nowrap;text-align:center} /* UCS Stage 5: min-width holds the longest label ("World X") so relabeling X→X′→World X across frame states keeps every segment — and the group's total width — constant (no header-cluster jitter) */
|
|
24
|
+
/* The read-only ribbon (unit 5, P7d). IN FLOW under the header, not in the fixed-bottom banner slot —
|
|
25
|
+
that slot is already claimed by transient event banners and #zoombar, and a persistent state note
|
|
26
|
+
parked there would either fight them or be covered. Existing quiet tokens only: no new colour, no new
|
|
27
|
+
font, and no bespoke "read-only" skin (button:disabled{opacity:.4} is already this app's "not now"). */
|
|
28
|
+
#roRibbon{display:none;align-items:center;gap:8px;padding:7px 14px;background:var(--panel);border-bottom:1px solid var(--line);color:var(--mut);font-size:12px}
|
|
29
|
+
body.model-ro #roRibbon{display:flex}
|
|
30
|
+
#roRibbon b{color:var(--text);font-weight:600}
|
|
31
|
+
/* The 2D empty state. SCOPED to #stage — deliberately not showEmpty(), which does
|
|
32
|
+
document.body.replaceChildren and would blank the header and the Grid panel with it. */
|
|
33
|
+
#ro2d{position:absolute;inset:0;display:none;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:24px;text-align:center;color:var(--mut);pointer-events:none}
|
|
34
|
+
body.model-ro:not(.v3d) #ro2d{display:flex}
|
|
35
|
+
#ro2d b{color:var(--text);font-size:14px}
|
|
36
|
+
#ro2d p{margin:0;max-width:44ch;line-height:1.5}
|
|
24
37
|
main{flex:1;display:flex;min-height:0}
|
|
25
38
|
#stagewrap{flex:1;position:relative;min-width:0;display:flex}
|
|
26
39
|
#stage{flex:1;overflow:auto;background:#0b1220;display:flex;align-items:safe center;justify-content:safe center}
|
|
@@ -807,7 +820,10 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
807
820
|
<b>Steel Model</b>
|
|
808
821
|
<div id=viewToggle role=group aria-label="Canvas view"><button id=vt2d class="seg on" aria-pressed=true data-tip="Plan view (2D overlay)">2D</button><button id=vt3d class=seg aria-pressed=false data-tip="3D model view">3D</button></div>
|
|
809
822
|
<select id=planSel data-tip="Switch plan view"></select>
|
|
810
|
-
|
|
823
|
+
<!-- These four are per-SHEET counts (see stats()). A model in the canonical format has no per-sheet
|
|
824
|
+
members, so for it they are HIDDEN rather than dimmed — a readout that is wrong is worse than one
|
|
825
|
+
that is absent, and "Members 0" beside a populated 3D scene is wrong (unit 5, P7d §8.5). -->
|
|
826
|
+
<span class=stat id=mcStat>Members <b id=mc>0</b></span><span class=stat id=wtStat>Weight <b id=wt>0</b> tons · <b id=wtlb>0</b> lb</span>
|
|
811
827
|
<span class=stat id=rfiStat data-tip="Click to list members with an unresolved size (RFI — Request for Information)">RFI <b id=rc>0</b></span>
|
|
812
828
|
<span class=stat id=dupStat data-tip="Overlapping/duplicate members (same geometry)">Dup <b id=dpc>0</b></span>
|
|
813
829
|
<span class=stat id=csStat data-tip="Coordinate system — Global by default. Set a local frame from the ⋯ menu for skewed framing.">Axes <b>Global</b></span>
|
|
@@ -840,6 +856,10 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
840
856
|
<button id=dragMoveB role=menuitemcheckbox aria-checked=false data-tip="When ON, left-dragging a member moves it and Ctrl+drag copies it. When OFF (default), a drag does neither — a click only selects, so members can't be nudged by accident (the Move and Copy tools still work). Applies to 2D and 3D."><span class=mck aria-hidden=true></span>Drag to move/copy</button>
|
|
841
857
|
</div>
|
|
842
858
|
</div>
|
|
859
|
+
<!-- The one LIVE editor a read-only model has, brought up to the header (unit 5, P7d §8.5). Behind the ⋯
|
|
860
|
+
menu it sat three clicks deep under a section of grayed rows — the single thing you CAN do, hidden
|
|
861
|
+
among the things you cannot. Shown only in that mode; ⋯ → Display → Grid lines… stays for everyone. -->
|
|
862
|
+
<button id=gridHdrB style="display:none" data-tip="Grid lines — move the grid, rename its lines and levels, and choose which levels show.">Grid lines…</button>
|
|
843
863
|
<span class=tb-sep></span>
|
|
844
864
|
<button id=askAiBtn>Ask AI ▸</button>
|
|
845
865
|
<span class=tb-sep></span>
|
|
@@ -872,7 +892,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
872
892
|
<button id=gridEditB data-tip="Grid lines — a plan reference with structural bay spacings (n*d repeats a bay). Shows in 2D and 3D; drawing and drags snap to its lines and intersections.">Grid lines…</button>
|
|
873
893
|
<button id=dimStyleB data-tip="Dimension style — end marks, label position and label background. Sets the defaults every dimension follows unless you give it its own style.">Dimension style…</button>
|
|
874
894
|
</div>
|
|
875
|
-
<button class=msec-hdr data-sec=detailing aria-expanded=false data-tip="Connection details, plates, frames, and inserted detail images">Detailing<span class=chev aria-hidden=true>▸</span></button>
|
|
895
|
+
<button id=secDetailingHdr class=msec-hdr data-sec=detailing aria-expanded=false data-tip="Connection details, plates, frames, and inserted detail images">Detailing<span class=chev aria-hidden=true>▸</span></button>
|
|
876
896
|
<div class=msec-body>
|
|
877
897
|
<button id=detailsBtn>Details</button>
|
|
878
898
|
<button id=connBtn data-tip="A lookup table of connection types (moment, shear, pinned, …). Each maps to a design detail and, per platform, a component ID; reference a row from each member end.">Connections</button>
|
|
@@ -886,7 +906,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
886
906
|
<button id=spBtn data-tip="Auto-detail bolted shear (fin) plates on eligible beam ends (a fin plate + bolt group + weld, shown in 3D). Tune sizes per the schedule via the AI or per-end params.">Shear plates</button>
|
|
887
907
|
<button id=framesBtn>Frames</button>
|
|
888
908
|
</div>
|
|
889
|
-
<button class=msec-hdr data-sec=checks aria-expanded=false data-tip="Find and fix modelling problems">Model checks<span class=chev aria-hidden=true>▸</span></button>
|
|
909
|
+
<button id=secChecksHdr class=msec-hdr data-sec=checks aria-expanded=false data-tip="Find and fix modelling problems">Model checks<span class=chev aria-hidden=true>▸</span></button>
|
|
890
910
|
<div class=msec-body>
|
|
891
911
|
<button id=dupB data-tip="Selects overlapping members drawn twice by mistake — review, then press Delete to remove the extra one.">Duplicates</button>
|
|
892
912
|
<button id=revB data-tip="Select beams drawn the wrong way — a mostly-horizontal beam should run left→right, a steep/skew beam bottom→up. Review, then press P to swap their direction.">Reversed beams</button>
|
|
@@ -915,9 +935,24 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
915
935
|
</div>
|
|
916
936
|
</div>
|
|
917
937
|
</header>
|
|
938
|
+
<!-- The read-only state, said once, in flow (unit 5, P7d). Every disabled control below points its
|
|
939
|
+
aria-describedby here rather than repeating the reason: a tooltip per dimmed control is noise, and
|
|
940
|
+
data-tip is hover-driven so it never reaches a keyboard or screen-reader user at all. -->
|
|
941
|
+
<div id=roRibbon>
|
|
942
|
+
<b>Read-only</b>
|
|
943
|
+
<span>This model is saved in FloLess’s canonical format. You can look around it in 3D, edit its grid, and export it — editing members, connections and dimensions here is still catching up. Ask your terminal AI to change the model.</span>
|
|
944
|
+
</div>
|
|
918
945
|
<main>
|
|
919
946
|
<div id=stagewrap>
|
|
920
947
|
<div id=stage><svg id=svg></svg></div>
|
|
948
|
+
<!-- The 2D empty state for a canonical model. Its members are world-mm and model-level, and the sheet
|
|
949
|
+
registration that would put them back into this sheet's pixels is computed at migration and never
|
|
950
|
+
persisted — so there is nothing honest to draw here, and a plausible plan in the wrong place is the
|
|
951
|
+
worst defect this editor can ship. Scoped to #stagewrap, NOT showEmpty(). -->
|
|
952
|
+
<div id=ro2d>
|
|
953
|
+
<b>The plan view isn’t available for this model</b>
|
|
954
|
+
<p>This model is one coherent 3D model rather than a stack of sheets, so there is no drawing to trace on. Switch to <b>3D</b> to see all of it.</p>
|
|
955
|
+
</div>
|
|
921
956
|
<canvas id=stage3d tabindex=0 aria-label="3D model"></canvas>
|
|
922
957
|
<div id=connCrumb role=navigation aria-label="Connection breadcrumb"></div>
|
|
923
958
|
<div id=m3dBar role=group aria-label="3D view controls">
|
|
@@ -1167,10 +1202,35 @@ const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
|
|
|
1167
1202
|
// own validator says so and falls back to exactly this (contract-schema.ts, validateContract), so
|
|
1168
1203
|
// diverging here would refuse documents this app itself wrote.
|
|
1169
1204
|
const EDITOR_TYPE = 'steel.takeoff/v1';
|
|
1205
|
+
// The canonical model format (unit 5). A migrated project holds this instead of EDITOR_TYPE, and P7d makes
|
|
1206
|
+
// it OPENABLE here — for viewing, plus the model grid. Everything else about it is refused.
|
|
1207
|
+
const MODEL_V2_TYPE = 'steel.model/v2';
|
|
1208
|
+
// Every type this page will open. A type NOT in here is refused before anything mutates the document; the
|
|
1209
|
+
// refusal copy below still tells a newer STEEL model apart from "you opened the wrong workflow".
|
|
1210
|
+
const OPENABLE_TYPES = [EDITOR_TYPE, MODEL_V2_TYPE];
|
|
1170
1211
|
// The type the draft key is built from. Captured ONCE, right after boot() validates it, and never re-read
|
|
1171
1212
|
// from `C` afterwards: `C` is mutable, and a key that can change identity mid-session would orphan the
|
|
1172
1213
|
// draft it was writing (persist and restoreSaved would address different rows).
|
|
1173
1214
|
let DRAFT_TYPE = EDITOR_TYPE;
|
|
1215
|
+
/**
|
|
1216
|
+
* Is the open document READ-ONLY to this editor? (unit 5, P7d)
|
|
1217
|
+
*
|
|
1218
|
+
* True for `steel.model/v2`. Pinned ONCE, from the type boot() validated, for the same reason DRAFT_TYPE is
|
|
1219
|
+
* — a mode that can change identity mid-session is a mode that guards nothing.
|
|
1220
|
+
*
|
|
1221
|
+
* READ-ONLY IS ENFORCED HERE, NOT BY DISABLED BUTTONS. Disabled controls are the UX; they are not the
|
|
1222
|
+
* enforcement, and the leak that matters is upstream of any user action. v2's `plan` schema is
|
|
1223
|
+
* `additionalProperties:false` and forbids `members`, `grid` and `default_tos` — all three of which the
|
|
1224
|
+
* editor's own boot normalisation writes. So a v2 document opened without this gate is CORRUPTED before the
|
|
1225
|
+
* user has done anything, and the corruption only surfaces later, as a save the server refuses for edits
|
|
1226
|
+
* they never made. See docs/superpowers/specs/2026-07-26-steel-v2-p7d-design.md §8.4.
|
|
1227
|
+
*
|
|
1228
|
+
* "Read-only" is precise: it means read-only to the MODEL. The model grid is a separate, deliberate
|
|
1229
|
+
* exception (§8.2) and takes its own path — it is not smuggled through here.
|
|
1230
|
+
*/
|
|
1231
|
+
let MODEL_RO = false;
|
|
1232
|
+
/** Ask before any model write. One name, so a new write site refuses by default rather than by remembering. */
|
|
1233
|
+
function canWriteModel() { return !MODEL_RO; }
|
|
1174
1234
|
/**
|
|
1175
1235
|
* Where this browser's unsaved edits live.
|
|
1176
1236
|
*
|
|
@@ -1427,13 +1487,14 @@ async function boot() {
|
|
|
1427
1487
|
return;
|
|
1428
1488
|
}
|
|
1429
1489
|
const loadedType = loaded.type;
|
|
1430
|
-
// A missing type is legacy steel v1 (see EDITOR_TYPE). Anything
|
|
1431
|
-
// the normalisation below starts mutating the document and before main() runs restoreSaved()
|
|
1432
|
-
// would otherwise overlay a steel draft onto a document of a different type entirely.
|
|
1433
|
-
if (loadedType != null && loadedType
|
|
1434
|
-
// Two different situations, and one message for both would be false in one of them. A
|
|
1435
|
-
// IS a Steel Model — just a
|
|
1436
|
-
// not a Steel Model" would be plainly wrong. Anything else means they opened the wrong
|
|
1490
|
+
// A missing type is legacy steel v1 (see EDITOR_TYPE). Anything OPENABLE_TYPES does not name is refused
|
|
1491
|
+
// HERE, before the normalisation below starts mutating the document and before main() runs restoreSaved()
|
|
1492
|
+
// — which would otherwise overlay a steel draft onto a document of a different type entirely.
|
|
1493
|
+
if (loadedType != null && !OPENABLE_TYPES.includes(loadedType)) {
|
|
1494
|
+
// Two different situations, and one message for both would be false in one of them. A newer
|
|
1495
|
+
// steel.model/* IS a Steel Model — just a format this build cannot draw yet — so telling that user
|
|
1496
|
+
// "this is not a Steel Model" would be plainly wrong. Anything else means they opened the wrong
|
|
1497
|
+
// workflow. (steel.model/v2 itself now OPENS; this branch is what a v3 would land in.)
|
|
1437
1498
|
const newerSteel = /^steel\.model\//.test(String(loadedType));
|
|
1438
1499
|
showEmpty('⊞',
|
|
1439
1500
|
newerSteel ? 'This Steel Model isn’t supported yet —' : 'Not a Steel Model —',
|
|
@@ -1447,6 +1508,7 @@ async function boot() {
|
|
|
1447
1508
|
// Pin the draft identity for the rest of the session. Read once, from the validated value, never from
|
|
1448
1509
|
// the mutable `C` — see draftKey().
|
|
1449
1510
|
DRAFT_TYPE = loadedType == null ? EDITOR_TYPE : loadedType;
|
|
1511
|
+
MODEL_RO = DRAFT_TYPE === MODEL_V2_TYPE; // …and the write mode, from the same validated value, before anything mutates
|
|
1450
1512
|
sweepOrphanDrafts(); // now that the identity is pinned, retire rows keyed by an older one
|
|
1451
1513
|
C = loaded;
|
|
1452
1514
|
// The server's tag for the contract we just read. Every write echoes it back, so a write that would
|
|
@@ -1612,7 +1674,27 @@ function showAiUpdateBanner(message, opts) {
|
|
|
1612
1674
|
}
|
|
1613
1675
|
|
|
1614
1676
|
function main() {
|
|
1615
|
-
|
|
1677
|
+
/*
|
|
1678
|
+
* V1'S BOOT-TIME REPAIR PASS IS SKIPPED FOR A READ-ONLY v2 DOCUMENT (unit 5, P7d).
|
|
1679
|
+
*
|
|
1680
|
+
* Four sanitisers run over the contract's model-global display state as main() defines them — this one,
|
|
1681
|
+
* sanitizeDimStyle(), sanitizePropLabels() and sanitizeViews() (plus sanitizeDims3d). Each exists because a
|
|
1682
|
+
* v1 contract is only loosely validated: v1's schema is `additionalProperties: true` for `prop_labels` and
|
|
1683
|
+
* for every `views[]` entry, so the editor has to clamp what it finds before drawing it.
|
|
1684
|
+
*
|
|
1685
|
+
* v2's schema CLOSED both of those. Running v1's repair pass over a v2 document therefore does exactly the
|
|
1686
|
+
* wrong thing in both directions, and it is not theoretical — it is what the schema check measured:
|
|
1687
|
+
* - it ADDS keys v2 forbids: `prop_labels.vis2d`/`vis3d` (v1's per-view label visibility) and
|
|
1688
|
+
* `views[].projection` (v2 keeps the projection inside `camera.proj`);
|
|
1689
|
+
* - it DROPS a key v2 requires: `views[].generated.axisId`, because v1's generated-view provenance is
|
|
1690
|
+
* keyed by label and elevation, and a canonical grid is referenced by stable axis id instead.
|
|
1691
|
+
* The second is data loss, and both land before the user has done anything — so the first save is refused
|
|
1692
|
+
* for edits they never made, which is the whole failure §8.4 exists to prevent.
|
|
1693
|
+
*
|
|
1694
|
+
* A v2 document does not need the pass: it arrives SERVER-VALIDATED (P7b validates schema plus referential
|
|
1695
|
+
* integrity on every PUT), which is a stronger guarantee than any of these clamps.
|
|
1696
|
+
*/
|
|
1697
|
+
if(canWriteModel())C.member_styles=sanitizeMemberStyles(C.member_styles); // F5: clamp the loaded contract's line styles to valid tokens + normalised keys (a hand-edited contract isn't schema-validated; the localStorage draft is separately sanitised in restoreSaved())
|
|
1616
1698
|
let P, X0,Y0,X1,Y1, FT, RB64, EXTX, EXTY, profs; // per-plan, set by setPlan()
|
|
1617
1699
|
let mode='sel', drag=null, picking=false, pickKind='profile', pickEnd=null, geoMode=null;
|
|
1618
1700
|
let dimMode=false, dimDraft=null, dimAxis='free', selDimIds=new Set(), dimsVisible=true; // Dimension tool: armed flag, in-progress {a,b,axis}, sticky axis, selected dim ids (multi-select), show/hide
|
|
@@ -1638,8 +1720,17 @@ let undo=[], redo=[];
|
|
|
1638
1720
|
// the whole selection — else selecting a roof (S-203) member while S-202 is active shows nothing, and a
|
|
1639
1721
|
// cross-floor Ctrl-click or box-select drops the off-sheet members. (Earlier this SWITCHED the active plan
|
|
1640
1722
|
// per pick, which cleared the accumulating selection — the bug this replaces.)
|
|
1641
|
-
|
|
1642
|
-
|
|
1723
|
+
// WHERE THE MEMBERS ARE, and it is not the same place in both formats (unit 5, P7d). v1 keeps one list per
|
|
1724
|
+
// sheet; v2 keeps ONE at the document root — `members` is not a plan property at all, so walking
|
|
1725
|
+
// `C.plans[].members` answers EMPTY for a populated model, silently. That silent empty is what puts an
|
|
1726
|
+
// unusable Send-to-Tekla and an empty Inspector beside a full 3D scene, so both resolve model-wide.
|
|
1727
|
+
//
|
|
1728
|
+
// A v2 record has a different SHAPE (world-mm `from`/`to`, no `wp`/`col`/`ends`), and that is safe here
|
|
1729
|
+
// because every consumer that reads those fields is a WRITE path, and every write is refused for v2. The
|
|
1730
|
+
// consumers that survive — selection, id lookup, the export id list — read `id` and hand the record to
|
|
1731
|
+
// `model().geometryOf`, which knows both shapes.
|
|
1732
|
+
const allMembers=()=>MODEL_RO?modelMembersV2():C.plans.flatMap(p=>p.members||[]);
|
|
1733
|
+
const byId=id=>{if(MODEL_RO)return modelMembersV2().find(m=>m&&m.id===id);for(const p of C.plans){const m=(p.members||[]).find(x=>x.id===id);if(m)return m;}return undefined;};
|
|
1643
1734
|
const planeOf=id=>{for(const p of C.plans)if((p.members||[]).some(m=>m.id===id))return p;return P;}; // the plane that owns a member id (for cross-sheet move/copy targeting); falls back to the active plane
|
|
1644
1735
|
const planeOfMember=m=>{for(const p of C.plans)if((p.members||[]).includes(m))return p;return null;}; // F9: owning plane by OBJECT IDENTITY (member ids are only sheet-unique — id lookup could hit the wrong sheet on a collision; Codex code-review #1)
|
|
1645
1736
|
const selArr=()=>allMembers().filter(m=>selIds.has(m.id));
|
|
@@ -1876,7 +1967,12 @@ const autofillTOS=syncDefaults;
|
|
|
1876
1967
|
// select/delete/undo — a reader-side id-uniqueness hardening. dims3d rides its own persistence.
|
|
1877
1968
|
// dim_style (the model-global dimension-style defaults) rides every entry like details/member_types: one
|
|
1878
1969
|
// chronological stack means an undo simply walks the whole model back, so there is no cross-sheet clobber.
|
|
1879
|
-
|
|
1970
|
+
// `modelGrid` is the MODEL-LEVEL grid (unit 5, P7d). v1 has none and the key is absent, which is what
|
|
1971
|
+
// apply() keys off — `null` would be indistinguishable from "this document has a model grid and it was
|
|
1972
|
+
// removed". Undo is not free here and this is the whole reason: the per-sheet capture below is blind to a
|
|
1973
|
+
// grid that does not live on a sheet, so without this line every grid edit on a v2 document would be
|
|
1974
|
+
// unundoable — silently, since Ctrl+Z would restore the sheets and report success.
|
|
1975
|
+
function snapshot(){return JSON.stringify(Object.assign(MODEL_RO?{modelGrid:C.grid||null}:{},{planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],connections:Array.isArray(C.connections)?C.connections:null,clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}}));} // members/dims/frame/grid are all PER-SHEET → captured per sheet so a cross-sheet undo restores each sheet's OWN dims/frame/grid, never the active sheet's over another's. clips/work area are view-state riding the undo stack; details/dim_style/connections = model-global, captured whole. connections is NOT per-plan sliced (unlike joints, keyed by a plan-local member id): the library is genuinely model-wide, referenced identically from every sheet.
|
|
1880
1976
|
// Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
|
|
1881
1977
|
// members, so one whole-model stack is coherent — undo restores all planes at once, and a cross-
|
|
1882
1978
|
// sheet edit/delete/to-level round-trips fully. (Earlier this was per-plane — `undo=P.undo` swapped
|
|
@@ -1887,8 +1983,26 @@ function snapshotLike(){return snapshot();}
|
|
|
1887
1983
|
function refreshDims3d(){if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();} // repaint the 3D dim lines/labels from C.dims3d
|
|
1888
1984
|
function refreshOverlayDims3d(){if(window.Steel3DView&&window.Steel3DView.refreshOverlayDims)window.Steel3DView.refreshOverlayDims();} // re-derive the legend DIMENSIONS overlays from C.dim_overlays
|
|
1889
1985
|
function pushUndo(prev){undo.push(prev);if(undo.length>200)undo.shift();redo.length=0;scheduleSave();}
|
|
1890
|
-
function apply(json){
|
|
1891
|
-
|
|
1986
|
+
function apply(json){
|
|
1987
|
+
// The undo stack's restore is the third write primitive (unit 5, P7d). Nothing pushes onto that stack while
|
|
1988
|
+
// the document is read-only — edit() refuses before pushUndo — so this is unreachable rather than merely
|
|
1989
|
+
// unused, and it is guarded for the same reason the other two are: an entry that arrives some other way
|
|
1990
|
+
// would write `P.members` and a per-plan `grid`, both of which v2's plan schema forbids.
|
|
1991
|
+
const d=JSON.parse(json);
|
|
1992
|
+
// THE MODEL-LEVEL GRID, restored first and on its own path (unit 5, P7d). The per-sheet restore below
|
|
1993
|
+
// cannot carry it — a v2 plan has no `grid` — so without this Ctrl+Z would walk every sheet back and
|
|
1994
|
+
// leave the grid edit standing, reporting success. Keyed on the KEY being present, not on its value:
|
|
1995
|
+
// `null` is a legitimate captured state (the grid was removed), and absence is "this document has no
|
|
1996
|
+
// model-level grid", which is every v1 document.
|
|
1997
|
+
if('modelGrid' in d){C.grid=d.modelGrid;refresh3DGrid();updGridToggle();}
|
|
1998
|
+
// The PER-SHEET restore is v1's, and a read-only document does not take it. Note this is a guard, not an
|
|
1999
|
+
// early return: everything AFTER this block — the selection cleanup, the abandoned drafts, the clip
|
|
2000
|
+
// state, scheduleSave/render/sync3D — must still run, or an undone grid edit would sit there unsaved and
|
|
2001
|
+
// unpainted. Unreachable rather than merely unused, since edit() refuses before pushUndo; guarded for
|
|
2002
|
+
// the same reason the other write primitives are, because an entry arriving some other way would write
|
|
2003
|
+
// `P.members` and a per-plan `grid`, both of which v2's plan schema forbids.
|
|
2004
|
+
if(canWriteModel()){
|
|
2005
|
+
if(Array.isArray(d))P.members=d; // legacy member-only snapshot — no longer produced (dedupe/all paths now push whole-model snapshot()); kept defensively for any in-flight entry
|
|
1892
2006
|
else if(Array.isArray(d.planes)){for(const o of d.planes){const tp=C.plans.find(p=>p.sheet===o.sheet);if(tp){tp.members=(o.members||[]).map(ensureMeta);if(Array.isArray(o.dims))tp.dims=o.dims;if('frame' in o)tp.frame=o.frame||null;if('grid' in o)tp.grid=o.grid;}else{console.error('undo: sheet '+o.sheet+' not found - slice skipped');toast('Undo couldn’t restore sheet '+o.sheet);}}if('joints' in d)C.joints=Array.isArray(d.joints)?d.joints:[];} // whole-model → restore EVERY sheet's OWN members/dims/frame/grid (cross-sheet undo restores each sheet's own, never the active sheet's over another's); joints captured whole
|
|
1893
2007
|
else{console.error('undo: legacy non-planes stack entry — no producer emits this any more; restoring members/joints only. dims/frame/grid are PER-SHEET in the planes format, so they are deliberately NOT written to the active plane here (that was the cross-sheet wrong-sheet footgun).');
|
|
1894
2008
|
const pmOld=new Set((P.members||[]).map(m=>m.id));P.members=d.members||[];
|
|
@@ -1912,6 +2026,7 @@ function apply(json){const d=JSON.parse(json);
|
|
|
1912
2026
|
// rides the undo stack, so it is this change's regression to close.
|
|
1913
2027
|
if(typeof connLibOpen==='function'&&connLibOpen())renderConnTable();}
|
|
1914
2028
|
if('dim_style' in d){C.dim_style=d.dim_style||{};sanitizeDimStyle();} // model-global dimension-style defaults ride the undo stack too (changing them repaints every non-overriding dim)
|
|
2029
|
+
} // end of the v1 per-sheet restore — see the guard above for why the rest still runs
|
|
1915
2030
|
updCS();
|
|
1916
2031
|
selIds=new Set([...selIds].filter(id=>byId(id)||/^det:/.test(id))); // keep a selected placed-detail id (det:…) — it isn't a member
|
|
1917
2032
|
selDimIds.forEach(id=>{if(!(P.dims||[]).some(x=>x.id===id))selDimIds.delete(id);}); // drop any dim selection the undo removed
|
|
@@ -1927,7 +2042,44 @@ function apply(json){const d=JSON.parse(json);
|
|
|
1927
2042
|
scheduleSave();render();sync3D();}
|
|
1928
2043
|
function doUndo(){if(!undo.length)return;redo.push(snapshotLike());apply(undo.pop());}
|
|
1929
2044
|
function doRedo(){if(!redo.length)return;undo.push(snapshotLike());apply(redo.pop());}
|
|
1930
|
-
|
|
2045
|
+
/**
|
|
2046
|
+
* The GRID transaction — the one model edit a read-only v2 document allows (unit 5, P7d §4).
|
|
2047
|
+
*
|
|
2048
|
+
* Named, not flagged at the call site, so the exemption is a small closed set that can be read in one place
|
|
2049
|
+
* instead of a boolean threaded through 148 `edit()` calls. Identical to `edit()` for v1.
|
|
2050
|
+
*/
|
|
2051
|
+
const GRID_EDIT={grid:true};
|
|
2052
|
+
function editGrid(fn){return edit(fn,GRID_EDIT);}
|
|
2053
|
+
/**
|
|
2054
|
+
* …and the half of the grid a v2 document does NOT get: a change to WHICH AXES EXIST (§8.2).
|
|
2055
|
+
*
|
|
2056
|
+
* v2's grid carries `axes[]` with STABLE IDS, and `steel-model-v2.ts` enforces that the declared axis count
|
|
2057
|
+
* per direction equals the count parsed from the spacing string. Those ids are identity, not decoration —
|
|
2058
|
+
* dimensions and generated views reference them. Migration minted them BY INDEX and the schema records that
|
|
2059
|
+
* from that point identity lives in the stored id, precisely because v1's index-based `gv:<i>` references
|
|
2060
|
+
* meant "an insert or re-space changed what a reference meant".
|
|
2061
|
+
*
|
|
2062
|
+
* So a re-space is an identity-MATCHING problem — which stored axis survived — with no inherent answer, the
|
|
2063
|
+
* same problem this epic already solved once at length for members. Re-minting on index would silently
|
|
2064
|
+
* rebind every dimension anchored to an axis, invisibly. It is refused for the HUMAN too, not only the AI,
|
|
2065
|
+
* and that is the point: a topology change that rebinds references goes through the reviewed path whoever
|
|
2066
|
+
* initiates it, which is the rule this epic applies everywhere else.
|
|
2067
|
+
*/
|
|
2068
|
+
function editGridTopology(fn){
|
|
2069
|
+
if(!canWriteModel()){toast('Re-spacing changes which grid lines exist, so it goes through a reviewed model update — ask your terminal AI to change the grid.');return;}
|
|
2070
|
+
return edit(fn,GRID_EDIT);}
|
|
2071
|
+
function edit(fn,opts){
|
|
2072
|
+
// READ-ONLY DOCUMENTS STOP HERE (unit 5, P7d). One refusal, at the transaction wrapper every model edit in
|
|
2073
|
+
// this page already funnels through, is worth more than the same condition repeated at 148 call sites — and
|
|
2074
|
+
// it means a write ADDED to this editor later is refused by default rather than by someone remembering to
|
|
2075
|
+
// gate it. The disabled controls are the UX; this is the enforcement.
|
|
2076
|
+
//
|
|
2077
|
+
// Silent, deliberately, and the reason is narrower than "unreachable": the paths that reach a MODEL edit
|
|
2078
|
+
// are disabled and labelled, so a toast here would fire for something the user could not have clicked —
|
|
2079
|
+
// while a refusal that DOES belong on screen (the grid re-space) has its own message at
|
|
2080
|
+
// editGridTopology. It is logged, because if one fires anyway that is a hole in the UI and the console
|
|
2081
|
+
// is where a triage starts. Codex's H12 was right that the first wording claimed more than it could.
|
|
2082
|
+
if(!canWriteModel()&&!(opts&&opts.grid)){console.warn('steel-editor: a model write was refused — this document is open read-only');return;}
|
|
1931
2083
|
// The stale-draft offer stops being safe the moment they build on the CURRENT version instead: clicking
|
|
1932
2084
|
// "View my edits instead" afterwards would overlay the old edits on top of this new work and discard it
|
|
1933
2085
|
// silently. Only that banner is dismissed — the AI-update and conflict bars MUST survive edits, which is
|
|
@@ -2197,7 +2349,15 @@ window.flushContract = async () => {
|
|
|
2197
2349
|
* edits instead" apply exactly the same fields. Two copies of this list would drift, and the failure would
|
|
2198
2350
|
* be silent: a field the button forgot would simply not come back, looking like it was never saved.
|
|
2199
2351
|
*/
|
|
2200
|
-
function applyDraftFields(d){
|
|
2352
|
+
function applyDraftFields(d){
|
|
2353
|
+
// The draft is V1-SHAPED, and overlaying it onto a read-only v2 document is one of the three leaks §8.4
|
|
2354
|
+
// names: the per-plan pass below writes `members`, `default_tos` and `grid`, all three of which v2's
|
|
2355
|
+
// plan schema forbids. Refused at the primitive rather than at each caller, so the automatic restore and
|
|
2356
|
+
// the "View my edits instead" button are covered by one guard. (When the model grid becomes writable it
|
|
2357
|
+
// needs a v2-shaped draft of its own — a ROOT `grid`, not a per-plan one; there is nothing to restore
|
|
2358
|
+
// until then, because every write is refused.)
|
|
2359
|
+
if(!canWriteModel()){console.warn('steel-editor: a local draft was not applied — this document is open read-only');return;}
|
|
2360
|
+
const by={};(d.plans||[]).forEach(p=>by[p.sheet]=p);
|
|
2201
2361
|
if(d.custom_details)C.custom_details=d.custom_details;
|
|
2202
2362
|
if(d.profile_colors)C.profile_colors=d.profile_colors;
|
|
2203
2363
|
if(d.member_styles)C.member_styles=sanitizeMemberStyles(d.member_styles); // F5: restore per-type line styles from the local draft (sanitised — the localStorage draft is unvalidated, unlike the server contract)
|
|
@@ -2292,7 +2452,12 @@ function restoreSaved(){
|
|
|
2292
2452
|
}
|
|
2293
2453
|
return applied;
|
|
2294
2454
|
}
|
|
2295
|
-
function restoreSavedInner(){
|
|
2455
|
+
function restoreSavedInner(){
|
|
2456
|
+
// Nothing to restore onto a read-only document, and applyDraftFields would refuse anyway — but returning
|
|
2457
|
+
// early keeps the SAVE PILL honest. Falling through would reach `return true` having applied nothing, and
|
|
2458
|
+
// the pill would say "Restored ✓" over a document with no restored edits in it.
|
|
2459
|
+
if(!canWriteModel())return false;
|
|
2460
|
+
try{const raw=localStorage.getItem(LSKEY);if(!raw)return false;const d=JSON.parse(raw);
|
|
2296
2461
|
// Structural first: the overlay below is per-sheet, so it is meaningless if the sheets moved.
|
|
2297
2462
|
if(d.sig!==dataSig())return false;
|
|
2298
2463
|
// Then the real base check. `serverEtag` is the tag boot() just read — main() is called synchronously
|
|
@@ -2630,7 +2795,7 @@ const _dEnd=v=>DIM_ENDS.includes(v),_dPlace=v=>v==='on'||v==='above',_dBg=v=>typ
|
|
|
2630
2795
|
// or an AI-authored contract can't put junk on the canvas.
|
|
2631
2796
|
function sanitizeDimStyle(){const s=(C&&C.dim_style&&typeof C.dim_style==='object'&&!Array.isArray(C.dim_style))?C.dim_style:{};
|
|
2632
2797
|
C.dim_style={end:_dEnd(s.end)?s.end:DIM_DEF.end,bg:_dBg(s.bg)?s.bg:DIM_DEF.bg,place:_dPlace(s.place)?s.place:DIM_DEF.place};}
|
|
2633
|
-
sanitizeDimStyle();
|
|
2798
|
+
if(canWriteModel())sanitizeDimStyle(); // …skipped for v2 — see the repair-pass note at the top of main()
|
|
2634
2799
|
function dimStyle(d){const g=(C&&C.dim_style)||DIM_DEF;return {
|
|
2635
2800
|
end: (d&&_dEnd(d.end)) ?d.end :(_dEnd(g.end) ?g.end :DIM_DEF.end),
|
|
2636
2801
|
bg: (d&&_dBg(d.bg)) ?d.bg :(_dBg(g.bg) ?g.bg :DIM_DEF.bg),
|
|
@@ -2726,14 +2891,64 @@ function renderDimsInner(){if(!dimsVisible||!Array.isArray(P.dims))return '';
|
|
|
2726
2891
|
// meaningful left to patch in place. Hit-testing is delegated off data-dim, so replacing the nodes is safe.
|
|
2727
2892
|
function renderDims(){return `<g class=dimsg>${renderDimsInner()}</g>`;}
|
|
2728
2893
|
// --- structural grid (Tekla-style; web/grid-core.js owns parsing/geometry — loaded via the module
|
|
2729
|
-
// shim as window.GridCore).
|
|
2730
|
-
//
|
|
2731
|
-
//
|
|
2732
|
-
// sprites in 3D, and feeds both snap engines. Riding the per-plan undo stack is therefore SAFE
|
|
2733
|
-
// (unlike the model-global dims3d). Visibility is P.grid.on (persisted, not undoable — a view toggle).
|
|
2894
|
+
// shim as window.GridCore). X/Y are relative spacing strings ("0 3*25'"), Z absolute levels. It renders
|
|
2895
|
+
// under the members in 2D + as dashed lines/label sprites in 3D, and feeds both snap engines. Visibility
|
|
2896
|
+
// is the grid's `on` (persisted, not undoable — a view toggle).
|
|
2734
2897
|
const GC=()=>window.GridCore||null;
|
|
2735
|
-
|
|
2736
|
-
|
|
2898
|
+
/**
|
|
2899
|
+
* WHERE THE GRID LIVES, resolved once (unit 5, P7d §4).
|
|
2900
|
+
*
|
|
2901
|
+
* v1: one grid PER PLAN (`P.grid`, like `P.frame`/`P.dims`), its origin and spacings in that sheet's
|
|
2902
|
+
* DISPLAY space — which is half of why v1 sheets were never registered to a common frame. Riding the
|
|
2903
|
+
* per-plan undo stack is safe there.
|
|
2904
|
+
* v2: ONE model grid at the document ROOT, in world mm. v2's `plan` schema is additionalProperties:false
|
|
2905
|
+
* and has no `grid` at all, so `P.grid` is not merely empty for a v2 document — writing it is illegal.
|
|
2906
|
+
*
|
|
2907
|
+
* The ~20 panel call sites are NOT taught the difference: they keep calling setPlanGrid/patchGrid, and
|
|
2908
|
+
* what changes is WHAT THEY RECEIVE. That adds no new write site to audit, and it keeps every read in one
|
|
2909
|
+
* vocabulary. For v1 `gridHost()` IS `P`, so this is byte-identical to what it replaced.
|
|
2910
|
+
*/
|
|
2911
|
+
function gridHost(){return MODEL_RO?C:(typeof P!=='undefined'?P:null);}
|
|
2912
|
+
function gridOf(){const h=gridHost();return (h&&h.grid)||null;}
|
|
2913
|
+
/**
|
|
2914
|
+
* The two LEVEL-LABEL edits, which also have to canonicalise `z` — without that quietly becoming a
|
|
2915
|
+
* topology write.
|
|
2916
|
+
*
|
|
2917
|
+
* Level labels are sorted by elevation, so an imported UNSORTED `z` must be canonicalised in the SAME
|
|
2918
|
+
* atomic edit or the labels rebind by source index. That is a real requirement, and it is why `z` rides
|
|
2919
|
+
* along on a label change at all. But rewriting `z` is precisely what a v2 document refuses, and rightly:
|
|
2920
|
+
* canonicalising can DEDUPE a level away, which retires a `dir:'z'` axis and rebinds anything anchored to
|
|
2921
|
+
* it.
|
|
2922
|
+
*
|
|
2923
|
+
* So the transaction is chosen by what the patch actually CONTAINS. When the stored string already is
|
|
2924
|
+
* canonical — true of every migrated document, since the server validated it — `z` is omitted and this is
|
|
2925
|
+
* an ordinary label edit. When it is not, `z` is in the patch and it goes through the topology gate, which
|
|
2926
|
+
* refuses it for v2 and names the review path. One rule, both callers, no third state.
|
|
2927
|
+
*/
|
|
2928
|
+
/**
|
|
2929
|
+
* May a DIRECT-MANIPULATION grid drag run? (unit 5, P7d §8.2)
|
|
2930
|
+
*
|
|
2931
|
+
* The three 2D drag writers — `setGridLineEnds`, `moveGridLine`, `moveGridLineEnd` — do NOT go through
|
|
2932
|
+
* `setPlanGrid`/`patchGrid`; they reach grid-core with the live grid object. So the transaction gate above
|
|
2933
|
+
* cannot see them, and §8.2 asks for them to be refused EXPLICITLY rather than assumed unreachable — which
|
|
2934
|
+
* they happen to be today, because a v2 document draws no 2D grid to grab.
|
|
2935
|
+
*
|
|
2936
|
+
* All three refuse for v2, and each for its own reason: `moveGridLine` rewrites the SPACING STRING, which
|
|
2937
|
+
* is the re-space; `moveGridLineEnd` writes v1's index-keyed `ends_x`/`ends_y`, a vocabulary v2 replaced
|
|
2938
|
+
* with an axis-id map; and `setGridLineEnds` moves a free line whose coordinates would be display px.
|
|
2939
|
+
*/
|
|
2940
|
+
function gridDragAllowed(){
|
|
2941
|
+
if(canWriteModel())return true;
|
|
2942
|
+
console.warn('steel-editor: a grid drag was refused — this document is open read-only');
|
|
2943
|
+
return false;}
|
|
2944
|
+
function editGridZLabels(normZ,g,patch){
|
|
2945
|
+
const full=(String((g&&g.z)||'')===String(normZ))?patch:Object.assign({z:normZ},patch);
|
|
2946
|
+
return (('z' in full)?editGridTopology:editGrid)(()=>{ModelCmd.patchGrid(gridOf(),full);});}
|
|
2947
|
+
function gridOn(){const g=gridOf();return !!(g&&g.on!==false);}
|
|
2948
|
+
// The 2D plan geometry — DISPLAY space, by definition, since that is the only space the 2D canvas has.
|
|
2949
|
+
// Null for v2: its grid is world mm and there is no persisted sheet registration to bring it back into a
|
|
2950
|
+
// sheet's pixels (§1). Drawing it through the v1 conversion would put a plausible grid in the wrong place.
|
|
2951
|
+
function gridGeo(){const gc=GC();if(!gc||MODEL_RO)return null;const g=gridOf();if(!g)return null;try{return gc.gridGeometry(g,(P.pt_per_ft>0)?P.pt_per_ft:1);}catch(_){return null;}}
|
|
2737
2952
|
// A grid <line> element (.gridhit) → its two endpoints [[x,y],[x,y]], or null. Mirrors the axis/index decode
|
|
2738
2953
|
// in the grid-drag path so a grid line can also serve as an extend/trim target.
|
|
2739
2954
|
function gridLineEndpoints(el){const geo=gridGeo();if(!geo||!el||!el.dataset)return null;
|
|
@@ -2786,9 +3001,10 @@ function gridSelSummary(){const geo=gridGeo()||{};const out=[];
|
|
|
2786
3001
|
// delete the selected FREE grid lines by identity (regular spacing lines can't be individually deleted → toast). Shared by the inspector Delete button; the keyboard Delete has its own bundled path (members+dims+grids in one edit()).
|
|
2787
3002
|
function deleteSelGrids(){
|
|
2788
3003
|
const glLids=new Set([...selGridIds].filter(id=>id.startsWith('gl:')).map(id=>id.slice(3)));
|
|
2789
|
-
const
|
|
3004
|
+
const _g=gridOf();
|
|
3005
|
+
const freeToDelete=(_g&&Array.isArray(_g.lines))?_g.lines.filter(l=>glLids.has(String(l.id))):[];
|
|
2790
3006
|
const hadReg=[...selGridIds].some(id=>id.startsWith('gv:')||id.startsWith('gh:'));
|
|
2791
|
-
if(freeToDelete.length)
|
|
3007
|
+
if(freeToDelete.length)editGrid(()=>{ModelCmd.removeGridLines(gridOf(),glLids);selGridIds.clear();});
|
|
2792
3008
|
else{selGridIds.clear();render();}
|
|
2793
3009
|
if(hadReg)toast('Regular grid lines come from the grid spacing — remove them in “Grid lines…”. Only free grid lines are deletable here.');}
|
|
2794
3010
|
// cursor-following distance readout for grid drags (same chrome as the 3D drag readout)
|
|
@@ -2805,7 +3021,7 @@ const gridDelta=(d)=>'Δ '+(d<0?'−':'+')+dimValueText(Math.abs(d));
|
|
|
2805
3021
|
// double-click a bubble → rename that one label in place (a themed input over the bubble; Enter/blur
|
|
2806
3022
|
// commits into the labels override — undoable; the open grid panel's Labels field refreshes via render)
|
|
2807
3023
|
function gridRenameBubble(axis,gi,anchorEl){
|
|
2808
|
-
const gc=GC();if(!gc||!
|
|
3024
|
+
const gc=GC();if(!gc||!gridOf())return;
|
|
2809
3025
|
const geo=gridGeo();const lines=axis==='v'?geo.v:axis==='h'?geo.h:(geo.lines||[]);const line=lines[gi];if(!line||!anchorEl)return;
|
|
2810
3026
|
const cur=line.label,r=anchorEl.getBoundingClientRect();
|
|
2811
3027
|
const inp=document.createElement('input');inp.value=cur;inp.className='gin';
|
|
@@ -2817,10 +3033,10 @@ function gridRenameBubble(axis,gi,anchorEl){
|
|
|
2817
3033
|
const nv=inp.value.trim();
|
|
2818
3034
|
if(!nv||nv===cur)return;
|
|
2819
3035
|
if(/\s/.test(nv)){toast('Labels can’t contain spaces');return;}
|
|
2820
|
-
if(axis==='l'){
|
|
3036
|
+
if(axis==='l'){editGrid(()=>{ModelCmd.setGridLineLabel(gridOf(),gi,nv);});return;}
|
|
2821
3037
|
const key=axis==='v'?'labels_x':'labels_y',style=axis==='v'?'num':'alpha';
|
|
2822
|
-
const toks=gc.labelsFor(
|
|
2823
|
-
|
|
3038
|
+
const toks=gc.labelsFor(gridOf()[key],style,lines.length);toks[gi]=nv;
|
|
3039
|
+
editGrid(()=>{ModelCmd.patchGrid(gridOf(),{[key]:toks.join(' ')});});};
|
|
2824
3040
|
inp.addEventListener('keydown',ev=>{ev.stopPropagation();
|
|
2825
3041
|
if(ev.key==='Enter'){ev.preventDefault();finish(true);}
|
|
2826
3042
|
else if(ev.key==='Escape'){ev.preventDefault();finish(false);}});
|
|
@@ -2835,8 +3051,8 @@ function sanitizePlanGrid(pl){if(!pl||pl.grid==null)return;const g=pl.grid;
|
|
|
2835
3051
|
if(typeof g!=='object'||Array.isArray(g)||!Array.isArray(g.origin)||g.origin.length<2||!isFinite(g.origin[0])||!isFinite(g.origin[1])){console.warn('discarding malformed grid on '+pl.sheet);pl.grid=null;return;}
|
|
2836
3052
|
sanitizeGridLines(g);}
|
|
2837
3053
|
function gridLineId(){return 'gl'+Date.now().toString(36)+Math.floor(Math.random()*1000).toString(36);}
|
|
2838
|
-
function gridNextLineLabel(){const n=(
|
|
2839
|
-
function gridEnsureForLine(a){const gc=GC();ModelCmd.ensurePlanGrid(
|
|
3054
|
+
function gridNextLineLabel(){const g=gridOf(),n=(g&&Array.isArray(g.lines))?g.lines.length+1:1;return 'L'+n;}
|
|
3055
|
+
function gridEnsureForLine(a){const gc=GC();ModelCmd.ensurePlanGrid(gridHost(),()=>({on:true,origin:a.slice(),x:'',y:'',z:"0'-0\"",labels_x:'',labels_y:'',labels_z:[],ext:gc?5*gc.FT_MM:1524,lines:[]}));}
|
|
2840
3056
|
// The 3D pick's minimum line length, in display px — a fixed floor, since 3D has no 2D `zoom` to scale by. 6 px is
|
|
2841
3057
|
// what the 2D tool enforces at 1:1; in real terms that is 6*mmPerPx (~2" at a typical 1/4"=1' sheet scale).
|
|
2842
3058
|
const GRID_LINE_MIN_DISP=6;
|
|
@@ -2846,7 +3062,7 @@ const GRID_LINE_MIN_DISP=6;
|
|
|
2846
3062
|
// depending on a hidden viewport (fitted at zoom≈0.2 it would silently refuse lines under ~2.5 ft).
|
|
2847
3063
|
function gridAddFreeLine(a,b,label,minDisp){const gc=GC();if(Math.hypot(b[0]-a[0],b[1]-a[1])<(minDisp>0?minDisp:6/zoom)){toast('Line is too short to create a grid line');return false;}
|
|
2848
3064
|
gridEnsureForLine(a);
|
|
2849
|
-
ModelCmd.addGridLine(
|
|
3065
|
+
ModelCmd.addGridLine(gridOf(),{id:gridLineId(),label:label||gridNextLineLabel(),a:a.slice(),b:b.slice()});return true;}
|
|
2850
3066
|
function gridSetPickClass(){document.body.classList.toggle('gridpick',!!gridPick||!!gridLinePick);
|
|
2851
3067
|
// ONE choke point for the 3D side: every path that arms or tears down the pick (start, cancel, setGridMode,
|
|
2852
3068
|
// Move/Copy arm, plan switch, view switch) already calls this, so the 3D pick can never outlive the 2D flag.
|
|
@@ -2876,7 +3092,7 @@ function gridReadFromDrawing(keep){
|
|
|
2876
3092
|
if(keep.labels_y)g.labels_y=keep.labels_y;
|
|
2877
3093
|
g.labels_z=Array.isArray(keep.labels_z)?keep.labels_z.slice():[];
|
|
2878
3094
|
if(Array.isArray(keep.hidden_z)&&keep.hidden_z.length)g.hidden_z=keep.hidden_z.slice();}
|
|
2879
|
-
|
|
3095
|
+
editGridTopology(()=>{ModelCmd.setPlanGrid(gridHost(),g);});
|
|
2880
3096
|
toast('Grid read from the drawing — '+r.info.v+' × '+r.info.h+' lines'+(r.info.labeled?'':'. Labels are auto — Ask AI can read the printed marks.'));}
|
|
2881
3097
|
// The bubble marks on most CAD sets are OUTLINED (not text), so the detector can't read them. The
|
|
2882
3098
|
// sanctioned path for that gap is the Ask-AI relay (the UI never calls an LLM): pre-fill the existing
|
|
@@ -2894,12 +3110,12 @@ function gridDefaultOrigin(){const xs=[],ys=[];for(const m of ((P&&P.members)||[
|
|
|
2894
3110
|
if(xs.length)return [Math.min(...xs),Math.max(...ys)]; // bottom-left of the steel
|
|
2895
3111
|
return [(typeof X0==='number'?X0:0)+50,(typeof Y1==='number'?Y1:300)-50];} // empty plan → near the sheet corner
|
|
2896
3112
|
function refresh3DGrid(){if(view3dReady&&window.Steel3DView&&window.Steel3DView.refreshGrid)window.Steel3DView.refreshGrid();}
|
|
2897
|
-
function updGridToggle(){const b=document.getElementById('gridToggleB');if(!b)return;b.disabled=!(
|
|
3113
|
+
function updGridToggle(){const b=document.getElementById('gridToggleB');if(!b)return;b.disabled=!gridOf();b.classList.toggle('on',gridOn());b.setAttribute('aria-checked',String(gridOn()));}
|
|
2898
3114
|
// ONE visibility switch, THREE surfaces: the grid panel's checkbox, the 3D legend's "Grid lines" row,
|
|
2899
3115
|
// and the ⋯ menu item — all call this. grid.on is contract data, so the flip is undoable like every
|
|
2900
3116
|
// other grid operation.
|
|
2901
|
-
function gridSetVisible(on){if(!C
|
|
2902
|
-
|
|
3117
|
+
function gridSetVisible(on){if(!C||!gridOf()||on===gridOn())return;
|
|
3118
|
+
editGrid(()=>{ModelCmd.patchGrid(gridOf(),{on:!!on});});updGridToggle();refresh3DGrid();if(view3d)build3DLegend();}
|
|
2903
3119
|
document.addEventListener('gridcore-ready',()=>{try{if(C)render();}catch(_){}}); // module shim finished after boot → paint the grid layer
|
|
2904
3120
|
function setGridMode(on){if(!C)return;gridMode=!!on;
|
|
2905
3121
|
if(!gridMode){const ae=document.activeElement,pn=document.getElementById('panel');if(ae&&pn&&pn.contains(ae))ae.blur(); // commit a focused field (change fires on blur) BEFORE the panel is torn down — a canvas click's pointerdown runs before the browser's own focus change
|
|
@@ -2941,19 +3157,33 @@ function renderGridPanel(p){
|
|
|
2941
3157
|
const gc=GC();
|
|
2942
3158
|
if(!gc){p.innerHTML='<span class=badge>Grid lines</span><div class=hint style="margin-top:8px">Loading grid tools…</div>';return;}
|
|
2943
3159
|
const ppf=(P&&P.pt_per_ft>0)?P.pt_per_ft:1;
|
|
2944
|
-
if(!
|
|
3160
|
+
if(!gridOf()){
|
|
2945
3161
|
const nCols=planColumnCount(),hasEls=!!filterElsForPlan();
|
|
3162
|
+
// The no-grid branch CREATES one, which mints the very axes the re-space refusal exists to protect —
|
|
3163
|
+
// so on a read-only document all four of its actions are topological. Gated at the transaction as well
|
|
3164
|
+
// (editGridTopology); this is the chrome saying so. (unit 5, P7d — Codex H9.)
|
|
3165
|
+
const roTopo=MODEL_RO?' disabled aria-describedby=gridRoWhy':'';
|
|
2946
3166
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
2947
3167
|
<div class=hint style="margin-top:8px">No grid yet. Grid lines are a plan reference — they don't constrain members.</div>
|
|
2948
|
-
<div class=
|
|
3168
|
+
${MODEL_RO?'<div class=hint id=gridRoWhy style="margin-top:8px">Starting a grid decides which grid lines <i>exist</i>, and dimensions anchor to them — so it goes through a reviewed model update. Ask your terminal AI to add a grid, and you can move and relabel it here.</div>':''}
|
|
3169
|
+
<div class=gbtns><button id=gridLineB${roTopo} class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button><button id=gridReadB${roTopo} ${hasEls?'':'disabled'} data-tip="${hasEls?'Detect the printed grid lines and bubbles in this sheet’s linework. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB${roTopo} ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button><button id=gridBlankB${roTopo} data-tip="Start from a 4×4 grid of 30' bays and edit the spacings. Undoable.">Start blank</button></div>
|
|
2949
3170
|
${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridPickHasFirst()?'Pick the second point for the grid line':'Pick the first point for the grid line')+(view3d?' — snaps to the model and the grid.':' — snaps to linework (<b>Alt</b> off).')+' <b>Esc</b> cancels.</div>':''}
|
|
2950
3171
|
<div class=hint style="margin-top:10px">Spacing uses <b>n*d</b> to repeat (e.g. <b>3*25'</b> = three 25' bays). Tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>`;
|
|
2951
3172
|
document.getElementById('gridLineB').onclick=gridStartLinePick;
|
|
2952
3173
|
const rb=document.getElementById('gridReadB');if(rb)rb.onclick=()=>gridReadFromDrawing(null);
|
|
2953
|
-
const ab=document.getElementById('gridAutoB');if(ab)ab.onclick=()=>{const g=gc.inferGrid(P.members,ppf);if(!g){toast('No columns to infer a grid from');return;}
|
|
2954
|
-
const bb=document.getElementById('gridBlankB');if(bb)bb.onclick=()=>{const o=gridDefaultOrigin();
|
|
3174
|
+
const ab=document.getElementById('gridAutoB');if(ab)ab.onclick=()=>{const g=gc.inferGrid((P&&P.members)||[],ppf);if(!g){toast('No columns to infer a grid from');return;}editGridTopology(()=>{ModelCmd.setPlanGrid(gridHost(),g);});};
|
|
3175
|
+
const bb=document.getElementById('gridBlankB');if(bb)bb.onclick=()=>{const o=gridDefaultOrigin();editGridTopology(()=>{ModelCmd.setPlanGrid(gridHost(),gc.defaultGrid(o));});};
|
|
2955
3176
|
return;}
|
|
2956
|
-
const g=
|
|
3177
|
+
const g=gridOf(),nCols=planColumnCount();
|
|
3178
|
+
// ── The read-only split (unit 5, P7d §8.2). Two DIFFERENT reasons, so two notes: a control is either
|
|
3179
|
+
// topological (it changes which grid lines exist, and dimensions are anchored to those) or it depends on
|
|
3180
|
+
// the 2D plan canvas, which a v2 model does not have. Disabled with a reason rather than removed — a
|
|
3181
|
+
// control that simply vanishes reads as "this editor is broken", which is the opposite of the truth.
|
|
3182
|
+
// aria-describedby, not data-tip alone: data-tip is hover-driven and never reaches a keyboard or
|
|
3183
|
+
// screen-reader user (§8.5).
|
|
3184
|
+
const ro=MODEL_RO;
|
|
3185
|
+
const roTopo=ro?' disabled aria-describedby=gridRoWhy':'', roNo2d=ro?' disabled aria-describedby=gridNo2dWhy':'';
|
|
3186
|
+
const og=(Array.isArray(g.origin)&&g.origin.length>=2&&isFinite(g.origin[0])&&isFinite(g.origin[1]))?g.origin:[0,0];
|
|
2957
3187
|
const normSp=v=>{const r=gc.parseSpacings(v);return r.err?String(v||''):gc.formatSpacings(r.offsets);};
|
|
2958
3188
|
const zParsed=gc.parseLevels(g.z,g.labels_z),normZ=zParsed.err?String(g.z||''):gc.formatLevels(zParsed.levels.map(l=>l.mm));
|
|
2959
3189
|
const zLabels=Array.isArray(g.labels_z)?g.labels_z:[];
|
|
@@ -2963,15 +3193,16 @@ function renderGridPanel(p){
|
|
|
2963
3193
|
const zLabelRows=zParsed.err?'':zParsed.levels.map((lv,i)=>{const elevation=gc.fmtLen(lv.mm),label=zLabels[lv.sourceIndex]||'',visible=!hiddenZKeys.has(gc.gridLevelKey(lv.mm)),name=label||elevation;return `<div class=vgfield style="display:grid;grid-template-columns:minmax(96px,auto) minmax(0,1fr);align-items:center;gap:7px;margin-top:6px;${visible?'':'opacity:.68'}"><label class=gck data-tip="Show / hide this 3D level grid and tag"><input type=checkbox data-zvisible="${i}" aria-label="Show ${esc(name)} at ${esc(elevation)} in 3D" ${visible?'checked':''}><span>${esc(elevation)}</span></label><input class=gin data-zlabel="${i}" value="${esc(label)}" placeholder="${esc(elevation)}" autocomplete=off spellcheck=false></div>`;}).join('');
|
|
2964
3194
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
2965
3195
|
<div class=hint style="margin-top:8px">A plan reference — doesn't constrain members. <b>n*d</b> repeats a bay (e.g. <b>3*25'</b>); tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>
|
|
3196
|
+
${ro?'<div class=hint id=gridRoWhy style="margin-top:8px">Spacings and levels decide which grid lines <i>exist</i>, and dimensions are anchored to them — so changing those goes through a reviewed model update. Ask your terminal AI. Labels, which levels show, the extension and the origin are editable right here.</div>':''}
|
|
2966
3197
|
<label class=gck style="margin-top:10px"><input type=checkbox id=gShow ${gridOn()?'checked':''}><span>Show grid lines</span></label>
|
|
2967
3198
|
<div class=sect style="margin-top:12px">X spacings <span style="color:var(--mut);font-weight:400;text-transform:none">· lines 1, 2, 3…</span></div>
|
|
2968
|
-
<input id=gX class=gin value="${esc(normSp(g.x))}" placeholder="e.g. 0'-0", 3*25'-0", 20'-6 1/2"" autocomplete=off spellcheck=false>
|
|
3199
|
+
<input id=gX class=gin${roTopo} value="${esc(normSp(g.x))}" placeholder="e.g. 0'-0", 3*25'-0", 20'-6 1/2"" autocomplete=off spellcheck=false>
|
|
2969
3200
|
<div id=gXfb class=gfb></div>
|
|
2970
3201
|
<div class=sect style="margin-top:10px">Y spacings <span style="color:var(--mut);font-weight:400;text-transform:none">· lines A, B, C…</span></div>
|
|
2971
|
-
<input id=gY class=gin value="${esc(normSp(g.y))}" placeholder="e.g. 0'-0", 4*30'-0"" autocomplete=off spellcheck=false>
|
|
3202
|
+
<input id=gY class=gin${roTopo} value="${esc(normSp(g.y))}" placeholder="e.g. 0'-0", 4*30'-0"" autocomplete=off spellcheck=false>
|
|
2972
3203
|
<div id=gYfb class=gfb></div>
|
|
2973
3204
|
<div class=sect style="margin-top:10px">Levels (Z)</div>
|
|
2974
|
-
<input id=gZ class=gin value="${esc(normZ)}" placeholder="e.g. 0'-0", 16'-6", 33'-0"" autocomplete=off spellcheck=false>
|
|
3205
|
+
<input id=gZ class=gin${roTopo} value="${esc(normZ)}" placeholder="e.g. 0'-0", 16'-6", 33'-0"" autocomplete=off spellcheck=false>
|
|
2975
3206
|
<div id=gZfb class=gfb></div>
|
|
2976
3207
|
<div class=hint style="margin-top:3px">Absolute elevations, one per level — check each row to show its grid and tag in 3D.</div>
|
|
2977
3208
|
<div class=sect style="margin-top:10px">Z elevation labels</div>
|
|
@@ -2984,15 +3215,18 @@ function renderGridPanel(p){
|
|
|
2984
3215
|
${(!g.labels_x&&!g.labels_y)?'<div class=gbtns style="margin-top:6px"><button id=gridLabelsAiB class=ghostw data-tip="Many drawings outline their bubble text, so the marks can’t be read deterministically. This sends a request to your AI terminal — it reads the printed marks from the source drawing and fills the labels as a contract update.">Ask AI to read the labels ▸</button></div>':''}
|
|
2985
3216
|
<div class=sect style="margin-top:10px">Single lines <span style="color:var(--mut);font-weight:400;text-transform:none">· any angle</span></div>
|
|
2986
3217
|
<div class=gfb>${(g.lines&&g.lines.length)?(g.lines.length+' individual line'+(g.lines.length===1?'':'s')+' · drag endpoints to adjust'):'No individual lines yet.'}</div>
|
|
2987
|
-
<div class=gbtns><button id=gridLineB class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button>${(g.lines&&g.lines.length)?'<button id=gridClearLinesB class=ghostw data-tip="Remove every individual grid line. The X/Y grid and levels stay. Undoable.">Clear single lines</button>':''}</div>
|
|
3218
|
+
<div class=gbtns><button id=gridLineB${roTopo} class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button>${(g.lines&&g.lines.length)?('<button id=gridClearLinesB'+roTopo+' class=ghostw data-tip="Remove every individual grid line. The X/Y grid and levels stay. Undoable.">Clear single lines</button>'):''}</div>
|
|
2988
3219
|
${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridPickHasFirst()?'Pick the second point for the grid line':'Pick the first point for the grid line')+(view3d?' — snaps to the model and the grid.':' — snaps to linework (<b>Alt</b> off).')+' <b>Esc</b> cancels.</div>':''}
|
|
2989
3220
|
<div class=sect style="margin-top:10px">Extension</div>
|
|
2990
3221
|
<input id=gExt class=gin style="width:110px" value="${esc(gc.fmtLen(isFinite(g.ext)?g.ext:1524))}" autocomplete=off spellcheck=false>
|
|
2991
3222
|
<div class=hint style="margin-top:3px">How far every line runs past the outermost, in plan. Drag a bubble <b>along</b> its line to override just that one.</div>
|
|
2992
3223
|
${(()=>{const n=Object.keys(g.ends_x||{}).length+Object.keys(g.ends_y||{}).length;return n?`<div class=gfb style="display:flex;align-items:center;gap:8px;margin-top:5px"><span>${n} line${n===1?'':'s'} with a custom extent</span><button id=gridResetExtB class=ghost style="height:22px;padding:0 8px;font-size:11px" data-tip="Reset every line back to the Extension value above. Undoable.">Reset all</button></div>`:'';})()}
|
|
2993
|
-
|
|
3224
|
+
${ro?`<div class=sect style="margin-top:10px">Origin <span style="color:var(--mut);font-weight:400;text-transform:none">· the 1-A corner, in model coordinates</span></div>
|
|
3225
|
+
<div style="display:flex;gap:6px"><input id=gOX class=gin value="${esc(gc.fmtLen(og[0]))}" aria-label="Grid origin X" autocomplete=off spellcheck=false><input id=gOY class=gin value="${esc(gc.fmtLen(og[1]))}" aria-label="Grid origin Y" autocomplete=off spellcheck=false></div>
|
|
3226
|
+
<div class=hint id=gridNo2dWhy style="margin-top:3px">Type the corner directly — this model has no plan view to pick it on.</div>`:''}
|
|
3227
|
+
<div class=gbtns><button id=gridPickB${roNo2d} class="${gridPick?'on':''}" data-tip="Click the grid's 1-A corner on the plan — snaps to member ends. Esc cancels.">Pick origin</button><button id=gridReadB2${roTopo} ${filterElsForPlan()?'':'disabled'} data-tip="${filterElsForPlan()?'Re-detect the printed grid from this sheet’s linework — keeps your levels and hand-set labels. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB2${roTopo} ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Re-infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button></div>
|
|
2994
3228
|
${gridPick?'<div class=hint style="margin-top:6px">Click the grid’s <b>1-A corner</b> on the plan — snaps to member ends (<b>Alt</b> off). <b>Esc</b> cancels.</div>':''}
|
|
2995
|
-
<div class=gbtns style="margin-top:16px"><button id=gridRemoveB class=ghostw style="flex:1" data-tip="Delete all grid lines and levels. Undoable.">Remove grid</button><button id=gridDoneB>Done</button></div>`;
|
|
3229
|
+
<div class=gbtns style="margin-top:16px"><button id=gridRemoveB${roTopo} class=ghostw style="flex:1" data-tip="Delete all grid lines and levels. Undoable.">Remove grid</button><button id=gridDoneB>Done</button></div>`;
|
|
2996
3230
|
const fbSpacing=(inpId,fbId,style,override,emptyMsg)=>{
|
|
2997
3231
|
const el=document.getElementById(fbId),v=document.getElementById(inpId).value;
|
|
2998
3232
|
const r=gc.parseSpacings(v);
|
|
@@ -3020,28 +3254,41 @@ function renderGridPanel(p){
|
|
|
3020
3254
|
if(ev.key==='Enter'){ev.preventDefault();el.blur();}
|
|
3021
3255
|
else if(ev.key==='Escape'){ev.preventDefault();el.value=orig;fbAll();}});
|
|
3022
3256
|
el.addEventListener('change',()=>commit(el.value.trim(),el));};
|
|
3023
|
-
wire('gX',(v,el)=>{const r=gc.parseSpacings(v);if(r.err)return;const next=gc.formatSpacings(r.offsets);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.x||''))
|
|
3024
|
-
|
|
3025
|
-
ModelCmd.patchGrid(
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
wire('
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3257
|
+
wire('gX',(v,el)=>{const r=gc.parseSpacings(v);if(r.err)return;const next=gc.formatSpacings(r.offsets);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.x||''))editGridTopology(()=>{ // a changed LINE COUNT invalidates the index-keyed per-line ends (they'd re-bind to the wrong lines)
|
|
3258
|
+
const gg=gridOf();
|
|
3259
|
+
if(gg.ends_x&&r.offsets.length!==gc.parseSpacings(gg.x).offsets.length)ModelCmd.patchGrid(gg,{ends_x:undefined});
|
|
3260
|
+
ModelCmd.patchGrid(gg,{x:next});});});
|
|
3261
|
+
wire('gY',(v,el)=>{const r=gc.parseSpacings(v);if(r.err)return;const next=gc.formatSpacings(r.offsets);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.y||''))editGridTopology(()=>{
|
|
3262
|
+
const gg=gridOf();
|
|
3263
|
+
if(gg.ends_y&&r.offsets.length!==gc.parseSpacings(gg.y).offsets.length)ModelCmd.patchGrid(gg,{ends_y:undefined});
|
|
3264
|
+
ModelCmd.patchGrid(gg,{y:next});});});
|
|
3265
|
+
wire('gZ',(v,el)=>{const r=gc.parseLevels(v);if(r.err)return;const next=gc.formatLevels(r.levels.map(l=>l.mm)),old=Array.isArray(g.labels_z)?g.labels_z:[],labels=gc.reconcileLevelLabels(zParsed,zNormalizedLabels.labels,r).labels,hidden=gc.normalizeHiddenLevels(g.hidden_z,r.levels),warning=levelWarningText(r);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.z||'')||JSON.stringify(labels)!==JSON.stringify(old)||JSON.stringify(hidden)!==JSON.stringify(g.hidden_z||[]))editGridTopology(()=>{ModelCmd.patchGrid(gridOf(),{z:next,labels_z:labels,hidden_z:hidden.length?hidden:undefined});});if(warning)toast(warning);});
|
|
3266
|
+
wire('gLX',(v)=>{if(v!==(g.labels_x||''))editGrid(()=>{ModelCmd.patchGrid(gridOf(),{labels_x:v});});});
|
|
3267
|
+
wire('gLY',(v)=>{if(v!==(g.labels_y||''))editGrid(()=>{ModelCmd.patchGrid(gridOf(),{labels_y:v});});});
|
|
3268
|
+
document.querySelectorAll('[data-zlabel]').forEach(el=>{const orig=el.value;el.addEventListener('input',()=>{const limited=gc.truncateText(el.value,40);if(limited!==el.value)el.value=limited;});el.addEventListener('keydown',ev=>{ev.stopPropagation();if(ev.key==='Enter'){ev.preventDefault();el.blur();}else if(ev.key==='Escape'){ev.preventDefault();el.value=orig;}});el.addEventListener('change',()=>{const i=+el.dataset.zlabel,nv=gc.truncateText(el.value.trim(),40),labels=zNormalizedLabels.labels.slice();if(labels[i]===nv&&g.z===normZ)return;labels[i]=nv;editGridZLabels(normZ,g,{labels_z:labels});});});
|
|
3269
|
+
document.querySelectorAll('[data-zvisible]').forEach(el=>el.addEventListener('change',()=>{const lv=zParsed.levels[+el.dataset.zvisible];if(!lv)return;const key=gc.gridLevelKey(lv.mm),next=hiddenZ.filter(mm=>gc.gridLevelKey(mm)!==key);if(!el.checked)next.push(lv.mm);const hidden=gc.normalizeHiddenLevels(next,zParsed.levels);editGrid(()=>{ModelCmd.patchGrid(gridOf(),{hidden_z:hidden.length?hidden:undefined});});}));
|
|
3270
|
+
wire('gExt',(v,el)=>{const mm=gc.parseLen(v);if(!isFinite(mm)||mm<0){el.style.borderColor='#fca5a5';return;}el.style.borderColor='';if(Math.abs(mm-(isFinite(g.ext)?g.ext:1524))>0.5)editGrid(()=>{ModelCmd.patchGrid(gridOf(),{ext:mm});});});
|
|
3271
|
+
// The ORIGIN, typed (unit 5, P7d). v1 sets it by clicking the 1-A corner on the plan; a v2 model has no
|
|
3272
|
+
// plan canvas to click (§1), so "move the grid" would have had no gesture at all — and moving it is one of
|
|
3273
|
+
// the edits this unit exists to give the human. Both coordinates commit as ONE edit: writing X and then Y
|
|
3274
|
+
// would put an intermediate position on the undo stack that the user never asked for.
|
|
3275
|
+
if(ro){const commitOrigin=()=>{
|
|
3276
|
+
const ex=gc.parseLen(document.getElementById('gOX').value),ey=gc.parseLen(document.getElementById('gOY').value);
|
|
3277
|
+
if(!isFinite(ex)||!isFinite(ey))return;
|
|
3278
|
+
const cur=(gridOf()||{}).origin||[0,0];
|
|
3279
|
+
if(Math.abs(ex-cur[0])<=0.5&&Math.abs(ey-cur[1])<=0.5)return; // same 1/32" the length formatter rounds to — a no-op must not push an undo entry
|
|
3280
|
+
editGrid(()=>{ModelCmd.patchGrid(gridOf(),{origin:[ex,ey]});});refresh3DGrid();};
|
|
3281
|
+
wire('gOX',commitOrigin);wire('gOY',commitOrigin);}
|
|
3035
3282
|
const gsh=document.getElementById('gShow');if(gsh)gsh.addEventListener('change',()=>gridSetVisible(gsh.checked));
|
|
3036
|
-
const grx=document.getElementById('gridResetExtB');if(grx)grx.onclick=()=>{
|
|
3037
|
-
const gdz=document.getElementById('gridDropZLabels');if(gdz)gdz.onclick=()=>{const labels=zNormalizedLabels.labels.slice(0,zParsed.levels.length);
|
|
3283
|
+
const grx=document.getElementById('gridResetExtB');if(grx)grx.onclick=()=>{editGrid(()=>{ModelCmd.patchGrid(gridOf(),{ends_x:undefined,ends_y:undefined});});}; // drop every per-line extent override → all lines follow the global Extension again
|
|
3284
|
+
const gdz=document.getElementById('gridDropZLabels');if(gdz)gdz.onclick=()=>{const labels=zNormalizedLabels.labels.slice(0,zParsed.levels.length);editGridZLabels(normZ,g,{labels_z:labels});toast(`${zExtraCount} extra Z label${zExtraCount===1?'':'s'} removed`);}; // labels are sorted by elevation, so canonicalize z in the same atomic edit (an imported unsorted z must not rebind them by source index)
|
|
3038
3285
|
document.getElementById('gridLineB').onclick=gridStartLinePick;
|
|
3039
|
-
const gcl=document.getElementById('gridClearLinesB');if(gcl)gcl.onclick=()=>{
|
|
3286
|
+
const gcl=document.getElementById('gridClearLinesB');if(gcl)gcl.onclick=()=>{editGridTopology(()=>{ModelCmd.clearGridLines(gridOf());});};
|
|
3040
3287
|
document.getElementById('gridPickB').onclick=()=>{gridPick=!gridPick;gridLinePick=null;gridSetPickClass();panel();};
|
|
3041
|
-
const r2=document.getElementById('gridReadB2');if(r2)r2.onclick=()=>gridReadFromDrawing(
|
|
3288
|
+
const r2=document.getElementById('gridReadB2');if(r2)r2.onclick=()=>gridReadFromDrawing(gridOf());
|
|
3042
3289
|
const lb=document.getElementById('gridLabelsAiB');if(lb)lb.onclick=gridAskAiLabels;
|
|
3043
|
-
const a2=document.getElementById('gridAutoB2');if(a2)a2.onclick=()=>{const ng=gc.inferGrid(P.members,ppf);if(!ng){toast('No columns to infer a grid from');return;}ng.z=
|
|
3044
|
-
document.getElementById('gridRemoveB').onclick=()=>{
|
|
3290
|
+
const a2=document.getElementById('gridAutoB2');if(a2)a2.onclick=()=>{const ng=gc.inferGrid(P.members,ppf);if(!ng){toast('No columns to infer a grid from');return;}const cg=gridOf();ng.z=cg.z;ng.labels_x=cg.labels_x;ng.labels_y=cg.labels_y;ng.labels_z=Array.isArray(cg.labels_z)?cg.labels_z.slice():[];if(Array.isArray(cg.hidden_z)&&cg.hidden_z.length)ng.hidden_z=cg.hidden_z.slice();ng.ext=cg.ext;editGridTopology(()=>{ModelCmd.setPlanGrid(gridHost(),ng);});}; // re-infer geometry, keep the user's levels/labels/visibility/extension
|
|
3291
|
+
document.getElementById('gridRemoveB').onclick=()=>{editGridTopology(()=>{ModelCmd.setPlanGrid(gridHost(),null);});};
|
|
3045
3292
|
document.getElementById('gridDoneB').onclick=()=>{setGridMode(false);render();};
|
|
3046
3293
|
}
|
|
3047
3294
|
function setGeo(){document.body.classList.toggle('geo',!!geoMode);document.body.classList.toggle('geoel',geoMode==='el');} // geoel = Extend/Trim armed; grid lines are a target ONLY then (not in Split), so their crosshair/highlight keys off geoel, not geo
|
|
@@ -3188,6 +3435,12 @@ function doDup(){const arr=sel2d();if(!arr.length)return;const o=12,pv=snapshot(
|
|
|
3188
3435
|
selIds=ns;selDimIds.clear();mode='sel';setMode();pushUndo(pv);render();}
|
|
3189
3436
|
function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'<','>':'>','&':'&','"':'"'}[c]));}
|
|
3190
3437
|
function render(){
|
|
3438
|
+
// A v2 document has no 2D plan to draw (§1): its members are world-mm and model-level, and the sheet
|
|
3439
|
+
// registration that would place them back into this sheet's display space is computed at migration and
|
|
3440
|
+
// never persisted — the adapter's own sheetFrame() refuses to fabricate one. So the canvas stays empty
|
|
3441
|
+
// rather than drawing a plausible plan in the wrong place, which is the worst defect class this epic has.
|
|
3442
|
+
// The inspector still repaints: the read-only panel is what the user actually has here.
|
|
3443
|
+
if(MODEL_RO){svg.replaceChildren();stats();panel();return;} // stats() here only RETIRES the per-sheet readouts — see its v2 branch
|
|
3191
3444
|
document.body.classList.remove('snapping'); // a wholesale svg rebuild drops any #snapMark → clear the cursor-hide flag too (the next pointermove re-adds it if still snapping)
|
|
3192
3445
|
buildColorRank(); // refresh the model-global colour rank before any colorFor() call below (B2 — keeps 2D hues stable across plans + matched to 3D)
|
|
3193
3446
|
reanchorAllPlans(); // F9: glue magnetic dims to their members BEFORE anything reads P.dims — covers every mutation path that ends in a render()
|
|
@@ -3284,7 +3537,14 @@ function updateLine(m){
|
|
|
3284
3537
|
if(pg){const pts=columnSectionPoly(m);if(pts)pg.setAttribute('points',_polyStr(pts));}return;}
|
|
3285
3538
|
const ln=svg.querySelector(`line.member[data-id="${m.id}"]`);
|
|
3286
3539
|
if(ln){ln.setAttribute('x1',m.wp[0][0]);ln.setAttribute('y1',m.wp[0][1]);ln.setAttribute('x2',m.wp[1][0]);ln.setAttribute('y2',m.wp[1][1]);}}
|
|
3540
|
+
/** Take a header stat out of the flow entirely — not dimmed, not zeroed. See stats() for when and why. */
|
|
3541
|
+
function hideStat(id){const el=document.getElementById(id);if(el)el.style.display='none';}
|
|
3287
3542
|
function stats(){
|
|
3543
|
+
// A v2 model has no per-sheet member list, and every number below is per-sheet. There is no honest value
|
|
3544
|
+
// to put here, so the readouts are REMOVED from the header instead of showing zeros beside a populated
|
|
3545
|
+
// 3D scene. This is the one place `hidden` beats `disabled` in this editor — that rule is about ACTION
|
|
3546
|
+
// controls, where vanishing reads as "broken"; a stat that cannot be computed has nothing to act on.
|
|
3547
|
+
if(MODEL_RO){for(const id of ['mcStat','wtStat','rfiStat','dupStat'])hideStat(id);return;}
|
|
3288
3548
|
document.getElementById('mc').textContent=P.members.length;
|
|
3289
3549
|
let w=0,rfi=0; for(const m of P.members){const wpf=_wt(m.profile); if(wpf==null)rfi++; else w+=_lenFt(ensureMeta(m))*wpf;}
|
|
3290
3550
|
document.getElementById('wt').textContent=(w/2000).toFixed(1);document.getElementById('wtlb').textContent=Math.round(w).toLocaleString();document.getElementById('rc').textContent=rfi;
|
|
@@ -3380,10 +3640,26 @@ async function connModifyRequest(j){
|
|
|
3380
3640
|
toast(res.ok?'Change queued for your terminal AI session':'Could not queue the request');
|
|
3381
3641
|
}catch(_){toast('Could not queue the request');}
|
|
3382
3642
|
}
|
|
3643
|
+
/**
|
|
3644
|
+
* The inspector for a read-only v2 document (unit 5, P7d).
|
|
3645
|
+
*
|
|
3646
|
+
* Every branch of panel() below reads v1 shapes — `selArr()` and `byId()` resolve through
|
|
3647
|
+
* `C.plans[].members`, which v2 does not have, so each would render an EMPTY inspector and a
|
|
3648
|
+
* "Members 0 · Weight 0" legend beside a populated 3D scene. A readout that is wrong is worse than one that
|
|
3649
|
+
* is absent (§8.5), so the unanswerable ones are not rendered at all and this says what the panel IS.
|
|
3650
|
+
*/
|
|
3651
|
+
function renderPanelV2(p){
|
|
3652
|
+
// The three surfaces that describe this mode — the ribbon, this panel, and the grid panel's own note —
|
|
3653
|
+
// must not drift apart. This one names the grid because the grid IS editable (§8.2), which the first
|
|
3654
|
+
// draft of this copy predated.
|
|
3655
|
+
p.innerHTML='<span class=badge>Read-only</span>'+
|
|
3656
|
+
'<div class=hint style="margin-top:8px">This model is saved in FloLess’s canonical format. You can look around it in 3D, edit its <b>grid</b>, and export it — editing members, connections and dimensions here is still catching up.</div>'+
|
|
3657
|
+
'<div class=hint style="margin-top:10px">Nothing is wrong with the model. Ask your terminal AI to change it, and it will show up here.</div>';}
|
|
3383
3658
|
function panel(){
|
|
3384
3659
|
const p=document.getElementById('panel');
|
|
3385
3660
|
if(!selDimIds.size||!dimsVisible)dimSplitMode=false;document.body.classList.toggle('dimsplit',dimSplitMode); // split mode is meaningless without a (visible) dim selected — also disarms when dims are hidden
|
|
3386
3661
|
if(gridMode){renderGridPanel(p);return;}
|
|
3662
|
+
if(MODEL_RO){renderPanelV2(p);return;} // …after the grid panel, which is the one panel a v2 document does reach
|
|
3387
3663
|
if(dimStyleMode&&(selIds.size||selDimIds.size))dimStyleMode=false; // anything that selects (Ctrl+A, Duplicates, Reversed beams, a legend/RFI locate…) takes the panel back from the style pane — one guard instead of a disarm call at every such command
|
|
3388
3664
|
if(dimStyleMode){renderDimStylePanel(p);return;}
|
|
3389
3665
|
if(view3d&&window.Steel3DView&&window.Steel3DView.frameArmed&&window.Steel3DView.frameArmed()){ // 3D local-frame armed → the panel-takeover idiom (badge + hint), like the 2D Set-local-axes / Dimension tools
|
|
@@ -4304,15 +4580,25 @@ function sanitizePropLabels(x){const o=(x&&typeof x==='object'&&!Array.isArray(x
|
|
|
4304
4580
|
selected_only:o.selected_only===true,
|
|
4305
4581
|
vis2d:o.vis2d!==false,vis3d:o.vis3d!==false, // per-view label VISIBILITY (B1): default ON; the property SELECTION (props) stays shared across 2D+3D — only show/hide is independent
|
|
4306
4582
|
ids:Array.isArray(o.ids)?o.ids.filter(v=>typeof v==='string'):[]};}
|
|
4583
|
+
// …all three skipped for v2 — see the repair-pass note at the top of main(). These two are the pair the
|
|
4584
|
+
// schema check caught: prop_labels gains vis2d/vis3d, and views gains `projection` while LOSING each
|
|
4585
|
+
// generated view's `axisId`.
|
|
4586
|
+
if(canWriteModel()){
|
|
4307
4587
|
C.prop_labels=sanitizePropLabels(C.prop_labels); // normalise the contract's incoming value now (PROP_KEYS is initialised above; runs before main's bootstrap render + restoreSaved override)
|
|
4308
4588
|
C.views=sanitizeViews(C.views); // normalise the incoming saved views now — inside main() where sanitizeViews is in scope (boot() only guaranteed an array); runs before the bootstrap render + restoreSaved override, same pattern as prop_labels above
|
|
4309
4589
|
if(SteelCore)C.dims3d=SteelCore.sanitizeDims3d(C.dims3d); // UCS Stage 5: canonicalise each 3D dim's axisDir (drop junk / normalise non-unit) so a bad value can't wedge the schema-validated save — the SERVER contract copy; restoreSaved re-sanitises the localStorage draft below
|
|
4590
|
+
}
|
|
4310
4591
|
// the "Label: value" lines a member contributes for the currently-checked props (registry order; skips N/A + empty)
|
|
4311
4592
|
function propLabelLinesFor(m){const pl=C.prop_labels;if(!pl||!pl.props.length)return [];ensureMeta(m);
|
|
4312
4593
|
const out=[];for(const def of PROP_DEFS){if(!pl.props.includes(def.key))continue;const raw=def.get(m);if(raw===undefined)continue;const t=def.fmt(raw);if(t==='')continue;out.push(def.label+': '+t);}return out;}
|
|
4313
4594
|
// members that actually get a label, honouring the plan-wide-vs-selected-only scope
|
|
4314
4595
|
function propLabelMembers(){const pl=C.prop_labels;if(!pl||!pl.props.length)return [];
|
|
4315
|
-
|
|
4596
|
+
// PER-SHEET for v1, and that is not incidental: renderPropLabels draws each chip at the member's
|
|
4597
|
+
// plan-local PIXEL coordinates into the ACTIVE sheet's SVG, so an off-sheet member would be painted in
|
|
4598
|
+
// the wrong place on any multi-sheet project. A repair briefly widened this to allMembers() to stop a
|
|
4599
|
+
// v2 TypeError and introduced exactly that regression; the v2 half is what needed the model-wide list.
|
|
4600
|
+
let base=MODEL_RO?modelMembersV2():P.members;
|
|
4601
|
+
if(pl.selected_only){const ids=new Set(pl.ids||[]);base=base.filter(m=>ids.has(m.id));}
|
|
4316
4602
|
return base.filter(m=>propLabelLinesFor(m).length>0);}
|
|
4317
4603
|
// one popup row's aggregate across the current selection: a shared value, "Varies", or N/A (disabled)
|
|
4318
4604
|
function propAggRow(def,arr){let anyApplicable=false,anyNonEmpty=false;const vals=[];
|
|
@@ -4344,7 +4630,7 @@ function renderSelLenLabels(){if(!showSelLen)return '';const selM=sel2d();if(!se
|
|
|
4344
4630
|
s+=`<rect class=mlenchip ${dd} data-tw="${tw}" x="${cx-w/2}" y="${cy-hh/2}" width="${w}" height="${hh}" rx="${3/zoom}" style="${hide}"/>`
|
|
4345
4631
|
+`<text class=mlentx ${dd} x="${cx}" y="${cy}" style="font-size:${11/zoom}px${hide}">${esc(txt)}</text>`;});}
|
|
4346
4632
|
return s?`<g class="mlenlabels">${s}</g>`:'';}
|
|
4347
|
-
function renderPropLabels(){const pl=C.prop_labels;propLabelsHidden=0;if(!pl||!pl.props.length||!
|
|
4633
|
+
function renderPropLabels(){const pl=C.prop_labels;propLabelsHidden=0;if(!pl||!pl.props.length||!plVis(false))return ''; // vis2d off → no 2D chips (B1); propLabelsHidden stays 0 so the "zoom in" pill also stays suppressed
|
|
4348
4634
|
const ms=propLabelMembers();if(!ms.length)return '';
|
|
4349
4635
|
let hidden=0,s='';
|
|
4350
4636
|
// Emit chips for EVERY labelled member (carrying its display length in data-mlen); the zoom threshold
|
|
@@ -4371,7 +4657,7 @@ function updatePropHint(){let el=document.getElementById('plHint');
|
|
|
4371
4657
|
// ---- 3D bridge: hand the label spec to the 3D view (it owns projection/placement over member geometry) ----
|
|
4372
4658
|
function refreshPropLabels3d(){const V=window.Steel3DView;if(!V||!V.setPropLabels)return;
|
|
4373
4659
|
const pl=C.prop_labels;
|
|
4374
|
-
if(!pl||!pl.props.length||!
|
|
4660
|
+
if(!pl||!pl.props.length||!plVis(true)){V.setPropLabels(null);return;} // vis3d off → clear the 3D labels (B1 per-view visibility)
|
|
4375
4661
|
V.setPropLabels({labels:propLabelMembers().map(m=>({id:m.id,lines:propLabelLinesFor(m)})),placement:pl.placement});}
|
|
4376
4662
|
|
|
4377
4663
|
// ---- The floating Properties popup ----
|
|
@@ -4406,7 +4692,7 @@ function propPopEl(){let el=document.getElementById('propPop');if(el)return el;
|
|
|
4406
4692
|
el.querySelector('#ppPlace').addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;C.prop_labels.placement=b.dataset.pl;refreshPropLabels();});
|
|
4407
4693
|
el.querySelector('#ppSel').addEventListener('change',e=>{const pl=C.prop_labels;pl.selected_only=e.target.checked;if(pl.selected_only)pl.ids=selArr().map(m=>m.id);refreshPropLabels();});
|
|
4408
4694
|
el.querySelector('#ppVis').addEventListener('change',e=>{const pl=C.prop_labels; // B1: per-view label visibility, right where labels are managed — bound to the view you're currently in
|
|
4409
|
-
if(view3d){pl.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();}else{pl.vis2d=e.target.checked;refreshPropLabels();}}); // 2D refreshPropLabels()=scheduleSave+render (updPlToggle re-syncs the ⋯ Display toggle); 3D pushes to the view
|
|
4695
|
+
if(!canWritePropLabelVis())return; if(view3d){pl.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();}else{pl.vis2d=e.target.checked;refreshPropLabels();}}); // 2D refreshPropLabels()=scheduleSave+render (updPlToggle re-syncs the ⋯ Display toggle); 3D pushes to the view
|
|
4410
4696
|
// focus trap + Esc (behaves as a lightweight non-modal dialog)
|
|
4411
4697
|
el.addEventListener('keydown',e=>{if(e.key==='Escape'){e.stopPropagation();closePropPop(true);return;}
|
|
4412
4698
|
if(e.key!=='Tab')return;const f=[...el.querySelectorAll('button,input,[tabindex]')].filter(n=>!n.disabled&&n.offsetParent!==null);
|
|
@@ -4429,7 +4715,7 @@ function renderPropPop(){const el=document.getElementById('propPop');if(!el||!el
|
|
|
4429
4715
|
el.querySelector('#ppScope').textContent=arr.length+(arr.length===1?' member · ':' members · ')+(pl.selected_only?'labels apply to the selected':'labels apply to all on this plan');
|
|
4430
4716
|
el.querySelectorAll('#ppPlace button').forEach(b=>b.classList.toggle('on',b.dataset.pl===pl.placement));
|
|
4431
4717
|
el.querySelector('#ppSel').checked=pl.selected_only;
|
|
4432
|
-
{const v=el.querySelector('#ppVis');if(v)v.checked=view3d
|
|
4718
|
+
{const v=el.querySelector('#ppVis');if(v){v.checked=plVis(view3d);if(!canWritePropLabelVis())v.disabled=true;}} // reflect the CURRENT view's visibility flag (self-heals a pinned popup across a 2D↔3D switch)
|
|
4433
4719
|
const ae=document.activeElement,fk=(ae&&ae.closest&&ae.closest('.pprow'))?ae.closest('.pprow').dataset.k:null;
|
|
4434
4720
|
let shown=0;const rows=PROP_DEFS.map(def=>{
|
|
4435
4721
|
if(q&&!def.label.toLowerCase().includes(q))return '';
|
|
@@ -5147,12 +5433,12 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
5147
5433
|
else{const a=gridLinePick.a.slice(),b=[x,y],pv=snapshot();if(gridAddFreeLine(a,b)){pushUndo(pv);gridCancelLinePick();render();refresh3DGrid();}else panel();}
|
|
5148
5434
|
e.preventDefault();return;}
|
|
5149
5435
|
if(gridPick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear(); // armed pick-origin → one snapped click sets the grid's 1-A corner (undoable)
|
|
5150
|
-
gridPick=false;gridSetPickClass();if(
|
|
5436
|
+
gridPick=false;gridSetPickClass();if(gridOf())editGrid(()=>{ModelCmd.patchGrid(gridOf(),{origin:[x,y]});});else panel();e.preventDefault();return;}
|
|
5151
5437
|
if(qdPick&&(view3d||mode!=='sel'||dimMode||csaxisMode||geoMode||cmTool||picking||dimSplitMode)){qdPick=null;setQdPickCls();} // a stale F7 station pick must never fire while/after ANOTHER tool runs — the first click under that tool disarms it instead (Codex final-review #3)
|
|
5152
5438
|
if(qdPick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear();const pp=qdPick;qdPick=null;setQdPickCls();quickDimSpacing(pp.pt,[x,y]);e.preventDefault();return;} // F7 grid quick-dim: the armed one-shot station pick consumes this click BEFORE the grid-line hit test — the picked station often lies ON a grid line, which must not start a grid drag instead (Codex final-review #6)
|
|
5153
5439
|
{const gb=t.closest&&t.closest('g.gridbubg'),ghit=(t.classList&&t.classList.contains('gridhit'))?t:null; // grid line body OR label bubble → drag slides the line; a no-move click selects it (bubble double-click still renames)
|
|
5154
5440
|
const gel=gb||ghit;
|
|
5155
|
-
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&
|
|
5441
|
+
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&gridOf()&&gridDragAllowed()){
|
|
5156
5442
|
const free=gel.dataset.gl!=null,axis=free?'l':(gel.dataset.gv!=null?'v':'h'),gi=+(free?gel.dataset.gl:(gel.dataset.gv!=null?gel.dataset.gv:gel.dataset.gh));
|
|
5157
5443
|
if(isFinite(gi)){buildSnap(null,{noGrid:true,noDims:true});const q=toSvg(e);const geo=gridGeo();const line=geo&&(free?(geo.lines||[])[gi]:geo[axis][gi]);
|
|
5158
5444
|
if(line){const end=gb?+(gb.dataset.end||0):null; // a bubble grab can become an END drag; a body grab translates the line
|
|
@@ -5242,7 +5528,7 @@ svg.addEventListener('pointermove',e=>{
|
|
|
5242
5528
|
if(!drag)return;const p=toSvg(e);
|
|
5243
5529
|
if(drag.type==='gridfree'){const dxc=p.x-drag.startPt[0],dyc=p.y-drag.startPt[1];
|
|
5244
5530
|
if(!drag.moved){if(Math.hypot(dxc,dyc)<=4/zoom)return;drag.moved=true;}
|
|
5245
|
-
const line=
|
|
5531
|
+
const _dg=gridOf();const line=_dg&&_dg.lines&&_dg.lines[drag.gi];if(!line||!gridDragAllowed())return;
|
|
5246
5532
|
let a=drag.origA.slice(),b=drag.origB.slice();
|
|
5247
5533
|
if(drag.end!=null){const target=drag.end===0?a:b;let x=target[0]+dxc,y=target[1]+dyc;
|
|
5248
5534
|
if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
@@ -5272,7 +5558,8 @@ svg.addEventListener('pointermove',e=>{
|
|
|
5272
5558
|
for(const q of snapPts){const c=drag.axis==='v'?q[0]:q[1];const d=Math.abs(c-np);if(d<bd){bd=d;bp=c;}}
|
|
5273
5559
|
if(bp!=null){np=bp;snapMark(drag.axis==='v'?np:p.x,drag.axis==='v'?p.y:np,'line');}else snapClear();}
|
|
5274
5560
|
else snapClear();
|
|
5275
|
-
|
|
5561
|
+
if(!gridDragAllowed())return;
|
|
5562
|
+
const applied=ModelCmd.moveGridLine(gc,gridOf(),ppf,drag.axis,drag.gi,np,drag.base); // clamps between neighbours, rebases origin on line 1/A
|
|
5276
5563
|
const geo=gridGeo(),lines=geo?geo[drag.axis]:null; // live readout: how far it moved + the bay it resizes
|
|
5277
5564
|
let sub='';
|
|
5278
5565
|
if(lines&&lines.length>1){const pos=(l)=>drag.axis==='v'?l.x:l.y;const bay=drag.gi>0?Math.abs(pos(lines[drag.gi])-pos(lines[drag.gi-1])):Math.abs(pos(lines[1])-pos(lines[0]));sub=' · bay '+dimValueText(bay);}
|
|
@@ -5283,7 +5570,8 @@ svg.addEventListener('pointermove',e=>{
|
|
|
5283
5570
|
for(const q of snapPts){const c=drag.axis==='v'?q[1]:q[0];const d=Math.abs(c-np);if(d<bd){bd=d;bp=c;}}
|
|
5284
5571
|
if(bp!=null){np=bp;snapMark(drag.axis==='v'?drag.orig:np,drag.axis==='v'?np:drag.orig,'end');}else snapClear();}
|
|
5285
5572
|
else snapClear();
|
|
5286
|
-
|
|
5573
|
+
if(!gridDragAllowed())return;
|
|
5574
|
+
const applied=ModelCmd.moveGridLineEnd(gc,gridOf(),ppf,drag.axis,drag.gi,drag.end,np); // 12" min length; near the full span → back to auto
|
|
5287
5575
|
gridReadout(e,gridDelta((applied!=null?applied:np)-drag.origEnd),'');
|
|
5288
5576
|
}
|
|
5289
5577
|
refreshGridLayer();refreshMagneticDims2D(); // moveGridLine mutates P.grid LIVE — grid-anchored dims must track the drag, not jump at pointer-up (Codex final-review #2)
|
|
@@ -5383,7 +5671,7 @@ svg.addEventListener('pointercancel',()=>{epPrevClear();if(!drag)return; // a
|
|
|
5383
5671
|
svg.addEventListener('dblclick',e=>{ // dbl-click a grid bubble → rename that label in place
|
|
5384
5672
|
const at=document.elementFromPoint(e.clientX,e.clientY); // the pointer capture the drag takes retargets dblclick to the svg root — resolve the bubble by position, not e.target
|
|
5385
5673
|
const gb=at&&at.closest&&at.closest('g.gridbubg');
|
|
5386
|
-
if(gb&&mode==='sel'&&
|
|
5674
|
+
if(gb&&mode==='sel'&&gridOf()&&!dimMode&&!csaxisMode&&!geoMode&&!picking){
|
|
5387
5675
|
e.preventDefault();
|
|
5388
5676
|
gridRenameBubble(gb.dataset.gl!=null?'l':(gb.dataset.gv!=null?'v':'h'),+(gb.dataset.gl!=null?gb.dataset.gl:(gb.dataset.gv!=null?gb.dataset.gv:gb.dataset.gh)),gb.querySelector('circle'));}});
|
|
5389
5677
|
function setMode(){document.body.classList.toggle('add',mode==='add');document.getElementById('mAdd').classList.toggle('on',mode==='add');
|
|
@@ -5429,11 +5717,110 @@ function updLenToggle(){const b=document.getElementById('lenToggleB');if(b){b.cl
|
|
|
5429
5717
|
document.getElementById('lenToggleB').onclick=e=>{e.stopPropagation();showSelLen=!showSelLen;try{localStorage.setItem('steel:selLen:v1',showSelLen?'1':'0');}catch(_){}updLenToggle();render();}; // render() repaints the 2D chips + pushes labels to 3D
|
|
5430
5718
|
function updCalloutToggle(){const b=document.getElementById('calloutToggleB');if(b){b.classList.toggle('on',calloutsVisible);b.setAttribute('aria-checked',String(calloutsVisible));}}
|
|
5431
5719
|
document.getElementById('calloutToggleB').onclick=e=>{e.stopPropagation();calloutsVisible=!calloutsVisible;updCalloutToggle();render();};
|
|
5432
|
-
function updPlToggle(){const b=document.getElementById('plToggleB');if(b){const on=!!(C.prop_labels&&
|
|
5433
|
-
document.getElementById('plToggleB').onclick=e=>{e.stopPropagation();C.prop_labels.vis2d=!C.prop_labels.vis2d;updPlToggle();refreshPropLabels();}; // refreshPropLabels → scheduleSave()+render(): repaints the 2D chips (gated by vis2d) and persists the choice
|
|
5720
|
+
function updPlToggle(){const b=document.getElementById('plToggleB');if(b){const on=!!(C.prop_labels&&plVis(false));b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on));}} // B1: 2D property-label visibility (independent of 3D)
|
|
5721
|
+
document.getElementById('plToggleB').onclick=e=>{e.stopPropagation();if(!canWritePropLabelVis())return;C.prop_labels.vis2d=!C.prop_labels.vis2d;updPlToggle();refreshPropLabels();}; // refreshPropLabels → scheduleSave()+render(): repaints the 2D chips (gated by vis2d) and persists the choice
|
|
5434
5722
|
function updRefToggle(){const b=document.getElementById('refToggleB');if(!b)return;b.disabled=!hasOverlay();b.classList.toggle('on',refSheetOn);b.setAttribute('aria-checked',String(refSheetOn));} // F13: grey the row out on a plan with no reference sheet (mirrors updGridToggle's no-grid disable)
|
|
5435
5723
|
document.getElementById('refToggleB').onclick=e=>{e.stopPropagation();refSheetOn=!refSheetOn;try{localStorage.setItem('steel:refSheet:v1',refSheetOn?'1':'0');}catch(_){}updRefToggle();render();}; // render() rebuilds the SVG (overlaySvg gone/back) and buildSnap re-reads overlaySnapGeom (snap candidates gone/back)
|
|
5436
5724
|
document.getElementById('gridEditB').onclick=()=>{setGridMode(!gridMode);render();};
|
|
5725
|
+
{const ghb=document.getElementById('gridHdrB');if(ghb)ghb.onclick=()=>{setGridMode(!gridMode);render();};} // the header twin (read-only mode only) — same one action, not a second implementation
|
|
5726
|
+
/**
|
|
5727
|
+
* The read-only CHROME (unit 5, P7d §8.5).
|
|
5728
|
+
*
|
|
5729
|
+
* Disabled, never removed. A user who migrated a project and finds the draw tools simply GONE will
|
|
5730
|
+
* conclude the editor is broken or their model is damaged; a disabled control with a reason says the model
|
|
5731
|
+
* is fine and the editor is catching up, which is the truth. (The header STATS are the deliberate
|
|
5732
|
+
* exception, and the reason is stated at stats(): a readout has nothing to act on, so an absent one beats
|
|
5733
|
+
* a wrong one.)
|
|
5734
|
+
*
|
|
5735
|
+
* Disabled at the HIGHEST COHERENT LEVEL — eight anchors rather than the several dozen leaves under them.
|
|
5736
|
+
* A menu section header carries its whole section; dimming every row inside it says the same thing forty
|
|
5737
|
+
* times. And every one points aria-describedby at the ribbon, because data-tip is hover-driven and reaches
|
|
5738
|
+
* neither a keyboard nor a screen-reader user.
|
|
5739
|
+
*
|
|
5740
|
+
* NOT disabled, and each for a reason: Undo/Redo (the grid edit is undoable), Ask AI (it IS the review
|
|
5741
|
+
* path this mode points at), Save/Approve/the export group (a v2 model exports — P7b wired those routes),
|
|
5742
|
+
* the 2D/3D toggle (locking it was rejected: the user should be able to look at the empty plan and read
|
|
5743
|
+
* why), and ⋯ → Display, whose rows are view state.
|
|
5744
|
+
*/
|
|
5745
|
+
const RO_ANCHORS=['mAdd','dimB','xfB','m3dDim']; // the two 2D write tools, the Move/Copy menu, and the 3D twin of the Dimension tool
|
|
5746
|
+
// The ⋯ sections whose ROWS write the model. Named once, so the disable and the stay-shut rule above
|
|
5747
|
+
// cannot drift apart — the header ids follow from these. `display` is absent deliberately: its rows are
|
|
5748
|
+
// view state, and Grid lines… lives there.
|
|
5749
|
+
const RO_LOCKED_SECS=['detailing','checks','snap'];
|
|
5750
|
+
function applyReadOnlyChrome(){
|
|
5751
|
+
if(!MODEL_RO)return;
|
|
5752
|
+
document.body.classList.add('model-ro');
|
|
5753
|
+
const gh=document.getElementById('gridHdrB');if(gh)gh.style.display='';
|
|
5754
|
+
const off=el=>{if(!el)return;el.disabled=true;el.setAttribute('aria-describedby','roRibbon');};
|
|
5755
|
+
for(const id of RO_ANCHORS)off(document.getElementById(id));
|
|
5756
|
+
roDisablePropLabelToggles();
|
|
5757
|
+
// The ⋯ menu's write sections, by section rather than by row. `display` is deliberately absent: its rows
|
|
5758
|
+
// are view state (what is shown), not model state — and Grid lines… lives there. Addressed by ID rather
|
|
5759
|
+
// than by attribute selector so the headless harness can see them: `getElementById` is what its DOM stub
|
|
5760
|
+
// models, and a querySelector here would have gone quietly no-op there while working in a browser — a
|
|
5761
|
+
// test that passes for the wrong reason.
|
|
5762
|
+
// …and CLOSED, not merely disabled. `openSecs` is restored from a localStorage key that is not scoped
|
|
5763
|
+
// to the project, so someone who last left Detailing open in a v1 project opens a migrated one with it
|
|
5764
|
+
// already expanded and every row inside it clickable — over a header that can no longer close it.
|
|
5765
|
+
// Disabling stops the CLICK; it does not undo the restore. Both halves happen here, in one place,
|
|
5766
|
+
// addressed by id, because the restore loop itself is querySelectorAll-driven and a guard there could
|
|
5767
|
+
// never be proven headless. (unit 5, P7d.)
|
|
5768
|
+
for(const id of ['secDetailingHdr','secChecksHdr','snapHdr']){ // the header ids for RO_LOCKED_SECS
|
|
5769
|
+
const h=document.getElementById(id);off(h);
|
|
5770
|
+
if(!h)continue;
|
|
5771
|
+
h.setAttribute('aria-expanded','false');
|
|
5772
|
+
const body=h.nextElementSibling;
|
|
5773
|
+
if(body&&body.classList&&typeof body.classList.remove==='function')body.classList.remove('open');
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
/**
|
|
5777
|
+
* The saved-view LIBRARY is model data, so a read-only document does not edit it (unit 5, P7d §8.5).
|
|
5778
|
+
*
|
|
5779
|
+
* Disabling the three header buttons was not enough, and Codex's H9 is what measured that: the per-row
|
|
5780
|
+
* rename, duplicate, update-to-current, delete and drag-reorder all write `C.views` too. Two of them
|
|
5781
|
+
* (save and update-to-current) re-capture through `captureView()`, which mints `projection` — a v1-only
|
|
5782
|
+
* key v2's closed `view` schema forbids — so those corrupt outright; the rest are schema-legal but are
|
|
5783
|
+
* still edits to the model, which this mode says it does not make.
|
|
5784
|
+
*
|
|
5785
|
+
* Gated at every WRITER — addView, duplicateView, updateViewToCurrent, deleteView, the rename commit,
|
|
5786
|
+
* the drag reorder, and createGeneratedViews — not only at the chrome, so a menu item or a keyboard path
|
|
5787
|
+
* cannot slip past. The generated-views one was the sixth, found by a review round aimed at this repair;
|
|
5788
|
+
* its launcher is disabled and its modal refuses a v2 grid anyway, which is exactly why an unguarded
|
|
5789
|
+
* writer behind two closed doors is worth guarding rather than reasoning about.
|
|
5790
|
+
*/
|
|
5791
|
+
function canWriteViews(){return canWriteModel();}
|
|
5792
|
+
/**
|
|
5793
|
+
* Mark a non-BUTTON affordance as unavailable, with the ribbon as its reason.
|
|
5794
|
+
*
|
|
5795
|
+
* The Views rows use `<span>`s, and `disabled` means nothing on a span — an untouched one still looks
|
|
5796
|
+
* live, takes the click, and does nothing, which is worse than either disabling or hiding it.
|
|
5797
|
+
*/
|
|
5798
|
+
function roLock(el){
|
|
5799
|
+
if(!MODEL_RO||!el)return el;
|
|
5800
|
+
el.setAttribute('aria-disabled','true');el.setAttribute('aria-describedby','roRibbon');
|
|
5801
|
+
el.style.opacity='.4';el.style.pointerEvents='none';el.style.cursor='default';
|
|
5802
|
+
return el;}
|
|
5803
|
+
/**
|
|
5804
|
+
* The two controls that set the per-view label flag — a key v2's closed `prop_labels` does not have.
|
|
5805
|
+
*
|
|
5806
|
+
* Separate from applyReadOnlyChrome's anchor list because `m3dPropLabels` lives in the 3D legend, which is
|
|
5807
|
+
* built lazily by build3DLegend() long after boot; disabling it once at boot would miss it.
|
|
5808
|
+
*/
|
|
5809
|
+
function roDisablePropLabelToggles(){
|
|
5810
|
+
if(!MODEL_RO)return;
|
|
5811
|
+
for(const id of ['plToggleB','m3dPropLabels']){
|
|
5812
|
+
const el=document.getElementById(id);
|
|
5813
|
+
if(el){el.disabled=true;el.setAttribute('aria-describedby','roRibbon');}
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
/** The Views tab's header write actions, disabled on each render (the tab rebuilds its own buttons). */
|
|
5817
|
+
function roDisableViewWrites(){
|
|
5818
|
+
if(!MODEL_RO)return;
|
|
5819
|
+
for(const id of ['vwSaveBtn','vwSaveMore','vwGenerateBtn']){
|
|
5820
|
+
const el=document.getElementById(id);
|
|
5821
|
+
if(el){el.disabled=true;el.setAttribute('aria-describedby','roRibbon');}
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5437
5824
|
document.getElementById('dimStyleB').onclick=()=>{setDimStyleMode(!dimStyleMode);render();};
|
|
5438
5825
|
document.getElementById('gridToggleB').onclick=e=>{e.stopPropagation();gridSetVisible(!gridOn());};
|
|
5439
5826
|
document.getElementById('dupB').onclick=()=>{const ids=redundantDups(); // re-scan on demand (also runs live after every edit)
|
|
@@ -5507,14 +5894,14 @@ addEventListener('keydown',e=>{
|
|
|
5507
5894
|
if((e.key==='Delete'||e.key==='Backspace')&&selIsConnOnly()&&!selDimIds.size&&!selGridIds.size&&!inForm){e.preventDefault();deleteSelConns();return;} // a PURE connection selection (one or many) removes those joints — matches the side-pane Delete. A mix with grids/members falls through to the general branch (which now also strips the selected joints), so nothing co-selected is silently left behind.
|
|
5508
5895
|
if((e.key==='Delete'||e.key==='Backspace')&&(selDimIds.size||selIds.size||selGridIds.size)&&!inForm){e.preventDefault(); // deletes everything selected — dims and/or members and/or (free) grid lines (a marquee can hold all)
|
|
5509
5896
|
const glLids=new Set([...selGridIds].filter(id=>id.startsWith('gl:')).map(id=>id.slice(3))); // selected free-line STABLE ids — delete by identity, not geo index (gridLines() drops degenerate entries so indices can skew)
|
|
5510
|
-
const freeToDelete=(
|
|
5897
|
+
const _kg=gridOf();const freeToDelete=(_kg&&Array.isArray(_kg.lines))?_kg.lines.filter(l=>glLids.has(String(l.id))):[]; // only lines that actually still exist → also guards the phantom-undo case (list cleared out from under the selection)
|
|
5511
5898
|
const hadReg=[...selGridIds].some(id=>id.startsWith('gv:')||id.startsWith('gh:')); // regular (spacing-generated) lines can't be individually deleted
|
|
5512
5899
|
const willMutate=selDimIds.size||selIds.size||freeToDelete.length;
|
|
5513
5900
|
if(willMutate)edit(()=>{
|
|
5514
5901
|
if(selDimIds.size){P.dims=P.dims.filter(d=>!selDimIds.has(d.id));selDimIds.clear();}
|
|
5515
5902
|
if(selIds.size){const jids=selJointIds();if(jids.size)C.joints=(C.joints||[]).filter(j=>!(j&&jids.has(j.id))); // any selected connection parts → remove their joints too (a mixed member+connection or connection+grid Delete)
|
|
5516
5903
|
for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));selIds.clear();} // selection spans sheets → remove from every plane, not just the active one
|
|
5517
|
-
if(freeToDelete.length)ModelCmd.removeGridLines(
|
|
5904
|
+
if(freeToDelete.length)ModelCmd.removeGridLines(gridOf(),glLids);
|
|
5518
5905
|
selGridIds.clear();});
|
|
5519
5906
|
else{selGridIds.clear();render();} // only regular grid lines were selected → nothing to delete (no phantom undo step); repaint to drop the highlight
|
|
5520
5907
|
if(hadReg)toast('Regular grid lines come from the grid spacing — remove them in “Grid lines…”. Only free grid lines are deletable here.');
|
|
@@ -5748,14 +6135,122 @@ async function sendSelectionToTekla(ids){
|
|
|
5748
6135
|
}finally{teklaSendBusy=false;}
|
|
5749
6136
|
}
|
|
5750
6137
|
|
|
6138
|
+
/* ───────────────────────── the MODEL READ HALF handed to the 3D view (unit 5, P7d) ─────────────────────
|
|
6139
|
+
*
|
|
6140
|
+
* ONE object, resolved once by `steel-3d-view.js`, answering every geometry question that view asks. The
|
|
6141
|
+
* contract VERSION is decided HERE and nowhere else — epic §15 answer 4: the gate at the adapter boundary,
|
|
6142
|
+
* not scattered `if (v2)` branches through the editor closure or the view.
|
|
6143
|
+
*
|
|
6144
|
+
* Everything below answers in the space the 3D scene uses. What differs between the arms is not a detail:
|
|
6145
|
+
* v1 stores members and the grid in one SHEET's display pixels, Y growing DOWN the page, elevations in
|
|
6146
|
+
* inches, and each sheet may have its OWN px→ft scale — so every read is a per-plan conversion.
|
|
6147
|
+
* v2 stores members and the ONE model grid in world millimetres with Y up. No scale, no flip, no
|
|
6148
|
+
* inches, no per-plan anything.
|
|
6149
|
+
*
|
|
6150
|
+
* THE v2 ARM ANSWERS ONLY WHAT IT CAN ANSWER TRUTHFULLY, and REFUSES the rest by throwing (§8.3). The
|
|
6151
|
+
* three reads that would be plausible-but-false if defaulted are named at their sites. A silent `[]` or a
|
|
6152
|
+
* substituted default is the exact defect `steel-model-adapter.js`'s own `sheetFrame()` refuses to ship —
|
|
6153
|
+
* and it is worse here, because a wrong position looks right.
|
|
6154
|
+
*/
|
|
6155
|
+
/**
|
|
6156
|
+
* PROPERTY-LABEL VISIBILITY: a display flag v2's schema does not have (unit 5, P7d).
|
|
6157
|
+
*
|
|
6158
|
+
* v1's `prop_labels` is `additionalProperties: true`, and the editor stores a per-view `vis2d`/`vis3d`
|
|
6159
|
+
* there. v2 CLOSED that object to `props`/`placement`/`selected_only`/`ids`, so writing either key
|
|
6160
|
+
* corrupts the document — the save is then refused for a toggle the user flicked, which is precisely the
|
|
6161
|
+
* failure §8.4 is about. Found by Codex's H9, not by the schema check, because the write happens on a
|
|
6162
|
+
* click rather than at boot.
|
|
6163
|
+
*
|
|
6164
|
+
* So for v2 the flag is REFUSED at the write, and `roDisablePropLabelToggles()` actually disables the two
|
|
6165
|
+
* controls that set it — the first version of this repair refused the write and left both looking live,
|
|
6166
|
+
* which is the silent no-op this whole mode exists to avoid.
|
|
6167
|
+
*
|
|
6168
|
+
* AND THE READ ANSWERS OFF. A draft of this said the honest read of an absent flag is ON, since v2 has no
|
|
6169
|
+
* per-view visibility concept — and a real browser pass proved that wrong immediately, with a TypeError:
|
|
6170
|
+
* answering ON sends `refreshPropLabels3d` on into `propLabelMembers`, and the label CONTENT
|
|
6171
|
+
* (`propLabelLinesFor`) is a v1-shaped derivation over `m.tos`/`m.col`/the plan's member list. There is
|
|
6172
|
+
* nothing behind the flag that can produce a correct label for a v2 member, so OFF is the true answer and
|
|
6173
|
+
* "no stored flag" was the wrong thing to reason from. Porting that derivation is a later unit's.
|
|
6174
|
+
*
|
|
6175
|
+
* This is the same line drawn everywhere else in this mode: display state stays live where v2's schema
|
|
6176
|
+
* allows it (`dim_overlays` is open, and its toggles are untouched), and is refused where v2 closed it.
|
|
6177
|
+
*/
|
|
6178
|
+
function canWritePropLabelVis(){return canWriteModel();}
|
|
6179
|
+
function plVis(is3d){if(MODEL_RO)return false;const pl=C&&C.prop_labels;return !!(pl&&(is3d?pl.vis3d:pl.vis2d));}
|
|
6180
|
+
/** v2's ONE root member array. Not a plan property — see §8.3 on why reading `C.plans[].members` is worse than useless here. */
|
|
6181
|
+
function modelMembersV2(){return (C&&Array.isArray(C.members))?C.members:[];}
|
|
6182
|
+
/** Refuse a read the v2 arm cannot answer truthfully. THROWS — never a default, never a silent empty. */
|
|
6183
|
+
function v2Refuse(what){throw new Error('steel.model/v2: '+what);}
|
|
6184
|
+
const V2_GRID_OPTS={yUp:true}; // v2's grid is world mm, Y up — see grid-core gridGeometry's `opts.yUp`
|
|
6185
|
+
// grid-core's grid helpers take a `ptPerFt` and divide by `mmPerPx(ptPerFt) = 304.8/ptPerFt`. A v2 grid is
|
|
6186
|
+
// ALREADY world mm, so the conversion must be the IDENTITY, and 304.8 pt/ft is the value that makes it one.
|
|
6187
|
+
// Named rather than inlined so it reads as "no conversion" and never as a plan's drawing scale — reporting
|
|
6188
|
+
// it through `api.ptPerFt()` would be exactly the plausible-but-false answer §8.3 refuses.
|
|
6189
|
+
const V2_PT_PER_FT=304.8;
|
|
6190
|
+
function modelReadsV1(){
|
|
6191
|
+
// Everything in here is the computation steel-3d-view.js used to do inline. It MOVED; it did not change.
|
|
6192
|
+
// The cache moved with it — resolving a member's scale per call re-scanned every plan and turned the
|
|
6193
|
+
// model-wide per-member loops (labels, endpoints, reference lines, membersInRect) quadratic. The view
|
|
6194
|
+
// still owns WHEN to drop it (buildFromScene / rebuild / a grid edit) and calls invalidate().
|
|
6195
|
+
let scaleIdx=null;
|
|
6196
|
+
const activeScale=()=>({ptPerFt:(P&&P.pt_per_ft>0?P.pt_per_ft:1),defaultTosMm:(defaultTOS!=null?defaultTOS*25.4:0)});
|
|
6197
|
+
const planList=()=>((C&&Array.isArray(C.plans))?C.plans:[]).map(p=>({members:p.members||[],ptPerFt:(p.pt_per_ft>0?p.pt_per_ft:1),defaultTosMm:(p.default_tos!=null?p.default_tos:0)*25.4})); // every sheet WITH its OWN px→ft scale AND its OWN default T.O.S, exactly as the server bake resolves them (contract-to-scene). Guards a not-yet-loaded contract so a hover can't throw out of the pointer handler.
|
|
6198
|
+
const scaleIndex=()=>{if(!scaleIdx){try{scaleIdx=SteelCore.planScaleIndex(planList(),activeScale());}catch(_){return new Map();}}return scaleIdx;}; // a transient failure returns an empty index WITHOUT caching it — caching one would silently downgrade every member to the active scale until the next rebuild
|
|
6199
|
+
return {
|
|
6200
|
+
invalidate(){scaleIdx=null;},
|
|
6201
|
+
geometryOf:m=>SteelCore.memberGeometryInOwnPlan(m,scaleIndex(),activeScale()),
|
|
6202
|
+
scaleOf:m=>SteelCore.planScaleOf(scaleIndex(),m,activeScale()), // keyed by the member OBJECT — ids are only sheet-unique
|
|
6203
|
+
defaultPlaneZ:()=>activeScale().defaultTosMm,
|
|
6204
|
+
memberCandidates(excludeId){const dtos=activeScale().defaultTosMm;
|
|
6205
|
+
return planList().flatMap(pl=>SteelCore.snapCandidates(pl.members,pl.ptPerFt,pl.defaultTosMm!=null?pl.defaultTosMm:dtos,excludeId));}, // each sheet's OWN default T.O.S — a default-elevation member on a non-active sheet must snap at the level it RENDERS at
|
|
6206
|
+
gridCandidates(){const gc=GC();return gc?gc.gridCandidates3d((P&&P.grid)||null,activeScale().ptPerFt):[];},
|
|
6207
|
+
levels:excludeMember=>SteelCore.elevationLevelsByPlan(planList(),activeScale(),excludeMember),
|
|
6208
|
+
levelsHere:()=>SteelCore.elevationLevels((P&&P.members)||[],activeScale().ptPerFt,activeScale().defaultTosMm,null),
|
|
6209
|
+
gridDraw(){const gc=GC();if(!gc)return null; // grid-core is an ES module and this is the classic script; null here is the same "grid tools still loading" state renderGridPanel shows, and nothing can reach 3D before a module script has run
|
|
6210
|
+
const g=(P&&P.grid)||null;if(!g||g.on===false)return null;
|
|
6211
|
+
return {g,geo:gc.gridGeometry(g,activeScale().ptPerFt),k:gc.mmPerPx(activeScale().ptPerFt),flipY:true};}, // display px, Y down → the view flips it
|
|
6212
|
+
};
|
|
6213
|
+
}
|
|
6214
|
+
function modelReadsV2(){
|
|
6215
|
+
const mem=()=>(C&&Array.isArray(C.members))?C.members:[]; // v2 holds ONE root member array — not a plan property at all
|
|
6216
|
+
const refuse=(what)=>{throw new Error('steel.model/v2: '+what);};
|
|
6217
|
+
return {
|
|
6218
|
+
invalidate(){}, // nothing is cached: a v2 member carries its own world-mm coordinates, so there is no per-plan scale to index
|
|
6219
|
+
geometryOf:m=>SteelCore.memberGeometryV2(m),
|
|
6220
|
+
// A v2 member has no owning plan and no scale. This is only ever asked by a WRITE path (the member
|
|
6221
|
+
// drag, the endpoint drag, split), every one of which is refused — so reaching it is a bug, and a
|
|
6222
|
+
// throw says so instead of inverting a commit through a fabricated scale.
|
|
6223
|
+
scaleOf:()=>refuse('a member has no owning-sheet scale — it is stored in world mm'),
|
|
6224
|
+
// NOT `defaultTosMm`. v1's is the active SHEET's fallback top-of-steel for blank ends; v2 has no such
|
|
6225
|
+
// thing (migration materialised every elevation explicitly), and substituting one here would silently
|
|
6226
|
+
// relocate the working plane. What this actually answers is where the default working plane sits with
|
|
6227
|
+
// no local frame set, and for a world-mm model that is the world datum.
|
|
6228
|
+
defaultPlaneZ:()=>0,
|
|
6229
|
+
memberCandidates:excludeId=>SteelCore.snapCandidatesV2(mem(),excludeId),
|
|
6230
|
+
gridCandidates(){const gc=GC(),g=(C&&C.grid)||null;return (gc&&g)?gc.gridCandidates3d(g,V2_PT_PER_FT,V2_GRID_OPTS):[];},
|
|
6231
|
+
levels:excludeMember=>SteelCore.elevationLevelsV2(mem(),excludeMember?excludeMember.id:null),
|
|
6232
|
+
// v1 distinguishes "levels on the ACTIVE sheet" from "levels across every sheet". v2 has one model, so
|
|
6233
|
+
// there is one answer and both questions get it — that is a real property of the format, not a shortcut.
|
|
6234
|
+
levelsHere:()=>SteelCore.elevationLevelsV2(mem(),null),
|
|
6235
|
+
gridDraw(){const gc=GC();if(!gc)return null;
|
|
6236
|
+
const g=(C&&C.grid)||null;if(!g||g.on===false)return null;
|
|
6237
|
+
return {g,geo:gc.gridGeometry(g,V2_PT_PER_FT,V2_GRID_OPTS),k:1,flipY:false};}, // k=1 and no flip: the stored coordinates ARE the scene's
|
|
6238
|
+
};
|
|
6239
|
+
}
|
|
5751
6240
|
const view3dApi={
|
|
6241
|
+
// The model read half — see modelReadsV1 / modelReadsV2 above. Built ONCE per view init; the arm is
|
|
6242
|
+
// decided by MODEL_RO, which boot() pinned from the validated type and nothing changes afterwards.
|
|
6243
|
+
model:()=>MODEL_RO?modelReadsV2():modelReadsV1(),
|
|
5752
6244
|
onFrame3dChange:()=>{updCS();if(typeof csSyncF3d==='function')csSyncF3d();
|
|
5753
6245
|
// F14: the Definition-points local (X′/Y′/Z′) row reads the 3D frame — refresh the inspector when the
|
|
5754
6246
|
// frame changes outside a render() path (notably Reset-to-global, which only fires this callback). Skip
|
|
5755
6247
|
// while the frame tool is armed (it owns the panel) and outside 3D / select mode.
|
|
5756
6248
|
if(view3d&&mode==='sel'&&!(window.Steel3DView&&window.Steel3DView.frameArmed&&window.Steel3DView.frameArmed()))panel();}, // the 3D local frame moved/armed/reset → resync the Axes chip + the numeric fields
|
|
5757
6249
|
// POST the in-progress contract so the model reflects unsaved edits; throws on a bad contract.
|
|
5758
|
-
|
|
6250
|
+
// PROJECT_QS is threaded so the server can resolve this project's activation grant — without it a
|
|
6251
|
+
// steel.model/v2 draft posts app-scoped, no grant resolves, and the render is refused as "not
|
|
6252
|
+
// activated" for a project that IS activated (P7d). Harmless for v1, which needs no grant.
|
|
6253
|
+
fetchScene:async()=>{const r=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/scene'+PROJECT_QS,{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({contract:C})});const j=await r.json();if(!j.ok)throw new Error(j.error||'scene render failed');
|
|
5759
6254
|
// The bake reports everything it could NOT emit in `skipped[]`, and we used to discard it entirely — so a
|
|
5760
6255
|
// connection the engine refused (e.g. a shear plate whose main became a brace) vanished from 3D silently.
|
|
5761
6256
|
// Always log the full list. TOAST only for `joint:<id>` entries: a refused connection is unambiguous and
|
|
@@ -5784,16 +6279,25 @@ const view3dApi={
|
|
|
5784
6279
|
else{selIds=new Set(ids2);selGridIds.clear();}
|
|
5785
6280
|
if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
|
|
5786
6281
|
onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
6282
|
+
// THE MEMBER LIST. v1 keeps one per sheet; v2 keeps ONE at the document root, which IS the whole model —
|
|
6283
|
+
// so for v2 both of these answer the same list, truthfully, rather than the silent [] that reading
|
|
6284
|
+
// `C.plans[].members` would give (§8.3). The view only ever takes ids and hands the records back to
|
|
6285
|
+
// `model().geometryOf`, so a v2 record travelling through here is read by nothing that assumes `wp`.
|
|
6286
|
+
getMembers:()=>MODEL_RO?modelMembersV2():P.members, // v1: active-sheet members (wp) for snap geometry (one ppf). v2 has no per-sheet list, and its ONE list is what the scene shows — so both questions get it.
|
|
6287
|
+
allMembers, // EVERY member in the model — already format-aware (see its definition); the 3D box-select tests all visible meshes, not just the active sheet's
|
|
6288
|
+
// ── The three reads §8.3 names as plausible-but-FALSE for v2. Each is a v1 PLAN concept, and each has a
|
|
6289
|
+
// wrong answer that looks right: an empty member list, a substituted default T.O.S that silently
|
|
6290
|
+
// relocates members, and a world-mm grid read through v1's display-space assumptions. The 3D view no
|
|
6291
|
+
// longer asks any of them — every one moved behind `model()` above — so these throws are TRIPWIRES: if
|
|
6292
|
+
// one fires, a v1-shaped read has crept back in, and it says so instead of answering.
|
|
6293
|
+
membersByPlan:()=>MODEL_RO?v2Refuse('membersByPlan — v2 has no per-plan members'):((C&&Array.isArray(C.plans))?C.plans:[]).map(p=>({members:p.members||[],ptPerFt:(p.pt_per_ft>0?p.pt_per_ft:1),defaultTosMm:(p.default_tos!=null?p.default_tos:0)*25.4})), // every sheet's members WITH its OWN px→ft scale AND its OWN default T.O.S — 3D snapping targets the whole model (any elevation), each plan resolved exactly like the server bake (contract-to-scene: per-plan pt_per_ft + `default_tos ?? 0`) so candidates land on the rendered steel. Guards a not-yet-loaded contract (C.plans absent) so a hover can't throw out of the pointer handler.
|
|
5790
6294
|
snapEnabled:()=>snapEnabled, // the persistent running-snaps (⋯ menu → Snapping) — 3D honours the same on/off set
|
|
5791
6295
|
snap3dFree:()=>snap3dFree, // SNAP-bar "3D snapping" mode — ON: free 3D snap; OFF: 3D placement snap constrained to the working plane
|
|
5792
6296
|
originGrid:()=>({on:originGridOn,incMm:originGridInc*25.4}), // UCS Stage 6 origin-relative snap — read live per hover; incMm from the inches step. Off ⇒ view skips it; requires a local frame to have any effect
|
|
5793
6297
|
canSelectId:(id)=>selIdOK(id), // Select-filter predicate for the 3D view (e.g. don't draw a whole-connection envelope for a fully-filtered connection)
|
|
5794
6298
|
canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
|
|
5795
|
-
ptPerFt:()=>(P&&P.pt_per_ft>0?P.pt_per_ft:1),
|
|
5796
|
-
defaultTosMm:()=>(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
|
|
6299
|
+
ptPerFt:()=>MODEL_RO?v2Refuse('ptPerFt — a drawing scale belongs to a SHEET; v2 members and grid are world mm'):(P&&P.pt_per_ft>0?P.pt_per_ft:1),
|
|
6300
|
+
defaultTosMm:()=>MODEL_RO?v2Refuse('defaultTosMm — v2 materialised every elevation, so a substituted default would silently relocate members'):(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
|
|
5797
6301
|
geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
|
|
5798
6302
|
onMoveMember:(id,newWp)=>{edit(()=>{const m=byId(id);if(m)MC().replaceEndpoints(m,newWp);});}, // 3D drag → write wp (undoable, autosaves, syncs 2D/chip/BOM). NOTE: the Select filter gates SELECTION (pick/marquee/Ctrl+A), NOT direct 3D drag-manipulation — gating here would strand the renderer's live preview (the mesh is already moved), so a filtered member is still directly draggable in 3D by design.
|
|
5799
6303
|
dragMoveEnabled:()=>dragMoveOn, // the 3D view gates its plain member-drag on this
|
|
@@ -5821,20 +6325,29 @@ const view3dApi={
|
|
|
5821
6325
|
geoMode=null;setGeo();snapEndMulti(sel,tm.wp[0],tm.wp[1]);}, // 3D Trim/Extend → every selected member's nearest end to the target line (snapEndMulti skips braces)
|
|
5822
6326
|
onSplit:(id,wp)=>{const m=byId(id);if(m){doSplit(m,wp);sync3D();}}, // 3D Split → cut at the clicked point on the member
|
|
5823
6327
|
getDims3d:()=>C.dims3d||[],
|
|
5824
|
-
getGrid:()=>(P&&P.grid)||null, // the ACTIVE plan's structural grid for the 3D render + plan-locked snapping (per-plan, display-space)
|
|
6328
|
+
getGrid:()=>MODEL_RO?v2Refuse('getGrid — the model grid is world mm; ask model().gridDraw() so the space comes with it'):((P&&P.grid)||null), // the ACTIVE plan's structural grid for the 3D render + plan-locked snapping (per-plan, display-space)
|
|
5825
6329
|
getDimOverlays:()=>C.dim_overlays||{}, // the legend DIMENSIONS toggles {bolt_pitch,edge_clearance,cope_size} — the 3D view derives + filters overlays from this
|
|
5826
6330
|
// dims3d is model-global: mutate + persist directly. NOT via edit() — a plan-scoped undo snapshot would corrupt dims3d across plans (undo on plan A could wipe dims added on plan B), and edit()'s sync3D would needlessly re-extrude every member mesh for a pure annotation. boot() guarantees C.dims3d is an array.
|
|
5827
|
-
|
|
6331
|
+
// May the VIEW arm a tool that writes? It cannot infer this from a disabled button — the dim tool also
|
|
6332
|
+
// arms from a bare `d` keydown, which no DOM `disabled` reaches.
|
|
6333
|
+
canEditModel:()=>canWriteModel(),
|
|
6334
|
+
// 3D dimensions are MODEL data (`C.dims3d`), and these two writers never went through edit() — they
|
|
6335
|
+
// call scheduleSave() directly, so the transaction gate could not see them. Reachable on a read-only
|
|
6336
|
+
// document through the keyboard even with #m3dDim disabled, which is how this was found.
|
|
6337
|
+
onAddDim3d:(dim)=>{if(!canWriteModel())return;C.dims3d.push(dim);scheduleSave();refreshDims3d();},
|
|
5828
6338
|
// "Add single line" committed from the 3D view. The picked points are scene mm; grid lines are stored in the
|
|
5829
6339
|
// plan's display space, so invert exactly what buildStructGrid does to draw them (mmX=px*k, mmY=-px*k → Y flips).
|
|
5830
6340
|
// Z is dropped on purpose: a grid line is a plan entity, drawn in 3D at every grid level.
|
|
5831
|
-
|
|
6341
|
+
// Refused for a read-only v2 document, and NOT because a free line is dangerous: this commit inverts the
|
|
6342
|
+
// 2D draw conversion (`mmX = px·k`, `mmY = −px·k`) to store display px, which is not the space a v2 grid's
|
|
6343
|
+
// lines live in — and adding a line changes which `gl:` ids exist, which is the topology gate's business.
|
|
6344
|
+
onAddGridLine3d:(a,b)=>{const gc=GC();if(!gc||!P||!gridDragAllowed()){gridCancelLinePick();panel();return;} // no grid module / no active plan → repaint so the hint can't outlive a pick that cannot commit
|
|
5832
6345
|
const k=gc.mmPerPx(P.pt_per_ft>0?P.pt_per_ft:1),toDisp=p=>[p[0]/k,-p[1]/k],pv=snapshot();
|
|
5833
6346
|
if(gridAddFreeLine(toDisp(a),toDisp(b),null,GRID_LINE_MIN_DISP)){pushUndo(pv);gridCancelLinePick();render();refresh3DGrid();}else panel();}, // rejected (too short) → keep the pick armed and let the user retry the 2nd point, same as 2D
|
|
5834
6347
|
onGridLinePickStep:()=>panel(), // first point placed in 3D → repaint the panel hint ("Pick the second point")
|
|
5835
6348
|
onGridLinePickCancel:()=>gridCancelLinePick(), // Esc in the 3D view cancels the pick (grid mode stays)
|
|
5836
6349
|
onSnapOnlyChanged:()=>updSnapStat(), // keep the header snap-override chip honest for every 3D-side clear (tool disarm etc.)
|
|
5837
|
-
onDeleteDim3d:(id)=>{C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
|
|
6350
|
+
onDeleteDim3d:(id)=>{if(!canWriteModel())return;C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
|
|
5838
6351
|
onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
|
|
5839
6352
|
if(id&&!selDimOK())return; // Dimensions select-switch off → a 3D dim is inert too
|
|
5840
6353
|
if(!id){sel3dDimIds.clear();render();return;}
|
|
@@ -6301,7 +6814,7 @@ function captureView(name){const V=window.Steel3DView;
|
|
|
6301
6814
|
camera:V.cameraState?V.cameraState():null,projection:V.projection?V.projection():'persp',mode:V.mode?V.mode():'solid',
|
|
6302
6815
|
clips:V.clipState?V.clipState():null,objects:V.objectsPaneState?V.objectsPaneState():null};}
|
|
6303
6816
|
// Push a captured view to the TOP (order 0; bump the rest), then persist + re-render + inline-rename it.
|
|
6304
|
-
function addView(v,{rename=true}={}){if(!Array.isArray(C.views))C.views=[];
|
|
6817
|
+
function addView(v,{rename=true}={}){if(!canWriteViews())return;if(!Array.isArray(C.views))C.views=[];
|
|
6305
6818
|
for(const x of C.views)x.order=(x.order||0)+1;v.order=0;C.views.push(v);activeViewId=v.id;scheduleSave();renderViewsTab();
|
|
6306
6819
|
if(rename){const row=document.querySelector('#m3dViewsBody .vwrow[data-id="'+v.id+'"]');if(row)startViewRename(v,row);}
|
|
6307
6820
|
return v;}
|
|
@@ -6339,14 +6852,15 @@ function startViewRename(v,row){const nameEl=row.querySelector('.vwname');if(!na
|
|
|
6339
6852
|
nameEl.replaceWith(inp);inp.focus();inp.select();
|
|
6340
6853
|
let done=false;
|
|
6341
6854
|
const finish=save=>{if(done)return;done=true;
|
|
6342
|
-
if(save){const nm=uniqueViewName(inp.value,v.id);if(nm&&nm!==v.name){v.name=nm;scheduleSave();}}
|
|
6855
|
+
if(save&&canWriteViews()){const nm=uniqueViewName(inp.value,v.id);if(nm&&nm!==v.name){v.name=nm;scheduleSave();}}
|
|
6343
6856
|
renderViewsTab();}; // commit or cancel → re-render restores the row (with the possibly-updated name/glyph)
|
|
6344
6857
|
inp.addEventListener('keydown',ev=>{ev.stopPropagation();if(ev.key==='Enter'){ev.preventDefault();finish(true);}else if(ev.key==='Escape'){ev.preventDefault();finish(false);}});
|
|
6345
6858
|
inp.addEventListener('blur',()=>finish(true));
|
|
6346
6859
|
}
|
|
6347
6860
|
// ── Row ⋯ menu: Rename / Duplicate / Update to current ──────────────────────────────────────────────────────────
|
|
6348
|
-
function updateViewToCurrent(v){const snap=captureView(v.name);snap.id=v.id;snap.order=v.order;v.camera=snap.camera;v.projection=snap.projection;v.mode=snap.mode;v.clips=snap.clips;v.objects=snap.objects;delete v.generated;v.v=1;activeViewId=v.id;scheduleSave();renderViewsTab();toast('Updated “'+v.name+'” to the current view');}
|
|
6861
|
+
function updateViewToCurrent(v){if(!canWriteViews())return;const snap=captureView(v.name);snap.id=v.id;snap.order=v.order;v.camera=snap.camera;v.projection=snap.projection;v.mode=snap.mode;v.clips=snap.clips;v.objects=snap.objects;delete v.generated;v.v=1;activeViewId=v.id;scheduleSave();renderViewsTab();toast('Updated “'+v.name+'” to the current view');}
|
|
6349
6862
|
function duplicateView(v){
|
|
6863
|
+
if(!canWriteViews())return;
|
|
6350
6864
|
const copy=JSON.parse(JSON.stringify(v));copy.id='v'+Math.random().toString(36).slice(2,9);copy.name=uniqueViewName(v.name+' copy');
|
|
6351
6865
|
// insert right after the source in order
|
|
6352
6866
|
for(const x of C.views)if((x.order||0)>(v.order||0))x.order=(x.order||0)+1;copy.order=(v.order||0)+1;C.views.push(copy);activeViewId=copy.id;scheduleSave();renderViewsTab();}
|
|
@@ -6365,13 +6879,13 @@ function openViewRowMenu(v,anchorEl){closeViewRowMenu();
|
|
|
6365
6879
|
function viewRowMenuOutside(e){const m=document.getElementById('vwRowMenu');if(m&&!m.contains(e.target))closeViewRowMenu();}
|
|
6366
6880
|
function closeViewRowMenu(){const m=document.getElementById('vwRowMenu');if(m)m.remove();document.removeEventListener('mousedown',viewRowMenuOutside,true);}
|
|
6367
6881
|
// ── Delete (immediate + undo toast that re-inserts at the original order) ────────────────────────────────────────
|
|
6368
|
-
function deleteView(v){const idx=(C.views||[]).findIndex(x=>x.id===v.id);if(idx<0)return;const removed=C.views[idx];const order=removed.order;
|
|
6882
|
+
function deleteView(v){if(!canWriteViews())return;const idx=(C.views||[]).findIndex(x=>x.id===v.id);if(idx<0)return;const removed=C.views[idx];const order=removed.order;
|
|
6369
6883
|
C.views.splice(idx,1);if(activeViewId===v.id)activeViewId=null;scheduleSave();renderViewsTab();
|
|
6370
6884
|
// Re-add unconditionally: Undo must restore the exact saved entry and its original order.
|
|
6371
6885
|
undoToast('Deleted “'+removed.name+'”',()=>{if(!Array.isArray(C.views))C.views=[];removed.order=order;C.views.push(removed);scheduleSave();renderViewsTab();});
|
|
6372
6886
|
}
|
|
6373
6887
|
// ── Reorder (pointer-drag a row; the drag-handle is the initiator — same recipe as the objects-list rows) ─────────
|
|
6374
|
-
function wireViewRowDrag(row,v){const handle=row.querySelector('.drag-handle');if(!handle)return;
|
|
6888
|
+
function wireViewRowDrag(row,v){if(!canWriteViews())return;const handle=row.querySelector('.drag-handle');if(!handle)return;
|
|
6375
6889
|
handle.addEventListener('pointerdown',e=>{e.preventDefault();e.stopPropagation();
|
|
6376
6890
|
const sx=e.clientX,sy=e.clientY;let started=false,target=null;
|
|
6377
6891
|
const move=ev=>{if(!started){if(Math.hypot(ev.clientX-sx,ev.clientY-sy)<6)return;started=true;row._dragging=true;}
|
|
@@ -6402,6 +6916,7 @@ function renderViewsTab(){const host=document.getElementById('m3dViewsBody');if(
|
|
|
6402
6916
|
const searchTog=document.createElement('button');searchTog.type='button';searchTog.id='vwSearchTog';searchTog.setAttribute('aria-label','Search views');searchTog.dataset.tip='Search views by name';if(viewsSearchOpen)searchTog.classList.add('on');searchTog.appendChild(magnifierSvg());searchTog.addEventListener('click',toggleViewsSearch);
|
|
6403
6917
|
head.append(split,searchTog);host.appendChild(head);
|
|
6404
6918
|
const genBtn=document.createElement('button');genBtn.type='button';genBtn.id='vwGenerateBtn';genBtn.className='ghostw';genBtn.textContent='Generate views from grids or levels…';genBtn.dataset.tip='Batch-create editable orthographic views from the active plan’s regular grid lines or Z levels';genBtn.addEventListener('click',()=>openViewGenerator(genBtn));host.appendChild(genBtn);
|
|
6919
|
+
roDisableViewWrites(); // the three Views write actions, once all three exist in the DOM (unit 5, P7d)
|
|
6405
6920
|
// Search box (revealed on demand)
|
|
6406
6921
|
if(viewsSearchOpen){const sb=document.createElement('div');sb.id='vwSearch';sb.className='show'+(viewsQuery?' has':'');
|
|
6407
6922
|
const ico=Object.assign(document.createElement('span'),{className:'lsico'});ico.setAttribute('aria-hidden','true');ico.appendChild(magnifierSvg());
|
|
@@ -6418,11 +6933,11 @@ function renderViewsTab(){const host=document.getElementById('m3dViewsBody');if(
|
|
|
6418
6933
|
applyViewsFilter();
|
|
6419
6934
|
}
|
|
6420
6935
|
function buildViewRow(v){const row=document.createElement('div');row.className='vwrow'+(activeViewId===v.id?' active':'');row.dataset.id=v.id;
|
|
6421
|
-
const dh=Object.assign(document.createElement('span'),{className:'drag-handle',textContent:'⠿'});dh.dataset.tip='Drag to reorder';['click','dblclick'].forEach(ev=>dh.addEventListener(ev,e=>e.stopPropagation()));row.appendChild(dh);
|
|
6936
|
+
const dh=Object.assign(document.createElement('span'),{className:'drag-handle',textContent:'⠿'});dh.dataset.tip='Drag to reorder';roLock(dh);['click','dblclick'].forEach(ev=>dh.addEventListener(ev,e=>e.stopPropagation()));row.appendChild(dh);
|
|
6422
6937
|
const glyph=Object.assign(document.createElement('span'),{className:'vwglyph'});glyph.appendChild(viewGlyph(v));row.appendChild(glyph);
|
|
6423
6938
|
const name=Object.assign(document.createElement('span'),{className:'vwname',textContent:v.name});name.dataset.tip='Click to activate · double-click to rename';row.appendChild(name);
|
|
6424
|
-
const x=Object.assign(document.createElement('span'),{className:'vx',textContent:'×'});x.dataset.tip='Delete this view';x.addEventListener('click',e=>{e.stopPropagation();deleteView(v);});row.appendChild(x);
|
|
6425
|
-
const dots=Object.assign(document.createElement('span'),{className:'vdots',textContent:'⋯'});dots.dataset.tip='More — Rename, Duplicate, Update to current';dots.setAttribute('role','button');dots.addEventListener('click',e=>{e.stopPropagation();openViewRowMenu(v,dots);});row.appendChild(dots);
|
|
6939
|
+
const x=Object.assign(document.createElement('span'),{className:'vx',textContent:'×'});x.dataset.tip='Delete this view';x.addEventListener('click',e=>{e.stopPropagation();deleteView(v);});roLock(x);row.appendChild(x);
|
|
6940
|
+
const dots=Object.assign(document.createElement('span'),{className:'vdots',textContent:'⋯'});dots.dataset.tip='More — Rename, Duplicate, Update to current';dots.setAttribute('role','button');roLock(dots);dots.addEventListener('click',e=>{e.stopPropagation();openViewRowMenu(v,dots);});row.appendChild(dots);
|
|
6426
6941
|
// single-click activates (deferred so a double-click renames instead); the drag-handle swallows its own clicks
|
|
6427
6942
|
let clickT=null;
|
|
6428
6943
|
row.addEventListener('click',e=>{if(row._dragging)return;if(e.target===dots||e.target===x)return;clearTimeout(clickT);clickT=setTimeout(()=>{if(!row._dragging)activateView(v);},200);});
|
|
@@ -6496,7 +7011,7 @@ function renderViewGenerator(){if(!viewGenState)return;const level=viewGenState.
|
|
|
6496
7011
|
viewGenSyncInputs();viewGenReflectSelection();}
|
|
6497
7012
|
function viewGenReflectSelection(){if(!viewGenState)return;const current=viewGenCurrentSources(),n=current.filter(s=>viewGenState.selected.has(viewGenKey(s))).length;document.getElementById('vgCount').textContent=n+' of '+current.length+' selected';viewGenValidate();}
|
|
6498
7013
|
function viewGenSelectAll(on){if(!viewGenState)return;viewGenState.lastAnchor=null;for(const s of viewGenCurrentSources()){const k=viewGenKey(s);if(on)viewGenState.selected.add(k);else viewGenState.selected.delete(k);}renderViewGenerator();}
|
|
6499
|
-
function createGeneratedViews(){if(!viewGenState)return;const parsed=viewGenValidate();if(!parsed||!parsed.ok)return;const V=window.Steel3DView,bounds=V&&V.sceneBounds?V.sceneBounds():null;
|
|
7014
|
+
function createGeneratedViews(){if(!canWriteViews())return;if(!viewGenState)return;const parsed=viewGenValidate();if(!parsed||!parsed.ok)return;const V=window.Steel3DView,bounds=V&&V.sceneBounds?V.sceneBounds():null;
|
|
6500
7015
|
if(!bounds){document.getElementById('vgError').textContent='The 3D model is not ready. Close this dialog and try again.';return;}
|
|
6501
7016
|
const selected=viewGenCurrentSources().filter(s=>viewGenState.selected.has(viewGenKey(s))),made=[],skipped=[],taken=new Set((C.views||[]).map(v=>v.name));
|
|
6502
7017
|
const freshName=base=>{let name=base,i=2;while(taken.has(name))name=base+' '+i++;taken.add(name);return name;};
|
|
@@ -6851,7 +7366,7 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
|
|
|
6851
7366
|
// GRID — the structural grid's visibility (per-plan contract data; same undoable switch as the panel
|
|
6852
7367
|
// checkbox and the ⋯ menu item). Only shown when this plan has a grid — slate outline swatch to match
|
|
6853
7368
|
// the grid's colour, not the cyan dim overlays.
|
|
6854
|
-
if(
|
|
7369
|
+
if(gridOf()){
|
|
6855
7370
|
host.appendChild(Object.assign(document.createElement('div'),{className:'ldiv'}));
|
|
6856
7371
|
const grow=document.createElement('div');grow.className='lrow dim';grow.dataset.tip='Show / hide the structural grid (2D + 3D)';
|
|
6857
7372
|
const gsw=document.createElement('span');gsw.className='lsw';gsw.style.setProperty('--sw','#64748b');gsw.setAttribute('role','checkbox');gsw.dataset.tip='Show / hide';gsw.setAttribute('aria-checked',String(gridOn()));
|
|
@@ -7021,14 +7536,15 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
|
|
|
7021
7536
|
// Mark labels: a checkbox in the View ▾ menu (mirrors Ref line) — show each member's mark/id in the 3D view.
|
|
7022
7537
|
document.getElementById('m3dLabels').onchange=e=>d3.setLabelsOn(e.target.checked);
|
|
7023
7538
|
// Property labels: independent 3D visibility for the shared prop-label selection (B1) — clears/repushes the 3D labels.
|
|
7024
|
-
document.getElementById('m3dPropLabels').onchange=e=>{C.prop_labels.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();};
|
|
7539
|
+
document.getElementById('m3dPropLabels').onchange=e=>{if(!canWritePropLabelVis()){e.target.checked=plVis(true);return;}C.prop_labels.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();};
|
|
7540
|
+
roDisablePropLabelToggles(); // the 3D legend is built lazily, so the boot-time pass could not have reached this one
|
|
7025
7541
|
// View menu: groups the Ref line + Labels toggles (same open/close discipline as Clip / Work area / Plane).
|
|
7026
7542
|
const viewBtn=document.getElementById('m3dView'),viewMenu=document.getElementById('m3dViewMenu');
|
|
7027
7543
|
function viewMenuOutside(e){if(!viewMenu.contains(e.target)&&e.target!==viewBtn)viewMenuClose();}
|
|
7028
7544
|
function viewMenuClose(){viewMenu.classList.remove('open');document.removeEventListener('mousedown',viewMenuOutside,true);}
|
|
7029
7545
|
viewBtn.onclick=e=>{e.stopPropagation();
|
|
7030
7546
|
if(viewMenu.classList.contains('open'))viewMenuClose();
|
|
7031
|
-
else{document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn();document.getElementById('m3dPropLabels').checked=!!(C.prop_labels&&
|
|
7547
|
+
else{document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn();document.getElementById('m3dPropLabels').checked=!!(C.prop_labels&&plVis(true)); // reflect live state on open
|
|
7032
7548
|
viewMenu.classList.add('open');document.addEventListener('mousedown',viewMenuOutside,true);}};
|
|
7033
7549
|
// Insert a detail: the ▾ menu lists the detail library + an "add image" option; picking one arms a
|
|
7034
7550
|
// placement pick (onInsertPlace drops it). While armed the button is a cancel target (onInsertModeChange).
|
|
@@ -7291,6 +7807,11 @@ viewHandlersLive=true;
|
|
|
7291
7807
|
// state setView acts on, and main() is not async so there is no await point to hang it off. It
|
|
7292
7808
|
// re-reads pendingView at that point, so a real click in between still cancels it; requestView3d's own
|
|
7293
7809
|
// viewWantSeq then covers every later change of mind, and clears aria-busy when it settles.
|
|
7810
|
+
// DEFAULT TO 3D for a read-only model (unit 5, P7d §8.5). The toggle defaults to 2D, and a v2 model has
|
|
7811
|
+
// no 2D plan — so a user who just migrated their project would land on a blank canvas and conclude the
|
|
7812
|
+
// migration ate their model. 3D IS the model view for it, and it shows all of it. A queued real click
|
|
7813
|
+
// still wins: this only supplies the default when the user expressed no preference during load.
|
|
7814
|
+
if(MODEL_RO&&pendingView===null)pendingView=true;
|
|
7294
7815
|
if(pendingView===true)setTimeout(()=>{if(pendingView!==true)return;pendingView=null;requestView3d();},0);
|
|
7295
7816
|
else{pendingView=null;setViewBusy(false);}
|
|
7296
7817
|
// Block the browser's Ctrl+wheel page-zoom anywhere in the app (fires even when the pointer isn't over the canvas). Canvas zoom below still runs.
|
|
@@ -7325,6 +7846,7 @@ function detThumb(text,imgEl){const key=(sheetOf(text)||'')+'|'+(numOf(text)||''
|
|
|
7325
7846
|
im.src='data:image/jpeg;base64,'+b64;}
|
|
7326
7847
|
// rename a detail EVERYWHERE — across all plans' callout lists, member end/col refs, and the custom store
|
|
7327
7848
|
function applyDetailRename(old,nw){nw=(nw||'').trim();if(!nw||nw===old)return false;
|
|
7849
|
+
if(!canWriteModel())return false; // the detail LIBRARY is model data — and the loop below walks C.plans[].members, which a v2 plan does not have
|
|
7328
7850
|
for(const pl of C.plans){
|
|
7329
7851
|
if(pl.details)for(const d of pl.details)if(d.text===old)d.text=nw;
|
|
7330
7852
|
// callouts[] carries names too, and the Details list renames from BOTH (#397). Skipping these renamed
|
|
@@ -7357,7 +7879,7 @@ function openDetails(){const g=document.getElementById('detailsGrid');const uniq
|
|
|
7357
7879
|
g.querySelectorAll('img.dthumb').forEach(im=>detThumb(im.dataset.t,im));
|
|
7358
7880
|
g.querySelectorAll('.dprevwrap[data-det]').forEach(c=>c.onclick=()=>openPreview(c.dataset.det));
|
|
7359
7881
|
g.querySelectorAll('input.dname').forEach(i=>i.onchange=()=>{if(applyDetailRename(i.dataset.old,i.value)){render();openDetails();}else i.value=i.dataset.old;});
|
|
7360
|
-
g.querySelectorAll('a.ddel').forEach(a=>a.onclick=e=>{e.preventDefault();delete C.custom_details[a.dataset.del];scheduleSave();render();openDetails();});
|
|
7882
|
+
g.querySelectorAll('a.ddel').forEach(a=>a.onclick=e=>{e.preventDefault();if(!canWriteModel())return;delete C.custom_details[a.dataset.del];scheduleSave();render();openDetails();});
|
|
7361
7883
|
document.getElementById('detailsBtn').textContent='Details ('+uniq.length+')';
|
|
7362
7884
|
document.getElementById('detailsModal').style.display='flex';}
|
|
7363
7885
|
function closeDetails(){document.getElementById('detailsModal').style.display='none';showDnForm(false);}
|
|
@@ -7589,7 +8111,7 @@ document.getElementById('dnAdd').onclick=()=>{const name=document.getElementById
|
|
|
7589
8111
|
if(!name){dnHint('Please enter a name.');return;}
|
|
7590
8112
|
if(detTexts().includes(name)){dnHint('That name already exists — pick another.');return;} // checks every name the Details list shows, callouts included — otherwise a new custom detail could duplicate a callout visible in that same list (#397)
|
|
7591
8113
|
if(!dnPending){dnHint('Paste or choose an image first.');return;}
|
|
7592
|
-
C.custom_details[name]=dnPending;scheduleSave();showDnForm(false);render();openDetails();};
|
|
8114
|
+
if(!canWriteModel())return;C.custom_details[name]=dnPending;scheduleSave();showDnForm(false);render();openDetails();};
|
|
7593
8115
|
// --- moment frame schedule (read from the Frame Elevations S-301/302/303) ---
|
|
7594
8116
|
function openFrames(){const g=document.getElementById('framesGrid');const fr=C.moment_frames||[];
|
|
7595
8117
|
g.innerHTML=fr.length?('<div class=hint style="margin-bottom:10px">From the Frame Elevations (S-301/302/303). Select an MF member and pick its girder size from the Profile list — roof girders for the Roof plan, 2nd-floor girders for the Second-Floor plan.</div><table class=ftab><thead><tr><th>Grid</th><th>Span</th><th>Roof girder</th><th>2nd floor</th><th>Columns</th></tr></thead><tbody>'+
|
|
@@ -8310,8 +8832,37 @@ document.addEventListener('keydown',e=>{if(!comboInput||comboPop.style.display==
|
|
|
8310
8832
|
else if(e.key==='Escape'){if(comboInput.dataset.src==='membertypes'&&comboInput.dataset.orig!=null)comboInput.value=comboInput.dataset.orig;hideCombo();e.stopPropagation();return;}
|
|
8311
8833
|
else return;
|
|
8312
8834
|
e.preventDefault();e.stopPropagation();opts.forEach((o,i)=>o.classList.toggle('active',i===comboIdx));if(comboIdx>=0)opts[comboIdx].scrollIntoView({block:'nearest'});},true);
|
|
8835
|
+
/**
|
|
8836
|
+
* The v2 half of setPlan (unit 5, P7d) — activate a CUT PLANE without any of the 2D setup.
|
|
8837
|
+
*
|
|
8838
|
+
* A v2 plan is not a sheet of members. It owns no `members`, carries no display-space geometry for them,
|
|
8839
|
+
* and its schema is `additionalProperties:false` with no `members`, `grid` or `default_tos` — the three keys
|
|
8840
|
+
* setPlan's normalisation writes. So the 2D setup is skipped WHOLESALE rather than made tolerant one read at
|
|
8841
|
+
* a time: the design puts the 2D canvas out of P7d's scope (§1), and guarding ~99 `P.members` reads
|
|
8842
|
+
* individually is exactly the slog that decision exists to avoid.
|
|
8843
|
+
*
|
|
8844
|
+
* Everything here is CLOSURE state or UI state. Nothing written below reaches the document.
|
|
8845
|
+
*/
|
|
8846
|
+
function setPlanV2(i){
|
|
8847
|
+
// The 2D viewport still needs FINITE numbers even though nothing is drawn into it: fitToWindow() divides by
|
|
8848
|
+
// EXTX/EXTY, and a NaN zoom propagates into the viewBox and into every snap tolerance derived from it.
|
|
8849
|
+
X0=0;Y0=0;X1=1000;Y1=1000;FT=(P&&P.pt_per_ft>0)?P.pt_per_ft:12;RB64='';EXTX=1000;EXTY=1000;
|
|
8850
|
+
svg.setAttribute('viewBox',`${X0} ${Y0} ${X1-X0} ${Y1-Y0}`);
|
|
8851
|
+
// The profile list, read from where v2 actually keeps members — the document ROOT. Deriving it from
|
|
8852
|
+
// `P.members` would be the silent-empty this design refuses; deriving it from `weights` alone would be a
|
|
8853
|
+
// truthful-but-partial list, which is the same defect one size down.
|
|
8854
|
+
profs=[...new Set([...(C.members||[]).map(m=>m&&m.profile).filter(Boolean),...Object.keys(WT)])].sort();
|
|
8855
|
+
selIds=new Set();findHits=new Set();selGridIds=new Set();picking=false;pickKind='profile';pickEnd=null;mode='sel';geoMode=null;setGeo();qdPick=null;setQdPickCls();
|
|
8856
|
+
dimMode=false;dimChain=false;dimSplitMode=false;selDimIds=new Set();setDimMode();
|
|
8857
|
+
setMode();
|
|
8858
|
+
if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();}
|
|
8859
|
+
dimStyleMode=false;csaxisMode=false;setCsMode();snapOnlyClear2d();closeSnapMenu();disarmCm();
|
|
8860
|
+
render();fitToWindow();
|
|
8861
|
+
refresh3DGrid();
|
|
8862
|
+
const ps=document.getElementById('planSel');if(ps)ps.value=String(i);}
|
|
8313
8863
|
// --- multi-plan: switch between all steel plan views ---
|
|
8314
8864
|
function setPlan(i){C.active=i;P=C.plans[i];
|
|
8865
|
+
if(MODEL_RO){setPlanV2(i);return;} // v2: no 2D setup at all — see setPlanV2 for why that is the whole branch
|
|
8315
8866
|
if(!Array.isArray(P.members))P.members=[];
|
|
8316
8867
|
if(!Array.isArray(P.segments))P.segments=[];
|
|
8317
8868
|
sanitizeDims(P); // …and its dimensions: drop any whose geometry isn't numeric (they render straight into SVG attributes)
|
|
@@ -8381,13 +8932,25 @@ const _restored=restoreSaved(); // bring back this brows
|
|
|
8381
8932
|
// B4: normalize brace sub-objects across ALL plans — seed defaults on a brace, strip a stale m.brace off a
|
|
8382
8933
|
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
8383
8934
|
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
//
|
|
8388
|
-
//
|
|
8389
|
-
|
|
8935
|
+
// EVERY per-plan normalisation below is v1's, and a read-only v2 document takes none of it (unit 5, P7d).
|
|
8936
|
+
// Two independent reasons, and either alone would be enough. It would MUTATE: sanitizePlanGrid writes
|
|
8937
|
+
// `p.grid`, a key v2's `additionalProperties:false` plan schema forbids, so it corrupts the document before
|
|
8938
|
+
// the user has done anything. And it would be MEANINGLESS: v2 owns no per-plan members, so the member loops
|
|
8939
|
+
// iterate nothing and sanitizeDims would re-validate v2 dim refs against v1's member index. A v2 document
|
|
8940
|
+
// arrives server-validated (P7b validates it on PUT); it does not need v1's repair pass.
|
|
8941
|
+
if(canWriteModel()){
|
|
8942
|
+
// B4: normalize brace sub-objects across ALL plans — seed defaults on a brace, strip a stale m.brace off a
|
|
8943
|
+
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
8944
|
+
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
8945
|
+
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
8946
|
+
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))ensureMeta(_m); // normalize role/ends/col on EVERY sheet, not just the active one setPlan() does — model-wide detailing (Base/Shear plates) reads off-sheet members, so a beam with no authored `ends` must be normalized here or it reads as ineligible until its sheet is opened. Same order as the active plan (normBrace → ensureMeta).
|
|
8947
|
+
for(const _p of (C.plans||[]))sanitizeDims(_p); // F9: validate magnetic dim refs on EVERY sheet (not just the active one setPlan sanitizes) — an unvisited plan could otherwise keep a stale/cross-plan ref (Codex R1 #17). Runs after normBrace so isBrace is reliable.
|
|
8948
|
+
// Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
|
|
8949
|
+
// not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
|
|
8950
|
+
for(const _p of (C.plans||[]))sanitizePlanGrid(_p);
|
|
8951
|
+
}
|
|
8390
8952
|
setPlan(C.active==null?0:C.active);
|
|
8953
|
+
applyReadOnlyChrome(); // …after setPlan, so the controls it touches are the ones the render just wired
|
|
8391
8954
|
setSaved(_restored?'ok':'idle', _restored?'Restored ✓':'Auto-save on');
|
|
8392
8955
|
try{stage.focus({preventScroll:true});}catch(_){} // grab keyboard focus on open so shortcuts work before the first click
|
|
8393
8956
|
// --- ?selftest=1 — cheap regression guard for the only non-trivial new math (local frame). Logs PASS/FAIL
|