@floless/app 0.85.0 → 0.86.1
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 +2001 -711
- package/dist/schemas/steel.takeoff.v1.schema.json +34 -4
- package/dist/skills/floless-app-knowledge/SKILL.md +206 -0
- package/dist/skills/floless-app-knowledge/references/schema.md +132 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +380 -28
- package/dist/skills/floless-app-workflows/SKILL.md +33 -7
- package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +2 -1
- package/dist/skills/floless-app-workflows/references/exec-contract.md +1 -1
- package/dist/skills/floless-app-workflows/references/workspace-data.md +111 -0
- package/dist/skills/reading-structural-drawings/SKILL.md +102 -1
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +33 -1
- package/dist/templates/floless-workspace-read.flo +161 -0
- package/dist/web/app.css +312 -14
- package/dist/web/aware.js +327 -43
- package/dist/web/grid-core.js +40 -6
- package/dist/web/index.html +49 -11
- package/dist/web/steel-3d-view.js +117 -20
- package/dist/web/steel-editor.html +1426 -296
- package/dist/web/steel-filter.html +3 -1
- package/dist/web/vector-3d.html +3 -3
- package/dist/web/vector-editor.html +12 -5
- package/dist/web/workspaces.js +1083 -100
- package/package.json +1 -1
|
@@ -48,6 +48,25 @@
|
|
|
48
48
|
line.member{cursor:pointer;stroke-width:6;stroke-linecap:round} /* default (drag-move OFF): a click selects → the pointer cursor tells the truth */
|
|
49
49
|
body.dragmove line.member{cursor:move} /* drag-move ON: the move cursor signals a drag will translate — a per-hover second signal beside the toolbar pill */
|
|
50
50
|
line.member.sel{stroke-width:7} line.member.rfi{stroke-dasharray:10 6}
|
|
51
|
+
polygon.bracehead{pointer-events:none} /* heads never intercept a click — line.bracehit below is the hit target */
|
|
52
|
+
/* An invisible hit corridor wide enough to cover the ARROWHEADS — the most eye-catching part of the symbol
|
|
53
|
+
would otherwise be a dead zone (the 6-unit body stroke is narrower than a head's wingspan). Same paired
|
|
54
|
+
visible-line/hit-line idiom as line.gridln + line.gridhit. Width is set inline (it tracks the head size). */
|
|
55
|
+
line.bracehit{stroke:transparent;pointer-events:stroke;cursor:pointer}
|
|
56
|
+
body.dragmove line.bracehit{cursor:move}
|
|
57
|
+
/* The visible body is decorative (the corridor owns the pointer). Its selected thickness is driven from the
|
|
58
|
+
GROUP's .sel class, never an inline width — so the surgical no-render selection cleanup, which only clears
|
|
59
|
+
classes on g.bracesym, can't leave a brace stuck at the selected weight. */
|
|
60
|
+
line.bracebody{stroke-width:6;stroke-linecap:round;pointer-events:none}
|
|
61
|
+
g.bracesym.sel line.bracebody{stroke-width:7}
|
|
62
|
+
/* An offset brace draws its symbol away from its work points; a faint witness ties the drawn line back to
|
|
63
|
+
each true work point so the end handles never look detached. Same language as the dimension witness. */
|
|
64
|
+
line.bracewit{stroke:#94a3b8;stroke-width:1;opacity:.55;stroke-dasharray:3 3;vector-effect:non-scaling-stroke;pointer-events:none}
|
|
65
|
+
/* Columns render as their profile-section footprint (a filled polygon), not a line: a solid fill so
|
|
66
|
+
they read as a section on the plan; fill-opacity keeps any grid/linework beneath faintly visible. */
|
|
67
|
+
polygon.member{cursor:pointer;stroke-width:1.5;fill-opacity:.7;stroke-linejoin:round}
|
|
68
|
+
body.dragmove polygon.member{cursor:move}
|
|
69
|
+
polygon.member.sel{stroke-width:2} polygon.member.rfi{fill-opacity:.15;stroke-dasharray:6 4}
|
|
51
70
|
circle.handle{fill:var(--bg);stroke:#f8fafc;stroke-width:3;cursor:grab}
|
|
52
71
|
line.seg{stroke:#475569;stroke-width:2;opacity:0;cursor:crosshair} body.add line.seg{opacity:.5}
|
|
53
72
|
line.seg:hover{stroke:#fbbf24;opacity:1;stroke-width:4}
|
|
@@ -61,7 +80,16 @@
|
|
|
61
80
|
.seg2{display:flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;height:28px;margin-top:8px}
|
|
62
81
|
.seg2 button{flex:1;border:0;border-radius:0;background:transparent;color:var(--mut)}
|
|
63
82
|
.seg2 button.on{background:var(--brand);color:#fff}
|
|
64
|
-
.
|
|
83
|
+
/* .segico = a segmented control whose buttons stack a small canonical glyph over their label (Dimension
|
|
84
|
+
style). The glyph is drawn in currentColor so it tracks the button's own muted/selected state — no new
|
|
85
|
+
hue — and the LABEL STAYS, so the accessible name and "Dot vs Tick" remain unambiguous. */
|
|
86
|
+
.seg2.segico{height:auto}
|
|
87
|
+
.seg2.segico button{display:flex;flex-direction:column;align-items:center;gap:3px;padding:5px 2px;font-size:11px;line-height:1.2}
|
|
88
|
+
.seg2.segico svg{display:block;overflow:visible}
|
|
89
|
+
.mtype-field .elab{margin-top:0}
|
|
90
|
+
.member-type-combo{height:30px;padding-right:28px;background:#0f172a linear-gradient(45deg,transparent 48%,var(--mut) 50%,transparent 52%) right 11px center/8px 8px no-repeat}
|
|
91
|
+
#comboPop.membertypes .opt{max-width:min(220px,calc(100vw - 24px));overflow:hidden;text-overflow:ellipsis}
|
|
92
|
+
#comboPop.membertypes .opt.add{border-top:1px solid var(--line);color:#bfdbfe}
|
|
65
93
|
.sect{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--mut);margin:0 0 4px}
|
|
66
94
|
.f{margin-top:8px} .unit{position:relative} .unit input{padding-right:34px}
|
|
67
95
|
.unit span{position:absolute;right:8px;top:50%;transform:translateY(-50%);color:var(--mut);font-size:11px;pointer-events:none}
|
|
@@ -93,6 +121,12 @@
|
|
|
93
121
|
circle.cobub.k-detailref,circle.cobub.k-elev{stroke-dasharray:3 3}
|
|
94
122
|
g.cohot:hover circle.cobub{opacity:1;stroke-width:2;filter:drop-shadow(0 0 4px currentColor)}
|
|
95
123
|
text.cotx{fill:#e2e8f0;font:bold 11px system-ui;text-anchor:middle;dominant-baseline:central;pointer-events:none;opacity:.6}
|
|
124
|
+
/* Vectorized PDF overlay — crisp, snappable drawing linework rendered from the filter vectors, NOT a
|
|
125
|
+
blurry raster (only vector PDFs; scanned sheets still fall back to the raster image). */
|
|
126
|
+
rect.pdfsheet{fill:#f8fafc}
|
|
127
|
+
g.pdfvec{pointer-events:none}
|
|
128
|
+
g.pdfvec path{fill:none;stroke:#334155;stroke-width:.7;vector-effect:non-scaling-stroke;opacity:.82;stroke-linecap:round;stroke-linejoin:round}
|
|
129
|
+
g.pdfvec circle{fill:none;stroke:#334155;stroke-width:.7;vector-effect:non-scaling-stroke;opacity:.55}
|
|
96
130
|
g.cohot:hover text.cotx{opacity:1}
|
|
97
131
|
#detailsModal,#framesModal,#rfiModal,#confModal,#askAiModal,#connModal,#connImportModal,#favConnModal{position:fixed;inset:0;z-index:20;display:none;align-items:center;justify-content:center}
|
|
98
132
|
#askAiDrop:hover{border-color:var(--brand);color:var(--text)} #askAiDrop.has{border-style:solid;border-color:var(--brand)}
|
|
@@ -125,6 +159,7 @@
|
|
|
125
159
|
#moreMenu #m3dInsert.on{color:var(--brand)}
|
|
126
160
|
#moreMenu #m3dInsertMenu{left:auto;right:calc(100% + 4px);top:0}
|
|
127
161
|
body:not(.v3d) #moreMenu #insWrap{display:none} /* Insert detail places into the 3D scene — hide it in 2D (needs 2 ids to beat the .m3dwrap.ins-in-menu display:block) */
|
|
162
|
+
body.v3d #moreMenu #dimStyleB{display:none} /* …and the mirror: Dimension style edits the 2D dim overlay, so it has nothing to show in 3D (Grid lines… stays — a grid IS drawn in 3D) */
|
|
128
163
|
#moreMenu button.msnap,#moreMenu button.dtog{display:flex;align-items:center;gap:0} /* .dtog = the Display show/hide toggles, same slider switch as Snapping (.msnap) */
|
|
129
164
|
#moreMenu button.msnap.on,#moreMenu button.dtog.on{color:var(--text)} /* the switch carries the state — don't also brand the text (reads as an armed tool elsewhere in this menu) */
|
|
130
165
|
#moreMenu .mck,.cmmenu .mck,.m3dmenu .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} /* delicate CSS-only slider switch — shared by the ⋯ Snapping rows, the Move/Copy → Drag-to-move/copy toggle, and the Work-area toggles */
|
|
@@ -139,10 +174,11 @@
|
|
|
139
174
|
/* Quick-access snap bar — always-expanded row of glyph toggles, bottom-right of the canvas (both views); reuses the brand-fill "on" toolbar language */
|
|
140
175
|
#snapBar{position:absolute;right:12px;bottom:12px;z-index:8;display:flex;gap:2px;padding:3px;background:var(--panel);border:1px solid var(--line);border-radius:8px;box-shadow:0 4px 14px rgba(0,0,0,.45)}
|
|
141
176
|
#snapBar.s3d{right:104px} /* in 3D, sit just LEFT of the bottom-right world-axis triad (#m3dAxes, right 15 + 78 wide) — same bottom edge, side by side (the ViewCube is top-right) */
|
|
142
|
-
#snapBar button{width:
|
|
177
|
+
#snapBar button{width:28px;height:28px;display:grid;place-items:center;border:0;border-radius:5px;background:transparent;color:#22d3ee;opacity:.55;font-size:15px;line-height:1;cursor:pointer;padding:0;transition:background-color .12s,opacity .12s,color .12s}
|
|
143
178
|
#snapBar button:hover{background:rgba(148,163,184,.12);opacity:.9}
|
|
144
179
|
#snapBar button.on{background:var(--brand);color:#0f172a;opacity:1}
|
|
145
180
|
#snapBar button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
|
|
181
|
+
body.v3d #snapBar [data-snap=perp],body.v3d #snapBar [data-snap=par],body.v3d #snapSect [data-snap=perp],body.v3d #snapSect [data-snap=par]{display:none} /* ⟂/∥ are 2D-only for now (no 3D snap candidates) — hide in 3D, mirroring the insWrap 2D/3D-scoped idiom */
|
|
146
182
|
#moreMenu .mhint{color:var(--mut);font-size:11px;line-height:1.4;padding:4px 12px 6px;max-width:230px;white-space:normal}
|
|
147
183
|
#rfiStat{cursor:pointer;text-decoration:underline dotted} #rfiStat:hover b{color:#fff}
|
|
148
184
|
#confStat{cursor:pointer;text-decoration:underline dotted} #confStat:hover b{filter:brightness(1.25)}
|
|
@@ -252,13 +288,26 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
252
288
|
line.extguide{stroke:#22d3ee;stroke-width:1.5;stroke-dasharray:6 5;opacity:.55;vector-effect:non-scaling-stroke;pointer-events:none} /* extension guide ray — faintest line on screen (a hint, not committed geometry) */
|
|
253
289
|
/* while a snap marker is up, the marker IS the cursor (Tekla) — hide the native crosshair over the canvas so it doesn't double up on it. !important beats the per-tool crosshair rules below; scoped to #svg so panels keep their cursor. */
|
|
254
290
|
body.snapping #svg,body.snapping #svg *{cursor:none!important}
|
|
255
|
-
line.dim{stroke:#22d3ee;stroke-width:
|
|
291
|
+
line.dim{stroke:#22d3ee;stroke-width:1.5;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}
|
|
256
292
|
line.dimwit{stroke:#22d3ee;stroke-width:1;opacity:.85;vector-effect:non-scaling-stroke;pointer-events:none}
|
|
257
|
-
circle.dimend{fill:#22d3ee;pointer-events:none}
|
|
293
|
+
circle.dimend{fill:#22d3ee;pointer-events:none} /* end style: dot */
|
|
294
|
+
line.dimend{stroke:#22d3ee;stroke-width:1.5;vector-effect:non-scaling-stroke;pointer-events:none} /* end style: oblique tick */
|
|
295
|
+
path.dimend{fill:#22d3ee;pointer-events:none} /* end style: arrow */
|
|
258
296
|
rect.dimchip{fill:#111827;stroke:#22d3ee;stroke-width:1;vector-effect:non-scaling-stroke;cursor:pointer}
|
|
297
|
+
rect.dimhit{fill:transparent;cursor:pointer} /* label hit target when the chip background is off — the bare text stays click/drag-able */
|
|
259
298
|
text.dimtx{fill:#e2e8f0;font-weight:600;font-family:system-ui;text-anchor:middle;dominant-baseline:central;pointer-events:none}
|
|
260
|
-
|
|
299
|
+
text.dimtx.dimhalo{paint-order:stroke;stroke:#0b1220;stroke-linejoin:round} /* background off → a halo keeps bare text legible over the drawing raster. stroke-width is set per-dim in 1/dz (dimSvg) — a fixed width is in USER units and would swell into a solid pill as you zoom in */
|
|
300
|
+
line.dim.dimsel{stroke:#f59e0b;stroke-width:2} line.dimwit.dimsel{stroke:#f59e0b;opacity:1} rect.dimchip.dimsel{stroke:#f59e0b}
|
|
301
|
+
circle.dimend.dimsel,path.dimend.dimsel{fill:#f59e0b} line.dimend.dimsel{stroke:#f59e0b}
|
|
261
302
|
circle.dimhandle{fill:#22d3ee;stroke:#0b1220;stroke-width:2;cursor:grab}
|
|
303
|
+
/* The Dimension style pane's live preview of the CURRENT combination — the only place Ends × Label ×
|
|
304
|
+
Background interact (the on-line gap appears only with the background off). It renders through the real
|
|
305
|
+
dimSvg, so it inherits the canvas classes above, whose lines/chips are clickable. Neutralise them:
|
|
306
|
+
`div.dimpv` (0,1,2) outranks `line.dim` (0,1,1), and this block sits AFTER them so source order agrees
|
|
307
|
+
too — `.dimpv svg *` alone merely TIED with line.dim and lost, leaving a pointer cursor on the swatch. */
|
|
308
|
+
.dimpv{background:#0b1220;border:1px solid var(--line);border-radius:6px;margin-top:8px;padding:1px}
|
|
309
|
+
.dimpv svg{display:block;width:100%;height:auto;pointer-events:none}
|
|
310
|
+
div.dimpv svg *{pointer-events:none;cursor:default}
|
|
262
311
|
/* property-label chips (right-click → Properties popup): dark chip + brand-blue accent, distinct from the cyan dimension chips.
|
|
263
312
|
pointer-events:none on the whole group — labels are passive annotations; clicks/marquee/drag pass through to the members underneath. */
|
|
264
313
|
g.pllabels{pointer-events:none}
|
|
@@ -267,8 +316,9 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
267
316
|
/* structural grid layer (under the members): dash-dot slate lines + label bubbles at both ends */
|
|
268
317
|
line.gridln{stroke:#64748b;stroke-width:1.3;stroke-dasharray:12 4 2 4;vector-effect:non-scaling-stroke;pointer-events:none;opacity:.85}
|
|
269
318
|
line.gridhit{stroke:transparent;stroke-width:9;vector-effect:non-scaling-stroke;pointer-events:stroke}
|
|
270
|
-
line.gridhit.gv{cursor:ew-resize} line.gridhit.gh{cursor:ns-resize}
|
|
319
|
+
line.gridhit.gv{cursor:ew-resize} line.gridhit.gh{cursor:ns-resize} line.gridhit.gl{cursor:move}
|
|
271
320
|
line.gridln.gdrag{stroke:var(--brand);opacity:1}
|
|
321
|
+
line.gridprev{stroke:var(--brand);stroke-width:1.2;stroke-dasharray:8 5;vector-effect:non-scaling-stroke;pointer-events:none;opacity:.9}
|
|
272
322
|
circle.gridbub{fill:#0f172a;stroke:#64748b;stroke-width:1.5;vector-effect:non-scaling-stroke;cursor:grab;filter:drop-shadow(0 1px 2px rgba(0,0,0,.45))}
|
|
273
323
|
text.gridtx{fill:#e2e8f0;font-weight:700;font-family:system-ui;text-anchor:middle;dominant-baseline:central;pointer-events:none}
|
|
274
324
|
g.gridbubg:hover circle.gridbub{stroke:var(--brand);fill:#1e293b}
|
|
@@ -280,9 +330,9 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
280
330
|
.gbtns{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px} .gbtns button{margin:0}
|
|
281
331
|
.gck{display:flex;align-items:center;gap:8px;color:var(--text);cursor:pointer;font-size:12px;padding:2px 0}
|
|
282
332
|
.gck input{accent-color:var(--brand);cursor:pointer;margin:0;width:14px;height:14px;flex:none} /* beat the panel's generic full-width input rule */
|
|
283
|
-
body.dimsplit line.member,body.dimsplit line.seg,body.dimsplit line.dim,body.dimsplit line.dimwit,body.dimsplit image{cursor:crosshair}
|
|
333
|
+
body.dimsplit #svg,body.dimsplit line.member,body.dimsplit line.seg,body.dimsplit line.dim,body.dimsplit line.dimwit,body.dimsplit image{cursor:crosshair} /* whole-canvas crosshair while the split/extend tool is armed — you can click anywhere, not just on a line (B8) */
|
|
284
334
|
.dimprev{opacity:.85} line.dim.dimprev{stroke-dasharray:7 4}
|
|
285
|
-
body.dimon line.member,body.dimon line.seg,body.dimon image{cursor:crosshair}
|
|
335
|
+
body.dimon #svg,body.dimon line.member,body.dimon line.seg,body.dimon image,body.add #svg,body.add line.member,body.add line.seg,body.add image,body.add polygon.member,body.add rect.pdfsheet{cursor:crosshair} /* Add-member is click-to-place like the Dimension tool → the whole canvas shows the crosshair */
|
|
286
336
|
body.csaxison #svg,body.csaxison line.member,body.csaxison line.seg,body.csaxison image{cursor:crosshair}
|
|
287
337
|
g.csglyph text{user-select:none}
|
|
288
338
|
body.geo line.seg{opacity:.45;cursor:crosshair} body.geo line.member{cursor:crosshair}
|
|
@@ -591,7 +641,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
591
641
|
<button id=undoB data-tip="Undo (Ctrl+Z)">↶</button>
|
|
592
642
|
<button id=redoB data-tip="Redo (Ctrl+Y / Ctrl+Shift+Z)">↷</button>
|
|
593
643
|
<span class=tb-sep></span>
|
|
594
|
-
<button id=mAdd data-tip="
|
|
644
|
+
<button id=mAdd data-tip="Add member (A) — click a start point then an end. Shift=ortho, Alt=no snap, right-click=restrict snap to one type">Add member</button>
|
|
595
645
|
<button id=dimB data-tip="Dimension tool (D) — click two snapped points, then a third to place. Default Free (aligned); hold Shift to lock to an axis, X/Y force horizontal/vertical, F free. Right-click the canvas to restrict snapping to one type.">⊢ Dimension</button>
|
|
596
646
|
<!-- 3D Dimension cluster — relocated here from the 3D toolbar so Dimension has ONE home; shown only in 3D (applyViewState). Same ids so steel-3d-view.js reflectDimBar() still drives it. -->
|
|
597
647
|
<span id=dim3dWrap style="display:none;align-items:center;gap:8px">
|
|
@@ -622,10 +672,12 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
622
672
|
<!-- Every section is a collapse/expand accordion (same as Snapping); state persists in localStorage (wireMoreSections). -->
|
|
623
673
|
<button id=snapHdr class="msnap-hdr msec-hdr" data-sec=snap aria-expanded=false aria-controls=snapSect data-tip="Running snaps — click to expand and turn each on/off (also on the snap bar, bottom-right)">Snapping<span class=chev aria-hidden=true>▸</span></button>
|
|
624
674
|
<div id=snapSect class="msnap-sect msec-body">
|
|
625
|
-
<button class="msnap on" data-snap=end role=menuitemcheckbox aria-checked=true data-tip="Snap to member/segment endpoints"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true
|
|
675
|
+
<button class="msnap on" data-snap=end role=menuitemcheckbox aria-checked=true data-tip="Snap to member/segment endpoints"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>◻</span>Endpoint</button>
|
|
626
676
|
<button class="msnap on" data-snap=int role=menuitemcheckbox aria-checked=true data-tip="Snap to where two members/segments cross"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>✕</span>Intersection</button>
|
|
627
677
|
<button class="msnap on" data-snap=mid role=menuitemcheckbox aria-checked=true data-tip="Snap to the midpoint of a member/segment"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>△</span>Midpoint</button>
|
|
628
678
|
<button class="msnap on" data-snap=line role=menuitemcheckbox aria-checked=true data-tip="Snap to the nearest point on any member/segment line"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>⧗</span>Nearest</button>
|
|
679
|
+
<button class="msnap" data-snap=perp role=menuitemcheckbox aria-checked=false data-tip="Perpendicular — from your first point, snap the second square (90°) to a target line (member, grid, or drawing linework). With Extension on, the foot may land on the line’s extension."><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>⟂</span>Perpendicular</button>
|
|
680
|
+
<button class="msnap" data-snap=par role=menuitemcheckbox aria-checked=false data-tip="Parallel — when you draw roughly parallel to a nearby line, snap the direction to exactly parallel."><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>∥</span>Parallel</button>
|
|
629
681
|
<button class="msnap" data-snap=ext role=menuitemcheckbox aria-checked=false data-tip="Snap along the invisible extension of a member/line past its endpoint, with a dashed guide line"><span class=mck aria-hidden=true></span><span class=sg aria-hidden=true>┈</span>Extension</button>
|
|
630
682
|
<div class=mhint>Right-click the canvas any time to force one snap type for a single pick.</div>
|
|
631
683
|
</div>
|
|
@@ -635,7 +687,9 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
635
687
|
<button id=calloutToggleB class=dtog role=menuitemcheckbox aria-checked=true data-tip="Show or hide the clickable callout bubbles (section / elevation / detail references) on the plan"><span class=mck aria-hidden=true></span>Callouts</button>
|
|
636
688
|
<button id=gridToggleB class=dtog role=menuitemcheckbox aria-checked=false data-tip="Show or hide the grid lines in 2D and 3D"><span class=mck aria-hidden=true></span>Grid lines</button>
|
|
637
689
|
<button id=lenToggleB class=dtog role=menuitemcheckbox aria-checked=false data-tip="Show each selected member's length on the canvas"><span class=mck aria-hidden=true></span>Member length</button>
|
|
690
|
+
<button id=plToggleB class=dtog role=menuitemcheckbox aria-checked=true data-tip="Show or hide property labels in the 2D plan (the property selection is shared with 3D — this hides them here only)"><span class=mck aria-hidden=true></span>Property labels</button>
|
|
638
691
|
<button id=gridEditB data-tip="Grid lines — a plan reference with structural bay spacings (n*d repeats a bay). Shows in 2D and 3D; drawing and drags snap to its lines and intersections.">Grid lines…</button>
|
|
692
|
+
<button id=dimStyleB data-tip="Dimension style — end marks, label position and label background. Sets the defaults every dimension follows unless you give it its own style.">Dimension style…</button>
|
|
639
693
|
</div>
|
|
640
694
|
<button class=msec-hdr data-sec=detailing aria-expanded=false data-tip="Connection details, plates, frames, and inserted detail images">Detailing<span class=chev aria-hidden=true>▸</span></button>
|
|
641
695
|
<div class=msec-body>
|
|
@@ -703,10 +757,11 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
703
757
|
<!-- Display toggles: reference lines + mark labels (grouped into a menu, like Plane / Work area).
|
|
704
758
|
The Dimension tool moved to the header so it lives in one place across 2D and 3D. -->
|
|
705
759
|
<div class=m3dwrap>
|
|
706
|
-
<button id=m3dView data-tip="Show or hide reference lines and
|
|
760
|
+
<button id=m3dView data-tip="Show or hide reference lines, mark labels, and property labels on the 3D model">View ▾</button>
|
|
707
761
|
<div id=m3dViewMenu class=m3dmenu role=menu>
|
|
708
762
|
<label data-tip="Show each member's reference line (centreline)"><input type=checkbox id=m3dRef> Ref line</label>
|
|
709
|
-
<label data-tip="Show each member's mark / id label in the 3D view"><input type=checkbox id=m3dLabels>
|
|
763
|
+
<label data-tip="Show each member's mark / id label in the 3D view"><input type=checkbox id=m3dLabels> Mark labels</label>
|
|
764
|
+
<label data-tip="Show or hide property labels in the 3D view (the property selection is shared with 2D — this hides them here only)"><input type=checkbox id=m3dPropLabels checked> Property labels</label>
|
|
710
765
|
</div>
|
|
711
766
|
</div>
|
|
712
767
|
<span class=tb-sep></span>
|
|
@@ -737,7 +792,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
737
792
|
</div>
|
|
738
793
|
</div>
|
|
739
794
|
<div class=m3dwrap>
|
|
740
|
-
<button id=m3dWork data-tip="Working area — bound the view to a box
|
|
795
|
+
<button id=m3dWork data-tip="Working area — bound the view to a box">Work area ▾</button>
|
|
741
796
|
<div id=m3dWorkMenu class=m3dmenu role=menu>
|
|
742
797
|
<button data-wa=all data-tip="Bound the work area to the whole model">Set to all objects</button>
|
|
743
798
|
<button data-wa=sel data-tip="Bound the work area to the current selection">Define from selection</button>
|
|
@@ -766,12 +821,15 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
766
821
|
<span id=zPct>100%</span>
|
|
767
822
|
<button id=zFit data-tip="Zoom to fit (Home)">Fit</button>
|
|
768
823
|
</div>
|
|
769
|
-
<!-- Quick-access snap toggles (same persistent state as the ⋯ menu → Snapping section; keep the two in sync — same
|
|
824
|
+
<!-- Quick-access snap toggles (same persistent state as the ⋯ menu → Snapping section; keep the two in sync — same 7 items).
|
|
825
|
+
Glyphs mirror SNAP_KINDS_2D — see the endpoint-glyph constraint there before "correcting" ◻ to □. -->
|
|
770
826
|
<div id=snapBar role=group aria-label="Snap settings">
|
|
771
|
-
<button data-snap=end data-tip="Endpoint snap"
|
|
827
|
+
<button data-snap=end data-tip="Endpoint snap">◻</button>
|
|
772
828
|
<button data-snap=int data-tip="Intersection snap">✕</button>
|
|
773
829
|
<button data-snap=mid data-tip="Midpoint snap">△</button>
|
|
774
830
|
<button data-snap=line data-tip="Nearest snap">⧗</button>
|
|
831
|
+
<button data-snap=perp data-tip="Perpendicular snap — square (90°) to a target line from your first point">⟂</button>
|
|
832
|
+
<button data-snap=par data-tip="Parallel snap — run parallel to a nearby line">∥</button>
|
|
775
833
|
<button data-snap=ext data-tip="Extension snap">┈</button>
|
|
776
834
|
</div>
|
|
777
835
|
</div>
|
|
@@ -900,7 +958,7 @@ async function boot() {
|
|
|
900
958
|
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS);
|
|
901
959
|
if (!res.ok) {
|
|
902
960
|
if (res.status === 404) {
|
|
903
|
-
showEmpty('⊞', 'No
|
|
961
|
+
showEmpty('⊞', 'No model for', 'Read a structural drawing first — ask your terminal AI to run the workflow, then open this editor again.', APP_ID);
|
|
904
962
|
} else {
|
|
905
963
|
showEmpty('⚠', 'Couldn’t load the contract', 'The server returned an error. Check that the FloLess server is running, then reopen the editor.');
|
|
906
964
|
}
|
|
@@ -918,14 +976,16 @@ async function boot() {
|
|
|
918
976
|
}
|
|
919
977
|
} catch (_) { /* no target goal shown */ }
|
|
920
978
|
PAL = (Array.isArray(C.palette) && C.palette.length) ? C.palette : DEFAULT_PAL; WT = C.weights || {};
|
|
921
|
-
try { const _sr = await fetch('/api/aisc-shapes'); if (_sr.ok) { const _sj = await _sr.json(); if (Array.isArray(_sj.shapes)) window.__AISC_SHAPES = new Set(_sj.shapes); } } catch (_) { /* no shape table → _nominalPlf falls back to regex-only */ }
|
|
979
|
+
try { const _sr = await fetch('/api/aisc-shapes'); if (_sr.ok) { const _sj = await _sr.json(); if (Array.isArray(_sj.shapes)) window.__AISC_SHAPES = new Set(_sj.shapes); if (_sj.bf && typeof _sj.bf === 'object') window.__AISC_BF = _sj.bf; } } catch (_) { /* no shape table → _nominalPlf falls back to regex-only; columns fall back to the marker footprint */ }
|
|
922
980
|
// No weight seeding needed: every RFI/weight read resolves through _wt(), which falls back to the
|
|
923
981
|
// SHAPES-guarded _nominalPlf for a valid AISC designation absent from the contract's weights map.
|
|
924
982
|
C.custom_details = C.custom_details || {};
|
|
925
983
|
C.profile_colors = C.profile_colors || {};
|
|
984
|
+
if(!Array.isArray(C.member_types))C.member_types=[];
|
|
926
985
|
if(!Array.isArray(C.dims3d))C.dims3d=[]; // model-global draft-only 3D dimensions
|
|
927
986
|
if(!Array.isArray(C.detail_placements))C.detail_placements=[]; // model-global draft-only placed detail images (Slice 4)
|
|
928
987
|
if(!C.dim_overlays||typeof C.dim_overlays!=='object'||Array.isArray(C.dim_overlays))C.dim_overlays={bolt_pitch:true,edge_clearance:true,cope_size:true,base_plate:true,anchor_depth:true}; // model-global legend DIMENSIONS toggles — all on by default
|
|
988
|
+
if(!C.dim_style||typeof C.dim_style!=='object'||Array.isArray(C.dim_style))C.dim_style={}; // model-global dimension-style defaults; the full sanitizeDimStyle() runs inside main() where DIM_ENDS/DIM_DEF live (mirrors prop_labels/views)
|
|
929
989
|
if(!Array.isArray(C.views))C.views=[]; // model-global saved views (Views Organizer): ensure an array in boot()'s OUTER scope (like dims3d/detail_placements above); the full sanitizeViews() runs inside main() where that helper lives (mirrors prop_labels)
|
|
930
990
|
main(); // (C.prop_labels is normalised inside main(), right after the PROP_DEFS/sanitizePropLabels registry is defined — see ~"normalise the contract's incoming value" — since that helper isn't in scope out here in boot())
|
|
931
991
|
// SSE: listen for external contract writebacks (e.g. the terminal AI PUT a revision).
|
|
@@ -946,8 +1006,13 @@ async function boot() {
|
|
|
946
1006
|
// localStorage draft is now STALE and would mask the server's version on reload
|
|
947
1007
|
// (restoreSaved() overlays it). Drop it so any reload shows the AI's contract.
|
|
948
1008
|
try { localStorage.removeItem('steeltakeoff:edits:v1:' + APP_ID); } catch (_) { /* ignore */ }
|
|
949
|
-
//
|
|
950
|
-
|
|
1009
|
+
// Auto-reload straight into the AI's version so the user never has to hit refresh — EXCEPT
|
|
1010
|
+
// when they have unsaved in-browser edits (saveStat 'dirty'/'err'), where a silent reload
|
|
1011
|
+
// would discard their work; there we fall back to the choose-to-reload banner.
|
|
1012
|
+
const sv = document.getElementById('saveStat');
|
|
1013
|
+
const hasUnsaved = !!sv && (sv.classList.contains('dirty') || sv.classList.contains('err'));
|
|
1014
|
+
if (hasUnsaved) showAiUpdateBanner('The AI updated this model — reload to see it (you have unsaved edits).');
|
|
1015
|
+
else location.reload();
|
|
951
1016
|
};
|
|
952
1017
|
es.onerror = () => {
|
|
953
1018
|
// Transient drops (readyState CONNECTING) auto-reconnect — ignore. A CLOSED channel is
|
|
@@ -982,7 +1047,7 @@ function showAiUpdateBanner(message) {
|
|
|
982
1047
|
|
|
983
1048
|
const msg = document.createElement('span');
|
|
984
1049
|
msg.style.cssText = 'flex:1';
|
|
985
|
-
msg.textContent = message || 'The AI updated this
|
|
1050
|
+
msg.textContent = message || 'The AI updated this model — reload to see the latest version.';
|
|
986
1051
|
|
|
987
1052
|
const reloadBtn = document.createElement('button');
|
|
988
1053
|
reloadBtn.style.cssText = 'background:#3b82f6;color:#fff;border:1px solid #60a5fa;border-radius:6px;padding:5px 12px;cursor:pointer;font:13px system-ui';
|
|
@@ -1005,9 +1070,11 @@ function main() {
|
|
|
1005
1070
|
let P, X0,Y0,X1,Y1, FT, RB64, EXTX, EXTY, profs; // per-plan, set by setPlan()
|
|
1006
1071
|
let mode='sel', drag=null, picking=false, pickKind='profile', pickEnd=null, geoMode=null;
|
|
1007
1072
|
let dimMode=false, dimDraft=null, dimAxis='free', selDimIds=new Set(), dimsVisible=true; // Dimension tool: armed flag, in-progress {a,b,axis}, sticky axis, selected dim ids (multi-select), show/hide
|
|
1073
|
+
let drawDraft=null; // Add-member tool: the first CLICKED start point (or null) — click-to-start / click-to-finish, mirroring the Dimension tool (no more press-drag)
|
|
1008
1074
|
let calloutsVisible=true; // Workstream B: show/hide the clickable callout bubbles (details + section/elevation/detail-ref) on the plan in select mode
|
|
1009
1075
|
let showSelLen=(()=>{try{return localStorage.getItem('steel:selLen:v1')==='1';}catch(_){return false;}})(); // ⋯ Display → Show member length: paint each selected member's length on the canvas (opt-in, default off)
|
|
1010
|
-
let gridMode=false, gridPick=false; // Grid lines: panel-takeover editing mode + armed pick-origin
|
|
1076
|
+
let gridMode=false, gridPick=false, gridLinePick=null; // Grid lines: panel-takeover editing mode + armed pick-origin / single-line clicks
|
|
1077
|
+
let dimStyleMode=false; // Dimension style: panel-takeover pane for the model-global defaults (⋯ → Display → Dimension style…)
|
|
1011
1078
|
let csaxisMode=false, csDraft=null; // Local coordinate system "set axes" tool: armed flag + in-progress origin [x,y] (null until click 1). P.frame={o,u} holds the committed local frame (null = global).
|
|
1012
1079
|
let dimChain=false, dimChainPrev=null, dimSeq=0; // chained "continuous" dimensioning: toggle, the running {point,axis,off,rot}, and a counter for unique ids on rapid clicks
|
|
1013
1080
|
let dimSplitMode=false; // "add split point" mode on a selected dim — each click inserts a point and splits the dim segment under it into two
|
|
@@ -1015,8 +1082,18 @@ let sel3dDimIds=new Set(),dim3dAnchor=null; // selected 3D dimension ids (mult
|
|
|
1015
1082
|
let selIds=new Set();
|
|
1016
1083
|
let findHits=new Set(); // Find-in-model highlight (Workspaces Ctrl+F) — kept SEPARATE from selIds so a search never clobbers/drops the user's real selection
|
|
1017
1084
|
let undo=[], redo=[];
|
|
1018
|
-
|
|
1019
|
-
|
|
1085
|
+
// Selection is MODEL-WIDE, not per-sheet: the 3D shows every plan, so a pick / box-select / Ctrl-click can
|
|
1086
|
+
// span sheets. byId + selArr therefore search ALL plans (not just the active P) so the inspector + edits see
|
|
1087
|
+
// the whole selection — else selecting a roof (S-203) member while S-202 is active shows nothing, and a
|
|
1088
|
+
// cross-floor Ctrl-click or box-select drops the off-sheet members. (Earlier this SWITCHED the active plan
|
|
1089
|
+
// per pick, which cleared the accumulating selection — the bug this replaces.)
|
|
1090
|
+
const allMembers=()=>C.plans.flatMap(p=>p.members||[]);
|
|
1091
|
+
const byId=id=>{for(const p of C.plans){const m=(p.members||[]).find(x=>x.id===id);if(m)return m;}return undefined;};
|
|
1092
|
+
const planeOf=id=>{for(const p of C.plans)if((p.members||[]).some(m=>m.id===id))return p;return P;}; // the plane that owns a member id (for cross-sheet move/copy targeting); falls back to the active plane
|
|
1093
|
+
const selArr=()=>allMembers().filter(m=>selIds.has(m.id));
|
|
1094
|
+
// The active-sheet subset of the selection — for 2D coordinate/decoration ops (handles, badges, move/copy,
|
|
1095
|
+
// 2D drag/zoom) that draw or compute in THIS sheet's px space, where an off-sheet member's wp is meaningless.
|
|
1096
|
+
const sel2d=()=>P.members.filter(m=>selIds.has(m.id));
|
|
1020
1097
|
const numOrNull=v=>{const n=parseFloat(v);return (v===''||v==null||isNaN(n))?null:n;};
|
|
1021
1098
|
// elevation = canonical decimal INCHES. parseLen accepts 5.75 | 5 3/4 | 1'-0 1/4" | 16'-6"
|
|
1022
1099
|
function parseLen(str){if(str==null)return null;
|
|
@@ -1039,10 +1116,15 @@ function ensureMeta(m){if(!m.role)m.role='beam';
|
|
|
1039
1116
|
if(!m.col)m.col={bos:null,tos:null,note:(/(^|[^A-Z])MF/i.test(m.profile||'')?'moment':''),tosDef:true,detail:''};return m;}
|
|
1040
1117
|
// Effective profile position on the reference line (the work-line between the end dots), à la Tekla.
|
|
1041
1118
|
// Explicit m.position wins; else a flat beam → top (top-of-steel), a steep beam (brace) / column → middle.
|
|
1042
|
-
//
|
|
1119
|
+
// A VERTICAL brace is always centred: its work-points sit on the column ℄, and the slope heuristic alone
|
|
1120
|
+
// mis-reads a shallow one (wide bay, short storey) as "roughly flat" and hangs it from its section top.
|
|
1121
|
+
// A LATERAL brace is a flat kicker and keeps the beam default.
|
|
1122
|
+
// MIRROR of server/contract-to-scene.ts depthPosition (same 0.5774 ≈ 30° threshold, mm units) — the
|
|
1123
|
+
// inspector must highlight the SAME default the bake uses, or the 3D differs from what the panel says.
|
|
1043
1124
|
function posDefault(m){
|
|
1044
1125
|
if(m.position==='top'||m.position==='middle'||m.position==='bottom')return m.position;
|
|
1045
1126
|
if(m.role==='column')return 'middle';
|
|
1127
|
+
if(isBrace(m)&&m.brace&&m.brace.type==='vertical')return 'middle';
|
|
1046
1128
|
const k=304.8/((P&&P.pt_per_ft>0)?P.pt_per_ft:1);
|
|
1047
1129
|
const z0=(m.ends&&m.ends[0]&&m.ends[0].tos!=null)?m.ends[0].tos:defaultTOS;
|
|
1048
1130
|
const z1=(m.ends&&m.ends[1]&&m.ends[1].tos!=null)?m.ends[1].tos:defaultTOS;
|
|
@@ -1052,10 +1134,137 @@ function posDefault(m){
|
|
|
1052
1134
|
// Beam: reverse wp + the per-end metadata (each end's TOS/note/detail follows its point). Column:
|
|
1053
1135
|
// the two handles are bottom (BOS) and top (TOS), so swap those. Used by 2D + 3D via the same panel.
|
|
1054
1136
|
function swapMemberEnds(m){
|
|
1137
|
+
// Brace: resolve the CURRENT lower end BEFORE the swap. When TOS differs the derivation follows the
|
|
1138
|
+
// swapped ends automatically; when TOS is tied (or an override exists) materialize the override so the
|
|
1139
|
+
// double arrow stays on the same PHYSICAL end (Codex round-3). Compute before wp/ends move below.
|
|
1140
|
+
let braceOld=null;
|
|
1141
|
+
if(isBrace(m)){normBrace(m); // a brace reached here without m.brace (reader payload / direct call) would NPE below
|
|
1142
|
+
const t0=effEndTos(m.ends&&m.ends[0]),t1=effEndTos(m.ends&&m.ends[1]);braceOld={old:braceLowerEnd(m),tie:(t0===t1)};}
|
|
1055
1143
|
if(Array.isArray(m.wp)&&m.wp.length>=2)m.wp=[m.wp[1].slice(),m.wp[0].slice()];
|
|
1056
1144
|
if(Array.isArray(m.ends)&&m.ends.length>=2)m.ends=[m.ends[1],m.ends[0]];
|
|
1057
1145
|
if(m.col){const b=(m.col.bos!=null?m.col.bos:0),t=(m.col.tos!=null?m.col.tos:defaultTOS);m.col.bos=t;m.col.tos=b;m.col.tosDef=false;}
|
|
1146
|
+
if(braceOld){
|
|
1147
|
+
if(braceOld.tie||(m.brace.lowerEnd===0||m.brace.lowerEnd===1))m.brace.lowerEnd=(1-braceOld.old);
|
|
1148
|
+
// braceDisplayLine takes its perpendicular from the a→b direction, so reversing wp flips which SIDE the
|
|
1149
|
+
// symbol is drawn on. Negate the offset to keep the drawn line exactly where it was (ui-ux review).
|
|
1150
|
+
if(m.brace.offset)m.brace.offset=-m.brace.offset;
|
|
1151
|
+
}
|
|
1058
1152
|
return m;}
|
|
1153
|
+
// Bulk "Swap start ↔ end" (multi-select button + the P shortcut). Braces are EXCLUDED: reversing a brace is
|
|
1154
|
+
// the inspector's "Swap lower ↔ higher end" (arrow assignment, no geometry move). (ui-ux + Codex review: the
|
|
1155
|
+
// single-select panel hid this control for a brace, but the plural paths still reversed one — flipping the
|
|
1156
|
+
// offset side of any brace caught in a box-select.) Owns its own edit()/toast so an all-brace selection
|
|
1157
|
+
// records NO undo entry — edit() pushes unconditionally, and a phantom Ctrl+Z that does nothing is a lie.
|
|
1158
|
+
function swapSelectionEnds(){
|
|
1159
|
+
const arr=selArr(), braces=arr.filter(m=>isBrace(m)), rest=arr.filter(m=>!isBrace(m));
|
|
1160
|
+
if(rest.length)edit(()=>{for(const m of rest)swapMemberEnds(m);});
|
|
1161
|
+
if(braces.length)toast(braces.length+' brace'+(braces.length>1?'s':'')+' skipped — use “Swap lower ↔ higher end” in the brace inspector');
|
|
1162
|
+
return {swapped:rest.length,skipped:braces.length};}
|
|
1163
|
+
// ── Braces (B4) ─────────────────────────────────────────────────────────────────────────────────────
|
|
1164
|
+
// A brace is a member with memberType 'brace' (role 'beam') + m.brace={type,floor,offset,lowerEnd}.
|
|
1165
|
+
// brace.floor + brace.offset are 2D-DISPLAY-ONLY — they must NEVER reach contract-to-scene/IFC/Tekla.
|
|
1166
|
+
function isBrace(m){return !!m&&memberTypeOf(m)==='brace';}
|
|
1167
|
+
// Canonical effective end-TOS. Follows the SCENE's null-fallback precedence (`tos != null ? tos : default`,
|
|
1168
|
+
// contract-to-scene), NOT the tosDef rule — the arrows must agree with the 3D slope, which the bake derives
|
|
1169
|
+
// from ends[].tos. It ADDS a Number.isFinite guard the scene lacks, so a NaN/garbage tos falls back to the
|
|
1170
|
+
// datum instead of poisoning braceLowerEnd's `<` comparison. Do NOT "simplify" it to the scene's bare rule.
|
|
1171
|
+
// The `!=null` half is equally load-bearing: a default-follow end carries tos:null, and `+null === 0`, so a
|
|
1172
|
+
// bare Number.isFinite(+o.tos) would read that end as elevation ZERO and put the double arrowhead on the
|
|
1173
|
+
// wrong end whenever the other end is explicit (one end at a 120" callout, the other following a 348" level).
|
|
1174
|
+
function effEndTos(o){return (o&&o.tos!=null&&Number.isFinite(+o.tos))?+o.tos:defaultTOS;}
|
|
1175
|
+
// Which wp index is the LOWER end (gets the double arrow): stored override wins; else lower effective-TOS; tie ⇒ 0.
|
|
1176
|
+
function braceLowerEnd(m){const b=(m&&m.brace)||{};if(b.lowerEnd===0||b.lowerEnd===1)return b.lowerEnd;
|
|
1177
|
+
return (effEndTos(m.ends&&m.ends[1])<effEndTos(m.ends&&m.ends[0]))?1:0;}
|
|
1178
|
+
// Seed defaults when entering brace, strip a stale sub-object off non-braces, clamp values. Idempotent —
|
|
1179
|
+
// safe to call at load (all plans) AND after applyMemberType. Codex round-1/2: no stale/garbage m.brace.
|
|
1180
|
+
function normBrace(m){
|
|
1181
|
+
if(!isBrace(m)){if(m&&m.brace)delete m.brace;return m;}
|
|
1182
|
+
const b=(m.brace&&typeof m.brace==='object')?m.brace:{};
|
|
1183
|
+
const out={type:(b.type==='lateral')?'lateral':'vertical',
|
|
1184
|
+
floor:(b.floor==='below')?'below':'above',
|
|
1185
|
+
offset:Number.isFinite(+b.offset)?+b.offset:0};
|
|
1186
|
+
if(b.lowerEnd===0||b.lowerEnd===1)out.lowerEnd=b.lowerEnd;
|
|
1187
|
+
// SEEDING an absent field is normal (silent). CLAMPING a field that was PRESENT but invalid means the
|
|
1188
|
+
// reader/AI emitted a bad shape — correcting that into invisibility hides a real upstream bug, so say so.
|
|
1189
|
+
// Display-only fields, hence a console warning rather than a toast. (silent-failure review)
|
|
1190
|
+
const bad=['type','floor','offset','lowerEnd'].filter(k=>b[k]!==undefined&&b[k]!==out[k]);
|
|
1191
|
+
if(bad.length)console.warn('normBrace: member '+(m.id||'?')+' had invalid brace field(s) '+bad.join(', ')+' — clamped',{was:b,now:out});
|
|
1192
|
+
m.brace=out;return m;}
|
|
1193
|
+
// The DRAWN line for a brace — READ-ONLY (pick / marquee / zoom-fit / label anchors), NEVER a mutation.
|
|
1194
|
+
// Lateral & offset-0 = the true WPs; a vertical brace shifts perpendicular by brace.offset (inches→px).
|
|
1195
|
+
function braceDisplayLine(m){const a=m.wp[0],b=m.wp[1];
|
|
1196
|
+
if(!isBrace(m)||m.brace.type==='lateral'||!m.brace.offset)return [[a[0],a[1]],[b[0],b[1]]];
|
|
1197
|
+
const ppf=(P&&P.pt_per_ft>0)?P.pt_per_ft:1, offPx=(m.brace.offset/12)*ppf;
|
|
1198
|
+
const dx=b[0]-a[0],dy=b[1]-a[1],L=Math.hypot(dx,dy)||1,nx=-dy/L,ny=dx/L;
|
|
1199
|
+
return [[a[0]+nx*offPx,a[1]+ny*offPx],[b[0]+nx*offPx,b[1]+ny*offPx]];}
|
|
1200
|
+
// The line any VISUAL should anchor to: a brace's DRAWN (offset) line, every other member's work points.
|
|
1201
|
+
// Chips, badges and zoom-framing must follow what the user can see, or an offset brace gets labels floating
|
|
1202
|
+
// on an invisible baseline. READ-ONLY — never feed a mutation. It returns COPIES in both branches (the
|
|
1203
|
+
// non-brace branch used to hand back the live m.wp point arrays, so a careless caller could have written
|
|
1204
|
+
// straight through into the geometry). (Lengths shown stay TRUE 3D via _lenFt; a parallel offset preserves
|
|
1205
|
+
// plan length, so the PLABEL_MIN_PX thresholds agree either way.)
|
|
1206
|
+
function memberViewLine(m){return isBrace(m)?braceDisplayLine(m):[[m.wp[0][0],m.wp[0][1]],[m.wp[1][0],m.wp[1][1]]];}
|
|
1207
|
+
// SVG for a brace symbol: the (offset) display line — dashed for a below-floor vertical, solid else — with a
|
|
1208
|
+
// DOUBLE arrowhead at the lower end + a SINGLE at the higher. Every head's tip sits AT its end point and its
|
|
1209
|
+
// body points INWARD, so a head never overhangs the work point. Structure: an invisible line.bracehit
|
|
1210
|
+
// (class=member + data-id) is the SOLE hit target; the visible line.bracebody and the heads are both
|
|
1211
|
+
// pointer-events:none, so clicking an arrowhead still selects the brace.
|
|
1212
|
+
// Heads are sized in CONTENT units, i.e. RELATIVE TO THE VISIBLE BRACE STROKE (line.bracebody stroke-width:6,
|
|
1213
|
+
// itself a content unit that scales with zoom) — not in screen px. A screen-constant head is swallowed by its
|
|
1214
|
+
// own line once you zoom in (at 170% the stroke is already ~10px) and floats free of it when you zoom out.
|
|
1215
|
+
// Everything else on this canvas (stroke, RFI dash, dim witness) scales with zoom; the head matches.
|
|
1216
|
+
const BRACE_STROKE=6; // must track line.bracebody's stroke-width in the CSS above
|
|
1217
|
+
const BRACE_ARR=BRACE_STROKE*3; // head length — 3× the stroke reads as an arrow at every zoom
|
|
1218
|
+
// A below-floor brace is DASHED — but `dashed` already means RFI on this canvas (line.member.rfi is
|
|
1219
|
+
// "10 6", a uniform short dash, and the legend says "Dashed = RFI"). So the brace uses a PHANTOM line
|
|
1220
|
+
// (long–short–long–short) that can't be mistaken for RFI's even ticks at a glance. Content units, so it
|
|
1221
|
+
// scales with zoom like every other dash here. Colour stays the member's profile colour — braces remain
|
|
1222
|
+
// recolourable from the legend, so the dash (not a reserved hue) is what identifies them.
|
|
1223
|
+
// long 30 / short 6 — an authored 5:1. stroke-linecap:round visually ADDS ~one stroke (6) to every dash, so
|
|
1224
|
+
// on screen it reads ~36:12, i.e. the 3:1 we actually want. Authoring 3:1 would collapse toward uniform.
|
|
1225
|
+
// Deliberately NOT dash-dot: line.gridln already owns "12 4 2 4".
|
|
1226
|
+
const BRACE_DASH='30 8 6 8';
|
|
1227
|
+
function _braceHeadPts(tip,dir,AL){const AW=AL*0.45,bx=tip[0]-dir[0]*AL,by=tip[1]-dir[1]*AL,px=-dir[1],py=dir[0];
|
|
1228
|
+
return `${tip[0].toFixed(1)},${tip[1].toFixed(1)} ${(bx+px*AW).toFixed(1)},${(by+py*AW).toFixed(1)} ${(bx-px*AW).toFixed(1)},${(by-py*AW).toFixed(1)}`;}
|
|
1229
|
+
function braceArrowLen(m){const dl=braceDisplayLine(m);
|
|
1230
|
+
const L=Math.hypot(dl[1][0]-dl[0][0],dl[1][1]-dl[0][1])||1;
|
|
1231
|
+
return Math.min(BRACE_ARR, L*0.22);} // never let the heads swallow a short brace
|
|
1232
|
+
// The three head polygons, in render order: [higher(single), lower-outer, lower-inner]. The lower pair is
|
|
1233
|
+
// separated by a GAP so the two chevrons read as ◄◄ instead of merging into one long solid arrow.
|
|
1234
|
+
function braceHeadPoints(m){
|
|
1235
|
+
const dl=braceDisplayLine(m),a=dl[0],b=dl[1];
|
|
1236
|
+
const lo=braceLowerEnd(m); // wp index of the lower end (double arrow)
|
|
1237
|
+
const P0=(lo===0)?a:b, P1=(lo===0)?b:a; // P0 lower, P1 higher
|
|
1238
|
+
const dx=b[0]-a[0],dy=b[1]-a[1],L=Math.hypot(dx,dy)||1,ux=dx/L,uy=dy/L;
|
|
1239
|
+
const outLo=(lo===0)?[-ux,-uy]:[ux,uy], outHi=(lo===0)?[ux,uy]:[-ux,-uy]; // outward at each physical end
|
|
1240
|
+
const AL=braceArrowLen(m);
|
|
1241
|
+
const GAP=AL*0.5, step=AL+GAP;
|
|
1242
|
+
return [_braceHeadPts(P1,outHi,AL),
|
|
1243
|
+
_braceHeadPts(P0,outLo,AL),
|
|
1244
|
+
_braceHeadPts([P0[0]-outLo[0]*step,P0[1]-outLo[1]*step],outLo,AL)];
|
|
1245
|
+
}
|
|
1246
|
+
function braceSymbol(m,c,glow){
|
|
1247
|
+
const dl=braceDisplayLine(m),a=dl[0],b=dl[1];
|
|
1248
|
+
const dashed=(m.brace.type==='vertical'&&m.brace.floor==='below');
|
|
1249
|
+
const sel=selIds.has(m.id); // find-hit needs no class here: render() passes its glow through `glow` on the group
|
|
1250
|
+
const hitW=Math.max(braceArrowLen(m)*1.05, 8); // corridor spans the head wingspan (2·0.45·AL) → arrowheads are clickable
|
|
1251
|
+
let s=`<g class="bracesym${sel?' sel':''}" data-id="${m.id}"${glow}>`;
|
|
1252
|
+
// Witness lines back to the TRUE work points: an offset brace's end handles sit on the column ℄, away from
|
|
1253
|
+
// the drawn symbol, and would otherwise look orphaned. Same idiom as the dimension witness (ui-ux review).
|
|
1254
|
+
if(m.brace.offset&&m.brace.type!=='lateral')
|
|
1255
|
+
s+=`<line class=bracewit x1="${m.wp[0][0]}" y1="${m.wp[0][1]}" x2="${a[0]}" y2="${a[1]}"/>`
|
|
1256
|
+
+`<line class=bracewit x1="${m.wp[1][0]}" y1="${m.wp[1][1]}" x2="${b[0]}" y2="${b[1]}"/>`;
|
|
1257
|
+
// Invisible hit corridor UNDER the visible line (heads are pointer-events:none, so the arrowhead — the most
|
|
1258
|
+
// eye-catching part — would otherwise be a dead zone). Inline stroke-width beats line.member's CSS width;
|
|
1259
|
+
// it carries class=member + data-id so click/drag/geo behave exactly like any other member.
|
|
1260
|
+
s+=`<line class="member bracehit" data-id="${m.id}" x1="${a[0]}" y1="${a[1]}" x2="${b[0]}" y2="${b[1]}" style="stroke-width:${hitW.toFixed(1)}"/>`;
|
|
1261
|
+
// The visible body is decorative — the corridor above owns the pointer. Width/cap/selected-weight come from
|
|
1262
|
+
// CSS keyed on the GROUP's .sel (see line.bracebody), so a no-render selection cleanup can't strand it thick.
|
|
1263
|
+
// NOTE: no `rfi` class on purpose; line.member.rfi forces a "10 6" dash, which would make an ABOVE-floor RFI
|
|
1264
|
+
// brace look BELOW-floor. On a brace the line style means FLOOR only; an unresolved size shows as the RFI pill.
|
|
1265
|
+
s+=`<line class="bracebody" x1="${a[0]}" y1="${a[1]}" x2="${b[0]}" y2="${b[1]}" stroke="${c}"${dashed?` stroke-dasharray="${BRACE_DASH}"`:''}/>`;
|
|
1266
|
+
for(const pts of braceHeadPoints(m)) s+=`<polygon class=bracehead fill="${c}" points="${pts}"/>`;
|
|
1267
|
+
return s+`</g>`;}
|
|
1059
1268
|
// --- Move/Copy transform core (spec §4.1): offsets are [dx,dy,dzIn] — dx/dy plan px, dz inches. ---
|
|
1060
1269
|
let cmSeq=0;
|
|
1061
1270
|
function cloneMember(m){const c=JSON.parse(JSON.stringify(m));c.id='m'+Date.now()+'_c'+(cmSeq++);return c;}
|
|
@@ -1083,7 +1292,7 @@ function retargetTos(m,srcDef,dstDef){const d=dstDef-srcDef;ensureMeta(m);
|
|
|
1083
1292
|
return m;}
|
|
1084
1293
|
// best-effort: framing plans carry TOS at the level UNO — assume the L2 datum +16'-6" (198"); each end's
|
|
1085
1294
|
// 'default' checkbox links it to this value (auto-updates when changed); uncheck to override.
|
|
1086
|
-
let defaultTOS=198, addProfile='';
|
|
1295
|
+
let defaultTOS=198, addProfile='', addType='beam'; // addType = the member type new members are drawn with (Add-member panel)
|
|
1087
1296
|
let basePickColId=null; // Mode B: the column whose base an armed 3D level-pick retargets
|
|
1088
1297
|
const MIN_COL_STUB_IN=12; // never trim a column below a 1' stub (keeps bos < tos)
|
|
1089
1298
|
// Mode B: arm the 3D column-base pick on `colId` (a level-snapped elevation → col.bos). 3D-view only.
|
|
@@ -1099,60 +1308,51 @@ function syncDefaults(){for(const m of P.members){ensureMeta(m);
|
|
|
1099
1308
|
else for(const en of m.ends)if(en.tosDef!==false&&defaultTOS!=null)en.tos=defaultTOS;}}
|
|
1100
1309
|
const autofillTOS=syncDefaults;
|
|
1101
1310
|
// profs is per-plan — computed in setPlan()
|
|
1102
|
-
// Undo snapshot
|
|
1103
|
-
//
|
|
1104
|
-
//
|
|
1105
|
-
//
|
|
1106
|
-
//
|
|
1107
|
-
//
|
|
1108
|
-
//
|
|
1109
|
-
|
|
1110
|
-
//
|
|
1111
|
-
//
|
|
1112
|
-
//
|
|
1113
|
-
|
|
1114
|
-
//
|
|
1115
|
-
//
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
return JSON.stringify(base);}
|
|
1121
|
-
// The mirror entry for the TARGET plan's own stack: shaped as if T were current (so a later undo
|
|
1122
|
-
// FROM T applies cleanly), with an others-slice pointing back at the source — undoing the arrival
|
|
1123
|
-
// from the target side restores the source plan too (a moved member is never stranded/lost).
|
|
1124
|
-
// extraIds = ids MOVING onto T (a move keeps ids, so their joints must ride this slice — else the
|
|
1125
|
-
// apply-from-T own-filter drops them and the member returns to the source stripped of connections).
|
|
1126
|
-
// Per-plan stacks are not cross-invalidated: if the op was already undone from the other side, this
|
|
1127
|
-
// mirror degrades to a benign one-step no-op undo (never data loss).
|
|
1128
|
-
function snapshotForPlan(T,src,extraIds){const tm=new Set([...(T.members||[]).map(m=>m.id),...(extraIds||[])]);
|
|
1129
|
-
return JSON.stringify({members:T.members||[],dims:T.dims||[],frame:T.frame||null,
|
|
1130
|
-
joints:(C.joints||[]).filter(j=>j&&tm.has(j.main)),
|
|
1131
|
-
clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,
|
|
1132
|
-
others:[{sheet:src.sheet,members:src.members}]});}
|
|
1133
|
-
function pushUndoFor(T,entry){(T.undo=T.undo||[]).push(entry);if(T.undo.length>200)T.undo.shift();(T.redo=T.redo||[]).length=0;}
|
|
1311
|
+
// Undo snapshot — WHOLE-MODEL on a SINGLE GLOBAL stack. Captures every plane's members AND each plane's
|
|
1312
|
+
// OWN dims/frame/grid (all per-sheet data), keyed by sheet, + model-global joints/details/dim_style. Because
|
|
1313
|
+
// selection + edit/delete/to-level now span sheets, undo must restore all touched sheets; a whole-model
|
|
1314
|
+
// snapshot on one global stack does that (undo/redo below). Keying dims/frame/grid by sheet (not the
|
|
1315
|
+
// active plane) is essential: the stack is NOT swapped on plan switch, so undoing from a different sheet
|
|
1316
|
+
// must not write the capture-sheet's dims/frame/grid onto whatever sheet is active now. INVARIANT: member
|
|
1317
|
+
// ids are unique across the set (real reads satisfy this); duplicate ids across sheets would over-match
|
|
1318
|
+
// select/delete/undo — a reader-side id-uniqueness hardening. dims3d rides its own persistence.
|
|
1319
|
+
// dim_style (the model-global dimension-style defaults) rides every entry like details/member_types: one
|
|
1320
|
+
// chronological stack means an undo simply walks the whole model back, so there is no cross-sheet clobber.
|
|
1321
|
+
function snapshot(){return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null});} // members/dims/frame/grid are all PER-SHEET → captured per sheet so a cross-sheet undo restores each sheet's OWN dims/frame/grid, never the active sheet's over another's. clips/work area are view-state riding the undo stack; details/dim_style = model-global, captured whole.
|
|
1322
|
+
// Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
|
|
1323
|
+
// members, so one whole-model stack is coherent — undo restores all planes at once, and a cross-
|
|
1324
|
+
// sheet edit/delete/to-level round-trips fully. (Earlier this was per-plane — `undo=P.undo` swapped
|
|
1325
|
+
// on plan switch — and a whole-model snapshot living on one plane's stack silently reverted edits
|
|
1326
|
+
// made on OTHER sheets when you undid; the bug this replaces.) The redo mirror is just another full
|
|
1327
|
+
// snapshot(); there is no cross-plane `others` slice to reconstruct any more.
|
|
1328
|
+
function snapshotLike(){return snapshot();}
|
|
1134
1329
|
function refreshDims3d(){if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();} // repaint the 3D dim lines/labels from C.dims3d
|
|
1135
1330
|
function refreshOverlayDims3d(){if(window.Steel3DView&&window.Steel3DView.refreshOverlayDims)window.Steel3DView.refreshOverlayDims();} // re-derive the legend DIMENSIONS overlays from C.dim_overlays
|
|
1136
1331
|
function pushUndo(prev){undo.push(prev);if(undo.length>200)undo.shift();redo.length=0;scheduleSave();}
|
|
1137
1332
|
function apply(json){const d=JSON.parse(json);
|
|
1138
|
-
if(Array.isArray(d))P.members=d; // legacy member-only snapshot
|
|
1139
|
-
else{const
|
|
1333
|
+
if(Array.isArray(d))P.members=d; // legacy member-only snapshot — no longer produced (dedupe/all paths now push whole-model snapshot()); kept defensively for any in-flight entry
|
|
1334
|
+
else if(Array.isArray(d.planes)){for(const o of d.planes){const tp=C.plans.find(p=>p.sheet===o.sheet);if(tp){tp.members=(o.members||[]).map(ensureMeta);if(Array.isArray(o.dims))tp.dims=o.dims;if('frame' in o)tp.frame=o.frame||null;if('grid' in o)tp.grid=o.grid;}else{console.error('undo: sheet '+o.sheet+' not found - slice skipped');toast('Undo couldn’t restore sheet '+o.sheet);}}if('joints' in d)C.joints=Array.isArray(d.joints)?d.joints:[];} // whole-model → restore EVERY sheet's OWN members/dims/frame/grid (cross-sheet undo restores each sheet's own, never the active sheet's over another's); joints captured whole
|
|
1335
|
+
else{console.error('undo: legacy non-planes stack entry — no producer emits this any more; restoring members/joints only. dims/frame/grid are PER-SHEET in the planes format, so they are deliberately NOT written to the active plane here (that was the cross-sheet wrong-sheet footgun).');
|
|
1336
|
+
const pmOld=new Set((P.members||[]).map(m=>m.id));P.members=d.members||[];
|
|
1140
1337
|
if('joints' in d){const own=new Set([...pmOld,...P.members.map(m=>m.id)]);C.joints=(C.joints||[]).filter(j=>!(j&&own.has(j.main))).concat(d.joints||[]);}
|
|
1141
1338
|
if(Array.isArray(d.others))for(const o of d.others){const tp=C.plans.find(p=>p.sheet===o.sheet);
|
|
1142
1339
|
if(tp&&tp!==P)tp.members=(o.members||[]).map(ensureMeta);
|
|
1143
1340
|
else if(!tp){console.error('undo: sheet '+o.sheet+' not found — cross-plan slice skipped');toast('Undo couldn’t restore sheet '+o.sheet);}}} // restore THIS plan's joint slice: drop joints owned by this plan (old ∪ restored member ids), re-add the snapshot's — OTHER sheets' joints stay untouched. grid is per-plan (restored above); 'others' = the cross-plan slice a to-level commit captured. dims3d rides its own path.
|
|
1144
1341
|
if('details' in d)C.detail_placements=Array.isArray(d.details)?d.details:[]; // restore the model-global placed details (Slice 4)
|
|
1342
|
+
if('dim_style' in d){C.dim_style=d.dim_style||{};sanitizeDimStyle();} // model-global dimension-style defaults ride the undo stack too (changing them repaints every non-overriding dim)
|
|
1145
1343
|
updCS();
|
|
1146
1344
|
selIds=new Set([...selIds].filter(id=>byId(id)||/^det:/.test(id))); // keep a selected placed-detail id (det:…) — it isn't a member
|
|
1147
1345
|
selDimIds.forEach(id=>{if(!(P.dims||[]).some(x=>x.id===id))selDimIds.delete(id);}); // drop any dim selection the undo removed
|
|
1148
1346
|
if(sel3dDimIds.size){const ok=new Set((C.dims3d||[]).map(x=>x.id));sel3dDimIds=new Set([...sel3dDimIds].filter(id=>ok.has(id)));} // drop stale 3D-dim selections
|
|
1149
1347
|
dimDraft=null;dimChainPrev=null;dimPrevClear(); // undo/redo changed geometry under the tool → abandon any in-progress dim placement / chain (else the chain head points at a removed segment)
|
|
1348
|
+
drawDraft=null;drawPrevClear(); // …likewise abandon an in-progress Add-member start point
|
|
1150
1349
|
cmDraft=null;cmPrevClear();cmHudClose(); // same for an in-progress Move/Copy pick — the base may reference removed geometry
|
|
1151
1350
|
if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // and the 3D-side draft/ghosts
|
|
1152
1351
|
if(window.Steel3DView&&window.Steel3DView.setClipState&&'clips' in d)window.Steel3DView.setClipState(d.clips); // restore clips + work area alongside the contract
|
|
1352
|
+
if('member_types' in d)C.member_types=sanitizeMemberTypes(d.member_types);
|
|
1153
1353
|
scheduleSave();render();sync3D();}
|
|
1154
|
-
function doUndo(){if(!undo.length)return;redo.push(snapshotLike(
|
|
1155
|
-
function doRedo(){if(!redo.length)return;undo.push(snapshotLike(
|
|
1354
|
+
function doUndo(){if(!undo.length)return;redo.push(snapshotLike());apply(undo.pop());}
|
|
1355
|
+
function doRedo(){if(!redo.length)return;undo.push(snapshotLike());apply(redo.pop());}
|
|
1156
1356
|
function edit(fn){const pv=snapshot();fn();pushUndo(pv);render();sync3D();}
|
|
1157
1357
|
// --- auto-save: edits persist to this browser (localStorage). Raster stays embedded; only members + TOS are stored. ---
|
|
1158
1358
|
const LSKEY = 'steeltakeoff:edits:v1:' + APP_ID;
|
|
@@ -1170,7 +1370,7 @@ function setSaved(state,msg){const el=document.getElementById('saveStat');if(!el
|
|
|
1170
1370
|
// since the engine's setClipState does NOT re-sanitise its input), and caps the list at 10.
|
|
1171
1371
|
function sanitizeViews(arr){if(!Array.isArray(arr))return [];const out=[];for(const v of arr){if(!v||typeof v!=='object')continue;const id=(typeof v.id==='string'&&v.id)?v.id:('v'+Math.random().toString(36).slice(2,9));const name=(typeof v.name==='string'&&v.name.trim())?v.name.slice(0,80):'View';out.push({v:1,id,name,order:typeof v.order==='number'?v.order:out.length,camera:(v.camera&&typeof v.camera==='object')?v.camera:null,projection:v.projection==='ortho'?'ortho':'persp',mode:['solid','wire','xray'].includes(v.mode)?v.mode:'solid',clips:(v.clips&&typeof v.clips==='object')?v.clips:null,objects:(v.objects&&typeof v.objects==='object')?v.objects:null});if(out.length>=10)break;}return out;}
|
|
1172
1372
|
function persist(){try{localStorage.setItem(LSKEY,JSON.stringify({sig:dataSig(),ts:Date.now(),active:C.active,
|
|
1173
|
-
custom_details:C.custom_details, profile_colors:C.profile_colors, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, prop_labels:C.prop_labels, joints:C.joints, detail_placements:C.detail_placements, views:C.views,
|
|
1373
|
+
custom_details:C.custom_details, profile_colors:C.profile_colors, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, detail_placements:C.detail_placements, views:C.views,
|
|
1174
1374
|
plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));setSaved('ok');}catch(e){setSaved('err');console.error('local autosave failed',e);}}
|
|
1175
1375
|
// --- server-side draft save: PUT the FULL contract C — this is the copy Approve bakes.
|
|
1176
1376
|
// localStorage (persist) stays the instant per-browser draft cache; this is the durable one.
|
|
@@ -1199,18 +1399,97 @@ function restoreSaved(){try{const raw=localStorage.getItem(LSKEY);if(!raw)return
|
|
|
1199
1399
|
if(d.sig!==dataSig())return false;const by={};(d.plans||[]).forEach(p=>by[p.sheet]=p);
|
|
1200
1400
|
if(d.custom_details)C.custom_details=d.custom_details;
|
|
1201
1401
|
if(d.profile_colors)C.profile_colors=d.profile_colors;
|
|
1402
|
+
if(Array.isArray(d.member_types))C.member_types=sanitizeMemberTypes(d.member_types);
|
|
1202
1403
|
if(d.target_confidence!=null)C.target_confidence=d.target_confidence;
|
|
1203
1404
|
C.plans.forEach(p=>{const s=by[p.sheet];if(s){if(Array.isArray(s.members))p.members=s.members;if(s.default_tos!=null)p.default_tos=s.default_tos;if(Array.isArray(s.details))p.details=s.details;if(Array.isArray(s.dims))p.dims=s.dims;if('frame' in s)p.frame=s.frame||null;if('grid' in s)p.grid=s.grid||null;p.autofilled=true;}});
|
|
1204
1405
|
if(Array.isArray(d.dims3d))C.dims3d=d.dims3d; // restore model-global 3D dims from the local draft
|
|
1205
1406
|
if(Array.isArray(d.detail_placements))C.detail_placements=d.detail_placements; // restore placed details
|
|
1206
1407
|
if(d.dim_overlays&&typeof d.dim_overlays==='object'&&!Array.isArray(d.dim_overlays)){const o=d.dim_overlays;C.dim_overlays={bolt_pitch:o.bolt_pitch!==false,edge_clearance:o.edge_clearance!==false,cope_size:o.cope_size!==false,base_plate:o.base_plate!==false,anchor_depth:o.anchor_depth!==false};} // restore the legend DIMENSIONS toggles — sanitised to the known boolean keys (a corrupt/partial draft can't desync the legend from what's drawn; on unless explicitly false)
|
|
1408
|
+
if('dim_style' in d){C.dim_style=d.dim_style;sanitizeDimStyle();} // restore the model-global dimension-style defaults — sanitised to the three known keys
|
|
1207
1409
|
if('prop_labels' in d)C.prop_labels=sanitizePropLabels(d.prop_labels); // restore canvas property-label display state (sanitised to known keys/placement)
|
|
1208
1410
|
if(Array.isArray(d.joints))C.joints=d.joints; // restore model-global connection joints (base plates) from the local draft
|
|
1209
1411
|
if(Array.isArray(d.views))C.views=sanitizeViews(d.views); // restore saved views (Views Organizer) from the local draft — sanitised to clean, capped entries
|
|
1210
1412
|
if(d.active!=null)C.active=d.active;return true;}catch(e){console.warn('discarding corrupt local draft',e);return false;}}
|
|
1211
1413
|
function updUR(){document.getElementById('undoB').disabled=!undo.length;document.getElementById('redoB').disabled=!redo.length;}
|
|
1212
|
-
|
|
1414
|
+
// Canonical, model-global palette rank (B2): EVERY plan's non-blank member profiles ∪ weight-table keys,
|
|
1415
|
+
// uppercased + sorted — the SAME basis contract-to-scene.ts uses, so a profile gets ONE hue in the 2D legend
|
|
1416
|
+
// AND in 3D, stable across plans. (The per-plan `profs` still drives the legend/datalist; only the colour
|
|
1417
|
+
// index moved off it — a blank/RFI/other-plan profile must not shift a real profile's slot.) Rebuilt at
|
|
1418
|
+
// render() top so it tracks edits without touching every profs.push site.
|
|
1419
|
+
let colorRank=[];
|
|
1420
|
+
function buildColorRank(){colorRank=[...new Set([...(C.plans||[]).flatMap(pl=>(pl.members||[]).map(m=>(m.profile||'').trim().toUpperCase())).filter(Boolean), ...Object.keys(WT||{}).map(k=>k.trim().toUpperCase())])].sort();}
|
|
1421
|
+
function colorFor(p){const k=(p||'').trim().toUpperCase();
|
|
1422
|
+
const ov=C.profile_colors[p]??(Object.entries(C.profile_colors).find(([kk])=>kk.trim().toUpperCase()===k)||[])[1]; // override: exact key, then case-insensitive — mirrors contract-to-scene pickColor so an override resolves identically in 2D + 3D
|
|
1423
|
+
if(ov)return ov;
|
|
1424
|
+
const i=colorRank.indexOf(k);return PAL[((i%PAL.length)+PAL.length)%PAL.length];} // i<0 (blank/CUSTOM/unresolved) wraps to PAL[last], matching pickColor so those members agree in 2D + 3D too
|
|
1213
1425
|
function len(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1]);}
|
|
1426
|
+
// ── Column profile sections ─────────────────────────────────────────────────────────────────────
|
|
1427
|
+
// A column is drawn on the plan as its profile-SECTION footprint (I/box/channel/angle/tube), not a
|
|
1428
|
+
// point. `profileDimsIn` MIRRORS server/contract-to-scene.ts `profileDimsIn` (KEEP IN LOCK-STEP —
|
|
1429
|
+
// same parse rules) → {w,d} in INCHES; window.__AISC_BF is the {designation→bf} map from
|
|
1430
|
+
// /api/aisc-shapes. Returns null for an unresolved mark (RFI).
|
|
1431
|
+
function profileDimsIn(profile){
|
|
1432
|
+
if(!profile)return null;
|
|
1433
|
+
const p=String(profile).trim().toUpperCase();
|
|
1434
|
+
if(p===''||/(^|[^A-Z])MF($|[^A-Z])/.test(p))return null;
|
|
1435
|
+
const m=p.match(/^([A-Z]+)\s*([0-9X./]+)/);if(!m)return null;
|
|
1436
|
+
const prefix=m[1],nums=m[2].split('X').map(t=>parseFloat(t)).filter(n=>!isNaN(n));
|
|
1437
|
+
if(!nums.length)return null;
|
|
1438
|
+
if((prefix==='HSS'||prefix==='TUBE'||prefix==='L')&&nums.length>=3)return{d:nums[0],w:nums[1]};
|
|
1439
|
+
if(prefix==='HSS'||prefix==='PIPE'){const dia=nums[0];return{d:dia,w:dia};}
|
|
1440
|
+
if(/^(W|S|M|HP|C|MC|WT|ST|MT)$/.test(prefix)){const d=nums[0],bf=(window.__AISC_BF||{})[p.replace(/\s+/g,'')];
|
|
1441
|
+
if(bf!==undefined)return{d,w:bf};const ratio=(prefix==='C'||prefix==='MC')?0.28:0.42;return{d,w:d*ratio};}
|
|
1442
|
+
return null;
|
|
1443
|
+
}
|
|
1444
|
+
// Section shape kind from the designation — mirrors steel-3d-view.js shapeOf (parity with 3D).
|
|
1445
|
+
function sectionKindOf(profile){const p=String(profile||'').toUpperCase().trim();
|
|
1446
|
+
if(/^(W|M|S|HP|UC|UB|UKC|UKB|IPE|HE)/.test(p))return 'I';
|
|
1447
|
+
if(/^(C|MC|PFC)/.test(p))return 'C';
|
|
1448
|
+
if(/^L/.test(p))return 'L';
|
|
1449
|
+
if(/^(HSS|PIPE|TS|SHS|RHS|CHS|TUBE|HSQ)/.test(p))return 'TUBE';
|
|
1450
|
+
return 'BOX';}
|
|
1451
|
+
// Local section outline (centred at origin), w/d in PX — mirrors steel-3d-view.js profileShape (the
|
|
1452
|
+
// tf/tw web+flange fractions match, so 2D and 3D read as the same section). Tube drawn solid in 2D.
|
|
1453
|
+
function sectionShapePts(profile,w,d){const hw=w/2,hd=d/2,kind=sectionKindOf(profile);
|
|
1454
|
+
if(kind==='I'){const tf=Math.min(d*0.5,Math.max(d*0.10,6)),tw=Math.min(w*0.5,Math.max(w*0.10,5));
|
|
1455
|
+
return [[-hw,-hd],[hw,-hd],[hw,-hd+tf],[tw/2,-hd+tf],[tw/2,hd-tf],[hw,hd-tf],[hw,hd],[-hw,hd],[-hw,hd-tf],[-tw/2,hd-tf],[-tw/2,-hd+tf],[-hw,-hd+tf]];}
|
|
1456
|
+
if(kind==='C'){const tf=Math.max(d*0.10,5),tw=Math.max(w*0.12,5);
|
|
1457
|
+
return [[-hw,-hd],[hw,-hd],[hw,-hd+tf],[-hw+tw,-hd+tf],[-hw+tw,hd-tf],[hw,hd-tf],[hw,hd],[-hw,hd]];}
|
|
1458
|
+
if(kind==='L'){const t=Math.max(Math.min(w,d)*0.18,5);
|
|
1459
|
+
return [[-hw,-hd],[hw,-hd],[hw,-hd+t],[-hw+t,-hd+t],[-hw+t,hd],[-hw,hd]];}
|
|
1460
|
+
return [[-hw,-hd],[hw,-hd],[hw,hd],[-hw,hd]];} // TUBE/BOX → rectangle
|
|
1461
|
+
// Column plan polygon (absolute px). Primary: derive from profile + pt_per_ft + rot. Fallback: a small
|
|
1462
|
+
// square footprint so an unresolved (RFI) column still reads as a section, never a bare point.
|
|
1463
|
+
// ponytail: filter-traced fallback (the saved section linework) deferred — the marker covers the rare
|
|
1464
|
+
// unresolved case; profile-derived covers every resolved column.
|
|
1465
|
+
function columnSectionPoly(m){
|
|
1466
|
+
const wp=m&&m.wp;if(!wp||!wp.length)return null;
|
|
1467
|
+
const a=wp[0],b=wp[wp.length-1],cx=(a[0]+b[0])/2,cy=(a[1]+b[1])/2;
|
|
1468
|
+
const ppf=(P&&P.pt_per_ft>0)?P.pt_per_ft:0,dims=profileDimsIn(m.profile);
|
|
1469
|
+
const sec=(dims&&ppf)?{w:dims.w,d:dims.d}:((m.section&&m.section.w>0&&m.section.d>0&&ppf)?m.section:null);
|
|
1470
|
+
// Profile-derived section (primary) OR the reader's traced footprint (fallback) — an RFI column with a
|
|
1471
|
+
// traced `section` still renders at its REAL size instead of a tiny generic marker.
|
|
1472
|
+
if(sec){
|
|
1473
|
+
const pts=sectionShapePts(m.profile,sec.w/12*ppf,sec.d/12*ppf),rot=(+m.rot||0)*Math.PI/180,cs=Math.cos(rot),sn=Math.sin(rot);
|
|
1474
|
+
return pts.map(([x,y])=>[cx+x*cs-y*sn,cy+x*sn+y*cs]);
|
|
1475
|
+
}
|
|
1476
|
+
const r=ppf?Math.max(6,(6/12)*ppf):8; // ~6" or a floor, so it stays visible even unscaled
|
|
1477
|
+
return [[cx-r,cy-r],[cx+r,cy-r],[cx+r,cy+r],[cx-r,cy+r]];
|
|
1478
|
+
}
|
|
1479
|
+
const _polyStr=pts=>pts.map(p=>p[0].toFixed(1)+','+p[1].toFixed(1)).join(' ');
|
|
1480
|
+
// Vector overlay: render THIS sheet's filter linework crisply (sharp, snappable, measurable) instead of
|
|
1481
|
+
// the blurry raster JPEG. Vector PDFs expose filterElsForPlan(); a genuinely scanned sheet (no vectors)
|
|
1482
|
+
// falls back to the RB64 raster. ponytail: all line d's are merged into ONE <path> so the browser parses
|
|
1483
|
+
// one node, not thousands — fast to re-render on pan/zoom.
|
|
1484
|
+
function overlaySvg(){
|
|
1485
|
+
const els=filterElsForPlan();
|
|
1486
|
+
if(!els)return RB64?`<image href="data:image/jpeg;base64,${RB64}" x="${X0}" y="${Y0}" width="${X1-X0}" height="${Y1-Y0}"/>`:'';
|
|
1487
|
+
let d='',circ='';
|
|
1488
|
+
for(const e of els){if(!e)continue;
|
|
1489
|
+
if(e.kind==='line'){if(typeof e.d==='string'&&e.d)d+=e.d+' ';else if(e.x1!=null&&e.x2!=null)d+=`M${e.x1} ${e.y1}L${e.x2} ${e.y2}`;}
|
|
1490
|
+
else if(e.kind==='circle'&&e.r>0)circ+=`<circle cx="${e.cx}" cy="${e.cy}" r="${e.r}"/>`;}
|
|
1491
|
+
return `<rect class=pdfsheet x="${X0}" y="${Y0}" width="${X1-X0}" height="${Y1-Y0}"/><g class=pdfvec>${d?`<path d="${d}"/>`:''}${circ}</g>`;
|
|
1492
|
+
}
|
|
1214
1493
|
// --- geometric edit: extend/trim (snap nearest end to a target line) + split at a point ---
|
|
1215
1494
|
function lineX(p1,p2,p3,p4){const x1=p1[0],y1=p1[1],x2=p2[0],y2=p2[1],x3=p3[0],y3=p3[1],x4=p4[0],y4=p4[1];
|
|
1216
1495
|
const den=(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4);if(Math.abs(den)<1e-9)return null; // parallel → no intersection
|
|
@@ -1277,26 +1556,127 @@ function dimDefaultOff(a,b,axis,rot){rot=rot||0;
|
|
|
1277
1556
|
if(axis==='x')return Math.min(A[1],B[1])-28/zoom; // X dim line sits "above" the anchors (local-Y)
|
|
1278
1557
|
return Math.min(A[0],B[0])-28/zoom;} // Y dim line sits "left" of the anchors (local-X)
|
|
1279
1558
|
// one dimension -> SVG string. opts: {id, sel, preview}. Lines use non-scaling-stroke (constant on
|
|
1280
|
-
// screen); the chip rect/text + end
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
s
|
|
1559
|
+
// screen); the chip rect/text + end markers are sized in 1/dz (zoom floored at DIM_ZMIN) and re-synced by updateBadges on zoom.
|
|
1560
|
+
// Below DIM_ZMIN, dim chips/text stop being constant-screen-size and shrink WITH the drawing, so a dense
|
|
1561
|
+
// set of dims doesn't pile up into an unreadable overlapping mass when zoomed out (B8). Tunable.
|
|
1562
|
+
const DIM_ZMIN=0.7;
|
|
1563
|
+
// Drafting-style dimension defaults. Three layers, narrowest first: a dim's own override (`end`/`bg`/
|
|
1564
|
+
// `place`) → the model-global default (C.dim_style, edited in the ⋯ → Display → Dimension style pane) →
|
|
1565
|
+
// these constants. An absent field means "follow the layer below", so changing the model default reaches
|
|
1566
|
+
// every dim that never overrode it, and dims drawn before any of this shipped render like new ones.
|
|
1567
|
+
const DIM_ENDS=['dot','tick','arrow','none'];
|
|
1568
|
+
const DIM_DEF={end:'tick',bg:false,place:'above'};
|
|
1569
|
+
const DIM_END_LBL={dot:'Dot',tick:'Tick',arrow:'Arrow',none:'None'};
|
|
1570
|
+
const DIM_END_TIP={dot:'A small disc on each anchor',tick:'An oblique slash on each anchor — the drafting default',arrow:'An arrowhead pointing at each anchor',none:'No end marker'};
|
|
1571
|
+
// Segmented-control glyphs: STATIC and canonical, one per option, drawn in currentColor so they follow the
|
|
1572
|
+
// button's own state. Deliberately NOT live re-renders of the current combination — an icon that reshuffles
|
|
1573
|
+
// whenever an unrelated setting changes stops being recognisable, and the preview strip below already shows
|
|
1574
|
+
// the real interaction. The button keeps its text label under the glyph (see .segico).
|
|
1575
|
+
const _gly=(w,h,inner)=>`<svg viewBox="0 0 ${w} ${h}" width="${w}" height="${h}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4">${inner}</svg>`;
|
|
1576
|
+
// (every attribute is quoted: an unquoted `y2=7/>` swallows the slash into the value and the element is dropped)
|
|
1577
|
+
const DIM_END_GLYPH={
|
|
1578
|
+
dot: _gly(34,14,`<line x1="2" y1="7" x2="32" y2="7"/><circle cx="3.4" cy="7" r="2.2" fill="currentColor" stroke="none"/><circle cx="30.6" cy="7" r="2.2" fill="currentColor" stroke="none"/>`),
|
|
1579
|
+
tick: _gly(34,14,`<line x1="2" y1="7" x2="32" y2="7"/><line x1="0.6" y1="10.6" x2="6.2" y2="3.4"/><line x1="27.8" y1="10.6" x2="33.4" y2="3.4"/>`),
|
|
1580
|
+
arrow:_gly(34,14,`<line x1="2" y1="7" x2="32" y2="7"/><path d="M2 7 10 4.6 10 9.4z" fill="currentColor" stroke="none"/><path d="M32 7 24 4.6 24 9.4z" fill="currentColor" stroke="none"/>`),
|
|
1581
|
+
none: _gly(34,14,`<line x1="2" y1="7" x2="32" y2="7"/>`)};
|
|
1582
|
+
const DIM_PLACE_GLYPH={ // an abstract mark for the text, above the line vs breaking it — no literal characters at this size
|
|
1583
|
+
above:_gly(34,14,`<line x1="2" y1="11" x2="32" y2="11"/><rect x="11" y="1.6" width="12" height="6" rx="1.5"/>`),
|
|
1584
|
+
on: _gly(34,14,`<line x1="2" y1="7" x2="10" y2="7"/><line x1="24" y1="7" x2="32" y2="7"/><rect x="11" y="4" width="12" height="6" rx="1.5"/>`)};
|
|
1585
|
+
// The live preview: the REAL dimSvg with dz pinned, so the pane can never show something the canvas
|
|
1586
|
+
// wouldn't draw. Sized in the same units the renderer uses, on the pane's own dark surface — the halo
|
|
1587
|
+
// (which exists for the white drawing beneath) is invisible here, so the CHIP and the on-line GAP are
|
|
1588
|
+
// what carry "background on/off", exactly as the eye needs them to.
|
|
1589
|
+
// Headroom matters: an "above" label is offset by half the 18-unit chip + 3, so the dim line needs ≥15 units
|
|
1590
|
+
// of clear space above it or a chipped label is clipped by the viewBox. Anchors sit below the line, and the
|
|
1591
|
+
// tick overshoot extends the witness lines 5 further up.
|
|
1592
|
+
// The label is a FIXED sample, not the measured length: the swatch shows a style, and a real measurement
|
|
1593
|
+
// would take its width from the plan's pt_per_ft — a contract value we don't control, which at an extreme
|
|
1594
|
+
// scale prints a label wider than the viewBox (clipped, and too wide to leave room for the on-line gap).
|
|
1595
|
+
const DIM_PV_TEXT=`4'-5 3/16"`;
|
|
1596
|
+
function dimStylePreview(st){const W=214,H=46,LINE=26;
|
|
1597
|
+
const d={a:[16,40],b:[W-16,40],axis:'x',off:LINE,rot:0,end:st.end,bg:st.bg,place:st.place};
|
|
1598
|
+
return `<div class=dimpv><svg viewBox="0 0 ${W} ${H}">${dimSvg(d,{dz:1,text:DIM_PV_TEXT})}</svg></div>`;}
|
|
1599
|
+
const _dEnd=v=>DIM_ENDS.includes(v),_dPlace=v=>v==='on'||v==='above',_dBg=v=>typeof v==='boolean';
|
|
1600
|
+
// Normalise C.dim_style to the three known keys. Same discipline as dim_overlays: a partial/corrupt draft
|
|
1601
|
+
// or an AI-authored contract can't put junk on the canvas.
|
|
1602
|
+
function sanitizeDimStyle(){const s=(C&&C.dim_style&&typeof C.dim_style==='object'&&!Array.isArray(C.dim_style))?C.dim_style:{};
|
|
1603
|
+
C.dim_style={end:_dEnd(s.end)?s.end:DIM_DEF.end,bg:_dBg(s.bg)?s.bg:DIM_DEF.bg,place:_dPlace(s.place)?s.place:DIM_DEF.place};}
|
|
1604
|
+
sanitizeDimStyle();
|
|
1605
|
+
function dimStyle(d){const g=(C&&C.dim_style)||DIM_DEF;return {
|
|
1606
|
+
end: (d&&_dEnd(d.end)) ?d.end :(_dEnd(g.end) ?g.end :DIM_DEF.end),
|
|
1607
|
+
bg: (d&&_dBg(d.bg)) ?d.bg :(_dBg(g.bg) ?g.bg :DIM_DEF.bg),
|
|
1608
|
+
place:(d&&_dPlace(d.place))?d.place:(_dPlace(g.place)?g.place:DIM_DEF.place)};}
|
|
1609
|
+
// does this dim carry its own style, rather than following the model default?
|
|
1610
|
+
const dimHasOverride=d=>!!d&&(_dEnd(d.end)||_dBg(d.bg)||_dPlace(d.place));
|
|
1611
|
+
// Tolerate a hand-edited / AI-written contract at the load boundary, like sanitizeFrame. A dim's geometry
|
|
1612
|
+
// is interpolated straight into SVG attributes, so a non-numeric anchor is attribute injection, not merely
|
|
1613
|
+
// a broken drawing — drop any dim we can't trust, and keep only style fields with a known value.
|
|
1614
|
+
function sanitizeDims(p){if(!p)return;
|
|
1615
|
+
if(!Array.isArray(p.dims)){p.dims=[];return;}
|
|
1616
|
+
// NOT the global isFinite: isFinite(null) and isFinite('') are both true, which would silently REPAIR a
|
|
1617
|
+
// junk anchor into 0 rather than drop the dim. A numeric string is still accepted (a hand-edited file).
|
|
1618
|
+
const num=v=>{const n=(typeof v==='number')?v:((typeof v==='string'&&v.trim()!=='')?Number(v):NaN);return Number.isFinite(n)?n:null;};
|
|
1619
|
+
const pt=a=>Array.isArray(a)&&a.length>=2&&num(a[0])!=null&&num(a[1])!=null;
|
|
1620
|
+
const out=[];
|
|
1621
|
+
for(const d of p.dims){
|
|
1622
|
+
if(!d||typeof d!=='object'||!pt(d.a)||!pt(d.b))continue;
|
|
1623
|
+
if(!(d.axis==='x'||d.axis==='y'||d.axis==='free')||num(d.off)==null)continue;
|
|
1624
|
+
const r=num(d.rot);
|
|
1625
|
+
const q={id:String(d.id||('d'+Date.now()+'_'+(dimSeq++))),a:[num(d.a[0]),num(d.a[1])],b:[num(d.b[0]),num(d.b[1])],axis:d.axis,off:num(d.off),rot:r==null?0:r};
|
|
1626
|
+
if(_dEnd(d.end))q.end=d.end;if(_dBg(d.bg))q.bg=d.bg;if(_dPlace(d.place))q.place=d.place;
|
|
1627
|
+
out.push(q);}
|
|
1628
|
+
if(out.length!==p.dims.length)console.warn('discarding '+(p.dims.length-out.length)+' malformed dimension(s) on '+p.sheet);
|
|
1629
|
+
p.dims=out;}
|
|
1630
|
+
// the two end markers, sized in 1/dz so they track the label's shrink. `dot` is a disc on the anchor;
|
|
1631
|
+
// `tick` is the drafting oblique slash (the dim-line direction turned 45°); `arrow` puts its tip on the
|
|
1632
|
+
// anchor and its tail inboard.
|
|
1633
|
+
function dimEndsSvg(g,end,dz,c){
|
|
1634
|
+
if(end==='none')return '';
|
|
1635
|
+
const dx=g.p2[0]-g.p1[0],dy=g.p2[1]-g.p1[1],L=Math.hypot(dx,dy)||1,ux=dx/L,uy=dy/L;
|
|
1636
|
+
const one=(p,sx,sy)=>{ // sx,sy = unit vector from this end pointing INBOARD along the dim line
|
|
1637
|
+
if(end==='dot')return `<circle class="dimend ${c}" cx="${p[0]}" cy="${p[1]}" r="${3/dz}"/>`;
|
|
1638
|
+
if(end==='tick'){const h=4.5/dz,tx=(ux-uy)*Math.SQRT1_2,ty=(ux+uy)*Math.SQRT1_2; // u turned +45°
|
|
1639
|
+
return `<line class="dimend ${c}" x1="${p[0]-tx*h}" y1="${p[1]-ty*h}" x2="${p[0]+tx*h}" y2="${p[1]+ty*h}"/>`;}
|
|
1640
|
+
const A=11/dz,W=4/dz,bx=p[0]+sx*A,by=p[1]+sy*A,nx=-sy,ny=sx;
|
|
1641
|
+
return `<path class="dimend ${c}" d="M${p[0]} ${p[1]} L${bx+nx*W/2} ${by+ny*W/2} L${bx-nx*W/2} ${by-ny*W/2}z"/>`;};
|
|
1642
|
+
return one(g.p1,ux,uy)+one(g.p2,-ux,-uy);}
|
|
1643
|
+
function dimSvg(d,o){o=o||{};const g=dimGeo(d.a,d.b,d.axis,d.off,d.rot),dz=(o.dz>0)?o.dz:Math.max(zoom,DIM_ZMIN); // dz = zoom floored at DIM_ZMIN, used for the CHIP/text/end sizes (positions stay in world units). o.dz pins it for the off-canvas style preview, which has no zoom of its own.
|
|
1644
|
+
const st=dimStyle(d);
|
|
1645
|
+
const c=(o.preview?'dimprev ':'')+(o.sel?'dimsel ':'');
|
|
1646
|
+
const raw=(typeof o.text==='string')?o.text:dimValueText(g.px),txt=esc(raw); // size the label from the RAW text — esc() turns ' and " into entities, which would over-measure it. o.text supplies a fixed sample for the style preview, whose width must not depend on the plan's scale.
|
|
1647
|
+
const cw=(raw.length*7+16)/dz,ch=18/dz,dd=o.id?` data-dim="${esc(o.id)}"`:'';
|
|
1648
|
+
// The chip+text run ALONG the dim line, like a drafting dimension: horizontal (x) dims stay flat,
|
|
1649
|
+
// vertical (y) dims rotate ~90°, free/slanted dims follow the slant. Clamp to the −90..90 arc so the
|
|
1650
|
+
// text never reads upside-down; within 8° of horizontal it stays flat. A vertical dim always lands on
|
|
1651
|
+
// −90 (reads bottom-to-top), which also puts "above" on the side away from the drawing whichever way
|
|
1652
|
+
// its two anchors happened to be picked.
|
|
1653
|
+
let ang=Math.atan2(g.p2[1]-g.p1[1],g.p2[0]-g.p1[0])*180/Math.PI;if(ang>=90)ang-=180;else if(ang<-90)ang+=180;if(Math.abs(ang)<8)ang=0;
|
|
1654
|
+
const over=st.end==='tick'?5/dz:0; // with ticks the WITNESS lines overshoot past the dim line (drafting convention); dots/arrows stop them at it
|
|
1655
|
+
let s='';for(const w of g.w){const wx=w[1][0]-w[0][0],wy=w[1][1]-w[0][1],WL=Math.hypot(wx,wy)||1;
|
|
1656
|
+
s+=`<line class="dimwit ${c}" x1="${w[0][0]}" y1="${w[0][1]}" x2="${w[1][0]+wx/WL*over}" y2="${w[1][1]+wy/WL*over}"/>`;}
|
|
1657
|
+
// Bare text sitting ON the line would be struck through, so break the line around it (AutoCAD's DIMGAP).
|
|
1658
|
+
// A dim shorter than its own label can't be broken — draw it whole and let the text overhang the ends.
|
|
1659
|
+
const dx=g.p2[0]-g.p1[0],dy=g.p2[1]-g.p1[1],L=Math.hypot(dx,dy)||1;
|
|
1660
|
+
if(!st.bg&&st.place==='on'&&L>cw+8/dz){const ux=dx/L,uy=dy/L,h=cw/2+3/dz;
|
|
1661
|
+
s+=`<line class="dim ${c}"${dd} x1="${g.p1[0]}" y1="${g.p1[1]}" x2="${g.mid[0]-ux*h}" y2="${g.mid[1]-uy*h}"/>`
|
|
1662
|
+
+`<line class="dim ${c}"${dd} x1="${g.mid[0]+ux*h}" y1="${g.mid[1]+uy*h}" x2="${g.p2[0]}" y2="${g.p2[1]}"/>`;}
|
|
1663
|
+
else s+=`<line class="dim ${c}"${dd} x1="${g.p1[0]}" y1="${g.p1[1]}" x2="${g.p2[0]}" y2="${g.p2[1]}"/>`;
|
|
1664
|
+
s+=dimEndsSvg(g,st.end,dz,c);
|
|
1665
|
+
const ly=st.place==='above'?-(ch/2+3/dz):0; // the label rides the rotated frame, so "above" is above as you read it
|
|
1666
|
+
const lab=(st.bg?`<rect class="dimchip ${c}"${dd} x="${-cw/2}" y="${ly-ch/2}" width="${cw}" height="${ch}" rx="${4/dz}"/>`
|
|
1667
|
+
:`<rect class="dimhit ${c}"${dd} x="${-cw/2}" y="${ly-ch/2}" width="${cw}" height="${ch}"/>`)
|
|
1668
|
+
+`<text class="dimtx ${st.bg?'':'dimhalo '}${c}" x="0" y="${ly}" style="font-size:${13/dz}px${st.bg?'':`;stroke-width:${3/dz}px`}">${txt}</text>`; // halo rides 1/dz with the text, else it swells into a solid pill as you zoom in
|
|
1669
|
+
s+=`<g transform="translate(${g.mid[0]} ${g.mid[1]}) rotate(${ang.toFixed(2)})">${lab}</g>`; // label group rides the dim-line midpoint
|
|
1294
1670
|
return s;}
|
|
1295
|
-
function
|
|
1671
|
+
function renderDimsInner(){if(!dimsVisible||!Array.isArray(P.dims))return '';
|
|
1296
1672
|
let s=P.dims.map(d=>dimSvg(d,{id:d.id,sel:selDimIds.has(d.id)})).join('');
|
|
1297
1673
|
const HR=epR();for(const d of P.dims)if(selDimIds.has(d.id)) // each selected dim gets draggable anchor handles — drag an end to re-measure (snaps like drawing; Alt off)
|
|
1298
1674
|
s+=`<circle class=dimhandle data-dim="${esc(d.id)}" data-dimend="0" cx="${d.a[0]}" cy="${d.a[1]}" r="${HR}"/><circle class=dimhandle data-dim="${esc(d.id)}" data-dimend="1" cx="${d.b[0]}" cy="${d.b[1]}" r="${HR}"/>`;
|
|
1299
1675
|
return s;}
|
|
1676
|
+
// The whole dim overlay is rebuilt on zoom (updateBadges) instead of patched attribute-by-attribute: the
|
|
1677
|
+
// end markers, the DIMGAP break and the "above" label offset are all derived from dz, so there is nothing
|
|
1678
|
+
// meaningful left to patch in place. Hit-testing is delegated off data-dim, so replacing the nodes is safe.
|
|
1679
|
+
function renderDims(){return `<g class=dimsg>${renderDimsInner()}</g>`;}
|
|
1300
1680
|
// --- structural grid (Tekla-style; web/grid-core.js owns parsing/geometry — loaded via the module
|
|
1301
1681
|
// shim as window.GridCore). The grid is PER-PLAN contract data (P.grid, like P.frame/P.dims — its
|
|
1302
1682
|
// origin/spacings live in the sheet's display space, which is per-plan): X/Y are relative spacing
|
|
@@ -1308,14 +1688,16 @@ function gridOn(){return !!(typeof P!=='undefined'&&P&&P.grid&&P.grid.on!==false
|
|
|
1308
1688
|
function gridGeo(){const gc=GC();if(!gc||typeof P==='undefined'||!P||!P.grid)return null;try{return gc.gridGeometry(P.grid,(P.pt_per_ft>0)?P.pt_per_ft:1);}catch(_){return null;}}
|
|
1309
1689
|
function gridSvg(){
|
|
1310
1690
|
if(!gridOn())return '';
|
|
1311
|
-
const geo=gridGeo();if(!geo||(!geo.v.length&&!geo.h.length))return '';
|
|
1691
|
+
const geo=gridGeo();if(!geo||(!geo.v.length&&!geo.h.length&&!(geo.lines&&geo.lines.length)))return '';
|
|
1312
1692
|
const R=11/zoom,F=12/zoom;
|
|
1313
1693
|
let s='<g id=gridG>';
|
|
1314
|
-
geo.v.forEach((l,i)=>{s+=`<line class=gridln 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}"
|
|
1315
|
-
geo.h.forEach((l,i)=>{s+=`<line class=gridln 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}"
|
|
1316
|
-
|
|
1694
|
+
geo.v.forEach((l,i)=>{s+=`<line class=gridln 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)} — drag to move"></line>`;});
|
|
1695
|
+
geo.h.forEach((l,i)=>{s+=`<line class=gridln 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)} — drag to move"></line>`;});
|
|
1696
|
+
(geo.lines||[]).forEach((l,i)=>{s+=`<line class=gridln 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)} — drag to move"></line>`;});
|
|
1697
|
+
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 edit the grid"><circle class=gridbub data-bx="${x}" data-by="${y}" cx="${x}" cy="${y}" r="${R}"/><text class=gridtx data-bx="${x}" data-by="${y}" x="${x}" y="${y}" style="font-size:${F}px">${esc(lb)}</text></g>`;
|
|
1317
1698
|
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);});
|
|
1318
1699
|
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);});
|
|
1700
|
+
(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);});
|
|
1319
1701
|
return s+'</g>';}
|
|
1320
1702
|
// live re-render of just the grid layer while a line is being dragged (render() is too heavy per move)
|
|
1321
1703
|
function refreshGridLayer(){const el=document.getElementById('gridG');if(el)el.outerHTML=gridSvg();}
|
|
@@ -1334,7 +1716,7 @@ const gridDelta=(d)=>'Δ '+(d<0?'−':'+')+dimValueText(Math.abs(d));
|
|
|
1334
1716
|
// commits into the labels override — undoable; the open grid panel's Labels field refreshes via render)
|
|
1335
1717
|
function gridRenameBubble(axis,gi,anchorEl){
|
|
1336
1718
|
const gc=GC();if(!gc||!P.grid)return;
|
|
1337
|
-
const geo=gridGeo();const lines=axis==='v'?geo.v:geo.h;const line=lines[gi];if(!line||!anchorEl)return;
|
|
1719
|
+
const geo=gridGeo();const lines=axis==='v'?geo.v:axis==='h'?geo.h:(geo.lines||[]);const line=lines[gi];if(!line||!anchorEl)return;
|
|
1338
1720
|
const cur=line.label,r=anchorEl.getBoundingClientRect();
|
|
1339
1721
|
const inp=document.createElement('input');inp.value=cur;inp.className='gin';
|
|
1340
1722
|
inp.style.cssText='position:fixed;z-index:70;width:72px;text-align:center;left:'+(r.left+r.width/2-36)+'px;top:'+(r.top+r.height/2-14)+'px;padding:4px;border-color:var(--brand);box-shadow:0 4px 14px rgba(0,0,0,.5)';
|
|
@@ -1345,6 +1727,7 @@ function gridRenameBubble(axis,gi,anchorEl){
|
|
|
1345
1727
|
const nv=inp.value.trim();
|
|
1346
1728
|
if(!nv||nv===cur)return;
|
|
1347
1729
|
if(/\s/.test(nv)){toast('Labels can’t contain spaces');return;}
|
|
1730
|
+
if(axis==='l'){edit(()=>{if(P.grid.lines&&P.grid.lines[gi])P.grid.lines[gi].label=nv;});return;}
|
|
1348
1731
|
const key=axis==='v'?'labels_x':'labels_y',style=axis==='v'?'num':'alpha';
|
|
1349
1732
|
const toks=gc.labelsFor(P.grid[key],style,lines.length);toks[gi]=nv;
|
|
1350
1733
|
edit(()=>{P.grid[key]=toks.join(' ');});};
|
|
@@ -1352,6 +1735,17 @@ function gridRenameBubble(axis,gi,anchorEl){
|
|
|
1352
1735
|
if(ev.key==='Enter'){ev.preventDefault();finish(true);}
|
|
1353
1736
|
else if(ev.key==='Escape'){ev.preventDefault();finish(false);}});
|
|
1354
1737
|
inp.addEventListener('blur',()=>finish(true));}
|
|
1738
|
+
function validGridLine(l){return l&&Array.isArray(l.a)&&Array.isArray(l.b)&&isFinite(l.a[0])&&isFinite(l.a[1])&&isFinite(l.b[0])&&isFinite(l.b[1])&&Math.hypot(l.b[0]-l.a[0],l.b[1]-l.a[1])>1e-6;}
|
|
1739
|
+
function sanitizeGridLines(g){if(!g||!Array.isArray(g.lines))return;g.lines=g.lines.filter(validGridLine).map((l,i)=>({id:String(l.id||('gl'+Date.now()+i)),label:String(l.label||('L'+(i+1))),a:[+l.a[0],+l.a[1]],b:[+l.b[0],+l.b[1]]}));if(!g.lines.length)delete g.lines;}
|
|
1740
|
+
function gridLineId(){return 'gl'+Date.now().toString(36)+Math.floor(Math.random()*1000).toString(36);}
|
|
1741
|
+
function gridNextLineLabel(){const n=(P&&P.grid&&Array.isArray(P.grid.lines))?P.grid.lines.length+1:1;return 'L'+n;}
|
|
1742
|
+
function gridEnsureForLine(a){const gc=GC();if(P.grid)return;P.grid={on:true,origin:a.slice(),x:'',y:'',z:'0',labels_x:'',labels_y:'',ext:gc?5*gc.FT_MM:1524,lines:[]};}
|
|
1743
|
+
function gridAddFreeLine(a,b,label){const gc=GC();if(Math.hypot(b[0]-a[0],b[1]-a[1])<6/zoom){toast('Line is too short to create a grid line');return false;}
|
|
1744
|
+
gridEnsureForLine(a);if(!Array.isArray(P.grid.lines))P.grid.lines=[];
|
|
1745
|
+
P.grid.lines.push({id:gridLineId(),label:label||gridNextLineLabel(),a:a.slice(),b:b.slice()});return true;}
|
|
1746
|
+
function gridSetPickClass(){document.body.classList.toggle('gridpick',!!gridPick||!!gridLinePick);}
|
|
1747
|
+
function gridStartLinePick(){gridPick=false;gridLinePick={a:null};gridSetPickClass();panel();}
|
|
1748
|
+
function gridCancelLinePick(){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridLinePick=null;gridSetPickClass();snapClear();gridReadoutHide();panel();}
|
|
1355
1749
|
function planColumnCount(){let n=0;for(const m of ((P&&P.members)||[]))if(m.role==='column')n++;return n;}
|
|
1356
1750
|
// The active plan's steel-filter elements (per-sheet linework the reader captured) — the source the
|
|
1357
1751
|
// grid-from-drawing detector reads. Falls back to the legacy single-sheet filter shape.
|
|
@@ -1396,9 +1790,37 @@ function gridSetVisible(on){if(!C||typeof P==='undefined'||!P||!P.grid||on===gri
|
|
|
1396
1790
|
document.addEventListener('gridcore-ready',()=>{try{if(C)render();}catch(_){}}); // module shim finished after boot → paint the grid layer
|
|
1397
1791
|
function setGridMode(on){if(!C)return;gridMode=!!on;
|
|
1398
1792
|
if(!gridMode){const ae=document.activeElement,pn=document.getElementById('panel');if(ae&&pn&&pn.contains(ae))ae.blur(); // commit a focused field (change fires on blur) BEFORE the panel is torn down — a canvas click's pointerdown runs before the browser's own focus change
|
|
1399
|
-
gridPick=false;
|
|
1400
|
-
else{if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();geoMode=null;setGeo();selIds.clear();selDimIds.clear();} // disarm Move/Copy too — grid mode and
|
|
1793
|
+
gridPick=false;if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridLinePick=null;gridSetPickClass();snapClear();}
|
|
1794
|
+
else{if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();dimStyleMode=false;geoMode=null;setGeo();selIds.clear();selDimIds.clear();} // disarm Move/Copy + the Dimension style pane too — grid mode, cmTool and the pane must be mutually exclusive (they own the left-click/Esc or the panel)
|
|
1401
1795
|
panel();}
|
|
1796
|
+
// The Dimension style pane — a panel takeover like the grid panel. It edits the MODEL-GLOBAL defaults
|
|
1797
|
+
// (C.dim_style), so every dim that doesn't carry its own style repaints as you click. Each change rides
|
|
1798
|
+
// edit() → one undo step, autosaved. Opening it drops the selection, exactly like the grid panel, because
|
|
1799
|
+
// the panel is the selection's home.
|
|
1800
|
+
function setDimStyleMode(on){if(!C||(on&&view3d))return;dimStyleMode=!!on; // 2D-only: the pane styles the 2D dim overlay, so refuse to arm it in 3D (the menu entry is hidden there too)
|
|
1801
|
+
if(dimStyleMode){if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(gridMode)setGridMode(false);if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();geoMode=null;setGeo();selIds.clear();selDimIds.clear();}
|
|
1802
|
+
panel();}
|
|
1803
|
+
function renderDimStylePanel(p){
|
|
1804
|
+
const g=C.dim_style,over=(P.dims||[]).filter(dimHasOverride).length;
|
|
1805
|
+
p.innerHTML=`<span class=badge>Dimension style</span>
|
|
1806
|
+
<div class=hint style="margin-top:8px">Defaults for every dimension that hasn't been given its own style. New dimensions start here too.</div>
|
|
1807
|
+
${dimStylePreview(g)}
|
|
1808
|
+
<div class=sect style="margin-top:12px">Ends</div>
|
|
1809
|
+
<div class="seg2 segico">${DIM_ENDS.map(k=>`<button data-gend="${k}" class="${g.end===k?'on':''}" data-tip="${esc(DIM_END_TIP[k])}">${DIM_END_GLYPH[k]}<span>${DIM_END_LBL[k]}</span></button>`).join('')}</div>
|
|
1810
|
+
<div class=sect style="margin-top:12px">Label</div>
|
|
1811
|
+
<div class="seg2 segico"><button data-gplace=above class="${g.place==='above'?'on':''}" data-tip="Text sits above the dimension line — the drafting default">${DIM_PLACE_GLYPH.above}<span>Above line</span></button><button data-gplace=on class="${g.place==='on'?'on':''}" data-tip="Text sits on the dimension line; the line breaks around it">${DIM_PLACE_GLYPH.on}<span>On line</span></button></div>
|
|
1812
|
+
<label class=gck style="margin-top:10px" data-tip="Draw a filled chip behind the text. Off = bare text with a halo, so the drawing stays visible."><input type=checkbox id=gDimBg ${g.bg?'checked':''}><span>Label background</span></label>
|
|
1813
|
+
${over?`<div class=divrow><hr></div>
|
|
1814
|
+
<div class=sect>Per-dimension styles</div>
|
|
1815
|
+
<div class=hint style="margin-top:4px"><b>${over}</b> dimension${over===1?'':'s'} on this sheet ${over===1?'has its':'have their'} own style and ${over===1?'ignores':'ignore'} these defaults.</div>
|
|
1816
|
+
<button id=dimClearOv class=ghostw style="margin-top:8px" data-tip="Drop the per-dimension styles on this sheet so every dimension follows the defaults again. Undoable.">Follow defaults again</button>`:''}
|
|
1817
|
+
<div class=hint style="margin-top:10px"><b>Esc</b> closes. Select a dimension to give it its own style.</div>`;
|
|
1818
|
+
const setG=fn=>edit(()=>{fn(C.dim_style);}); // undoable: snapshot() carries dim_style like every other model-global field
|
|
1819
|
+
p.querySelectorAll('button[data-gend]').forEach(b=>b.onclick=()=>setG(s=>{s.end=b.dataset.gend;}));
|
|
1820
|
+
p.querySelectorAll('button[data-gplace]').forEach(b=>b.onclick=()=>setG(s=>{s.place=b.dataset.gplace;}));
|
|
1821
|
+
document.getElementById('gDimBg').onchange=e=>setG(s=>{s.bg=e.target.checked;});
|
|
1822
|
+
const cl=document.getElementById('dimClearOv');
|
|
1823
|
+
if(cl)cl.onclick=()=>{const n=over;edit(()=>{for(const d of P.dims){delete d.end;delete d.bg;delete d.place;}});toast(`${n} dimension${n===1?'':'s'} now follow${n===1?'s':''} the defaults`);};}
|
|
1402
1824
|
// The grid panel (armed-tool takeover, like the Dimension tool). Empty state = two explicit create
|
|
1403
1825
|
// buttons (nothing is created just by opening — UX review); fields commit on change (blur/Enter),
|
|
1404
1826
|
// one undo step each; keystrokes only update the live feedback line.
|
|
@@ -1408,10 +1830,12 @@ function renderGridPanel(p){
|
|
|
1408
1830
|
const ppf=(P&&P.pt_per_ft>0)?P.pt_per_ft:1;
|
|
1409
1831
|
if(!P.grid){
|
|
1410
1832
|
const nCols=planColumnCount(),hasEls=!!filterElsForPlan();
|
|
1411
|
-
|
|
1833
|
+
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
1412
1834
|
<div class=hint style="margin-top:8px">No grid yet. Grid lines are a plan reference — they don't constrain members.</div>
|
|
1413
|
-
<div class=gbtns><button id=gridReadB ${hasEls?'':'disabled'} data-tip="${hasEls?'Detect the printed grid lines and bubbles in this sheet’s linework. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button><button id=gridBlankB data-tip="Start from a 4×4 grid of 30' bays and edit the spacings. Undoable.">Start blank</button></div>
|
|
1835
|
+
<div class=gbtns><button id=gridLineB class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button><button id=gridReadB ${hasEls?'':'disabled'} data-tip="${hasEls?'Detect the printed grid lines and bubbles in this sheet’s linework. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button><button id=gridBlankB data-tip="Start from a 4×4 grid of 30' bays and edit the spacings. Undoable.">Start blank</button></div>
|
|
1836
|
+
${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridLinePick.a?'Pick the second point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.':'Pick the first point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.')+'</div>':''}
|
|
1414
1837
|
<div class=hint style="margin-top:10px">Spacing uses <b>n*d</b> to repeat (e.g. <b>3*25'</b> = three 25' bays). Tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>`;
|
|
1838
|
+
document.getElementById('gridLineB').onclick=gridStartLinePick;
|
|
1415
1839
|
const rb=document.getElementById('gridReadB');if(rb)rb.onclick=()=>gridReadFromDrawing(null);
|
|
1416
1840
|
const ab=document.getElementById('gridAutoB');if(ab)ab.onclick=()=>{const g=gc.inferGrid(P.members,ppf);if(!g){toast('No columns to infer a grid from');return;}edit(()=>{P.grid=g;});};
|
|
1417
1841
|
const bb=document.getElementById('gridBlankB');if(bb)bb.onclick=()=>{const o=gridDefaultOrigin();edit(()=>{P.grid=gc.defaultGrid(o);});};
|
|
@@ -1434,6 +1858,10 @@ function renderGridPanel(p){
|
|
|
1434
1858
|
<div style="display:flex;gap:6px"><input id=gLX class=gin value="${esc(g.labels_x||'')}" placeholder="auto: 1 2 3…" autocomplete=off spellcheck=false><input id=gLY class=gin value="${esc(g.labels_y||'')}" placeholder="auto: A B C…" autocomplete=off spellcheck=false></div>
|
|
1435
1859
|
<div id=gLfb class=gfb></div>
|
|
1436
1860
|
${(!g.labels_x&&!g.labels_y)?'<div class=gbtns style="margin-top:6px"><button id=gridLabelsAiB class=ghostw data-tip="Many drawings outline their bubble text, so the marks can’t be read deterministically. This sends a request to your AI terminal — it reads the printed marks from the source drawing and fills the labels as a contract update.">Ask AI to read the labels ▸</button></div>':''}
|
|
1861
|
+
<div class=sect style="margin-top:10px">Single lines <span style="color:var(--mut);font-weight:400;text-transform:none">· any angle</span></div>
|
|
1862
|
+
<div class=gfb>${(g.lines&&g.lines.length)?(g.lines.length+' individual line'+(g.lines.length===1?'':'s')+' · drag endpoints to adjust'):'No individual lines yet.'}</div>
|
|
1863
|
+
<div class=gbtns><button id=gridLineB class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button>${(g.lines&&g.lines.length)?'<button id=gridClearLinesB class=ghostw data-tip="Remove every individual grid line. The X/Y grid and levels stay. Undoable.">Clear single lines</button>':''}</div>
|
|
1864
|
+
${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridLinePick.a?'Pick the second point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.':'Pick the first point for the grid line — snaps to linework (<b>Alt</b> off). <b>Esc</b> cancels.')+'</div>':''}
|
|
1437
1865
|
<div class=sect style="margin-top:10px">Extension</div>
|
|
1438
1866
|
<input id=gExt class=gin style="width:110px" value="${esc(gc.fmtLen(isFinite(g.ext)?g.ext:1524))}" autocomplete=off spellcheck=false>
|
|
1439
1867
|
<div class=hint style="margin-top:3px">How far every line runs past the outermost, in plan. Drag a bubble <b>along</b> its line to override just that one.</div>
|
|
@@ -1479,7 +1907,9 @@ function renderGridPanel(p){
|
|
|
1479
1907
|
wire('gExt',(v,el)=>{const mm=gc.parseLen(v);if(!isFinite(mm)||mm<0){el.style.borderColor='#fca5a5';return;}el.style.borderColor='';if(Math.abs(mm-(isFinite(g.ext)?g.ext:1524))>0.5)edit(()=>{P.grid.ext=mm;});});
|
|
1480
1908
|
const gsh=document.getElementById('gShow');if(gsh)gsh.addEventListener('change',()=>gridSetVisible(gsh.checked));
|
|
1481
1909
|
const grx=document.getElementById('gridResetExtB');if(grx)grx.onclick=()=>{edit(()=>{delete P.grid.ends_x;delete P.grid.ends_y;});}; // drop every per-line extent override → all lines follow the global Extension again
|
|
1482
|
-
document.getElementById('
|
|
1910
|
+
document.getElementById('gridLineB').onclick=gridStartLinePick;
|
|
1911
|
+
const gcl=document.getElementById('gridClearLinesB');if(gcl)gcl.onclick=()=>{edit(()=>{delete P.grid.lines;});};
|
|
1912
|
+
document.getElementById('gridPickB').onclick=()=>{gridPick=!gridPick;gridLinePick=null;gridSetPickClass();panel();};
|
|
1483
1913
|
const r2=document.getElementById('gridReadB2');if(r2)r2.onclick=()=>gridReadFromDrawing(P.grid);
|
|
1484
1914
|
const lb=document.getElementById('gridLabelsAiB');if(lb)lb.onclick=gridAskAiLabels;
|
|
1485
1915
|
const a2=document.getElementById('gridAutoB2');if(a2)a2.onclick=()=>{const ng=gc.inferGrid(P.members,ppf);if(!ng){toast('No columns to infer a grid from');return;}ng.z=P.grid.z;ng.labels_x=P.grid.labels_x;ng.labels_y=P.grid.labels_y;ng.ext=P.grid.ext;edit(()=>{P.grid=ng;});}; // re-infer geometry, keep the user's levels/labels/extension
|
|
@@ -1491,7 +1921,7 @@ function setGeo(){document.body.classList.toggle('geo',!!geoMode);}
|
|
|
1491
1921
|
let lastCmd=null;
|
|
1492
1922
|
function setLastCmd(label,run){lastCmd={label,run};}
|
|
1493
1923
|
function anyToolActive(){
|
|
1494
|
-
if(dimMode||dimChain||dimSplitMode||geoMode||csaxisMode||gridMode||gridPick||mode==='add'||picking||cmTool)return true; // 2D tools armed (cmTool = Move/Copy)
|
|
1924
|
+
if(dimMode||dimChain||dimSplitMode||geoMode||csaxisMode||gridMode||gridPick||gridLinePick||dimStyleMode||mode==='add'||picking||cmTool)return true; // 2D tools armed (cmTool = Move/Copy)
|
|
1495
1925
|
if(view3d&&window.Steel3DView){if(window.Steel3DView.clipMode&&window.Steel3DView.clipMode())return true;const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))return true;} // 3D dim/clip armed
|
|
1496
1926
|
return false;
|
|
1497
1927
|
}
|
|
@@ -1499,11 +1929,15 @@ function repeatLast(){if(lastCmd){lastCmd.run();if(typeof toast==='function')toa
|
|
|
1499
1929
|
// nearest end → intersection: extends when the line is past the end, trims when it crosses the member. ponytail: keeps the larger piece on a deep overshoot — undo+drag if that's wrong.
|
|
1500
1930
|
// Multi: trim/extend the nearest end of EVERY given member to the (tA,tB) target line; members
|
|
1501
1931
|
// parallel to the target (no intersection) are skipped. One undo for the whole batch.
|
|
1502
|
-
function snapEndMulti(ms,tA,tB){const pv=snapshot();let n=0;
|
|
1503
|
-
for(const m of ms){
|
|
1932
|
+
function snapEndMulti(ms,tA,tB){const pv=snapshot();let n=0,skipped=0;
|
|
1933
|
+
for(const m of ms){
|
|
1934
|
+
if(isBrace(m)){skipped++;continue;} // extend/trim never moves a brace work point (it must stay on the column ℄) — matches doSplit
|
|
1935
|
+
const I=lineX(m.wp[0],m.wp[1],tA,tB);if(!I)continue;
|
|
1504
1936
|
const h=len(m.wp[0],I)<=len(m.wp[1],I)?0:1;m.wp[h]=I;m.rfi=(_wt(m.profile)==null);n++;}
|
|
1937
|
+
if(skipped)toast(n?(skipped+' brace'+(skipped>1?'s':'')+' skipped — braces can’t be extended/trimmed'):'Braces can’t be extended/trimmed — edit them from the inspector');
|
|
1505
1938
|
if(n){pushUndo(pv);render();sync3D();}return n;}
|
|
1506
|
-
function doSplit(m,pt){
|
|
1939
|
+
function doSplit(m,pt){if(isBrace(m)){toast('Braces can’t be split — edit them from the inspector');return;} // split/extend/trim disabled on braces (offset would create off-℄ WPs · Codex round-2)
|
|
1940
|
+
const pv=snapshot();ensureMeta(m);const base=JSON.parse(JSON.stringify(m));
|
|
1507
1941
|
const a=m.wp[0].slice(),b=m.wp[1].slice(),q=pt.slice(),mk=()=>({tos:null,note:'',tosDef:true,detail:''});
|
|
1508
1942
|
m.wp=[a,q];if(m.ends)m.ends=[m.ends[0],mk()]; // first half keeps its start end, fresh cut end
|
|
1509
1943
|
const c=JSON.parse(JSON.stringify(base));c.id='m'+Date.now();c.wp=[q.slice(),b];
|
|
@@ -1538,7 +1972,7 @@ function redundantDups(){return dedupeFootprintIds(P.members,dupScore);}
|
|
|
1538
1972
|
// MIRROR of server/steel-merge.ts (the tested source of truth) — keep the two in lock-step.
|
|
1539
1973
|
const MRG_END=3, MRG_ANG=3*Math.PI/180, MRG_TOS=0.5;
|
|
1540
1974
|
function _mUnit(a,b){const dx=b[0]-a[0],dy=b[1]-a[1],L=Math.hypot(dx,dy)||1;return [dx/L,dy/L];}
|
|
1541
|
-
function _mElig(m){return (m.role||'beam')==='beam'&&Array.isArray(m.wp)&&m.wp.length>=2&&typeof m.profile==='string'&&m.profile.trim()!=='';}
|
|
1975
|
+
function _mElig(m){return (m.role||'beam')==='beam'&&!isBrace(m)&&Array.isArray(m.wp)&&m.wp.length>=2&&typeof m.profile==='string'&&m.profile.trim()!=='';} // braces never merge with beams (Codex round-1)
|
|
1542
1976
|
function _mShare(a,b){for(const i of[0,1])for(const j of[0,1])if(len(a.wp[i],b.wp[j])<=MRG_END)return{aEnd:i,bEnd:j};return null;}
|
|
1543
1977
|
function _mStraight(a,b,s){const da=_mUnit(a.wp[0],a.wp[1]),db=_mUnit(b.wp[0],b.wp[1]);
|
|
1544
1978
|
if(Math.abs(da[0]*db[1]-da[1]*db[0])>Math.sin(MRG_ANG))return false; // not collinear
|
|
@@ -1559,7 +1993,7 @@ function isReversed(m){if(!m||!m.wp||m.wp.length<2)return false;
|
|
|
1559
1993
|
const dx=m.wp[1][0]-m.wp[0][0],dy=m.wp[1][1]-m.wp[0][1];if(dx===0&&dy===0)return false;
|
|
1560
1994
|
return Math.abs(dx)>=Math.abs(dy)?dx<0:dy>0;}
|
|
1561
1995
|
// Ids of the active plan's beams (not columns) drawn the wrong way — the "Reversed beams" selection.
|
|
1562
|
-
function reversedBeams(){return P.members.filter(m=>m.role!=='column'&&isReversed(m)).map(m=>m.id);}
|
|
1996
|
+
function reversedBeams(){return P.members.filter(m=>m.role!=='column'&&!isBrace(m)&&isReversed(m)).map(m=>m.id);} // braces excluded — their reverse is the inspector's swap lower/higher (Codex round-1)
|
|
1563
1997
|
function mergeCollinearJS(members){
|
|
1564
1998
|
const idx=members.map((_,i)=>i).filter(i=>_mElig(members[i]));
|
|
1565
1999
|
const adj=new Map();for(const i of idx)adj.set(i,[]);
|
|
@@ -1606,20 +2040,24 @@ function applyZoom(z,ax,ay){z=Math.max(ZMIN,Math.min(ZMAX,z));
|
|
|
1606
2040
|
function zoomCentered(z){const r=stage.getBoundingClientRect();applyZoom(z,r.left+stage.clientWidth/2,r.top+stage.clientHeight/2);}
|
|
1607
2041
|
function fitToWindow(){applyZoom(Math.min(stage.clientWidth/EXTX,stage.clientHeight/EXTY)*0.98);}
|
|
1608
2042
|
// --- duplicate the selected member(s) in place (Ctrl+D) ---
|
|
1609
|
-
function doDup(){const arr=
|
|
2043
|
+
function doDup(){const arr=sel2d();if(!arr.length)return;const o=12,pv=snapshot(),ns=new Set();
|
|
1610
2044
|
let i=0;for(const s of arr){const id='m'+Date.now()+'_'+(i++);const c=JSON.parse(JSON.stringify(s));
|
|
1611
2045
|
c.id=id;c.wp=[[s.wp[0][0]+o,s.wp[0][1]+o],[s.wp[1][0]+o,s.wp[1][1]+o]];P.members.push(c);ns.add(id);}
|
|
1612
2046
|
selIds=ns;selDimIds.clear();mode='sel';setMode();pushUndo(pv);render();}
|
|
1613
2047
|
function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'<','>':'>','&':'&','"':'"'}[c]));}
|
|
1614
2048
|
function render(){
|
|
1615
2049
|
document.body.classList.remove('snapping'); // a wholesale svg rebuild drops any #snapMark → clear the cursor-hide flag too (the next pointermove re-adds it if still snapping)
|
|
2050
|
+
buildColorRank(); // refresh the model-global colour rank before any colorFor() call below (B2 — keeps 2D hues stable across plans + matched to 3D)
|
|
1616
2051
|
if(geoMode&&(selIds.size<1||(geoMode==='split'&&selIds.size!==1))){geoMode=null;document.body.classList.remove('geo');} // Split needs exactly one member; Extend/Trim works on any selection
|
|
1617
|
-
let s=
|
|
2052
|
+
let s=overlaySvg(); // crisp vector linework (snappable) when the sheet has vectors; raster only for scanned PDFs
|
|
1618
2053
|
s+=gridSvg(); // structural grid under the linework (members/dims stay on top)
|
|
1619
2054
|
for(const sg of P.segments) s+=`<line class=seg data-seg="${sg.id}" x1="${sg.a[0]}" y1="${sg.a[1]}" x2="${sg.b[0]}" y2="${sg.b[1]}"/>`;
|
|
1620
2055
|
for(const m of P.members){const c=colorFor(m.profile);const sel=selIds.has(m.id);const fh=findHits.has(m.id);const on=sel||fh;const g=on?` style="filter:drop-shadow(0 0 3px ${c}) drop-shadow(0 0 8px ${c})"`:'';
|
|
2056
|
+
if(isBrace(m)){s+=braceSymbol(m,c,g);continue;} // a brace draws as its distinct symbol (dashed=below-floor + hi/lo arrows), not a plain line (B4)
|
|
2057
|
+
if(m.role==='column'){const pts=columnSectionPoly(m); // a column draws as its profile-section footprint, not a line
|
|
2058
|
+
if(pts){s+=`<polygon class="member${m.rfi?' rfi':''}${sel?' sel':''}${fh?' find-hit':''}" data-id="${m.id}" points="${_polyStr(pts)}" fill="${c}" stroke="${c}"${g}/>`;continue;}}
|
|
1621
2059
|
s+=`<line class="member${m.rfi?' rfi':''}${sel?' sel':''}${fh?' find-hit':''}" data-id="${m.id}" x1="${m.wp[0][0]}" y1="${m.wp[0][1]}" x2="${m.wp[1][0]}" y2="${m.wp[1][1]}" stroke="${c}"${g}/>`;}
|
|
1622
|
-
{const hsel=
|
|
2060
|
+
{const hsel=sel2d();if(hsel.length>=1){const HR=epR();for(const sm of hsel)for(let i=0;i<2;i++) s+=`<circle class="handle ${i===0?'ep-start':'ep-end'}" data-mid="${sm.id}" data-h="${i}" cx="${sm.wp[i][0]}" cy="${sm.wp[i][1]}" r="${HR}"/>`;}} // end 1 (start) yellow, end 2 (end) magenta · shown for every selected member · radius grows with zoom (epR) so it stays visible against the thick line
|
|
1623
2061
|
if((mode==='add'||(picking&&pickKind==='profile'))&&P.labels) for(const lb of P.labels){const w=Math.max(40,lb.text.length*11);
|
|
1624
2062
|
s+=`<rect class=lblhot data-prof="${esc(lb.text)}" x="${lb.disp[0]-w/2}" y="${lb.disp[1]-10}" width="${w}" height="20" rx="3"><title>${esc(lb.text)}</title></rect>`;}
|
|
1625
2063
|
if(picking&&pickKind==='detail'&&P.details) for(const d of P.details){const w=Math.max(34,d.text.length*8);
|
|
@@ -1642,8 +2080,8 @@ function render(){
|
|
|
1642
2080
|
}
|
|
1643
2081
|
// numbered badges on the selected members (1..N in selection order; coincident ones fan out so duplicates are countable)
|
|
1644
2082
|
// sized in 1/zoom units → constant on screen at any zoom (updateBadges keeps them in sync while zooming)
|
|
1645
|
-
const selM=
|
|
1646
|
-
if(selM.length>=2){const mid=m=>
|
|
2083
|
+
const selM=sel2d();
|
|
2084
|
+
if(selM.length>=2){const mid=m=>{const v=memberViewLine(m);return [(v[0][0]+v[1][0])/2,(v[0][1]+v[1][1])/2];};const grp={};const R=12/zoom,F=13/zoom; // badge sits on the DRAWN line (offset brace included)
|
|
1647
2085
|
selM.forEach((m,idx)=>{const c=mid(m),k=Math.round(c[0]/8)+','+Math.round(c[1]/8);(grp[k]=grp[k]||[]).push({idx,c});});
|
|
1648
2086
|
for(const k in grp){const a=grp[k],n=a.length;a.forEach((it,j)=>{const x=it.c[0]+(j-(n-1)/2)*R*2,y=it.c[1];const d=`data-bx="${it.c[0]}" data-fi="${j}" data-gn="${n}"`;
|
|
1649
2087
|
s+=`<circle class=numbg ${d} cx="${x}" cy="${y}" r="${R}"/><text class=numtx ${d} x="${x}" y="${y}" style="font-size:${F}px">${it.idx+1}</text>`;});}}
|
|
@@ -1651,7 +2089,7 @@ function render(){
|
|
|
1651
2089
|
s+=renderPropLabels(); // right-click property-label chips (2D); 3D labels ride the div-overlay pool
|
|
1652
2090
|
s+=renderSelLenLabels(); // on-select member-length chips (2D), gated by the ⋯ Display "Show member length" toggle
|
|
1653
2091
|
if(P.frame)s+=axisGlyphSvg(P.frame.o,P.frame.u,false); // local-axes glyph at the origin (only when a frame is set; removed on reset)
|
|
1654
|
-
svg.innerHTML=s; document.getElementById('profiles').innerHTML=profs.map(p=>`<option value="${esc(p)}">`).join(''); document.getElementById('details').innerHTML=(P.details||[]).map(d=>`<option value="${esc(d.text)}">`).join(''); stats(); panel(); updUR(); updDup(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); updGridToggle(); updLenToggle(); updDimToggle(); updCalloutToggle();
|
|
2092
|
+
svg.innerHTML=s; document.getElementById('profiles').innerHTML=profs.map(p=>`<option value="${esc(p)}">`).join(''); document.getElementById('details').innerHTML=(P.details||[]).map(d=>`<option value="${esc(d.text)}">`).join(''); stats(); panel(); updUR(); updDup(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); updGridToggle(); updLenToggle(); updDimToggle(); updCalloutToggle(); updPlToggle();
|
|
1655
2093
|
if(view3d&&window.Steel3DView){window.Steel3DView.setSelection(selIds);updateIsolateBtn();if(selIds.size&&window.Steel3DView.selectedClips&&window.Steel3DView.selectedClips().length)window.Steel3DView.setSelectedClips([]);refreshLegendSel();} // keep the 3D highlight + legend selection in sync; selecting a member clears any clip selection (exclusive)
|
|
1656
2094
|
try{updateConnCrumb();}catch(_){} // Connection Component breadcrumb follows the selection (3D-only; hidden at root)
|
|
1657
2095
|
syncPropLabelsAfterRender(); // corner-note + push labels to 3D + refresh the popup rows against the (possibly changed) selection
|
|
@@ -1666,12 +2104,11 @@ function updateBadges(){const R=12/zoom,F=13/zoom,ox=el=>(+el.dataset.fi-(+el.da
|
|
|
1666
2104
|
svg.querySelectorAll('circle.numbg').forEach(c=>{c.setAttribute('cx',(+c.dataset.bx)+ox(c));c.setAttribute('r',R);});
|
|
1667
2105
|
svg.querySelectorAll('text.numtx').forEach(t=>{t.setAttribute('x',(+t.dataset.bx)+ox(t));t.style.fontSize=F+'px';});
|
|
1668
2106
|
svg.querySelectorAll('circle.handle,circle.dimhandle').forEach(h=>h.setAttribute('r',epR()));
|
|
1669
|
-
|
|
1670
|
-
|
|
2107
|
+
// (brace arrowheads need no rescale here — they are content-unit sized, so they scale with the member
|
|
2108
|
+
// stroke exactly like the line they cap. See braceHeadPoints().)
|
|
2109
|
+
{const dg=svg.querySelector('g.dimsg');if(dg)dg.innerHTML=renderDimsInner();} // dims shrink below DIM_ZMIN (see dimSvg) so dense dims don't overlap when zoomed out (B8) — every part of a dim is zoom-derived, so rebuild the group rather than patch it
|
|
1671
2110
|
svg.querySelectorAll('circle.gridbub').forEach(c=>c.setAttribute('r',11/zoom));
|
|
1672
2111
|
svg.querySelectorAll('text.gridtx').forEach(t=>t.style.fontSize=(12/zoom)+'px');
|
|
1673
|
-
svg.querySelectorAll('rect.dimchip').forEach(r=>{const w=(+r.dataset.w)/zoom,h=(+r.dataset.h)/zoom;
|
|
1674
|
-
r.setAttribute('width',w);r.setAttribute('height',h);r.setAttribute('x',(+r.dataset.cx)-w/2);r.setAttribute('y',(+r.dataset.cy)-h/2);});
|
|
1675
2112
|
// property-label chips: recompute size + stacked screen offset from the baked anchor (ax,ay) + per-row screen
|
|
1676
2113
|
// offset (off) so they stay constant on screen while zooming (like dim chips) — AND re-apply the zoom
|
|
1677
2114
|
// threshold live (data-mlen × zoom), so zooming reveals/hides labels as members cross ~24px on screen.
|
|
@@ -1686,7 +2123,12 @@ function updateBadges(){const R=12/zoom,F=13/zoom,ox=el=>(+el.dataset.fi-(+el.da
|
|
|
1686
2123
|
mlG.querySelectorAll('text.mlentx').forEach(t=>{const show=(+t.dataset.mlen)*zoom>=PLABEL_MIN_PX;t.style.display=show?'':'none';t.setAttribute('x',(+t.dataset.mx)+(+t.dataset.nx)*(+t.dataset.base)/zoom);t.setAttribute('y',(+t.dataset.my)+(+t.dataset.ny)*(+t.dataset.base)/zoom);t.style.fontSize=(11/zoom)+'px';});}}
|
|
1687
2124
|
const cg=svg.querySelector('g.csglyph');if(cg&&P.frame)cg.outerHTML=axisGlyphSvg(P.frame.o,P.frame.u,false);} // glyph is sized in 1/zoom → regenerate on zoom (like the dim chips)
|
|
1688
2125
|
function updateHandles(m){svg.querySelectorAll(`circle.handle[data-mid="${m.id}"]`).forEach(h=>{const i=+h.dataset.h;h.setAttribute('cx',m.wp[i][0]);h.setAttribute('cy',m.wp[i][1]);});}
|
|
1689
|
-
function updateLine(m){
|
|
2126
|
+
function updateLine(m){
|
|
2127
|
+
if(isBrace(m)){const g=svg.querySelector(`g.bracesym[data-id="${m.id}"]`); // a brace is a symbol group — re-serialize the whole glyph so it follows the drag live (moves off true WPs, redraws offset)
|
|
2128
|
+
if(g){const glow=selIds.has(m.id)||findHits.has(m.id);const c=colorFor(m.profile);g.outerHTML=braceSymbol(m,c,glow?` style="filter:drop-shadow(0 0 3px ${c}) drop-shadow(0 0 8px ${c})"`:'');}return;}
|
|
2129
|
+
if(m.role==='column'){const pg=svg.querySelector(`polygon.member[data-id="${m.id}"]`); // columns are polygons — re-derive their footprint from the moved centroid so they follow the drag live
|
|
2130
|
+
if(pg){const pts=columnSectionPoly(m);if(pts)pg.setAttribute('points',_polyStr(pts));}return;}
|
|
2131
|
+
const ln=svg.querySelector(`line.member[data-id="${m.id}"]`);
|
|
1690
2132
|
if(ln){ln.setAttribute('x1',m.wp[0][0]);ln.setAttribute('y1',m.wp[0][1]);ln.setAttribute('x2',m.wp[1][0]);ln.setAttribute('y2',m.wp[1][1]);}}
|
|
1691
2133
|
function stats(){
|
|
1692
2134
|
document.getElementById('mc').textContent=P.members.length;
|
|
@@ -1782,6 +2224,8 @@ function panel(){
|
|
|
1782
2224
|
const p=document.getElementById('panel');
|
|
1783
2225
|
if(!selDimIds.size||!dimsVisible)dimSplitMode=false;document.body.classList.toggle('dimsplit',dimSplitMode); // split mode is meaningless without a (visible) dim selected — also disarms when dims are hidden
|
|
1784
2226
|
if(gridMode){renderGridPanel(p);return;}
|
|
2227
|
+
if(dimStyleMode&&(selIds.size||selDimIds.size))dimStyleMode=false; // anything that selects (Ctrl+A, Duplicates, Reversed beams, a legend/RFI locate…) takes the panel back from the style pane — one guard instead of a disarm call at every such command
|
|
2228
|
+
if(dimStyleMode){renderDimStylePanel(p);return;}
|
|
1785
2229
|
if(csaxisMode){p.innerHTML=`<span class=badge>Set local axes</span>
|
|
1786
2230
|
<div class=hint id=csHint 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>
|
|
1787
2231
|
<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;}
|
|
@@ -1808,23 +2252,49 @@ function panel(){
|
|
|
1808
2252
|
document.getElementById('dimChainB').onclick=()=>toggleDimChain();
|
|
1809
2253
|
return;}
|
|
1810
2254
|
if(selDimIds.size&&!selIds.size&&!dimMode&&mode==='sel'){const one=selDimIds.size===1?P.dims.find(x=>x.id===[...selDimIds][0]):null;
|
|
2255
|
+
const dsel=P.dims.filter(d=>selDimIds.has(d.id));
|
|
2256
|
+
const shared=k=>{const v=agg(dsel,d=>dimStyle(d)[k]);return v===VARIES?null:v;}; // null ⇒ the selection disagrees → light no button, leave the checkbox indeterminate
|
|
2257
|
+
const endV=shared('end'),placeV=shared('place'),bgV=shared('bg');
|
|
2258
|
+
const nOver=dsel.filter(dimHasOverride).length; // >0 ⇒ offer the way back to the model-global default
|
|
1811
2259
|
p.innerHTML=`<span class=badge>Dimension${selDimIds.size>1?'s · '+selDimIds.size:''}</span>
|
|
1812
|
-
${one?`<div class=hint style="margin-top:8px">Length <b>${esc(dimValueText(dimGeo(one.a,one.b,one.axis,one.off).px))}</b> · ${({free:'Free (aligned)',x:'X (horizontal)',y:'Y (vertical)'})[one.axis]}</div>`:''}
|
|
2260
|
+
${one?`<div class=hint style="margin-top:8px">Length <b>${esc(dimValueText(dimGeo(one.a,one.b,one.axis,one.off,one.rot).px))}</b> · ${({free:'Free (aligned)',x:'X (horizontal)',y:'Y (vertical)'})[one.axis]}</div>`:''}
|
|
2261
|
+
${(endV&&placeV&&bgV!==null)?dimStylePreview({end:endV,bg:bgV,place:placeV}):''}
|
|
2262
|
+
<div class=sect style="margin-top:12px">Ends</div>
|
|
2263
|
+
<div class="seg2 segico">${DIM_ENDS.map(k=>`<button data-dend="${k}" class="${endV===k?'on':''}" data-tip="${esc(DIM_END_TIP[k])}">${DIM_END_GLYPH[k]}<span>${DIM_END_LBL[k]}</span></button>`).join('')}</div>
|
|
2264
|
+
<div class=sect style="margin-top:12px">Label</div>
|
|
2265
|
+
<div class="seg2 segico"><button data-dplace=above class="${placeV==='above'?'on':''}" data-tip="Text sits above the dimension line — the drafting default">${DIM_PLACE_GLYPH.above}<span>Above line</span></button><button data-dplace=on class="${placeV==='on'?'on':''}" data-tip="Text sits on the dimension line; the line breaks around it">${DIM_PLACE_GLYPH.on}<span>On line</span></button></div>
|
|
2266
|
+
<label class=gck style="margin-top:10px" data-tip="Draw a filled chip behind the text. Off = bare text with a halo, so the drawing stays visible."><input type=checkbox id=dimBg ${bgV===true?'checked':''}><span>Label background</span></label>
|
|
2267
|
+
${nOver?`<button id=dimUseDef class=ghostw style="margin-top:10px" data-tip="Drop this dimension's own style so it follows the model defaults (⋯ → Display → Dimension style…). Undoable.">Follow the defaults</button>`
|
|
2268
|
+
:`<div class=hint style="margin-top:8px">Following the model defaults. Change them in <b>⋯ → Display → Dimension style</b>.</div>`}
|
|
1813
2269
|
<div class=sect style="margin-top:12px">Edit</div>
|
|
1814
|
-
<div class=seg2><button id=dimSplitB class="${dimSplitMode?'on':''}" data-tip="
|
|
1815
|
-
<div class=hint style="margin-top:8px">${dimSplitMode?'Click
|
|
2270
|
+
<div class=seg2><button id=dimSplitB class="${dimSplitMode?'on':''}" data-tip="Split / Extend (S) — click between the dimension's ends to split it, or beyond an end to add a new segment that continues it. Esc ends.">Split / Extend</button></div>
|
|
2271
|
+
<div class=hint style="margin-top:8px">${dimSplitMode?'Click <b>between</b> the ends to split, <b>beyond</b> an end to extend — keep clicking to chain more. <b>Alt</b> = no snap · <b>Esc</b> ends.':'Drag an end handle to re-measure · <b>Del</b> removes · <b>Esc</b> deselects.'}</div>`;
|
|
2272
|
+
const setAll=fn=>edit(()=>{for(const d of P.dims)if(selDimIds.has(d.id))fn(d);}); // a style edit applies to every selected dim, and rides edit() → undoable
|
|
2273
|
+
p.querySelectorAll('button[data-dend]').forEach(b=>b.onclick=()=>setAll(d=>{d.end=b.dataset.dend;}));
|
|
2274
|
+
p.querySelectorAll('button[data-dplace]').forEach(b=>b.onclick=()=>setAll(d=>{d.place=b.dataset.dplace;}));
|
|
2275
|
+
const cb=document.getElementById('dimBg');cb.indeterminate=(bgV===null);cb.onchange=e=>setAll(d=>{d.bg=e.target.checked;});
|
|
2276
|
+
{const ud=document.getElementById('dimUseDef');if(ud)ud.onclick=()=>setAll(d=>{delete d.end;delete d.bg;delete d.place;});}
|
|
1816
2277
|
document.getElementById('dimSplitB').onclick=()=>toggleDimSplit();
|
|
1817
2278
|
return;}
|
|
1818
2279
|
if(mode==='add'){
|
|
2280
|
+
const pk=picking&&pickKind==='profile';
|
|
1819
2281
|
p.innerHTML=`<span class=badge>Add member</span>
|
|
1820
2282
|
<div class=sect>Current profile</div>
|
|
1821
|
-
<input id=addProf class=combo data-src=profiles placeholder="type or pick (e.g. W16X26)" value="${esc(addProfile)}" autocomplete=off>
|
|
1822
|
-
<div class=hint id=pickHint style="margin-top:4px;font-style:italic"
|
|
2283
|
+
<div style="display:flex;gap:6px"><input id=addProf class=combo data-src=profiles placeholder="type or pick (e.g. W16X26)" value="${esc(addProfile)}" style="flex:1" autocomplete=off><button id=addPick class="ghost${pk?' on':''}" data-tip="Pick profile by clicking a label in the drawing">⌖ pick</button></div>
|
|
2284
|
+
<div class=hint id=pickHint style="margin-top:4px;font-style:italic${pk?';color:var(--brand)':''}">${pk?'Click a profile label in the drawing…':'or click a label in the drawing'}</div>
|
|
2285
|
+
${memberTypeField('mTypeA',[{memberType:addType}])}
|
|
1823
2286
|
<div class=divrow><hr></div>
|
|
1824
2287
|
<div class=sect>Draw a member</div>
|
|
1825
|
-
<div class=hint
|
|
2288
|
+
<div class=hint id=drawHint>${view3d?'✏️ Click the start then the end — both land on the <b>working plane</b>. A near-vertical pick pair becomes a column. <b>Shift</b> = straight, <b>Esc</b> = exit.':drawHintText()}</div>`;
|
|
1826
2289
|
const ap=document.getElementById('addProf');
|
|
1827
2290
|
ap.oninput=ap.onchange=e=>{addProfile=e.target.value.toUpperCase().replace(/ /g,'');};
|
|
2291
|
+
document.getElementById('addPick').onclick=()=>{picking=!pk;pickKind='profile';pickEnd=null;render();}; // labels are already hot in Add mode — this arms the same highlighted "pick a label" state as the member inspector
|
|
2292
|
+
document.getElementById('mTypeA').onchange=e=>{const v=e.target.value;
|
|
2293
|
+
if(!normMemberTypeKey(v)){e.target.value=memberTypeLabel(addType);return;} // blank or punctuation-only ("!!!") normalises to no key → mints nothing, so don't burn an undo step on it
|
|
2294
|
+
const set=()=>{const k=memberTypeFromInput(v);if(k)addType=k;};
|
|
2295
|
+
memberTypeKnownLabel(v)?set():edit(set); // a brand-new type mutates the contract → undoable + saved
|
|
2296
|
+
e.target.value=memberTypeLabel(addType);
|
|
2297
|
+
const h=document.getElementById('drawHint');if(h&&!view3d)h.innerHTML=drawHintText();};
|
|
1828
2298
|
return;}
|
|
1829
2299
|
// A placed detail image (Slice 4) selected — its own inspector: Position / Orientation / Appearance +
|
|
1830
2300
|
// "Ask AI to build this" (records a modify request) + Remove. Every field mutation rides edit() → undoable.
|
|
@@ -1963,7 +2433,7 @@ function panel(){
|
|
|
1963
2433
|
return;
|
|
1964
2434
|
}}
|
|
1965
2435
|
const arr=selArr();
|
|
1966
|
-
if(arr.length===0){p.innerHTML='<h3 style="display:flex;justify-content:space-between;align-items:center">Legend'+(Object.keys(C.profile_colors).length?'<button class=ghost id=resetCols style="font-size:10px;padding:1px 6px">reset colours</button>':'')+'</h3><div class=legend>'+profs.filter(pr=>P.members.some(mm=>mm.profile===pr)).map(pr=>`<span><input type=color class=swc data-prof="${esc(pr)}" value="${colorFor(pr)}" data-tip="Click to recolour ${esc(pr)}">${esc(pr)}</span>`).join('')+'</div><div class=hint style="margin-top:12px">Click a member to edit; <b>Ctrl</b>/<b>Shift+click</b> to add/remove; drag an empty area to <b>box-select</b> — <b>left→right</b> grabs fully-enclosed, <b>right→left</b> grabs touched (Ctrl/Shift adds). Drag a selected line to move it (all selected move together) — it snaps onto nearby grid/endpoints; drag an end dot to adjust — also snaps (<b>Alt</b> off). Hold <b>Shift</b> to keep it straight (H/V). <b>Ctrl+D</b> duplicate, <b>Ctrl+Z/Y</b> undo/redo, <b>Del</b> delete, <b>Esc</b> deselect. <b>
|
|
2436
|
+
if(arr.length===0){p.innerHTML='<h3 style="display:flex;justify-content:space-between;align-items:center">Legend'+(Object.keys(C.profile_colors).length?'<button class=ghost id=resetCols style="font-size:10px;padding:1px 6px">reset colours</button>':'')+'</h3><div class=legend>'+profs.filter(pr=>P.members.some(mm=>mm.profile===pr)).map(pr=>`<span><input type=color class=swc data-prof="${esc(pr)}" value="${colorFor(pr)}" data-tip="Click to recolour ${esc(pr)}">${esc(pr)}</span>`).join('')+'</div><div class=hint style="margin-top:12px">Click a member to edit; <b>Ctrl</b>/<b>Shift+click</b> to add/remove; drag an empty area to <b>box-select</b> — <b>left→right</b> grabs fully-enclosed, <b>right→left</b> grabs touched (Ctrl/Shift adds). Drag a selected line to move it (all selected move together) — it snaps onto nearby grid/endpoints; drag an end dot to adjust — also snaps (<b>Alt</b> off). Hold <b>Shift</b> to keep it straight (H/V). <b>Ctrl+D</b> duplicate, <b>Ctrl+Z/Y</b> undo/redo, <b>Del</b> delete, <b>Esc</b> deselect. <b>Scroll</b> zoom, <b>middle-drag</b> pan, <b>Home</b> fit. Short even dashes = RFI (size unresolved, e.g. MF). A line with <b>arrowheads</b> is a <b>brace</b> — solid = above the floor, long–short dashes = below; the double arrowhead marks its lower end.</div>'+
|
|
1967
2437
|
'<div style="border-top:1px solid var(--line);margin-top:12px;padding-top:12px"><div class=sect>Project defaults</div>'+
|
|
1968
2438
|
'<div class=hint style="margin:0 0 6px;font-size:11px">Level <b>'+esc(fmtFtIn(defaultTOS))+'</b> ('+esc(P.sheet)+'). '+((P.tos_callouts&&P.tos_callouts.length)?'Per-zone T.O. STEEL callouts from the drawing applied to each member; ':'')+'ends ticked <b>default</b> follow the level.</div>'+
|
|
1969
2439
|
'<div class=elab>Default TOS</div><input id=defTos inputmode=decimal placeholder="5 3/4" · 1'-0 1/4"" value="'+esc(fmtFtIn(defaultTOS))+'"><span class=edec>'+esc(fmtDecIn(defaultTOS))+'</span>'+
|
|
@@ -2001,18 +2471,20 @@ function panel(){
|
|
|
2001
2471
|
`<div class=divrow><hr><button class=ghost id=matchEnds>Match → both ends (each)</button><hr></div>`+
|
|
2002
2472
|
`<div class=sect>${dotE}End</div>${mTos('tosB','TOS',s1)}${mNote('ntB',s1)}${mDet('dtB',s1)}`;}
|
|
2003
2473
|
const posA=!allCol?agg(beams,m=>posDefault(m)):null;
|
|
2474
|
+
const rotAgg=agg(arr,m=>((((+m.rot||0)%360)+360)%360)); // shared rotation, or VARIES
|
|
2004
2475
|
p.innerHTML=`<h3>${arr.length} members selected</h3>
|
|
2005
2476
|
<div class="row hint" style="margin-top:0">Edits apply to <b>all ${arr.length}</b> selected · a blank <b>Varies</b> field is left unchanged.</div>
|
|
2006
2477
|
<div class=row><label>Profile</label><input id=pf class=combo data-src=profiles placeholder="${VV(profAgg)?'Varies':''}" value="${VV(profAgg)?'':esc(profAgg||'')}" autocomplete=off></div>
|
|
2007
|
-
|
|
2008
|
-
<div class="seg2 mtype" id=mTypeM style="margin-top:6px" data-tip="Set member type for all selected — drives legend grouping">${MEMBER_TYPES.map(t=>`<button data-mtype="${t.k}" class="${arr.every(x=>memberTypeOf(x)===t.k)?'on':''}">${t.label}</button>`).join('')}</div>
|
|
2478
|
+
${memberTypeField('mTypeM',arr)}
|
|
2009
2479
|
${(!allBeam&&!allCol)?`<div class=hint style="margin-top:4px">Mixed — ${beams.length} beam${beams.length>1?'s':''}, ${cols.length} column${cols.length>1?'s':''}</div>`:''}
|
|
2010
2480
|
<div class="row hint">Total length <b>${totalL} ft</b>${totalW!=null?` · <b>${totalW.toLocaleString()} lb</b>`:''}${dupSel?` · <span style="color:#fca5a5">${dupSel} duplicate${dupSel>1?'s':''}</span> (overlap a kept member — deleting these dedupes)`:''}</div>
|
|
2011
2481
|
<div class=row><button class=ghostw id=verifyBtn${allVerified?' style="border-color:#166534;color:#86efac"':''}>${allVerified?'✓ All verified — click to unverify':'Mark all verified'}</button></div>
|
|
2012
2482
|
${elev}
|
|
2013
|
-
${!allCol?`<div class=divrow><hr><span class=sect style="margin:0">Profile
|
|
2014
|
-
<div class=hint style="margin:0 0 6px">Where the section sits on the reference line (beams) — like Tekla.</div>
|
|
2483
|
+
${!allCol?`<div class=divrow><hr><span class=sect style="margin:0" data-tip="Where the section sits on the reference line (beams). Top = top-of-steel; Middle = centroid; Bottom = underside.">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
2015
2484
|
<div class=seg2 style="margin-top:0"><button id=posTop class="${posA==='top'?'on':''}">Top</button><button id=posMid class="${posA==='middle'?'on':''}">Middle</button><button id=posBot class="${posA==='bottom'?'on':''}">Bottom</button></div>`:''}
|
|
2485
|
+
<div class=divrow><hr><span class=sect style="margin:0" data-tip="Spin every selected section about its reference line. 0° = as drawn. Blank = leave each unchanged; normalised to ±360°.">Profile Rotation <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
2486
|
+
<div class=detrow><label class=detf><span>Angle °</span><input id=detRotZ inputmode=decimal placeholder="${rotAgg===VARIES?'Varies':''}" value="${rotAgg===VARIES?'':esc(String(Number(rotAgg)||0))}" autocomplete=off></label></div>
|
|
2487
|
+
<div class=seg2 style="margin-top:6px"><button id=rot0>0°</button><button id=rot90>90°</button><button id=rot180>180°</button><button id=rot270>270°</button></div>
|
|
2016
2488
|
<div class=divrow><hr><span class=sect style="margin:0">Modify geometry</span><hr></div>
|
|
2017
2489
|
<div class=seg2 style="margin-top:0"><button id=geoEL class="${geoMode==='el'?'on':''}">Extend / Trim all</button></div>
|
|
2018
2490
|
<div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — the nearest end of <b>every</b> selected member snaps to where it meets that line.':'<b>Extend/Trim</b> (E) every selected member\'s nearest end to one line. <b>Esc</b> cancels.'}</div>
|
|
@@ -2020,16 +2492,19 @@ function panel(){
|
|
|
2020
2492
|
<div class="row f"><button class=danger id=del>Delete selected (${arr.length})</button></div>`;
|
|
2021
2493
|
// wiring — every commit applies to the whole selection; a blank field is a no-op (leaves each member's own value).
|
|
2022
2494
|
document.getElementById('pf').onchange=e=>{const v=e.target.value.toUpperCase().replace(/ /g,'');if(!v)return;edit(()=>{for(const m of selArr()){m.profile=v;m.rfi=(_wt(v)==null);}if(!profs.includes(v)){profs.push(v);profs.sort();}});};
|
|
2023
|
-
document.
|
|
2024
|
-
document.getElementById('rBeam').onclick=()=>edit(()=>{for(const m of selArr())if(m.role==='column'){m.role='beam';ensureMeta(m);}});
|
|
2025
|
-
document.getElementById('rCol').onclick=()=>edit(()=>{for(const m of selArr())if(m.role!=='column'){m.role='column';ensureMeta(m);}});
|
|
2495
|
+
document.getElementById('mTypeM').onchange=e=>{const v=e.target.value;if(!normMemberTypeKey(v)){e.target.value=memberTypeValueFor(selArr());return;}edit(()=>{const k=memberTypeFromInput(v);if(!k)return;applyMemberType(selArr(),k);});}; // type owns Column-vs-beam-style role and legend category
|
|
2026
2496
|
document.getElementById('verifyBtn').onclick=()=>edit(()=>{const v=!allVerified;for(const m of selArr())m.verified=v;});
|
|
2027
2497
|
{const _gel=document.getElementById('geoEL');if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};}
|
|
2028
|
-
{const _sw=document.getElementById('swapEnds');if(_sw)_sw.onclick=()=>
|
|
2029
|
-
document.getElementById('del').onclick=()=>edit(()=>{
|
|
2498
|
+
{const _sw=document.getElementById('swapEnds');if(_sw)_sw.onclick=()=>swapSelectionEnds();} // reverse start↔end for the whole selection (2D + 3D via render+sync3D); braces excluded, and it owns its edit()/toast
|
|
2499
|
+
document.getElementById('del').onclick=()=>edit(()=>{for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));selIds.clear();if(selDimIds.size){P.dims=P.dims.filter(d=>!selDimIds.has(d.id));selDimIds.clear();}}); // selection spans sheets → remove from every plane; a mixed marquee also holds dims (active sheet) — remove them too (matches keyboard Delete)
|
|
2030
2500
|
{const sp=v=>edit(()=>{for(const m of selArr())if(m.role!=='column')m.position=v;});
|
|
2031
2501
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
2032
2502
|
if(_pt)_pt.onclick=()=>sp('top');if(_pm)_pm.onclick=()=>sp('middle');if(_pb)_pb.onclick=()=>sp('bottom');}
|
|
2503
|
+
// Rotation — apply one angle to every selected member's section (blank input = no-op). Normalised (-360,360).
|
|
2504
|
+
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{for(const m of selArr())m.rot=r;});};
|
|
2505
|
+
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>{if(e.target.value.trim()==='')return;setRot(e.target.value);};
|
|
2506
|
+
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
2507
|
+
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
2033
2508
|
// elevation wiring: a blank commit is skipped (Varies = unchanged); the "default" checkbox shows indeterminate when mixed.
|
|
2034
2509
|
const wMTos=(id,os)=>{const ck=document.getElementById(id+'_ck');if(ck){if(agg(os,o=>o.tosDef!==false)===VARIES)ck.indeterminate=true;ck.onchange=e=>edit(()=>{for(const o of os){o.tosDef=e.target.checked;if(o.tosDef)o.tos=defaultTOS;}});}
|
|
2035
2510
|
const inp=document.getElementById(id);if(inp)inp.onchange=e=>{const t=e.target.value.trim();if(!t)return;edit(()=>{const v=parseLen(t);for(const o of os){o.tos=v;o.tosDef=false;}});};};
|
|
@@ -2040,7 +2515,14 @@ function panel(){
|
|
|
2040
2515
|
else if(allBeam){const s0=beams.map(m=>m.ends[0]),s1=beams.map(m=>m.ends[1]);
|
|
2041
2516
|
wMTos('tosA',s0);wMText('ntA',s0,(o,v)=>o.note=v);wMText('dtA',s0,(o,v)=>o.detail=v);
|
|
2042
2517
|
wMTos('tosB',s1);wMText('ntB',s1,(o,v)=>o.note=v);wMText('dtB',s1,(o,v)=>o.detail=v);
|
|
2043
|
-
|
|
2518
|
+
// Braces are skipped: copying end0's TOS onto end1 would FLATTEN a brace's slope (and re-derive its
|
|
2519
|
+
// lower/higher arrowheads to the tie default) — silently, from a mixed box-select. (code review)
|
|
2520
|
+
// edit() pushes undo unconditionally, so an all-brace selection must not enter it (Codex round-4).
|
|
2521
|
+
{const me=document.getElementById('matchEnds');if(me)me.onclick=()=>{
|
|
2522
|
+
const sel=selArr().filter(m=>m.role!=='column'), targets=sel.filter(m=>!isBrace(m)), sk=sel.length-targets.length;
|
|
2523
|
+
if(targets.length)edit(()=>{for(const m of targets)
|
|
2524
|
+
m.ends[1]={tos:m.ends[0].tos,note:m.ends[0].note,tosDef:m.ends[0].tosDef,detail:m.ends[0].detail,conn:m.ends[0].conn,connVerified:m.ends[0].connVerified};});
|
|
2525
|
+
if(sk)toast(sk+' brace'+(sk>1?'s':'')+' skipped — matching ends would flatten the slope its arrows encode');};}}
|
|
2044
2526
|
return;}
|
|
2045
2527
|
const m=ensureMeta(arr[0]), wpf=_wt(m.profile), L=_lenFt(m).toFixed(1), col=(m.role==='column'), pos=posDefault(m);
|
|
2046
2528
|
const _lvl=({'S-202':'second','S-203':'roof'})[P.sheet];
|
|
@@ -2062,7 +2544,7 @@ function panel(){
|
|
|
2062
2544
|
const elev = col
|
|
2063
2545
|
? `<div class="sect f">Elevation</div>${ftFld('bos',dotS+'Bottom (BOS)',m.col.bos)}${tosFld('tosC',dotE+'Top (TOS)',m.col)}${cFld('cnC',m.col)}${fb(m.col,nin('ntC',m.col.note)+dFld('dtC',m.col))}`
|
|
2064
2546
|
: `<div class="sect f">${dotS}Start</div>${tosFld('tosA','TOS',m.ends[0])}${cFld('cnA',m.ends[0])}${fb(m.ends[0],nin('ntA',m.ends[0].note)+dFld('dtA',m.ends[0]))}
|
|
2065
|
-
|
|
2547
|
+
${isBrace(m)?'':`<div class=divrow><hr><button class=ghost id=matchEnds>Match → both ends</button><hr></div>`}
|
|
2066
2548
|
<div class=sect>${dotE}End</div>${tosFld('tosB','TOS',m.ends[1])}${cFld('cnB',m.ends[1])}${fb(m.ends[1],nin('ntB',m.ends[1].note)+dFld('dtB',m.ends[1]))}`;
|
|
2067
2549
|
const bpj=col?(C.joints||[]).find(j=>j&&j.kind==='base-plate'&&j.main===m.id):null; // this column's base-plate joint, if detailed
|
|
2068
2550
|
const pFld=(key,label,ph,unit)=>{const raw=bpj&&bpj.params&&bpj.params[key]!=null?bpj.params[key]:null;const val=raw==null?'':(unit==='mm'?esc(fmtFtIn(Number(raw)/25.4)):esc(String(raw)));return `<div class=elab>${label}</div><input id=bp_${key} inputmode=decimal placeholder="${esc(ph)}" value="${val}" autocomplete=off>${unit&&unit!=='mm'?`<span class=edec>${unit}</span>`:''}`;}; // mm params shown/entered in ft-in
|
|
@@ -2097,36 +2579,65 @@ function panel(){
|
|
|
2097
2579
|
const spSect=spjs.length?`<div class=hint style="margin:8px 0 0">${spAllAuto?'Auto-added — millimetres; empty = engine default. <b>Clearance</b> = the gap (≈½–¾") so the beam clears the support; <b>Web side</b> picks which face of the web the plate laps. Clear all via <b>Clear shear plates</b> in the toolbar (AI-tuned plates are kept).':'Tune this end's shear plate — millimetres; empty = engine default. <b>Clearance</b> = the gap (≈½–¾") so the beam clears the support; <b>Web side</b> picks which face of the web the plate laps.'}</div>${spjs.map(spBlock).join('')}`:'';
|
|
2098
2580
|
const _cps=(!col&&copesByMember[m.id])?copesByMember[m.id]:[]; // auto cope(s) on this beam (from the rendered scene)
|
|
2099
2581
|
const copeSect=_cps.length?`<div class=divrow><hr><span class=sect style="margin:0">Cope (auto)</span><hr></div><div class=hint style="margin:0 0 2px">${_cps.map(esc).join(' · ')} — auto, clash-driven so the beam clears the support.</div>`:'';
|
|
2582
|
+
const rotN=((((+m.rot||0)%360)+360)%360); // [0,360) → drives the quick-chip highlight
|
|
2583
|
+
const rotDisp=Number((((+m.rot||0)%360)).toFixed(2));// signed (-360,360), cleaned, shown in the input
|
|
2584
|
+
const br=isBrace(m), brc=(m.brace||{}); // B4 brace controls (Brace type / Position / Offset / swap lower↔higher)
|
|
2585
|
+
const braceSect=!br?'':`<div class=divrow><hr><span class=sect style="margin:0">Brace</span><hr></div>
|
|
2586
|
+
<div class=elab>Brace type</div>
|
|
2587
|
+
<div class=seg2 style="margin-top:0"><button id=brLat class="${brc.type==='lateral'?'on':''}">Lateral</button><button id=brVert class="${brc.type!=='lateral'?'on':''}">Vertical</button></div>
|
|
2588
|
+
${brc.type==='lateral'?'<div class=hint style="margin:6px 0 0">A lateral brace runs between beams — it is drawn at its true work points and is never offset.</div>':`<div class=elab style="margin-top:7px">Position</div>
|
|
2589
|
+
<div class=seg2 style="margin-top:0"><button id=brAbove class="${brc.floor!=='below'?'on':''}" data-tip="Solid line — brace above the floor">Above ─</button><button id=brBelow class="${brc.floor==='below'?'on':''}" data-tip="Dashed line — brace below the floor">Below ┄</button></div>
|
|
2590
|
+
<div class=elab style="margin-top:7px">Offset</div>
|
|
2591
|
+
<div style="display:flex;gap:6px"><input id=brOff inputmode=decimal placeholder="0 (on the column ℄)" value="${brc.offset?esc(fmtFtIn(brc.offset)):''}" style="flex:1"><button id=brFlip class=ghost data-tip="Draw the symbol on the other side of the work-point line">⇄</button></div>
|
|
2592
|
+
<span class=edec>how far the SYMBOL is drawn off the work points — the brace itself never moves. Sign is relative to ${dotS}start → ${dotE}end; <b>⇄</b> flips the side.</span>`}
|
|
2593
|
+
<div class=row><button class=ghostw id=brSwap data-tip="Flip which end is the lower (double-arrow) end — display only, no geometry change">⇄ Swap lower ↔ higher end</button>
|
|
2594
|
+
<div class=hint style="margin:4px 0 0">Changes which end shows the double arrowhead. <b>Display only</b> — no geometry moves.</div></div>
|
|
2595
|
+
<div class=hint style="margin:8px 0 0">Split / Extend / Trim don't apply to a brace — drag an end handle to move a work point, or set the Offset above.</div>`;
|
|
2100
2596
|
p.innerHTML=`<h3>Member ${esc(m.id)}</h3>
|
|
2101
2597
|
<div class=row><label>Profile</label><div style="display:flex;gap:6px"><input id=pf class=combo data-src=profiles value="${esc(m.profile)}" style="flex:1" autocomplete=off><button id=pickProf class="ghost${(picking&&pickKind==='profile')?' on':''}" data-tip="Pick profile by clicking a label in the drawing">⌖ pick</button></div>${(picking&&pickKind==='profile')?'<div class="hint" style="margin-top:4px;font-style:italic;color:var(--brand)">Click a profile label in the drawing…</div>':(picking&&pickKind==='detail')?'<div class="hint" style="margin-top:4px;font-style:italic;color:#a855f7">Click a detail callout in the drawing…</div>':''}</div>
|
|
2102
|
-
|
|
2103
|
-
|
|
2598
|
+
${memberTypeField('mTypeS',[m])}
|
|
2599
|
+
${braceSect}
|
|
2104
2600
|
<div class="row hint">Length <b>${L} ft</b> · ${wpf==null?'<span class=pill style="background:#7f1d1d">RFI — size unresolved</span>':'Weight <b>'+(_lenFt(m)*wpf).toFixed(0)+' lb</b> · '+wpf+' lb/ft'}</div>
|
|
2105
2601
|
<div class=row><button class=ghostw id=verifyBtn${m.verified?' style="border-color:#166534;color:#86efac"':''} data-tip="Mark this member human-confirmed → 100% in the confidence report">${m.verified?'✓ Verified — human-confirmed':'Mark verified'}</button></div>
|
|
2106
2602
|
${mfSug.length?`<div class="row" style="border:1px solid #a855f7;border-radius:6px;padding:7px 8px;background:rgba(168,85,247,.07)"><div class=elab style="color:#c4b5fd;margin:0">Moment-frame girder · ${_lvl==='roof'?'roof':'2nd floor'} (from Frames)</div><div style="display:flex;flex-wrap:wrap;gap:5px;margin-top:5px">${mfSug.map(s=>`<button class="ghost mfsug${s===m.profile?' on':''}" data-s="${esc(s)}">${esc(s)}</button>`).join('')}</div></div>`:''}
|
|
2107
2603
|
${elev}
|
|
2108
2604
|
${bpSect}${spSect}${copeSect}
|
|
2109
|
-
${col?'':`<div class=divrow><hr><span class=sect style="margin:0">Profile
|
|
2110
|
-
<div class=hint style="margin:0 0 6px">Where the section sits on the reference line (between the end dots) — like Tekla. Top = top-of-steel (dots on the top flange).</div>
|
|
2605
|
+
${col?'':`<div class=divrow><hr><span class=sect style="margin:0" data-tip="Where the section sits on the reference line (between the end dots). Top = top-of-steel (dots on the top flange); Middle = centroid; Bottom = underside.">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
2111
2606
|
<div class=seg2 style="margin-top:0"><button id=posTop class="${pos==='top'?'on':''}">Top</button><button id=posMid class="${pos==='middle'?'on':''}">Middle</button><button id=posBot class="${pos==='bottom'?'on':''}">Bottom</button></div>`}
|
|
2112
|
-
<div class=divrow><hr><span class=sect style="margin:0">
|
|
2607
|
+
<div class=divrow><hr><span class=sect style="margin:0" data-tip="Spin the section around the reference line (the work-line between the end dots). 0° = as drawn; the axis is fixed — this only changes which way the section faces. Any angle; normalised to ±360°.">Profile Rotation <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
2608
|
+
<div class=detrow><label class=detf><span>Angle °</span><input id=detRotZ inputmode=decimal value="${rotDisp}" autocomplete=off></label></div>
|
|
2609
|
+
<div class=seg2 style="margin-top:6px"><button id=rot0 class="${rotN===0?'on':''}">0°</button><button id=rot90 class="${rotN===90?'on':''}">90°</button><button id=rot180 class="${rotN===180?'on':''}">180°</button><button id=rot270 class="${rotN===270?'on':''}">270°</button></div>
|
|
2610
|
+
${br?'':`<div class=divrow><hr><span class=sect style="margin:0">Modify geometry</span><hr></div>
|
|
2113
2611
|
<div class=seg2 style="margin-top:0"><button id=geoEL class="${geoMode==='el'?'on':''}">Extend / Trim</button><button id=geoSplit class="${geoMode==='split'?'on':''}">Split</button></div>
|
|
2114
2612
|
<div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — another member or a grey segment. The nearest end of this member snaps to where the two lines meet (extends if short, trims if it overshoots).':geoMode==='split'?'Click a <b>point on this member</b> to cut it into two members.':'<b>Extend/Trim</b> (E) an end to meet another line · <b>Split</b> (S) at a point. <b>Esc</b> cancels.'}</div>
|
|
2115
|
-
<div class=row><button class=ghostw id=swapEnds data-tip="Reverse the member: swap the start (${col?'bottom':'yellow'}) and end (${col?'top':'magenta'}) handles · Shortcut: P">⇄ Swap start ↔ end <span style="opacity:.55">(P)</span></button></div
|
|
2613
|
+
<div class=row><button class=ghostw id=swapEnds data-tip="Reverse the member: swap the start (${col?'bottom':'yellow'}) and end (${col?'top':'magenta'}) handles · Shortcut: P">⇄ Swap start ↔ end <span style="opacity:.55">(P)</span></button></div>`}
|
|
2116
2614
|
<div class="row f"><button class=danger id=del>Delete member</button></div>`;
|
|
2117
2615
|
document.getElementById('pf').onchange=e=>edit(()=>{const v=e.target.value.toUpperCase().replace(/ /g,'');m.profile=v;m.rfi=(_wt(v)==null);if(v&&!profs.includes(v)){profs.push(v);profs.sort();}});
|
|
2118
2616
|
document.getElementById('pickProf').onclick=()=>{if(picking&&pickKind==='profile'){picking=false;}else{picking=true;pickKind='profile';pickEnd=null;}render();};
|
|
2119
|
-
document.
|
|
2120
|
-
document.getElementById('rBeam').onclick=()=>{if(col)edit(()=>{m.role='beam';});};
|
|
2121
|
-
document.getElementById('rCol').onclick=()=>{if(!col)edit(()=>{m.role='column';});};
|
|
2617
|
+
document.getElementById('mTypeS').onchange=e=>{const v=e.target.value;if(!normMemberTypeKey(v)){e.target.value=memberTypeLabel(memberTypeOf(m));return;}edit(()=>{const k=memberTypeFromInput(v);if(k&&memberTypeOf(m)!==k)applyMemberType([m],k);});}; // retype → role + legend recategorize (edit() → sync3D → build3DLegend); undoable
|
|
2122
2618
|
document.querySelectorAll('.mfsug').forEach(b=>b.onclick=()=>edit(()=>{m.profile=b.dataset.s;m.mf=true;m.rfi=(_wt(m.profile)==null);if(!profs.includes(m.profile)){profs.push(m.profile);profs.sort();}})); // record the moment-frame provenance (drives the confidence "schedule-resolved" factor)
|
|
2123
2619
|
const _gel=document.getElementById('geoEL'),_gsp=document.getElementById('geoSplit');
|
|
2124
2620
|
if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};
|
|
2125
2621
|
if(_gsp)_gsp.onclick=()=>{geoMode=(geoMode==='split'?null:'split');setGeo();render();};
|
|
2126
2622
|
{const _sw=document.getElementById('swapEnds');if(_sw)_sw.onclick=()=>edit(()=>swapMemberEnds(m));} // reverse start↔end (2D + 3D via render+sync3D)
|
|
2127
|
-
|
|
2623
|
+
// Brace controls (B4). type/floor/offset are display-only; swap flips brace.lowerEnd (arrow assignment, no geometry move).
|
|
2624
|
+
{const setBr=fn=>edit(()=>{if(!m.brace)normBrace(m);fn(m.brace);});
|
|
2625
|
+
const _bl=document.getElementById('brLat');if(_bl)_bl.onclick=()=>setBr(b=>b.type='lateral');
|
|
2626
|
+
const _bv=document.getElementById('brVert');if(_bv)_bv.onclick=()=>setBr(b=>b.type='vertical');
|
|
2627
|
+
const _ba=document.getElementById('brAbove');if(_ba)_ba.onclick=()=>setBr(b=>b.floor='above');
|
|
2628
|
+
const _bb=document.getElementById('brBelow');if(_bb)_bb.onclick=()=>setBr(b=>b.floor='below');
|
|
2629
|
+
const _bo=document.getElementById('brOff');if(_bo)_bo.onchange=e=>{const v=e.target.value.trim();const n=v===''?0:parseLen(v);setBr(b=>b.offset=Number.isFinite(n)?n:0);};
|
|
2630
|
+
const _bf=document.getElementById('brFlip');if(_bf)_bf.onclick=()=>setBr(b=>b.offset=-(b.offset||0)); // draw the symbol on the other side (no typing a minus)
|
|
2631
|
+
const _bsw=document.getElementById('brSwap');if(_bsw)_bsw.onclick=()=>edit(()=>{normBrace(m);m.brace.lowerEnd=1-braceLowerEnd(m);});}
|
|
2632
|
+
{const setPos=v=>edit(()=>{m.position=v;}); // profile placement on the reference line; persists + re-extrudes the 3D
|
|
2128
2633
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
2129
2634
|
if(_pt)_pt.onclick=()=>setPos('top');if(_pm)_pm.onclick=()=>setPos('middle');if(_pb)_pb.onclick=()=>setPos('bottom');}
|
|
2635
|
+
// Rotation — spin the section about the reference line. Normalised to (-360,360); 0 = as drawn.
|
|
2636
|
+
// edit() re-renders 2D (columnSectionPoly reads m.rot) AND re-extrudes 3D (steel-3d-view el.rot).
|
|
2637
|
+
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{m.rot=r;});};
|
|
2638
|
+
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>setRot(e.target.value);
|
|
2639
|
+
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
2640
|
+
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
2130
2641
|
const wireTos=(id,o)=>{const ck=document.getElementById(id+'_ck');if(ck)ck.onchange=e=>edit(()=>{o.tosDef=e.target.checked;if(o.tosDef)o.tos=defaultTOS;});
|
|
2131
2642
|
const inp=document.getElementById(id);if(inp)inp.onchange=e=>edit(()=>{o.tos=parseLen(e.target.value);o.tosDef=false;});};
|
|
2132
2643
|
const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{o.detail=e.target.value.trim();});
|
|
@@ -2156,7 +2667,10 @@ function panel(){
|
|
|
2156
2667
|
wireTos('tosB',m.ends[1]);
|
|
2157
2668
|
document.getElementById('ntB').onchange=e=>edit(()=>{m.ends[1].note=e.target.value;});
|
|
2158
2669
|
wireDet('dtB',m.ends[1]);wireConn('cnB',m.ends[1]);
|
|
2159
|
-
|
|
2670
|
+
// Not rendered for a brace — matching ends would FLATTEN the slope its arrowheads encode. Null-guarded
|
|
2671
|
+
// (the element is absent) plus a defensive isBrace check. (Codex round-4)
|
|
2672
|
+
{const me=document.getElementById('matchEnds');
|
|
2673
|
+
if(me)me.onclick=()=>{if(isBrace(m))return;edit(()=>{m.ends[1]={tos:m.ends[0].tos,note:m.ends[0].note,tosDef:m.ends[0].tosDef,detail:m.ends[0].detail,conn:m.ends[0].conn,connVerified:m.ends[0].connVerified};});};}
|
|
2160
2674
|
// shear-plate inspector wiring (per detailed end) — every mutation rides edit() → undoable; editing
|
|
2161
2675
|
// makes the plate user-owned (survives the auto-detail "Clear"). Bolt grid capped (rows×cols = parts).
|
|
2162
2676
|
for(const {e,j} of spjs){const jid=j.id,MAXC=20,MAXD=100000; // jid is a JS closure var (the find key), never placed in the DOM
|
|
@@ -2183,7 +2697,8 @@ function panel(){
|
|
|
2183
2697
|
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{m.verified=!m.verified;});}
|
|
2184
2698
|
}
|
|
2185
2699
|
function addFromSeg(sid){const sg=P.segments.find(s=>s.id===sid);if(!sg)return;const prof=addProfile;const id='m'+Date.now();const pv=snapshot();
|
|
2186
|
-
|
|
2700
|
+
const nm=ensureMeta({id,profile:prof,wp:[sg.a.slice(),sg.b.slice()],angle:sg.o,rfi:(_wt(prof)==null)});
|
|
2701
|
+
applyMemberType([nm],addType);P.members.push(nm);
|
|
2187
2702
|
if(prof&&!profs.includes(prof)){profs.push(prof);profs.sort();}pushUndo(pv);render();sync3D();}
|
|
2188
2703
|
// --- marquee hit-test (crossing selection): does segment ab touch rect [x0,y0,x1,y1]? ---
|
|
2189
2704
|
function inRect(p,r){return p[0]>=r[0]&&p[0]<=r[2]&&p[1]>=r[1]&&p[1]<=r[3];}
|
|
@@ -2195,10 +2710,10 @@ function rectHit(p0,p1,r){
|
|
|
2195
2710
|
for(let i=0;i<4;i++) if(segSeg(p0,p1,c[i],c[(i+1)%4])) return true;
|
|
2196
2711
|
return false;}
|
|
2197
2712
|
// --- snap to existing member/segment/dimension endpoints + MIDPOINTS (△) + line INTERSECTIONS (×); members lie on grids → snaps to grid intersections; Alt = off; right-click = snap-override menu ---
|
|
2198
|
-
const SNAP_PX=9; let snapPts=[], snapSegs=[], snapMids=[], snapInts=[], snapGeom=[], lastSnapKind='end', snapExtFrom=null; // lastSnapKind → marker glyph; snapGeom = member/segment lines (
|
|
2199
|
-
let snapOnly=null; // Tekla-style TRANSIENT override: 'end'|'int'|'mid'|'line'|'ext'
|
|
2713
|
+
const SNAP_PX=9; let snapPts=[], snapSegs=[], snapMids=[], snapInts=[], snapGeom=[], snapDimSegs=[], snapCoreN=0, lastSnapKind='end', snapExtFrom=null; // lastSnapKind → marker glyph; snapGeom = member/segment/grid lines (NO dims) for extension+intersection; snapDimSegs = dimension lines, kept out of snapGeom but a valid ⟂/∥ target; snapExtFrom = the endpoint an extension snap projects from; snapCoreN = count of AUTHORED endpoints at the front of snapPts (overlay endpoints are appended after) so the silent axis-align fallback never pulls to the ~13k traced-drawing vertices
|
|
2714
|
+
let snapOnly=null; // Tekla-style TRANSIENT override: one snap kind ('end'|'int'|'mid'|'line'|'ext'|'perp'|'par') or 'none' (free) restricts the current operation (right-click menu); null = use the persistent running-snaps
|
|
2200
2715
|
// persistent running-snaps (AutoCAD Osnap-style), GLOBAL across models, toggled from the ⋯ menu → Snapping
|
|
2201
|
-
const SNAP_PREF_KEY='steel:snapPrefs:v1', SNAP_DEFAULTS={end:true,int:true,mid:true,line:true,ext:false};
|
|
2716
|
+
const SNAP_PREF_KEY='steel:snapPrefs:v1', SNAP_DEFAULTS={end:true,int:true,mid:true,line:true,ext:false,perp:false,par:false};
|
|
2202
2717
|
let snapEnabled=(()=>{try{return Object.assign({},SNAP_DEFAULTS,JSON.parse(localStorage.getItem(SNAP_PREF_KEY)||'{}'));}catch(_){return {...SNAP_DEFAULTS};}})();
|
|
2203
2718
|
function saveSnapPrefs(){try{localStorage.setItem(SNAP_PREF_KEY,JSON.stringify(snapEnabled));}catch(_){}}
|
|
2204
2719
|
// a type fires when a transient override forces exactly it (override ignores running-snaps, AutoCAD-style), else when its running-snap is on
|
|
@@ -2208,15 +2723,59 @@ const _mid=(a,b)=>[(a[0]+b[0])/2,(a[1]+b[1])/2];
|
|
|
2208
2723
|
function _segX(a,b,c,d){const rx=b[0]-a[0],ry=b[1]-a[1],sx=d[0]-c[0],sy=d[1]-c[1],den=rx*sy-ry*sx;
|
|
2209
2724
|
if(Math.abs(den)<1e-9)return null;const qx=c[0]-a[0],qy=c[1]-a[1],t=(qx*sy-qy*sx)/den,u=(qx*ry-qy*rx)/den;
|
|
2210
2725
|
return (t<0||t>1||u<0||u>1)?null:[a[0]+rx*t,a[1]+ry*t];}
|
|
2726
|
+
// ---- Traced PDF/SVG overlay as snap targets (B3) — this sheet's LINE vectors (the same ones overlaySvg()
|
|
2727
|
+
// draws; circles render but aren't snap targets) become endpoint/nearest/midpoint snaps, so drawing + drags
|
|
2728
|
+
// stick to the drawing, not just the baked grey P.segments. Kept OUT of snapGeom on purpose: buildSnap runs
|
|
2729
|
+
// on every interactive move and its intersection pass is O(n²) (the extension/nearest scans stay O(n)) —
|
|
2730
|
+
// walking thousands of drawing segments through the pairwise loop would freeze the tool. Parsed ONCE per
|
|
2731
|
+
// sheet and cached on the els-array identity: filterElsForPlan() returns a new array only on a plan switch
|
|
2732
|
+
// or a contract re-read (SSE writeback → full page reload), so identity tracks content; an in-place mutation
|
|
2733
|
+
// of the same array would need to null _ovSnapEls. ponytail: endpoint + nearest-on-line + midpoint only — no
|
|
2734
|
+
// drawing×drawing intersection snap (that O(n²) over ~6k segments is untenable per-move); spatial index if needed.
|
|
2735
|
+
let _ovSnap=null,_ovSnapEls=null;
|
|
2736
|
+
function overlaySnapGeom(){
|
|
2737
|
+
const els=filterElsForPlan();
|
|
2738
|
+
if(!els){_ovSnap=null;_ovSnapEls=null;return null;} // scanned raster / empty → nothing traced to snap to
|
|
2739
|
+
if(els===_ovSnapEls&&_ovSnap)return _ovSnap; // same sheet's vectors → reuse the parse
|
|
2740
|
+
const pts=[],segs=[],mids=[];
|
|
2741
|
+
const add=(a,b)=>{if(!(isFinite(a[0])&&isFinite(a[1])&&isFinite(b[0])&&isFinite(b[1])))return;
|
|
2742
|
+
if(a[0]===b[0]&&a[1]===b[1])return;pts.push(a,b);segs.push([a,b]);mids.push(_mid(a,b));};
|
|
2743
|
+
for(const e of els){if(!e||e.kind!=='line')continue;
|
|
2744
|
+
if(typeof e.d==='string'&&e.d)parsePathSegs(e.d,add);
|
|
2745
|
+
else if(e.x1!=null&&e.x2!=null)add([e.x1,e.y1],[e.x2,e.y2]);}
|
|
2746
|
+
_ovSnapEls=els;_ovSnap={pts,segs,mids};return _ovSnap;}
|
|
2747
|
+
// Tokenize an SVG path 'd' into straight snap segments. Today's vectorizer emits M/L polylines with the odd
|
|
2748
|
+
// C curve (absolute), but the overlay is drawn by the browser's FULL path parser — so to keep snapping in
|
|
2749
|
+
// step with what's on screen we parse the whole line-ish grammar: M/L/H/V/C + Z + their relative (lowercase)
|
|
2750
|
+
// forms + exponent numbers. A curve (C) contributes only its start→endpoint chord — enough for a rounded
|
|
2751
|
+
// corner's ends, and curves are rare (mostly text). Malformed numbers → NaN, which add() drops.
|
|
2752
|
+
function parsePathSegs(d,add){
|
|
2753
|
+
const t=d.match(/[A-Za-z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!t)return;
|
|
2754
|
+
let i=0,cur=null,start=null,cmd='';const num=()=>parseFloat(t[i++]);
|
|
2755
|
+
while(i<t.length){const tok=t[i];
|
|
2756
|
+
if(/^[A-Za-z]$/.test(tok)){cmd=tok;i++; // a lone letter is a command (anchored — '1e2' is an exponent number, not the command 'e')
|
|
2757
|
+
if(cmd==='Z'||cmd==='z'){if(cur&&start)add(cur,start);cur=start;} // close → segment back to the subpath start
|
|
2758
|
+
continue;}
|
|
2759
|
+
const U=cmd.toUpperCase(),r=(cmd!==U&&!!cur); // lowercase = relative (to the current point)
|
|
2760
|
+
const bx=cur?cur[0]:0,by=cur?cur[1]:0; // base for relative coords / H·V's kept axis
|
|
2761
|
+
if(U==='M'){let x=num(),y=num();if(r){x+=bx;y+=by;}cur=[x,y];start=cur;cmd=(cmd==='m'?'l':'L');} // extra pairs after a moveto are implicit lineto
|
|
2762
|
+
else if(U==='L'){let x=num(),y=num();if(r){x+=bx;y+=by;}const p=[x,y];if(cur)add(cur,p);cur=p;}
|
|
2763
|
+
else if(U==='H'){let x=num();if(r)x+=bx;const p=[x,by];if(cur)add(cur,p);cur=p;}
|
|
2764
|
+
else if(U==='V'){let y=num();if(r)y+=by;const p=[bx,y];if(cur)add(cur,p);cur=p;}
|
|
2765
|
+
else if(U==='C'){i+=4;let x=num(),y=num();if(r){x+=bx;y+=by;}const p=[x,y];if(cur)add(cur,p);cur=p;} // skip the 2 control points, chord to the endpoint
|
|
2766
|
+
else{i++;cur=null;}}} // operand of an unmodelled command (S/Q/T/A) → advance AND break the pen chain, so the next segment is a clean skip, never a chord from a stale point
|
|
2211
2767
|
function buildSnap(except,opts){const ex=except instanceof Set?except:(except!=null?new Set([except]):new Set()); // id or Set of ids to skip
|
|
2212
|
-
snapPts=[];snapSegs=[];snapMids=[];snapInts=[];snapGeom=[]; // snapGeom = real member/segment/grid lines (extension + intersections project off these, never off dim/annotation lines)
|
|
2213
|
-
for(const m of P.members){if(ex.has(m.id))continue;snapPts.push(m.wp[0],m.wp[1]);snapSegs.push([m.wp[0],m.wp[1]]);snapMids.push(_mid(m.wp[0],m.wp[1]));snapGeom.push([m.wp[0],m.wp[1]]);}
|
|
2768
|
+
snapPts=[];snapSegs=[];snapMids=[];snapInts=[];snapGeom=[];snapDimSegs=[]; // snapGeom = real member/segment/grid lines (extension + intersections project off these, never off dim/annotation lines); snapDimSegs = dim lines (⟂/∥ target only)
|
|
2769
|
+
for(const m of P.members){if(ex.has(m.id))continue;snapPts.push(m.wp[0],m.wp[1]);if(isBrace(m))continue;snapSegs.push([m.wp[0],m.wp[1]]);snapMids.push(_mid(m.wp[0],m.wp[1]));snapGeom.push([m.wp[0],m.wp[1]]);} // brace: TRUE WP endpoints only in the geometry snap set — no offset-derived body/mid/intersection candidates, so ⟂/∥/nearest can never target an invisible baseline (Codex round-2/3)
|
|
2214
2770
|
for(const s of P.segments){snapPts.push(s.a,s.b);snapSegs.push([s.a,s.b]);snapMids.push(_mid(s.a,s.b));snapGeom.push([s.a,s.b]);}
|
|
2215
2771
|
if(gridOn()&&!(opts&&opts.noGrid)){const geo=gridGeo();if(geo){const gs=GC().gridSnapGeom(geo); // grid lines snap like member geometry — nearest + extension + member/grid intersections; grid nodes → endpoints. (Hidden grid doesn't snap; a DRAGGED grid line passes opts.noGrid so it can't stick to its own lines.)
|
|
2216
2772
|
for(const sg of gs.segs){snapSegs.push(sg);snapGeom.push(sg);}for(const q of gs.pts)snapPts.push(q);}}
|
|
2217
2773
|
for(let i=0;i<snapGeom.length;i++)for(let j=i+1;j<snapGeom.length;j++){const x=_segX(snapGeom[i][0],snapGeom[i][1],snapGeom[j][0],snapGeom[j][1]);if(x)snapInts.push(x);} // member×member, member×grid and grid×grid crossings → intersection (×) snap
|
|
2218
2774
|
if(dimsVisible&&!(opts&&opts.noDims)&&Array.isArray(P.dims))for(const d of P.dims){if(ex.has(d.id))continue; // dim (annotation) lines: nearest / endpoint / midpoint only — NOT intersections or extension; opts.noDims skips them (e.g. a grid-line drag shouldn't stick to annotations)
|
|
2219
|
-
const g=dimGeo(d.a,d.b,d.axis,d.off,d.rot);snapPts.push(g.p1,g.p2);snapSegs.push([g.p1,g.p2]);snapMids.push(g.mid);}
|
|
2775
|
+
const g=dimGeo(d.a,d.b,d.axis,d.off,d.rot);snapPts.push(g.p1,g.p2);snapSegs.push([g.p1,g.p2]);snapMids.push(g.mid);snapDimSegs.push([g.p1,g.p2]);} // dim line also a ⟂/∥ target (square/parallel to a dimension), but stays out of snapGeom (no int/ext off annotations)
|
|
2776
|
+
snapCoreN=snapPts.length; // everything so far is AUTHORED (member/segment/grid/dim) — the axis-align fallback in snap() only walks [0,snapCoreN)
|
|
2777
|
+
if(!(opts&&opts.noOverlay)){const ov=overlaySnapGeom();if(ov){ // traced PDF overlay → endpoint/nearest/midpoint (cached, appended AFTER the intersection pass → never in snapGeom)
|
|
2778
|
+
snapPts=snapPts.concat(ov.pts);snapSegs=snapSegs.concat(ov.segs);snapMids=snapMids.concat(ov.mids);}}}
|
|
2220
2779
|
// nearest point lying ON another member/segment LINE (perpendicular foot, clamped to the segment) within tol
|
|
2221
2780
|
function nearestOnLine(x,y,tol){let bp=null,bd=tol;
|
|
2222
2781
|
for(const sg of snapSegs){const pr=projPt([x,y],sg[0],sg[1]);const d=Math.hypot(pr.pt[0]-x,pr.pt[1]-y);if(d<bd){bd=d;bp=pr.pt;}}
|
|
@@ -2229,7 +2788,36 @@ function nearestOnExtension(x,y,tol){let best=null,bd=tol;
|
|
|
2229
2788
|
const fx=a[0]+t*vx,fy=a[1]+t*vy,d=Math.hypot(fx-x,fy-y);
|
|
2230
2789
|
if(d<bd){bd=d;best={x:fx,y:fy,from:(t<0?a:b)};}}
|
|
2231
2790
|
return best;}
|
|
2232
|
-
|
|
2791
|
+
// --- Perpendicular (⟂) / Parallel (∥) — Tier-2 snaps. Both key off the ANCHOR (the first picked point of the
|
|
2792
|
+
// current op) and target member/segment/grid geometry (snapGeom) PLUS the traced PDF/SVG overlay linework,
|
|
2793
|
+
// reusing B3's cached overlaySnapGeom() parse. Off by default. ---
|
|
2794
|
+
let snapAlignDir=null; // unit direction of the target line the last ⟂/∥ snap used → orients its glyph
|
|
2795
|
+
// Targets a ⟂ snap may drop its foot onto: member/segment/grid geometry (snapGeom) + dimension lines
|
|
2796
|
+
// (snapDimSegs — square to a dimension IS wanted) + the traced overlay segments (B3 overlaySnapGeom).
|
|
2797
|
+
// Perp is proximity-gated (foot must be near the cursor) so the dense overlay is fine. Parallel is NOT — it
|
|
2798
|
+
// matches by direction only, and the overlay carries a segment at almost every angle (thousands of traced
|
|
2799
|
+
// lines), so it targets snapGeom + snapDimSegs ONLY (the model's + dims' few real directions), not the overlay.
|
|
2800
|
+
function snapPerpTargets(){const ov=overlaySnapGeom();return snapGeom.concat(snapDimSegs, ov?ov.segs:[]);}
|
|
2801
|
+
// Perpendicular: drop the foot of the ANCHOR onto each target's infinite line. On-segment always valid; on the
|
|
2802
|
+
// extension valid only when Extension snap is on (dashed guide from the near end). Take the foot nearest the
|
|
2803
|
+
// CURSOR within tol → the segment anchor→foot is exactly 90° to that target line.
|
|
2804
|
+
function nearestPerp(cx,cy,ax,ay,tol,allowExt){let best=null,bd=tol;
|
|
2805
|
+
for(const sg of snapPerpTargets()){const a=sg[0],b=sg[1],vx=b[0]-a[0],vy=b[1]-a[1],L2=vx*vx+vy*vy;if(L2<1e-9)continue;
|
|
2806
|
+
const t=((ax-a[0])*vx+(ay-a[1])*vy)/L2,fx=a[0]+t*vx,fy=a[1]+t*vy,on=(t>=0&&t<=1);
|
|
2807
|
+
if(!on&&!allowExt)continue;
|
|
2808
|
+
const d=Math.hypot(fx-cx,fy-cy);if(d<bd){const L=Math.sqrt(L2);bd=d;best={x:fx,y:fy,dir:[vx/L,vy/L],from:on?null:(t<0?a:b)};}}
|
|
2809
|
+
return best;}
|
|
2810
|
+
// Parallel: when the anchor→cursor drag is within PAR_TAN of a MODEL / dimension line's direction (members,
|
|
2811
|
+
// grid, dims — via snapGeom + snapDimSegs, NOT the overlay, which has a line at nearly every angle and would
|
|
2812
|
+
// fire constantly), lock EXACTLY to it — point 2 = the cursor projected onto the ray through the anchor.
|
|
2813
|
+
const PAR_TAN=Math.tan(2.5*Math.PI/180);
|
|
2814
|
+
function nearestParallel(cx,cy,ax,ay){const dx=cx-ax,dy=cy-ay,dl=Math.hypot(dx,dy);if(dl<6)return null; // need a little drag to define a direction
|
|
2815
|
+
let best=null,bt=PAR_TAN;
|
|
2816
|
+
for(const sg of snapGeom.concat(snapDimSegs)){const vx=sg[1][0]-sg[0][0],vy=sg[1][1]-sg[0][1],L=Math.hypot(vx,vy);if(L<1e-9)continue;
|
|
2817
|
+
const ux=vx/L,uy=vy/L,along=dx*ux+dy*uy,perp=Math.abs(dx*uy-dy*ux),tan=perp/Math.max(Math.abs(along),1e-9);
|
|
2818
|
+
if(tan<bt){bt=tan;best={x:ax+along*ux,y:ay+along*uy,dir:[ux,uy]};}}
|
|
2819
|
+
return best;}
|
|
2820
|
+
function snap(x,y,anchor){const tol=SNAP_PX/zoom;lastSnapKind='end';snapExtFrom=null;snapAlignDir=null;
|
|
2233
2821
|
if(snapAllowed('end')){let bp=null,bd=tol;
|
|
2234
2822
|
for(const q of snapPts){const d=Math.hypot(q[0]-x,q[1]-y);if(d<bd){bd=d;bp=q;}}
|
|
2235
2823
|
if(bp)return {x:bp[0],y:bp[1],hit:true,kind:'end'};} // 1) endpoint / grid intersection (highest priority)
|
|
@@ -2237,10 +2825,14 @@ function snap(x,y){const tol=SNAP_PX/zoom;lastSnapKind='end';snapExtFrom=null;
|
|
|
2237
2825
|
if(ip){lastSnapKind='int';return {x:ip[0],y:ip[1],hit:true,kind:'int'};}} // 2) member/segment line crossing (×) — Tekla's intersection snap
|
|
2238
2826
|
if(snapAllowed('mid')){let mp=null,md=tol;for(const q of snapMids){const d=Math.hypot(q[0]-x,q[1]-y);if(d<md){md=d;mp=q;}}
|
|
2239
2827
|
if(mp){lastSnapKind='mid';return {x:mp[0],y:mp[1],hit:true,kind:'mid'};}} // 3) midpoint of a member/segment/dimension line (△)
|
|
2828
|
+
if(anchor&&snapAllowed('perp')){const pp=nearestPerp(x,y,anchor[0],anchor[1],tol,snapEnabled.ext!==false);
|
|
2829
|
+
if(pp){lastSnapKind='perp';snapExtFrom=pp.from;snapAlignDir=pp.dir;return {x:pp.x,y:pp.y,hit:true,kind:'perp'};}} // 3b) ⟂ to a target line, foot dropped from the anchor (ext on → foot may lie on the extension, dashed)
|
|
2830
|
+
if(anchor&&snapAllowed('par')){const pr=nearestParallel(x,y,anchor[0],anchor[1]);
|
|
2831
|
+
if(pr){lastSnapKind='par';snapAlignDir=pr.dir;return {x:pr.x,y:pr.y,hit:true,kind:'par'};}} // 3c) ∥ to a nearby target line's direction
|
|
2240
2832
|
if(snapAllowed('line')){const ln=nearestOnLine(x,y,tol);if(ln){lastSnapKind='line';return {x:ln.x,y:ln.y,hit:true,kind:'line'};}} // 4) nearest point ON a line (hourglass)
|
|
2241
2833
|
if(snapAllowed('ext')){const ex=nearestOnExtension(x,y,tol);if(ex){lastSnapKind='ext';snapExtFrom=ex.from;return {x:ex.x,y:ex.y,hit:true,kind:'ext'};}} // 5) along a line's EXTENSION past its end (dashed guide) — off by default
|
|
2242
2834
|
if(!snapOnly&&snapEnabled.end!==false){let sx=x,sy=y,bx=tol,by=tol; // 6) else axis-align to a nearby endpoint's row/column (an endpoint-based aid → off when Endpoint snap is off, or under any "only X" override)
|
|
2243
|
-
for(const q
|
|
2835
|
+
for(let i=0;i<snapCoreN;i++){const q=snapPts[i];const dx=Math.abs(q[0]-x);if(dx<bx){bx=dx;sx=q[0];}const dy=Math.abs(q[1]-y);if(dy<by){by=dy;sy=q[1];}} // AUTHORED endpoints only ([0,snapCoreN)) — the ~13k overlay vertices must NOT silently pull a free point to a random drawing row/column (no marker shows here)
|
|
2244
2836
|
return {x:sx,y:sy,hit:false,kind:null};}
|
|
2245
2837
|
return {x,y,hit:false,kind:null};}
|
|
2246
2838
|
// one persistent marker element; kind 'mid' draws an upward triangle, everything else the original circle. Defaults to the last snap()'s kind.
|
|
@@ -2251,6 +2843,11 @@ function snapMark(x,y,kind){kind=kind||lastSnapKind;snapClear();
|
|
|
2251
2843
|
else if(kind==='end'){const r=6/zoom;el=document.createElementNS(ns,'rect');el.setAttribute('x',x-r);el.setAttribute('y',y-r);el.setAttribute('width',2*r);el.setAttribute('height',2*r);} // endpoint = SQUARE (CAD convention)
|
|
2252
2844
|
else if(kind==='ext'){const r=6/zoom;el=document.createElementNS(ns,'rect');el.setAttribute('x',x-r);el.setAttribute('y',y-r);el.setAttribute('width',2*r);el.setAttribute('height',2*r);el.setAttribute('stroke-dasharray',`${3/zoom} ${2/zoom}`); // extension = a DASHED square (on the endpoint's ray) + the dashed guide line below
|
|
2253
2845
|
if(snapExtFrom){const g=document.createElementNS(ns,'line');g.setAttribute('x1',snapExtFrom[0]);g.setAttribute('y1',snapExtFrom[1]);g.setAttribute('x2',x);g.setAttribute('y2',y);g.id='snapExtLine';g.setAttribute('class','extguide');svg.appendChild(g);}}
|
|
2846
|
+
else if(kind==='perp'){const r=8/zoom,u=snapAlignDir||[1,0],px=-u[1],py=u[0]; // right-angle marker at the foot: one arm along the target line, one perpendicular to it (collinear with foot→anchor)
|
|
2847
|
+
el=document.createElementNS(ns,'path');el.setAttribute('d',`M ${x+u[0]*r} ${y+u[1]*r} L ${x+(u[0]+px)*r} ${y+(u[1]+py)*r} L ${x+px*r} ${y+py*r}`);
|
|
2848
|
+
if(snapExtFrom){const g=document.createElementNS(ns,'line');g.setAttribute('x1',snapExtFrom[0]);g.setAttribute('y1',snapExtFrom[1]);g.setAttribute('x2',x);g.setAttribute('y2',y);g.id='snapExtLine';g.setAttribute('class','extguide');svg.appendChild(g);}} // dashed guide when the foot sits on the target's extension
|
|
2849
|
+
else if(kind==='par'){const r=8/zoom,o=3/zoom,u=snapAlignDir||[1,0],px=-u[1],py=u[0]; // two short strokes parallel to the target line = ∥
|
|
2850
|
+
el=document.createElementNS(ns,'path');el.setAttribute('d',`M ${x+px*o-u[0]*r} ${y+py*o-u[1]*r} L ${x+px*o+u[0]*r} ${y+py*o+u[1]*r} M ${x-px*o-u[0]*r} ${y-py*o-u[1]*r} L ${x-px*o+u[0]*r} ${y-py*o+u[1]*r}`);}
|
|
2254
2851
|
else{const r=7/zoom;el=document.createElementNS(ns,'path');el.setAttribute('d',`M ${x-r} ${y-r} L ${x+r} ${y-r} L ${x-r} ${y+r} L ${x+r} ${y+r} Z`);} // on-line ("nearest") = HOURGLASS/clepsydra (AutoCAD Nearest glyph); circle is reserved for a future Center snap
|
|
2255
2852
|
el.id='snapMark';el.setAttribute('class','snapmk');svg.appendChild(el);document.body.classList.add('snapping');} // marker up → hide the native crosshair (see .snapping CSS)
|
|
2256
2853
|
function snapClear(){const c=document.getElementById('snapMark');if(c)c.remove();const g=document.getElementById('snapExtLine');if(g)g.remove();document.body.classList.remove('snapping');}
|
|
@@ -2278,7 +2875,7 @@ function _lenFt(m){return _len3dFt(m,FT,defaultTOS);}
|
|
|
2278
2875
|
const PROP_DEFS=[
|
|
2279
2876
|
{key:'id', label:'Mark', get:m=>m.id, fmt:v=>v==null?'':String(v)},
|
|
2280
2877
|
{key:'profile', label:'Profile', get:m=>m.profile, fmt:v=>v==null?'':String(v)},
|
|
2281
|
-
{key:'type', label:'Type', get:m=>
|
|
2878
|
+
{key:'type', label:'Type', get:m=>memberTypeLabel(memberTypeOf(m)), fmt:v=>v==null?'':String(v)},
|
|
2282
2879
|
{key:'role', label:'Role', get:m=>m.role==='column'?'Column':'Beam', fmt:v=>v||''},
|
|
2283
2880
|
{key:'length', label:'Length', get:m=>_lenFt(m), fmt:v=>v==null?'':v.toFixed(1)+' ft'},
|
|
2284
2881
|
{key:'weight', label:'Weight', get:m=>{const w=_wt(m.profile);return w==null?undefined:_lenFt(m)*w;}, fmt:v=>v==null?'':Math.round(v).toLocaleString()+' lb'},
|
|
@@ -2301,6 +2898,7 @@ function sanitizePropLabels(x){const o=(x&&typeof x==='object'&&!Array.isArray(x
|
|
|
2301
2898
|
return {props:Array.isArray(o.props)?o.props.filter(k=>PROP_KEYS.has(k)):[],
|
|
2302
2899
|
placement:['start','mid','end'].includes(o.placement)?o.placement:'mid',
|
|
2303
2900
|
selected_only:o.selected_only===true,
|
|
2901
|
+
vis2d:o.vis2d!==false,vis3d:o.vis3d!==false, // per-view label VISIBILITY (B1): default ON; the property SELECTION (props) stays shared across 2D+3D — only show/hide is independent
|
|
2304
2902
|
ids:Array.isArray(o.ids)?o.ids.filter(v=>typeof v==='string'):[]};}
|
|
2305
2903
|
C.prop_labels=sanitizePropLabels(C.prop_labels); // normalise the contract's incoming value now (PROP_KEYS is initialised above; runs before main's bootstrap render + restoreSaved override)
|
|
2306
2904
|
C.views=sanitizeViews(C.views); // normalise the incoming saved views now — inside main() where sanitizeViews is in scope (boot() only guaranteed an array); runs before the bootstrap render + restoreSaved override, same pattern as prop_labels above
|
|
@@ -2328,9 +2926,9 @@ const PLABEL_MIN_PX=24;
|
|
|
2328
2926
|
// member's true 3D length at its midpoint, nudged perpendicular off the line (fixed relative to member direction).
|
|
2329
2927
|
// Cyan dimension chips; the member being end-dragged is skipped (its live overlay covers it); coincident midpoints
|
|
2330
2928
|
// fan out along the perpendicular so duplicate/overlapping members stay readable. Rescaled live by updateBadges.
|
|
2331
|
-
function renderSelLenLabels(){if(!showSelLen)return '';const selM=
|
|
2929
|
+
function renderSelLenLabels(){if(!showSelLen)return '';const selM=sel2d();if(!selM.length)return '';
|
|
2332
2930
|
const drg=(drag&&drag.type==='end')?drag.id:null,grp={};
|
|
2333
|
-
for(const m of selM){if(m.id===drg)continue;
|
|
2931
|
+
for(const m of selM){if(m.id===drg)continue;if(!m.wp||!m.wp[0]||!m.wp[1])continue;const vl=memberViewLine(m),a=vl[0],b=vl[1]; // anchor on the DRAWN line so an offset brace's chip rides its symbol
|
|
2334
2932
|
const mid=[(a[0]+b[0])/2,(a[1]+b[1])/2],k=Math.round(mid[0]/8)+','+Math.round(mid[1]/8);(grp[k]=grp[k]||[]).push({m,a,b,mid});}
|
|
2335
2933
|
let s='';
|
|
2336
2934
|
for(const k in grp){const arr=grp[k],n=arr.length;arr.forEach((it,j)=>{const {m,a,b,mid}=it;
|
|
@@ -2341,14 +2939,14 @@ function renderSelLenLabels(){if(!showSelLen)return '';const selM=selArr();if(!s
|
|
|
2341
2939
|
s+=`<rect class=mlenchip ${dd} data-tw="${tw}" x="${cx-w/2}" y="${cy-hh/2}" width="${w}" height="${hh}" rx="${3/zoom}" style="${hide}"/>`
|
|
2342
2940
|
+`<text class=mlentx ${dd} x="${cx}" y="${cy}" style="font-size:${11/zoom}px${hide}">${esc(txt)}</text>`;});}
|
|
2343
2941
|
return s?`<g class="mlenlabels">${s}</g>`:'';}
|
|
2344
|
-
function renderPropLabels(){const pl=C.prop_labels;propLabelsHidden=0;if(!pl||!pl.props.length)return '';
|
|
2942
|
+
function renderPropLabels(){const pl=C.prop_labels;propLabelsHidden=0;if(!pl||!pl.props.length||!pl.vis2d)return ''; // vis2d off → no 2D chips (B1); propLabelsHidden stays 0 so the "zoom in" pill also stays suppressed
|
|
2345
2943
|
const ms=propLabelMembers();if(!ms.length)return '';
|
|
2346
2944
|
let hidden=0,s='';
|
|
2347
2945
|
// Emit chips for EVERY labelled member (carrying its display length in data-mlen); the zoom threshold
|
|
2348
2946
|
// only sets each chip's initial visibility. updateBadges re-applies it live as the user zooms — so
|
|
2349
2947
|
// zooming in reveals a hidden label and zooming out hides it (they're in the DOM either way).
|
|
2350
2948
|
for(const m of ms){const lines=propLabelLinesFor(m);if(!lines.length)continue;
|
|
2351
|
-
const a=
|
|
2949
|
+
const vl=memberViewLine(m),a=vl[0],b=vl[1],mlen=len(a,b);const show=mlen*zoom>=PLABEL_MIN_PX;if(!show)hidden++; // chips ride the DRAWN line (offset brace included)
|
|
2352
2950
|
const anc=pl.placement==='start'?a:pl.placement==='end'?b:[(a[0]+b[0])/2,(a[1]+b[1])/2];
|
|
2353
2951
|
const n=lines.length,hide=show?'':';display:none';
|
|
2354
2952
|
lines.forEach((txt,i)=>{const off=(i-(n-1)/2)*15,tw=txt.length,w=(tw*6.4+12)/zoom,h=15/zoom,cy=anc[1]+off/zoom;
|
|
@@ -2368,7 +2966,7 @@ function updatePropHint(){let el=document.getElementById('plHint');
|
|
|
2368
2966
|
// ---- 3D bridge: hand the label spec to the 3D view (it owns projection/placement over member geometry) ----
|
|
2369
2967
|
function refreshPropLabels3d(){const V=window.Steel3DView;if(!V||!V.setPropLabels)return;
|
|
2370
2968
|
const pl=C.prop_labels;
|
|
2371
|
-
if(!pl||!pl.props.length){V.setPropLabels(null);return;}
|
|
2969
|
+
if(!pl||!pl.props.length||!pl.vis3d){V.setPropLabels(null);return;} // vis3d off → clear the 3D labels (B1 per-view visibility)
|
|
2372
2970
|
V.setPropLabels({labels:propLabelMembers().map(m=>({id:m.id,lines:propLabelLinesFor(m)})),placement:pl.placement});}
|
|
2373
2971
|
|
|
2374
2972
|
// ---- The floating Properties popup ----
|
|
@@ -2385,7 +2983,8 @@ function propPopEl(){let el=document.getElementById('propPop');if(el)return el;
|
|
|
2385
2983
|
+`<div class=ppmeta id=ppMeta></div><div class=ppscope id=ppScope></div>`
|
|
2386
2984
|
+`<div class=pplist id=ppList></div>`
|
|
2387
2985
|
+`<div class=ppfoot><div class=seg2 id=ppPlace><button data-pl=start>Start</button><button data-pl=mid>Middle</button><button data-pl=end>End</button></div>`
|
|
2388
|
-
+`<label><input type=checkbox id=ppSel>Selected only</label
|
|
2986
|
+
+`<label><input type=checkbox id=ppSel>Selected only</label>`
|
|
2987
|
+
+`<label data-tip="Show or hide property labels in the view you're in now — the property selection is shared with the other view, this only hides them here"><input type=checkbox id=ppVis> Show in this view</label></div>`;
|
|
2389
2988
|
document.body.appendChild(el);
|
|
2390
2989
|
const list=el.querySelector('#ppList');
|
|
2391
2990
|
list.addEventListener('click',e=>{const row=e.target.closest('.pprow');if(!row)return;
|
|
@@ -2401,6 +3000,8 @@ function propPopEl(){let el=document.getElementById('propPop');if(el)return el;
|
|
|
2401
3000
|
el.querySelector('#ppPin').onclick=()=>{propPopPinned=!propPopPinned;if(propPopPinned)dockPropPop();renderPropPop();};
|
|
2402
3001
|
el.querySelector('#ppPlace').addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;C.prop_labels.placement=b.dataset.pl;refreshPropLabels();});
|
|
2403
3002
|
el.querySelector('#ppSel').addEventListener('change',e=>{const pl=C.prop_labels;pl.selected_only=e.target.checked;if(pl.selected_only)pl.ids=selArr().map(m=>m.id);refreshPropLabels();});
|
|
3003
|
+
el.querySelector('#ppVis').addEventListener('change',e=>{const pl=C.prop_labels; // B1: per-view label visibility, right where labels are managed — bound to the view you're currently in
|
|
3004
|
+
if(view3d){pl.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();}else{pl.vis2d=e.target.checked;refreshPropLabels();}}); // 2D refreshPropLabels()=scheduleSave+render (updPlToggle re-syncs the ⋯ Display toggle); 3D pushes to the view
|
|
2404
3005
|
// focus trap + Esc (behaves as a lightweight non-modal dialog)
|
|
2405
3006
|
el.addEventListener('keydown',e=>{if(e.key==='Escape'){e.stopPropagation();closePropPop(true);return;}
|
|
2406
3007
|
if(e.key!=='Tab')return;const f=[...el.querySelectorAll('button,input,[tabindex]')].filter(n=>!n.disabled&&n.offsetParent!==null);
|
|
@@ -2418,11 +3019,12 @@ function renderPropPop(){const el=document.getElementById('propPop');if(!el||!el
|
|
|
2418
3019
|
el.classList.toggle('connmode',!!propPopConn);
|
|
2419
3020
|
if(propPopConn){renderConnTree(el);return;} // connection / mixed-selection tree view
|
|
2420
3021
|
const arr=selArr(),pl=C.prop_labels,q=(el.querySelector('#ppSearch').value||'').trim().toLowerCase();
|
|
2421
|
-
el.querySelector('#ppTitle').textContent='Properties
|
|
3022
|
+
el.querySelector('#ppTitle').textContent='Properties'; // short title so the header never clips it; the selection count moved to the roomy scope line below
|
|
2422
3023
|
el.querySelector('#ppLabeled').textContent=pl.props.length?pl.props.length+' labeled':'';
|
|
2423
|
-
el.querySelector('#ppScope').textContent=pl.selected_only?'
|
|
3024
|
+
el.querySelector('#ppScope').textContent=arr.length+(arr.length===1?' member · ':' members · ')+(pl.selected_only?'labels apply to the selected':'labels apply to all on this plan');
|
|
2424
3025
|
el.querySelectorAll('#ppPlace button').forEach(b=>b.classList.toggle('on',b.dataset.pl===pl.placement));
|
|
2425
3026
|
el.querySelector('#ppSel').checked=pl.selected_only;
|
|
3027
|
+
{const v=el.querySelector('#ppVis');if(v)v.checked=view3d?!!pl.vis3d:!!pl.vis2d;} // reflect the CURRENT view's visibility flag (self-heals a pinned popup across a 2D↔3D switch)
|
|
2426
3028
|
const ae=document.activeElement,fk=(ae&&ae.closest&&ae.closest('.pprow'))?ae.closest('.pprow').dataset.k:null;
|
|
2427
3029
|
let shown=0;const rows=PROP_DEFS.map(def=>{
|
|
2428
3030
|
if(q&&!def.label.toLowerCase().includes(q))return '';
|
|
@@ -2510,8 +3112,11 @@ function refreshPropLabels(){scheduleSave();render();} // render() → renderP
|
|
|
2510
3112
|
// 2D: right-click anywhere on the canvas (set it before grabbing an endpoint — a drag captures the pointer).
|
|
2511
3113
|
// 3D: right-CLICK while the Dimension tool is armed (right-DRAG stays orbit/pan). The override clears when
|
|
2512
3114
|
// the operation ends: tool disarm, plan/view switch, a select-mode drag ending, Esc, or "All snaps". ---
|
|
2513
|
-
|
|
2514
|
-
|
|
3115
|
+
// The endpoint/vertex glyph is ◻ U+25FB (MEDIUM square), never □ U+25A1 — U+25A1's ink is ~⅔ the height of ✕/△ in
|
|
3116
|
+
// the system-ui stack, so it reads half-size beside them and no font-size bump fixes it without breaking the baseline.
|
|
3117
|
+
// The same character is hardcoded in the snap bar and the ⋯ menu's Snapping rows; all three must move together.
|
|
3118
|
+
const SNAP_KINDS_2D=[['end','◻','Endpoint'],['int','✕','Intersection'],['mid','△','Midpoint'],['line','⧗','Nearest'],['perp','⟂','Perpendicular'],['par','∥','Parallel'],['ext','┈','Extension']]; // display order: point/line snaps, then the ⟂/∥ pair, Extension last; glyphs mirror the on-canvas markers; perp/par need a first point (anchor). (snap() PRIORITY is separate — end>int>mid>perp>par>line>ext.)
|
|
3119
|
+
const SNAP_KINDS_3D=[['vertex','◻','Vertex'],['intersection','✕','Intersection'],['midpoint','△','Midpoint'],['centerline','⧗','Centerline'],['vertical-axis','│','Vertical axis']];
|
|
2515
3120
|
function snapKindLabel(k,is3d){const r=(is3d?SNAP_KINDS_3D:SNAP_KINDS_2D).find(x=>x[0]===k);return r?r[2]:k;}
|
|
2516
3121
|
function updSnapStat(){const el=document.getElementById('snapStat');if(!el)return;
|
|
2517
3122
|
const V=window.Steel3DView,k=view3d?(V&&V.snapOnly?V.snapOnly():null):snapOnly;
|
|
@@ -2528,8 +3133,13 @@ function closeSnapMenu(){const m=document.getElementById('snapMenu');if(m)m.clas
|
|
|
2528
3133
|
function openSnapMenu(x,y,is3d){const m=snapMenuEl();m._is3d=!!is3d;
|
|
2529
3134
|
const V=window.Steel3DView,cur=is3d?(V&&V.snapOnly?V.snapOnly():null):snapOnly;
|
|
2530
3135
|
const off=k=>!is3d&&k&&snapEnabled[k]===false; // a running-snap turned off in the ⋯ menu → dim it here (the override can still force it — AutoCAD-style)
|
|
3136
|
+
// ⟂/∥ need a 'from' point: offered for member draw + the Dimension tool (both anchor the 2nd/chain point). The
|
|
3137
|
+
// single-point picks below (split / set-axes / grid corner+line / extend-trim) have no anchor, so forcing ⟂/∥
|
|
3138
|
+
// there would snap nothing AND suppress the five that do — omit them for those (a future tool that threads an
|
|
3139
|
+
// anchor gets them automatically, since it won't be in this list).
|
|
3140
|
+
const noAnchor=!is3d&&(dimSplitMode||csaxisMode||gridPick||gridLinePick||!!geoMode);
|
|
2531
3141
|
const row=(k,g,l)=>`<button role=menuitem data-k="${k}" class="${(cur===k||(!cur&&!k))?'on':''}${off(k)?' dim':''}"><span class=sg aria-hidden=true>${g}</span>${l}${off(k)?' <span class=offtag>off</span>':''}</button>`;
|
|
2532
|
-
m.innerHTML=row('','✓','All snaps (default)')+'<hr>'+(is3d?SNAP_KINDS_3D:SNAP_KINDS_2D).map(r=>row(r[0],r[1],r[2])).join('')+'<hr>'+row('none','⌀','No snap (free)');
|
|
3142
|
+
m.innerHTML=row('','✓','All snaps (default)')+'<hr>'+(is3d?SNAP_KINDS_3D:SNAP_KINDS_2D).filter(r=>!(noAnchor&&(r[0]==='perp'||r[0]==='par'))).map(r=>row(r[0],r[1],r[2])).join('')+'<hr>'+row('none','⌀','No snap (free)');
|
|
2533
3143
|
m.classList.add('open');const r=m.getBoundingClientRect();
|
|
2534
3144
|
m.style.left=Math.max(4,Math.min(x,innerWidth-r.width-8))+'px';m.style.top=Math.max(4,Math.min(y,innerHeight-r.height-8))+'px';
|
|
2535
3145
|
m.focus();}
|
|
@@ -2553,13 +3163,15 @@ document.getElementById('snapStat').onclick=()=>{snapOnly=null;const V=window.St
|
|
|
2553
3163
|
// svg.innerHTML wholesale, so we only render() on commit/cancel — like the draw/marquee temps). ---
|
|
2554
3164
|
const SVGNS='http://www.w3.org/2000/svg';
|
|
2555
3165
|
function setDimMode(){document.body.classList.toggle('dimon',dimMode);document.getElementById('dimB').classList.toggle('on',dimMode);
|
|
2556
|
-
if(dimMode){if(mode==='add'){mode='sel';setMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();geoMode=null;setGeo();selIds.clear();selDimIds.clear();dimsVisible=true;updDimToggle();} // arming clears conflicting modes (add/set-axes/move-copy) + ensures dims are visible — covers the D-key path too, not just the button
|
|
3166
|
+
if(dimMode){if(mode==='add'){mode='sel';setMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();dimStyleMode=false;geoMode=null;setGeo();selIds.clear();selDimIds.clear();dimsVisible=true;updDimToggle();} // arming clears conflicting modes (add/set-axes/move-copy/dim-style pane) + ensures dims are visible — covers the D-key path too, not just the button
|
|
2557
3167
|
snapOnlyClear2d(); // any dim-tool transition ends the previous operation → the snap override reverts (arming must not inherit add-mode's override)
|
|
2558
3168
|
dimDraft=null;dimChainPrev=null;dimPrevClear();}
|
|
2559
|
-
function dimSnapAt(e){const q=toSvg(e);let x=q.x,y=q.y;
|
|
2560
|
-
if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;return {x,y,raw:[q.x,q.y],hit:sn.hit};}
|
|
3169
|
+
function dimSnapAt(e,anchor){const q=toSvg(e);let x=q.x,y=q.y; // anchor (optional) = the current tool's 'from' point (draw's 1st point, or the dim's 1st / chain point) so ⟂/∥ can square/align the next pick
|
|
3170
|
+
if(!e.altKey){buildSnap(null);const sn=snap(x,y,anchor);x=sn.x;y=sn.y;return {x,y,raw:[q.x,q.y],hit:sn.hit};}
|
|
2561
3171
|
return {x,y,raw:[q.x,q.y],hit:false};}
|
|
2562
|
-
|
|
3172
|
+
// The dim's 'from' point for ⟂/∥ while picking the NEXT point: the chain's previous point, or (mid-draft) point 1. Null while picking point 1 or the offset (click 3).
|
|
3173
|
+
function dimAnchor(){return dimChainPrev?dimChainPrev.point:(dimDraft&&!dimDraft.b?dimDraft.a:null);}
|
|
3174
|
+
function dimClick(e){const s=dimSnapAt(e,dimAnchor());
|
|
2563
3175
|
if(dimChainPrev){const a=dimChainPrev.point,b=[s.x,s.y],axis=dimChainPrev.axis,off=dimChainPrev.off,rot=dimChainPrev.rot||0; // CHAIN: each click adds the next dim from the previous point, on the same axis + offset line + baked frame
|
|
2564
3176
|
if(dimGeo(a,b,axis,off,rot).px<1){dimPrev(e);return;} // ignore a zero / sub-pixel click (measured length in the frame) — don't commit a degenerate dim
|
|
2565
3177
|
edit(()=>{P.dims.push({id:'d'+Date.now()+'_'+(dimSeq++),a,b,axis,off,rot});});
|
|
@@ -2576,12 +3188,12 @@ function dimClick(e){const s=dimSnapAt(e);
|
|
|
2576
3188
|
function dimPrevClear(){const g=document.getElementById('dimPrevG');if(g)g.remove();snapClear();}
|
|
2577
3189
|
function dimPrev(e){if(!dimMode){dimPrevClear();return;}
|
|
2578
3190
|
{const h=document.getElementById('dimHint');if(h)h.textContent=dimHintText();} // keep the panel hint live (chain / stage state)
|
|
2579
|
-
if(dimChainPrev){const s=dimSnapAt(e);s.hit?snapMark(s.x,s.y):snapClear(); // chain: preview the next segment from the last point at the shared axis + offset
|
|
3191
|
+
if(dimChainPrev){const s=dimSnapAt(e,dimAnchor());s.hit?snapMark(s.x,s.y):snapClear(); // chain: preview the next segment from the last point at the shared axis + offset
|
|
2580
3192
|
let g=document.getElementById('dimPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='dimPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}
|
|
2581
3193
|
g.innerHTML=dimSvg({a:dimChainPrev.point,b:[s.x,s.y],axis:dimChainPrev.axis,off:dimChainPrev.off,rot:dimChainPrev.rot||0},{preview:true});return;}
|
|
2582
|
-
if(!dimDraft){const s=dimSnapAt(e);s.hit?snapMark(s.x,s.y):snapClear();const og=document.getElementById('dimPrevG');if(og)og.remove();return;} // before click 1: show the snap marker for the prospective FIRST anchor (no dim drawn yet)
|
|
3194
|
+
if(!dimDraft){const s=dimSnapAt(e,dimAnchor());s.hit?snapMark(s.x,s.y):snapClear();const og=document.getElementById('dimPrevG');if(og)og.remove();return;} // before click 1: show the snap marker for the prospective FIRST anchor (no dim drawn yet)
|
|
2583
3195
|
let g=document.getElementById('dimPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='dimPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}
|
|
2584
|
-
if(!dimDraft.b){const s=dimSnapAt(e);s.hit?snapMark(s.x,s.y):snapClear(); // stage 1: live CONSTRAINED preview from a → the tentative 2nd point
|
|
3196
|
+
if(!dimDraft.b){const s=dimSnapAt(e,dimAnchor());s.hit?snapMark(s.x,s.y):snapClear(); // stage 1: live CONSTRAINED preview from a → the tentative 2nd point
|
|
2585
3197
|
const b=[s.x,s.y];dimLastPtr=b;
|
|
2586
3198
|
const ax=e.shiftKey?dominantAxis(dimDraft.a,b):dimDraft.axis; // X/Y/F + Shift force already apply while picking the 2nd point (value shown live); Shift dominant-axis follows the local frame
|
|
2587
3199
|
const rot=ax==='free'?0:frameRot();
|
|
@@ -2598,25 +3210,68 @@ function dimHintText(){if(dimChainPrev)return 'Chaining — click the next point
|
|
|
2598
3210
|
const loc=!!(P&&P.frame);
|
|
2599
3211
|
const a={free:'Free (aligned)',x:loc?'X (local)':'X (horizontal)',y:loc?'Y (local)':'Y (vertical)'}[dimDraft?dimDraft.axis:dimAxis];
|
|
2600
3212
|
return 'Dimension — '+a+(dimChain?' · Chain ON':'')+(loc?' · local axes':'')+'. Click 1: start · Click 2: end · Click 3: place. Shift=lock axis · X/Y/F force · Alt=no snap · right-click=snap menu · Esc=cancel.';}
|
|
3213
|
+
// ---- Add-member draw: click-to-start / click-to-finish (mirrors the Dimension tool; snaps on both clicks) ----
|
|
3214
|
+
function drawClick(e){const s=dimSnapAt(e,drawDraft);const p=[s.x,s.y]; // dimSnapAt = buildSnap()+snap(); anchor=drawDraft → once a start exists, ⟂/∥ can square/align the end point
|
|
3215
|
+
if(!drawDraft){drawDraft=p;if(picking&&pickKind==='profile'){picking=false;render();}drawPrev(e);return;} // click 1 → the start point (starting a draw disarms an armed ⌖ pick)
|
|
3216
|
+
const a=drawDraft,b=e.shiftKey?orthoLock(a[0],a[1],p[0],p[1]):p; // Shift = straight (ortho, local-frame aware)
|
|
3217
|
+
if(len(a,b)<=6){drawPrev(e);return;} // sub-6px 2nd pick (double-click / near-miss) → KEEP the start, don't commit (mirrors dimClick's zero-length guard)
|
|
3218
|
+
const dx=Math.abs(b[0]-a[0]),dy=Math.abs(b[1]-a[1]),o=dx>3*dy?'H':(dy>3*dx?'V':'D'); // classify H/V/diagonal like the old drag-commit
|
|
3219
|
+
const id='m'+Date.now(),pv=snapshot();const nm=ensureMeta({id,profile:addProfile,wp:[a,b],angle:o,rfi:(_wt(addProfile)==null)});
|
|
3220
|
+
applyMemberType([nm],addType);P.members.push(nm); // the Add-member panel's type owns role + legend category
|
|
3221
|
+
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}pushUndo(pv);
|
|
3222
|
+
drawDraft=null;render();drawPrev(e);} // commit → clear the draft, keep the tool armed for the next member
|
|
3223
|
+
function drawPrevClear(){const g=document.getElementById('drawPrevLine');if(g)g.remove();snapClear();}
|
|
3224
|
+
function drawPrev(e){if(mode!=='add'||view3d){drawPrevClear();return;}
|
|
3225
|
+
{const h=document.getElementById('drawHint');if(h)h.innerHTML=drawHintText();} // keep the side-panel hint live (stage-aware)
|
|
3226
|
+
const s=dimSnapAt(e,drawDraft); // anchor=drawDraft → the live rubber-band end can ⟂/∥ snap to a target line
|
|
3227
|
+
if(!drawDraft){s.hit?snapMark(s.x,s.y):snapClear();const g=document.getElementById('drawPrevLine');if(g)g.remove();return;} // before click 1 → just the snap marker for the prospective start
|
|
3228
|
+
let b=[s.x,s.y];
|
|
3229
|
+
if(e.shiftKey){b=orthoLock(drawDraft[0],drawDraft[1],b[0],b[1]);snapClear();}else{s.hit?snapMark(s.x,s.y):snapClear();} // ortho locks the axis (no snap marker while locked, like the dim tool)
|
|
3230
|
+
let ln=document.getElementById('drawPrevLine');
|
|
3231
|
+
if(!ln){ln=document.createElementNS(SVGNS,'line');ln.id='drawPrevLine';ln.setAttribute('class','draw');ln.setAttribute('pointer-events','none');svg.appendChild(ln);}
|
|
3232
|
+
ln.setAttribute('x1',drawDraft[0]);ln.setAttribute('y1',drawDraft[1]);ln.setAttribute('x2',b[0]);ln.setAttribute('y2',b[1]);}
|
|
3233
|
+
function drawHintText(){const prof=addProfile?('<b>'+esc(addProfile)+'</b>'):'the current profile'; // voice mirrors dimHintText (tool — Click 1/Click 2 — modifiers)
|
|
3234
|
+
return drawDraft
|
|
3235
|
+
? '✏️ Add member — <b>Click 2:</b> end. Shift=straight · Alt=no snap · Esc=cancel.'
|
|
3236
|
+
: '✏️ Add member — <b>Click 1:</b> start · <b>Click 2:</b> end. New members take '+prof+' as a <b>'+esc(memberTypeLabel(addType))+'</b>. Click a highlighted segment to trace it instead. Shift=straight · Alt=no snap · Esc=exit.';}
|
|
2601
3237
|
function toggleDimChain(){dimChain=!dimChain;if(!dimChain){dimChainPrev=null;dimPrevClear();}render();} // Chain (C): toggle continuous dimensioning; turning it off ends any running chain (render() repaints the panel)
|
|
2602
3238
|
function toggleDimSplit(){dimSplitMode=!dimSplitMode;snapClear();snapOnlyClear2d();render();} // S / "Add split point": arm splitting on the selected dim(s); each click then inserts a point; any transition drops the previous operation's snap override
|
|
2603
|
-
//
|
|
2604
|
-
//
|
|
2605
|
-
//
|
|
2606
|
-
//
|
|
3239
|
+
// Add a point to the SELECTED dimension nearest the click (B8): project the click onto that dim's line
|
|
3240
|
+
// (UNCLAMPED, so it works anywhere — no proximity tolerance). If the point falls BETWEEN the ends → split
|
|
3241
|
+
// the dim there into two; if it falls BEYOND an end → add a continuing dimension from that end to the point
|
|
3242
|
+
// (a running-dimension chain). BOTH split and extend place the new point where you clicked for x/y dims —
|
|
3243
|
+
// the dim graphic sits on the fixed offset line, so the witness points to the feature you picked and the
|
|
3244
|
+
// measured total is preserved; free/oblique dims project onto the measured line so they never kink.
|
|
3245
|
+
// Everything stays selected so you keep adding.
|
|
3246
|
+
// only the style fields this dim actually overrides — splitting/extending carries them to the new
|
|
3247
|
+
// segments, while dims that never overrode anything keep following the model default (C.dim_style),
|
|
3248
|
+
// and DIM_DEF under that. Uses the SAME validators as dimHasOverride/dimStyle, so a junk field is
|
|
3249
|
+
// neither reported as an override nor copied onward into the new segments.
|
|
3250
|
+
const dimStyleOverrides=d=>{const o={};if(_dEnd(d.end))o.end=d.end;if(_dBg(d.bg))o.bg=d.bg;if(_dPlace(d.place))o.place=d.place;return o;};
|
|
2607
3251
|
function dimSplitAt(m){
|
|
2608
|
-
|
|
3252
|
+
let best=null;
|
|
2609
3253
|
for(const d of P.dims){if(!selDimIds.has(d.id))continue;
|
|
2610
|
-
const
|
|
2611
|
-
|
|
2612
|
-
const
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
const
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
3254
|
+
const g=dimGeo(d.a,d.b,d.axis,d.off,d.rot); // the VISIBLE (offset) dim line p1→p2
|
|
3255
|
+
const ax=g.p1[0],ay=g.p1[1],vx=g.p2[0]-ax,vy=g.p2[1]-ay,L2=vx*vx+vy*vy||1;
|
|
3256
|
+
const t=((m[0]-ax)*vx+(m[1]-ay)*vy)/L2; // UNCLAMPED param (t<0 before p1, t>1 past p2)
|
|
3257
|
+
const tc=t<0?0:t>1?1:t,dist=Math.hypot(m[0]-(ax+tc*vx),m[1]-(ay+tc*vy)); // distance to the SEGMENT (clamped foot), not the infinite line — a click beyond a chain then picks the OUTERMOST dim to extend, not an inner one
|
|
3258
|
+
if(!best||dist<best.dist)best={d,t,dist};} // nearest selected dim — no proximity cap, so a click anywhere acts
|
|
3259
|
+
if(!best){toast('Select a dimension, then click to split or extend it');return;}
|
|
3260
|
+
const d=best.d,t=best.t,EPS=0.02,pv=snapshot();
|
|
3261
|
+
if(t>EPS&&t<1-EPS){ // INTERIOR → split into two (both halves keep d.off → offset line stays continuous, no kink)
|
|
3262
|
+
const mid=d.axis==='free'?[d.a[0]+(d.b[0]-d.a[0])*t,d.a[1]+(d.b[1]-d.a[1])*t]:m.slice(); // x/y: split AT the clicked feature (like extend) — the graphic stays on the fixed offset line, so the witness points to what you clicked; free: project onto the baseline to keep the point on the measured line
|
|
3263
|
+
const id1='d'+Date.now()+'_'+(dimSeq++),id2='d'+Date.now()+'_'+(dimSeq++);
|
|
3264
|
+
P.dims=P.dims.filter(x=>x.id!==d.id);
|
|
3265
|
+
const sty=dimStyleOverrides(d); // both halves inherit the split dim's style
|
|
3266
|
+
P.dims.push({id:id1,a:d.a.slice(),b:mid.slice(),axis:d.axis,off:d.off,rot:d.rot,...sty},{id:id2,a:mid.slice(),b:d.b.slice(),axis:d.axis,off:d.off,rot:d.rot,...sty});
|
|
3267
|
+
selDimIds.delete(d.id);selDimIds.add(id1);selDimIds.add(id2);
|
|
3268
|
+
}else{ // BEYOND an end → add a continuing dimension from that end to the clicked point (same axis/off/rot)
|
|
3269
|
+
const beyondB=t>=1-EPS,nearEnd=beyondB?d.b.slice():d.a.slice(); // discriminator must match the EPS band above (else branch runs for t≤EPS OR t≥1-EPS): t≥1-EPS → past the b end, else past a — otherwise a click just inside b extended from a, making a reversed near-full-length dim
|
|
3270
|
+
const far=d.axis==='free'?[d.a[0]+(d.b[0]-d.a[0])*t,d.a[1]+(d.b[1]-d.a[1])*t]:m.slice(); // free: project to stay collinear; x/y: measure to the actual clicked point (graphic sits on the fixed offset line)
|
|
3271
|
+
const id='d'+Date.now()+'_'+(dimSeq++);
|
|
3272
|
+
P.dims.push({id,a:beyondB?nearEnd:far,b:beyondB?far:nearEnd,axis:d.axis,off:d.off,rot:d.rot,...dimStyleOverrides(d)}); // keep the original a→b orientation + style
|
|
3273
|
+
selDimIds.add(id);
|
|
3274
|
+
}
|
|
2620
3275
|
pushUndo(pv);render();sync3D();
|
|
2621
3276
|
}
|
|
2622
3277
|
let dimLastPtr=null; // last canvas pointer during placement, for axis-key live refresh
|
|
@@ -2651,7 +3306,8 @@ function armCm(tool,array){ // re-arming the same config toggles the tool off
|
|
|
2651
3306
|
if(mode==='add'){mode='sel';setMode();if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}
|
|
2652
3307
|
if(dimMode){dimMode=false;setDimMode();}
|
|
2653
3308
|
if(csaxisMode){csaxisMode=false;setCsMode();}
|
|
2654
|
-
if(gridMode||gridPick){gridMode=false;gridPick=false;
|
|
3309
|
+
if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // arming Move/Copy leaves the grid panel — grid mode and cmTool must be mutually exclusive
|
|
3310
|
+
dimStyleMode=false; // …and the Dimension style pane (both own the panel)
|
|
2655
3311
|
geoMode=null;setGeo();selDimIds.clear();dimSplitMode=false;picking=false;pickEnd=null;
|
|
2656
3312
|
cmHudClose();cmPrevClear(); // switching Move⇄Copy mid-pick must drop the old HUD/preview — a stale HUD Enter would commit for the previous tool
|
|
2657
3313
|
if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // and the 3D-side draft (same reason)
|
|
@@ -2671,7 +3327,7 @@ function cmSnapAt(e){const q=toSvg(e);let x=q.x,y=q.y,hit=false;
|
|
|
2671
3327
|
return {x,y,hit};}
|
|
2672
3328
|
function cmOffsetsFor(v){if(cmArrayMode)return cmDraft&&cmDraft.vA?arrayOffsets(cmDraft.vA,cmCountA,v,cmCountB):linearOffsets(v,Math.max(0,cmCountA-1)); // stage A previews countA-1 NEW copies — counts include the original, so the ghost count matches the commit
|
|
2673
3329
|
return cmTool==='copy'?linearOffsets(v,cmCount):[v];}
|
|
2674
|
-
function cmSelBbox(){let x0=1e15,y0=1e15,x1=-1e15,y1=-1e15;for(const m of
|
|
3330
|
+
function cmSelBbox(){let x0=1e15,y0=1e15,x1=-1e15,y1=-1e15;for(const m of sel2d())for(const p of m.wp){x0=Math.min(x0,p[0]);y0=Math.min(y0,p[1]);x1=Math.max(x1,p[0]);y1=Math.max(y1,p[1]);}return [x0,y0,x1,y1];}
|
|
2675
3331
|
function cmPrevClear(){const g=document.getElementById('cmPrevG');if(g)g.remove();snapClear();}
|
|
2676
3332
|
function cmPrev(e){if(!cmTool)return;cmLastEvt=e;
|
|
2677
3333
|
{const h=document.getElementById('cmHint');if(h)h.textContent=cmHintText();}
|
|
@@ -2684,7 +3340,7 @@ function cmPrev(e){if(!cmTool)return;cmLastEvt=e;
|
|
|
2684
3340
|
function cmRefreshPrev(){if(cmTool&&cmDraft&&cmLastEvt)cmPrev(cmLastEvt);}
|
|
2685
3341
|
// ghosts: every selected member at every offset (cap 600 lines → per-offset bbox), then the rubber
|
|
2686
3342
|
// line + arrowhead + ft-in chip. Array stage B keeps direction A's rubber dimmed for context.
|
|
2687
|
-
function cmPrevSvg(v,cur){const sel=
|
|
3343
|
+
function cmPrevSvg(v,cur){const sel=sel2d(),offs=cmOffsetsFor(v);let s='';
|
|
2688
3344
|
const many=sel.length*offs.length>600,bb=many?cmSelBbox():null;
|
|
2689
3345
|
for(const off of offs){
|
|
2690
3346
|
if(many){s+=`<rect class=cmghostbox x="${bb[0]+off[0]}" y="${bb[1]+off[1]}" width="${bb[2]-bb[0]}" height="${bb[3]-bb[1]}"/>`;continue;}
|
|
@@ -2728,7 +3384,7 @@ function cmClick(e){
|
|
|
2728
3384
|
cmCommit(v);}
|
|
2729
3385
|
// Shared commit core (2D picks, HUD, and the 3D flow all land here): offs = [dx,dy,dzIn] lists in
|
|
2730
3386
|
// plan px / inches. Move applies offs[0] to the selection; copy clones per offset and selects the set.
|
|
2731
|
-
function cmApplyOffsets(offs){const sel=
|
|
3387
|
+
function cmApplyOffsets(offs){const sel=sel2d();if(!sel.length){toast('Selection is empty — '+(cmTool==='move'?'Move':'Copy')+' ended');disarmCm();render();return;}
|
|
2732
3388
|
if(cmArrayMode&&cmCountA*cmCountB>100){toast('Array capped at 100 instances — lower the counts (two passes reach further)');return;}
|
|
2733
3389
|
if(!offs.length){toast(cmArrayMode?'A 1 × 1 array places no copies — raise a count':'Nothing to place');return;} // empty offset list (e.g. array 1×1) → no-op, never deref offs[0]
|
|
2734
3390
|
edit(()=>{
|
|
@@ -2783,7 +3439,7 @@ function cmHudCommit(str){const pv=parseVec(str);
|
|
|
2783
3439
|
if(cmArrayMode&&!cmDraft.vA){cmDraft.vA=v;cmHudClose();cmRefreshPrev();panel();return;} // typed spacing commits direction A
|
|
2784
3440
|
cmHudClose();cmCommit(v);}
|
|
2785
3441
|
// --- Move/Copy to level (spec §4.5): themed plan picker, click-row selection (no native radios),
|
|
2786
|
-
// double-click commits.
|
|
3442
|
+
// double-click commits. Undo is one whole-model global-stack entry (source removals + target adds). ---
|
|
2787
3443
|
let lvModal=null;
|
|
2788
3444
|
function lvOpen(){return !!lvModal;}
|
|
2789
3445
|
function closeLevelModal(){if(lvModal){lvModal.remove();lvModal=null;}}
|
|
@@ -2814,23 +3470,26 @@ function openLevelModal(tool){ // works from 2D and 3D — the commit is plan-
|
|
|
2814
3470
|
const cancel=document.createElement('button');cancel.textContent='Cancel';cancel.onclick=closeLevelModal;
|
|
2815
3471
|
go.onclick=()=>{if(pick>=0){toLevelCommit(tool,pick);closeLevelModal();}};
|
|
2816
3472
|
ft.append(cancel,go);pn.append(hd,body,note,ft);lvModal.append(bd,pn);document.body.appendChild(lvModal);}
|
|
2817
|
-
function toLevelCommit(tool,ti){const sel=selArr();const T=C.plans[ti];
|
|
3473
|
+
function toLevelCommit(tool,ti){const sel=selArr();const T=C.plans[ti]; // model-wide: a cross-sheet selection all moves/copies to the target level (counts match the modal, which reads selIds)
|
|
2818
3474
|
if(!sel.length){toast('Selection is empty — nothing to '+(tool==='move'?'move':'copy'));return;}
|
|
2819
|
-
if(!T
|
|
3475
|
+
if(!T)return;
|
|
2820
3476
|
if(!Array.isArray(T.members))T.members=[];
|
|
2821
3477
|
const dstDef=(T.default_tos!=null?T.default_tos:198);
|
|
2822
|
-
const pv=
|
|
3478
|
+
const pv=snapshot(); // whole-model pre-mutation → one global-stack entry undoes the source removals AND the target adds
|
|
2823
3479
|
const moved=[];
|
|
2824
|
-
for(const m of sel){const
|
|
2825
|
-
|
|
3480
|
+
for(const m of sel){const srcPl=planeOf(m.id);if(srcPl===T)continue; // already on the target level → no-op for this member
|
|
3481
|
+
const srcDef=(srcPl&&srcPl.default_tos!=null?srcPl.default_tos:defaultTOS); // retarget TOS from EACH source plane's own default (sources may span sheets)
|
|
3482
|
+
const c=(tool==='copy')?cloneMember(m):m;retargetTos(c,srcDef,dstDef);moved.push(c);}
|
|
3483
|
+
if(!moved.length){toast('Selection is already on '+T.sheet);return;}
|
|
3484
|
+
if(tool==='move'){const mv=new Set(moved.map(m=>m.id));for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!mv.has(m.id));selIds=new Set();} // remove moved members from EVERY source plane, not just the active one
|
|
2826
3485
|
T.members.push(...moved);T.members.forEach(ensureMeta);
|
|
2827
|
-
pushUndo(pv);
|
|
3486
|
+
pushUndo(pv);disarmCm();render();sync3D(); // one global-stack entry; disarm BEFORE render so the panel never advertises a dead tool
|
|
2828
3487
|
toast((tool==='move'?'Moved ':'Copied ')+moved.length+' member'+(moved.length===1?'':'s')+' to '+T.sheet);}
|
|
2829
3488
|
// --- Local coordinate system "set axes" tool: two snapped clicks (origin, then X-direction) define
|
|
2830
3489
|
// P.frame={o,u}. Shares buildSnap/snap/snapMark; preview lives in its own <g> (render() rebuilds wholesale). ---
|
|
2831
3490
|
function setCsMode(){document.body.classList.toggle('csaxison',csaxisMode);
|
|
2832
3491
|
const b=document.getElementById('csSetB');if(b)b.classList.toggle('on',csaxisMode);
|
|
2833
|
-
if(csaxisMode){if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(cmTool)disarmCm();geoMode=null;setGeo();selIds.clear();selDimIds.clear();} // arming disarms conflicting tools + clears selection
|
|
3492
|
+
if(csaxisMode){if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(cmTool)disarmCm();dimStyleMode=false;geoMode=null;setGeo();selIds.clear();selDimIds.clear();} // arming disarms conflicting tools (incl. the Dimension style pane) + clears selection
|
|
2834
3493
|
snapOnlyClear2d(); // any set-axes transition ends the previous operation → the snap override reverts (arming must not inherit another tool's override)
|
|
2835
3494
|
csDraft=null;csPrevClear();}
|
|
2836
3495
|
function csSnapAt(e){const q=toSvg(e);if(e.altKey)return [q.x,q.y];buildSnap(null);const sn=snap(q.x,q.y);return [sn.x,sn.y];}
|
|
@@ -2882,18 +3541,24 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
2882
3541
|
if(csaxisMode){csClick(e);e.preventDefault();return;} // set-local-axes armed → clicks define origin then X-direction
|
|
2883
3542
|
if(dimMode){dimClick(e);e.preventDefault();return;} // tool armed → all clicks place dimension points
|
|
2884
3543
|
if(cmTool){cmClick(e);e.preventDefault();return;} // Move/Copy armed → clicks pick base/destination
|
|
3544
|
+
if(gridLinePick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear();
|
|
3545
|
+
if(!gridLinePick.a){gridLinePick.a=[x,y];const ln=document.createElementNS(SVGNS,'line');ln.setAttribute('class','gridprev');ln.setAttribute('x1',x);ln.setAttribute('y1',y);ln.setAttribute('x2',x);ln.setAttribute('y2',y);svg.appendChild(ln);gridLinePick.line=ln;panel();}
|
|
3546
|
+
else{const a=gridLinePick.a.slice(),b=[x,y],pv=snapshot();if(gridAddFreeLine(a,b)){pushUndo(pv);gridCancelLinePick();render();refresh3DGrid();}else panel();}
|
|
3547
|
+
e.preventDefault();return;}
|
|
2885
3548
|
if(gridPick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear(); // armed pick-origin → one snapped click sets the grid's 1-A corner (undoable)
|
|
2886
|
-
gridPick=false;
|
|
3549
|
+
gridPick=false;gridSetPickClass();if(P.grid)edit(()=>{P.grid.origin=[x,y];});else panel();e.preventDefault();return;}
|
|
2887
3550
|
{const gb=t.closest&&t.closest('g.gridbubg'),ghit=(t.classList&&t.classList.contains('gridhit'))?t:null; // grid line body OR label bubble → drag slides the line (a no-move bubble click still opens the panel)
|
|
2888
3551
|
const gel=gb||ghit;
|
|
2889
3552
|
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&P.grid){
|
|
2890
|
-
const axis=gel.dataset.gv!=null?'v':'h',gi=+(gel.dataset.gv!=null?gel.dataset.gv:gel.dataset.gh);
|
|
2891
|
-
if(isFinite(gi)){buildSnap(null,{noGrid:true,noDims:true});const q=toSvg(e);const geo=gridGeo();const line=geo&&geo[axis][gi];
|
|
2892
|
-
if(line){const end=gb?+(gb.dataset.end||0):null; // a bubble grab can become an END drag
|
|
2893
|
-
drag={type:'
|
|
3553
|
+
const free=gel.dataset.gl!=null,axis=free?'l':(gel.dataset.gv!=null?'v':'h'),gi=+(free?gel.dataset.gl:(gel.dataset.gv!=null?gel.dataset.gv:gel.dataset.gh));
|
|
3554
|
+
if(isFinite(gi)){buildSnap(null,{noGrid:true,noDims:true});const q=toSvg(e);const geo=gridGeo();const line=geo&&(free?(geo.lines||[])[gi]:geo[axis][gi]);
|
|
3555
|
+
if(line){const end=gb?+(gb.dataset.end||0):null; // a bubble grab can become an END drag; a body grab translates the line
|
|
3556
|
+
if(free)drag={type:'gridfree',gi,startPt:[q.x,q.y],origA:line.a.slice(),origB:line.b.slice(),end,bubble:!!gb,moved:false,pre:snapshot()};
|
|
3557
|
+
else drag={type:'gridline',axis,gi,startPt:[q.x,q.y],orig:axis==='v'?line.x:line.y,origEnd:end===0?line.lo:line.hi,end,
|
|
2894
3558
|
base:geo[axis].map(l=>axis==='v'?l.x:l.y),bubble:!!gb,moved:false,dir:null,pre:snapshot()}; // base = dragstart positions so one drag quantizes the string ONCE (no 1/16" creep on unmoved lines)
|
|
2895
3559
|
svg.setPointerCapture(e.pointerId);e.preventDefault();return;}}}}
|
|
2896
3560
|
if(gridMode)setGridMode(false); // any other canvas click leaves the grid panel — selection takes the panel back (fields commit on blur first)
|
|
3561
|
+
if(dimStyleMode)setDimStyleMode(false); // …and the Dimension style pane, so clicking a dim hands the panel to its inspector
|
|
2897
3562
|
if(dimSplitMode&&selDimIds.size&&dimsVisible&&mode==='sel'){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear();dimSplitAt([x,y]);e.preventDefault();return;} // split mode → each click inserts a point into the selected dim under it
|
|
2898
3563
|
if(t.dataset.dimend!=null&&mode==='sel'){const id=t.dataset.dim,end=+t.dataset.dimend;buildSnap(id);drag={type:'dimend',id,end,pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // drag a selected dim's anchor handle → re-measure (snaps; exclude this dim so the end can't snap to its own line/midpoint)
|
|
2899
3564
|
if(t.dataset.dim&&mode==='sel'){const did=t.dataset.dim;selIds.clear(); // a dim click is member-exclusive (clears any member selection)
|
|
@@ -2910,48 +3575,78 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
2910
3575
|
snapClear();doSplit(m,cut);return;}
|
|
2911
3576
|
if(geoMode==='el'&&selIds.size>=1){ // extend/trim → pick ONE target line; ALL selected ends snap to it
|
|
2912
3577
|
let tgt=null;
|
|
2913
|
-
if(t.classList.contains('member')&&!selIds.has(t.dataset.id)){const tm=byId(t.dataset.id);
|
|
3578
|
+
if(t.classList.contains('member')&&!selIds.has(t.dataset.id)){const tm=byId(t.dataset.id);
|
|
3579
|
+
if(tm&&isBrace(tm))toast('A brace can’t be an extend/trim target — its drawn line is offset from its work points'); // clicking the VISIBLE brace body would silently target its invisible baseline
|
|
3580
|
+
else if(tm)tgt=[tm.wp[0],tm.wp[1]];}
|
|
2914
3581
|
else if(t.classList.contains('seg')){const sg=P.segments.find(s=>s.id===t.dataset.seg);if(sg)tgt=[sg.a,sg.b];}
|
|
2915
|
-
if(tgt){geoMode=null;setGeo();snapEndMulti(
|
|
3582
|
+
if(tgt){geoMode=null;setGeo();snapEndMulti(sel2d(),tgt[0],tgt[1]);} // miss (empty/own line) keeps the mode armed
|
|
2916
3583
|
return;}
|
|
2917
3584
|
if(t.classList.contains('handle')){const id=t.dataset.mid||[...selIds][0],m=byId(id),h=+t.dataset.h;if(!m)return;buildSnap(id);
|
|
2918
3585
|
drag={type:'end',h,id,anchor:m.wp[1-h].slice(),orig:m.wp[h].slice(),pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // anchor = the fixed end (length ref); orig = where this end started (moved ref)
|
|
2919
3586
|
if(t.classList.contains('lblhot')){const prof=t.dataset.prof;
|
|
2920
|
-
if(picking&&pickKind==='profile'&&selIds.size===1){const id=[...selIds][0];picking=false;edit(()=>{const m=byId(id);m.profile=prof;m.rfi=(_wt(prof)==null);if(!profs.includes(prof)){profs.push(prof);profs.sort();}});return;}
|
|
2921
|
-
if(mode==='add'){addProfile=prof;
|
|
3587
|
+
if(mode!=='add'&&picking&&pickKind==='profile'&&selIds.size===1){const id=[...selIds][0];picking=false;edit(()=>{const m=byId(id);m.profile=prof;m.rfi=(_wt(prof)==null);if(!profs.includes(prof)){profs.push(prof);profs.sort();}});return;} // in Add mode a profile pick ALWAYS means "adopt as the current add profile" (a 3D draw can leave a member selected)
|
|
3588
|
+
if(mode==='add'&&!drawDraft){addProfile=prof;if(picking&&pickKind==='profile'){picking=false;render();return;} // adopt a label's profile ONLY before the first click; mid-draw a label click falls through to drawClick → places the END on that label's point (mirrors the seg guard)
|
|
3589
|
+
const hi=document.getElementById('addProf');if(hi)hi.value=addProfile;const ph=document.getElementById('pickHint');if(ph){ph.classList.add('pick');setTimeout(()=>ph&&ph.classList.remove('pick'),450);}return;}
|
|
2922
3590
|
return;}
|
|
2923
3591
|
if(t.classList.contains('dethot')){const det=t.dataset.det;
|
|
2924
3592
|
if(picking&&pickKind==='detail'&&pickEnd){const o=pickEnd;picking=false;pickEnd=null;edit(()=>{o.detail=det;});}return;}
|
|
2925
3593
|
{const cg=t.closest('g.cohot');if(cg){const sheet=cg.dataset.coSheet,prev=cg.dataset.coPrev; // Workstream B smart jump
|
|
2926
3594
|
const idx=sheet?C.plans.findIndex(p=>p.sheet&&p.sheet.toUpperCase()===sheet.toUpperCase()):-1;
|
|
2927
3595
|
if(idx>=0){if(idx!==C.active)setPlan(idx);else fitToWindow();} // referenced sheet is loaded → switch to it (or re-frame if already here)
|
|
2928
|
-
else if(
|
|
2929
|
-
else toast(
|
|
3596
|
+
else if(sheet)tryDetailVector(sheet,prev); // not loaded → crisp VECTOR of the referenced sheet (else raster preview, else a toast)
|
|
3597
|
+
else toast('No target sheet for this callout');
|
|
2930
3598
|
return;}}
|
|
2931
|
-
if(t.classList.contains('seg')&&mode==='add'){addFromSeg(t.dataset.seg);return;}
|
|
2932
|
-
if(
|
|
3599
|
+
if(t.classList.contains('seg')&&mode==='add'&&!drawDraft){addFromSeg(t.dataset.seg);return;} // segment quick-add ONLY when no draw is in progress; mid-draw a seg click falls through to drawClick → places the end ON that segment
|
|
3600
|
+
if(mode==='add'){drawClick(e);e.preventDefault();return;} // Add-member is click-to-place (like the Dimension tool): every canvas click drops a start/end point (snapped, incl. onto the traced overlay). Runs AFTER the label-pick (lblhot) and detected-segment (seg) branches above, so those still work.
|
|
2933
3601
|
if(t.classList.contains('member')&&mode==='sel'){const id=t.dataset.id,ctrl=(e.ctrlKey||e.metaKey),add=(ctrl||e.shiftKey),p=toSvg(e);
|
|
2934
3602
|
// Plain click selects on down (so a no-drag click still selects even with drag-move off). Ctrl/Shift defer
|
|
2935
3603
|
// their select to up — a Ctrl-DRAG copies, a Shift-DRAG moves (Shift also ortho-locks the move to H/V), and an additive-CLICK toggles selection (Tekla: Ctrl or Shift).
|
|
2936
3604
|
if(!add&&!selIds.has(id)){selIds=new Set([id]);render();}
|
|
2937
3605
|
const canDrag=dragMoveOn; // the toggle gates BOTH gestures: left-drag=move and Ctrl+drag=copy (Ctrl/Shift+CLICK still toggles selection below — a click, not a drag)
|
|
2938
|
-
const srcIds=(add&&!selIds.has(id))?new Set([id]):new Set(
|
|
3606
|
+
const srcIds=(add&&!selIds.has(id))?new Set([id]):new Set(sel2d().map(m=>m.id)); // Ctrl/Shift on an unselected member acts on just it; else the whole selection
|
|
2939
3607
|
const items=[...srcIds].map(mid=>{const m=byId(mid);return{id:mid,o0:m.wp[0].slice(),o1:m.wp[1].slice()};});
|
|
2940
3608
|
buildSnap(srcIds); // snap the dragged line(s) to OTHER members'/segments' endpoints
|
|
2941
3609
|
drag={type:'grab',copy:ctrl,add,armed:canDrag,start:[p.x,p.y],items,clickId:id,pre:snapshot(),moved:false};
|
|
2942
3610
|
svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // always capture: even an unarmed grab tracks the gesture so a blocked drag can teach the toggle
|
|
2943
|
-
if((t===svg||t.tagName==='image'||t.classList.contains('seg'))&&mode==='sel'){const p=toSvg(e); // t===svg → drag on bare canvas
|
|
3611
|
+
if((t===svg||t.tagName==='image'||t.classList.contains('pdfsheet')||t.classList.contains('seg'))&&mode==='sel'){const p=toSvg(e); // t===svg/pdfsheet → drag on bare/vector canvas still box-selects
|
|
2944
3612
|
const rc=document.createElementNS('http://www.w3.org/2000/svg','rect');rc.setAttribute('class','marquee window');svg.appendChild(rc);
|
|
2945
3613
|
drag={type:'marquee',x0:p.x,y0:p.y,sx0:e.clientX,window:true,add:(e.ctrlKey||e.metaKey||e.shiftKey),rect:rc};svg.setPointerCapture(e.pointerId);e.preventDefault();}});
|
|
2946
3614
|
svg.addEventListener('pointermove',e=>{
|
|
2947
3615
|
if(csaxisMode){csPrev(e);return;}
|
|
2948
3616
|
if(dimMode){dimPrev(e);return;}
|
|
3617
|
+
if(mode==='add'&&!view3d){drawPrev(e);return;} // Add-member hover: snap marker + rubber-band from the placed start (no drag — click-to-place)
|
|
2949
3618
|
if(cmTool){cmPrev(e);return;}
|
|
3619
|
+
if(gridLinePick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y,sn.kind):snapClear();}else snapClear();
|
|
3620
|
+
if(gridLinePick.a){
|
|
3621
|
+
if(gridLinePick.line){gridLinePick.line.setAttribute('x2',x);gridLinePick.line.setAttribute('y2',y);}
|
|
3622
|
+
gridReadout(e,dimValueText(Math.hypot(x-gridLinePick.a[0],y-gridLinePick.a[1])), ' · angle '+Math.round(Math.atan2(y-gridLinePick.a[1],x-gridLinePick.a[0])*180/Math.PI)+'°');}
|
|
3623
|
+
return;}
|
|
2950
3624
|
if(dimSplitMode&&dimsVisible){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);sn.hit?snapMark(sn.x,sn.y):snapClear();}else snapClear();return;} // split mode → show the snap marker for the prospective split point
|
|
2951
3625
|
if(geoMode==='split'&&selIds.size===1&&!drag){const m=byId([...selIds][0]);if(m){const q=toSvg(e),raw=projPt([q.x,q.y],m.wp[0],m.wp[1]);
|
|
2952
3626
|
const d=Math.hypot(q.x-raw.pt[0],q.y-raw.pt[1]);
|
|
2953
3627
|
if(d<16/zoom&&raw.t>0.03&&raw.t<0.97){let cut=raw.pt;if(!e.altKey){buildSnap(m.id);const sn=snap(raw.pt[0],raw.pt[1]);if(sn.hit){const p2=projPt([sn.x,sn.y],m.wp[0],m.wp[1]);if(p2.t>0.02&&p2.t<0.98)cut=p2.pt;}}snapMark(cut[0],cut[1],'end');}else snapClear();}return;} // the cut lands ON the member → always the neutral circle, never a stale midpoint △ (e.g. Alt held = no snap() this frame)
|
|
2954
3628
|
if(!drag)return;const p=toSvg(e);
|
|
3629
|
+
if(drag.type==='gridfree'){const dxc=p.x-drag.startPt[0],dyc=p.y-drag.startPt[1];
|
|
3630
|
+
if(!drag.moved){if(Math.hypot(dxc,dyc)<=4/zoom)return;drag.moved=true;}
|
|
3631
|
+
const line=P.grid&&P.grid.lines&&P.grid.lines[drag.gi];if(!line)return;
|
|
3632
|
+
let a=drag.origA.slice(),b=drag.origB.slice();
|
|
3633
|
+
if(drag.end!=null){const target=drag.end===0?a:b;let x=target[0]+dxc,y=target[1]+dyc;
|
|
3634
|
+
if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
3635
|
+
const other=drag.end===0?b:a;if(Math.hypot(x-other[0],y-other[1])>=6/zoom){if(drag.end===0)a=[x,y];else b=[x,y];}
|
|
3636
|
+
gridReadout(e,dimValueText(Math.hypot(b[0]-a[0],b[1]-a[1])), ' · angle '+Math.round(Math.atan2(b[1]-a[1],b[0]-a[0])*180/Math.PI)+'°');
|
|
3637
|
+
}else{
|
|
3638
|
+
if(!e.altKey){let best=null,bd=SNAP_PX/zoom;
|
|
3639
|
+
for(const o of [drag.origA,drag.origB]){const nx=o[0]+dxc,ny=o[1]+dyc;
|
|
3640
|
+
if(snapAllowed('end'))for(const q of snapPts){const d=Math.hypot(q[0]-nx,q[1]-ny);if(d<bd){bd=d;best={cx:q[0]-nx,cy:q[1]-ny,q,kind:'end'};}}
|
|
3641
|
+
if(snapAllowed('int'))for(const q of snapInts){const d=Math.hypot(q[0]-nx,q[1]-ny);if(d<bd){bd=d;best={cx:q[0]-nx,cy:q[1]-ny,q,kind:'int'};}}
|
|
3642
|
+
if(snapAllowed('mid'))for(const q of snapMids){const d=Math.hypot(q[0]-nx,q[1]-ny);if(d<bd){bd=d;best={cx:q[0]-nx,cy:q[1]-ny,q,kind:'mid'};}}
|
|
3643
|
+
if(snapAllowed('line')){const ln=nearestOnLine(nx,ny,bd);if(ln){bd=ln.d;best={cx:ln.x-nx,cy:ln.y-ny,q:[ln.x,ln.y],kind:'line'};}}
|
|
3644
|
+
if(snapAllowed('ext')){const ex=nearestOnExtension(nx,ny,bd);if(ex){bd=Math.hypot(ex.x-nx,ex.y-ny);best={cx:ex.x-nx,cy:ex.y-ny,q:[ex.x,ex.y],kind:'ext',from:ex.from};}}}
|
|
3645
|
+
if(best){a=[drag.origA[0]+dxc+best.cx,drag.origA[1]+dyc+best.cy];b=[drag.origB[0]+dxc+best.cx,drag.origB[1]+dyc+best.cy];if(best.kind==='ext')snapExtFrom=best.from;snapMark(best.q[0],best.q[1],best.kind);}else{a=[drag.origA[0]+dxc,drag.origA[1]+dyc];b=[drag.origB[0]+dxc,drag.origB[1]+dyc];snapClear();}}
|
|
3646
|
+
else{a=[drag.origA[0]+dxc,drag.origA[1]+dyc];b=[drag.origB[0]+dxc,drag.origB[1]+dyc];snapClear();}
|
|
3647
|
+
gridReadout(e,gridDelta(Math.hypot(a[0]-drag.origA[0],a[1]-drag.origA[1])),'');
|
|
3648
|
+
}
|
|
3649
|
+
line.a=a;line.b=b;refreshGridLayer();const dl=svg.querySelector(`line.gridln[data-gl="${drag.gi}"]`);if(dl)dl.classList.add('gdrag');return;}
|
|
2955
3650
|
if(drag.type==='gridline'){const dxc=p.x-drag.startPt[0],dyc=p.y-drag.startPt[1];
|
|
2956
3651
|
if(!drag.moved){if(Math.hypot(dxc,dyc)<=4/zoom)return;drag.moved=true; // past the tolerance = a drag, not a click
|
|
2957
3652
|
const along=drag.axis==='v'?Math.abs(dyc):Math.abs(dxc),perp=drag.axis==='v'?Math.abs(dxc):Math.abs(dyc);
|
|
@@ -2982,10 +3677,6 @@ svg.addEventListener('pointermove',e=>{
|
|
|
2982
3677
|
return;}
|
|
2983
3678
|
if(drag.type==='dimend'){const d=P.dims.find(x=>x.id===drag.id);if(d){let x=p.x,y=p.y;if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();if(drag.end===0)d.a=[x,y];else d.b=[x,y];render();}return;} // dragging a dim anchor → snap + re-measure live
|
|
2984
3679
|
if(drag.type==='dim'){const d=P.dims.find(x=>x.id===drag.id);if(d){d.off=dimOffFromPointer(d.a,d.b,d.axis,[p.x,p.y],d.rot);render();}return;}
|
|
2985
|
-
if(drag.type==='draw'){let x=p.x,y=p.y;
|
|
2986
|
-
if(e.shiftKey){[x,y]=orthoLock(drag.x0,drag.y0,x,y);snapClear();} // ortho draw — local frame when set, else screen H/V
|
|
2987
|
-
else if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
2988
|
-
drag.line.setAttribute('x2',x);drag.line.setAttribute('y2',y);drag.cur=[x,y];return;}
|
|
2989
3680
|
if(drag.type==='marquee'){const x=Math.min(drag.x0,p.x),y=Math.min(drag.y0,p.y),w=Math.abs(p.x-drag.x0),h=Math.abs(p.y-drag.y0);
|
|
2990
3681
|
drag.window=(e.clientX>=drag.sx0); // Tekla: drag L→R = window (enclose); R→L = crossing (touch)
|
|
2991
3682
|
drag.rect.classList.toggle('window',drag.window); // solid rect = window, dashed = crossing (visual affordance)
|
|
@@ -3014,30 +3705,32 @@ svg.addEventListener('pointermove',e=>{
|
|
|
3014
3705
|
else snapClear();
|
|
3015
3706
|
for(const it of drag.items){const m=byId(it.id);if(!m)continue;
|
|
3016
3707
|
m.wp[0]=[it.o0[0]+dx,it.o0[1]+dy];m.wp[1]=[it.o1[0]+dx,it.o1[1]+dy];updateLine(m);}
|
|
3017
|
-
if(selIds.size<=2)for(const m of
|
|
3708
|
+
if(selIds.size<=2)for(const m of sel2d())updateHandles(m);return;}
|
|
3018
3709
|
// endpoint
|
|
3019
3710
|
const m=byId(drag.id);if(!m)return;let x=p.x,y=p.y;
|
|
3020
3711
|
if(e.shiftKey){[x,y]=orthoLock(drag.anchor[0],drag.anchor[1],x,y);snapClear();} // ortho endpoint — local frame when set, else screen H/V
|
|
3021
|
-
else if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
3712
|
+
else if(!e.altKey){const sn=snap(x,y,drag.anchor);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear(); // anchor = the member's fixed end → ⟂/∥ to a target line
|
|
3022
3713
|
m.wp[drag.h]=[x,y];updateLine(m);updateHandles(m);
|
|
3023
3714
|
{let g=document.getElementById('epPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='epPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}epPrevDraw(g,drag.orig,drag.anchor,[x,y],m);}}); // live moved + length readout
|
|
3024
3715
|
svg.addEventListener('pointerup',()=>{if(!drag)return;snapClear();epPrevClear();
|
|
3716
|
+
if(drag.type==='gridfree'){const wasBubble=drag.bubble,moved=drag.moved,pre=drag.pre;drag=null;gridReadoutHide();snapOnlyClear2d();
|
|
3717
|
+
if(!moved){if(wasBubble){setGridMode(true);
|
|
3718
|
+
svg.querySelectorAll('line.member.sel,polygon.member.sel').forEach(n=>{n.classList.remove('sel');n.style.filter='';});svg.querySelectorAll('g.bracesym').forEach(n=>{n.classList.remove('sel');n.style.filter='';});
|
|
3719
|
+
svg.querySelectorAll('circle.handle,circle.dimhandle,circle.numbg,text.numtx').forEach(n=>n.remove());
|
|
3720
|
+
svg.querySelectorAll('.dimsel').forEach(n=>n.classList.remove('dimsel'));}
|
|
3721
|
+
return;}
|
|
3722
|
+
if(pre&&snapshot()!==pre)pushUndo(pre);refresh3DGrid();render();return;}
|
|
3025
3723
|
if(drag.type==='gridline'){const wasBubble=drag.bubble,moved=drag.moved,pre=drag.pre;drag=null;gridReadoutHide();
|
|
3026
3724
|
snapOnlyClear2d(); // a grid-line drag is one discrete operation → its single-shot snap override always reverts (grid-line drags can run while the grid panel is open, so don't gate on anyToolActive())
|
|
3027
3725
|
if(!moved){if(wasBubble){setGridMode(true); // opens the panel (clears the logical selection). NO render() — replacing the bubble between the two clicks of a dbl-click would swallow the rename gesture…
|
|
3028
|
-
svg.querySelectorAll('line.member.sel').forEach(n=>{n.classList.remove('sel');n.style.filter='';}); // …so drop the stale selection VISUALS surgically instead
|
|
3726
|
+
svg.querySelectorAll('line.member.sel,polygon.member.sel').forEach(n=>{n.classList.remove('sel');n.style.filter='';});svg.querySelectorAll('g.bracesym').forEach(n=>{n.classList.remove('sel');n.style.filter='';}); // …so drop the stale selection VISUALS surgically instead
|
|
3029
3727
|
svg.querySelectorAll('circle.handle,circle.dimhandle,circle.numbg,text.numtx').forEach(n=>n.remove());
|
|
3030
3728
|
svg.querySelectorAll('.dimsel').forEach(n=>n.classList.remove('dimsel'));}
|
|
3031
3729
|
return;} // a no-move line-body click is a no-op (selection untouched)
|
|
3032
|
-
if(pre&&snapshot()!==pre)pushUndo(pre);render();return;}
|
|
3033
|
-
if(drag.type==='draw'){const a=[drag.x0,drag.y0],b=drag.cur||a;drag.line.remove();
|
|
3034
|
-
if(len(a,b)>6){const dx=Math.abs(b[0]-a[0]),dy=Math.abs(b[1]-a[1]),o=dx>3*dy?'H':(dy>3*dx?'V':'D');
|
|
3035
|
-
const id='m'+Date.now(),pv=snapshot();P.members.push(ensureMeta({id,profile:addProfile,wp:[a,b],angle:o,rfi:(_wt(addProfile)==null)}));
|
|
3036
|
-
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}pushUndo(pv);}
|
|
3037
|
-
drag=null;render();return;}
|
|
3730
|
+
if(pre&&snapshot()!==pre)pushUndo(pre);refresh3DGrid();render();return;}
|
|
3038
3731
|
if(drag.type==='marquee'){const r=drag.cur,win=drag.window!==false,add=drag.add;
|
|
3039
3732
|
if(r&&(r[2]-r[0]>2||r[3]-r[1]>2)){
|
|
3040
|
-
const memHit=m=>win?(inRect(
|
|
3733
|
+
const memHit=m=>{const w=isBrace(m)?braceDisplayLine(m):m.wp;return win?(inRect(w[0],r)&&inRect(w[1],r)):rectHit(w[0],w[1],r);}; // window: both ends enclosed · crossing: touched · brace = its VISIBLE offset line (Codex round-1)
|
|
3041
3734
|
const mIds=P.members.filter(memHit).map(m=>m.id), dIds=[];
|
|
3042
3735
|
if(dimsVisible)for(const d of P.dims){const g=dimGeo(d.a,d.b,d.axis,d.off,d.rot); // area-select grabs dims by their VISIBLE geometry — the dim line + its two witness lines (not the invisible anchor span)
|
|
3043
3736
|
const hit=win?(inRect(g.p1,r)&&inRect(g.p2,r)):(rectHit(g.p1,g.p2,r)||rectHit(g.w[0][0],g.w[0][1],r)||rectHit(g.w[1][0],g.w[1][1],r));
|
|
@@ -3059,17 +3752,19 @@ svg.addEventListener('pointerup',()=>{if(!drag)return;snapClear();epPrevClear();
|
|
|
3059
3752
|
if(drag.pre&&snapshot()!==drag.pre)pushUndo(drag.pre);
|
|
3060
3753
|
if(!anyToolActive())snapOnlyClear2d(); // a select-mode drag WAS the operation → the override was single-shot
|
|
3061
3754
|
drag=null;render();});
|
|
3062
|
-
svg.addEventListener('pointercancel',()=>{epPrevClear();if(drag&&drag.type==='gridline'){drag=null;gridReadoutHide();snapClear();render();}}); // a cancelled pointer must not strand the floating readout
|
|
3755
|
+
svg.addEventListener('pointercancel',()=>{epPrevClear();if(drag&&(drag.type==='gridline'||drag.type==='gridfree')){drag=null;gridReadoutHide();snapClear();render();}}); // a cancelled pointer must not strand the floating readout
|
|
3063
3756
|
svg.addEventListener('dblclick',e=>{ // dbl-click a grid bubble → rename that label in place
|
|
3064
3757
|
const at=document.elementFromPoint(e.clientX,e.clientY); // the pointer capture the drag takes retargets dblclick to the svg root — resolve the bubble by position, not e.target
|
|
3065
3758
|
const gb=at&&at.closest&&at.closest('g.gridbubg');
|
|
3066
3759
|
if(gb&&mode==='sel'&&P&&P.grid&&!dimMode&&!csaxisMode&&!geoMode&&!picking){
|
|
3067
3760
|
e.preventDefault();
|
|
3068
|
-
gridRenameBubble(gb.dataset.gv!=null?'v':'h',+(gb.dataset.gv!=null?gb.dataset.gv:gb.dataset.gh),gb.querySelector('circle'));}});
|
|
3069
|
-
function setMode(){document.body.classList.toggle('add',mode==='add');document.getElementById('mAdd').classList.toggle('on',mode==='add');
|
|
3761
|
+
gridRenameBubble(gb.dataset.gl!=null?'l':(gb.dataset.gv!=null?'v':'h'),+(gb.dataset.gl!=null?gb.dataset.gl:(gb.dataset.gv!=null?gb.dataset.gv:gb.dataset.gh)),gb.querySelector('circle'));}});
|
|
3762
|
+
function setMode(){document.body.classList.toggle('add',mode==='add');document.getElementById('mAdd').classList.toggle('on',mode==='add');
|
|
3763
|
+
picking=false;pickKind='profile';pickEnd=null; // a pick armed in one mode must never bleed into the other (an inspector ⌖ pick would otherwise show the Add panel's button pre-armed)
|
|
3764
|
+
if(mode!=='add'){drawDraft=null;drawPrevClear();}} // leaving Add-member drops any in-progress start point + its preview
|
|
3070
3765
|
document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();
|
|
3071
3766
|
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();} // the 3D dim tool shares the left-click — disarm it when entering add mode
|
|
3072
|
-
selDimIds.clear();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 + drops any dim selection + reverts a snap override; leaving add clears the 3D draw draft
|
|
3767
|
+
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
|
|
3073
3768
|
document.getElementById('dimB').onclick=()=>{if(csaxisMode){csaxisMode=false;setCsMode();}dimMode=!dimMode;setDimMode();render();setLastCmd('Dimension',()=>{if(!dimMode){dimMode=true;setDimMode();render();}});};
|
|
3074
3769
|
document.getElementById('csSetB').onclick=()=>{csaxisMode=!csaxisMode;setCsMode();render();};
|
|
3075
3770
|
document.getElementById('csResetB').onclick=()=>{resetFrame();render();};
|
|
@@ -3079,7 +3774,10 @@ function updLenToggle(){const b=document.getElementById('lenToggleB');if(b){b.cl
|
|
|
3079
3774
|
document.getElementById('lenToggleB').onclick=e=>{e.stopPropagation();showSelLen=!showSelLen;try{localStorage.setItem('steel:selLen:v1',showSelLen?'1':'0');}catch(_){}updLenToggle();render();}; // render() repaints the 2D chips + pushes labels to 3D
|
|
3080
3775
|
function updCalloutToggle(){const b=document.getElementById('calloutToggleB');if(b){b.classList.toggle('on',calloutsVisible);b.setAttribute('aria-checked',String(calloutsVisible));}}
|
|
3081
3776
|
document.getElementById('calloutToggleB').onclick=e=>{e.stopPropagation();calloutsVisible=!calloutsVisible;updCalloutToggle();render();};
|
|
3777
|
+
function updPlToggle(){const b=document.getElementById('plToggleB');if(b){const on=!!(C.prop_labels&&C.prop_labels.vis2d);b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on));}} // B1: 2D property-label visibility (independent of 3D)
|
|
3778
|
+
document.getElementById('plToggleB').onclick=e=>{e.stopPropagation();C.prop_labels.vis2d=!C.prop_labels.vis2d;updPlToggle();refreshPropLabels();}; // refreshPropLabels → scheduleSave()+render(): repaints the 2D chips (gated by vis2d) and persists the choice
|
|
3082
3779
|
document.getElementById('gridEditB').onclick=()=>{setGridMode(!gridMode);render();};
|
|
3780
|
+
document.getElementById('dimStyleB').onclick=()=>{setDimStyleMode(!dimStyleMode);render();};
|
|
3083
3781
|
document.getElementById('gridToggleB').onclick=e=>{e.stopPropagation();gridSetVisible(!gridOn());};
|
|
3084
3782
|
document.getElementById('dupB').onclick=()=>{const ids=redundantDups(); // re-scan on demand (also runs live after every edit)
|
|
3085
3783
|
if(!ids.length){const b=document.getElementById('dupB');b.dataset.flash='1';b.classList.add('ok');b.textContent='No duplicates ✓';
|
|
@@ -3112,8 +3810,8 @@ addEventListener('keydown',e=>{
|
|
|
3112
3810
|
if(e.key==='Escape'&&rfiOpen()){closeRFI();return;}
|
|
3113
3811
|
if(e.key==='Escape'&&confOpen()){closeConf();return;}
|
|
3114
3812
|
if(e.key==='Escape'&&snapMenuOpen()){closeSnapMenu();return;}
|
|
3115
|
-
if(e.key==='Escape'&&drag){e.preventDefault();const pre=drag.pre,wasGrid=drag.type==='gridline'; // Esc mid-drag → cancel the command and revert to the pre-drag state (no undo entry committed)
|
|
3116
|
-
if(drag.type==='
|
|
3813
|
+
if(e.key==='Escape'&&drag){e.preventDefault();const pre=drag.pre,wasGrid=drag.type==='gridline'||drag.type==='gridfree'; // Esc mid-drag → cancel the command and revert to the pre-drag state (no undo entry committed)
|
|
3814
|
+
if(drag.type==='marquee'&&drag.rect)drag.rect.remove();
|
|
3117
3815
|
drag=null;snapClear();epPrevClear();gridReadoutHide();if(wasGrid||!anyToolActive())snapOnlyClear2d(); // a gridline drag's single-shot snap override is always cleared (it can run with the grid panel open, so don't gate on anyToolActive) — matches the normal release
|
|
3118
3816
|
if(pre)apply(pre);else render(); // apply() restores the snapshot + re-renders (2D+3D); draw/marquee have no snapshot, just refresh
|
|
3119
3817
|
return;}
|
|
@@ -3121,8 +3819,10 @@ addEventListener('keydown',e=>{
|
|
|
3121
3819
|
if(e.key==='Home'){e.preventDefault();if(view3d&&window.Steel3DView)window.Steel3DView.frameAll();else fitToWindow();return;}
|
|
3122
3820
|
if(!view3d&&!inForm&&(((e.key==='z'||e.key==='Z')&&e.altKey)||(e.key===' '&&e.shiftKey))){e.preventDefault();zoomToSelection();return;} // 2D zoom-to-selected (Tekla Shift+Space / Alt+Z); 3D handles its own (steel-3d-view onKey)
|
|
3123
3821
|
if((e.key===' '||e.key==='Enter')&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){if(!anyToolActive()&&lastCmd){e.preventDefault();repeatLast();}return;} // idle Space/Enter → repeat the last command (AutoCAD/Tekla)
|
|
3124
|
-
if(e.key==='Escape'&&
|
|
3822
|
+
if(e.key==='Escape'&&gridLinePick){gridCancelLinePick();return;} // Esc disarms add-single-line (grid mode stays)
|
|
3823
|
+
if(e.key==='Escape'&&gridPick){gridPick=false;gridSetPickClass();snapClear();panel();return;} // Esc disarms pick-origin (grid mode stays)
|
|
3125
3824
|
if(e.key==='Escape'&&gridMode&&!inForm){setGridMode(false);render();return;} // Esc exits the grid panel (a focused field handles its own Esc = revert)
|
|
3825
|
+
if(e.key==='Escape'&&dimStyleMode&&!inForm){setDimStyleMode(false);render();return;} // …likewise the Dimension style pane
|
|
3126
3826
|
if(e.key==='Escape'&&cmTool){if(cmHudIsOpen())cmHudClose();
|
|
3127
3827
|
else if(view3d&&window.Steel3DView&&window.Steel3DView.cmEscape&&window.Steel3DView.cmEscape()){} // 3D: step the pick back (array dir A → base) before exiting
|
|
3128
3828
|
else if(cmDraft&&cmDraft.vA){cmDraft.vA=null;cmRefreshPrev();panel();}else if(cmDraft){cmDraft=null;cmPrevClear();panel();}else{disarmCm();render();}return;} // Move/Copy Esc ladder: HUD → array dir A → base pick → exit tool
|
|
@@ -3131,14 +3831,16 @@ addEventListener('keydown',e=>{
|
|
|
3131
3831
|
if(e.key==='Escape'&&dimMode){if(dimChainPrev){dimChainPrev=null;dimPrevClear();}else if(dimDraft){dimDraft=null;dimPrevClear();}else{dimMode=false;setDimMode();}render();return;} // Esc: end the chain → drop the in-progress dim → exit the tool
|
|
3132
3832
|
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
|
|
3133
3833
|
if(e.key==='Escape'&&view3d&&mode==='add'&&window.Steel3DView&&window.Steel3DView.drEscape&&window.Steel3DView.drEscape()){return;} // 3D draw: 1st Esc drops the in-progress start pick, 2nd exits add mode (falls through below)
|
|
3834
|
+
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
|
|
3134
3835
|
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();render();return;}
|
|
3135
3836
|
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)
|
|
3136
3837
|
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
|
|
3137
3838
|
if((e.key==='Delete'||e.key==='Backspace')&&selIds.size&&!selDimIds.size&&[...selIds].every(id=>/^det:/.test(id))&&!inForm){e.preventDefault();edit(()=>{const rm=new Set([...selIds].map(id=>id.slice(4)));C.detail_placements=(C.detail_placements||[]).filter(x=>x&&!rm.has(x.id));selIds.clear();});return;} // a placed-detail-only selection deletes from detail_placements — Delete now matches every other object's remove gesture (not just the inspector button)
|
|
3138
3839
|
if((e.key==='Delete'||e.key==='Backspace')&&(selDimIds.size||selIds.size)&&!inForm){e.preventDefault();edit(()=>{ // deletes everything selected — dims and/or members (a marquee can hold both)
|
|
3139
3840
|
if(selDimIds.size){P.dims=P.dims.filter(d=>!selDimIds.has(d.id));selDimIds.clear();}
|
|
3140
|
-
if(selIds.size){
|
|
3841
|
+
if(selIds.size){for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));selIds.clear();}});return;} // selection spans sheets → remove from every plane, not just the active one
|
|
3141
3842
|
if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='d'&&!view3d){e.preventDefault();dimMode=!dimMode;setDimMode();render();setLastCmd('Dimension',()=>{if(!dimMode){dimMode=true;setDimMode();render();}});return;} // D — toggle the Dimension tool
|
|
3843
|
+
if(!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='a'&&!view3d){e.preventDefault();document.getElementById('mAdd').click();return;} // A — toggle the Add-member tool (mirrors D=Dimension; plain 'a', Ctrl+A is still select-all). The mAdd click owns the arm/disarm-conflicts + setLastCmd logic.
|
|
3142
3844
|
if(dimMode&&!inForm&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const dk=e.key.toLowerCase();
|
|
3143
3845
|
if(dk==='x'||dk==='y'||dk==='f'){e.preventDefault();dimSetAxis(dk==='f'?'free':dk);dimDraft&&svg.querySelector('#dimPrevG')&&dimRefreshPrev();return;}
|
|
3144
3846
|
if(dk==='c'){e.preventDefault();toggleDimChain();return;}} // C — toggle chained (continuous) dimensioning
|
|
@@ -3154,7 +3856,7 @@ addEventListener('keydown',e=>{
|
|
|
3154
3856
|
if(!inForm&&selDimIds.size>=1&&!selIds.size&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()==='s'){e.preventDefault();toggleDimSplit();return;} // S — toggle "add split point" on the selected dimension(s)
|
|
3155
3857
|
if(!inForm&&[...selIds].some(id=>!/^det:/.test(id))&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const kk=e.key.toLowerCase(); // member-only shortcuts — require a real member selected, not a placed-detail-only selection
|
|
3156
3858
|
if(kk==='e'){e.preventDefault();geoMode=(geoMode==='el'?null:'el');setGeo();render();setLastCmd('Extend/Trim',()=>{geoMode='el';setGeo();render();});return;} // Extend/Trim — any selection
|
|
3157
|
-
if(kk==='p'){e.preventDefault();
|
|
3859
|
+
if(kk==='p'){e.preventDefault();swapSelectionEnds();return;} // P — swap start↔end for the whole selection (2D + 3D); braces excluded (owns its edit()/toast)
|
|
3158
3860
|
if(kk==='s'&&selIds.size===1&&!selDimIds.size){e.preventDefault();geoMode=(geoMode==='split'?null:'split');setGeo();render();setLastCmd('Split',()=>{geoMode='split';setGeo();render();});return;}} // member Split — single member only, and not while dims are also selected (mixed → ambiguous, so neither split fires)
|
|
3159
3861
|
if(!(e.ctrlKey||e.metaKey))return;const k=e.key.toLowerCase();
|
|
3160
3862
|
if(k==='z'&&!e.shiftKey){e.preventDefault();doUndo();}
|
|
@@ -3211,7 +3913,19 @@ document.getElementById('cpLevelB').onclick=()=>openLevelModal('copy');
|
|
|
3211
3913
|
let copesByMember={}, partsById={};
|
|
3212
3914
|
const view3dApi={
|
|
3213
3915
|
// POST the in-progress contract so the model reflects unsaved edits; throws on a bad contract.
|
|
3214
|
-
fetchScene:async()=>{const r=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/scene',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({contract:C})});const j=await r.json();if(!j.ok)throw new Error(j.error||'scene render failed');
|
|
3916
|
+
fetchScene:async()=>{const r=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/scene',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({contract:C})});const j=await r.json();if(!j.ok)throw new Error(j.error||'scene render failed');
|
|
3917
|
+
// The bake reports everything it could NOT emit in `skipped[]`, and we used to discard it entirely — so a
|
|
3918
|
+
// connection the engine refused (e.g. a shear plate whose main became a brace) vanished from 3D silently.
|
|
3919
|
+
// Always log the full list. TOAST only for `joint:<id>` entries: a refused connection is unambiguous and
|
|
3920
|
+
// always surprising. Member skips are NOT toasted — the bake legitimately drops RFI members (no size) and
|
|
3921
|
+
// zero-height foundation columns, so the count is dominated by expected drops and a toast would nag on
|
|
3922
|
+
// every 3D open. Telling a degenerate brace apart from those needs skip REASONS from the server; until
|
|
3923
|
+
// contract-to-scene returns them, the console is the honest channel. (silent-failure review)
|
|
3924
|
+
{const sk=Array.isArray(j.skipped)?j.skipped:[];
|
|
3925
|
+
if(sk.length){
|
|
3926
|
+
const jn=sk.filter(s=>String(s).startsWith('joint:')).length;
|
|
3927
|
+
console.warn('3D bake skipped '+sk.length+' item(s):',sk);
|
|
3928
|
+
if(jn)toast(jn+' connection'+(jn>1?'s':'')+' not shown in 3D — see the console');}}const cm={},pb={};const sc=j.scene||{};sc.elements=Array.isArray(sc.elements)?sc.elements:[];for(const el of sc.elements){if(!el)continue;if(el.id)pb[el.id]=el;if(el.kind==='cut'&&el.member){(cm[el.member]||(cm[el.member]=[])).push((el.meta&&el.meta.label)||'Cope');}}
|
|
3215
3929
|
// Slice 4: append placed detail images as CLIENT-SIDE scene elements (kind:'image'), resolving each
|
|
3216
3930
|
// placement's detailName → custom_details base64 in the browser. The server's contract-to-scene never
|
|
3217
3931
|
// emits these, so they stay out of the reconstructed scene / IFC / Tekla export and the baked lock.
|
|
@@ -3220,12 +3934,13 @@ const view3dApi={
|
|
|
3220
3934
|
for(const p of (C.detail_placements||[])){if(!p||!p.id)continue;const raw=C.custom_details[p.detailName];if(raw==null)continue;const url=String(raw).startsWith('data:')?raw:'data:image/jpeg;base64,'+raw;const el={kind:'image',id:'det:'+p.id,group:'detail',url,pos:p.pos||[0,0,0],u:p.u,n:p.n,rotZ:p.rotZ||0,size:p.size||1000,opacity:p.opacity==null?1:p.opacity};sc.elements.push(el);pb[el.id]=el;}
|
|
3221
3935
|
copesByMember=cm;partsById=pb;return sc;}, // cache resolved parts by id (real dims for the part Inspector) AND cope labels per member; placed details ride in as image elements
|
|
3222
3936
|
|
|
3223
|
-
onSelect:(id,additive)=>{selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();}else
|
|
3937
|
+
onSelect:(id,additive)=>{selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears 2D + 3D dim selection so Delete is unambiguous)
|
|
3224
3938
|
onSelectMany:(ids,additive)=>{selDimIds.clear();sel3dDimIds.clear();
|
|
3225
|
-
if(additive){for(const id of (ids||[]))selIds.has(id)?selIds.delete(id):selIds.add(id);} // Ctrl/Shift + 3D area-select → toggle each framed object into the current selection (add/remove), like Tekla
|
|
3939
|
+
if(additive){for(const id of (ids||[]))selIds.has(id)?selIds.delete(id):selIds.add(id);} // Ctrl/Shift + 3D area-select → toggle each framed object into the current selection (add/remove), like Tekla — spans sheets
|
|
3226
3940
|
else selIds=new Set(ids||[]);
|
|
3227
3941
|
if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
|
|
3228
|
-
getMembers:()=>P.members, //
|
|
3942
|
+
getMembers:()=>P.members, // active-sheet members (wp) for snap geometry (one ppf)
|
|
3943
|
+
allMembers, // EVERY sheet's members — the 3D box-select tests all visible meshes, not just the active sheet's
|
|
3229
3944
|
snapEnabled:()=>snapEnabled, // the persistent running-snaps (⋯ menu → Snapping) — 3D honours the same on/off set
|
|
3230
3945
|
ptPerFt:()=>(P&&P.pt_per_ft>0?P.pt_per_ft:1),
|
|
3231
3946
|
defaultTosMm:()=>(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
|
|
@@ -3233,15 +3948,17 @@ const view3dApi={
|
|
|
3233
3948
|
onMoveMember:(id,newWp)=>{edit(()=>{const m=byId(id);if(m)m.wp=newWp;});}, // 3D drag → write wp (undoable, autosaves, syncs 2D/chip/BOM)
|
|
3234
3949
|
dragMoveEnabled:()=>dragMoveOn, // the 3D view gates its plain member-drag on this
|
|
3235
3950
|
dragMoveHint:()=>{if(dragHintShown)return;dragHintShown=true;try{localStorage.setItem('steel:dragmovehint:v1','1');}catch(_){}toast('Drag to move/copy is off — turn it on in the Move / Copy menu, or use the Move (M) / Copy (C) tools');},
|
|
3236
|
-
onCopyDrag3d:(ids,dxMm,dyMm)=>{const
|
|
3237
|
-
const
|
|
3238
|
-
|
|
3951
|
+
onCopyDrag3d:(ids,dxMm,dyMm)=>{const r6=n=>Math.round(n*1e6)/1e6; // Ctrl+drag copy: mm delta → plan px (Y FLIPPED), clone + translate + select
|
|
3952
|
+
edit(()=>{const ns=new Set();for(const id of (ids||[])){const src=byId(id);if(!src)continue;const pl=planeOf(id);const k=304.8/((pl&&pl.pt_per_ft>0)?pl.pt_per_ft:1); // mm→px in the SOURCE plane's own scale (sheets may differ)
|
|
3953
|
+
const c=cloneMember(src);translateMembers([c],[r6(dxMm/k),r6(-dyMm/k),0]);pl.members=pl.members||[];pl.members.push(c);ns.add(c.id);}selIds=ns;}); // clone lands on the SOURCE's plane (a cross-sheet selection copies each member onto its own sheet, not the active one)
|
|
3239
3954
|
toast('Copied '+(ids?ids.length:0)+' member'+((ids&&ids.length===1)?'':'s'));},
|
|
3240
3955
|
onMoveEndpoint:(id,end,wp)=>{edit(()=>{const m=byId(id);if(m&&Array.isArray(m.wp)&&m.wp.length>=2)m.wp[end]=wp;});}, // 3D end-node drag → write just that endpoint
|
|
3241
3956
|
onElevateMember:(id,dIn)=>{edit(()=>{const m=byId(id);if(!m)return;ensureMeta(m); // 3D Alt-drag → raise/lower T.O.S by dIn inches
|
|
3242
3957
|
if(m.role==='column'){m.col.tos=(m.col.tos!=null?m.col.tos:defaultTOS)+dIn;m.col.bos=(m.col.bos!=null?m.col.bos:0)+dIn;m.col.tosDef=false;} // rigid raise (bos null→0, both shift) so the column isn't stretched
|
|
3243
3958
|
else m.ends.forEach(e=>{e.tos=(e.tos!=null?e.tos:defaultTOS)+dIn;e.tosDef=false;});});},
|
|
3244
|
-
onTrimExtend:(targetId)=>{const tm=byId(targetId);
|
|
3959
|
+
onTrimExtend:(targetId)=>{const tm=byId(targetId);
|
|
3960
|
+
if(tm&&isBrace(tm)){toast('A brace can’t be an extend/trim target');return;} // same rule as 2D: never target a brace's invisible baseline
|
|
3961
|
+
if(tm){geoMode=null;setGeo();snapEndMulti(sel2d(),tm.wp[0],tm.wp[1]);}}, // 3D Trim/Extend → every selected member's nearest end to the target line (snapEndMulti skips braces)
|
|
3245
3962
|
onSplit:(id,wp)=>{const m=byId(id);if(m){doSplit(m,wp);sync3D();}}, // 3D Split → cut at the clicked point on the member
|
|
3246
3963
|
getDims3d:()=>C.dims3d||[],
|
|
3247
3964
|
getGrid:()=>(P&&P.grid)||null, // the ACTIVE plan's structural grid for the 3D render + plan-locked snapping (per-plan, display-space)
|
|
@@ -3282,10 +3999,12 @@ const view3dApi={
|
|
|
3282
3999
|
m=ensureMeta({id,profile:addProfile,wp:[wpA,wpB],role:'beam',angle:_mAngle([wpA,wpB])}); // classify H/V/D from the PLAN delta — same rule as _mAngle + the 2D add path (all three agree)
|
|
3283
4000
|
const mfNote=/(^|[^A-Z])MF/i.test(addProfile||'')?'moment':''; // a moment-frame profile keeps the auto note ensureMeta gives 2D-drawn members
|
|
3284
4001
|
m.ends=[{tos:near(zA)?null:zA,note:mfNote,tosDef:near(zA),detail:''},{tos:near(zB)?null:zB,note:mfNote,tosDef:near(zB),detail:''}];}
|
|
4002
|
+
if((addType==='column')===(m.role==='column'))m.memberType=addType; // 3D geometry decides column-vs-beam; only stamp the panel's type when it agrees with that role
|
|
3285
4003
|
m.rfi=(_wt(addProfile)==null);P.members.push(m);
|
|
3286
4004
|
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}
|
|
3287
4005
|
selIds=new Set([id]);});
|
|
3288
|
-
|
|
4006
|
+
const asCol=hIn<6&&dzIn>6;
|
|
4007
|
+
toast('Added '+(asCol?'a column':'a beam')+' on the working plane'+(((addType==='column')!==asCol)?' — the pick geometry set the type, not '+memberTypeLabel(addType):''));}, // say it out loud when 3D geometry overrode the Add panel's type
|
|
3289
4008
|
onClipsChange:()=>{build3DLegend();}, // a clip added / removed / toggled → rebuild the legend's Clip section
|
|
3290
4009
|
beginClipEdit:()=>pushUndo(snapshot()), // a clip / work-area manipulation → push a pre-edit snapshot so Ctrl+Z/Y restores it
|
|
3291
4010
|
onClipModeChange:(m)=>{const b=document.getElementById('m3dClip');if(b){b.classList.toggle('on',!!m);b.textContent=m?'Clip ✕':'Clip ▾';}}, // armed → button fills brand-blue + becomes a cancel target (✕ = cancel)
|
|
@@ -3322,8 +4041,9 @@ const view3dApi={
|
|
|
3322
4041
|
toast((had?'Base plate on '+col.id+' replaced with “'+f.name+'”':'“'+f.name+'” applied to '+col.id)+' — click another column, or Esc');return;
|
|
3323
4042
|
}
|
|
3324
4043
|
if(f.kind==='shear-plate'){
|
|
3325
|
-
const
|
|
3326
|
-
|
|
4044
|
+
const _pk=pick.anchorId?P.members.find(m=>m&&m.id===pick.anchorId):null;
|
|
4045
|
+
const beam=(_pk&&_pk.role==='beam'&&!isBrace(_pk))?_pk:null; // a brace never carries a shear plate — the server skips the joint, so the UI must not claim "applied"
|
|
4046
|
+
if(!beam){toast(_pk&&isBrace(_pk)?'A brace can’t carry a shear plate — click a beam end':'Click a beam end to place this shear plate');return;}
|
|
3327
4047
|
const id='cx'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36);
|
|
3328
4048
|
const g=partsById[beam.id],d3=(a,b)=>a&&b?Math.hypot(a[0]-b[0],a[1]-b[1],a[2]-b[2]):Infinity;
|
|
3329
4049
|
const endIdx=(g&&g.from&&g.to&&d3(pick.point,g.to)<d3(pick.point,g.from))?1:0;
|
|
@@ -3360,7 +4080,7 @@ const view3dApi={
|
|
|
3360
4080
|
}
|
|
3361
4081
|
// Slice E: a RECOGNIZED shear/fin plate dropped onto a BEAM → bake an EDITABLE shear-plate recipe joint on
|
|
3362
4082
|
// the nearest end; expandShearPlate re-derives it there from the fitted params. Needs a beam at the pick.
|
|
3363
|
-
const beam=(rc&&rc.kind==='shear-plate'&&pick.anchorId)?P.members.find(m=>m&&m.id===pick.anchorId&&m.role==='beam'):null;
|
|
4083
|
+
const beam=(rc&&rc.kind==='shear-plate'&&pick.anchorId)?P.members.find(m=>m&&m.id===pick.anchorId&&m.role==='beam'&&!isBrace(m)):null; // never place a shear plate on a brace (server refuses it)
|
|
3364
4084
|
if(beam){
|
|
3365
4085
|
const id='cx'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36);
|
|
3366
4086
|
// Nearest end via the resolved 3D geometry: end0 = beam.from (wp[0]), end1 = beam.to (wp[1]).
|
|
@@ -3490,13 +4210,69 @@ function startClipRename(c,labEl){
|
|
|
3490
4210
|
// Connection-part group keys, in assembly reading order (plate → fasteners → weld). Used to split the
|
|
3491
4211
|
// legend into a MEMBERS list and a CONNECTIONS section so the steel parts don't blur into one long list.
|
|
3492
4212
|
const CONN_ORDER=['base-plate','shear-plate','washer-plate','stiffener','anchor','bolt','nut','washer','weld']; // plates → secondary plates → fastener rods → hardware → weld (so shear-plate parts file under Connections, not Members)
|
|
3493
|
-
// Member-type categories
|
|
3494
|
-
//
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
const
|
|
3498
|
-
const
|
|
3499
|
-
function
|
|
4213
|
+
// Member-type categories: the inspector uses this single field for both legend grouping and the structural
|
|
4214
|
+
// Column vs beam-style geometry choice. Custom types group in the legend and use beam-style geometry.
|
|
4215
|
+
const BASE_MEMBER_TYPES=[{k:'column',label:'Column'},{k:'beam',label:'Beam'},{k:'brace',label:'Brace'},{k:'ledger',label:'Ledger'},{k:'frame',label:'Frame'}];
|
|
4216
|
+
const BASE_MTYPE_LABEL=Object.fromEntries(BASE_MEMBER_TYPES.map(t=>[t.k,t.label]));
|
|
4217
|
+
const normMemberTypeKey=s=>String(s||'').trim().toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-+|-+$/g,'').slice(0,48);
|
|
4218
|
+
const labelFromMemberTypeKey=k=>String(k||'').split(/[-_]+/).filter(Boolean).map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(' ')||'Type';
|
|
4219
|
+
function cleanMemberTypeLabel(s){return String(s||'').replace(/\s+/g,' ').trim().slice(0,48);}
|
|
4220
|
+
function sanitizeMemberTypes(arr){
|
|
4221
|
+
const seen=new Set(),out=[];
|
|
4222
|
+
for(const raw of Array.isArray(arr)?arr:[]){
|
|
4223
|
+
const label=cleanMemberTypeLabel(typeof raw==='string'?raw:(raw&&raw.label));
|
|
4224
|
+
const k=normMemberTypeKey((raw&&raw.k)||label);
|
|
4225
|
+
if(!k||BASE_MTYPE_LABEL[k]||seen.has(k))continue;
|
|
4226
|
+
seen.add(k);out.push({k,label:label||labelFromMemberTypeKey(k)});
|
|
4227
|
+
}
|
|
4228
|
+
return out;
|
|
4229
|
+
}
|
|
4230
|
+
function memberTypeRecords(){
|
|
4231
|
+
const out=BASE_MEMBER_TYPES.slice(),seen=new Set(out.map(t=>t.k));
|
|
4232
|
+
for(const t of sanitizeMemberTypes(C&&C.member_types)){if(!seen.has(t.k)){seen.add(t.k);out.push(t);}}
|
|
4233
|
+
for(const p of ((C&&C.plans)||[]))for(const m of (p.members||[])){const k=normMemberTypeKey(m&&m.memberType);if(k&&!seen.has(k)){seen.add(k);out.push({k,label:labelFromMemberTypeKey(k)});}}
|
|
4234
|
+
return out;
|
|
4235
|
+
}
|
|
4236
|
+
function memberTypeLabel(k){const r=memberTypeRecords().find(t=>t.k===normMemberTypeKey(k));return r?r.label:labelFromMemberTypeKey(k);}
|
|
4237
|
+
function memberTypeKnown(k){const nk=normMemberTypeKey(k);return !!nk&&memberTypeRecords().some(t=>t.k===nk);}
|
|
4238
|
+
function memberTypeKnownLabel(v){const label=cleanMemberTypeLabel(v),key=normMemberTypeKey(label); // as TYPED — matches an existing key or label (i.e. memberTypeFromInput won't mint a new type)
|
|
4239
|
+
return !!key&&memberTypeRecords().some(t=>t.k===key||t.label.toLowerCase()===label.toLowerCase());}
|
|
4240
|
+
function memberTypeOf(m){const raw=normMemberTypeKey(m&&m.memberType);return raw&&memberTypeKnown(raw)?raw:((m&&m.role==='column')?'column':'beam');} // default Column for a column role, else Beam
|
|
4241
|
+
function memberTypeFromInput(v){
|
|
4242
|
+
const label=cleanMemberTypeLabel(v),key=normMemberTypeKey(label);
|
|
4243
|
+
if(!key)return null;
|
|
4244
|
+
const rec=memberTypeRecords().find(t=>t.k===key||t.label.toLowerCase()===label.toLowerCase());
|
|
4245
|
+
if(rec)return rec.k;
|
|
4246
|
+
C.member_types=sanitizeMemberTypes([...(C.member_types||[]),{k:key,label}]);
|
|
4247
|
+
return key;
|
|
4248
|
+
}
|
|
4249
|
+
function applyMemberType(ms,k){
|
|
4250
|
+
const type=normMemberTypeKey(k),role=(type==='column')?'column':'beam';
|
|
4251
|
+
let dropped=0,unsupported=0;
|
|
4252
|
+
for(const m of ms){if(!m)continue;
|
|
4253
|
+
const wasBrace=isBrace(m);
|
|
4254
|
+
m.role=role;ensureMeta(m);m.memberType=type;normBrace(m); // normBrace: seed m.brace on entering brace, DELETE it on leaving (Codex round-1/2)
|
|
4255
|
+
// Becoming a brace ORPHANS any connection hanging off this member: the bake (steel-joints.expandJoints)
|
|
4256
|
+
// refuses a brace `main`, so the joint would linger in C.joints, never render, and vanish from 3D with no
|
|
4257
|
+
// explanation. Purge it here and say so, rather than leave a recipe that can never bake. (silent-failure review)
|
|
4258
|
+
if(!wasBrace&&isBrace(m)&&Array.isArray(C.joints)&&C.joints.length){
|
|
4259
|
+
const before=C.joints.length;
|
|
4260
|
+
C.joints=C.joints.filter(j=>!(j&&j.main===m.id));
|
|
4261
|
+
dropped+=before-C.joints.length;
|
|
4262
|
+
// …and it can no longer be another joint's SUPPORT. That silently changes the surviving joint's geometry,
|
|
4263
|
+
// so it is counted and reported too, not just the joints removed outright. (Codex round-5)
|
|
4264
|
+
for(const j of C.joints)if(j&&Array.isArray(j.secondaries)&&j.secondaries.includes(m.id)){
|
|
4265
|
+
j.secondaries=j.secondaries.filter(s=>s!==m.id);unsupported++;}
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
if(dropped||unsupported)toast([dropped?dropped+' connection'+(dropped>1?'s':'')+' removed':'',
|
|
4269
|
+
unsupported?unsupported+' connection'+(unsupported>1?'s':'')+' lost its support':''].filter(Boolean).join(' · ')+' — a brace can’t carry or support one');
|
|
4270
|
+
}
|
|
4271
|
+
function memberTypeValueFor(ms){const vals=ms.map(memberTypeOf),one=vals.every(v=>v===vals[0]);return one?memberTypeLabel(vals[0]):'';}
|
|
4272
|
+
function memberTypeField(id,ms){
|
|
4273
|
+
const v=memberTypeValueFor(ms);
|
|
4274
|
+
return `<div class="mtype-field f"><div class=elab>Member type</div><input id=${id} class="combo member-type-combo" data-src=membertypes placeholder="${v?'':'Varies'}" value="${esc(v)}" autocomplete=off></div>`;
|
|
4275
|
+
}
|
|
3500
4276
|
function profileKeyOf(m){return (m&&m.profile||'').trim().toUpperCase();} // matches the scene group key (contract-to-scene upper-cases the profile)
|
|
3501
4277
|
function categoryOfProfile(profKey){for(const m of (P.members||[]))if(profileKeyOf(m)===profKey)return memberTypeOf(m);return 'beam';} // a profile-group's category = the type of its member(s)
|
|
3502
4278
|
let legendMode=(localStorage.getItem('floless.legendMode')==='type')?'type':'profile';
|
|
@@ -3504,7 +4280,7 @@ let collapsedCats=new Set((()=>{try{return JSON.parse(localStorage.getItem('flol
|
|
|
3504
4280
|
let legendQuery=''; // transient objects-list search filter (members + connections only) — NOT persisted
|
|
3505
4281
|
// While a search is active, object categories (member types + connections) render EXPANDED so a match inside a
|
|
3506
4282
|
// manually-collapsed category still surfaces — WITHOUT mutating the persisted collapsedCats.
|
|
3507
|
-
function catForceOpen(cat){return !!legendQuery&&(
|
|
4283
|
+
function catForceOpen(cat){return !!legendQuery&&(memberTypeRecords().some(t=>t.k===cat)||/^conn-/.test(cat));}
|
|
3508
4284
|
function saveLegendPrefs(){try{localStorage.setItem('floless.legendMode',legendMode);localStorage.setItem('floless.legendCollapsed',JSON.stringify([...collapsedCats]));}catch{}}
|
|
3509
4285
|
// Drag a typed member row onto another type category to retype it. Pointer Events (NOT the HTML5 drag API,
|
|
3510
4286
|
// which paints a white browser ghost on Windows). A 6px threshold tells a drag from the row's click(hide) /
|
|
@@ -3524,10 +4300,10 @@ function wireRowDrag(row,g){const handle=row.querySelector('.drag-handle');if(!h
|
|
|
3524
4300
|
if(drop)retypeProfile(g.key,drop);};
|
|
3525
4301
|
document.addEventListener('pointermove',move);document.addEventListener('pointerup',up);});}
|
|
3526
4302
|
// Retype every member of a profile-group to `cat` (undoable); the legend re-categorises on rebuild + flashes the moved row.
|
|
3527
|
-
function retypeProfile(profKey,cat){if(!
|
|
4303
|
+
function retypeProfile(profKey,cat){if(!memberTypeKnown(cat))return;
|
|
3528
4304
|
const targets=(P.members||[]).filter(m=>profileKeyOf(m)===profKey);
|
|
3529
4305
|
if(!targets.length||targets.every(m=>memberTypeOf(m)===cat))return; // already that type → no-op (no empty undo step)
|
|
3530
|
-
edit(()=>
|
|
4306
|
+
edit(()=>applyMemberType(targets,cat));
|
|
3531
4307
|
setTimeout(()=>{const r=[...document.querySelectorAll('#m3dLegend .lrow[data-key]')].find(r=>r.dataset.key===profKey);if(r){r.classList.add('flash');setTimeout(()=>r.classList.remove('flash'),400);}},250);}
|
|
3532
4308
|
// ════════════════════════════════════════════════════════════════════════════════════════════════════════════
|
|
3533
4309
|
// Panel tabs (Objects | Views | Favourites) + the Views Organizer (Slice V1).
|
|
@@ -4020,9 +4796,10 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
|
|
|
4020
4796
|
host.insertBefore(sb,hint);
|
|
4021
4797
|
}
|
|
4022
4798
|
if(legendMode==='type'&&members.length){ // group the profile-rows under their member-type categories
|
|
4023
|
-
const
|
|
4799
|
+
const mtypes=memberTypeRecords();
|
|
4800
|
+
const byCat=new Map(mtypes.map(t=>[t.k,[]]));
|
|
4024
4801
|
for(const g of members){(byCat.get(categoryOfProfile(g.key))||byCat.get('beam')).push(g);}
|
|
4025
|
-
for(const {k,label} of
|
|
4802
|
+
for(const {k,label} of mtypes){const gs=byCat.get(k)||[],keys=gs.map(g=>g.key);
|
|
4026
4803
|
host.appendChild(buildCatHeader(k,label,gs.length,{empty:!gs.length,getState:()=>grpState(keys),onToggle:()=>grpToggle(keys),toggleTitle:'Show / hide all '+label.toLowerCase()+'s'}));
|
|
4027
4804
|
if(!collapsedCats.has(k)||catForceOpen(k))for(const g of gs)addRow(g,true,true);}
|
|
4028
4805
|
} else for(const g of members)addRow(g);
|
|
@@ -4199,7 +4976,7 @@ function applyLegendFilter(){
|
|
|
4199
4976
|
let any=false;
|
|
4200
4977
|
rows.forEach(r=>{const hit=(r.textContent||'').toLowerCase().includes(q);r.classList.toggle('qhide',!hit);if(hit)any=true;});
|
|
4201
4978
|
host.querySelectorAll('.cat-hdr').forEach(h=>{const cat=h.dataset.cat||'';
|
|
4202
|
-
|
|
4979
|
+
if(!(memberTypeRecords().some(t=>t.k===cat)||/^conn-/.test(cat)))return; // leave the Dimensions/Clip headers untouched
|
|
4203
4980
|
let vis=false;
|
|
4204
4981
|
for(let n=h.nextElementSibling;n&&!n.classList.contains('cat-hdr')&&!n.classList.contains('lsec')&&!n.classList.contains('ldiv');n=n.nextElementSibling){
|
|
4205
4982
|
if((n.matches('.lrow[data-key]')||n.matches('.lrow[data-connkey]'))&&!n.classList.contains('qhide')){vis=true;break;}}
|
|
@@ -4245,15 +5022,17 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
|
|
|
4245
5022
|
else{clipMenu.classList.add('open');document.addEventListener('mousedown',clipMenuOutside,true);}};
|
|
4246
5023
|
clipMenu.querySelectorAll('button').forEach(b=>b.onclick=()=>{clipMenuClose();const a=b.dataset.clip;
|
|
4247
5024
|
if(a==='plane'){d3.setClipMode('plane');setLastCmd('Clip plane',()=>d3.setClipMode('plane'));}else if(a==='box'){d3.setClipMode('box');setLastCmd('Clip box',()=>d3.setClipMode('box'));}else if(a==='clear')d3.clearClips();});
|
|
4248
|
-
//
|
|
5025
|
+
// Mark labels: a checkbox in the View ▾ menu (mirrors Ref line) — show each member's mark/id in the 3D view.
|
|
4249
5026
|
document.getElementById('m3dLabels').onchange=e=>d3.setLabelsOn(e.target.checked);
|
|
5027
|
+
// Property labels: independent 3D visibility for the shared prop-label selection (B1) — clears/repushes the 3D labels.
|
|
5028
|
+
document.getElementById('m3dPropLabels').onchange=e=>{C.prop_labels.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();};
|
|
4250
5029
|
// View menu: groups the Ref line + Labels toggles (same open/close discipline as Clip / Work area / Plane).
|
|
4251
5030
|
const viewBtn=document.getElementById('m3dView'),viewMenu=document.getElementById('m3dViewMenu');
|
|
4252
5031
|
function viewMenuOutside(e){if(!viewMenu.contains(e.target)&&e.target!==viewBtn)viewMenuClose();}
|
|
4253
5032
|
function viewMenuClose(){viewMenu.classList.remove('open');document.removeEventListener('mousedown',viewMenuOutside,true);}
|
|
4254
5033
|
viewBtn.onclick=e=>{e.stopPropagation();
|
|
4255
5034
|
if(viewMenu.classList.contains('open'))viewMenuClose();
|
|
4256
|
-
else{document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn(); // reflect live state on open
|
|
5035
|
+
else{document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn();document.getElementById('m3dPropLabels').checked=!!(C.prop_labels&&C.prop_labels.vis3d); // reflect live state on open
|
|
4257
5036
|
viewMenu.classList.add('open');document.addEventListener('mousedown',viewMenuOutside,true);}};
|
|
4258
5037
|
// Insert a detail: the ▾ menu lists the detail library + an "add image" option; picking one arms a
|
|
4259
5038
|
// placement pick (onInsertPlace drops it). While armed the button is a cancel target (onInsertModeChange).
|
|
@@ -4414,8 +5193,10 @@ function applyViewState(on){ // flip the toggle + swap the canvases (
|
|
|
4414
5193
|
if(!on)document.getElementById('m3dLegend').style.display='none'; // panel is shown by setView (showLegendPanel) when entering 3D
|
|
4415
5194
|
}
|
|
4416
5195
|
async function setView(on){
|
|
5196
|
+
drawDraft=null;drawPrevClear(); // any view switch drops an in-progress 2D Add-member start — it's a plan-pixel point, meaningless after the switch (else a stale point finishes a member on return)
|
|
4417
5197
|
if(on){
|
|
4418
5198
|
if(dimMode||dimChain||dimSplitMode){dimMode=dimChain=dimSplitMode=false;selDimIds.clear();setDimMode();document.body.classList.remove('dimsplit');} // entering 3D disarms the 2D dim/chain/split tools so their X/Y/F/S/Esc keys don't double-fire with the 3D tool
|
|
5199
|
+
dimStyleMode=false; // …and closes the 2D Dimension style pane (it styles the 2D overlay only)
|
|
4419
5200
|
if(cmTool){cmDraft=null;cmPrevClear();cmHudClose();} // Move/Copy stays armed across the view switch — only the in-progress 2D pick is dropped (it's in plan px)
|
|
4420
5201
|
if(selIds.size)sel3dDimIds.clear(); // a member selected in 2D wins over a stale 3D-dim selection
|
|
4421
5202
|
if(!window.Steel3DView){toast('3D view unavailable (renderer failed to load)');return;} // stay in 2D
|
|
@@ -4433,13 +5214,15 @@ async function setView(on){
|
|
|
4433
5214
|
}
|
|
4434
5215
|
}else{if(cmTool&&window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // 3D→2D: drop the mm-space pick the same way (tool stays armed)
|
|
4435
5216
|
applyViewState(false);if(window.Steel3DView)window.Steel3DView.hide();}
|
|
4436
|
-
if(propPopOpen()){if(propPopPinned)dockPropPop();else closePropPop(true);} // the popup is anchored to one canvas — re-dock if pinned, else dismiss on the view switch
|
|
5217
|
+
if(propPopOpen()){if(propPopPinned){dockPropPop();renderPropPop();}else closePropPop(true);} // the popup is anchored to one canvas — re-dock if pinned (renderPropPop re-syncs its "Show in this view" checkbox to the now-live view), else dismiss on the view switch
|
|
4437
5218
|
refreshPropLabels3d();updatePropHint(); // push the label set to whichever view is now live (3D shows them; 2D hides the 3D host) + refresh the corner note
|
|
4438
5219
|
}
|
|
4439
5220
|
document.getElementById('vt2d').onclick=()=>{if(view3d)setView(false);};
|
|
4440
5221
|
document.getElementById('vt3d').onclick=()=>{if(!view3d)setView(true);};
|
|
4441
|
-
// Ctrl+wheel
|
|
4442
|
-
|
|
5222
|
+
// Block the browser's Ctrl+wheel page-zoom anywhere in the app (fires even when the pointer isn't over the canvas). Canvas zoom below still runs.
|
|
5223
|
+
window.addEventListener('wheel',e=>{if(e.ctrlKey)e.preventDefault();},{passive:false});
|
|
5224
|
+
// wheel = zoom at cursor (matches 3D; Ctrl+wheel too). Pan is middle-drag, below.
|
|
5225
|
+
stage.addEventListener('wheel',e=>{e.preventDefault();applyZoom(zoom*Math.exp(-e.deltaY*0.0015),e.clientX,e.clientY);},{passive:false});
|
|
4443
5226
|
// middle-button drag = pan
|
|
4444
5227
|
stage.addEventListener('mousedown',e=>{if(e.button===1)e.preventDefault();});
|
|
4445
5228
|
let pan=null;
|
|
@@ -4541,15 +5324,15 @@ function spDistToSeg(p,a,b){const vx=b[0]-a[0],vy=b[1]-a[1],L2=vx*vx+vy*vy;if(L2
|
|
|
4541
5324
|
let t=((p[0]-a[0])*vx+(p[1]-a[1])*vy)/L2;t=Math.max(0,Math.min(1,t));return spDist(p,[a[0]+t*vx,a[1]+t*vy]);}
|
|
4542
5325
|
function spSupportTol(){const k=(P.pt_per_ft&&P.pt_per_ft>0)?P.pt_per_ft:12;return Math.max(6,0.75*k);} // ~9in at the plan's scale, min 6 display-pts: "the beam end meets this member"
|
|
4543
5326
|
function spInferSupport(beam,endIdx){if(!beam||!Array.isArray(beam.wp)||beam.wp.length<2)return null;const pt=beam.wp[endIdx];if(!pt)return null;
|
|
4544
|
-
let best=null,bd=Infinity;for(const m of (P.members||[])){if(!m||m.id===beam.id||!Array.isArray(m.wp)||!m.wp.length)continue;
|
|
5327
|
+
let best=null,bd=Infinity;for(const m of (P.members||[])){if(!m||m.id===beam.id||isBrace(m)||!Array.isArray(m.wp)||!m.wp.length)continue; // a brace never SUPPORTS a shear plate (mirrors server inferSupport)
|
|
4545
5328
|
const d=(m.role==='column')?spDist(pt,m.wp[0]):(m.wp.length>=2?spDistToSeg(pt,m.wp[0],m.wp[1]):spDist(pt,m.wp[0]));if(d<bd){bd=d;best=m;}}
|
|
4546
5329
|
return (best&&bd<=spSupportTol())?best:null;}
|
|
4547
|
-
function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||!beam.ends)return false;
|
|
5330
|
+
function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||isBrace(beam)||!beam.ends)return false; // a brace never CARRIES a shear plate (mirrors server expandJoints)
|
|
4548
5331
|
if(beam.mf===true||/^MF/i.test(beam.profile||''))return false; // a moment-frame girder (resolved via Frames → m.mf, or an unresolved MF mark) takes a MOMENT connection, not a shear tab
|
|
4549
5332
|
const end=beam.ends[endIdx];if(!end)return false;
|
|
4550
5333
|
const t=spConnText(end);if(spIsMoment(t))return false;if(spIsShear(t))return true;return !!spInferSupport(beam,endIdx);} // explicit moment → no; explicit shear → yes; else propose only where the end frames into a support
|
|
4551
|
-
function spEligibleEnds(){const out=[];for(const m of (P.members||[])){if(!m||m.role==='column')continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;}
|
|
4552
|
-
function spBeamIds(){const s=new Set();for(const m of (P.members||[]))if(m&&m.role!=='column'&&m.id)s.add(m.id);return s;} // ACTIVE plan's beams — auto-detail + its undo are per-plan
|
|
5334
|
+
function spEligibleEnds(){const out=[];for(const m of (P.members||[])){if(!m||m.role==='column'||isBrace(m))continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;}
|
|
5335
|
+
function spBeamIds(){const s=new Set();for(const m of (P.members||[]))if(m&&m.role!=='column'&&!isBrace(m)&&m.id)s.add(m.id);return s;} // ACTIVE plan's beams (never braces) — auto-detail + its undo are per-plan
|
|
4553
5336
|
function spJointOf(beamId,endIdx){return (C.joints||[]).find(j=>j&&j.kind==='shear-plate'&&j.main===beamId&&j.at==='end'+endIdx);}
|
|
4554
5337
|
function autoShearPlates(){const ids=spBeamIds();return (C.joints||[]).filter(j=>j&&j.kind==='shear-plate'&&j.source==='auto'&&ids.has(j.main));} // active plan's auto shear plates
|
|
4555
5338
|
function spJointId(beamId,endIdx){const ids=new Set((C.joints||[]).map(j=>j&&j.id));let id='sp-'+beamId+'-e'+endIdx,k=2;while(ids.has(id))id='sp-'+beamId+'-e'+endIdx+'-'+(k++);return id;} // unique vs ANY existing joint id
|
|
@@ -4639,7 +5422,7 @@ function rfiReason(m){if(!m.profile)return 'No profile assigned';
|
|
|
4639
5422
|
if(/^MF/i.test(m.profile))return 'Moment-frame mark — pick a girder (see Frames)';
|
|
4640
5423
|
if(/^BF/i.test(m.profile))return 'Brace-frame mark — pick a section';
|
|
4641
5424
|
return 'Size not in the AISC table — check the designation';}
|
|
4642
|
-
function zoomToMember(m){const a=
|
|
5425
|
+
function zoomToMember(m){const vl=memberViewLine(m),a=vl[0],b=vl[1],w=Math.abs(a[0]-b[0])||40,h=Math.abs(a[1]-b[1])||40; // frame what's DRAWN — an offset brace must land in view, not its invisible baseline
|
|
4643
5426
|
applyZoom(Math.max(.3,Math.min(2.5,Math.min(stage.clientWidth/(w*2.2),stage.clientHeight/(h*2.2)))));
|
|
4644
5427
|
const cx=(a[0]+b[0])/2,cy=(a[1]+b[1])/2;stage.scrollLeft=(cx-X0)*zoom-stage.clientWidth/2;stage.scrollTop=(cy-Y0)*zoom-stage.clientHeight/2;}
|
|
4645
5428
|
// ── Find in model (Workspaces Ctrl+F) ──────────────────────────────────────────
|
|
@@ -4671,11 +5454,11 @@ window.findMember = findMember; window.clearFind = clearFind; // expose to the s
|
|
|
4671
5454
|
// zoomToSelection (Tekla "Zoom selected") and Find-in-model — mirrors the 3D view's frameSelection().
|
|
4672
5455
|
function zoomToMembers(arr){if(!arr.length){fitToWindow();return;}
|
|
4673
5456
|
let x0=Infinity,y0=Infinity,x1=-Infinity,y1=-Infinity;
|
|
4674
|
-
for(const m of arr)for(const p of m
|
|
5457
|
+
for(const m of arr)for(const p of memberViewLine(m)){if(p[0]<x0)x0=p[0];if(p[0]>x1)x1=p[0];if(p[1]<y0)y0=p[1];if(p[1]>y1)y1=p[1];} // bound the DRAWN lines (offset braces included)
|
|
4675
5458
|
const w=Math.max(x1-x0,40),h=Math.max(y1-y0,40);
|
|
4676
5459
|
applyZoom(Math.min(stage.clientWidth/(w*1.35),stage.clientHeight/(h*1.35)));
|
|
4677
5460
|
const cx=(x0+x1)/2,cy=(y0+y1)/2;stage.scrollLeft=(cx-X0)*zoom-stage.clientWidth/2;stage.scrollTop=(cy-Y0)*zoom-stage.clientHeight/2;}
|
|
4678
|
-
function zoomToSelection(){zoomToMembers(
|
|
5461
|
+
function zoomToSelection(){zoomToMembers(sel2d());}
|
|
4679
5462
|
function openRFI(){const g=document.getElementById('rfiGrid');const list=rfiList();
|
|
4680
5463
|
g.innerHTML=list.length?('<div class=hint style="margin-bottom:10px">'+list.length+' member'+(list.length>1?'s':'')+' have no resolved AISC size, so their weight is excluded from the BOM. Assign a profile to clear it — for <b>MF/BF</b> marks use the <b>Frames</b> schedule. Edits here update the contract.</div><table class=ftab><thead><tr><th>#</th><th>Profile / mark</th><th>Role</th><th>Length</th><th>Why it’s flagged</th><th></th></tr></thead><tbody>'+
|
|
4681
5464
|
list.map((m,i)=>{ensureMeta(m);const L=_lenFt(m).toFixed(1);
|
|
@@ -4743,6 +5526,7 @@ function _scoreConnections(){
|
|
|
4743
5526
|
return{band:'low',reason:row?'library row has a type only (no detail/component id)':'connection type only (no detail)'};};
|
|
4744
5527
|
const byEnd=[];
|
|
4745
5528
|
(C.plans||[]).forEach((plan,pi)=>{for(const m of (plan.members||[])){
|
|
5529
|
+
if(isBrace(m))continue; // a brace's ends are not beam shear connections — mirrors server scoreConnections (Codex review)
|
|
4746
5530
|
if(m.role==='column'){const r=bandEnd(m.col||{});byEnd.push({id:m.id+'#col',pi,sheet:plan.sheet||'',memberId:m.id,which:'col',band:r.band,reason:r.reason});}
|
|
4747
5531
|
else{const ends=m.ends||[];for(const w of [0,1]){const r=bandEnd(ends[w]||{});byEnd.push({id:m.id+'#'+w,pi,sheet:plan.sheet||'',memberId:m.id,which:w,band:r.band,reason:r.reason});}}}});
|
|
4748
5532
|
const counts=_cnt0();let num=0,den=0;
|
|
@@ -4752,7 +5536,7 @@ function scoreContractJS(){const plans=C.plans||[];const byMember=[],byDetail=[]
|
|
|
4752
5536
|
const _conn=_scoreConnections();
|
|
4753
5537
|
const known=new Set();for(const p of plans)if(p.sheet)known.add(p.sheet.toUpperCase());for(const s of Object.keys(C.detail_bubbles||{}))known.add(s.toUpperCase());
|
|
4754
5538
|
plans.forEach((plan,pi)=>{segs+=(plan.segments||[]).length;const ms=plan.members||[];const dup=_confDupIds(ms);
|
|
4755
|
-
for(const m of ms){const r=_scoreMember(m,dup);byMember.push({id:m.id,planIdx:pi,sheet:plan.sheet||'',role:m.role==='column'?'column':'beam',profile:m.profile||'',band:r.band,tons:r.band==='rfi'?0:_mTons(m,plan.pt_per_ft,plan.default_tos),factors:r.factors});}
|
|
5539
|
+
for(const m of ms){const r=_scoreMember(m,dup);byMember.push({id:m.id,planIdx:pi,sheet:plan.sheet||'',role:m.role==='column'?'column':'beam',isBrace:isBrace(m)||undefined,profile:m.profile||'',band:r.band,tons:r.band==='rfi'?0:_mTons(m,plan.pt_per_ft,plan.default_tos),factors:r.factors});} // isBrace mirrors the server MemberScore so the report can label it Brace
|
|
4756
5540
|
for(const d of (plan.details||[])){const sh=_detSheet(d.text);const ok=sh!=null&&known.has(sh.toUpperCase());byDetail.push({text:d.text||'',planIdx:pi,sheet:plan.sheet||'',band:ok?'high':'low',reason:ok?('references '+sh+' (in the set)'):sh?('references '+sh+' — not found in the set'):'no sheet reference parsed'});}});
|
|
4757
5541
|
const roll=(arr,cw)=>{const c=_cnt0();let n=0,d=0,t=0;for(const m of arr){c[m.band]++;if(m.band==='rfi')continue;const w=cw?1:m.tons;n+=w*BANDW[m.band];d+=w;t+=m.tons;}return {score:d>0?Math.round(n/d*100):null,tons:t,counts:c};};
|
|
4758
5542
|
const dRoll=arr=>{const c=_cnt0();let n=0,d=0;for(const x of arr){c[x.band]++;n+=BANDW[x.band];d++;}return {score:d>0?Math.round(n/d*100):null,tons:0,counts:c};};
|
|
@@ -4800,7 +5584,7 @@ function renderConf(){const s=scoreContractJS();const cat=s.byCategory;
|
|
|
4800
5584
|
document.getElementById('confBody').innerHTML=confBodyHtml(s);
|
|
4801
5585
|
wireConf();}
|
|
4802
5586
|
function confBodyHtml(s){
|
|
4803
|
-
if(!s.byMember.length&&!s.byDetail.length)return '<div class=hint style="padding:14px 0">No members in the
|
|
5587
|
+
if(!s.byMember.length&&!s.byDetail.length)return '<div class=hint style="padding:14px 0">No members in the model yet.</div>';
|
|
4804
5588
|
if(confCat==='connections'){
|
|
4805
5589
|
// worst-first so the RFIs / unmapped ends surface at the top (the "what to fix next" view)
|
|
4806
5590
|
const _ord={rfi:0,low:1,med:2,high:3,verified:4};
|
|
@@ -4824,7 +5608,7 @@ function confBodyHtml(s){
|
|
|
4824
5608
|
let h='<table class=ftab><thead><tr><th>Band</th><th>Element</th><th>Sheet</th><th>Tons</th><th>Evidence</th><th></th></tr></thead><tbody>';
|
|
4825
5609
|
mem.forEach(m=>{const chips=m.factors.map(f=>'<span class="chip '+(f.state==='ok'?'':f.state)+'">'+esc(f.label)+(f.state==='ok'?' ✓':f.state==='fail'?' ✗':' ●')+'</span>').join('');
|
|
4826
5610
|
h+='<tr class=confrow data-mid="'+esc(m.id)+'" data-pi="'+m.planIdx+'"><td><span class=pill style="'+BANDPILL[m.band]+'">'+BANDLAB[m.band]+'</span></td>'+
|
|
4827
|
-
'<td>'+(esc(m.profile)||'<span style="color:var(--mut)">(no profile)</span>')+' <span style="color:var(--mut);font-size:11px">'+esc(m.role)+'</span></td>'+
|
|
5611
|
+
'<td>'+(esc(m.profile)||'<span style="color:var(--mut)">(no profile)</span>')+' <span style="color:var(--mut);font-size:11px">'+esc(m.isBrace?'brace':m.role)+'</span></td>'+ // a brace carries role 'beam' — label it honestly
|
|
4828
5612
|
'<td>'+esc(m.sheet)+'</td><td>'+(m.tons?m.tons.toFixed(2):'—')+'</td><td>'+chips+'</td>'+
|
|
4829
5613
|
'<td><button class=ghost data-loc="'+esc(m.id)+'" data-pi="'+m.planIdx+'">Locate</button></td></tr>';
|
|
4830
5614
|
if(confExpand===m.id)h+='<tr><td></td><td colspan=5 class=conf-expand>'+m.factors.map(f=>'<div>• <b>'+esc(f.label)+':</b> '+esc(f.detail)+'</div>').join('')+'</td></tr>';});
|
|
@@ -4859,6 +5643,19 @@ function openPreview(text){const img=previewFor(text);if(!img)return;const custo
|
|
|
4859
5643
|
li.onload=init;li.src='data:image/jpeg;base64,'+img;
|
|
4860
5644
|
document.getElementById('lbCap').textContent=custom?('Custom · '+text):(sheetOf(text)+(n?' · detail '+n:'')+(b?'':' (numbered on the sheet)'));
|
|
4861
5645
|
document.getElementById('lightbox').style.display='flex';if(li.complete)init();}
|
|
5646
|
+
// A callout's referenced sheet rendered as a crisp VECTOR (the extracted <project>/details/<sheet>.svg,
|
|
5647
|
+
// served by /api/contract/:app/detail/:sheet) — an <img> renders the SVG sharp + zoomable, NOT a blurry
|
|
5648
|
+
// raster. Preferred over the raster preview; falls back to it (then a toast) when no vector exists.
|
|
5649
|
+
function openDetailVector(url,sheet){const li=document.getElementById('lbImg');
|
|
5650
|
+
li.onload=()=>{li.onload=null;lbReset();};li.src=url;
|
|
5651
|
+
document.getElementById('lbCap').textContent=sheet+' · vector';
|
|
5652
|
+
document.getElementById('lightbox').style.display='flex';if(li.complete)lbReset();}
|
|
5653
|
+
async function tryDetailVector(sheet,prev){
|
|
5654
|
+
const url='/api/contract/'+encodeURIComponent(APP_ID)+'/detail/'+encodeURIComponent(sheet)+PROJECT_QS;
|
|
5655
|
+
try{const r=await fetch(url,{method:'HEAD'});if(r.ok){openDetailVector(url,sheet);return;}}catch(_){}
|
|
5656
|
+
if(prev&&previewFor(prev))openPreview(prev); // no vector → raster preview
|
|
5657
|
+
else toast('Sheet '+sheet+' isn’t loaded — open it to jump there');
|
|
5658
|
+
}
|
|
4862
5659
|
function closeLightbox(){document.getElementById('lightbox').style.display='none';document.getElementById('lbImg').src='';}
|
|
4863
5660
|
function lightboxOpen(){return document.getElementById('lightbox').style.display==='flex';}
|
|
4864
5661
|
document.getElementById('lbClose').onclick=closeLightbox;
|
|
@@ -4877,6 +5674,7 @@ lbView.addEventListener('dblclick',lbReset);
|
|
|
4877
5674
|
// --- custom dark combobox (replaces the native white datalist dropdown) ---
|
|
4878
5675
|
const COMBO_SRC={
|
|
4879
5676
|
profiles:()=>profs,
|
|
5677
|
+
membertypes:()=>memberTypeRecords().map(t=>t.label),
|
|
4880
5678
|
conntypes:()=>['moment','drag','shear','braced','pinned','fixed'],
|
|
4881
5679
|
details:()=>{const s=new Set();(P.details||[]).forEach(d=>s.add(d.text));Object.keys(C.custom_details).forEach(n=>s.add(n));return [...s].sort((a,b)=>String(a).localeCompare(String(b),undefined,{numeric:true}));},
|
|
4882
5680
|
connrows:()=>['— none —',...(C.connections||[]).map(r=>connLabel(r))]
|
|
@@ -4889,34 +5687,38 @@ const comboPop=document.createElement('div');comboPop.id='comboPop';document.bod
|
|
|
4889
5687
|
let comboInput=null,comboIdx=-1;
|
|
4890
5688
|
function showCombo(inp){const src=COMBO_SRC[inp.dataset.src];if(!src)return;comboInput=inp;
|
|
4891
5689
|
// connrows is a row PICKER (readonly), not a type-to-filter field — always offer every row.
|
|
4892
|
-
const
|
|
4893
|
-
|
|
4894
|
-
|
|
5690
|
+
const isType=inp.dataset.src==='membertypes';
|
|
5691
|
+
const q=(inp.dataset.src==='connrows'||isType)?'':(inp.value||'').trim().toUpperCase();const opts=src().filter(o=>String(o).toUpperCase().includes(q));
|
|
5692
|
+
const typed=isType?cleanMemberTypeLabel(inp.value):'',canAdd=!!(isType&&typed&&!memberTypeKnownLabel(typed));
|
|
5693
|
+
if(!opts.length&&!canAdd){comboPop.style.display='none';return;}
|
|
5694
|
+
comboPop.classList.toggle('membertypes',isType);
|
|
5695
|
+
comboPop.innerHTML=opts.map(o=>`<div class=opt data-v="${esc(o)}"${String(o).length>24?` data-tip="${esc(o)}"`:''}>${esc(o)}</div>`).join('')+(canAdd?`<div class="opt add" data-v="${esc(typed)}">+ Add "${esc(typed)}"</div>`:'');
|
|
4895
5696
|
const r=inp.getBoundingClientRect();comboPop.style.left=Math.round(r.left)+'px';comboPop.style.top=Math.round(r.bottom+2)+'px';comboPop.style.minWidth=Math.round(r.width)+'px';
|
|
4896
5697
|
comboPop.style.display='block';comboIdx=-1;}
|
|
4897
5698
|
function hideCombo(){comboPop.style.display='none';comboInput=null;comboIdx=-1;}
|
|
4898
5699
|
comboPop.addEventListener('mousedown',e=>{const o=e.target.closest('.opt');if(!o||!comboInput)return;e.preventDefault();
|
|
4899
5700
|
comboInput.value=o.dataset.v;comboInput.dispatchEvent(new Event('input'));comboInput.dispatchEvent(new Event('change'));hideCombo();});
|
|
4900
|
-
document.addEventListener('focusin',e=>{if(e.target.classList&&e.target.classList.contains('combo'))showCombo(e.target);});
|
|
5701
|
+
document.addEventListener('focusin',e=>{if(e.target.classList&&e.target.classList.contains('combo')){if(e.target.dataset.src==='membertypes')e.target.dataset.orig=e.target.value;showCombo(e.target);}});
|
|
4901
5702
|
document.addEventListener('input',e=>{if(e.target===comboInput)showCombo(e.target);});
|
|
4902
5703
|
document.addEventListener('focusout',e=>{if(e.target===comboInput)setTimeout(hideCombo,150);});
|
|
4903
5704
|
document.addEventListener('keydown',e=>{if(!comboInput||comboPop.style.display==='none')return;
|
|
4904
5705
|
const opts=[...comboPop.querySelectorAll('.opt')];if(!opts.length)return;
|
|
4905
5706
|
if(e.key==='ArrowDown')comboIdx=Math.min(opts.length-1,comboIdx+1);
|
|
4906
5707
|
else if(e.key==='ArrowUp')comboIdx=Math.max(0,comboIdx-1);
|
|
4907
|
-
else if(e.key==='Enter'){if(comboIdx>=0){comboInput.value=opts[comboIdx].dataset.v;comboInput.dispatchEvent(new Event('input'));comboInput.dispatchEvent(new Event('change'));}hideCombo();e.preventDefault();e.stopPropagation();return;}
|
|
4908
|
-
else if(e.key==='Escape'){hideCombo();e.stopPropagation();return;}
|
|
5708
|
+
else if(e.key==='Enter'){if(comboIdx>=0){comboInput.value=opts[comboIdx].dataset.v;comboInput.dispatchEvent(new Event('input'));comboInput.dispatchEvent(new Event('change'));}else if(comboInput.dataset.src==='membertypes')comboInput.dispatchEvent(new Event('change'));hideCombo();e.preventDefault();e.stopPropagation();return;}
|
|
5709
|
+
else if(e.key==='Escape'){if(comboInput.dataset.src==='membertypes'&&comboInput.dataset.orig!=null)comboInput.value=comboInput.dataset.orig;hideCombo();e.stopPropagation();return;}
|
|
4909
5710
|
else return;
|
|
4910
5711
|
e.preventDefault();e.stopPropagation();opts.forEach((o,i)=>o.classList.toggle('active',i===comboIdx));if(comboIdx>=0)opts[comboIdx].scrollIntoView({block:'nearest'});},true);
|
|
4911
5712
|
// --- multi-plan: switch between all steel plan views ---
|
|
4912
5713
|
function setPlan(i){C.active=i;P=C.plans[i];
|
|
4913
5714
|
if(!Array.isArray(P.members))P.members=[];
|
|
4914
5715
|
if(!Array.isArray(P.segments))P.segments=[];
|
|
4915
|
-
|
|
5716
|
+
sanitizeDims(P); // …and its dimensions: drop any whose geometry isn't numeric (they render straight into SVG attributes)
|
|
4916
5717
|
sanitizeFrame(P); // tolerate a hand-edited/AI-written frame: normalize or drop to global
|
|
4917
5718
|
// grid: drop a malformed hand-edited/AI-written grid at the load boundary (like sanitizeFrame) —
|
|
4918
5719
|
// the renderers assume a finite [x,y] origin; the spacing strings report their own errors inline.
|
|
4919
5720
|
if(P.grid!=null&&(typeof P.grid!=='object'||Array.isArray(P.grid)||!Array.isArray(P.grid.origin)||P.grid.origin.length<2||!isFinite(P.grid.origin[0])||!isFinite(P.grid.origin[1]))){console.warn('discarding malformed grid on '+P.sheet);P.grid=null;}
|
|
5721
|
+
if(P.grid)sanitizeGridLines(P.grid);
|
|
4920
5722
|
// clip = the drawing's display-space crop. A contract may ship WITHOUT a raster/clip (a shared or
|
|
4921
5723
|
// committed contract strips raster_b64 for confidentiality), so fall back to the members' bounding
|
|
4922
5724
|
// box (padded) → the editor renders members on a blank canvas instead of crashing on P.clip[0].
|
|
@@ -4934,13 +5736,16 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
4934
5736
|
// double-count the BOM. Collapse them automatically (keep the most-resolved copy), undoable, once
|
|
4935
5737
|
// per plan. The "Duplicates" button stays for any made while editing.
|
|
4936
5738
|
if(!P.deduped){P.deduped=true;const red=new Set(redundantDups());
|
|
4937
|
-
if(red.size){
|
|
4938
|
-
|
|
5739
|
+
if(red.size){const _pv=snapshot();P.members=P.members.filter(m=>!red.has(m.id));pushUndo(_pv); // whole-model snapshot pre-filter → the global stack can undo the dedupe from any plane
|
|
5740
|
+
setTimeout(()=>toast('Auto-removed '+red.size+' duplicate member'+(red.size>1?'s':'')),60);}}
|
|
4939
5741
|
profs=[...new Set([...P.members.map(m=>m.profile), ...Object.keys(WT)])].sort();
|
|
4940
|
-
undo
|
|
5742
|
+
// undo/redo is one GLOBAL stack (module-level, declared once) — NOT swapped per plane. A plane switch
|
|
5743
|
+
// must not reset or re-scope undo, since snapshots are whole-model and selection/edits span sheets.
|
|
4941
5744
|
selIds=new Set();findHits=new Set();picking=false;pickKind='profile';pickEnd=null;mode='sel';geoMode=null; // findHits resets per plan like selIds — a stale Find highlight must not bleed onto another sheet via a colliding member id
|
|
4942
5745
|
dimMode=false;dimChain=false;dimSplitMode=false;selDimIds=new Set();setDimMode(); // Dimension tool resets per plan (incl. chain + split); setDimMode syncs the button/body.dimon classes + clears any draft/preview/chain (dimsVisible persists across plans)
|
|
4943
|
-
|
|
5746
|
+
setMode(); // Add-member likewise resets per plan: syncs body.add (crosshair) + the button off, and drops any in-progress start point (a plan-pixel draft is stale on another sheet)
|
|
5747
|
+
if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // grid panel/pick disarms per plan like the other takeover tools (a leaked pick would set geometry in the WRONG sheet's display space)
|
|
5748
|
+
dimStyleMode=false; // the style pane's override count is per-sheet → close it on a plan switch rather than show a stale one
|
|
4944
5749
|
csaxisMode=false;setCsMode(); // set-axes tool resets per plan; P.frame itself is per-plan data (persisted), so it stays
|
|
4945
5750
|
snapOnlyClear2d();closeSnapMenu(); // a snap override never outlives its plan (different geometry)
|
|
4946
5751
|
disarmCm(); // Move/Copy resets per plan too (its counts persist — they're session prefs, not plan data)
|
|
@@ -4955,6 +5760,10 @@ planSel.innerHTML=C.plans.map((p,i)=>`<option value="${i}">${esc(p.sheet)} · ${
|
|
|
4955
5760
|
planSel.onchange=e=>setPlan(+e.target.value);
|
|
4956
5761
|
document.getElementById('revertB').onclick=()=>{if(confirm('Discard ALL saved edits and reload the originally detected contract? This cannot be undone.')){localStorage.removeItem(LSKEY);location.reload();}};
|
|
4957
5762
|
const _restored=restoreSaved(); // bring back this browser's saved edits before first paint
|
|
5763
|
+
// B4: normalize brace sub-objects across ALL plans — seed defaults on a brace, strip a stale m.brace off a
|
|
5764
|
+
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
5765
|
+
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
5766
|
+
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
4958
5767
|
setPlan(C.active==null?0:C.active);
|
|
4959
5768
|
setSaved(_restored?'ok':'idle', _restored?'Restored ✓':'Auto-save on');
|
|
4960
5769
|
try{stage.focus({preventScroll:true});}catch(_){} // grab keyboard focus on open so shortcuts work before the first click
|
|
@@ -4964,6 +5773,7 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
4964
5773
|
const fails=[];const ok=(c,m)=>{if(!c)fails.push(m);};
|
|
4965
5774
|
const near=(a,b,t=1e-6)=>Math.abs(a-b)<=t;const pnear=(p,q,t=1e-6)=>near(p[0],q[0],t)&&near(p[1],q[1],t);
|
|
4966
5775
|
const sf=P.frame;
|
|
5776
|
+
const _seSave=Object.assign({},snapEnabled);Object.assign(snapEnabled,SNAP_DEFAULTS); // run the guard against DEFAULT running-snaps, not whatever's in localStorage — a user with e.g. only-perp saved must not break the regression check (blocks that toggle snaps save/restore locally on top of this)
|
|
4967
5777
|
// 1) orthoLock — global (no frame): snaps to screen H/V
|
|
4968
5778
|
P.frame=null;
|
|
4969
5779
|
ok(pnear(orthoLock(0,0,3,1),[3,0]),'orthoLock global x-dominant');
|
|
@@ -4986,6 +5796,115 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
4986
5796
|
{const tz={frame:{o:[0,0],u:[0,0]}};sanitizeFrame(tz);ok(tz.frame===null,'sanitizeFrame drops zero-length u');}
|
|
4987
5797
|
{const tb={frame:{o:[0,0],u:[1]}};sanitizeFrame(tb);ok(tb.frame===null,'sanitizeFrame drops malformed u');}
|
|
4988
5798
|
P.frame=sf; // restore
|
|
5799
|
+
// 5b) dimension style — the three layers: per-dim override → C.dim_style → DIM_DEF. Junk at any layer
|
|
5800
|
+
// falls through to the one below.
|
|
5801
|
+
{const sds=C.dim_style;
|
|
5802
|
+
C.dim_style={end:'tick',bg:false,place:'above'};
|
|
5803
|
+
ok(dimStyle({}).end==='tick'&&dimStyle({}).bg===false&&dimStyle({}).place==='above','dimStyle → drafting defaults');
|
|
5804
|
+
ok(dimStyle({end:'arrow',bg:true,place:'on'}).end==='arrow'&&dimStyle({end:'arrow',bg:true,place:'on'}).bg===true,'dimStyle → per-dim override wins');
|
|
5805
|
+
ok(dimStyle({end:'spline',place:'sideways'}).end==='tick'&&dimStyle({end:'spline',place:'sideways'}).place==='above','dimStyle → junk per-dim value falls back');
|
|
5806
|
+
C.dim_style={end:'dot',bg:true,place:'on'}; // model-global default moves…
|
|
5807
|
+
ok(dimStyle({}).end==='dot'&&dimStyle({}).bg===true&&dimStyle({}).place==='on','dimStyle → a dim with no override follows the model default');
|
|
5808
|
+
ok(dimStyle({end:'none'}).end==='none'&&dimStyle({end:'none'}).bg===true,'dimStyle → an override beats the model default, field by field');
|
|
5809
|
+
C.dim_style={end:'spline',bg:'yes',place:42}; // …and junk in the model default falls through to DIM_DEF
|
|
5810
|
+
ok(dimStyle({}).end==='tick'&&dimStyle({}).bg===false&&dimStyle({}).place==='above','dimStyle → junk model default falls back to DIM_DEF');
|
|
5811
|
+
C.dim_style={end:'arrow'};sanitizeDimStyle(); // sanitizeDimStyle fills the missing keys, keeps the good one
|
|
5812
|
+
ok(C.dim_style.end==='arrow'&&C.dim_style.bg===false&&C.dim_style.place==='above','sanitizeDimStyle → fills missing keys, keeps valid ones');
|
|
5813
|
+
ok(!dimHasOverride({id:'x'})&&dimHasOverride({id:'x',bg:false})&&!dimHasOverride({id:'x',end:'nope'}),'dimHasOverride → only a VALID own field counts');
|
|
5814
|
+
// Split/Extend carries exactly the fields the dim overrides — a junk field is neither reported nor copied on
|
|
5815
|
+
ok(Object.keys(dimStyleOverrides({id:'y',axis:'x'})).length===0,'dimStyleOverrides → a dim with no override carries nothing');
|
|
5816
|
+
{const o=dimStyleOverrides({id:'x',end:'arrow',bg:false,place:'nope',axis:'x'});
|
|
5817
|
+
ok(o.end==='arrow'&&o.bg===false&&!('place' in o),'dimStyleOverrides → carries the valid fields, drops the junk one');}
|
|
5818
|
+
// dim_style rides every entry on the single global stack (like details/member_types) and round-trips through apply()
|
|
5819
|
+
C.dim_style={end:'dot',bg:true,place:'on'};
|
|
5820
|
+
{const entry=snapshot();
|
|
5821
|
+
ok('dim_style' in JSON.parse(entry)&&'dim_style' in JSON.parse(snapshotLike()),'snapshot + its redo mirror both carry dim_style');
|
|
5822
|
+
C.dim_style={end:'arrow',bg:false,place:'above'};
|
|
5823
|
+
apply(entry);ok(C.dim_style.end==='dot'&&C.dim_style.bg===true&&C.dim_style.place==='on','undo restores the model default (snapshot→apply round-trip)');}
|
|
5824
|
+
{const s=dimStyleMode;dimStyleMode=true;ok(anyToolActive(),'dimStyleMode counts as an armed tool');dimStyleMode=s;}
|
|
5825
|
+
C.dim_style=sds;sanitizeDimStyle();} // restore
|
|
5826
|
+
// 5b2) label width comes from the RAW text, not the escaped one — a ft-in value is full of ' and ", and
|
|
5827
|
+
// esc()ing before measuring inflated every chip (and starved the on-line gap of room). zoom is pinned so
|
|
5828
|
+
// dz is known: a ratio-only check would hold even for the bug it guards against.
|
|
5829
|
+
ok(esc(`9'-0"`).length>`9'-0"`.length,'esc() inflates ft-in text (guard premise)');
|
|
5830
|
+
{const sz=zoom;zoom=2;const dz=Math.max(zoom,DIM_ZMIN);
|
|
5831
|
+
const D={id:'t',a:[0,0],b:[2000,0],axis:'x',off:0,rot:0},svg=dimSvg({...D,bg:false,place:'on'},{});
|
|
5832
|
+
const raw=dimValueText(dimGeo(D.a,D.b,'x',0,0).px);
|
|
5833
|
+
const w=+/class="dimhit[^"]*"[^>]*width="([\d.]+)"/.exec(svg)[1];
|
|
5834
|
+
ok(near(w,(raw.length*7+16)/dz,1e-6),'label box measured from the RAW text (esc() would over-measure it)');
|
|
5835
|
+
ok((svg.match(/class="dim /g)||[]).length===2,'bare on-line label breaks the dim line in two (DIMGAP)');
|
|
5836
|
+
ok((dimSvg({...D,bg:true,place:'on'},{}).match(/class="dim /g)||[]).length===1,'a chipped label leaves the dim line whole');
|
|
5837
|
+
ok((dimSvg({...D,b:[3,0],bg:false,place:'on'},{}).match(/class="dim /g)||[]).length===1,'a dim shorter than its own label is NOT broken');
|
|
5838
|
+
// the halo is 3/dz in USER units — a fixed 3 would pass a ratio check at dz===1 and swell into a pill above it
|
|
5839
|
+
ok(near(+/stroke-width:([\d.]+)px/.exec(svg)[1],3/dz,1e-6),'bare-label halo stroke is 3/dz, so it holds its screen width');
|
|
5840
|
+
ok(!/stroke-width:/.test(dimSvg({...D,bg:true,place:'above'},{})),'a chipped label gets no halo stroke');
|
|
5841
|
+
// ticks push the witness lines past the dim line; dots stop them at it
|
|
5842
|
+
const wy2=s=>+/class="dimwit[^"]*"[^>]*y2="([\-\d.]+)"/.exec(s)[1];
|
|
5843
|
+
ok(wy2(dimSvg({...D,off:-100,end:'tick',bg:true,place:'above'},{}))!==wy2(dimSvg({...D,off:-100,end:'dot',bg:true,place:'above'},{})),'tick witness lines overshoot the dim line; dots stop at it');
|
|
5844
|
+
zoom=sz;}
|
|
5845
|
+
// 5b3) the style-pane preview renders through the REAL dimSvg with dz pinned, so it can't drift from the
|
|
5846
|
+
// canvas and can't move when the user zooms the drawing behind it.
|
|
5847
|
+
{const sz=zoom;const P1=(zoom=1,dimStylePreview({end:'tick',bg:false,place:'above'}));
|
|
5848
|
+
const P3=(zoom=3,dimStylePreview({end:'tick',bg:false,place:'above'}));zoom=sz;
|
|
5849
|
+
ok(P1===P3,'style preview is zoom-independent (dz pinned)');
|
|
5850
|
+
ok(/class="dim /.test(P1)&&/class="dimend /.test(P1)&&/class="dimtx/.test(P1),'style preview is drawn by dimSvg, not a second renderer');
|
|
5851
|
+
const chip=dimStylePreview({end:'tick',bg:true,place:'on'}),bare=dimStylePreview({end:'tick',bg:false,place:'on'});
|
|
5852
|
+
ok(/dimchip/.test(chip)&&!/dimchip/.test(bare),'preview shows the chip only with the background on');
|
|
5853
|
+
ok((bare.match(/class="dim /g)||[]).length===2&&(chip.match(/class="dim /g)||[]).length===1,'preview shows the on-line gap only with the background off');
|
|
5854
|
+
// The preview must label a FIXED sample. A substring check would pass by fluke if o.text were reverted
|
|
5855
|
+
// and the measured value happened to contain it — so pin the exact label AND render at two plan scales.
|
|
5856
|
+
{const sf=FT;FT=12;const a=dimStylePreview({end:'tick',bg:false,place:'above'});
|
|
5857
|
+
FT=0.001;const b=dimStylePreview({end:'tick',bg:false,place:'above'});FT=sf;
|
|
5858
|
+
ok(a===b,'preview is independent of the plan scale (a measured label would change with FT)');
|
|
5859
|
+
ok(/<text class="dimtx[^"]*"[^>]*>([^<]*)<\/text>/.exec(a)[1]===esc(DIM_PV_TEXT),'preview label is exactly the fixed sample');}
|
|
5860
|
+
// EVERY glyph attribute must be double-quoted: `y2=7/>` parses the slash INTO the value and the element
|
|
5861
|
+
// vanishes. Check each `=` is followed by a quote — a value-before-slash test misses `x1=2 y1="7"`.
|
|
5862
|
+
const gl=[...Object.values(DIM_END_GLYPH),...Object.values(DIM_PLACE_GLYPH)].join('');
|
|
5863
|
+
ok(!/=(?!")/.test(gl),'segmented-control glyphs quote every attribute (an unquoted one eats the self-closing slash)');
|
|
5864
|
+
// a key-COUNT check passes when a required glyph is missing and an unrelated key replaces it — then
|
|
5865
|
+
// `${DIM_END_GLYPH[k]}` renders the string "undefined" into the button.
|
|
5866
|
+
ok(DIM_ENDS.every(k=>typeof DIM_END_GLYPH[k]==='string')&&Object.keys(DIM_END_GLYPH).length===DIM_ENDS.length,'every end style has a glyph, and no stray keys');
|
|
5867
|
+
ok(['above','on'].every(k=>typeof DIM_PLACE_GLYPH[k]==='string')&&Object.keys(DIM_PLACE_GLYPH).length===2,'every label placement has a glyph');
|
|
5868
|
+
// The label box is the thing that can leave the viewBox — vertically when placed above, horizontally if
|
|
5869
|
+
// the text ever outgrows the frame. Its x/y are inside the label group's translate, so add it back.
|
|
5870
|
+
// Checked for every placement × background, not just the one combination that first bit us.
|
|
5871
|
+
for(const place of ['above','on'])for(const bg of [true,false]){
|
|
5872
|
+
const s=dimStylePreview({end:'tick',bg,place});
|
|
5873
|
+
const vb=/viewBox="0 0 (\d+) (\d+)"/.exec(s),W=+vb[1],H=+vb[2];
|
|
5874
|
+
const tr=/translate\(([\d.]+) ([\d.]+)\)/.exec(s);
|
|
5875
|
+
const bx=/<rect class="dim(?:chip|hit)[^"]*" x="(-?[\d.]+)" y="(-?[\d.]+)" width="([\d.]+)" height="([\d.]+)"/.exec(s);
|
|
5876
|
+
const L=+tr[1]+ +bx[1],T=+tr[2]+ +bx[2],R=L+ +bx[3],B=T+ +bx[4];
|
|
5877
|
+
ok(L>0&&T>0&&R<W&&B<H,`preview label box fits the viewBox (place=${place}, background=${bg?'on':'off'})`);}}
|
|
5878
|
+
// 5c) end markers — pins dimEndsSvg itself: `none` draws nothing, `dot` marks BOTH anchors, an arrow puts
|
|
5879
|
+
// a tip ON each anchor (a shared orientation would collapse both tips to one end), a tick is a 45° slash.
|
|
5880
|
+
{const g={p1:[0,0],p2:[2000,0]};
|
|
5881
|
+
ok(dimEndsSvg(g,'none',1,'')==='','dim ends: none draws nothing');
|
|
5882
|
+
ok((dimEndsSvg(g,'dot',1,'').match(/<circle/g)||[]).length===2,'dim ends: dot marks both anchors');
|
|
5883
|
+
const tips=[...dimEndsSvg(g,'arrow',1,'').matchAll(/<path class="dimend[^"]*" d="M([\-\d.]+) /g)].map(m=>+m[1]);
|
|
5884
|
+
ok(tips.length===2&&near(Math.min(...tips),0)&&near(Math.max(...tips),2000),'dim ends: an arrow tip sits on EACH anchor');
|
|
5885
|
+
const t=/<line class="dimend[^"]*" x1="([\-\d.]+)" y1="([\-\d.]+)" x2="([\-\d.]+)" y2="([\-\d.]+)"/.exec(dimEndsSvg(g,'tick',1,''));
|
|
5886
|
+
ok(near(+t[3]-+t[1],+t[4]-+t[2]),'dim ends: a tick is a 45° slash (equal dx,dy on a horizontal dim)');}
|
|
5887
|
+
// 5d) label angle — pins the clamp INSIDE dimSvg (not a transcribed copy): a vertical dim always lands on
|
|
5888
|
+
// -90 whichever way its anchors were picked, so it reads bottom-to-top and "above" stays on one side.
|
|
5889
|
+
{const rot=(a,b)=>/rotate\((-?[\d.]+)/.exec(dimSvg({id:'t',a,b,axis:'free',off:0,rot:0},{}))[1];
|
|
5890
|
+
ok(near(+rot([0,0],[0,10]),-90)&&near(+rot([0,10],[0,0]),-90),'dimSvg emits rotate(-90) for a vertical dim, both anchor orders');
|
|
5891
|
+
ok(near(+rot([0,0],[10,0]),0)&&near(+rot([10,0],[0,0]),0),'dimSvg emits rotate(0) for a horizontal dim, both anchor orders');}
|
|
5892
|
+
// 5e) sanitizeDims — a hand-edited/AI-written contract can't inject an SVG attribute through a dim anchor
|
|
5893
|
+
{const bad={sheet:'T',dims:[
|
|
5894
|
+
{id:'ok',a:[0,0],b:[10,0],axis:'x',off:5,rot:0,end:'arrow',bg:true,place:'on'},
|
|
5895
|
+
{id:'inj',a:['0" onpointerenter="alert(1)',0],b:[10,0],axis:'x',off:5}, // non-numeric anchor
|
|
5896
|
+
{id:'ax',a:[0,0],b:[10,0],axis:'diagonal',off:5}, // unknown axis
|
|
5897
|
+
{id:'nul',a:[null,0],b:[10,0],axis:'x',off:5}, // isFinite(null) is true — must NOT be repaired to 0
|
|
5898
|
+
{id:'empty',a:[0,0],b:[' ',0],axis:'x',off:5}, // …nor isFinite(' ')
|
|
5899
|
+
{id:'noff',a:[0,0],b:[10,0],axis:'x',off:null}, // …nor a null offset
|
|
5900
|
+
{id:'str',a:['0',0],b:['10',0],axis:'x',off:'5'}, // a numeric string IS accepted (hand-edited file)
|
|
5901
|
+
{id:'junk',a:[0,0],b:[10,0],axis:'free',off:5,end:'spline',place:'sideways',bg:'yes'}]};
|
|
5902
|
+
sanitizeDims(bad);
|
|
5903
|
+
ok(bad.dims.length===3&&bad.dims[0].id==='ok'&&bad.dims[1].id==='str'&&bad.dims[2].id==='junk','sanitizeDims drops non-numeric anchors, null/blank values and unknown axes');
|
|
5904
|
+
ok(bad.dims[1].a[0]===0&&bad.dims[1].b[0]===10&&bad.dims[1].off===5,'sanitizeDims coerces numeric strings to numbers');
|
|
5905
|
+
ok(bad.dims[0].end==='arrow'&&bad.dims[0].bg===true&&bad.dims[0].place==='on','sanitizeDims keeps valid style fields');
|
|
5906
|
+
ok(!('end' in bad.dims[1])&&!('place' in bad.dims[1])&&!('bg' in bad.dims[1]),'sanitizeDims strips junk style fields');
|
|
5907
|
+
{const nd={sheet:'T',dims:'not an array'};sanitizeDims(nd);ok(Array.isArray(nd.dims)&&!nd.dims.length,'sanitizeDims replaces a non-array dims with []');}}
|
|
4989
5908
|
// 6) snap — midpoint tier (△) + dimension lines as snap targets + self-snap exclusion
|
|
4990
5909
|
{const sm=P.members,ss=P.segments,sd=P.dims,sdv=dimsVisible,sz=zoom;
|
|
4991
5910
|
zoom=1;P.members=[{id:'tm',wp:[[0,0],[100,0]]}];P.segments=[];P.dims=[];dimsVisible=true;
|
|
@@ -5015,22 +5934,33 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
5015
5934
|
return near(m.col.tos,396)&&near(m.col.bos,198);})(),'retargetTos column keeps height');
|
|
5016
5935
|
ok((()=>{const m={id:'b1',role:'beam',wp:[[0,0],[1,0]],ends:[{tos:null,tosDef:true},{tos:190,tosDef:false}]};retargetTos(m,198,396);
|
|
5017
5936
|
return m.ends[0].tosDef===true&&near(m.ends[0].tos,396)&&near(m.ends[1].tos,388);})(),'retargetTos beam: default follows, override Δ-shifts');
|
|
5018
|
-
// 8)
|
|
5019
|
-
//
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
r=r&&
|
|
5031
|
-
r=r&&
|
|
5032
|
-
|
|
5033
|
-
|
|
5937
|
+
// 8) GLOBAL undo stack (whole-model). The regression the per-plane stacks caused: editing sheet A,
|
|
5938
|
+
// then sheet B, then undoing must revert ONLY the last edit (B) and leave A's edit intact — with the
|
|
5939
|
+
// old per-plane design a whole-model snapshot on A's stack silently reverted B. Also: a cross-plane
|
|
5940
|
+
// move round-trips BOTH sheets on ONE global entry. Uses the real pushUndo/doUndo/doRedo. Fake plans
|
|
5941
|
+
// are restored (and re-rendered) in finally.
|
|
5942
|
+
ok((()=>{const sp=C.plans,sA=C.active,sP=P,su=undo,sr=redo,ss=selIds,sj=C.joints;let r=true;
|
|
5943
|
+
try{const A={sheet:'__tA',members:[{id:'a1',wp:[[0,0],[1,0]]}],segments:[],dims:[]},
|
|
5944
|
+
B={sheet:'__tB',members:[{id:'b1',wp:[[0,0],[1,0]]}],segments:[],dims:[]};
|
|
5945
|
+
C.plans=[A,B];C.active=0;P=A;undo=[];redo=[];selIds=new Set();C.joints=[];
|
|
5946
|
+
const pv1=snapshot();A.members.push({id:'a2',wp:[[0,0],[1,0]]});pushUndo(pv1); // edit sheet A
|
|
5947
|
+
const pv2=snapshot();B.members.push({id:'b2',wp:[[0,0],[1,0]]});pushUndo(pv2); // edit sheet B
|
|
5948
|
+
doUndo(); r=r&&A.members.length===2&&B.members.length===1; // undo reverts B ONLY — A's edit SURVIVES (the regression)
|
|
5949
|
+
doUndo(); r=r&&A.members.length===1&&B.members.length===1; // undo A → both at start
|
|
5950
|
+
doRedo(); doRedo(); r=r&&A.members.length===2&&B.members.length===2; // redo replays both
|
|
5951
|
+
undo=[];redo=[];A.members=[{id:'a1',wp:[[0,0],[1,0]]}];B.members=[]; // fresh: cross-plane MOVE a1 A→B
|
|
5952
|
+
const pvm=snapshot();A.members=[];B.members.push({id:'a1',wp:[[0,0],[1,0]]});pushUndo(pvm);
|
|
5953
|
+
doUndo(); r=r&&A.members.length===1&&B.members.length===0; // one entry restores BOTH sheets
|
|
5954
|
+
doRedo(); r=r&&A.members.length===0&&B.members.length===1;
|
|
5955
|
+
// per-sheet dims/frame/grid: undoing while a DIFFERENT sheet is active must restore the CAPTURE sheet's
|
|
5956
|
+
// data and leave the active sheet's untouched (global stack is not swapped per plane — the fix). Uses
|
|
5957
|
+
// frame (per-sheet, render-safe) as the representative of the dims/frame/grid trio.
|
|
5958
|
+
undo=[];redo=[];A.frame={o:[0,0],u:[1,0]};B.frame={o:[9,0],u:[1,0]};P=A;C.active=0;
|
|
5959
|
+
const pvd=snapshot();A.frame={o:[5,0],u:[1,0]};pushUndo(pvd); // change sheet A's frame
|
|
5960
|
+
P=B;C.active=1;doUndo(); // undo A's frame change while viewing sheet B
|
|
5961
|
+
r=r&&A.frame.o[0]===0&&B.frame.o[0]===9; // A's frame restored; B's frame UNTOUCHED (not overwritten with A's)
|
|
5962
|
+
}catch(e){console.error('SELFTEST8 threw',e&&e.stack||e);r=false;}finally{C.plans=sp;C.active=sA;P=sP;undo=su;redo=sr;selIds=ss;C.joints=sj;render();}
|
|
5963
|
+
return r;})(),'global undo: interleaved edit undoes only the last; cross-plane move + per-sheet dims round-trip');
|
|
5034
5964
|
// 9) intersection snap (×) + the right-click snap override
|
|
5035
5965
|
{const sm=P.members,ss=P.segments,sd=P.dims,sdv=dimsVisible,sz=zoom,so=snapOnly;
|
|
5036
5966
|
zoom=1;P.members=[{id:'a',wp:[[0,0],[100,0]]},{id:'b',wp:[[50,-50],[50,50]]}];P.segments=[];P.dims=[];dimsVisible=false;
|
|
@@ -5052,6 +5982,62 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
5052
5982
|
snapEnabled.end=true;const x4=snap(1,1);ok(x4.kind==='end','re-enabling Endpoint restores it');
|
|
5053
5983
|
const ax2=snap(2,40);ok(ax2.x===0,'with Endpoint on, axis-align still pulls to the endpoint column');
|
|
5054
5984
|
Object.assign(snapEnabled,se);P.members=sm;P.segments=ss;P.dims=sd;dimsVisible=sdv;zoom=sz;}
|
|
5985
|
+
// 10b) Perpendicular (⟂) + Parallel (∥) — both key off the anchor; target a line (member/grid/overlay)
|
|
5986
|
+
{const sm=P.members,ss=P.segments,sd=P.dims,sdv=dimsVisible,sz=zoom,se=Object.assign({},snapEnabled),so=snapOnly,sflt=(typeof C!=='undefined'&&C)?C.filter:undefined;
|
|
5987
|
+
if(typeof C!=='undefined'&&C)C.filter=null;_ovSnapEls=null; // isolate: no overlay linework in the target set (null filter → overlaySnapGeom returns null)
|
|
5988
|
+
zoom=1;snapOnly=null;P.members=[{id:'t',wp:[[0,0],[100,0]]}];P.segments=[];P.dims=[];dimsVisible=false;buildSnap(null,{noGrid:true});
|
|
5989
|
+
snapEnabled.end=false;snapEnabled.int=false;snapEnabled.mid=false;snapEnabled.line=false;snapEnabled.ext=false;snapEnabled.perp=true;snapEnabled.par=false;
|
|
5990
|
+
const p1=snap(40,3,[40,40]);ok(p1.hit&&p1.kind==='perp'&&pnear([p1.x,p1.y],[40,0]),'perp → drops the anchor’s square foot onto the target line');
|
|
5991
|
+
const p0=snap(40,3);ok(p0.kind!=='perp','perp needs an anchor — a first-point pick has none, so no ⟂ snap');
|
|
5992
|
+
const pe0=snap(150,3,[150,40]);ok(pe0.kind!=='perp','perp foot past the segment end is NOT taken with Extension off');
|
|
5993
|
+
snapEnabled.ext=true;const pe1=snap(150,3,[150,40]);ok(pe1.hit&&pe1.kind==='perp'&&pnear([pe1.x,pe1.y],[150,0])&&pnear(snapExtFrom,[100,0]),'perp foot on the extension IS taken with Extension on, dashed from the near end');
|
|
5994
|
+
snapEnabled.ext=false;
|
|
5995
|
+
snapEnabled.end=true;const pr1=snap(2,2,[0,40]);ok(pr1.kind==='end','priority: endpoint outranks ⟂ when both land on the same point (anchor (0,40) → foot (0,0) = the endpoint)');
|
|
5996
|
+
snapEnabled.end=false;snapEnabled.line=true;const pr2=snap(40,3,[40,40]);ok(pr2.kind==='perp','priority: ⟂ outranks nearest-on-line (both find (40,0); ⟂ wins)');
|
|
5997
|
+
snapEnabled.line=false;snapEnabled.perp=false;snapEnabled.par=true;
|
|
5998
|
+
const pa=snap(60,12,[10,10]);ok(pa.hit&&pa.kind==='par'&&Math.abs(pa.y-10)<1e-6,'parallel → near-parallel drag locks EXACTLY to the target direction (rides the anchor’s row)');
|
|
5999
|
+
const pa2=snap(20,40,[10,10]);ok(pa2.kind!=='par','parallel does NOT fire when the drag is far from any line direction');
|
|
6000
|
+
if(typeof C!=='undefined'&&C)C.filter=sflt;_ovSnapEls=null;Object.assign(snapEnabled,se);snapOnly=so;P.members=sm;P.segments=ss;P.dims=sd;dimsVisible=sdv;zoom=sz;}
|
|
6001
|
+
// 10c) Overlay (traced PDF filter) linework as a ⟂ target (reusing B3 overlaySnapGeom) + els-identity cache rebuild
|
|
6002
|
+
{if(typeof C!=='undefined'&&C){const sm=P.members,ss=P.segments,sd=P.dims,sdv=dimsVisible,ssh=P.sheet,sz=zoom,se=Object.assign({},snapEnabled),so=snapOnly,sflt=C.filter;
|
|
6003
|
+
zoom=1;snapOnly=null;P.members=[];P.segments=[];P.dims=[];dimsVisible=false;P.sheet='__perptest'; // isolate: no member/segment/dim geometry → only the overlay is a candidate
|
|
6004
|
+
snapEnabled.end=false;snapEnabled.int=false;snapEnabled.mid=false;snapEnabled.line=false;snapEnabled.ext=false;snapEnabled.perp=true;snapEnabled.par=false;
|
|
6005
|
+
C.filter={elements:[{kind:'line',x1:0,y1:100,x2:200,y2:100}]};_ovSnapEls=null;buildSnap(null,{noGrid:true}); // explicit x1 overlay line; NO member/grid → only the overlay can be hit
|
|
6006
|
+
const o1=snap(60,97,[60,140]);ok(o1.hit&&o1.kind==='perp'&&pnear([o1.x,o1.y],[60,100]),'⟂ targets OVERLAY linework (x1 form) — foot lands on the traced filter line');
|
|
6007
|
+
C.filter={elements:[{kind:'line',d:'M0 100L200 100'}]};buildSnap(null,{noGrid:true}); // NEW array identity + d-path form → overlaySnapGeom rebuilds (no manual cache reset)
|
|
6008
|
+
const o2=snap(60,97,[60,140]);ok(o2.hit&&o2.kind==='perp'&&pnear([o2.x,o2.y],[60,100]),'⟂ targets OVERLAY d-path linework AND the els-identity cache rebuilt on the swapped array');
|
|
6009
|
+
snapEnabled.perp=false;snapEnabled.par=true;
|
|
6010
|
+
const opar=snap(70,102,[10,100]);ok(opar.kind!=='par','∥ does NOT target the overlay — a drag parallel to a traced line does not lock (overlay too dense to direction-match; parallel uses model geometry only)');
|
|
6011
|
+
C.filter=sflt;P.sheet=ssh;P.dims=sd;dimsVisible=sdv;_ovSnapEls=null;Object.assign(snapEnabled,se);snapOnly=so;P.members=sm;P.segments=ss;zoom=sz;}}
|
|
6012
|
+
// 10d) ⟂/∥ can target a DIMENSION line (square/parallel to a placed dimension)
|
|
6013
|
+
{const sm=P.members,ss=P.segments,sd=P.dims,sdv=dimsVisible,sz=zoom,se=Object.assign({},snapEnabled),so=snapOnly,sflt=(typeof C!=='undefined'&&C)?C.filter:undefined;
|
|
6014
|
+
if(typeof C!=='undefined'&&C)C.filter=null;_ovSnapEls=null;
|
|
6015
|
+
zoom=1;snapOnly=null;P.members=[];P.segments=[];P.dims=[{id:'dt',a:[0,0],b:[100,0],axis:'x',off:40,rot:0}];dimsVisible=true;buildSnap(null,{noGrid:true});
|
|
6016
|
+
ok(snapDimSegs.length>0,'the dim line is captured as a ⟂/∥ target (snapDimSegs), kept out of snapGeom');
|
|
6017
|
+
snapEnabled.end=false;snapEnabled.int=false;snapEnabled.mid=false;snapEnabled.line=false;snapEnabled.ext=false;snapEnabled.perp=true;snapEnabled.par=false;
|
|
6018
|
+
const ds=snapDimSegs[0],dm=[(ds[0][0]+ds[1][0])/2,(ds[0][1]+ds[1][1])/2],dv=[ds[1][0]-ds[0][0],ds[1][1]-ds[0][1]],dL=Math.hypot(dv[0],dv[1]),nx=-dv[1]/dL,ny=dv[0]/dL;
|
|
6019
|
+
const dp=snap(dm[0]+nx*2,dm[1]+ny*2,[dm[0]+nx*30,dm[1]+ny*30]);ok(dp.hit&&dp.kind==='perp'&&pnear([dp.x,dp.y],dm,0.5),'⟂ drops the foot onto a dimension line');
|
|
6020
|
+
if(typeof C!=='undefined'&&C)C.filter=sflt;_ovSnapEls=null;Object.assign(snapEnabled,se);snapOnly=so;P.members=sm;P.segments=ss;P.dims=sd;dimsVisible=sdv;zoom=sz;}
|
|
6021
|
+
// 11b) B3 — snapping to the traced PDF overlay (filter vectors → endpoint/nearest/midpoint) + the path parser
|
|
6022
|
+
{const sm=P.members,ss=P.segments,sd=P.dims,sf=C.filter,ssh=P.sheet,sdv=dimsVisible,sz=zoom;
|
|
6023
|
+
zoom=1;P.members=[];P.segments=[];P.dims=[];dimsVisible=false;P.sheet='__ovtest';
|
|
6024
|
+
C.filter={elements:[{kind:'line',d:'M 0 0 L 100 0 L 100 40'}]}; // an L-polyline (0,0)→(100,0)→(100,40)
|
|
6025
|
+
_ovSnapEls=null;buildSnap(null,{noGrid:true}); // reset the cache (keys on els identity), then rebuild
|
|
6026
|
+
const oe=snap(2,2);ok(oe.hit&&oe.kind==='end'&&pnear([oe.x,oe.y],[0,0]),'overlay → snaps to a traced line endpoint');
|
|
6027
|
+
const om=snap(50,2);ok(om.hit&&om.kind==='mid'&&pnear([om.x,om.y],[50,0]),'overlay → snaps to a traced segment midpoint (△)');
|
|
6028
|
+
const ol=snap(30,3);ok(ol.hit&&pnear([ol.x,ol.y],[30,0]),'overlay → snaps onto a traced line (nearest)');
|
|
6029
|
+
_ovSnapEls=null;buildSnap(null,{noGrid:true,noOverlay:true});const on=snap(2,2);ok(!on.hit,'opts.noOverlay excludes the overlay from the snap set');
|
|
6030
|
+
// parser handles the full line-ish grammar so snapping stays in step with what overlaySvg() draws
|
|
6031
|
+
{const g=[];parsePathSegs('M 0 0 L 10 0 C 12 5 14 5 16 0',(a,b)=>g.push([a,b]));
|
|
6032
|
+
ok(g.length===2&&pnear(g[0][0],[0,0])&&pnear(g[0][1],[10,0])&&pnear(g[1][1],[16,0]),'parsePathSegs: M/L segment + C chord to endpoint');}
|
|
6033
|
+
{const g=[];parsePathSegs('M 10 10 l 5 0 v 5 h -5 z',(a,b)=>g.push([a,b])); // relative l/v/h then Z close
|
|
6034
|
+
ok(g.length===4&&pnear(g[0][1],[15,10])&&pnear(g[1][1],[15,15])&&pnear(g[2][1],[10,15])&&pnear(g[3][1],[10,10]),'parsePathSegs: relative l/v/h + Z close back to subpath start');}
|
|
6035
|
+
{const g=[];parsePathSegs('M 0 0 L 1e2 0',(a,b)=>g.push([a,b]));ok(g.length===1&&pnear(g[0][1],[100,0]),'parsePathSegs: exponent coordinate (1e2 → 100)');}
|
|
6036
|
+
// axis-align fallback (snap() rung 6) must NEVER pull to an overlay vertex — only authored endpoints
|
|
6037
|
+
P.members=[{id:'col',wp:[[200,0],[200,50]]}];C.filter={elements:[{kind:'line',d:'M 5 30 L 5 60'}]}; // authored column far away; overlay vertices sit at x=5
|
|
6038
|
+
_ovSnapEls=null;buildSnap(null,{noGrid:true});
|
|
6039
|
+
const aa=snap(7,500);ok(!aa.hit&&aa.x===7,'axis-align ignores overlay vertices — a free point is NOT silently pulled to a drawing column');
|
|
6040
|
+
C.filter=sf;P.sheet=ssh;_ovSnapEls=null;P.members=sm;P.segments=ss;P.dims=sd;dimsVisible=sdv;zoom=sz;}
|
|
5055
6041
|
// 11) member length — true 3D distance between the two end nodes: level beam = plan run, plumb column = TOS−BOS
|
|
5056
6042
|
// height (its plan points coincide → 0 plan distance), and a SLOPED member picks up its elevation rise.
|
|
5057
6043
|
{const sf=FT,st=defaultTOS;FT=12;defaultTOS=198;
|
|
@@ -5071,7 +6057,151 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
5071
6057
|
ok(win([2,2],[8,8])&&crs([2,2],[8,8]),'fully-inside member: window and crossing both pick it');
|
|
5072
6058
|
ok(!win([5,5],[50,5])&&crs([5,5],[50,5]),'straddling member: crossing picks it, window does not');
|
|
5073
6059
|
ok(!win([20,20],[30,30])&&!crs([20,20],[30,30]),'outside member: neither picks it');}
|
|
5074
|
-
|
|
6060
|
+
Object.assign(snapEnabled,_seSave); // restore the user's real running-snaps (before any further case runs)
|
|
6061
|
+
// 13) B4 braces — normBrace hygiene, lower/higher-end derivation, and the DISPLAY-ONLY offset.
|
|
6062
|
+
// The invariant that must never rot: brace.offset moves the DRAWN line, never m.wp.
|
|
6063
|
+
{const sm=P.members,sz=zoom,sp=P.pt_per_ft,st=defaultTOS;
|
|
6064
|
+
zoom=1;P.pt_per_ft=12;defaultTOS=0; // 12 px per ft → 12" of offset = 12 px
|
|
6065
|
+
const mk=o=>Object.assign({id:'br',role:'beam',memberType:'brace',profile:'HSS4X4X1/4',wp:[[0,0],[100,0]],
|
|
6066
|
+
ends:[{tos:0,tosDef:false},{tos:0,tosDef:false}]},o);
|
|
6067
|
+
|
|
6068
|
+
// normBrace: seeds defaults on a brace …
|
|
6069
|
+
{const m=normBrace(mk({}));ok(m.brace&&m.brace.type==='vertical'&&m.brace.floor==='above'&&m.brace.offset===0,'normBrace seeds vertical/above/0');}
|
|
6070
|
+
// … clamps garbage (a reader/AI can write anything) …
|
|
6071
|
+
{const m=normBrace(mk({brace:{type:'diagonal',floor:'over',offset:'6"',lowerEnd:2}}));
|
|
6072
|
+
ok(m.brace.type==='vertical'&&m.brace.floor==='above'&&m.brace.offset===0&&m.brace.lowerEnd===undefined,'normBrace clamps bad type/floor/offset/lowerEnd');}
|
|
6073
|
+
// … and STRIPS a stale sub-object off a non-brace (retyped away, or a reader mistake)
|
|
6074
|
+
{const m=normBrace({id:'b',role:'beam',memberType:'beam',wp:[[0,0],[1,0]],brace:{type:'vertical'}});
|
|
6075
|
+
ok(!('brace' in m),'normBrace deletes a stale m.brace from a non-brace');}
|
|
6076
|
+
|
|
6077
|
+
// lower end = the end with the lower effective TOS; a tie falls back to end 0; an override wins.
|
|
6078
|
+
ok(braceLowerEnd(normBrace(mk({ends:[{tos:120,tosDef:false},{tos:0,tosDef:false}]})))===1,'braceLowerEnd → the lower-TOS end');
|
|
6079
|
+
ok(braceLowerEnd(normBrace(mk({})))===0,'braceLowerEnd → tie falls back to end 0');
|
|
6080
|
+
ok(braceLowerEnd(normBrace(mk({brace:{lowerEnd:1}})))===1,'braceLowerEnd → stored override wins over the TOS tie');
|
|
6081
|
+
// a DEFAULT-FOLLOW end carries tos:null, and +null===0 — so a bare Number.isFinite(+tos) would read it as
|
|
6082
|
+
// elevation ZERO and flip the arrowheads. effEndTos must resolve null to the plan default (PR review).
|
|
6083
|
+
{const st2=defaultTOS;defaultTOS=348;
|
|
6084
|
+
ok(effEndTos({tos:null,tosDef:true})===348,'effEndTos: a default-follow end (tos:null) resolves to the plan default, not 0');
|
|
6085
|
+
ok(braceLowerEnd(normBrace(mk({ends:[{tos:120,tosDef:false},{tos:null,tosDef:true}]})))===0,'braceLowerEnd: explicit 120" is LOWER than a default-follow 348" end');
|
|
6086
|
+
defaultTOS=st2;}
|
|
6087
|
+
// swapMemberEnds reverses wp, which flips the perpendicular → the offset must negate so the DRAWN line
|
|
6088
|
+
// stays on the same physical side, and the lower-end override must follow the swapped indices.
|
|
6089
|
+
{const m=normBrace(mk({brace:{type:'vertical',floor:'below',offset:12,lowerEnd:0}}));
|
|
6090
|
+
const drawnBefore=braceDisplayLine(m).map(p=>p.slice());
|
|
6091
|
+
swapMemberEnds(m);
|
|
6092
|
+
const drawnAfter=braceDisplayLine(m);
|
|
6093
|
+
ok(m.brace.offset===-12,'swapMemberEnds negates a brace offset (drawn side preserved)');
|
|
6094
|
+
ok(m.brace.lowerEnd===1,'swapMemberEnds inverts a stored lowerEnd override');
|
|
6095
|
+
ok(pnear(drawnAfter[0],drawnBefore[1])&&pnear(drawnAfter[1],drawnBefore[0]),'swapMemberEnds leaves the DRAWN brace line exactly where it was');}
|
|
6096
|
+
|
|
6097
|
+
// DISPLAY-ONLY offset: the drawn line shifts perpendicular, m.wp does NOT move. A negative value
|
|
6098
|
+
// flips the side. A lateral brace ignores offset entirely (it lives between beams, never offset).
|
|
6099
|
+
{const m=normBrace(mk({brace:{type:'vertical',floor:'below',offset:12}}));
|
|
6100
|
+
const dl=braceDisplayLine(m);
|
|
6101
|
+
ok(pnear(dl[0],[0,12])&&pnear(dl[1],[100,12]),'braceDisplayLine offsets the DRAWN line by +12px');
|
|
6102
|
+
ok(pnear(m.wp[0],[0,0])&&pnear(m.wp[1],[100,0]),'brace.offset never moves m.wp (display-only)');
|
|
6103
|
+
m.brace.offset=-12;ok(pnear(braceDisplayLine(m)[0],[0,-12]),'a negative offset draws on the other side');
|
|
6104
|
+
m.brace.type='lateral';ok(pnear(braceDisplayLine(m)[0],[0,0]),'a lateral brace is never offset');}
|
|
6105
|
+
|
|
6106
|
+
// arrowheads: tips sit AT the end points, bodies inward — no head may overhang a work point.
|
|
6107
|
+
{const m=normBrace(mk({brace:{type:'vertical',floor:'above',offset:0}}));
|
|
6108
|
+
const pts=braceHeadPoints(m).join(' ').split(' ').map(s=>s.split(',').map(Number));
|
|
6109
|
+
ok(pts.every(p=>p[0]>=-0.01&&p[0]<=100.01),'brace arrowheads never overhang the work points');
|
|
6110
|
+
ok(braceHeadPoints(m).length===3,'brace draws 3 heads (single higher + double lower)');}
|
|
6111
|
+
|
|
6112
|
+
// ── the CLIENT MIRRORS of the server guards. These are the paths that actually bite the user while
|
|
6113
|
+
// editing (silent geometry corruption), and the server tests do not protect them. (pr-test-analyzer)
|
|
6114
|
+
ok(!_mElig(normBrace(mk({}))),'_mElig rejects a brace (never merges into a beam)');
|
|
6115
|
+
|
|
6116
|
+
{const sm2=P.members;
|
|
6117
|
+
// reversedBeams: a brace pointing "backwards" must not be offered to the reversed-beams tool
|
|
6118
|
+
P.members=[normBrace(mk({id:'brR',wp:[[100,0],[0,0]]})), {id:'bR',role:'beam',profile:'W16X26',wp:[[100,0],[0,0]],ends:[{},{}]}];
|
|
6119
|
+
const rb=reversedBeams();
|
|
6120
|
+
ok(!rb.includes('brR')&&rb.includes('bR'),'reversedBeams excludes a brace, still finds a reversed beam');
|
|
6121
|
+
|
|
6122
|
+
// buildSnap: a brace contributes its TRUE endpoints but NO body segment (so ⟂/∥/nearest can never
|
|
6123
|
+
// latch onto its invisible, offset baseline)
|
|
6124
|
+
{const ss=P.segments,sd=P.dims,sdv=dimsVisible;
|
|
6125
|
+
P.members=[normBrace(mk({id:'brS',wp:[[0,0],[100,0]],brace:{type:'vertical',floor:'above',offset:24}}))];
|
|
6126
|
+
P.segments=[];P.dims=[];dimsVisible=false;buildSnap(null,{noGrid:true});
|
|
6127
|
+
const hasEnds=snapPts.some(p=>pnear(p,[0,0]))&&snapPts.some(p=>pnear(p,[100,0]));
|
|
6128
|
+
const hasBody=snapGeom.some(g=>pnear(g[0],[0,0])&&pnear(g[1],[100,0]));
|
|
6129
|
+
ok(hasEnds,'buildSnap keeps a brace’s TRUE work-point endpoints');
|
|
6130
|
+
ok(!hasBody&&!snapMids.some(q=>pnear(q,[50,0])),'buildSnap excludes a brace’s body from snapGeom/snapMids');
|
|
6131
|
+
P.segments=ss;P.dims=sd;dimsVisible=sdv;}
|
|
6132
|
+
|
|
6133
|
+
// snapEndMulti (Extend/Trim) must never move a brace work point, and must not push an undo entry
|
|
6134
|
+
{const br=normBrace(mk({id:'brX',wp:[[0,0],[100,0]]})), bm={id:'bX',role:'beam',profile:'W16X26',wp:[[0,50],[100,50]],ends:[{},{}]};
|
|
6135
|
+
P.members=[br,bm];const u0=undo.length;
|
|
6136
|
+
const moved=snapEndMulti([br],[200,-50],[200,50]); // a target line the brace's axis would meet at x=200
|
|
6137
|
+
ok(moved===0&&pnear(br.wp[1],[100,0])&&undo.length===u0,'snapEndMulti skips a brace (no wp move, no undo entry)');}
|
|
6138
|
+
|
|
6139
|
+
// doSplit is a no-op on a brace
|
|
6140
|
+
{const br=normBrace(mk({id:'brD',wp:[[0,0],[100,0]]}));P.members=[br];
|
|
6141
|
+
doSplit(br,[50,0]);ok(P.members.length===1,'doSplit refuses to cut a brace');}
|
|
6142
|
+
|
|
6143
|
+
// swapSelectionEnds skips braces (the bulk path that used to flip a brace's offset side)
|
|
6144
|
+
{const br=normBrace(mk({id:'brW',wp:[[0,0],[100,0]],brace:{type:'vertical',floor:'above',offset:24}}));
|
|
6145
|
+
P.members=[br];const si=selIds;selIds=new Set(['brW']);const u0=undo.length;
|
|
6146
|
+
const r=swapSelectionEnds();
|
|
6147
|
+
ok(r.skipped===1&&r.swapped===0&&pnear(br.wp[0],[0,0])&&undo.length===u0,'swapSelectionEnds skips an all-brace selection (no wp move, no undo entry)');
|
|
6148
|
+
selIds=si;}
|
|
6149
|
+
|
|
6150
|
+
// the editor's shear-plate mirror: a brace neither carries nor supports a fin plate
|
|
6151
|
+
{const br=normBrace(mk({id:'brP',wp:[[0,0],[0,100]]})), bm={id:'bP',role:'beam',profile:'W16X26',wp:[[0,0],[100,0]],ends:[{},{}]};
|
|
6152
|
+
P.members=[br,bm];
|
|
6153
|
+
ok(spEndEligible(br,0)===false,'spEndEligible rejects a brace end');
|
|
6154
|
+
ok(spInferSupport(bm,0)!==br,'spInferSupport never returns a brace as the support');
|
|
6155
|
+
ok(!spBeamIds().has('brP'),'spBeamIds excludes braces');}
|
|
6156
|
+
|
|
6157
|
+
// retyping a CONNECTED beam to a brace must purge the joint the bake would silently refuse
|
|
6158
|
+
{const sj=C.joints;
|
|
6159
|
+
const bm={id:'bJ',role:'beam',memberType:'beam',profile:'W16X26',wp:[[0,0],[100,0]],ends:[{},{}]};
|
|
6160
|
+
C.joints=[{id:'j1',kind:'shear-plate',main:'bJ',at:'end0'},{id:'j2',kind:'shear-plate',main:'other',secondaries:['bJ']}];
|
|
6161
|
+
P.members=[bm];applyMemberType([bm],'brace');
|
|
6162
|
+
ok(!C.joints.some(j=>j.main==='bJ'),'retyping a connected beam to a brace purges the joint hanging off it');
|
|
6163
|
+
ok(!(C.joints.find(j=>j.id==='j2')||{secondaries:[]}).secondaries.includes('bJ'),'…and drops it from any other joint’s supports');
|
|
6164
|
+
C.joints=sj;}
|
|
6165
|
+
|
|
6166
|
+
// the editor's confidence mirror: brace ends are not scored as beam connections
|
|
6167
|
+
{const spl=C.plans,sa=C.active;
|
|
6168
|
+
C.plans=[{sheet:'T',members:[normBrace(mk({id:'brC',wp:[[0,0],[100,0]]})),{id:'bC',role:'beam',profile:'W16X26',wp:[[0,50],[100,50]],ends:[{},{}]}]}];
|
|
6169
|
+
const ids=_scoreConnections().ends.map(e=>e.memberId);
|
|
6170
|
+
ok(!ids.includes('brC')&&ids.includes('bC'),'_scoreConnections skips brace ends, still scores beams');
|
|
6171
|
+
C.plans=spl;C.active=sa;}
|
|
6172
|
+
|
|
6173
|
+
P.members=sm2;}
|
|
6174
|
+
|
|
6175
|
+
P.members=sm;zoom=sz;P.pt_per_ft=sp;defaultTOS=st;}
|
|
6176
|
+
|
|
6177
|
+
// 14) The editor's first-load auto-dedupe DELETES what redundantDups() returns, so an X-brace's two
|
|
6178
|
+
// legs — which share a plan footprint — live or die by this function. Guard both directions.
|
|
6179
|
+
{const sm3=P.members;
|
|
6180
|
+
const leg=(id,wp,ends,off)=>({id,role:'beam',memberType:'brace',profile:'HSS6X6X5/8',wp,
|
|
6181
|
+
brace:{type:'vertical',floor:'above',offset:off},ends});
|
|
6182
|
+
const AB=[[0,0],[240,0]],BA=[[240,0],[0,0]];
|
|
6183
|
+
const lo={tos:0,tosDef:false},hi={tos:198,tosDef:false};
|
|
6184
|
+
// RIGHT: same canonical wp order, transposed elevations → two distinct signatures → both kept.
|
|
6185
|
+
P.members=[leg('lA',AB,[lo,hi],12),leg('lB',AB,[hi,lo],-12)];
|
|
6186
|
+
ok(redundantDups().length===0,'redundantDups keeps BOTH legs of a correctly-emitted X');
|
|
6187
|
+
// WRONG: mirrored wp (footprint is order-independent) + untransposed elevations → one leg destroyed.
|
|
6188
|
+
P.members=[leg('lA',AB,[lo,hi],12),leg('lB',BA,[lo,hi],-12)];
|
|
6189
|
+
ok(redundantDups().length===1,'redundantDups drops a leg when the X is emitted with mirrored wp');
|
|
6190
|
+
P.members=sm3;}
|
|
6191
|
+
|
|
6192
|
+
// 15) posDefault() must MIRROR server/contract-to-scene.ts depthPosition(), or the inspector
|
|
6193
|
+
// highlights a default the bake does not use. A SHALLOW vertical brace (wide bay, short storey)
|
|
6194
|
+
// is the discriminating case: the slope heuristic alone calls it "roughly flat" → top.
|
|
6195
|
+
{const sp2=P.pt_per_ft,st2=defaultTOS;
|
|
6196
|
+
P.pt_per_ft=12;defaultTOS=0;
|
|
6197
|
+
const shallow=(brace,position)=>Object.assign({id:'sb',role:'beam',memberType:'brace',profile:'HSS6X6X5/8',
|
|
6198
|
+
wp:[[0,0],[1200,0]],ends:[{tos:0,tosDef:false},{tos:12,tosDef:false}],brace},position?{position}:{});
|
|
6199
|
+
ok(posDefault(shallow({type:'vertical',floor:'above',offset:12}))==='middle','posDefault centres a SHALLOW vertical brace');
|
|
6200
|
+
ok(posDefault(shallow({type:'lateral'}))==='top','posDefault leaves a flat lateral brace at top (control)');
|
|
6201
|
+
ok(posDefault(shallow({type:'vertical',floor:'above',offset:12},'top'))==='top','an explicit position still wins');
|
|
6202
|
+
P.pt_per_ft=sp2;defaultTOS=st2;}
|
|
6203
|
+
|
|
6204
|
+
const msg=fails.length?('SELFTEST FAIL: '+fails.join(' | ')):'SELFTEST PASS (frame + snap + transform + brace math)';
|
|
5075
6205
|
console[fails.length?'error':'log'](msg);try{toast(msg);}catch(_){}
|
|
5076
6206
|
})();}
|
|
5077
6207
|
// --- provenance caption: show contract.source when present (read from <name> · <sheet> · <read_at>) ---
|
|
@@ -5264,4 +6394,4 @@ boot().catch(err => { document.body.replaceChildren(Object.assign(document.creat
|
|
|
5264
6394
|
document.addEventListener('pointerout', e=>{ if(e.target.closest('[data-tip]')) hide(); });
|
|
5265
6395
|
document.addEventListener('pointerdown', hide, true); // a click hides the tip immediately
|
|
5266
6396
|
})();
|
|
5267
|
-
</script></body></html>
|
|
6397
|
+
</script></body></html>
|