@floless/app 0.123.2 → 0.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +600 -317
- package/dist/schemas/steel.model.v2.schema.json +10 -0
- package/dist/skills/floless-app-approval/SKILL.md +7 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -3
- package/dist/web/app.js +3 -3
- package/dist/web/aware.js +37 -5
- package/dist/web/index.html +2 -2
- package/dist/web/steel-3d-view.js +345 -14
- package/dist/web/steel-editor.html +745 -21
- package/dist/web/steel-filter.html +64 -8
- package/dist/web/vector-editor.html +15 -1
- package/dist/web/workspaces.js +324 -4
- package/package.json +1 -1
|
@@ -879,6 +879,14 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
879
879
|
#m3dRefsBody .refdet input[type=text]{height:24px;font-size:11px}
|
|
880
880
|
#m3dRefsBody .refdet .dnote{color:var(--mut);font-size:11px;line-height:1.45}
|
|
881
881
|
#m3dRefsBody .refdet .dwarn{color:#fbbf24;font-size:11px;line-height:1.45}
|
|
882
|
+
/* The Stage D measurement block. IT IS NOT A .dwarn, and that distinction is the point: `.dwarn` is
|
|
883
|
+
amber, and amber in this panel already means "something looks wrong with this reference" (it is
|
|
884
|
+
1000× too big, it is a long way from your model). A measurement is a neutral READING — dressing it in
|
|
885
|
+
the warning colour would tell the user their measurement was a problem, and would leave nothing louder
|
|
886
|
+
for the caution that lives INSIDE it. So the block is neutral and contained, and only the caution
|
|
887
|
+
within it is amber. Every value here is already in use two rules up (--line, #0b1220 from .lockrow's
|
|
888
|
+
track); no new token enters the baseline. */
|
|
889
|
+
#m3dRefsBody .refdet .dmeas{border:1px solid var(--line);border-radius:6px;background:#0b1220;padding:6px;display:flex;flex-direction:column;gap:6px}
|
|
882
890
|
#m3dRefsBody .refdet .lockrow{display:flex;align-items:center;gap:0;color:var(--text);font-size:11px;background:transparent;border:0;padding:2px 0;cursor:pointer;box-shadow:none}
|
|
883
891
|
#m3dRefsBody .refdet .lockrow .mck{position:relative;width:26px;height:14px;margin-right:9px;border-radius:7px;border:1px solid var(--line);background:#0b1220;flex:none;transition:background-color .15s,border-color .15s}
|
|
884
892
|
#m3dRefsBody .refdet .lockrow .mck::after{content:'';position:absolute;top:1px;left:1px;width:10px;height:10px;border-radius:50%;background:#64748b;transition:transform .15s,background-color .15s}
|
|
@@ -949,6 +957,40 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
949
957
|
#riSays b{color:var(--mut);font-weight:600}
|
|
950
958
|
#riVerdict{display:none;margin-top:10px;padding:8px 10px;border:1px solid #713f12;border-radius:7px;color:#fbbf24;font-size:11.5px;line-height:1.55}
|
|
951
959
|
#riVerdict button{margin-top:7px}
|
|
960
|
+
/* ── The storey / type picker (S2 Stage C) — load ONE FLOOR of a building you cannot afford whole.
|
|
961
|
+
A section INSIDE the confirm stage rather than a fourth stage: that stage already means "here are
|
|
962
|
+
the facts, add it?", and this makes it "here are the facts, choose a part, add it" — still the same
|
|
963
|
+
question with a refinement, not a new one. A fourth stage would also charge every large file an
|
|
964
|
+
extra click, which is precisely the file this exists to help.
|
|
965
|
+
The grouping chrome is #m3dLegend's `.cat-hdr`/`.cat-label`/`.cat-tog`, widened above rather than
|
|
966
|
+
re-declared, and the rows reuse `.reftree`'s bounded-scroll recipe. NO SCROLLBAR CSS IS NEEDED —
|
|
967
|
+
the page's global `*{scrollbar-width…}` (line 6) and `*::-webkit-scrollbar*` rules already reach
|
|
968
|
+
any new container. NO CHECKBOX CSS EITHER: `input[type=checkbox]` is fully themed above
|
|
969
|
+
(unchecked box, :checked, indeterminate, :focus-visible, forced-colors). */
|
|
970
|
+
#riPickToggle{margin-top:10px}
|
|
971
|
+
#refImportModal .reftree{max-height:168px;overflow:auto;border:1px solid var(--line);border-radius:7px;background:var(--bg);padding:3px 2px;margin-bottom:8px}
|
|
972
|
+
#refImportModal .ripick-row{display:flex;align-items:center;gap:6px;padding:2px 4px;border-radius:5px;font-size:11.5px;color:var(--text);cursor:pointer;user-select:none}
|
|
973
|
+
#refImportModal .ripick-row:hover{background:#33415580}
|
|
974
|
+
#refImportModal .ripick-row .rpname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
|
|
975
|
+
#refImportModal .ripick-row .rpcount{flex:none;color:var(--mut);font-variant-numeric:tabular-nums;font-size:10px}
|
|
976
|
+
/* The storey-less row. NOT a disabled checkbox — a disabled control says "you may not do this yet",
|
|
977
|
+
and the truth is that the reader cannot express it at all, so there is no control to disable. */
|
|
978
|
+
#refImportModal .ripick-row--fixed{cursor:default}
|
|
979
|
+
#refImportModal .ripick-row--fixed:hover{background:none}
|
|
980
|
+
#refImportModal .ripick-row .rpfixed{flex:none;width:14px;text-align:center;color:var(--mut)}
|
|
981
|
+
#refImportModal .ripick-row .rpnote{flex:none;color:var(--mut);font-size:10px}
|
|
982
|
+
#riPickNote,#riNoBreak{color:var(--mut);font-size:11px;line-height:1.5;margin:8px 0}
|
|
983
|
+
/* The live count's two loud states, in the tokens this file already uses — #riVerdict's amber and
|
|
984
|
+
#riDropErr's red. No new colour is introduced by this feature. */
|
|
985
|
+
#riConfirmErr{display:none;margin-top:10px;color:#fca5a5;font-size:11.5px;line-height:1.5}
|
|
986
|
+
/* Two ids, deliberately: `#riElements.warn` alone is specificity (1,1,0) and loses to
|
|
987
|
+
`#refImportModal .rirow .pv` (1,2,0) above, so the colour was authored and never rendered. An
|
|
988
|
+
independent QA pass found it by reading the computed colour — asserting the class name, which
|
|
989
|
+
is what this session's own E2E did, passes with the pixel still wrong. */
|
|
990
|
+
#refImportModal #riElements.warn{color:#fbbf24} #refImportModal #riElements.refuse{color:#fca5a5}
|
|
991
|
+
#riFootNote{display:none;flex:1;align-self:center;font-size:11px;line-height:1.4;text-align:left}
|
|
992
|
+
#riFootNote.warn{color:#fbbf24} #riFootNote.refuse{color:#fca5a5}
|
|
993
|
+
#riInsert[disabled]{opacity:.5;cursor:not-allowed}
|
|
952
994
|
/* ── Favourites tab (#m3dFavBody) — the Views-tab row/search recipe. No create button (★ lives in the
|
|
953
995
|
Inspector); a kind-filter + search header, per-row kind swatch + portability badge + row-click-to-arm. ── */
|
|
954
996
|
#favHeadRow{display:flex;align-items:stretch;gap:6px;margin-bottom:6px;flex:none}
|
|
@@ -1007,19 +1049,31 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1007
1049
|
#m3dLegend .lmode{display:flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;height:24px;margin-bottom:6px;flex:none}
|
|
1008
1050
|
#m3dLegend .lmode button{flex:1;border:0;background:transparent;color:var(--mut);font-size:11px;cursor:pointer}
|
|
1009
1051
|
#m3dLegend .lmode button.on{background:var(--brand);color:#fff}
|
|
1010
|
-
|
|
1011
|
-
#
|
|
1052
|
+
/* WIDENED, NOT DUPLICATED, to reach the import modal's storey/type picker (S2 Stage C) — the same
|
|
1053
|
+
technique the `.psethd`/`.psetbody` rules above needed for #m3dRefsBody, and for the same reason:
|
|
1054
|
+
these are scoped to #m3dLegend, which is not an ancestor of #refImportModal. The picker is the
|
|
1055
|
+
identical shape (a header standing for several rows, with a tri-state toggle), so it gets the
|
|
1056
|
+
identical chrome rather than a second copy that drifts. */
|
|
1057
|
+
#m3dLegend .cat-hdr,#refImportModal .cat-hdr{display:flex;align-items:center;gap:6px;padding:3px 4px;border-radius:5px;cursor:pointer;user-select:none;white-space:nowrap}
|
|
1058
|
+
#m3dLegend .cat-hdr:hover,#refImportModal .cat-hdr:hover{background:#33415580}
|
|
1059
|
+
/* …but NOT in the import modal, where only the nested toggle acts. In #m3dLegend the whole header
|
|
1060
|
+
collapses its group, so the pointer and the hover fill are honest there; borrowing them here would
|
|
1061
|
+
promise a click that does nothing. Placed AFTER the rule it overrides — same specificity, so source
|
|
1062
|
+
order is what decides, and an earlier copy silently lost. */
|
|
1063
|
+
#refImportModal .cat-hdr{cursor:default}
|
|
1064
|
+
#refImportModal .cat-hdr:hover{background:none}
|
|
1065
|
+
#refImportModal .cat-tog{cursor:pointer}
|
|
1012
1066
|
#m3dLegend .cat-hdr.empty .cat-label,#m3dLegend .cat-hdr.empty .cat-count{opacity:.55}
|
|
1013
1067
|
#m3dLegend .cat-hdr.drop-target{outline:1px solid var(--brand);background:rgba(59,130,246,.18)}
|
|
1014
1068
|
#m3dLegend .cat-chevron{font-size:10px;color:var(--mut);width:12px;flex:none;text-align:center}
|
|
1015
|
-
#m3dLegend .cat-tog{font-size:12px;width:14px;flex:none;cursor:pointer;line-height:1;text-align:center}
|
|
1016
|
-
#m3dLegend .cat-tog[data-state=on]{color:var(--brand)} #m3dLegend .cat-tog[data-state=off]{color:var(--mut)} #m3dLegend .cat-tog[data-state=mixed]{color:#64748b}
|
|
1069
|
+
#m3dLegend .cat-tog,#refImportModal .cat-tog{font-size:12px;width:14px;flex:none;cursor:pointer;line-height:1;text-align:center;background:none;border:0;padding:0}
|
|
1070
|
+
#m3dLegend .cat-tog[data-state=on],#refImportModal .cat-tog[data-state=on]{color:var(--brand)} #m3dLegend .cat-tog[data-state=off],#refImportModal .cat-tog[data-state=off]{color:var(--mut)} #m3dLegend .cat-tog[data-state=mixed],#refImportModal .cat-tog[data-state=mixed]{color:#64748b}
|
|
1017
1071
|
/* `min-width:0` + ellipsis because a flex item that cannot shrink below its content OVERFLOWS the row
|
|
1018
1072
|
rather than truncating, and `.cat-hdr` is `white-space:nowrap`. The legend's own categories were
|
|
1019
1073
|
always short enough to hide this; the reference tree's disambiguated headers ("Wall · IFCWALL…")
|
|
1020
1074
|
are the first labels long enough to test it. Same recipe as `.refname` directly above. */
|
|
1021
|
-
#m3dLegend .cat-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:12px;color:var(--text)}
|
|
1022
|
-
#m3dLegend .cat-count{font-size:10px;color:var(--mut);font-variant-numeric:tabular-nums}
|
|
1075
|
+
#m3dLegend .cat-label,#refImportModal .cat-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:12px;color:var(--text)}
|
|
1076
|
+
#m3dLegend .cat-count,#refImportModal .cat-count{font-size:10px;color:var(--mut);font-variant-numeric:tabular-nums}
|
|
1023
1077
|
#m3dLegend .lrow.typed{padding-left:20px}
|
|
1024
1078
|
#m3dLegend .cat-hdr.sub{padding-left:20px} /* a nested (middle) category, e.g. Dimensions → Base-plate */
|
|
1025
1079
|
#m3dLegend .lrow.sub{padding-left:34px} /* a row inside a nested category — indented one level deeper */
|
|
@@ -1474,8 +1528,25 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1474
1528
|
<div id=riConfirmStage style="display:none">
|
|
1475
1529
|
<div id=riSays></div>
|
|
1476
1530
|
<div class=rirow><span class=pn>Schema</span><span class=pv id=riSchema>—</span></div>
|
|
1477
|
-
|
|
1531
|
+
<!-- "ESTIMATED objects", and it reads `population` — not `probe.elements`, which counts elements
|
|
1532
|
+
placed directly in the spatial structure and is a DIFFERENT, smaller number (measured: 10 for
|
|
1533
|
+
a file whose read returns 16, and 5,878 for one that returns 17,460). This row sits directly
|
|
1534
|
+
above a limit stated in objects, so the two have to be the same kind of number. `aria-live` is
|
|
1535
|
+
on the VALUE alone so ticking a storey re-announces the count, not the label. -->
|
|
1536
|
+
<div class=rirow><span class=pn data-tip="How many objects FloLess expects to load, read from the file's own storey and type summary before anything is drawn. The real count can differ a little once the file is read.">Estimated objects</span><span class=pv id=riElements aria-live=polite>—</span></div>
|
|
1478
1537
|
<div class=rirow><span class=pn>File size</span><span class=pv id=riBytes>—</span></div>
|
|
1538
|
+
<!-- ── The picker. Hidden entirely unless the file offers a real choice (more than one storey or
|
|
1539
|
+
more than one type); collapsed unless the file is big enough for the choice to matter, so a
|
|
1540
|
+
13-object model still imports in two clicks. -->
|
|
1541
|
+
<button type=button id=riPickToggle class=pilllink style="display:none" aria-expanded=false aria-controls=riPick>Load only part of this file ▸</button>
|
|
1542
|
+
<div id=riPick style="display:none">
|
|
1543
|
+
<div id=riPickNote style="display:none"></div>
|
|
1544
|
+
<div class=cat-hdr id=riStoreyHdr><span class=cat-label>Storeys</span><span class=cat-count id=riStoreyCount></span><button type=button class=cat-tog id=riStoreyAll data-state=on data-tip="Select or clear every storey"></button></div>
|
|
1545
|
+
<div class=reftree id=riStoreyList></div>
|
|
1546
|
+
<div class=cat-hdr id=riTypeHdr><span class=cat-label>Types</span><span class=cat-count id=riTypeCount></span><button type=button class=cat-tog id=riTypeAll data-state=on data-tip="Select or clear every type"></button></div>
|
|
1547
|
+
<div class=reftree id=riTypeList></div>
|
|
1548
|
+
</div>
|
|
1549
|
+
<div id=riNoBreak style="display:none"></div>
|
|
1479
1550
|
<!-- NO SIZE ROW HERE, and that is a decision rather than an omission. The only pre-tessellation
|
|
1480
1551
|
measurement available is `probe.bbox`, which its own manifest calls APPROXIMATE — measured, it
|
|
1481
1552
|
spans every cartesian point the file places, not the geometry: for the Motebello lift shaft it
|
|
@@ -1484,9 +1555,17 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1484
1555
|
is in, from the rendered bounds; the bbox is used ONLY for the position hint below, which is
|
|
1485
1556
|
labelled a probability and phrased as one. -->
|
|
1486
1557
|
<div id=riVerdict role=status></div>
|
|
1558
|
+
<!-- The confirm stage's OWN error slot. Without it a refusal had to fall back to `riStage('drop')`,
|
|
1559
|
+
which swaps the whole body out — so a message saying "choose fewer storeys" destroyed the
|
|
1560
|
+
picker it was pointing at. -->
|
|
1561
|
+
<div id=riConfirmErr role=alert></div>
|
|
1487
1562
|
</div>
|
|
1488
1563
|
</div>
|
|
1489
1564
|
<div class=rifoot>
|
|
1565
|
+
<!-- The count again, in the footer, because the picker pushes the row above out of view on a file
|
|
1566
|
+
with twelve storeys and sixteen types — and the number is the whole reason the control is
|
|
1567
|
+
comprehensible. Shown only when it is amber or red; silence is the ok state. -->
|
|
1568
|
+
<div id=riFootNote role=status></div>
|
|
1490
1569
|
<button id=riCancel>Cancel</button>
|
|
1491
1570
|
<button id=riInsert class=primary style="display:none" data-tip="Add this model as a reference. It is never part of your steel.">Add reference</button>
|
|
1492
1571
|
</div>
|
|
@@ -1496,7 +1575,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1496
1575
|
<div id=ciBody>
|
|
1497
1576
|
<!-- stage: dropzone -->
|
|
1498
1577
|
<div id=ciDropStage>
|
|
1499
|
-
<div id=ciDrop data-tip="Click to browse, or drag an IFC file here"><span
|
|
1578
|
+
<div id=ciDrop data-tip="Click to browse, or drag an IFC file here"><span>Drop an IFC file here, or click to browse</span></div>
|
|
1500
1579
|
<input id=ciFile type=file accept=".ifc,.ifczip" hidden>
|
|
1501
1580
|
<div class=hint style="margin-top:10px">Design a connection in IDEA StatiCa, Tekla or any tool, export IFC, and drop it here to place it in your model. The file stays on your machine.</div>
|
|
1502
1581
|
<div class=gerr id=ciDropErr style="display:none"></div>
|
|
@@ -1567,6 +1646,12 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
|
|
|
1567
1646
|
// /api/contract call; the contract-request (Ask AI) bodies carry `project` for slice-4 context.
|
|
1568
1647
|
const PROJECT = new URLSearchParams(location.search).get('project') || '';
|
|
1569
1648
|
const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
|
|
1649
|
+
// READS ONLY, and only when project-scoped — the same split steel-filter.html already makes, for the
|
|
1650
|
+
// same reason. A project with no model yet is an expected state, not a failure, but a 404 makes the
|
|
1651
|
+
// browser log its own red "Failed to load resource" that no JS handling can suppress; 204 says the
|
|
1652
|
+
// same thing silently. Never on the app-keyed URL, whose 404 carries the publication-ownership codes
|
|
1653
|
+
// the empty states below branch on, and never on the PUT — a write wants the ordinary refusal.
|
|
1654
|
+
const CONTRACT_QS = PROJECT ? (PROJECT_QS + '&quietMissing=1') : PROJECT_QS;
|
|
1570
1655
|
// ── The browser draft's identity, and the contract type this page can render (unit 5, P1c-3) ──
|
|
1571
1656
|
// The one contract type this editor renders. A contract with NO `type` is legacy steel v1 — the server's
|
|
1572
1657
|
// own validator says so and falls back to exactly this (contract-schema.ts, validateContract), so
|
|
@@ -1943,7 +2028,14 @@ async function boot() {
|
|
|
1943
2028
|
import('./steel-detail-refs.js'), import('./steel-model-v2-projection.js'),
|
|
1944
2029
|
import('./steel-model-v2-commands.js'), import('./steel-model-v2-client-validation.js'),
|
|
1945
2030
|
]);
|
|
1946
|
-
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) +
|
|
2031
|
+
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + CONTRACT_QS);
|
|
2032
|
+
// 204 = the project-scoped "nothing stored yet", the quiet twin of the generic 404 below. It carries
|
|
2033
|
+
// no body and no code, so it routes straight to the same empty state rather than through the
|
|
2034
|
+
// publication-code branches, which only an app-keyed read can produce.
|
|
2035
|
+
if (res.status === 204) {
|
|
2036
|
+
showEmpty('⊞', 'No model for', 'Read a structural drawing first — ask your terminal AI to run the workflow, then open this editor again.', APP_ID);
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
1947
2039
|
if (!res.ok) {
|
|
1948
2040
|
if (res.status === 404) {
|
|
1949
2041
|
// TWO different 404s, and telling them apart is the whole point of this branch.
|
|
@@ -4130,7 +4222,7 @@ function gridSvg(){
|
|
|
4130
4222
|
geo.v.forEach((l,i)=>{s+=`<line class="gridln${gsel('gv:'+i)}" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}"/><line class="gridhit gv" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
4131
4223
|
geo.h.forEach((l,i)=>{s+=`<line class="gridln${gsel('gh:'+i)}" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}"/><line class="gridhit gh" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
4132
4224
|
(geo.lines||[]).forEach((l,i)=>{s+=`<line class="gridln${gsel('gl:'+(l.id!=null?l.id:i))}" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}"/><line class="gridhit gl" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
4133
|
-
const bub=(x,y,lb,ax,i,end)=>`<g class=gridbubg data-${ax}="${i}" data-end="${end}" data-tip="Grid ${esc(lb)} — drag to move or adjust · dbl-click to rename · click to select"><circle class=gridbub
|
|
4225
|
+
const bub=(x,y,lb,ax,i,end)=>`<g class=gridbubg data-${ax}="${i}" data-end="${end}" data-tip="Grid ${esc(lb)} — drag to move or adjust · dbl-click to rename · click to select"><circle class=gridbub cx="${x}" cy="${y}" r="${R}"/><text class=gridtx x="${x}" y="${y}" style="font-size:${F}px">${esc(lb)}</text></g>`;
|
|
4134
4226
|
geo.v.forEach((l,i)=>{s+=bub(l.x,l.lo,l.label,'gv',i,0)+bub(l.x,l.hi,l.label,'gv',i,1);});
|
|
4135
4227
|
geo.h.forEach((l,i)=>{s+=bub(l.lo,l.y,l.label,'gh',i,0)+bub(l.hi,l.y,l.label,'gh',i,1);});
|
|
4136
4228
|
(geo.lines||[]).forEach((l,i)=>{s+=bub(l.a[0],l.a[1],l.label,'gl',i,0)+bub(l.b[0],l.b[1],l.label,'gl',i,1);});
|
|
@@ -4472,7 +4564,9 @@ let lastCmd=null;
|
|
|
4472
4564
|
function setLastCmd(label,run){lastCmd={label,run};}
|
|
4473
4565
|
function anyToolActive(){
|
|
4474
4566
|
if(dimMode||dimChain||dimSplitMode||geoMode||csaxisMode||gridMode||gridPick||gridLinePick||dimStyleMode||mode==='add'||picking||cmTool||qdPick)return true; // 2D tools armed (cmTool = Move/Copy; qdPick = the F7 grid station pick)
|
|
4475
|
-
if(view3d&&window.Steel3DView){if(window.Steel3DView.clipMode&&window.Steel3DView.clipMode())return true;
|
|
4567
|
+
if(view3d&&window.Steel3DView){if(window.Steel3DView.clipMode&&window.Steel3DView.clipMode())return true;
|
|
4568
|
+
if(window.Steel3DView.refMeasureState&&window.Steel3DView.refMeasureState().armed)return true; // the reference measure owns the left-click too, so Space/Enter must not re-invoke the last command over it
|
|
4569
|
+
const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))return true;} // 3D dim/clip armed
|
|
4476
4570
|
return false;
|
|
4477
4571
|
}
|
|
4478
4572
|
function repeatLast(){if(lastCmd){lastCmd.run();if(typeof toast==='function')toast('↻ '+lastCmd.label);}}
|
|
@@ -5012,7 +5106,7 @@ function panel(){
|
|
|
5012
5106
|
const _rb=document.getElementById('csRepickB');if(_rb)_rb.onclick=()=>{if(_d3.repickFrame3d)_d3.repickFrame3d();};
|
|
5013
5107
|
return;}
|
|
5014
5108
|
if(csaxisMode){p.innerHTML=`<span class=badge>Set local axes</span>
|
|
5015
|
-
<div class=hint
|
|
5109
|
+
<div class=hint style="margin-top:8px">${csDraft?'Click the <b>second</b> point — the local-X direction. Y follows at 90°.':'Click the <b>origin</b> point to start.'}</div>
|
|
5016
5110
|
<div class=hint style="margin-top:8px">Two clicks define the frame; snaps to member ends & grid (<b>Alt</b> off). <b>Esc</b> cancels.</div>`;return;}
|
|
5017
5111
|
if(cmTool){const nsel=selIds.size;
|
|
5018
5112
|
p.innerHTML=`<span class=badge>${cmTool==='move'?'Move':(cmArrayMode?'Copy array':'Copy')}</span>
|
|
@@ -6572,7 +6666,7 @@ function disarmCm(){cmTool=null;cmArrayMode=false;cmDraft=null;cmHudClose();cmPr
|
|
|
6572
6666
|
if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d();} // drop the 3D-side pick/preview too
|
|
6573
6667
|
function armCm(tool,array){ // re-arming the same config toggles the tool off — works in 2D and (on the working plane) in 3D
|
|
6574
6668
|
if(cmTool===tool&&cmArrayMode===!!array){disarmCm();render();return;}
|
|
6575
|
-
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();} // the 3D dim tool + the local frame share the left-click — disarm both
|
|
6669
|
+
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();if(window.Steel3DView.armRefMeasure3d){window.Steel3DView.armRefMeasure3d(null);refMeasureClear();}} // the 3D dim tool + the local frame share the left-click — disarm both
|
|
6576
6670
|
if(!selIds.size){toast('Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
|
|
6577
6671
|
if(mode==='add'){mode='sel';setMode();if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}
|
|
6578
6672
|
if(dimMode){dimMode=false;setDimMode();}
|
|
@@ -7111,7 +7205,7 @@ function setMode(){document.body.classList.toggle('add',mode==='add');document.g
|
|
|
7111
7205
|
if(mode!=='add'){drawDraft=null;drawPrevClear();cmHudClose();if(view3d&&window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}} // leaving Add-member drops the in-progress start + preview, closes any open typed-entry HUD, and clears the 3D draw start (else a stale Add token could revalidate on re-arm — Codex)
|
|
7112
7206
|
document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();if(qdPick){qdPick=null;setQdPickCls();}
|
|
7113
7207
|
if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // arming Add leaves the grid panel — same mutual exclusion Move/Copy already enforces. In 3D addActive() consumes the click AHEAD of the grid pick, so without this the Add gesture would run while the grid button + hint still claimed an armed pick (the A shortcut routes through this same handler)
|
|
7114
|
-
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();} // the 3D dim tool + the local frame share the left-click — disarm both when entering add mode
|
|
7208
|
+
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();if(window.Steel3DView.armRefMeasure3d){window.Steel3DView.armRefMeasure3d(null);refMeasureClear();}} // the 3D dim tool + the local frame share the left-click — disarm both when entering add mode
|
|
7115
7209
|
selDimIds.clear();dimStyleMode=false;mode=(mode==='add'?'sel':'add');if(mode==='add')selIds.clear();else if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();snapOnlyClear2d();setMode();render();setLastCmd('Add member',()=>{if(mode!=='add'){if(dimMode){dimMode=false;setDimMode();}mode='add';selIds.clear();setMode();render();}});}; // entering add/sel disarms the Dimension + set-axes tools + the Dimension style pane + drops any dim selection + reverts a snap override; leaving add clears the 3D draw draft
|
|
7116
7210
|
document.getElementById('dimB').onclick=()=>{if(csaxisMode){csaxisMode=false;setCsMode();}if(qdPick){qdPick=null;setQdPickCls();}dimMode=!dimMode;setDimMode();render();setLastCmd('Dimension',()=>{if(!dimMode){dimMode=true;setDimMode();render();}});};
|
|
7117
7211
|
document.getElementById('csSetB').onclick=()=>{csaxisMode=!csaxisMode;setCsMode();render();};
|
|
@@ -7390,6 +7484,20 @@ addEventListener('keydown',e=>{
|
|
|
7390
7484
|
if(e.key==='Escape'&&selDimIds.size){if(dimSplitMode){dimSplitMode=false;snapClear();render();}else{selDimIds.clear();render();}return;} // Esc on a selected dim: end split mode → else deselect
|
|
7391
7485
|
if(e.key==='Escape'&&view3d&&mode==='add'){if(cmHudIsOpen()){cmHudClose();return;}if(window.Steel3DView&&window.Steel3DView.drEscape&&window.Steel3DView.drEscape())return;} // 3D draw: Esc closes an open typed-entry HUD first, then drops the in-progress start pick, then exits add mode (falls through below)
|
|
7392
7486
|
if(e.key==='Escape'&&!view3d&&mode==='add'&&drawDraft){drawDraft=null;drawPrevClear();render();return;} // 2D Add-member: 1st Esc drops the in-progress start point (2nd falls through below → exits the tool), like the Dimension tool
|
|
7487
|
+
// Esc while typing the true distance leaves the BOX, and stops there. Without this the press falls all
|
|
7488
|
+
// the way to the catch-all below — which is not guarded by `inForm` — and clears the user's member
|
|
7489
|
+
// selection as the answer to "I have finished typing", which is not a thing they asked for.
|
|
7490
|
+
if(e.key==='Escape'&&_ae&&_ae.id==='refMeasureTrue'){e.preventDefault();e.stopImmediatePropagation();if(_ae.blur)_ae.blur();return;}
|
|
7491
|
+
// The reference measure's Esc, owned HERE and not in the 3D layer — the same split the grid-line pick
|
|
7492
|
+
// documents on both sides. This handler is bound at parse time and the 3D view binds its own inside
|
|
7493
|
+
// init(), so this one runs FIRST: were the measure handled there, the catch-all one line below would
|
|
7494
|
+
// already have cleared the user's member selection by the time it stepped the measure back, and one Esc
|
|
7495
|
+
// would do two things. `stopImmediatePropagation` because the press is fully consumed here.
|
|
7496
|
+
// Three stages, resolved inside refMeasureEscape: drop the second pick → drop the result → exit the tool.
|
|
7497
|
+
if(e.key==='Escape'&&view3d&&!inForm&&window.Steel3DView&&window.Steel3DView.refMeasureEscape&&window.Steel3DView.refMeasureEscape()){
|
|
7498
|
+
e.preventDefault();e.stopImmediatePropagation();
|
|
7499
|
+
if(refMeasure&&!(window.Steel3DView.refMeasureKept&&window.Steel3DView.refMeasureKept()))refMeasure=null; // the stage that dropped the RESULT drops the card with it
|
|
7500
|
+
renderRefsTab();return;}
|
|
7393
7501
|
if(e.key==='Escape'){if(geoMode){geoMode=null;setGeo();render();return;}if(mode==='add'){mode='sel';setMode();}picking=false;pickKind='profile';pickEnd=null;selIds.clear();selGridIds.clear();render();return;}
|
|
7394
7502
|
if((e.key==='Delete'||e.key==='Backspace')&&view3d&&window.Steel3DView.selectedClips&&window.Steel3DView.selectedClips().length&&!selIds.size&&!sel3dDimIds.size&&!selDimIds.size&&!inForm){e.preventDefault();window.Steel3DView.deleteSelectedClips();return;} // 3D: Del removes the selected clip plane(s)/box(es) — only when nothing else is selected (clip selection is exclusive)
|
|
7395
7503
|
if((e.key==='Delete'||e.key==='Backspace')&&view3d&&sel3dDimIds.size&&!selIds.size&&!inForm){e.preventDefault();[...sel3dDimIds].forEach(id=>view3dApi.onDeleteDim3d(id));return;} // 3D: Delete removes ALL selected 3D dims — only when no member is selected
|
|
@@ -8038,6 +8146,11 @@ const view3dApi={
|
|
|
8038
8146
|
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
|
|
8039
8147
|
onGridLinePickStep:()=>panel(), // first point placed in 3D → repaint the panel hint ("Pick the second point")
|
|
8040
8148
|
onGridLinePickCancel:()=>gridCancelLinePick(), // Esc in the 3D view cancels the pick (grid mode stays)
|
|
8149
|
+
// S2 Stage D — the reference measure. The 3D layer owns the PICK; the editor owns the RESULT, which is
|
|
8150
|
+
// why the second click hands the two points over here instead of storing them there.
|
|
8151
|
+
onRefMeasure:(refId,a,b,mm)=>{refMeasure={refId,a,b,mm,typed:''};refSelectedId=refId;renderRefsTab();},
|
|
8152
|
+
onRefMeasureStep:()=>renderRefsTab(), // repaint so the panel's armed affordance can't drift from the tool
|
|
8153
|
+
onRefMeasureCancel:()=>{const v=window.Steel3DView;if(v&&v.armRefMeasure3d)v.armRefMeasure3d(null);refMeasureClear();},
|
|
8041
8154
|
onSnapOnlyChanged:()=>updSnapStat(), // keep the header snap-override chip honest for every 3D-side clear (tool disarm etc.)
|
|
8042
8155
|
onDeleteDim3d:(id)=>{if(!canWriteModel())return;C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
|
|
8043
8156
|
onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
|
|
@@ -9009,6 +9122,20 @@ const refLoading=new Set(); // ids with a geometry fetch in flight — the
|
|
|
9009
9122
|
const refFailed=new Map(); // id -> why its geometry could not be fetched (see loadReferenceGeometry)
|
|
9010
9123
|
const refEmpty=new Set(); // ids the reader answered for, with nothing drawable in the answer
|
|
9011
9124
|
let refSelectedId=null; // the reference the panel has expanded (and the 3D layer has selected)
|
|
9125
|
+
/**
|
|
9126
|
+
* THE STAGE D MEASUREMENT, AND IT IS NOT MODEL DATA. `{refId,a,b,mm,typed}` or null.
|
|
9127
|
+
*
|
|
9128
|
+
* Deliberately a module variable rather than a key on `C`: a measurement is a question the user asked, not
|
|
9129
|
+
* a fact about the building. Nothing in save(), snapshot(), restoreSaved() or the schema knows it exists,
|
|
9130
|
+
* so a measure that is never accepted leaves the serialized contract byte-identical — the bargain this
|
|
9131
|
+
* whole feature is sold on, pinned by server/reference-measure-scale.test.ts.
|
|
9132
|
+
*
|
|
9133
|
+
* `typed` rides along for a duller reason: renderRefsTab() rebuilds the whole tab, and several ordinary
|
|
9134
|
+
* acts reach it (an opacity release, a snap toggle, geometry finishing its fetch, refEdit itself). Without
|
|
9135
|
+
* somewhere outside the DOM to keep it, a half-typed "6" would be destroyed by an event the user did not
|
|
9136
|
+
* connect to their typing.
|
|
9137
|
+
*/
|
|
9138
|
+
let refMeasure=null;
|
|
9012
9139
|
/**
|
|
9013
9140
|
* The INDEX of the one object drilled into inside `refSelectedId`, or null.
|
|
9014
9141
|
*
|
|
@@ -9235,11 +9362,193 @@ function refEdit(id,patch){
|
|
|
9235
9362
|
const v=window.Steel3DView;
|
|
9236
9363
|
if(v){if(patch.display&&v.setReferenceDisplay)v.setReferenceDisplay(id,refDisp(r));
|
|
9237
9364
|
if(patch.placement&&v.setReferencePlacement)v.setReferencePlacement(id,r.placement||null);}
|
|
9365
|
+
// A MEASUREMENT DOES NOT SURVIVE THE SCALE IT WAS TAKEN AT (S2 Stage D). Its card says the distance is
|
|
9366
|
+
// "at this reference's scale right now", and the accept multiplies by the scale then applied — so a
|
|
9367
|
+
// scale changed by ANY other route in between makes both the sentence false and the arithmetic wrong.
|
|
9368
|
+
// The Scale box is one row above the card and is deliberately not suppressed while measuring, so this is
|
|
9369
|
+
// reachable in three clicks. Placed HERE because refEdit is the single write path: a guard in the card
|
|
9370
|
+
// could be walked around by the box, and one in the box could be walked around by the next writer.
|
|
9371
|
+
// SCALE ONLY — a change of `origin` translates the reference, and a distance is translation-invariant, so
|
|
9372
|
+
// "move it next to your model" must not throw a measurement away for no reason.
|
|
9373
|
+
if(patch.placement&&patch.placement.scale!==undefined&&refMeasure&&refMeasure.refId===id){
|
|
9374
|
+
refMeasure=null;if(v&&v.clearRefMeasure3d)v.clearRefMeasure3d();} // set directly, not via refMeasureClear() — the renderRefsTab below is the one repaint this needs
|
|
9238
9375
|
scheduleSave();renderRefsTab();
|
|
9239
9376
|
}
|
|
9240
9377
|
|
|
9378
|
+
// ── S2 Stage D: measure a distance on a reference, then set its scale from it ─────────────────────
|
|
9379
|
+
//
|
|
9380
|
+
// The two points come from the 3D layer's armed pick (`armRefMeasure3d`), which snaps to THAT reference's
|
|
9381
|
+
// own points and to nothing else. The reason is arithmetic, not taste: `xrefMatrix` builds
|
|
9382
|
+
// translate(origin)·rotZ·scale(s), so a distance between two points INSIDE the reference is s·|p₁−p₂| and
|
|
9383
|
+
// scales by the factor — while a distance from the reference to our steel, or to a second reference, is
|
|
9384
|
+
// not a quantity `placement.scale` governs at all. Letting a foreign point in would compute a factor from
|
|
9385
|
+
// something the factor does not move, and the resulting scale would be silently wrong.
|
|
9386
|
+
|
|
9387
|
+
/** Arm the two-point measure against one reference, opening its row so the result has somewhere to land. */
|
|
9388
|
+
function refMeasureArm(id){
|
|
9389
|
+
const r=refById(id);if(!r){toast('That reference is no longer in this model');return;}
|
|
9390
|
+
const v=window.Steel3DView;
|
|
9391
|
+
// `view3d` IS THE CONDITION. Steel3DView.armRefMeasure3d exists as soon as the module loads, in either
|
|
9392
|
+
// view, so testing for the method alone was a branch that could never fire for the reason it named —
|
|
9393
|
+
// and would have armed a pick against a canvas nobody is looking at.
|
|
9394
|
+
if(!view3d||!v||!v.armRefMeasure3d){toast('Switch to the 3D view to measure a reference');return;}
|
|
9395
|
+
// Both entry points are already gated on there being geometry; this is the guard that survives a refactor
|
|
9396
|
+
// of either of them, and it distinguishes "still loading" from "there is nothing here" the way the move
|
|
9397
|
+
// command's sibling refusal does.
|
|
9398
|
+
// THE REASON IS ALREADY KNOWN — say it. refFailed carries why the fetch failed and refEmpty means the
|
|
9399
|
+
// reader answered with nothing drawable; collapsing both into "there is no geometry yet" tells a user
|
|
9400
|
+
// whose file failed to load exactly what a user whose file is legitimately empty is told.
|
|
9401
|
+
if(!refGeom.has(id)){
|
|
9402
|
+
toast(refLoading.has(id)?'Still reading its geometry — try again in a moment'
|
|
9403
|
+
:refFailed.has(id)?('Its geometry could not be read — '+refFailed.get(id))
|
|
9404
|
+
:refEmpty.has(id)?'This file has nothing drawable in it to measure'
|
|
9405
|
+
:'There is no geometry to measure yet');
|
|
9406
|
+
return;}
|
|
9407
|
+
refMeasureClear();
|
|
9408
|
+
// OPENING THE ROW IS ALL THREE OF THE ROW HANDLER'S MOVES, not just the first. `refSelectedObjIdx` is an
|
|
9409
|
+
// INDEX into the selected reference's object array, so setting `refSelectedId` alone would leave an index
|
|
9410
|
+
// taken inside reference A pointing into reference B — the exact failure refRemove's comment names.
|
|
9411
|
+
refSelectedId=id;refSelectedObjIdx=null;
|
|
9412
|
+
if(v.selectReference)v.selectReference(id);
|
|
9413
|
+
// SAID, NOT SILENTLY FIXED. Un-hiding would be a persisted display write the user did not ask for; §10.3
|
|
9414
|
+
// already establishes that a hidden reference still snaps, so the tool works — it is only the looking
|
|
9415
|
+
// that does not.
|
|
9416
|
+
if(refDisp(r).visible===false)toast('“'+r.name+'” is hidden — show it to see what you are measuring');
|
|
9417
|
+
v.armRefMeasure3d(id);
|
|
9418
|
+
renderRefsTab();panel();
|
|
9419
|
+
}
|
|
9420
|
+
/** Is the two-point measure armed against THIS reference right now? (Independent of a result existing.) */
|
|
9421
|
+
function refMeasureArmedOn(id){
|
|
9422
|
+
const v=window.Steel3DView;
|
|
9423
|
+
return !!(v&&v.refMeasureState&&v.refMeasureState().refId===id);
|
|
9424
|
+
}
|
|
9425
|
+
/**
|
|
9426
|
+
* The measurement lives in ONE reference's detail block, so it must not outlive that block being open.
|
|
9427
|
+
*
|
|
9428
|
+
* Three ordinary acts move `refSelectedId` without touching the tool: clicking the measured row again
|
|
9429
|
+
* (the handler TOGGLES), clicking a different reference's row, and inserting a new reference. Each left
|
|
9430
|
+
* the tool armed and the dashed segment drawn while the chip read "Measured - see the panel" and the
|
|
9431
|
+
* panel had no card — the dead-control shape dropRefMeasure3d exists to prevent, arrived at from the
|
|
9432
|
+
* other side. Called from every site that assigns refSelectedId.
|
|
9433
|
+
*/
|
|
9434
|
+
function refMeasureFollowSelection(){
|
|
9435
|
+
const v=window.Steel3DView;
|
|
9436
|
+
const armedOn=v&&v.refMeasureState?v.refMeasureState().refId:null;
|
|
9437
|
+
const held=refMeasure?refMeasure.refId:null;
|
|
9438
|
+
for(const id of new Set([armedOn,held])){if(id&&id!==refSelectedId)refMeasureDropFor(id);}
|
|
9439
|
+
}
|
|
9440
|
+
/** Drop the measurement and the segment drawn for it. The ONLY thing a cancelled measure changes. */
|
|
9441
|
+
function refMeasureClear(){
|
|
9442
|
+
const had=!!refMeasure;refMeasure=null;
|
|
9443
|
+
const v=window.Steel3DView;if(v&&v.clearRefMeasure3d)v.clearRefMeasure3d();
|
|
9444
|
+
if(had)renderRefsTab();
|
|
9445
|
+
}
|
|
9446
|
+
/**
|
|
9447
|
+
* Disarm the tool AND drop any result, when this reference stops being a thing you can measure.
|
|
9448
|
+
*
|
|
9449
|
+
* One helper rather than the same three lines at every call site, because the sites that need it are the
|
|
9450
|
+
* ones easiest to forget: removing the reference, re-reading its geometry, and — the one a first cut
|
|
9451
|
+
* missed — the tool being armed with no result yet, where a `refMeasure`-only guard sees nothing to clean
|
|
9452
|
+
* up and leaves the chip reading "Click the first point on this reference" over a dead id whose every
|
|
9453
|
+
* click is a silent no-op.
|
|
9454
|
+
*/
|
|
9455
|
+
function refMeasureDropFor(id){
|
|
9456
|
+
const v=window.Steel3DView;
|
|
9457
|
+
const armed=!!(v&&v.refMeasureState&&v.refMeasureState().refId===id);
|
|
9458
|
+
if(!armed&&!(refMeasure&&refMeasure.refId===id))return;
|
|
9459
|
+
if(v&&v.armRefMeasure3d)v.armRefMeasure3d(null);
|
|
9460
|
+
refMeasureClear();
|
|
9461
|
+
// ALWAYS repaint. refMeasureClear only does so when a MEASUREMENT existed, and disarming with no result is
|
|
9462
|
+
// the ordinary case — pressing the button a second time to stop. Without this the button went on reading
|
|
9463
|
+
// "Measuring - click to stop" over a tool that was no longer armed: the same lie the armed affordance was
|
|
9464
|
+
// added to stop telling, in the other direction. Caught in the browser pass.
|
|
9465
|
+
renderRefsTab();
|
|
9466
|
+
}
|
|
9467
|
+
/** The measured distance in the editor's own length format, plus the millimetres the input takes bare. */
|
|
9468
|
+
function refMeasureWords(mm){return fmtFtIn(mm/304.8*12)+' ('+Math.round(mm).toLocaleString('en-US')+' mm)';}
|
|
9469
|
+
/**
|
|
9470
|
+
* What typing this value would do — SHARED by the live caution and the accept, so the number the caution
|
|
9471
|
+
* names and the number the button applies can never be two different numbers. Returns null when the typed
|
|
9472
|
+
* value is not a positive finite length.
|
|
9473
|
+
*
|
|
9474
|
+
* IT COMPOSES WITH THE SCALE ALREADY APPLIED, and that is the whole arithmetic. `refMeasure.mm` is the
|
|
9475
|
+
* distance AS DRAWN — the snap points come off `matrixWorld`, which already includes `placement.scale` —
|
|
9476
|
+
* so the factor that makes the drawn distance equal the true one is `true/measured`, applied ON TOP of
|
|
9477
|
+
* what is there. Comparing against the file's own size instead is the bug `refScaleAdvice`'s comment
|
|
9478
|
+
* records on the other offer for this same field: the advice survived being taken, and a second click gave
|
|
9479
|
+
* 0.000001.
|
|
9480
|
+
*/
|
|
9481
|
+
function refMeasuredScaleOf(r,typed){
|
|
9482
|
+
if(!r||!refMeasure||refMeasure.refId!==r.id)return null; // not this reference's measurement - no offer to make
|
|
9483
|
+
const gc=GC();
|
|
9484
|
+
const trueMm=(gc&&gc.parseLen)?gc.parseLen(typed):NaN;
|
|
9485
|
+
const measured=refMeasure.mm;
|
|
9486
|
+
// A REASON, NOT A BARE null — the caller had four causes collapsed into one message. `trueMm>0` is
|
|
9487
|
+
// redundant against a VALID contract (a positive applied scale turns a non-positive typed distance
|
|
9488
|
+
// into a non-positive `next`, refused below) and is kept anyway: it stops being redundant exactly when
|
|
9489
|
+
// `placement.scale` is itself negative, which the schema forbids and a hand-edited file can carry.
|
|
9490
|
+
if(!(measured>0))return {bad:'measured'};
|
|
9491
|
+
if(!isFinite(trueMm)||!(trueMm>0))return {bad:'typed'};
|
|
9492
|
+
const applied=((r.placement&&r.placement.scale)||1);
|
|
9493
|
+
const next=applied*(trueMm/measured);
|
|
9494
|
+
// And THIS is the case worth naming rather than blaming the typing: a negative applied scale means a
|
|
9495
|
+
// perfectly good 6m is reported as not-a-length, and the user retypes it forever while the real fault
|
|
9496
|
+
// sits in the Scale box above.
|
|
9497
|
+
if(!isFinite(next)||!(next>0))return {bad:'scale'};
|
|
9498
|
+
const times=next>applied?next/applied:applied/next;
|
|
9499
|
+
return {applied,next,times,bigger:next>applied,
|
|
9500
|
+
timesWords:times>=1000?Math.round(times).toLocaleString('en-US')+'×':(Math.round(times*10)/10)+'×'};
|
|
9501
|
+
}
|
|
9502
|
+
/**
|
|
9503
|
+
* Turn "this is really 6 m" into a scale, through the SAME write every other scale edit uses.
|
|
9504
|
+
*
|
|
9505
|
+
* AN ABSURD FACTOR IS CAUTIONED, NOT REFUSED. A first cut hard-blocked anything outside [1e-6,1e6]; design
|
|
9506
|
+
* review overturned it on two grounds that both hold. The Scale box four rows up accepts any positive
|
|
9507
|
+
* number, so a gate here would be a second policy for one field. And it is recoverable in the way I had
|
|
9508
|
+
* assumed it was not — `snapshot()` does not capture `reference_models`, but the Scale box still shows the
|
|
9509
|
+
* value, so typing 1 back in IS the undo. What is left is a live warning, which is the honest shape: the
|
|
9510
|
+
* typed distance is the one quantity in this interaction the user actually knows.
|
|
9511
|
+
*/
|
|
9512
|
+
function refApplyMeasuredScale(id,typed){
|
|
9513
|
+
if(!canWriteModel())return;
|
|
9514
|
+
const r=refById(id);if(!r)return;
|
|
9515
|
+
const t=refMeasuredScaleOf(r,typed);
|
|
9516
|
+
if(!t||t.bad){
|
|
9517
|
+
toast(!t?'There is no measurement to set a scale from — measure two points first'
|
|
9518
|
+
:t.bad==='scale'?('“'+r.name+'” has a scale of '+((r.placement&&r.placement.scale))+', which is not a positive number — fix the Scale box first')
|
|
9519
|
+
:t.bad==='measured'?'That measurement has no length — measure two different points'
|
|
9520
|
+
:"That does not look like a length — try something like 6m, 20', or 6096");
|
|
9521
|
+
return;}
|
|
9522
|
+
// THE LOCK IS REFUSED BY `refEdit`, not by a branch of its own here — its toast is the one the Scale box
|
|
9523
|
+
// produces for the same act on the same field, and a second locked-state pattern for one field in one
|
|
9524
|
+
// panel is the drift.
|
|
9525
|
+
refEdit(id,{placement:{scale:t.next}});
|
|
9526
|
+
// …and THIS is the load-bearing line: refEdit refused the write, so the measurement must survive for the
|
|
9527
|
+
// user to unlock and press again rather than re-measure. Written as one guarded return over a shared
|
|
9528
|
+
// call, because the same thing spelled as two branches each ending in an identical refEdit reads as an
|
|
9529
|
+
// accident and the next simplifier collapses it — deleting this behaviour silently.
|
|
9530
|
+
if(refDisp(r).locked)return;
|
|
9531
|
+
// ASSERT THE WRITE, do not assume it. refEdit returns void and reports only the lock refusal, by
|
|
9532
|
+
// inference; every other refusal inside it (today canWriteModel(), which merely returns) would reach
|
|
9533
|
+
// the full success path — measurement discarded, tool disarmed, a toast claiming a scale was set that
|
|
9534
|
+
// was not. Reading the field back costs one line and turns that whole class into a visible failure.
|
|
9535
|
+
const written=(r.placement||{}).scale;
|
|
9536
|
+
if(written!==t.next){toast('Could not set the scale on “'+r.name+'” — nothing was changed');return;}
|
|
9537
|
+
refMeasureClear();
|
|
9538
|
+
const v=window.Steel3DView;if(v&&v.armRefMeasure3d)v.armRefMeasure3d(null); // the job is done — give the left-click back
|
|
9539
|
+
toast('Scale set — “'+r.name+'” now matches what you measured.');
|
|
9540
|
+
}
|
|
9541
|
+
|
|
9241
9542
|
// ── The References tab ────────────────────────────────────────────────────────────────────────────
|
|
9242
|
-
function renderRefsTab(){const host=document.getElementById('m3dRefsBody');if(!host)return;
|
|
9543
|
+
function renderRefsTab(){const host=document.getElementById('m3dRefsBody');if(!host)return;
|
|
9544
|
+
// WAS THE USER TYPING THE TRUE DISTANCE? This function replaces the whole tab, and several ordinary acts
|
|
9545
|
+
// reach it while the Stage D card is open — an opacity release, a lock toggle, geometry arriving for ANY
|
|
9546
|
+
// reference, a second measurement, refEdit itself. The typed TEXT survives on `refMeasure.typed`; what
|
|
9547
|
+
// does not survive on its own is the caret, and losing that mid-number is the difference between a
|
|
9548
|
+
// control that stutters and one that works.
|
|
9549
|
+
const _ae=document.activeElement;
|
|
9550
|
+
const _keepCaret=_ae&&_ae.id==='refMeasureTrue'?{start:_ae.selectionStart,end:_ae.selectionEnd}:null;
|
|
9551
|
+
host.replaceChildren();
|
|
9243
9552
|
const head=document.createElement('div');head.id='refHeadRow';
|
|
9244
9553
|
const add=document.createElement('button');add.type='button';add.id='refAddBtn';add.textContent='+ Add a reference model';
|
|
9245
9554
|
add.dataset.tip='Overlay an architect’s or engineer’s IFC to build against. It is never part of your steel.';
|
|
@@ -9251,6 +9560,11 @@ function renderRefsTab(){const host=document.getElementById('m3dRefsBody');if(!h
|
|
|
9251
9560
|
e.textContent='No reference models yet — add somebody else’s IFC to see it beside your steel and snap to it. It never enters your BOM, an export, or the lock.';
|
|
9252
9561
|
host.appendChild(e);return;}
|
|
9253
9562
|
for(const r of all){host.appendChild(buildRefRow(r));if(r.id===refSelectedId)host.appendChild(buildRefDetail(r));}
|
|
9563
|
+
// …and put the caret back where it was. Done here rather than in buildRefMeasureCard because focus only
|
|
9564
|
+
// takes on a node that is IN the document, and the card is not attached until the loop above runs.
|
|
9565
|
+
if(_keepCaret){const el=document.getElementById('refMeasureTrue');
|
|
9566
|
+
if(el&&el.focus){el.focus();
|
|
9567
|
+
try{if(el.setSelectionRange)el.setSelectionRange(_keepCaret.start,_keepCaret.end);}catch(e){console.warn('[reference] could not restore the caret in the measure box',e);}}}
|
|
9254
9568
|
}
|
|
9255
9569
|
|
|
9256
9570
|
function buildRefRow(r){
|
|
@@ -9308,12 +9622,16 @@ function buildRefRow(r){
|
|
|
9308
9622
|
row.appendChild(zoom);
|
|
9309
9623
|
|
|
9310
9624
|
const dots=Object.assign(document.createElement('span'),{className:'refdots',textContent:'⋯'});
|
|
9311
|
-
|
|
9625
|
+
// The tip ENUMERATES the menu, so adding an item without touching it leaves the anchor advertising a
|
|
9626
|
+
// menu that no longer exists. (Caught in the browser pass: Stage D's item shipped while this still read
|
|
9627
|
+
// "move it next to your model, reload, remove".)
|
|
9628
|
+
dots.setAttribute('role','button');dots.dataset.tip='More — measure a distance, move it next to your model, reload, remove';
|
|
9312
9629
|
dots.addEventListener('click',e=>{e.stopPropagation();openRefRowMenu(r,dots);});
|
|
9313
9630
|
row.appendChild(dots);
|
|
9314
9631
|
|
|
9315
9632
|
row.addEventListener('click',()=>{
|
|
9316
9633
|
refSelectedId=refSelectedId===r.id?null:r.id;
|
|
9634
|
+
refMeasureFollowSelection(); // this handler TOGGLES, so one click can collapse the measured row
|
|
9317
9635
|
refSelectedObjIdx=null; // picking a WHOLE reference from the row leaves no object drilled into — same rule the 3D layer's `selectReference` follows, so the two surfaces cannot disagree
|
|
9318
9636
|
if(window.Steel3DView&&window.Steel3DView.selectReference)window.Steel3DView.selectReference(refSelectedId);
|
|
9319
9637
|
renderRefsTab();panel();});
|
|
@@ -9479,11 +9797,49 @@ function buildRefDetail(r){
|
|
|
9479
9797
|
refEdit(r.id,{placement:{scale:v}});});
|
|
9480
9798
|
sRow.appendChild(sc);wrap.appendChild(sRow);
|
|
9481
9799
|
|
|
9800
|
+
// THE SECOND DOOR INTO THE MEASURE (S2 Stage D). The ⋯ item is where a user browsing what a reference can
|
|
9801
|
+
// do finds it; this is where a user staring at a Scale value they know is wrong is already looking, so
|
|
9802
|
+
// the offer belongs at the point of pain too — in the same ghost weight as the two fix buttons below.
|
|
9803
|
+
// Gated on there being geometry, the same rule and the same reason as the ⋯ item.
|
|
9804
|
+
if(refGeom.has(r.id)){
|
|
9805
|
+
// THE BUTTON REPORTS THE TOOL'S STATE, and a second press turns it off. Without this, Clear left the
|
|
9806
|
+
// panel looking exactly like the never-armed state while every canvas click was still being eaten by
|
|
9807
|
+
// the measure, and there was no way to put the left-click back except Esc or arming something else.
|
|
9808
|
+
const armedNow=refMeasureArmedOn(r.id);
|
|
9809
|
+
const mb=document.createElement('button');mb.type='button';mb.className='ghost'+(armedNow?' on':'');mb.id='refMeasureBtn';
|
|
9810
|
+
mb.style.marginTop='6px';mb.textContent=armedNow?'Measuring — click to stop':'Measure a distance →';
|
|
9811
|
+
mb.setAttribute('aria-pressed',String(armedNow));
|
|
9812
|
+
mb.dataset.tip=armedNow?'Stop measuring and give the left-click back to selecting.':REF_MEASURE_TIP;
|
|
9813
|
+
mb.addEventListener('click',()=>{if(refMeasureArmedOn(r.id))refMeasureDropFor(r.id);else refMeasureArm(r.id);});
|
|
9814
|
+
wrap.appendChild(mb);
|
|
9815
|
+
// IN PROSE, NOT IN A TOOLTIP — the same treatment and the same gating as the Ctrl+click drill note
|
|
9816
|
+
// above, for the reason that note states: a tooltip is hover-driven and reaches neither a keyboard nor a
|
|
9817
|
+
// screen-reader user, and a two-click canvas gesture is precisely the thing they cannot discover by
|
|
9818
|
+
// hovering. The half of this flow after the result — the box and both buttons — is ordinary form chrome
|
|
9819
|
+
// and is fully reachable; the picking half is not, which is the same gap the Dimension tool and the
|
|
9820
|
+
// grid-line pick already have and is not Stage D's to close.
|
|
9821
|
+
wrap.appendChild(Object.assign(document.createElement('div'),{className:'dnote',
|
|
9822
|
+
textContent:'Pick two points on this reference in the 3D view to measure the distance between them, then tell us what that distance should really be.'}));
|
|
9823
|
+
}
|
|
9824
|
+
|
|
9825
|
+
// EVIDENCE BEATS A GUESS. Both offers write `placement.scale`, and `refScaleAdvice` is a span-similarity
|
|
9826
|
+
// heuristic while a measurement is a distance the user knows. Putting "Scale ×0.001" beside "you measured
|
|
9827
|
+
// 6,096 mm" asks them to adjudicate between the two, and the guess can win. Suppressed only for the
|
|
9828
|
+
// reference that HAS the measurement, and only while it is on screen: taking or clearing it restores the
|
|
9829
|
+
// advisory, recomputed against whatever scale is then applied — which is refScaleAdvice's own behaviour,
|
|
9830
|
+
// so this needs no dismissed-flag of its own.
|
|
9831
|
+
// ARMED **OR** HOLDING A RESULT. Keying on the result alone left the guess live through the whole of
|
|
9832
|
+
// the armed-with-first-point state — with its Scale x1000 button one row above the card, one click
|
|
9833
|
+
// from changing the very scale the half-finished pick was taken at. That is the window the stale-pick
|
|
9834
|
+
// bug lived in, and suppressing the offer is half of closing it.
|
|
9835
|
+
const measuring=!!(refMeasure&&refMeasure.refId===r.id)||refMeasureArmedOn(r.id);
|
|
9836
|
+
if(refMeasure&&refMeasure.refId===r.id)wrap.appendChild(buildRefMeasureCard(r));
|
|
9837
|
+
|
|
9482
9838
|
// The scale advisory, on a measurement that can bear it: `spanMm` is computed server-side from the
|
|
9483
9839
|
// vertices the reader actually returned. The pre-insert modal deliberately offers none, because
|
|
9484
9840
|
// before tessellation the only number available is the reader's bbox, which spans everything the file
|
|
9485
9841
|
// MENTIONS (74 m for a 3.6 m shaft) and would offer to permanently mis-scale a correct reference.
|
|
9486
|
-
const scale=refScaleAdvice(r.id);
|
|
9842
|
+
const scale=measuring?null:refScaleAdvice(r.id);
|
|
9487
9843
|
if(scale){
|
|
9488
9844
|
const w=Object.assign(document.createElement('div'),{className:'dwarn'});
|
|
9489
9845
|
w.textContent='This looks about '+scale.words+' your model. If the file states the wrong units, this is the usual fix.';
|
|
@@ -9506,6 +9862,74 @@ function buildRefDetail(r){
|
|
|
9506
9862
|
return wrap;
|
|
9507
9863
|
}
|
|
9508
9864
|
|
|
9865
|
+
/**
|
|
9866
|
+
* What the two clicks measured, and the one question that turns it into a scale (S2 Stage D).
|
|
9867
|
+
*
|
|
9868
|
+
* IT SITS IN THE DETAIL BLOCK, not over the canvas, because it is a RECORD rather than a hint: it has to
|
|
9869
|
+
* survive the second click while the user composes an answer. A card that follows the cursor is a moving
|
|
9870
|
+
* target the instant the mouse leaves it, and it would have to carry a text input — which either follows
|
|
9871
|
+
* the cursor too (unworkable) or snaps to a fixed spot, at which point it is a worse-positioned panel.
|
|
9872
|
+
* The canvas keeps the half the panel cannot show: the dashed segment stays drawn with its value on it,
|
|
9873
|
+
* and the cursor readout carries the running distance while the second point is still being aimed.
|
|
9874
|
+
* This is also where `placement.scale` already lives — Scale is one row up and the heuristic advisory
|
|
9875
|
+
* occupies the very slot below — so the number the user just set is where they would look for it.
|
|
9876
|
+
*/
|
|
9877
|
+
function buildRefMeasureCard(r){
|
|
9878
|
+
const box=Object.assign(document.createElement('div'),{className:'dmeas'});
|
|
9879
|
+
box.id='refMeasureCard';
|
|
9880
|
+
const head=document.createElement('div');head.className='drow';
|
|
9881
|
+
head.appendChild(Object.assign(document.createElement('span'),{className:'dlab',textContent:'Measured'}));
|
|
9882
|
+
head.appendChild(Object.assign(document.createElement('span'),{id:'refMeasureVal',
|
|
9883
|
+
textContent:refMeasureWords(refMeasure.mm)+', at this reference’s scale right now'}));
|
|
9884
|
+
box.appendChild(head);
|
|
9885
|
+
|
|
9886
|
+
const row=document.createElement('div');row.className='drow';
|
|
9887
|
+
row.appendChild(Object.assign(document.createElement('span'),{className:'dlab',textContent:'Really'}));
|
|
9888
|
+
const inp=document.createElement('input');inp.type='text';inp.id='refMeasureTrue';
|
|
9889
|
+
inp.style.cssText='flex:1;min-width:0';inp.placeholder='e.g. 6m, 20\', 6096';
|
|
9890
|
+
inp.value=refMeasure.typed||''; // survives a rebuild — see refMeasure's doc comment
|
|
9891
|
+
inp.setAttribute('aria-label','What should that distance really be?');
|
|
9892
|
+
// ASCII apostrophe in the EXAMPLE, deliberately: parseLen's regex matches ' and not the typographic ’,
|
|
9893
|
+
// so a tip that showed the pretty one would teach a character the parser rejects.
|
|
9894
|
+
inp.dataset.tip='What that distance really is. 20\' feet, 6m metres, a bare number millimetres.';
|
|
9895
|
+
row.appendChild(inp);box.appendChild(row);
|
|
9896
|
+
|
|
9897
|
+
// THE CAUTION IS LIVE AND IT DOES NOT BLOCK — see refApplyMeasuredScale for why a hard gate was dropped.
|
|
9898
|
+
const warn=Object.assign(document.createElement('div'),{className:'dwarn',id:'refMeasureWarn'});
|
|
9899
|
+
warn.style.display='none';box.appendChild(warn);
|
|
9900
|
+
const reflect=()=>{
|
|
9901
|
+
refMeasure.typed=inp.value; // keep it OUTSIDE the DOM, so a re-render cannot eat it
|
|
9902
|
+
const t=refMeasuredScaleOf(r,inp.value);
|
|
9903
|
+
// The factor the caution is about to name, left where a test can read it. Without it the only way to
|
|
9904
|
+
// check that the caution and the button agree is to recompute — which is what the test claiming to
|
|
9905
|
+
// compare them was actually doing, so a caution that doubled its own number went unnoticed.
|
|
9906
|
+
warn.dataset.next=(t&&!t.bad&&isFinite(t.next))?String(t.next):'';
|
|
9907
|
+
// CLEARED, NOT JUST HIDDEN. An independent QA pass read this element's text after it had been hidden
|
|
9908
|
+
// and reported the feature as computing wrong ratios — because a hidden node still carrying 'about
|
|
9909
|
+
// 1,000x smaller' from three keystrokes ago is a false statement waiting for anything to show it. The
|
|
9910
|
+
// arithmetic was right; the leftover was not.
|
|
9911
|
+
if(!t||t.bad||!(t.times>=10)){warn.textContent='';warn.style.display='none';return;}
|
|
9912
|
+
warn.textContent='That would make this reference about '+t.timesWords+' '+(t.bigger?'bigger':'smaller')+
|
|
9913
|
+
' than it is now. Double-check you picked the right two points and typed the right units.';
|
|
9914
|
+
warn.style.display='';};
|
|
9915
|
+
inp.addEventListener('input',reflect);
|
|
9916
|
+
|
|
9917
|
+
const btns=document.createElement('div');btns.className='drow';
|
|
9918
|
+
const set=document.createElement('button');set.type='button';set.className='ghost';set.id='refMeasureSet';
|
|
9919
|
+
set.textContent='Set scale from this';
|
|
9920
|
+
set.dataset.tip='Set this reference’s scale so your two points measure exactly what you typed.';
|
|
9921
|
+
set.addEventListener('click',()=>refApplyMeasuredScale(r.id,inp.value));
|
|
9922
|
+
inp.addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();refApplyMeasuredScale(r.id,inp.value);}});
|
|
9923
|
+
const clr=document.createElement('button');clr.type='button';clr.className='ghost';clr.id='refMeasureClearBtn';
|
|
9924
|
+
clr.textContent='Clear';clr.dataset.tip='Discard this measurement — nothing has been saved.';
|
|
9925
|
+
clr.addEventListener('click',()=>refMeasureClear());
|
|
9926
|
+
// NO LOCKED SPECIAL-CASE, deliberately — refEdit already refuses a placement patch on a locked reference
|
|
9927
|
+
// with its own toast, which is exactly how the sibling Scale box behaves. See refApplyMeasuredScale.
|
|
9928
|
+
btns.append(set,clr);box.appendChild(btns);
|
|
9929
|
+
reflect(); // a restored `typed` gets its caution back with it
|
|
9930
|
+
return box;
|
|
9931
|
+
}
|
|
9932
|
+
|
|
9509
9933
|
// ── The drilled-into reference object (S2 Stage A) ────────────────────────────────────────────────
|
|
9510
9934
|
//
|
|
9511
9935
|
// Ctrl+click one object inside a reference and this is what the Inspect panel shows: what the FILE says
|
|
@@ -10215,6 +10639,15 @@ function unitWords(declared){
|
|
|
10215
10639
|
* general-purpose nudge after a manual drag.)
|
|
10216
10640
|
*/
|
|
10217
10641
|
const REF_MOVE_LABEL='Move it next to your model';
|
|
10642
|
+
/**
|
|
10643
|
+
* The measure's label and its one-sentence explanation, in ONE place for exactly the reason above: there
|
|
10644
|
+
* are two doors into this tool — the ⋯ item and the ghost button beside the Scale box — and the same
|
|
10645
|
+
* action wearing two independently-edited labels is a drift waiting to happen. (Both are deliberately
|
|
10646
|
+
* kept: the ⋯ item is where a user browsing what a reference CAN do finds it, and the panel button is
|
|
10647
|
+
* where a user staring at a Scale value they know is wrong is already looking.)
|
|
10648
|
+
*/
|
|
10649
|
+
const REF_MEASURE_LABEL='Measure a distance on it';
|
|
10650
|
+
const REF_MEASURE_TIP='Pick two points on this reference, tell us what that distance really is, and we’ll scale it to match.';
|
|
10218
10651
|
/**
|
|
10219
10652
|
* Shift a reference so its centre lands ON THE MODEL — the fix the Motebello measurement earned.
|
|
10220
10653
|
*
|
|
@@ -10250,6 +10683,11 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
10250
10683
|
const m=document.createElement('div');m.id='refRowMenu';m.className='m3dmenu open';m.setAttribute('role','menu');
|
|
10251
10684
|
const mk=(label,fn,danger)=>{const b=document.createElement('button');b.type='button';b.textContent=label;if(danger)b.className='mdanger';b.setAttribute('role','menuitem');b.addEventListener('click',()=>{closeRefRowMenu();fn();});return b;};
|
|
10252
10685
|
m.append(mk('Zoom to it',()=>{if(window.Steel3DView)window.Steel3DView.frameReference(r.id);}));
|
|
10686
|
+
// Offered only where there is something to measure — the same rule the move item follows below, and for
|
|
10687
|
+
// the same stated reason: an enabled item that can do nothing but toast a refusal is a worse answer than
|
|
10688
|
+
// no item. (refMeasureArm keeps its own refusal anyway; a guard that lives only in the caller is one
|
|
10689
|
+
// refactor from being gone.)
|
|
10690
|
+
if(refGeom.has(r.id))m.append(mk(REF_MEASURE_LABEL,()=>refMeasureArm(r.id)));
|
|
10253
10691
|
// OFFERED ONLY WHEN THERE IS SOMETHING TO BE NEXT TO. Loading a reference before modelling any steel is
|
|
10254
10692
|
// a normal first move, and in that state this command can do nothing but toast a refusal — an enabled
|
|
10255
10693
|
// item that always fails is a worse answer than no item. Omitted rather than disabled, which is how
|
|
@@ -10259,6 +10697,11 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
10259
10697
|
if(nativeModelBounds())m.append(mk(REF_MOVE_LABEL,()=>refMoveToOrigin(r.id)));
|
|
10260
10698
|
m.append(mk('Reload its geometry',()=>{
|
|
10261
10699
|
if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to reload it');return;} // the lock freezes reload, as the schema says
|
|
10700
|
+
// A MEASUREMENT OF THIS REFERENCE DOES NOT SURVIVE ITS GEOMETRY BEING RE-READ. The dashed
|
|
10701
|
+
// segment is drawn at world points taken off the OLD tessellation, so keeping it would leave a
|
|
10702
|
+
// line — and a number the panel invites you to scale from — floating beside geometry it no
|
|
10703
|
+
// longer describes. Same reasoning the tree's positional group keys are dropped two lines down.
|
|
10704
|
+
refMeasureDropFor(r.id);
|
|
10262
10705
|
refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);
|
|
10263
10706
|
// The tree's group keys are POSITIONAL ('2:1' is the second storey's second type), so a
|
|
10264
10707
|
// re-read that adds, drops or reorders anything makes them address different groups. Dropped
|
|
@@ -10296,6 +10739,9 @@ async function refRemove(r){
|
|
|
10296
10739
|
refGeom.delete(r.id);refUnresolved.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);
|
|
10297
10740
|
refTreeOpen.delete(r.id);refTreeGroups.delete(r.id);refTreeQuery.delete(r.id); // the tree goes with the reference
|
|
10298
10741
|
if(refSelectedId===r.id){refSelectedId=null;refSelectedObjIdx=null;} // the object drilled into goes with the reference it was inside — leaving the index behind would point the panel into a reference that no longer exists
|
|
10742
|
+
// …and so does a measurement of it, for the same reason one rung down: the dashed segment and the offer
|
|
10743
|
+
// to scale from it would outlive the thing they describe, and the offer's write target no longer exists.
|
|
10744
|
+
refMeasureDropFor(r.id);
|
|
10299
10745
|
pushReferences();renderRefsTab();panel();
|
|
10300
10746
|
}catch(_){toast('Could not remove that reference');}
|
|
10301
10747
|
}
|
|
@@ -10347,11 +10793,246 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10347
10793
|
if(!view3d){toast('Switch to the 3D view to add a reference model');return;}
|
|
10348
10794
|
riStop(); // a previous attempt's in-flight probe must not answer into this one
|
|
10349
10795
|
riSha=null;riName='';riVerdict=null;riProbeCentre=null;riErr('');ri$('riDrop').classList.remove('drag');
|
|
10796
|
+
riBuildPick(null); // and the picker, so a cancelled file's storeys never show under a new name
|
|
10350
10797
|
riStage('drop');ri$('refImportModal').style.display='flex';}
|
|
10351
10798
|
window.openRefImport=openRefImport;
|
|
10352
10799
|
function riClose(){riStop();riClearSoft();ri$('refImportModal').style.display='none';}
|
|
10353
10800
|
|
|
10354
10801
|
const RI_MAX_BYTES=150*1024*1024; // mirrors MAX_BYTES in server/reference-import.ts (pinned by the parity test)
|
|
10802
|
+
// Mirrors MAX_OBJECTS / WARN_OBJECTS in server/reference-import.ts (pinned by the same parity test).
|
|
10803
|
+
// MIRRORED rather than fetched because the picker re-judges the total on every checkbox: a round
|
|
10804
|
+
// trip per tick is not a control. The SERVER still owns the decision — it refuses the insert on its
|
|
10805
|
+
// own count, twice — so this copy only ever tells the user what is about to happen.
|
|
10806
|
+
// DECLARED SEPARATELY, one `const` each. The parity test reads these as source text and matches
|
|
10807
|
+
// `const NAME = …`, so a single statement with two declarators hides the second one from the guard
|
|
10808
|
+
// entirely — which is a mirror that silently stops being checked.
|
|
10809
|
+
const REF_MAX_OBJECTS=20000;
|
|
10810
|
+
const REF_WARN_OBJECTS=11000;
|
|
10811
|
+
|
|
10812
|
+
// ── The storey / type picker (S2 Stage C) ───────────────────────────────────────────────────────
|
|
10813
|
+
// `null` on either axis means "everything", which is NOT the same as a Set holding every name: the
|
|
10814
|
+
// former omits the key from the request and reads the whole file, the latter narrows to a list. That
|
|
10815
|
+
// distinction is the whole feature — see riBuildFilter.
|
|
10816
|
+
let riProbeRows=null; // {storeys, types} as the probe reported them, or null
|
|
10817
|
+
let riPopulation=null; // the whole-file estimate, or null when the bridge offered no breakdown
|
|
10818
|
+
// Sets hold the file's OWN spelling of each name, never a normalised one. The reader matches
|
|
10819
|
+
// case-insensitively, so lower-casing them worked — and quietly wrote "basement" onto the
|
|
10820
|
+
// contract for a file that says "BASEMENT". The stored filter is meant to be what `probe`
|
|
10821
|
+
// reported; a real browser pass caught it, no unit test could have. Exact matching is also
|
|
10822
|
+
// correct here because every name in a Set came from the very rows being compared against.
|
|
10823
|
+
let riStoreyPick=null,riTypePick=null; // Set of chosen names, or null for "all"
|
|
10824
|
+
|
|
10825
|
+
/** Rows a filter can actually name. The storey-less row is excluded: no filter value reaches it. */
|
|
10826
|
+
const riSelectable=rows=>(rows||[]).filter(r=>r&&r.name!==null);
|
|
10827
|
+
|
|
10828
|
+
/**
|
|
10829
|
+
* The estimate for the current selection — the SAME rule as the server's `selectedPopulation`.
|
|
10830
|
+
*
|
|
10831
|
+
* A `min` of two independent sums, and therefore a heuristic rather than a bound: the two axes
|
|
10832
|
+
* intersect, and two separate breakdowns cannot express an intersection. Measured on a real file, a
|
|
10833
|
+
* storey with 7 and a type with 6 share ZERO objects while this returns 6. That is why nothing in the
|
|
10834
|
+
* UI states this number as a fact about the combination — see riPickNote.
|
|
10835
|
+
*/
|
|
10836
|
+
function riEstimate(){
|
|
10837
|
+
if(!riProbeRows)return null;
|
|
10838
|
+
if(riStoreyPick===null&&riTypePick===null)return riPopulation;
|
|
10839
|
+
const sumOf=(rows,want)=>{
|
|
10840
|
+
if(!rows||want===null)return null;
|
|
10841
|
+
const hit=rows.filter(r=>r.name!==null&&want.has(r.name));
|
|
10842
|
+
// NOTHING MATCHED IS NO ESTIMATE, NOT ZERO — the same rule the server applies, for the same
|
|
10843
|
+
// reason: zero would read as "this selection is tiny" when it means "we cannot tell".
|
|
10844
|
+
return hit.length?hit.reduce((n,r)=>n+r.elements,0):null;
|
|
10845
|
+
};
|
|
10846
|
+
const sums=[sumOf(riProbeRows.storeys,riStoreyPick),sumOf(riProbeRows.types,riTypePick)].filter(n=>n!==null);
|
|
10847
|
+
return sums.length?Math.min(...sums):null;
|
|
10848
|
+
}
|
|
10849
|
+
const riVerdictOf=n=>(!Number.isFinite(n)?null:n>REF_MAX_OBJECTS?'refuse':n>=REF_WARN_OBJECTS?'warn':'ok');
|
|
10850
|
+
|
|
10851
|
+
/**
|
|
10852
|
+
* What to send with the insert — `undefined` for "the whole file".
|
|
10853
|
+
*
|
|
10854
|
+
* ALL-CHECKED COLLAPSES TO OMITTING THE KEY rather than listing every name, and that is not merely
|
|
10855
|
+
* tidier: an explicit full list is a filter, so it would make the server demand a `selected` receipt
|
|
10856
|
+
* and would run the estimate through the min-heuristic for a case that is exactly known. Omitting is
|
|
10857
|
+
* also the only spelling the reader reads as "unfiltered" — an empty list means "select nothing".
|
|
10858
|
+
*/
|
|
10859
|
+
function riBuildFilter(){
|
|
10860
|
+
if(riStoreyPick===null&&riTypePick===null)return undefined; // untouched: the whole file
|
|
10861
|
+
const f={};
|
|
10862
|
+
if(riStoreyPick!==null)f.storeys=[...riStoreyPick];
|
|
10863
|
+
if(riTypePick!==null)f.ifcTypes=[...riTypePick];
|
|
10864
|
+
// AN EMPTIED PICK IS SENT AS EMPTY, NOT DROPPED. Returning `undefined` here would say "the whole
|
|
10865
|
+
// file" for a user who had just cleared every row — the one inference the route refuses outright,
|
|
10866
|
+
// reimplemented on this side of the wire. The server answers it with `reference-empty-filter`;
|
|
10867
|
+
// relying on the Add button being disabled would make a UI state the only guard against reading a
|
|
10868
|
+
// whole building. (Code review.)
|
|
10869
|
+
return f;
|
|
10870
|
+
}
|
|
10871
|
+
|
|
10872
|
+
/** Has the user narrowed an axis to nothing? The server refuses this; the button refuses it sooner. */
|
|
10873
|
+
const riEmptyPick=()=>(riStoreyPick!==null&&riStoreyPick.size===0)||(riTypePick!==null&&riTypePick.size===0);
|
|
10874
|
+
|
|
10875
|
+
/** One list of checkboxes. `pick` is null for "all", so a fresh render starts every row checked. */
|
|
10876
|
+
function riRenderRows(host,rows,pick,onToggle){
|
|
10877
|
+
host.replaceChildren();
|
|
10878
|
+
for(const r of rows||[]){
|
|
10879
|
+
if(r.name===null){
|
|
10880
|
+
// NOT A DISABLED CHECKBOX. A disabled control says "you may not do this yet"; the truth is that
|
|
10881
|
+
// the reader skips unnamed-storey rows entirely, so no filter value can ever select these and
|
|
10882
|
+
// there is no control to disable. They load only while the storey axis is untouched — which is
|
|
10883
|
+
// what the note says, and it is re-derived on every render rather than toggled.
|
|
10884
|
+
const row=document.createElement('div');row.className='ripick-row ripick-row--fixed';
|
|
10885
|
+
row.dataset.tip='Not assigned to any storey in the file, so a storey filter can never pick these out on their own. They load only while every storey is selected.';
|
|
10886
|
+
const dash=document.createElement('span');dash.className='rpfixed';dash.setAttribute('aria-hidden','true');dash.textContent='—';
|
|
10887
|
+
const nm=document.createElement('span');nm.className='rpname';nm.textContent='Not on any storey';
|
|
10888
|
+
const ct=document.createElement('span');ct.className='rpcount';ct.textContent=r.elements.toLocaleString();
|
|
10889
|
+
const note=document.createElement('span');note.className='rpnote';
|
|
10890
|
+
note.textContent=pick===null?'Included':'Excluded — can’t be selected';
|
|
10891
|
+
row.append(dash,nm,ct,note);host.appendChild(row);
|
|
10892
|
+
continue;
|
|
10893
|
+
}
|
|
10894
|
+
const row=document.createElement('label');row.className='ripick-row';
|
|
10895
|
+
const cb=document.createElement('input');cb.type='checkbox';
|
|
10896
|
+
cb.checked=pick===null||pick.has(r.name);
|
|
10897
|
+
cb.addEventListener('change',()=>onToggle(r.name,cb.checked));
|
|
10898
|
+
const nm=document.createElement('span');nm.className='rpname';nm.textContent=r.name;
|
|
10899
|
+
const ct=document.createElement('span');ct.className='rpcount';ct.textContent=r.elements.toLocaleString();
|
|
10900
|
+
row.append(cb,nm,ct);host.appendChild(row);
|
|
10901
|
+
}
|
|
10902
|
+
}
|
|
10903
|
+
|
|
10904
|
+
/** Repaint everything the selection governs: both lists, both toggles, the count and the button. */
|
|
10905
|
+
function riPaintPick(refocus){
|
|
10906
|
+
if(!riProbeRows)return;
|
|
10907
|
+
const sRows=riSelectable(riProbeRows.storeys),tRows=riSelectable(riProbeRows.types);
|
|
10908
|
+
riRenderRows(ri$('riStoreyList'),riProbeRows.storeys,riStoreyPick,(name,on)=>{
|
|
10909
|
+
if(riStoreyPick===null)riStoreyPick=new Set(sRows.map(r=>r.name));
|
|
10910
|
+
on?riStoreyPick.add(name):riStoreyPick.delete(name);
|
|
10911
|
+
if(riStoreyPick.size===sRows.length)riStoreyPick=null; // back to "all" — omit the key entirely
|
|
10912
|
+
riPaintPick({host:'riStoreyList',name});
|
|
10913
|
+
});
|
|
10914
|
+
riRenderRows(ri$('riTypeList'),riProbeRows.types,riTypePick,(name,on)=>{
|
|
10915
|
+
if(riTypePick===null)riTypePick=new Set(tRows.map(r=>r.name));
|
|
10916
|
+
on?riTypePick.add(name):riTypePick.delete(name);
|
|
10917
|
+
if(riTypePick.size===tRows.length)riTypePick=null;
|
|
10918
|
+
riPaintPick({host:'riTypeList',name});
|
|
10919
|
+
});
|
|
10920
|
+
const state=(pick,total)=>pick===null?'on':pick.size===0?'off':pick.size===total?'on':'mixed';
|
|
10921
|
+
const sTog=ri$('riStoreyAll'),tTog=ri$('riTypeAll');
|
|
10922
|
+
for(const [tog,pick,total] of [[sTog,riStoreyPick,sRows.length],[tTog,riTypePick,tRows.length]]){
|
|
10923
|
+
const st=state(pick,total);
|
|
10924
|
+
tog.dataset.state=st;tog.textContent=st==='on'?'☑':st==='off'?'☐':'▣';
|
|
10925
|
+
tog.setAttribute('aria-label',(st==='on'?'Clear':'Select')+' every '+(tog===sTog?'storey':'type'));
|
|
10926
|
+
}
|
|
10927
|
+
// Put the keyboard back where it was. The rows are rebuilt wholesale, so the element that fired the
|
|
10928
|
+
// change event no longer exists; without this a keyboard user is thrown to the top of the modal on
|
|
10929
|
+
// every single tick. Matched by NAME rather than index because a repaint can reorder nothing today
|
|
10930
|
+
// but would silently mis-focus if it ever did.
|
|
10931
|
+
if(refocus){
|
|
10932
|
+
const host=ri$(refocus.host);
|
|
10933
|
+
for(const l of host.querySelectorAll('label.ripick-row')){
|
|
10934
|
+
if(l.querySelector('.rpname')?.textContent===refocus.name){l.querySelector('input')?.focus();break;}
|
|
10935
|
+
}
|
|
10936
|
+
}
|
|
10937
|
+
ri$('riStoreyCount').textContent=sRows.length+' in this file';
|
|
10938
|
+
ri$('riTypeCount').textContent=tRows.length+' in this file';
|
|
10939
|
+
// THE STANDING NOTE, present exactly while both axes are narrowed. It says what the mechanic IS
|
|
10940
|
+
// rather than predicting a number: the estimate here is a min of two independent sums and can be
|
|
10941
|
+
// far above the truth (measured 6 where the real intersection was 0), so a sentence built on it
|
|
10942
|
+
// would state a wrong count as fact.
|
|
10943
|
+
const both=riStoreyPick!==null&&riTypePick!==null;
|
|
10944
|
+
const note=ri$('riPickNote');
|
|
10945
|
+
note.textContent=both?'Storeys and types narrow together — an object has to match BOTH to load, so picking from each can give you far fewer objects than either one alone.':'';
|
|
10946
|
+
note.style.display=both?'block':'none';
|
|
10947
|
+
riPaintCount();
|
|
10948
|
+
}
|
|
10949
|
+
|
|
10950
|
+
/** The live count, its two loud states, and the button they govern. */
|
|
10951
|
+
function riPaintCount(){
|
|
10952
|
+
// `riEstimate()` needs the rows; when there is no picker there are none, so the whole-file
|
|
10953
|
+
// population is the estimate. Reading `riEstimate()` unconditionally printed "—" over the correct
|
|
10954
|
+
// number for a file whose breakdown has one half present and the other missing — a state
|
|
10955
|
+
// `readPopulation` documents as reachable. (Second review round.)
|
|
10956
|
+
const n=riProbeRows?riEstimate():riPopulation;
|
|
10957
|
+
const v=riVerdictOf(n),empty=riEmptyPick();
|
|
10958
|
+
const canPick=!!riProbeRows;
|
|
10959
|
+
const el=ri$('riElements'),foot=ri$('riFootNote'),add=ri$('riInsert');
|
|
10960
|
+
el.classList.remove('warn','refuse');foot.classList.remove('warn','refuse');
|
|
10961
|
+
// THE REFUSAL DOES NOT OUTLIVE THE FIX. Staying on the confirm stage exists so the user can act on
|
|
10962
|
+
// "choose fewer storeys" — so the red sentence has to clear as they do, or they watch the live
|
|
10963
|
+
// count fall to a safe number underneath a message still quoting the old one.
|
|
10964
|
+
{const e=ri$('riConfirmErr');if(e.style.display!=='none'){e.textContent='';e.style.display='none';}}
|
|
10965
|
+
el.textContent=n===null?'—':'~'+n.toLocaleString();
|
|
10966
|
+
let msg='';
|
|
10967
|
+
if(empty){
|
|
10968
|
+
el.classList.add('refuse');
|
|
10969
|
+
msg='Nothing is selected, so there would be nothing to load. Tick at least one storey or type.';
|
|
10970
|
+
}else if(v==='refuse'){
|
|
10971
|
+
el.classList.add('refuse');
|
|
10972
|
+
// THE REMEDY MUST BE ONE THEY HAVE. With no picker on screen there is nothing to uncheck, and the
|
|
10973
|
+
// first version of this branch hard-blocked the user with an instruction they could not follow —
|
|
10974
|
+
// the same client/server mismatch `pickerCanExist` exists to remove, in the other direction.
|
|
10975
|
+
msg='About '+n.toLocaleString()+' objects — over FloLess’s limit of '+REF_MAX_OBJECTS.toLocaleString()+' for one reference. '
|
|
10976
|
+
+(canPick?'Uncheck some storeys or types to bring it under.'
|
|
10977
|
+
:'This file doesn’t offer storeys or types to load part of it, so it can only be exported smaller.');
|
|
10978
|
+
}else if(v==='warn'){
|
|
10979
|
+
el.classList.add('warn');
|
|
10980
|
+
msg='About '+n.toLocaleString()+' objects — this will take a while to load and may feel slow to navigate.';
|
|
10981
|
+
}
|
|
10982
|
+
foot.textContent=msg;
|
|
10983
|
+
if(msg)foot.classList.add(empty||v==='refuse'?'refuse':'warn'); // never tag a note that is not shown
|
|
10984
|
+
foot.style.display=msg?'block':'none';
|
|
10985
|
+
// DISABLED, not merely warned. The server refuses both of these anyway — this only saves the user
|
|
10986
|
+
// the upload and the wait before being told.
|
|
10987
|
+
const blocked=empty||v==='refuse';
|
|
10988
|
+
add.disabled=blocked;
|
|
10989
|
+
add.dataset.tip=blocked
|
|
10990
|
+
?(empty?'Tick at least one storey or type first'
|
|
10991
|
+
:canPick?'This selection is over the limit — uncheck some rows'
|
|
10992
|
+
:'This file is over the limit and cannot be loaded in parts')
|
|
10993
|
+
:'Add this model as a reference. It is never part of your steel.';
|
|
10994
|
+
}
|
|
10995
|
+
|
|
10996
|
+
/**
|
|
10997
|
+
* Build the picker for a freshly probed file — or explain, in the same slot, why there is none.
|
|
10998
|
+
*
|
|
10999
|
+
* TWO INDEPENDENT QUESTIONS. Does the control EXIST (is there a real choice to make)? And is it OPEN
|
|
11000
|
+
* (is the file big enough for that choice to matter)? Conflating them either hides the option on a
|
|
11001
|
+
* small-but-many-storeyed file or charges every 13-object model an extra decision.
|
|
11002
|
+
*/
|
|
11003
|
+
function riBuildPick(probe){
|
|
11004
|
+
riProbeRows=null;riStoreyPick=null;riTypePick=null;
|
|
11005
|
+
const tog=ri$('riPickToggle'),box=ri$('riPick'),none=ri$('riNoBreak');
|
|
11006
|
+
tog.style.display='none';box.style.display='none';none.style.display='none';
|
|
11007
|
+
ri$('riStoreyList').replaceChildren();ri$('riTypeList').replaceChildren();
|
|
11008
|
+
ri$('riInsert').disabled=false;
|
|
11009
|
+
ri$('riFootNote').style.display='none';ri$('riFootNote').textContent='';
|
|
11010
|
+
ri$('riElements').classList.remove('warn','refuse');
|
|
11011
|
+
{const e=ri$('riConfirmErr');e.textContent='';e.style.display='none';}
|
|
11012
|
+
if(!probe)return;
|
|
11013
|
+
// NULL IS NOT EMPTY. No breakdown means the user's IFC reader could not answer — never that the
|
|
11014
|
+
// file has no storeys — so the slot says so instead of showing an empty picker they cannot use.
|
|
11015
|
+
if(probe.storeys===null||probe.types===null){
|
|
11016
|
+
none.textContent='This file doesn’t say how many storeys or types it contains — that usually means an older IFC reader. FloLess can only load it whole.';
|
|
11017
|
+
none.style.display='block';
|
|
11018
|
+
riPaintCount(); // no picker is not "no judgement": the count is still judged, from riPopulation
|
|
11019
|
+
return;
|
|
11020
|
+
}
|
|
11021
|
+
riProbeRows={storeys:probe.storeys,types:probe.types};
|
|
11022
|
+
const sRows=riSelectable(probe.storeys),tRows=riSelectable(probe.types);
|
|
11023
|
+
// NO CHOICE, NO CONTROL. One storey and one type cannot be split into anything, and a picker that
|
|
11024
|
+
// can only select everything is furniture.
|
|
11025
|
+
if(sRows.length<=1&&tRows.length<=1){riPaintCount();return;}
|
|
11026
|
+
tog.style.display='';
|
|
11027
|
+
const big=riPopulation!==null&&riPopulation>=REF_WARN_OBJECTS;
|
|
11028
|
+
riSetPickOpen(big);
|
|
11029
|
+
riPaintPick();
|
|
11030
|
+
}
|
|
11031
|
+
function riSetPickOpen(open){
|
|
11032
|
+
ri$('riPick').style.display=open?'block':'none';
|
|
11033
|
+
ri$('riPickToggle').setAttribute('aria-expanded',open?'true':'false');
|
|
11034
|
+
ri$('riPickToggle').textContent=open?'Load only part of this file ▾':'Load only part of this file ▸';
|
|
11035
|
+
}
|
|
10355
11036
|
function riReadFile(f){ if(!f||riBusy)return;riErr('');
|
|
10356
11037
|
if(!/\.(ifc|ifczip)$/i.test(f.name||'')){riErr('Not an IFC file — expected .ifc or .ifczip.');return;}
|
|
10357
11038
|
if(f.size>RI_MAX_BYTES){riErr('“'+f.name+'” is '+fileSizeWords(f.size)+'; the limit for a reference model is 150 MB. Try exporting just the part of the model you need to see.');return;}
|
|
@@ -10379,6 +11060,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10379
11060
|
// response already on the wire lands anyway — so the id is what actually stops a cancelled
|
|
10380
11061
|
// file's facts being written under a different file's name.
|
|
10381
11062
|
if(mine!==riRun)return;
|
|
11063
|
+
// CLEARED PER ATTEMPT, HERE — not only in openRefImport. Both failure paths leave the modal open
|
|
11064
|
+
// at the drop stage, so a second file dropped after one fails never calls openRefImport again.
|
|
11065
|
+
// `riSha`/`riVerdict` survive that only because they are overwritten unconditionally below;
|
|
11066
|
+
// the picker state would not be, if the next file's breakdown is absent and riBuildPick returns
|
|
11067
|
+
// early. File A's storeys would then ride file B's sha, and the reader would select nothing.
|
|
11068
|
+
riProbeRows=null;riStoreyPick=null;riTypePick=null;riPopulation=null;
|
|
10382
11069
|
riClearSoft();
|
|
10383
11070
|
if(!res.ok||!d.ok){riStage('drop');riErr(d.error||'Could not read that file.');return;}
|
|
10384
11071
|
riSha=d.sha;riVerdict=d.verdict||null;
|
|
@@ -10389,7 +11076,13 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10389
11076
|
says.append(b,document.createTextNode(said?unitWords(said):'nothing about its units'),
|
|
10390
11077
|
document.createTextNode('. FloLess has already applied that — you should not need to rescale it.'));
|
|
10391
11078
|
ri$('riSchema').textContent=(d.probe&&d.probe.schema)||'—';
|
|
10392
|
-
|
|
11079
|
+
// THE READ POPULATION, not `probe.elements` — those count different things and the second is
|
|
11080
|
+
// smaller (measured 10 against a 16-object read, 5,878 against 17,460). This row sits above a
|
|
11081
|
+
// limit stated in objects, so the two must be the same kind of number. `riBuildPick` then
|
|
11082
|
+
// overwrites it with the live figure whenever a picker exists.
|
|
11083
|
+
riPopulation=typeof d.population==='number'?d.population:null;
|
|
11084
|
+
ri$('riElements').textContent=riPopulation===null?'—':'~'+riPopulation.toLocaleString();
|
|
11085
|
+
riBuildPick(d.probe);
|
|
10393
11086
|
// KB below a megabyte. `Math.max(1, …)` reported a 7.6 KB file as "1 MB" — a small lie, but the
|
|
10394
11087
|
// number sits directly above a limit stated in MB, so it made the two unreadable together.
|
|
10395
11088
|
ri$('riBytes').textContent=fileSizeWords(d.bytes||0);
|
|
@@ -10447,6 +11140,7 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10447
11140
|
// the same reason the offer is (the bbox spans everything the file places) — the panel's own offer
|
|
10448
11141
|
// re-does it exactly once the real bounds exist.
|
|
10449
11142
|
const riNative=nativeModelCentre();
|
|
11143
|
+
const riFilterBody=riBuildFilter(); // computed ONCE — it was called twice in one expression
|
|
10450
11144
|
const riOriginShift=takeOrigin&&riProbeCentre?riProbeCentre.map((v,i)=>riNative[i]-v):null;
|
|
10451
11145
|
riStage('prog');riProg('Reading the geometry…','Still reading — a whole building takes a moment.');
|
|
10452
11146
|
try{
|
|
@@ -10456,7 +11150,11 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10456
11150
|
// the reference rather than by a debounced PUT afterwards. Applying it in the presentation
|
|
10457
11151
|
// block left it outside the point of no return: a closed tab or a save conflict would leave
|
|
10458
11152
|
// the server holding the site coordinates the user had just asked to move away from.
|
|
10459
|
-
|
|
11153
|
+
// The chosen SUBSET rides the insert alongside the placement, and for the same reason: it is
|
|
11154
|
+
// part of what the user decided in this modal, so it belongs inside the point of no return
|
|
11155
|
+
// rather than in a PUT afterwards. `undefined` here means the whole file — never an empty list,
|
|
11156
|
+
// which the reader would read as "select nothing".
|
|
11157
|
+
body:JSON.stringify({sha:riSha,name:riName,...(riFilterBody?{filter:riFilterBody}:{}),...(takeOrigin&&riOriginShift?{placement:{origin:riOriginShift}}:{})})});
|
|
10460
11158
|
d=await res.json().catch(()=>({}));
|
|
10461
11159
|
if(mine!==riRun){
|
|
10462
11160
|
// Cancelled while this was in flight. The server refuses to commit for a client that has gone
|
|
@@ -10470,13 +11168,27 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10470
11168
|
return;
|
|
10471
11169
|
}
|
|
10472
11170
|
riClearSoft();
|
|
10473
|
-
if(!res.ok||!d.ok){
|
|
11171
|
+
if(!res.ok||!d.ok){
|
|
11172
|
+
// STAY ON CONFIRM for the refusals the picker itself can fix. `riStage('drop')` swaps the whole
|
|
11173
|
+
// body back to the dropzone, so telling somebody to "choose fewer storeys or types" would
|
|
11174
|
+
// remove every control that lets them. The other failures still go back — there is nothing to
|
|
11175
|
+
// act on in this stage for a vanished upload or a contract conflict.
|
|
11176
|
+
// `reference-filter-unconfirmed` belongs here too: its whole remedy is to try again, and
|
|
11177
|
+
// dropping to the dropzone would throw away the twelve storeys the user had just ticked.
|
|
11178
|
+
const actionable=d.code==='reference-too-many-objects'||d.code==='reference-filter-unmatched'
|
|
11179
|
+
||d.code==='reference-empty-filter'||d.code==='reference-filter-unconfirmed';
|
|
11180
|
+
if(actionable&&riStageNow!=='drop'){
|
|
11181
|
+
riStage('confirm');
|
|
11182
|
+
const e=ri$('riConfirmErr');e.textContent=d.error||'Could not add that reference.';e.style.display='block';
|
|
11183
|
+
}else{riStage('drop');riErr(d.error||'Could not add that reference.');}
|
|
11184
|
+
return;
|
|
11185
|
+
}
|
|
10474
11186
|
adoptReferenceWrite(d.etag);
|
|
10475
11187
|
if(!Array.isArray(C.reference_models))C.reference_models=[];
|
|
10476
11188
|
C.reference_models.push(d.reference);
|
|
10477
11189
|
refGeom.set(d.reference.id,refGeomFrom(d)); // the same normaliser the geometry route's arrival uses — one shape, one spelling
|
|
10478
11190
|
hadDrill=refSelectedObjIdx!==null; // …before this line drops it; the presentation half below needs to know
|
|
10479
|
-
refSelectedId=d.reference.id;refSelectedObjIdx=null;
|
|
11191
|
+
refSelectedId=d.reference.id;refMeasureFollowSelection();refSelectedObjIdx=null;
|
|
10480
11192
|
inserted=d.reference;
|
|
10481
11193
|
}catch(e){
|
|
10482
11194
|
// Aborted: no response at all, so we cannot know whether the write landed. Same reasoning as
|
|
@@ -10507,6 +11219,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10507
11219
|
// throw away whatever else the inspector was in the middle of. (Codex review, both halves.)
|
|
10508
11220
|
if(hadDrill)panel();
|
|
10509
11221
|
toast('Added “'+inserted.name+'” as a reference'+(d.dropped?' ('+d.dropped+' object'+(d.dropped===1?'':'s')+' had nothing to draw)':''));
|
|
11222
|
+
// A PARTIAL MATCH IS NOT A CLEAN SUCCESS. The reference really was added, so this is a toast
|
|
11223
|
+
// rather than an error — but a user who picked three storeys and got two must be told, or the
|
|
11224
|
+
// server carrying `unmatched` on the response reaches nobody and the fix is wire-only.
|
|
11225
|
+
if(Array.isArray(d.unmatched)&&d.unmatched.length){
|
|
11226
|
+
toast('But nothing matched '+d.unmatched.map(function(u){return '“'+u+'”';}).join(', ')+' — that part of the file may have been renamed.');
|
|
11227
|
+
}
|
|
10510
11228
|
}catch(e){
|
|
10511
11229
|
console.error('[reference] added, but the view could not be updated',e);
|
|
10512
11230
|
toast('Added “'+inserted.name+'” — reload the view to see it');
|
|
@@ -10519,6 +11237,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
10519
11237
|
// leaving the invisible one is the version of that rule that does not hold. (UX review, #580.)
|
|
10520
11238
|
ri$('riBackdrop').onclick=()=>{if(riStageNow!=='prog')riClose();};
|
|
10521
11239
|
ri$('riInsert').onclick=riInsert;
|
|
11240
|
+
ri$('riPickToggle').onclick=()=>riSetPickOpen(ri$('riPick').style.display==='none');
|
|
11241
|
+
// The tri-state header toggle: `null` (all) and a full Set are the same selection but not the
|
|
11242
|
+
// same REQUEST — null omits the key — so clearing goes to an empty Set and selecting goes back
|
|
11243
|
+
// to null, never to a Set holding every name.
|
|
11244
|
+
ri$('riStoreyAll').onclick=()=>{riStoreyPick=riStoreyPick===null?new Set():null;riPaintPick();};
|
|
11245
|
+
ri$('riTypeAll').onclick=()=>{riTypePick=riTypePick===null?new Set():null;riPaintPick();};
|
|
10522
11246
|
ri$('riDrop').onclick=()=>ri$('riFile').click();
|
|
10523
11247
|
ri$('riDrop').onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();ri$('riFile').click();}};
|
|
10524
11248
|
ri$('riFile').onchange=e=>{const f=e.target.files&&e.target.files[0];e.target.value='';riReadFile(f);};
|