@floless/app 0.123.1 → 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 +62 -10
- package/dist/web/index.html +2 -2
- package/dist/web/steel-3d-view.js +345 -14
- package/dist/web/steel-editor.html +1281 -34
- package/dist/web/steel-filter.html +64 -8
- package/dist/web/vector-editor.html +15 -1
- package/dist/web/workspaces.js +342 -4
- package/package.json +1 -1
|
@@ -557,16 +557,21 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
557
557
|
a bespoke fixed-height box here would be one more thing to theme and test for nothing. */
|
|
558
558
|
#panel .robjname{font-size:13px;color:var(--text);font-weight:600;overflow-wrap:anywhere;margin:0 0 2px}
|
|
559
559
|
#panel .psetgrp{border-top:1px solid var(--line)}
|
|
560
|
-
#panel
|
|
561
|
-
#panel
|
|
562
|
-
#panel
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
#panel .psethd
|
|
566
|
-
#panel .psethd .
|
|
567
|
-
#panel .psethd .
|
|
568
|
-
#panel .
|
|
569
|
-
#panel .
|
|
560
|
+
/* The property-set accordion. #m3dRefsBody is named alongside #panel because the reference object
|
|
561
|
+
tree (S2 Stage B) reuses this exact header in the References legend, which is a SIBLING of #panel —
|
|
562
|
+
scoped to #panel alone the header fell through to the global `button{}` pill: grey fill, rounded
|
|
563
|
+
border, a chevron that never turned and a count that was not muted. Same markup, same look, both
|
|
564
|
+
places. */
|
|
565
|
+
#panel .psethd,#m3dRefsBody .psethd{display:flex;align-items:center;gap:6px;width:100%;background:transparent;border:0;border-radius:0;box-shadow:none;color:var(--text);font:600 11px system-ui;padding:5px 2px;cursor:pointer;text-align:left}
|
|
566
|
+
#panel .psethd:hover,#m3dRefsBody .psethd:hover{color:var(--text);background:#33415580}
|
|
567
|
+
#panel .psethd[aria-expanded=true],#m3dRefsBody .psethd[aria-expanded=true]{color:var(--brand)}
|
|
568
|
+
#panel .psethd:focus-visible,#m3dRefsBody .psethd:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
569
|
+
#panel .psethd .chev,#m3dRefsBody .psethd .chev{color:var(--mut);font-size:10px;width:10px;flex:none;transition:transform .15s}
|
|
570
|
+
#panel .psethd[aria-expanded=true] .chev,#m3dRefsBody .psethd[aria-expanded=true] .chev{transform:rotate(90deg);color:var(--brand)}
|
|
571
|
+
#panel .psethd .psn,#m3dRefsBody .psethd .psn{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
572
|
+
#panel .psethd .psc,#m3dRefsBody .psethd .psc{flex:none;color:var(--mut);font-weight:400;font-variant-numeric:tabular-nums}
|
|
573
|
+
#panel .psetbody,#m3dRefsBody .psetbody{display:none;padding:2px 0 8px 16px}
|
|
574
|
+
#panel .psetbody.open,#m3dRefsBody .psetbody.open{display:block}
|
|
570
575
|
/* Label ABOVE value, not beside it: an IFC property name ("NominalRenderingHeight") and its value
|
|
571
576
|
("0055SFt0000001150") can BOTH be long, so the label-left/value-right recipe this panel uses
|
|
572
577
|
elsewhere either truncates or wraps into a ragged mess at this width. */
|
|
@@ -874,6 +879,14 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
874
879
|
#m3dRefsBody .refdet input[type=text]{height:24px;font-size:11px}
|
|
875
880
|
#m3dRefsBody .refdet .dnote{color:var(--mut);font-size:11px;line-height:1.45}
|
|
876
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}
|
|
877
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}
|
|
878
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}
|
|
879
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}
|
|
@@ -891,6 +904,36 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
891
904
|
#m3dRefsBody .refdet .seg2 button{font-size:11px;padding:0}
|
|
892
905
|
#m3dRefsBody .refdet .seg2 .swc{flex:1;width:auto;height:100%;border:0;border-radius:0;min-width:0}
|
|
893
906
|
#m3dRefsBody .refdet .seg2 .swc.on{box-shadow:inset 0 0 0 2px var(--brand)}
|
|
907
|
+
/* ── The object tree (S2 Stage B) — what is INSIDE one reference, storey → IFC type.
|
|
908
|
+
Grouping chrome is #m3dLegend's own `.cat-hdr`/`.cat-hdr.sub`/`.cat-chevron`/`.cat-count`, which
|
|
909
|
+
already exists for exactly this two-level shape (Dimensions → Base-plate); the rows sit at the
|
|
910
|
+
`.lrow.sub` indent. New here: the bounded scroll box, the row, the filter box and the cap notice.
|
|
911
|
+
The accordion HEADER is `.psethd`/`.psetbody`, whose rules had to be widened to name #m3dRefsBody —
|
|
912
|
+
they were scoped to #panel, which is a sibling of this panel, not an ancestor.
|
|
913
|
+
THE BOX IS BOUNDED, and that is a deliberate departure from the property panel's "no inner
|
|
914
|
+
scroller" rule: that reasoning ("one more thing to theme and test for nothing") holds at 31 sets
|
|
915
|
+
and does not hold at 17,460 objects, which would otherwise push every control above it off screen.
|
|
916
|
+
Same recipe as #ciList / #vgList, so it inherits the global themed scrollbar and adds no CSS. */
|
|
917
|
+
#m3dRefsBody .reftree{max-height:min(38vh,300px);overflow:auto;border:1px solid var(--line);border-radius:7px;background:var(--bg);padding:3px 2px}
|
|
918
|
+
/* The tree's own filter. It does NOT reuse #propPop's `.ppsearch` — that recipe is scoped to #propPop
|
|
919
|
+
and cannot reach this panel, so naming it here would be a class that styles nothing. The global
|
|
920
|
+
`select,input` rule already makes it dark, and `#m3dRefsBody .refdet input[type=text]` above already
|
|
921
|
+
sizes it (and outranks this rule, so height/font are deliberately not restated here). What neither
|
|
922
|
+
gives it is room for its text against the global `padding:6px`, or the branded focus ring that every
|
|
923
|
+
other input in this file has and that CLAUDE.md requires. */
|
|
924
|
+
#m3dRefsBody .reftreesearch{padding:4px 0 6px}
|
|
925
|
+
#m3dRefsBody .reftreesearch input{padding:0 8px}
|
|
926
|
+
#m3dRefsBody .reftreesearch input:focus{outline:none;border-color:var(--brand)}
|
|
927
|
+
#m3dRefsBody .reftreesearch input::placeholder{color:var(--mut)}
|
|
928
|
+
#m3dLegend .refobjrow{display:flex;align-items:center;gap:6px;padding:2px 4px 2px 34px;border-radius:5px;cursor:pointer;user-select:none;white-space:nowrap;font-size:11px;color:var(--text)}
|
|
929
|
+
#m3dLegend .refobjrow:hover{background:#33415580}
|
|
930
|
+
#m3dLegend .refobjrow:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
931
|
+
#m3dLegend .refobjrow.sel{box-shadow:inset 2px 0 0 var(--brand);background:rgba(59,130,246,.16)}
|
|
932
|
+
#m3dLegend .refobjrow.flash{background:rgba(59,130,246,.12)} /* "you just navigated here" — the same flash tint .lrow/.vwrow use, held longer (900ms) because the tree may also have scrolled */
|
|
933
|
+
#m3dLegend .refobjrow .ronm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
|
|
934
|
+
#m3dLegend .refobjrow .rord{flex:none;color:var(--mut);font-size:10px;font-variant-numeric:tabular-nums}
|
|
935
|
+
#m3dRefsBody .reftree .cat-hdr:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
936
|
+
#m3dRefsBody .refcap{color:var(--mut);font-size:10px;padding:4px 4px 4px 34px;line-height:1.4}
|
|
894
937
|
#m3dRefsBody .refdet .colrow{display:flex;align-items:center;gap:6px}
|
|
895
938
|
#m3dRefsBody .refdet .colrow .seg2{flex:1;min-width:0}
|
|
896
939
|
/* ── Reference-model import modal (#refImportModal) — the #connImportModal recipe, under its own ids.
|
|
@@ -914,6 +957,40 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
914
957
|
#riSays b{color:var(--mut);font-weight:600}
|
|
915
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}
|
|
916
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}
|
|
917
994
|
/* ── Favourites tab (#m3dFavBody) — the Views-tab row/search recipe. No create button (★ lives in the
|
|
918
995
|
Inspector); a kind-filter + search header, per-row kind swatch + portability badge + row-click-to-arm. ── */
|
|
919
996
|
#favHeadRow{display:flex;align-items:stretch;gap:6px;margin-bottom:6px;flex:none}
|
|
@@ -972,15 +1049,31 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
972
1049
|
#m3dLegend .lmode{display:flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;height:24px;margin-bottom:6px;flex:none}
|
|
973
1050
|
#m3dLegend .lmode button{flex:1;border:0;background:transparent;color:var(--mut);font-size:11px;cursor:pointer}
|
|
974
1051
|
#m3dLegend .lmode button.on{background:var(--brand);color:#fff}
|
|
975
|
-
|
|
976
|
-
#
|
|
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}
|
|
977
1066
|
#m3dLegend .cat-hdr.empty .cat-label,#m3dLegend .cat-hdr.empty .cat-count{opacity:.55}
|
|
978
1067
|
#m3dLegend .cat-hdr.drop-target{outline:1px solid var(--brand);background:rgba(59,130,246,.18)}
|
|
979
1068
|
#m3dLegend .cat-chevron{font-size:10px;color:var(--mut);width:12px;flex:none;text-align:center}
|
|
980
|
-
#m3dLegend .cat-tog{font-size:12px;width:14px;flex:none;cursor:pointer;line-height:1;text-align:center}
|
|
981
|
-
#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}
|
|
982
|
-
|
|
983
|
-
|
|
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}
|
|
1071
|
+
/* `min-width:0` + ellipsis because a flex item that cannot shrink below its content OVERFLOWS the row
|
|
1072
|
+
rather than truncating, and `.cat-hdr` is `white-space:nowrap`. The legend's own categories were
|
|
1073
|
+
always short enough to hide this; the reference tree's disambiguated headers ("Wall · IFCWALL…")
|
|
1074
|
+
are the first labels long enough to test it. Same recipe as `.refname` directly above. */
|
|
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}
|
|
984
1077
|
#m3dLegend .lrow.typed{padding-left:20px}
|
|
985
1078
|
#m3dLegend .cat-hdr.sub{padding-left:20px} /* a nested (middle) category, e.g. Dimensions → Base-plate */
|
|
986
1079
|
#m3dLegend .lrow.sub{padding-left:34px} /* a row inside a nested category — indented one level deeper */
|
|
@@ -1435,8 +1528,25 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1435
1528
|
<div id=riConfirmStage style="display:none">
|
|
1436
1529
|
<div id=riSays></div>
|
|
1437
1530
|
<div class=rirow><span class=pn>Schema</span><span class=pv id=riSchema>—</span></div>
|
|
1438
|
-
|
|
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>
|
|
1439
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>
|
|
1440
1550
|
<!-- NO SIZE ROW HERE, and that is a decision rather than an omission. The only pre-tessellation
|
|
1441
1551
|
measurement available is `probe.bbox`, which its own manifest calls APPROXIMATE — measured, it
|
|
1442
1552
|
spans every cartesian point the file places, not the geometry: for the Motebello lift shaft it
|
|
@@ -1445,9 +1555,17 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1445
1555
|
is in, from the rendered bounds; the bbox is used ONLY for the position hint below, which is
|
|
1446
1556
|
labelled a probability and phrased as one. -->
|
|
1447
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>
|
|
1448
1562
|
</div>
|
|
1449
1563
|
</div>
|
|
1450
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>
|
|
1451
1569
|
<button id=riCancel>Cancel</button>
|
|
1452
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>
|
|
1453
1571
|
</div>
|
|
@@ -1457,7 +1575,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1457
1575
|
<div id=ciBody>
|
|
1458
1576
|
<!-- stage: dropzone -->
|
|
1459
1577
|
<div id=ciDropStage>
|
|
1460
|
-
<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>
|
|
1461
1579
|
<input id=ciFile type=file accept=".ifc,.ifczip" hidden>
|
|
1462
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>
|
|
1463
1581
|
<div class=gerr id=ciDropErr style="display:none"></div>
|
|
@@ -1528,6 +1646,12 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
|
|
|
1528
1646
|
// /api/contract call; the contract-request (Ask AI) bodies carry `project` for slice-4 context.
|
|
1529
1647
|
const PROJECT = new URLSearchParams(location.search).get('project') || '';
|
|
1530
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;
|
|
1531
1655
|
// ── The browser draft's identity, and the contract type this page can render (unit 5, P1c-3) ──
|
|
1532
1656
|
// The one contract type this editor renders. A contract with NO `type` is legacy steel v1 — the server's
|
|
1533
1657
|
// own validator says so and falls back to exactly this (contract-schema.ts, validateContract), so
|
|
@@ -1904,7 +2028,14 @@ async function boot() {
|
|
|
1904
2028
|
import('./steel-detail-refs.js'), import('./steel-model-v2-projection.js'),
|
|
1905
2029
|
import('./steel-model-v2-commands.js'), import('./steel-model-v2-client-validation.js'),
|
|
1906
2030
|
]);
|
|
1907
|
-
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
|
+
}
|
|
1908
2039
|
if (!res.ok) {
|
|
1909
2040
|
if (res.status === 404) {
|
|
1910
2041
|
// TWO different 404s, and telling them apart is the whole point of this branch.
|
|
@@ -4091,7 +4222,7 @@ function gridSvg(){
|
|
|
4091
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>`;});
|
|
4092
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>`;});
|
|
4093
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>`;});
|
|
4094
|
-
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>`;
|
|
4095
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);});
|
|
4096
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);});
|
|
4097
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);});
|
|
@@ -4433,7 +4564,9 @@ let lastCmd=null;
|
|
|
4433
4564
|
function setLastCmd(label,run){lastCmd={label,run};}
|
|
4434
4565
|
function anyToolActive(){
|
|
4435
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)
|
|
4436
|
-
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
|
|
4437
4570
|
return false;
|
|
4438
4571
|
}
|
|
4439
4572
|
function repeatLast(){if(lastCmd){lastCmd.run();if(typeof toast==='function')toast('↻ '+lastCmd.label);}}
|
|
@@ -4973,7 +5106,7 @@ function panel(){
|
|
|
4973
5106
|
const _rb=document.getElementById('csRepickB');if(_rb)_rb.onclick=()=>{if(_d3.repickFrame3d)_d3.repickFrame3d();};
|
|
4974
5107
|
return;}
|
|
4975
5108
|
if(csaxisMode){p.innerHTML=`<span class=badge>Set local axes</span>
|
|
4976
|
-
<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>
|
|
4977
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;}
|
|
4978
5111
|
if(cmTool){const nsel=selIds.size;
|
|
4979
5112
|
p.innerHTML=`<span class=badge>${cmTool==='move'?'Move':(cmArrayMode?'Copy array':'Copy')}</span>
|
|
@@ -6533,7 +6666,7 @@ function disarmCm(){cmTool=null;cmArrayMode=false;cmDraft=null;cmHudClose();cmPr
|
|
|
6533
6666
|
if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d();} // drop the 3D-side pick/preview too
|
|
6534
6667
|
function armCm(tool,array){ // re-arming the same config toggles the tool off — works in 2D and (on the working plane) in 3D
|
|
6535
6668
|
if(cmTool===tool&&cmArrayMode===!!array){disarmCm();render();return;}
|
|
6536
|
-
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
|
|
6537
6670
|
if(!selIds.size){toast('Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
|
|
6538
6671
|
if(mode==='add'){mode='sel';setMode();if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}
|
|
6539
6672
|
if(dimMode){dimMode=false;setDimMode();}
|
|
@@ -7072,7 +7205,7 @@ function setMode(){document.body.classList.toggle('add',mode==='add');document.g
|
|
|
7072
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)
|
|
7073
7206
|
document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();if(qdPick){qdPick=null;setQdPickCls();}
|
|
7074
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)
|
|
7075
|
-
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
|
|
7076
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
|
|
7077
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();}});};
|
|
7078
7211
|
document.getElementById('csSetB').onclick=()=>{csaxisMode=!csaxisMode;setCsMode();render();};
|
|
@@ -7351,6 +7484,20 @@ addEventListener('keydown',e=>{
|
|
|
7351
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
|
|
7352
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)
|
|
7353
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;}
|
|
7354
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;}
|
|
7355
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)
|
|
7356
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
|
|
@@ -7999,6 +8146,11 @@ const view3dApi={
|
|
|
7999
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
|
|
8000
8147
|
onGridLinePickStep:()=>panel(), // first point placed in 3D → repaint the panel hint ("Pick the second point")
|
|
8001
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();},
|
|
8002
8154
|
onSnapOnlyChanged:()=>updSnapStat(), // keep the header snap-override chip honest for every 3D-side clear (tool disarm etc.)
|
|
8003
8155
|
onDeleteDim3d:(id)=>{if(!canWriteModel())return;C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
|
|
8004
8156
|
onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
|
|
@@ -8080,7 +8232,9 @@ const view3dApi={
|
|
|
8080
8232
|
// that — with a marquee selection live, drilling was silently impossible.
|
|
8081
8233
|
const stole=nextIdx!==null&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size);
|
|
8082
8234
|
if(stole){selIds.clear();selDimIds.clear();selGridIds.clear();sel3dDimIds.clear();}
|
|
8083
|
-
if
|
|
8235
|
+
// The object tree, if the user has it open, comes to the object — see `revealRefTreeObject`. It
|
|
8236
|
+
// repaints the tab itself, so the ordinary repaint below is skipped when it did.
|
|
8237
|
+
if(!(nextId&&nextIdx!==null&&revealRefTreeObject(nextId,nextIdx))&&legendTab==='refs')renderRefsTab();
|
|
8084
8238
|
if(stole)render();else panel(); // render() repaints the canvas too, so our own highlight goes with the selection
|
|
8085
8239
|
},
|
|
8086
8240
|
onBasePickModeChange:()=>{}, // Mode B armed state shows via the 3D crosshair + elevation readout; nothing else to reflect
|
|
@@ -8968,6 +9122,20 @@ const refLoading=new Set(); // ids with a geometry fetch in flight — the
|
|
|
8968
9122
|
const refFailed=new Map(); // id -> why its geometry could not be fetched (see loadReferenceGeometry)
|
|
8969
9123
|
const refEmpty=new Set(); // ids the reader answered for, with nothing drawable in the answer
|
|
8970
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;
|
|
8971
9139
|
/**
|
|
8972
9140
|
* The INDEX of the one object drilled into inside `refSelectedId`, or null.
|
|
8973
9141
|
*
|
|
@@ -9194,11 +9362,193 @@ function refEdit(id,patch){
|
|
|
9194
9362
|
const v=window.Steel3DView;
|
|
9195
9363
|
if(v){if(patch.display&&v.setReferenceDisplay)v.setReferenceDisplay(id,refDisp(r));
|
|
9196
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
|
|
9197
9375
|
scheduleSave();renderRefsTab();
|
|
9198
9376
|
}
|
|
9199
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
|
+
|
|
9200
9542
|
// ── The References tab ────────────────────────────────────────────────────────────────────────────
|
|
9201
|
-
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();
|
|
9202
9552
|
const head=document.createElement('div');head.id='refHeadRow';
|
|
9203
9553
|
const add=document.createElement('button');add.type='button';add.id='refAddBtn';add.textContent='+ Add a reference model';
|
|
9204
9554
|
add.dataset.tip='Overlay an architect’s or engineer’s IFC to build against. It is never part of your steel.';
|
|
@@ -9210,6 +9560,11 @@ function renderRefsTab(){const host=document.getElementById('m3dRefsBody');if(!h
|
|
|
9210
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.';
|
|
9211
9561
|
host.appendChild(e);return;}
|
|
9212
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);}}}
|
|
9213
9568
|
}
|
|
9214
9569
|
|
|
9215
9570
|
function buildRefRow(r){
|
|
@@ -9267,12 +9622,16 @@ function buildRefRow(r){
|
|
|
9267
9622
|
row.appendChild(zoom);
|
|
9268
9623
|
|
|
9269
9624
|
const dots=Object.assign(document.createElement('span'),{className:'refdots',textContent:'⋯'});
|
|
9270
|
-
|
|
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';
|
|
9271
9629
|
dots.addEventListener('click',e=>{e.stopPropagation();openRefRowMenu(r,dots);});
|
|
9272
9630
|
row.appendChild(dots);
|
|
9273
9631
|
|
|
9274
9632
|
row.addEventListener('click',()=>{
|
|
9275
9633
|
refSelectedId=refSelectedId===r.id?null:r.id;
|
|
9634
|
+
refMeasureFollowSelection(); // this handler TOGGLES, so one click can collapse the measured row
|
|
9276
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
|
|
9277
9636
|
if(window.Steel3DView&&window.Steel3DView.selectReference)window.Steel3DView.selectReference(refSelectedId);
|
|
9278
9637
|
renderRefsTab();panel();});
|
|
@@ -9438,11 +9797,49 @@ function buildRefDetail(r){
|
|
|
9438
9797
|
refEdit(r.id,{placement:{scale:v}});});
|
|
9439
9798
|
sRow.appendChild(sc);wrap.appendChild(sRow);
|
|
9440
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
|
+
|
|
9441
9838
|
// The scale advisory, on a measurement that can bear it: `spanMm` is computed server-side from the
|
|
9442
9839
|
// vertices the reader actually returned. The pre-insert modal deliberately offers none, because
|
|
9443
9840
|
// before tessellation the only number available is the reader's bbox, which spans everything the file
|
|
9444
9841
|
// MENTIONS (74 m for a 3.6 m shaft) and would offer to permanently mis-scale a correct reference.
|
|
9445
|
-
const scale=refScaleAdvice(r.id);
|
|
9842
|
+
const scale=measuring?null:refScaleAdvice(r.id);
|
|
9446
9843
|
if(scale){
|
|
9447
9844
|
const w=Object.assign(document.createElement('div'),{className:'dwarn'});
|
|
9448
9845
|
w.textContent='This looks about '+scale.words+' your model. If the file states the wrong units, this is the usual fix.';
|
|
@@ -9459,9 +9856,80 @@ function buildRefDetail(r){
|
|
|
9459
9856
|
fix.addEventListener('click',()=>refMoveToOrigin(r.id));
|
|
9460
9857
|
w.appendChild(document.createElement('br'));w.appendChild(fix);wrap.appendChild(w);
|
|
9461
9858
|
}
|
|
9859
|
+
// LAST in the block, deliberately. Opening a tree of 17,460 objects must not push the "how does this
|
|
9860
|
+
// look" controls — the reason the row was expanded in the first place — off the top of the panel.
|
|
9861
|
+
buildRefTree(r,wrap);
|
|
9462
9862
|
return wrap;
|
|
9463
9863
|
}
|
|
9464
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
|
+
|
|
9465
9933
|
// ── The drilled-into reference object (S2 Stage A) ────────────────────────────────────────────────
|
|
9466
9934
|
//
|
|
9467
9935
|
// Ctrl+click one object inside a reference and this is what the Inspect panel shows: what the FILE says
|
|
@@ -9497,13 +9965,59 @@ function ifcTypeWords(t){
|
|
|
9497
9965
|
/**
|
|
9498
9966
|
* Is this a name, or is it the file's way of writing "nothing"?
|
|
9499
9967
|
*
|
|
9500
|
-
*
|
|
9968
|
+
* Two of the Motebello sample's nineteen objects are named `-`. Printing that as a headline reads as a
|
|
9501
9969
|
* broken template rather than as "the author did not name this", so a string with no letter and no digit
|
|
9502
9970
|
* is treated as no name at all — and what the file DID write is then stated in words underneath, because
|
|
9503
9971
|
* hiding it would be this panel telling a smaller truth than the file did.
|
|
9504
9972
|
*/
|
|
9505
9973
|
function refObjNamed(n){return typeof n==='string'&&/[\p{L}\p{N}]/u.test(n);}
|
|
9506
9974
|
|
|
9975
|
+
/**
|
|
9976
|
+
* The objects of one reference, grouped storey → IFC type, for the object tree (S2 Stage B).
|
|
9977
|
+
*
|
|
9978
|
+
* INDICES, NEVER OBJECTS. The result addresses each object by its position in the array it was built
|
|
9979
|
+
* from — the same handle the 3D layer and the Inspect panel already use, because an IFC GlobalId can be
|
|
9980
|
+
* absent or duplicated (see `xrefSubSelected` in web/steel-3d-view.js). It also means this structure
|
|
9981
|
+
* costs a few numbers per object, and nothing here has to be kept in step with the array it describes.
|
|
9982
|
+
*
|
|
9983
|
+
* ORDER IS FIRST APPEARANCE, not alphabetical. A building's storeys have an order — LG, L1, L2, ROOF —
|
|
9984
|
+
* that no sort of their names recovers ("L10" sorts before "L2", "BASEMENT" before everything), and we
|
|
9985
|
+
* are given no elevations to sort by. File order is the author's own sequence and it is the only
|
|
9986
|
+
* ordering here that is not invented. Types are ordered the same way within a storey, for the same
|
|
9987
|
+
* reason. (This preserves the order of the read it is given; it does not — and cannot — promise that two
|
|
9988
|
+
* reads of a changed file agree, which is why the tree's group state is dropped on a re-read.)
|
|
9989
|
+
*
|
|
9990
|
+
* THE STOREY-LESS GROUP GOES LAST, and is left as `null` for the renderer to name rather than labelled
|
|
9991
|
+
* here. A file that records no storeys at all — which is ordinary, though no sample file we hold does it;
|
|
9992
|
+
* Daldy contributes one such object among 17,460 — produces exactly one group, and the tree then
|
|
9993
|
+
* degrades to a flat list of types.
|
|
9994
|
+
*/
|
|
9995
|
+
function groupReferenceObjects(objects){
|
|
9996
|
+
const list=Array.isArray(objects)?objects:[];
|
|
9997
|
+
const byStorey=new Map(); // storey label (or null) -> Map<type label, number[]>
|
|
9998
|
+
for(let i=0;i<list.length;i++){
|
|
9999
|
+
const o=list[i]||{};
|
|
10000
|
+
// Trimmed, and blank counts as absent — the same rule the Inspect panel's identity line follows, and
|
|
10001
|
+
// for the same measured reason: this file family pads fields to a fixed width (it is Motebello's
|
|
10002
|
+
// MATERIAL that arrives as eighty spaces), so a padded field would otherwise head a group with nothing.
|
|
10003
|
+
const s=(typeof o.storey==='string'&&o.storey.trim())?o.storey.trim():null;
|
|
10004
|
+
const t=(typeof o.ifcType==='string'&&o.ifcType.trim())?o.ifcType.trim():null;
|
|
10005
|
+
if(!byStorey.has(s))byStorey.set(s,new Map());
|
|
10006
|
+
const types=byStorey.get(s);
|
|
10007
|
+
if(!types.has(t))types.set(t,[]);
|
|
10008
|
+
types.get(t).push(i);
|
|
10009
|
+
}
|
|
10010
|
+
const out=[];
|
|
10011
|
+
for(const [storey,types] of byStorey){
|
|
10012
|
+
const groups=[...types].map(([type,indices])=>({type,words:ifcTypeWords(type),count:indices.length,indices}));
|
|
10013
|
+
out.push({storey,count:groups.reduce((n,g)=>n+g.count,0),types:groups});
|
|
10014
|
+
}
|
|
10015
|
+
// The unlabelled storey last, wherever it appeared. It is the one group whose position carries no
|
|
10016
|
+
// information from the file, so it is the one group we may place.
|
|
10017
|
+
out.sort((a,b)=>(a.storey===null?1:0)-(b.storey===null?1:0));
|
|
10018
|
+
return out;
|
|
10019
|
+
}
|
|
10020
|
+
|
|
9507
10021
|
/** One `name: value` row. The FOUR value states are rendered differently ON PURPOSE — see the CSS. */
|
|
9508
10022
|
function buildPropRow(prop){
|
|
9509
10023
|
const row=document.createElement('div');row.className='psrow';
|
|
@@ -9680,6 +10194,433 @@ function renderPanelReferenceObject(p){
|
|
|
9680
10194
|
return true;
|
|
9681
10195
|
}
|
|
9682
10196
|
|
|
10197
|
+
// ── The object tree (S2 Stage B) ─────────────────────────────────────────────────────────────────
|
|
10198
|
+
//
|
|
10199
|
+
// What is INSIDE one reference, grouped storey → IFC type, in the row's own detail block. Selecting a
|
|
10200
|
+
// row drills into that object exactly as Ctrl+click does — it is the same call — and drilling in 3D
|
|
10201
|
+
// brings the tree to the object.
|
|
10202
|
+
|
|
10203
|
+
/**
|
|
10204
|
+
* Per-REFERENCE tree state, scoped per reference for the reason `refPsetOpen` is scoped per object.
|
|
10205
|
+
* (Its key is `refId|objIdx`; these are keyed by reference id alone, which is the level they belong to.)
|
|
10206
|
+
*
|
|
10207
|
+
* One global tree state would silently misapply reference A's open storeys to reference B's entirely
|
|
10208
|
+
* different ones — the same trap the property-set memory already avoids, one level up.
|
|
10209
|
+
*
|
|
10210
|
+
* `refTreeGroups` holds an EXPLICIT open/closed per group, not a set of "expanded" keys. A set cannot
|
|
10211
|
+
* express this: the default for a lone group is OPEN, so the set has to mean both "the user opened this"
|
|
10212
|
+
* and "the user has touched nothing", and those two cancel — clicking a lone group's header wrote the
|
|
10213
|
+
* key, which read back as still-open, and clicking again emptied the set, which re-armed the auto-open.
|
|
10214
|
+
* The header could never be closed, and worse, its click changed the OTHER level (whose default was
|
|
10215
|
+
* keyed on the same set being empty). A key that is simply absent means "no opinion — use the default".
|
|
10216
|
+
*/
|
|
10217
|
+
const refTreeOpen=new Set(); // reference ids whose tree accordion is open
|
|
10218
|
+
const refTreeGroups=new Map(); // refId -> Map<group key ('storeyIdx' / 'storeyIdx:typeIdx'), boolean open>
|
|
10219
|
+
const refTreeQuery=new Map(); // refId -> the live filter text
|
|
10220
|
+
/** The id the filter input carries, so it can be found again across the repaint its own typing causes. */
|
|
10221
|
+
const REF_TREE_SEARCH_ID='refTreeSearch';
|
|
10222
|
+
/**
|
|
10223
|
+
* How many object rows one type group will build at once.
|
|
10224
|
+
*
|
|
10225
|
+
* The DOM is bounded: a group builds rows only once it is open, and the one path that opens groups
|
|
10226
|
+
* unasked (a filter at or below this cap) can by definition not exceed it. But ONE group can still be
|
|
10227
|
+
* enormous: Daldy's IFCMEMBER is 9,210 objects. This is the last bound, and it is stated in the UI
|
|
10228
|
+
* rather than applied silently: a list that stops at 300 with no explanation reads as a broken tree,
|
|
10229
|
+
* which is worse than a limit that says what it is.
|
|
10230
|
+
*
|
|
10231
|
+
* Deliberately NOT virtualisation. Nothing in this app windows a list — `#ciList` and `#vgList` are
|
|
10232
|
+
* both plain `overflow:auto` — and introducing it for one feature is more machinery than the problem
|
|
10233
|
+
* needs once rendering is lazy. What the user gives up past the cap is scroll-hunting; the filter is
|
|
10234
|
+
* the way through, and it is right there. The one row the cap may NOT drop is the selected one — see
|
|
10235
|
+
* the window in `buildRefTree`, without which "drilling in 3D shows you the row" was false for the
|
|
10236
|
+
* 8,910 members of that group that fall past row 300.
|
|
10237
|
+
*/
|
|
10238
|
+
const REF_TREE_CAP=300;
|
|
10239
|
+
|
|
10240
|
+
/**
|
|
10241
|
+
* Does this object match the filter? Name, raw IFC type, storey, and the plain word the tree shows for
|
|
10242
|
+
* that type — the four things a row shows or sits under. `q` must arrive lowercased and trimmed; only
|
|
10243
|
+
* the haystack is lowercased here.
|
|
10244
|
+
*/
|
|
10245
|
+
function refTreeMatches(o,q){
|
|
10246
|
+
if(!q)return true;
|
|
10247
|
+
const hay=[o&&o.name,o&&o.ifcType,o&&o.storey,ifcTypeWords(o&&o.ifcType)].filter((s)=>typeof s==='string').join(' ').toLowerCase();
|
|
10248
|
+
return hay.includes(q);
|
|
10249
|
+
}
|
|
10250
|
+
|
|
10251
|
+
/**
|
|
10252
|
+
* Make a `role=button` div actually behave like one.
|
|
10253
|
+
*
|
|
10254
|
+
* `role=button` without a tab stop and a key handler is a promise to a screen reader that the element
|
|
10255
|
+
* cannot keep — it announces "button, collapsed" and then Tab never reaches it. The legend's own
|
|
10256
|
+
* `.cat-hdr` elsewhere carries no role, so it at least does not lie; these do, so they earn the rest.
|
|
10257
|
+
* `stopPropagation` because the editor's global shortcut handler eats Space and Enter.
|
|
10258
|
+
*
|
|
10259
|
+
* `ownsTabStop:false` for anything inside a roving group — see `refTreeRoving`.
|
|
10260
|
+
*/
|
|
10261
|
+
function refTreeKeyOperable(el,ownsTabStop){
|
|
10262
|
+
if(ownsTabStop!==false)el.tabIndex=0;
|
|
10263
|
+
el.addEventListener('keydown',(e)=>{
|
|
10264
|
+
if(e.key!=='Enter'&&e.key!==' ')return;
|
|
10265
|
+
e.preventDefault();e.stopPropagation();el.click();
|
|
10266
|
+
});
|
|
10267
|
+
}
|
|
10268
|
+
|
|
10269
|
+
/**
|
|
10270
|
+
* ONE tab stop for the whole list of object rows, with the arrows moving inside it.
|
|
10271
|
+
*
|
|
10272
|
+
* A capped type group is 300 rows, and several can be open at once. Giving each row a tab stop made the
|
|
10273
|
+
* tree keyboard-REACHABLE and the page keyboard-hostile: Tab had to be pressed hundreds of times to get
|
|
10274
|
+
* past the legend. This is the roving-tabindex pattern the editor already uses for its long selectable
|
|
10275
|
+
* lists — the active row is the selected one if it is on screen, else the first, and Arrow Up/Down move
|
|
10276
|
+
* both the focus and the stop. Tab then enters the list once and leaves it once.
|
|
10277
|
+
*/
|
|
10278
|
+
function refTreeRoving(rows){
|
|
10279
|
+
const isSel=(n)=>String(n.className||'').split(/\s+/).includes('sel');
|
|
10280
|
+
const active=rows.find(isSel)||rows[0];
|
|
10281
|
+
rows.forEach((n)=>{n.tabIndex=n===active?0:-1;});
|
|
10282
|
+
rows.forEach((n,i)=>n.addEventListener('keydown',(e)=>{
|
|
10283
|
+
if(e.key!=='ArrowDown'&&e.key!=='ArrowUp')return;
|
|
10284
|
+
const next=rows[i+(e.key==='ArrowDown'?1:-1)];
|
|
10285
|
+
if(!next)return;
|
|
10286
|
+
e.preventDefault();e.stopPropagation();
|
|
10287
|
+
rows.forEach((m)=>{m.tabIndex=-1;});
|
|
10288
|
+
next.tabIndex=0;next.focus();
|
|
10289
|
+
}));
|
|
10290
|
+
}
|
|
10291
|
+
|
|
10292
|
+
/**
|
|
10293
|
+
* The tree for one reference, appended to its detail block.
|
|
10294
|
+
*
|
|
10295
|
+
* Renders NOTHING but a header until the user opens it, and nothing but group headers until they open a
|
|
10296
|
+
* group. That is what makes a 17,460-object file cost the same as a 19-object one on the way IN; opening
|
|
10297
|
+
* the tree itself is then one linear pass plus a header per storey×type (192 of them, on that file).
|
|
10298
|
+
*/
|
|
10299
|
+
function buildRefTree(r,wrap){
|
|
10300
|
+
const geom=refGeom.get(r.id);
|
|
10301
|
+
const open=refTreeOpen.has(r.id);
|
|
10302
|
+
const hd=document.createElement('button');hd.type='button';hd.className='psethd';
|
|
10303
|
+
hd.setAttribute('aria-expanded',String(open));hd.setAttribute('aria-controls','reftree-'+r.id);
|
|
10304
|
+
const chev=Object.assign(document.createElement('span'),{className:'chev',textContent:'▸'});chev.setAttribute('aria-hidden','true');
|
|
10305
|
+
hd.append(chev,Object.assign(document.createElement('span'),{className:'psn',textContent:'What’s in this file'}),
|
|
10306
|
+
Object.assign(document.createElement('span'),{className:'psc',textContent:geom?String((geom.objects||[]).length):''}));
|
|
10307
|
+
hd.dataset.tip='List the objects inside this reference, grouped by storey and IFC type';
|
|
10308
|
+
wrap.appendChild(hd);
|
|
10309
|
+
const body=document.createElement('div');body.className='psetbody'+(open?' open':'');body.id='reftree-'+r.id;
|
|
10310
|
+
wrap.appendChild(body);
|
|
10311
|
+
hd.addEventListener('click',()=>{
|
|
10312
|
+
if(refTreeOpen.has(r.id))refTreeOpen.delete(r.id);else refTreeOpen.add(r.id);
|
|
10313
|
+
renderRefsTab();
|
|
10314
|
+
});
|
|
10315
|
+
if(!open)return;
|
|
10316
|
+
|
|
10317
|
+
// NOT AN EMPTY TREE — say which of the several reasons it is. A tree that renders nothing is
|
|
10318
|
+
// indistinguishable from a file with nothing in it, and only one of those is true at a time.
|
|
10319
|
+
if(!geom){
|
|
10320
|
+
const n=Object.assign(document.createElement('div'),{className:'dnote'});
|
|
10321
|
+
n.textContent=refLoading.has(r.id)?'Still reading this file…'
|
|
10322
|
+
:refUnresolved.has(r.id)?'Its file is missing from this project, so there is nothing to list.'
|
|
10323
|
+
:refFailed.has(r.id)?'Its geometry could not be loaded — use ⋯ ▸ Reload its geometry.'
|
|
10324
|
+
// The reader ANSWERED for this one and had nothing drawable to give. The row already says
|
|
10325
|
+
// "· nothing to draw"; saying "never read" three pixels below it would contradict it.
|
|
10326
|
+
:refEmpty.has(r.id)?'This file was read, but it holds nothing we can draw — so there is nothing to list.'
|
|
10327
|
+
:'This file hasn’t been read yet.';
|
|
10328
|
+
body.appendChild(n);return;
|
|
10329
|
+
}
|
|
10330
|
+
const objects=geom.objects||[];
|
|
10331
|
+
// Geometry present and empty is a FIFTH state, not a sixth branch of the one above: a cache entry that
|
|
10332
|
+
// predates the reader's own emptiness check returns ok with no objects. Without this the tree drew a
|
|
10333
|
+
// filter box over an empty bordered rectangle and said nothing at all — the exact outcome the comment
|
|
10334
|
+
// above promises to prevent.
|
|
10335
|
+
if(!objects.length){
|
|
10336
|
+
body.appendChild(Object.assign(document.createElement('div'),
|
|
10337
|
+
{className:'dnote',textContent:'Reading this file returned no objects — use ⋯ ▸ Reload its geometry to try again.'}));
|
|
10338
|
+
return;
|
|
10339
|
+
}
|
|
10340
|
+
const groups=groupReferenceObjects(objects);
|
|
10341
|
+
const q=(refTreeQuery.get(r.id)||'').trim().toLowerCase();
|
|
10342
|
+
|
|
10343
|
+
// The filter, inside the tree it filters — it is scoped to ONE reference's objects, so it is not a
|
|
10344
|
+
// peer of the tab's own controls. It reuses the property popover's SHAPE, not its CSS: every
|
|
10345
|
+
// `.ppsearch` rule is scoped to #propPop and cannot reach this panel, so the class is styled here.
|
|
10346
|
+
const sb=document.createElement('div');sb.className='reftreesearch';
|
|
10347
|
+
const inp=document.createElement('input');inp.type='text';inp.placeholder='Filter by name, type or storey…';
|
|
10348
|
+
inp.id=REF_TREE_SEARCH_ID;
|
|
10349
|
+
inp.autocomplete='off';inp.value=refTreeQuery.get(r.id)||'';
|
|
10350
|
+
inp.setAttribute('role','searchbox');inp.setAttribute('aria-label','Filter the objects in this reference');
|
|
10351
|
+
inp.addEventListener('keydown',(e)=>e.stopPropagation()); // the editor's global shortcuts must not see typing
|
|
10352
|
+
// TYPING REPAINTS THE TAB, WHICH DESTROYS THIS INPUT, so the focus has to be put back or the NEXT
|
|
10353
|
+
// character lands on the document — where `a` arms Add-member and Backspace deletes the selection.
|
|
10354
|
+
// (That is not hypothetical: the first version looked this up with a selector that could never match,
|
|
10355
|
+
// and typing "beam" into the filter armed a tool.) Found by id, because the id is the one thing that
|
|
10356
|
+
// survives the rebuild, and the whole selection is restored, so editing mid-word works.
|
|
10357
|
+
//
|
|
10358
|
+
// NOT WHILE COMPOSING. An IME builds one character out of several keystrokes and holds that state on
|
|
10359
|
+
// the INPUT ELEMENT; replacing the element mid-composition drops or mangles it. `isComposing` means
|
|
10360
|
+
// the user is mid-character, so the tree simply does not repaint until `compositionend` fires — the
|
|
10361
|
+
// filter is one keystroke stale for the duration, which nobody can see, and the character survives.
|
|
10362
|
+
//
|
|
10363
|
+
// Undo history is NOT preserved: it belongs to the element, and this rebuilds the element. Fixing that
|
|
10364
|
+
// means repainting the tree without rebuilding the whole tab, which is a larger change than this pass.
|
|
10365
|
+
const refilter=()=>{
|
|
10366
|
+
const from=inp.selectionStart,to=inp.selectionEnd,dir=inp.selectionDirection;
|
|
10367
|
+
refTreeQuery.set(r.id,inp.value);renderRefsTab();
|
|
10368
|
+
const again=document.getElementById(REF_TREE_SEARCH_ID);
|
|
10369
|
+
if(!again){console.error('[reference] the tree filter did not survive its repaint — typing would now reach the editor shortcuts');return;}
|
|
10370
|
+
again.focus();
|
|
10371
|
+
try{again.setSelectionRange(from,to,dir||'none');}catch(e){console.debug('[reference] could not restore the filter selection',e);}
|
|
10372
|
+
};
|
|
10373
|
+
inp.addEventListener('input',(e)=>{ if(e&&e.isComposing)return; refilter(); });
|
|
10374
|
+
inp.addEventListener('compositionend',refilter);
|
|
10375
|
+
sb.appendChild(inp);body.appendChild(sb);
|
|
10376
|
+
|
|
10377
|
+
const box=document.createElement('div');box.className='reftree';body.appendChild(box);
|
|
10378
|
+
const expanded=refTreeGroups.get(r.id)||new Map();
|
|
10379
|
+
|
|
10380
|
+
// MATCHED ONCE, NOT PER GROUP. Every count below is a lookup into this set. The old shape re-ran the
|
|
10381
|
+
// string work of `refTreeMatches` for each object once for its storey's count and again for its type's
|
|
10382
|
+
// count, and it measured 732 ms per keystroke — a filter you can outrun by typing.
|
|
10383
|
+
const hits=q?new Set():null;
|
|
10384
|
+
if(q)for(let i=0;i<objects.length;i++)if(refTreeMatches(objects[i],q))hits.add(i);
|
|
10385
|
+
const matched=q?hits.size:objects.length;
|
|
10386
|
+
|
|
10387
|
+
/**
|
|
10388
|
+
* A filter opens the groups it matched — UNLESS it matched more than one screenful.
|
|
10389
|
+
*
|
|
10390
|
+
* "Never hide a match behind a collapsed chevron" is the right instinct and it does not survive this
|
|
10391
|
+
* building: filtering Daldy for "mullion" matches 8,000-odd objects across ten storeys, and force-
|
|
10392
|
+
* expanding all of them built 2,795 rows and nine separate "showing 300 of …" lines — a wall, from a
|
|
10393
|
+
* rule meant to be helpful. Above the cap the groups keep whatever the user had open, and their headers
|
|
10394
|
+
* still read "N of M", so where the matches are is stated rather than dumped.
|
|
10395
|
+
*/
|
|
10396
|
+
const wide=!!q&&matched>REF_TREE_CAP;
|
|
10397
|
+
// A SINGLE GROUP AT ITS LEVEL OPENS ITSELF — with nothing to choose between, a click to reach the only
|
|
10398
|
+
// content is a toll. It is also what makes the storey-less file and the single-storey file (Motebello)
|
|
10399
|
+
// land somewhere sensible with no special case.
|
|
10400
|
+
//
|
|
10401
|
+
// A CHOICE IS REMEMBERED AGAINST THE FILTER IT WAS MADE UNDER, which is what lets both of these be
|
|
10402
|
+
// true at once: a filter opens the groups it matched, AND a header still obeys a click while filtering.
|
|
10403
|
+
// Storing the choice alone could not do that — a storey closed with no filter went on suppressing its
|
|
10404
|
+
// own matches afterwards, so a user could type a precise query, read "(2 of 6)" on the header, and be
|
|
10405
|
+
// shown nothing. Keying the choice to the query means the collapse applies when that query returns
|
|
10406
|
+
// (including when it returns to empty) and stays out of the way under a different one.
|
|
10407
|
+
const isOpen=(key,only)=>{
|
|
10408
|
+
const chose=expanded.get(key);
|
|
10409
|
+
// `q:null` is the reveal's own mark: "this group holds the selection, keep it open under ANY query".
|
|
10410
|
+
// Without it, groups opened only to show a selected object collapsed the moment the filter changed —
|
|
10411
|
+
// including clearing it — so an object picked while filtering vanished from the tree the instant the
|
|
10412
|
+
// user emptied the box, while staying selected in 3D and in the panel.
|
|
10413
|
+
if(chose&&(chose.q===null||chose.q===q))return chose.open;
|
|
10414
|
+
if(q&&!wide)return true;
|
|
10415
|
+
return !!only;
|
|
10416
|
+
};
|
|
10417
|
+
const toggle=(key,wasOpen)=>{const s=new Map(refTreeGroups.get(r.id)||[]);
|
|
10418
|
+
s.set(key,{open:!wasOpen,q});refTreeGroups.set(r.id,s);renderRefsTab();};
|
|
10419
|
+
// THE STOREY TIER IS OMITTED ENTIRELY when the file records no storeys at all — chrome around a
|
|
10420
|
+
// grouping level that carries no information. One line says so instead, once.
|
|
10421
|
+
const flat=groups.length===1&&groups[0].storey===null;
|
|
10422
|
+
const built=[]; // every object row this paint produced, in order — see `refTreeRoving` at the end
|
|
10423
|
+
if(flat){
|
|
10424
|
+
const n=Object.assign(document.createElement('div'),{className:'dnote'});n.style.margin='0 0 4px';
|
|
10425
|
+
n.textContent='This file does not record storeys — its objects are grouped by type only.';
|
|
10426
|
+
box.appendChild(n);
|
|
10427
|
+
}
|
|
10428
|
+
groups.forEach((s,si)=>{
|
|
10429
|
+
const sKey=String(si);
|
|
10430
|
+
const sMatched=q?s.types.reduce((n,t)=>n+t.indices.reduce((m,i)=>m+(hits.has(i)?1:0),0),0):s.count;
|
|
10431
|
+
if(q&&!sMatched)return; // a storey with no match is gone, not greyed
|
|
10432
|
+
const sOpen=flat||isOpen(sKey,groups.length===1);
|
|
10433
|
+
if(!flat){
|
|
10434
|
+
const h=document.createElement('div');h.className='cat-hdr';h.setAttribute('role','button');
|
|
10435
|
+
h.setAttribute('aria-expanded',String(sOpen));
|
|
10436
|
+
h.append(Object.assign(document.createElement('span'),{className:'cat-chevron',textContent:sOpen?'▼':'▶'}),
|
|
10437
|
+
Object.assign(document.createElement('span'),{className:'cat-label',textContent:s.storey||'No storey recorded'}),
|
|
10438
|
+
// "N of M" WHILE FILTERING. A count that quietly means something different depending on a text box
|
|
10439
|
+
// above it is the same class of wrong as a stale one.
|
|
10440
|
+
Object.assign(document.createElement('span'),{className:'cat-count',textContent:q?'('+sMatched+' of '+s.count+')':'('+s.count+')'}));
|
|
10441
|
+
h.dataset.tip=(s.storey||'The file records no storey for these objects')+' — '+s.count+' object'+(s.count===1?'':'s');
|
|
10442
|
+
h.addEventListener('click',()=>toggle(sKey,sOpen));
|
|
10443
|
+
refTreeKeyOperable(h);
|
|
10444
|
+
box.appendChild(h);
|
|
10445
|
+
}
|
|
10446
|
+
if(!sOpen)return;
|
|
10447
|
+
// TWO TYPES CAN SHARE A PLAIN WORD, and Daldy proves it: `IFCWALL` and `IFCWALLSTANDARDCASE` both
|
|
10448
|
+
// read "Wall", so its LG storey listed "Wall (388)" directly above "Wall (52)" — two groups a user
|
|
10449
|
+
// cannot tell apart, differing only in a number. The raw token comes back for exactly those, and only
|
|
10450
|
+
// those: showing it on every header does not fit a 340px panel sixteen times over, and showing it
|
|
10451
|
+
// never leaves the list lying about what is in the file. (Found by running it on the real building.)
|
|
10452
|
+
const words=(t)=>t.words||'No type recorded';
|
|
10453
|
+
const dup=new Set(),once=new Set();
|
|
10454
|
+
s.types.forEach((t)=>{const w=words(t);if(once.has(w))dup.add(w);else once.add(w);});
|
|
10455
|
+
s.types.forEach((t,ti)=>{
|
|
10456
|
+
const tKey=si+':'+ti;
|
|
10457
|
+
const tHits=q?t.indices.filter((i)=>hits.has(i)):t.indices;
|
|
10458
|
+
if(q&&!tHits.length)return;
|
|
10459
|
+
const tOpen=isOpen(tKey,s.types.length===1);
|
|
10460
|
+
const h=document.createElement('div');h.className='cat-hdr'+(flat?'':' sub');h.setAttribute('role','button');
|
|
10461
|
+
h.setAttribute('aria-expanded',String(tOpen));
|
|
10462
|
+
h.append(Object.assign(document.createElement('span'),{className:'cat-chevron',textContent:tOpen?'▼':'▶'}),
|
|
10463
|
+
// The PLAIN WORD only. "Generic element (IFCBUILDINGELEMENTPROXY)" does not fit a 340px panel
|
|
10464
|
+
// repeated sixteen times, and the raw token is already shown on the object itself once selected —
|
|
10465
|
+
// except where two of this storey's types share that word, when it is the only thing separating them.
|
|
10466
|
+
Object.assign(document.createElement('span'),{className:'cat-label',textContent:words(t)+(dup.has(words(t))&&t.type?' · '+t.type:'')}),
|
|
10467
|
+
Object.assign(document.createElement('span'),{className:'cat-count',textContent:q?'('+tHits.length+' of '+t.count+')':'('+t.count+')'}));
|
|
10468
|
+
h.dataset.tip=(t.type||'The file records no IFC type for these objects')+' — '+t.count+' object'+(t.count===1?'':'s');
|
|
10469
|
+
h.addEventListener('click',()=>toggle(tKey,tOpen));
|
|
10470
|
+
refTreeKeyOperable(h);
|
|
10471
|
+
box.appendChild(h);
|
|
10472
|
+
if(!tOpen)return;
|
|
10473
|
+
const list=tHits;
|
|
10474
|
+
// THE SELECTED ROW IS NEVER THE ONE THE CAP DROPS. Taking a blind first-300 made "drill in 3D and the
|
|
10475
|
+
// tree shows you the row" false for 8,910 of this group's 9,210 members — the reveal opened the right
|
|
10476
|
+
// headers and then found nothing to scroll to. When the selection sits past the cap the window slides
|
|
10477
|
+
// to hold it, and the line below says so rather than still claiming the first 300.
|
|
10478
|
+
const want=(refSelectedId===r.id&&typeof refSelectedObjIdx==='number')?list.indexOf(refSelectedObjIdx):-1;
|
|
10479
|
+
let from=0;
|
|
10480
|
+
if(want>=REF_TREE_CAP)from=Math.min(want-(REF_TREE_CAP>>1),list.length-REF_TREE_CAP);
|
|
10481
|
+
const shown=list.slice(from,from+REF_TREE_CAP);
|
|
10482
|
+
// The ordinal of every row in one pass, rather than an indexOf per row: on a 9,210-index group a
|
|
10483
|
+
// filter whose matches sit late cost ~2.8M comparisons on EVERY keystroke.
|
|
10484
|
+
const ord=new Map();t.indices.forEach((i,n)=>ord.set(i,n+1));
|
|
10485
|
+
shown.forEach((idx)=>{ const row=buildRefObjRow(r,objects[idx],idx,t,flat,ord.get(idx)); built.push(row); box.appendChild(row); });
|
|
10486
|
+
if(list.length>REF_TREE_CAP){
|
|
10487
|
+
const more=Object.assign(document.createElement('div'),{className:'refcap'});
|
|
10488
|
+
more.textContent=from
|
|
10489
|
+
?'Showing '+shown.length+' of '+list.length+', centred on the selected object — use the filter above to narrow this list.'
|
|
10490
|
+
:'Showing '+REF_TREE_CAP+' of '+list.length+' — use the filter above to narrow this list.';
|
|
10491
|
+
box.appendChild(more);
|
|
10492
|
+
}
|
|
10493
|
+
});
|
|
10494
|
+
});
|
|
10495
|
+
if(built.length)refTreeRoving(built);
|
|
10496
|
+
if(q&&!matched){
|
|
10497
|
+
const e=Object.assign(document.createElement('div'),{className:'lsempty'});
|
|
10498
|
+
e.textContent='No objects match “'+(refTreeQuery.get(r.id)||'').trim()+'”.';
|
|
10499
|
+
box.appendChild(e);
|
|
10500
|
+
}
|
|
10501
|
+
}
|
|
10502
|
+
|
|
10503
|
+
/**
|
|
10504
|
+
* Bring the tree to an object drilled into from the 3D view.
|
|
10505
|
+
*
|
|
10506
|
+
* ONLY IF THE TREE IS ALREADY OPEN. Ctrl+click in the canvas is not a request to rearrange the legend,
|
|
10507
|
+
* and opening a panel behind the user's back — expanding groups, scrolling a list they were not looking
|
|
10508
|
+
* at — is the kind of help that costs them their place. When the tree IS open the opposite is true: a
|
|
10509
|
+
* selection the tree cannot show is a tree disagreeing with the scene, so its groups open, the row
|
|
10510
|
+
* scrolls into view, and it flashes the way every other "you just navigated here" row in this panel does.
|
|
10511
|
+
*
|
|
10512
|
+
* TWO THINGS COULD HIDE THAT ROW and both are handled here rather than left to fail quietly: a filter the
|
|
10513
|
+
* object does not match (cleared, and the user is told, because a tree that silently drops the filter is
|
|
10514
|
+
* as confusing as one that silently ignores the selection), and a position past the row cap (handled by
|
|
10515
|
+
* the window in `buildRefTree`, which keys off the selection this function has already set).
|
|
10516
|
+
*
|
|
10517
|
+
* Returns false when it did nothing, so the caller can fall back to an ordinary repaint.
|
|
10518
|
+
*/
|
|
10519
|
+
function revealRefTreeObject(refId,idx){
|
|
10520
|
+
if(!refTreeOpen.has(refId)||legendTab!=='refs')return false;
|
|
10521
|
+
const geom=refGeom.get(refId);
|
|
10522
|
+
const objects=geom&&geom.objects;
|
|
10523
|
+
if(!Array.isArray(objects)||!objects[idx])return false;
|
|
10524
|
+
const q=(refTreeQuery.get(refId)||'').trim().toLowerCase();
|
|
10525
|
+
const cleared=!!q&&!refTreeMatches(objects[idx],q);
|
|
10526
|
+
if(cleared)refTreeQuery.set(refId,'');
|
|
10527
|
+
const groups=groupReferenceObjects(objects);
|
|
10528
|
+
// `q:null` — open under ANY query, not just the one in the box right now. The path to the SELECTED
|
|
10529
|
+
// object is not a filter-scoped preference: filed against the current query, these opens evaporated as
|
|
10530
|
+
// soon as the user changed or cleared the filter, and the object they had just picked dropped out of
|
|
10531
|
+
// the tree while remaining lit in 3D. A later explicit click on the same header overwrites this.
|
|
10532
|
+
const s=new Map(refTreeGroups.get(refId)||[]);
|
|
10533
|
+
groups.forEach((st,si)=>st.types.forEach((t,ti)=>{
|
|
10534
|
+
if(t.indices.indexOf(idx)<0)return;
|
|
10535
|
+
s.set(String(si),{open:true,q:null});s.set(si+':'+ti,{open:true,q:null});
|
|
10536
|
+
}));
|
|
10537
|
+
refTreeGroups.set(refId,s);
|
|
10538
|
+
renderRefsTab();
|
|
10539
|
+
// SAID BEFORE ANYTHING ELSE CAN GO WRONG. Taking the filter away is a visible change to the user's own
|
|
10540
|
+
// state, so it is announced on every path that does it — including the one below that then fails to
|
|
10541
|
+
// find the row, which is exactly when an unexplained empty filter box would be most confusing.
|
|
10542
|
+
if(cleared)toast('Cleared the object filter to show the selected object');
|
|
10543
|
+
// Scoped to THIS reference's tree. Only the selected reference renders a detail block today, so an
|
|
10544
|
+
// unscoped lookup is right by accident; this makes it right on purpose.
|
|
10545
|
+
const row=document.querySelector('#reftree-'+refId+' .refobjrow[data-idx="'+idx+'"]');
|
|
10546
|
+
if(!row){console.error('[reference] object',idx,'of',refId,'is selected but has no row in the open tree');return true;}
|
|
10547
|
+
try{row.scrollIntoView({block:'nearest'});}catch(e){console.debug('[reference] scrollIntoView unavailable',e);}
|
|
10548
|
+
row.classList.add('flash');setTimeout(()=>row.classList.remove('flash'),900);
|
|
10549
|
+
return true;
|
|
10550
|
+
}
|
|
10551
|
+
|
|
10552
|
+
/** "1st", "2nd", "3rd", "4th" — including the 11th/12th/13th exceptions, which the naive rule gets wrong. */
|
|
10553
|
+
function ordinalSuffix(n){
|
|
10554
|
+
const t=n%100;
|
|
10555
|
+
if(t>=11&&t<=13)return 'th';
|
|
10556
|
+
return ['th','st','nd','rd'][n%10]||'th';
|
|
10557
|
+
}
|
|
10558
|
+
|
|
10559
|
+
/**
|
|
10560
|
+
* One object row.
|
|
10561
|
+
*
|
|
10562
|
+
* THE NAME IS NOT ENOUGH AND THIS FILE PROVES IT: twelve of Motebello's nineteen objects are called
|
|
10563
|
+
* "Betonfertigteil" and two are called "-". So the row carries its position within its own type group as
|
|
10564
|
+
* well — `#4/19` on that file, since all nineteen share one type — which always exists and is the one
|
|
10565
|
+
* thing that distinguishes two otherwise identical rows. The caller passes the ordinal in because it can
|
|
10566
|
+
* number a whole group in one pass; finding it per row was a linear scan of up to 9,210 indices.
|
|
10567
|
+
*
|
|
10568
|
+
* THE ORDINAL IS COUNTED AGAINST THE UNFILTERED GROUP. Numbering the filtered view would renumber every
|
|
10569
|
+
* object as the user types, which is a statement about the file that changes with a text box.
|
|
10570
|
+
*/
|
|
10571
|
+
function buildRefObjRow(r,o,idx,group,flat,ordinal){
|
|
10572
|
+
const row=document.createElement('div');
|
|
10573
|
+
row.className='refobjrow'+(refSelectedId===r.id&&refSelectedObjIdx===idx?' sel':'');
|
|
10574
|
+
if(flat)row.style.paddingLeft='20px';
|
|
10575
|
+
row.dataset.idx=String(idx);
|
|
10576
|
+
// Enter/Space select, like `refTreeKeyOperable` — but selecting REPAINTS the tab, which destroys this
|
|
10577
|
+
// row, and the focus went to the document with it. A keyboard user who picks a row was then back at
|
|
10578
|
+
// the top of the panel and could not carry on arrowing. So the focus is put on the row that replaced
|
|
10579
|
+
// this one. (Rows do not own a tab stop of their own — `refTreeRoving` shares one between them.)
|
|
10580
|
+
row.setAttribute('role','button');
|
|
10581
|
+
row.addEventListener('keydown',(e)=>{
|
|
10582
|
+
if(e.key!=='Enter'&&e.key!==' ')return;
|
|
10583
|
+
e.preventDefault();e.stopPropagation();
|
|
10584
|
+
row.click();
|
|
10585
|
+
const again=document.querySelector('#reftree-'+r.id+' .refobjrow[data-idx="'+idx+'"]');
|
|
10586
|
+
if(again)again.focus();
|
|
10587
|
+
});
|
|
10588
|
+
const named=refObjNamed(o&&o.name);
|
|
10589
|
+
const label=named?String(o.name).trim():(group.words||'Object');
|
|
10590
|
+
row.appendChild(Object.assign(document.createElement('span'),{className:'ronm',textContent:label}));
|
|
10591
|
+
if(ordinal>0)row.appendChild(Object.assign(document.createElement('span'),{className:'rord',textContent:'#'+ordinal+'/'+group.count}));
|
|
10592
|
+
// The ordinal badge is the one thing on this row whose MEANING is not self-evident — `#4/19` could be
|
|
10593
|
+
// read as a date or an id — so the tooltip spells it out. It is the only place that can: the row is
|
|
10594
|
+
// already dense, and a second visible label per row on a 340px rail costs more than it explains.
|
|
10595
|
+
row.dataset.tip=(named?String(o.name).trim():'This file gives it no name')+' — '+(o&&o.ifcType||'no IFC type')
|
|
10596
|
+
+(o&&o.storey?' · '+String(o.storey).trim():'')
|
|
10597
|
+
+(ordinal>0?' — the '+ordinal+ordinalSuffix(ordinal)+' of '+group.count+' with this type in this storey':'');
|
|
10598
|
+
// THE SAME CALL Ctrl+click MAKES. Two routes into one selection, so they cannot drift into two.
|
|
10599
|
+
row.addEventListener('click',()=>{
|
|
10600
|
+
const v=window.Steel3DView;
|
|
10601
|
+
if(!v||!v.selectReferenceObject){
|
|
10602
|
+
console.error('[reference] the 3D view is not available, so a tree row cannot select',r.id,idx);
|
|
10603
|
+
toast('The 3D view isn’t ready yet — try again in a moment');return;
|
|
10604
|
+
}
|
|
10605
|
+
// Visibility is NOT what makes this fail — `setReferences` builds a mesh for every object whether the
|
|
10606
|
+
// reference is shown or not, so a hidden reference selects fine. What fails is the panel and the
|
|
10607
|
+
// renderer disagreeing about how many objects there are, and telling the user to toggle an eye icon
|
|
10608
|
+
// would send them after the wrong thing. A throw is caught for the same reason: it would otherwise
|
|
10609
|
+
// escape the listener and leave the tree half-drawn with no message at all.
|
|
10610
|
+
let ok=false;
|
|
10611
|
+
try{ok=v.selectReferenceObject(r.id,idx);}
|
|
10612
|
+
catch(e){
|
|
10613
|
+
console.error('[reference] selecting object',idx,'of',r.id,'threw',e);
|
|
10614
|
+
toast('Could not select that object — use ⋯ ▸ Reload its geometry');return;
|
|
10615
|
+
}
|
|
10616
|
+
if(!ok){
|
|
10617
|
+
console.error('[reference] object',idx,'of',r.id,'has no mesh — the panel and the 3D view disagree');
|
|
10618
|
+
toast('That object isn’t in the 3D scene — use ⋯ ▸ Reload its geometry');
|
|
10619
|
+
}
|
|
10620
|
+
});
|
|
10621
|
+
return row;
|
|
10622
|
+
}
|
|
10623
|
+
|
|
9683
10624
|
/** A file size a human recognises from their file manager. KB under a megabyte, MB above it. */
|
|
9684
10625
|
function fileSizeWords(bytes){
|
|
9685
10626
|
const n=Number(bytes)||0;
|
|
@@ -9698,6 +10639,15 @@ function unitWords(declared){
|
|
|
9698
10639
|
* general-purpose nudge after a manual drag.)
|
|
9699
10640
|
*/
|
|
9700
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.';
|
|
9701
10651
|
/**
|
|
9702
10652
|
* Shift a reference so its centre lands ON THE MODEL — the fix the Motebello measurement earned.
|
|
9703
10653
|
*
|
|
@@ -9733,6 +10683,11 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
9733
10683
|
const m=document.createElement('div');m.id='refRowMenu';m.className='m3dmenu open';m.setAttribute('role','menu');
|
|
9734
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;};
|
|
9735
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)));
|
|
9736
10691
|
// OFFERED ONLY WHEN THERE IS SOMETHING TO BE NEXT TO. Loading a reference before modelling any steel is
|
|
9737
10692
|
// a normal first move, and in that state this command can do nothing but toast a refusal — an enabled
|
|
9738
10693
|
// item that always fails is a worse answer than no item. Omitted rather than disabled, which is how
|
|
@@ -9742,7 +10697,17 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
9742
10697
|
if(nativeModelBounds())m.append(mk(REF_MOVE_LABEL,()=>refMoveToOrigin(r.id)));
|
|
9743
10698
|
m.append(mk('Reload its geometry',()=>{
|
|
9744
10699
|
if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to reload it');return;} // the lock freezes reload, as the schema says
|
|
9745
|
-
|
|
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);
|
|
10705
|
+
refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);
|
|
10706
|
+
// The tree's group keys are POSITIONAL ('2:1' is the second storey's second type), so a
|
|
10707
|
+
// re-read that adds, drops or reorders anything makes them address different groups. Dropped
|
|
10708
|
+
// rather than migrated: there is no identity here to migrate them by.
|
|
10709
|
+
refTreeGroups.delete(r.id);refTreeQuery.delete(r.id);
|
|
10710
|
+
loadReferenceGeometry(r.id,{rebuild:true});}));
|
|
9746
10711
|
m.appendChild(document.createElement('hr'));
|
|
9747
10712
|
m.appendChild(mk('Remove',()=>refRemove(r),true));
|
|
9748
10713
|
document.body.appendChild(m);
|
|
@@ -9772,7 +10737,11 @@ async function refRemove(r){
|
|
|
9772
10737
|
adoptReferenceWrite(d.etag);
|
|
9773
10738
|
const i=refList().findIndex(x=>x&&x.id===r.id);if(i>=0)C.reference_models.splice(i,1);
|
|
9774
10739
|
refGeom.delete(r.id);refUnresolved.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);
|
|
10740
|
+
refTreeOpen.delete(r.id);refTreeGroups.delete(r.id);refTreeQuery.delete(r.id); // the tree goes with the reference
|
|
9775
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);
|
|
9776
10745
|
pushReferences();renderRefsTab();panel();
|
|
9777
10746
|
}catch(_){toast('Could not remove that reference');}
|
|
9778
10747
|
}
|
|
@@ -9824,11 +10793,246 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9824
10793
|
if(!view3d){toast('Switch to the 3D view to add a reference model');return;}
|
|
9825
10794
|
riStop(); // a previous attempt's in-flight probe must not answer into this one
|
|
9826
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
|
|
9827
10797
|
riStage('drop');ri$('refImportModal').style.display='flex';}
|
|
9828
10798
|
window.openRefImport=openRefImport;
|
|
9829
10799
|
function riClose(){riStop();riClearSoft();ri$('refImportModal').style.display='none';}
|
|
9830
10800
|
|
|
9831
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
|
+
}
|
|
9832
11036
|
function riReadFile(f){ if(!f||riBusy)return;riErr('');
|
|
9833
11037
|
if(!/\.(ifc|ifczip)$/i.test(f.name||'')){riErr('Not an IFC file — expected .ifc or .ifczip.');return;}
|
|
9834
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;}
|
|
@@ -9856,6 +11060,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9856
11060
|
// response already on the wire lands anyway — so the id is what actually stops a cancelled
|
|
9857
11061
|
// file's facts being written under a different file's name.
|
|
9858
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;
|
|
9859
11069
|
riClearSoft();
|
|
9860
11070
|
if(!res.ok||!d.ok){riStage('drop');riErr(d.error||'Could not read that file.');return;}
|
|
9861
11071
|
riSha=d.sha;riVerdict=d.verdict||null;
|
|
@@ -9866,7 +11076,13 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9866
11076
|
says.append(b,document.createTextNode(said?unitWords(said):'nothing about its units'),
|
|
9867
11077
|
document.createTextNode('. FloLess has already applied that — you should not need to rescale it.'));
|
|
9868
11078
|
ri$('riSchema').textContent=(d.probe&&d.probe.schema)||'—';
|
|
9869
|
-
|
|
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);
|
|
9870
11086
|
// KB below a megabyte. `Math.max(1, …)` reported a 7.6 KB file as "1 MB" — a small lie, but the
|
|
9871
11087
|
// number sits directly above a limit stated in MB, so it made the two unreadable together.
|
|
9872
11088
|
ri$('riBytes').textContent=fileSizeWords(d.bytes||0);
|
|
@@ -9924,6 +11140,7 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9924
11140
|
// the same reason the offer is (the bbox spans everything the file places) — the panel's own offer
|
|
9925
11141
|
// re-does it exactly once the real bounds exist.
|
|
9926
11142
|
const riNative=nativeModelCentre();
|
|
11143
|
+
const riFilterBody=riBuildFilter(); // computed ONCE — it was called twice in one expression
|
|
9927
11144
|
const riOriginShift=takeOrigin&&riProbeCentre?riProbeCentre.map((v,i)=>riNative[i]-v):null;
|
|
9928
11145
|
riStage('prog');riProg('Reading the geometry…','Still reading — a whole building takes a moment.');
|
|
9929
11146
|
try{
|
|
@@ -9933,7 +11150,11 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9933
11150
|
// the reference rather than by a debounced PUT afterwards. Applying it in the presentation
|
|
9934
11151
|
// block left it outside the point of no return: a closed tab or a save conflict would leave
|
|
9935
11152
|
// the server holding the site coordinates the user had just asked to move away from.
|
|
9936
|
-
|
|
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}}:{})})});
|
|
9937
11158
|
d=await res.json().catch(()=>({}));
|
|
9938
11159
|
if(mine!==riRun){
|
|
9939
11160
|
// Cancelled while this was in flight. The server refuses to commit for a client that has gone
|
|
@@ -9947,13 +11168,27 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9947
11168
|
return;
|
|
9948
11169
|
}
|
|
9949
11170
|
riClearSoft();
|
|
9950
|
-
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
|
+
}
|
|
9951
11186
|
adoptReferenceWrite(d.etag);
|
|
9952
11187
|
if(!Array.isArray(C.reference_models))C.reference_models=[];
|
|
9953
11188
|
C.reference_models.push(d.reference);
|
|
9954
11189
|
refGeom.set(d.reference.id,refGeomFrom(d)); // the same normaliser the geometry route's arrival uses — one shape, one spelling
|
|
9955
11190
|
hadDrill=refSelectedObjIdx!==null; // …before this line drops it; the presentation half below needs to know
|
|
9956
|
-
refSelectedId=d.reference.id;refSelectedObjIdx=null;
|
|
11191
|
+
refSelectedId=d.reference.id;refMeasureFollowSelection();refSelectedObjIdx=null;
|
|
9957
11192
|
inserted=d.reference;
|
|
9958
11193
|
}catch(e){
|
|
9959
11194
|
// Aborted: no response at all, so we cannot know whether the write landed. Same reasoning as
|
|
@@ -9984,6 +11219,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9984
11219
|
// throw away whatever else the inspector was in the middle of. (Codex review, both halves.)
|
|
9985
11220
|
if(hadDrill)panel();
|
|
9986
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
|
+
}
|
|
9987
11228
|
}catch(e){
|
|
9988
11229
|
console.error('[reference] added, but the view could not be updated',e);
|
|
9989
11230
|
toast('Added “'+inserted.name+'” — reload the view to see it');
|
|
@@ -9996,6 +11237,12 @@ function adoptReferenceWrite(etag){if(!etag)return;const prev=serverEtag;serverE
|
|
|
9996
11237
|
// leaving the invisible one is the version of that rule that does not hold. (UX review, #580.)
|
|
9997
11238
|
ri$('riBackdrop').onclick=()=>{if(riStageNow!=='prog')riClose();};
|
|
9998
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();};
|
|
9999
11246
|
ri$('riDrop').onclick=()=>ri$('riFile').click();
|
|
10000
11247
|
ri$('riDrop').onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();ri$('riFile').click();}};
|
|
10001
11248
|
ri$('riFile').onchange=e=>{const f=e.target.files&&e.target.files[0];e.target.value='';riReadFile(f);};
|