@floless/app 0.132.2 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +5948 -3270
- package/dist/schemas/steel.model.v2.schema.json +216 -3
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +66 -5
- package/dist/templates/steel-model.flo +6 -2
- package/dist/web/app.css +41 -1
- package/dist/web/app.js +3 -2
- package/dist/web/aware.js +291 -12
- package/dist/web/commands-shell.js +40 -2
- package/dist/web/commands-steel.js +130 -3
- package/dist/web/index.html +16 -3
- package/dist/web/instructor.js +108 -25
- package/dist/web/steel-3d-core.js +128 -0
- package/dist/web/steel-3d-view.js +38 -13
- package/dist/web/steel-editor.html +361 -158
- package/dist/web/steel-model-v2-client-validation.js +6 -0
- package/dist/web/steel-model-v2-commands.js +127 -50
- package/dist/web/steel-model-v2-projection.js +3 -2
- package/package.json +4 -1
|
@@ -707,6 +707,30 @@
|
|
|
707
707
|
body.v3d #snapSect [data-snap3d]{display:flex}
|
|
708
708
|
#moreMenu .mhint{color:var(--mut);font-size:11px;line-height:1.4;padding:4px 12px 6px;max-width:230px;white-space:normal}
|
|
709
709
|
#rfiStat{cursor:pointer;text-decoration:underline dotted} #rfiStat:hover b{color:var(--ink-max)}
|
|
710
|
+
#endsStat{color:var(--mut)} #endsStat.has{color:var(--warn)} #endsStat.has b{color:var(--warn)}
|
|
711
|
+
body.member-end-review #stage{cursor:default}
|
|
712
|
+
#panel .mer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:4px}
|
|
713
|
+
#panel .mer-title{font-size:10px;font-weight:700;line-height:1.35;letter-spacing:.08em;text-transform:uppercase;color:var(--text)}
|
|
714
|
+
#panel .mer-toolbar,#panel .mer-nav{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px}
|
|
715
|
+
#panel .mer-group{margin-top:12px;padding-top:9px;border-top:1px solid var(--line)}
|
|
716
|
+
#panel .mer-group-title{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--mut);margin-bottom:5px}
|
|
717
|
+
#panel .mer-row{display:grid;grid-template-columns:18px minmax(0,1fr);gap:7px;padding:8px 5px;border-left:3px solid transparent;border-radius:4px}
|
|
718
|
+
#panel .mer-row.focused{background:var(--brand-wash);border-left-color:var(--brand)}
|
|
719
|
+
#panel .mer-row:focus-within{outline:2px solid var(--brand);outline-offset:-2px}
|
|
720
|
+
#panel .mer-row label{display:flex;align-items:flex-start;gap:7px;min-width:0;color:var(--text);font-size:12px;font-weight:600;line-height:1.35;cursor:pointer}
|
|
721
|
+
#panel .mer-row input[type=checkbox]{margin-top:1px;cursor:pointer}
|
|
722
|
+
#panel .mer-evidence{font-size:11px;line-height:1.4;color:var(--mut);margin-top:3px;overflow-wrap:anywhere}
|
|
723
|
+
#panel .mer-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
|
|
724
|
+
#panel .mer-actions button,#panel .mer-toolbar button,#panel .mer-nav button{font-size:11px;padding:4px 7px}
|
|
725
|
+
#panel .mer-actions button.selected{border-color:var(--brand);background:var(--brand-wash);color:var(--text)}
|
|
726
|
+
#panel .mer-primary{width:100%;margin-top:10px;background:var(--brand);border-color:var(--brand);color:var(--brand-ink);font-weight:700}
|
|
727
|
+
#panel .mer-live{min-height:18px;margin-top:7px;font-size:11px;line-height:1.4;color:var(--mut)}
|
|
728
|
+
.mer-extension{stroke:var(--warn);stroke-width:2;stroke-dasharray:8 5;vector-effect:non-scaling-stroke;pointer-events:none}
|
|
729
|
+
.mer-target-line{stroke:var(--cyan);stroke-width:3;stroke-dasharray:3 4;vector-effect:non-scaling-stroke;fill:none;pointer-events:none}
|
|
730
|
+
.mer-end-marker,.mer-target-marker{fill:var(--panel);stroke-width:2;vector-effect:non-scaling-stroke}
|
|
731
|
+
.mer-end-marker{stroke:var(--warn);pointer-events:none} .mer-target-marker{stroke:var(--cyan);pointer-events:all;cursor:pointer}
|
|
732
|
+
.mer-target-marker.selected{stroke:var(--brand);stroke-width:4}
|
|
733
|
+
.mer-label{fill:var(--text);font:700 11px system-ui;paint-order:stroke;stroke:var(--bg);stroke-width:3px;stroke-linejoin:round;pointer-events:none}
|
|
710
734
|
#confStat{cursor:pointer;text-decoration:underline dotted} #confStat:hover b{filter:brightness(1.25)}
|
|
711
735
|
.conf-cats{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;padding:14px;border-bottom:1px solid var(--line)}
|
|
712
736
|
.ccard{background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:10px 12px}
|
|
@@ -1757,6 +1781,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1757
1781
|
<span class=stat id=mcStat>Members <b id=mc>0</b></span><span class=stat id=wtStat>Weight <b id=wt>0</b> tons · <b id=wtlb>0</b> lb</span>
|
|
1758
1782
|
<span class=stat id=rfiStat data-tip="Click to list members with an unresolved size (RFI — Request for Information)">RFI <b id=rc>0</b></span>
|
|
1759
1783
|
<span class=stat id=dupStat data-tip="Overlapping/duplicate members (same geometry)">Dup <b id=dpc>0</b></span>
|
|
1784
|
+
<span class=stat id=endsStat data-tip="Member ends that may stop at a support face instead of its centerline.">Ends <b id=endsCount>—</b></span>
|
|
1760
1785
|
<span class=stat id=csStat data-tip="Coordinate system — Global by default. Set a local frame from the ⋯ menu for skewed framing.">Axes <b>Global</b></span>
|
|
1761
1786
|
<span class=stat id=snapStat style="display:none" data-tip="Snap restricted for this operation — right-click the canvas to change; click here or press Esc to clear">Snap <b>—</b></span>
|
|
1762
1787
|
<span class=stat id=confStat data-tip="Confidence report — AI-read score vs. target. Click to review element evidence." style="display:none">Confidence <b id=confPct>—</b><span id=confTgt></span></span>
|
|
@@ -1840,6 +1865,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
1840
1865
|
<div class=msec-body>
|
|
1841
1866
|
<button data-command-id="steel.check-duplicates" id=dupB data-tip="Selects overlapping members drawn twice by mistake — review, then press Delete to remove the extra one.">Duplicates</button>
|
|
1842
1867
|
<button data-command-id="steel.check-reversed" id=revB data-tip="Select beams drawn the wrong way — a mostly-horizontal beam should run left→right, a steep/skew beam bottom→up. Review, then press P to swap their direction.">Reversed beams</button>
|
|
1868
|
+
<button data-command-id="steel.check-member-ends" id=memberEndsB data-tip="Find beam and brace ends that may stop at support faces instead of support centerlines. Drawing reads automatically align only unambiguous cases; review the rest here.">Check member ends short of supports</button>
|
|
1843
1869
|
<button data-command-id="steel.merge-collinear" id=mrgB data-tip="Joins straight, end-to-end runs of the same profile into one beam. Undoable.">Merge collinear beams</button>
|
|
1844
1870
|
</div>
|
|
1845
1871
|
<button data-command-id="steel.menu-section#Coordinate system" class=msec-hdr data-sec=coords aria-expanded=false data-tip="Local vs global drawing axes (for skewed framing)">Coordinate system<span class=chev aria-hidden=true>▸</span></button>
|
|
@@ -2466,6 +2492,82 @@ const DEFAULT_PAL=['#60a5fa','#94a3b8','#f59e0b','#34d399','#f472b6','#a78bfa','
|
|
|
2466
2492
|
// `conflicted` LATCHES: once a save is refused, firing the identical PUT every 500 ms debounce tick is
|
|
2467
2493
|
// wasted traffic and makes the pill flicker in a way that reads as broken rather than informative.
|
|
2468
2494
|
let serverEtag = null;
|
|
2495
|
+
let serverRevision = -1;
|
|
2496
|
+
let contractEventEpoch = 0;
|
|
2497
|
+
let contractEventReady = false;
|
|
2498
|
+
let contractEventWatermark = null;
|
|
2499
|
+
let contractEventSource = null;
|
|
2500
|
+
let contractBootSnapshotInstalled = false;
|
|
2501
|
+
const CONTRACT_EVENT_BOOTSTRAP_ATTEMPTS = 3;
|
|
2502
|
+
const CONTRACT_EVENT_BOOTSTRAP_RETRY_MS = 250;
|
|
2503
|
+
|
|
2504
|
+
function contractEventMatches(m){return m&&typeof m==='object'&&m.type==='contract-changed'&&m.appId===APP_ID&&((m.project||'')===PROJECT);}
|
|
2505
|
+
function editorHasUnsavedWork(){const sv=document.getElementById('saveStat');return !!sv&&(sv.classList.contains('dirty')||sv.classList.contains('err')||sv.classList.contains('conflict'));}
|
|
2506
|
+
function parkDraftForExternalChange(){const parked=flushLocalDraft?flushLocalDraft():false;if(!parked)console.warn('steel-editor: pending edits could not be parked before an external model update');return parked;}
|
|
2507
|
+
function handleContractChanged(m){
|
|
2508
|
+
if(!contractEventMatches(m))return;
|
|
2509
|
+
if(!Number.isSafeInteger(m.storeRevision)||m.storeRevision<0||typeof m.etag!=='string'){console.warn('steel-editor: ignored an unorderable contract event');return;}
|
|
2510
|
+
const own=m.mutationId?ownWrites.indexOf(m.mutationId):-1;
|
|
2511
|
+
if(own>=0){const newest=own===ownWrites.length-1;ownWrites.splice(0,own+1);if(newest&&m.storeRevision>serverRevision){const prev=serverEtag;serverEtag=m.etag;serverRevision=m.storeRevision;restampDraftBase(prev,m.etag);}return;}
|
|
2512
|
+
if(m.storeRevision<=serverRevision)return;
|
|
2513
|
+
if(window.invalidateMemberEndReview)window.invalidateMemberEndReview('The model changed — check member ends again.');
|
|
2514
|
+
if(editorHasUnsavedWork()){
|
|
2515
|
+
const parked=parkDraftForExternalChange();
|
|
2516
|
+
const lead=(typeof m.reason==='string'&&CHANGE_LEAD[m.reason])||'The AI updated this model';
|
|
2517
|
+
showAiUpdateBanner(parked?lead+' — reload to see it (you have unsaved edits).':lead+' — but this browser could not save your unsaved edits, so reloading would lose them. Copy them out first.',parked?undefined:{noReload:true});
|
|
2518
|
+
}else location.reload();
|
|
2519
|
+
}
|
|
2520
|
+
function bufferContractEvent(m){
|
|
2521
|
+
if(!Number.isSafeInteger(m.storeRevision)||m.storeRevision<0||typeof m.etag!=='string'){console.warn('steel-editor: ignored an unorderable contract event');return;}
|
|
2522
|
+
if(!contractEventWatermark||m.storeRevision>=contractEventWatermark.storeRevision)contractEventWatermark=m;
|
|
2523
|
+
}
|
|
2524
|
+
function drainContractEvents(epoch){if(epoch!==contractEventEpoch||!contractEventReady)return;const row=contractEventWatermark;contractEventWatermark=null;if(row)handleContractChanged(row);}
|
|
2525
|
+
async function rebootstrapContractEvents(epoch,attempt=0){
|
|
2526
|
+
if(epoch!==contractEventEpoch)return;contractEventReady=false;
|
|
2527
|
+
try{
|
|
2528
|
+
const res=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+'/snapshot'+CONTRACT_QS);
|
|
2529
|
+
if(epoch!==contractEventEpoch)return;
|
|
2530
|
+
if(!res.ok)throw new Error('snapshot HTTP '+res.status);
|
|
2531
|
+
const snap=await res.json();
|
|
2532
|
+
if(epoch!==contractEventEpoch)return;
|
|
2533
|
+
if(!snap||!Number.isSafeInteger(snap.storeRevision)||typeof snap.etag!=='string')throw new Error('snapshot payload was not an atomic contract triple');
|
|
2534
|
+
if(snap.storeRevision>serverRevision){
|
|
2535
|
+
if(window.invalidateMemberEndReview)window.invalidateMemberEndReview('The model changed — check member ends again.');
|
|
2536
|
+
if(editorHasUnsavedWork()){
|
|
2537
|
+
const parked=parkDraftForExternalChange();
|
|
2538
|
+
showAiUpdateBanner(parked?'A newer model is available. Your edits are still here. Resolve the model update, then check member ends again.':'Live updates reconnected, but this browser could not save your edits. Copy them out before reloading.',parked?undefined:{noReload:true});
|
|
2539
|
+
}else{location.reload();return;}
|
|
2540
|
+
}
|
|
2541
|
+
if(epoch!==contractEventEpoch)return;contractEventReady=true;drainContractEvents(epoch);
|
|
2542
|
+
}catch(e){
|
|
2543
|
+
if(epoch!==contractEventEpoch)return;
|
|
2544
|
+
contractEventReady=false;
|
|
2545
|
+
console.warn('steel-editor: reconnect snapshot failed',e&&e.message?e.message:e);
|
|
2546
|
+
const nextAttempt=attempt+1;
|
|
2547
|
+
if(nextAttempt<CONTRACT_EVENT_BOOTSTRAP_ATTEMPTS){
|
|
2548
|
+
const delay=CONTRACT_EVENT_BOOTSTRAP_RETRY_MS*Math.pow(2,attempt);
|
|
2549
|
+
setTimeout(()=>epoch===contractEventEpoch&&!contractEventReady?rebootstrapContractEvents(epoch,nextAttempt):undefined,delay);
|
|
2550
|
+
}else{
|
|
2551
|
+
showAiUpdateBanner('Live updates disconnected — reconnecting could not verify the latest model. Retrying on a fresh connection.');
|
|
2552
|
+
const failedSource=contractEventSource;
|
|
2553
|
+
if(failedSource){failedSource.onopen=null;failedSource.onmessage=null;failedSource.onerror=null;failedSource.close();}
|
|
2554
|
+
contractEventSource=null;startContractEvents();
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
function startContractEvents(){
|
|
2559
|
+
if(typeof EventSource==='undefined')return;
|
|
2560
|
+
try{
|
|
2561
|
+
const source=new EventSource('/api/events');contractEventSource=source;
|
|
2562
|
+
source.onopen=()=>{
|
|
2563
|
+
if(source!==contractEventSource)return;
|
|
2564
|
+
if(!contractBootSnapshotInstalled)return;
|
|
2565
|
+
contractEventEpoch++;contractEventReady=false;contractEventWatermark=null;rebootstrapContractEvents(contractEventEpoch);
|
|
2566
|
+
};
|
|
2567
|
+
source.onmessage=e=>{if(source!==contractEventSource)return;let m;try{m=JSON.parse(e.data);}catch{return;}if(!contractEventMatches(m))return;if(!contractEventReady)bufferContractEvent(m);else handleContractChanged(m);};
|
|
2568
|
+
source.onerror=()=>{if(source!==contractEventSource)return;contractEventReady=false;if(source.readyState===EventSource.CLOSED){ownWrites.length=0;console.warn('steel-editor: SSE channel closed — live updates paused');showAiUpdateBanner('Live updates disconnected — reload to resume change detection.');}};
|
|
2569
|
+
}catch(e){console.warn('steel-editor: could not open live updates',e&&e.message?e.message:e);}
|
|
2570
|
+
}
|
|
2469
2571
|
let conflicted = false;
|
|
2470
2572
|
// Serialize THIS tab's writes. Without it the editor conflicts with ITSELF: a slow autosave still in
|
|
2471
2573
|
// flight when the next one (or flushContract, which Approve awaits) fires means two requests carrying
|
|
@@ -2626,6 +2728,7 @@ function contractFailureState(status, code, serverError, projectScoped) {
|
|
|
2626
2728
|
async function boot() {
|
|
2627
2729
|
if (!APP_ID) { showEmpty('⊞', 'No workflow selected', 'Open a workflow in the FloLess canvas, then open the contract editor from that workflow’s node.'); return; }
|
|
2628
2730
|
armEarlyViewToggle(); // BEFORE the first await — that is the whole point; see above
|
|
2731
|
+
startContractEvents(); // subscribe first; contract events buffer until the atomic snapshot is installed
|
|
2629
2732
|
[SteelCore, ViewGen, ModelCmd, DetailRefs, V2Projection, V2Commands, V2Validation, SplitView, FilterCore, PlanXf, CatalogPicker] = await Promise.all([
|
|
2630
2733
|
import('./steel-3d-core.js'), import('./steel-view-generation.js'), import('./steel-model-commands.js'),
|
|
2631
2734
|
import('./steel-detail-refs.js'), import('./steel-model-v2-projection.js'),
|
|
@@ -2633,7 +2736,7 @@ async function boot() {
|
|
|
2633
2736
|
import('./steel-split-view.js'), import('./steel-filter-core.js'), import('./steel-plan-transform.js'),
|
|
2634
2737
|
import('./steel-catalog-picker.js'),
|
|
2635
2738
|
]);
|
|
2636
|
-
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + CONTRACT_QS);
|
|
2739
|
+
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + '/snapshot' + CONTRACT_QS);
|
|
2637
2740
|
// 204 = the project-scoped "nothing stored yet", the quiet twin of the generic 404 below. It carries
|
|
2638
2741
|
// no body and no code, so it routes straight to the same empty state rather than through the
|
|
2639
2742
|
// publication-code branches, which only an app-keyed read can produce.
|
|
@@ -2697,7 +2800,8 @@ async function boot() {
|
|
|
2697
2800
|
// Parse into a LOCAL first (unit 5, P1c-3). `C` is the global everything else in this page reads, so
|
|
2698
2801
|
// assigning before the type is validated would publish a document this editor cannot render — briefly
|
|
2699
2802
|
// live, and observable to anything that runs in between. Validate, then publish.
|
|
2700
|
-
const
|
|
2803
|
+
const snapshotPayload = await res.json();
|
|
2804
|
+
const loaded = snapshotPayload && snapshotPayload.contract;
|
|
2701
2805
|
// Shape first, then type. A body that is null, an array or a scalar has no `type` to test, so a
|
|
2702
2806
|
// type-only gate waved it through and the failure surfaced as a raw red `boot().catch` — "Cannot read
|
|
2703
2807
|
// properties of null (reading 'palette')" — instead of the styled state this item introduces. `plans`
|
|
@@ -2742,7 +2846,8 @@ async function boot() {
|
|
|
2742
2846
|
C = loaded;
|
|
2743
2847
|
// The server's tag for the contract we just read. Every write echoes it back, so a write that would
|
|
2744
2848
|
// land on top of someone else's is refused instead of silently winning.
|
|
2745
|
-
serverEtag = res.headers.get('ETag');
|
|
2849
|
+
serverEtag = snapshotPayload.etag || res.headers.get('ETag');
|
|
2850
|
+
serverRevision = Number.isSafeInteger(snapshotPayload.storeRevision) ? snapshotPayload.storeRevision : -1;
|
|
2746
2851
|
// The confidence target is a workflow INPUT (target_confidence), not contract data. Read its declared
|
|
2747
2852
|
// default only for an app-scoped editor: a project owns its contract independently of the installed
|
|
2748
2853
|
// workflow, so asking /api/app/<id> there can only add a normal 404 to the console. A project-specific
|
|
@@ -2789,109 +2894,9 @@ async function boot() {
|
|
|
2789
2894
|
// Reference models (#278) are always a model-level array in the native contract.
|
|
2790
2895
|
if(!Array.isArray(C.reference_models))C.reference_models=[];
|
|
2791
2896
|
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())
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
if (typeof EventSource !== 'undefined') {
|
|
2796
|
-
try {
|
|
2797
|
-
const es = new EventSource('/api/events');
|
|
2798
|
-
es.onmessage = (e) => {
|
|
2799
|
-
let m;
|
|
2800
|
-
try { m = JSON.parse(e.data); } catch { return; }
|
|
2801
|
-
if (!m || typeof m !== 'object') return;
|
|
2802
|
-
if (m.type !== 'contract-changed') return;
|
|
2803
|
-
if (m.appId !== APP_ID) return;
|
|
2804
|
-
// …and the same PROJECT. Two projects of one app share an appId, so without this a write to one
|
|
2805
|
-
// reloads the other's tab and (before the removal below was dropped) destroyed its draft — item
|
|
2806
|
-
// A's own bug class, left half-fixed: the key became project-scoped while the invalidation did
|
|
2807
|
-
// not. `|| ''` on both sides because an app-scoped write carries no `project` at all.
|
|
2808
|
-
if ((m.project || '') !== PROJECT) return;
|
|
2809
|
-
// OUR OWN echo, recognised by NAME rather than by clock (unit 5, P1c-3).
|
|
2810
|
-
const own = m.mutationId ? ownWrites.indexOf(m.mutationId) : -1;
|
|
2811
|
-
if (own >= 0) {
|
|
2812
|
-
// Everything OLDER than the match is superseded: SSE preserves order on a connection, so an
|
|
2813
|
-
// echo we have not seen by the time a later one arrives is never coming.
|
|
2814
|
-
const newest = own === ownWrites.length - 1;
|
|
2815
|
-
ownWrites.splice(0, own + 1);
|
|
2816
|
-
// Adopt the tag the server produced for our write — but ONLY from the newest echo. This is the
|
|
2817
|
-
// case the old clock could never cover (a PUT that succeeds while its response is lost leaves
|
|
2818
|
-
// `serverEtag` stale, so the tab's own next save is refused against its own change) — and
|
|
2819
|
-
// review found the mirror image: a LATE echo carries an OLDER tag, and adopting that rolls
|
|
2820
|
-
// `serverEtag` backwards, guaranteeing a 412 on the user's next write.
|
|
2821
|
-
if (newest && typeof m.etag === 'string' && m.etag) { const prev = serverEtag; serverEtag = m.etag; restampDraftBase(prev, m.etag); }
|
|
2822
|
-
return;
|
|
2823
|
-
}
|
|
2824
|
-
// An external write. The draft is deliberately NOT dropped here any more: with a server-issued
|
|
2825
|
-
// base recorded, a reload now compares bases and OFFERS a stale draft back instead of masking
|
|
2826
|
-
// the newer version with it — which is the only thing the removal was ever protecting against.
|
|
2827
|
-
// Removing it first was actively harmful, because it ran BEFORE the `hasUnsaved` check below:
|
|
2828
|
-
// in exactly the case where work was at risk, the durable copy was destroyed and only in-memory
|
|
2829
|
-
// `C` survived, so the banner's own Reload button lost it.
|
|
2830
|
-
// Auto-reload straight into the AI's version so the user never has to hit refresh — EXCEPT
|
|
2831
|
-
// when they have unsaved in-browser edits (saveStat 'dirty'/'err'), where a silent reload
|
|
2832
|
-
// would discard their work; there we fall back to the choose-to-reload banner.
|
|
2833
|
-
const sv = document.getElementById('saveStat');
|
|
2834
|
-
// 'conflict' counts as unsaved, and omitting it lost data: after a refused save the edits are
|
|
2835
|
-
// unsaved BY DEFINITION, so a silent reload here would drop the localStorage draft (above) and
|
|
2836
|
-
// discard exactly the work the conflict banner had just promised was "still here".
|
|
2837
|
-
// (Historically this also had to compensate for the 2.5 s echo suppressor, which stopped working
|
|
2838
|
-
// the moment the conflict latch tripped — persistServer returned before stamping its timestamp,
|
|
2839
|
-
// so the window expired and stayed expired. Identity has no such state, but this check is load
|
|
2840
|
-
// bearing on its own merits and stays.)
|
|
2841
|
-
const hasUnsaved = !!sv && (sv.classList.contains('dirty') || sv.classList.contains('err')
|
|
2842
|
-
|| sv.classList.contains('conflict'));
|
|
2843
|
-
if (hasUnsaved) {
|
|
2844
|
-
// GET THE EDIT ONTO DISK FIRST. 'dirty' also covers the 500 ms debounce window, where
|
|
2845
|
-
// `persist()` has not run yet and the edit lives only in `C` — so the Reload this banner is
|
|
2846
|
-
// about to offer would discard it, with no draft to park and nothing to offer back. That is
|
|
2847
|
-
// the same loss the stale-draft flow exists to prevent, arriving 500 ms earlier.
|
|
2848
|
-
//
|
|
2849
|
-
// The LOCAL half only. The server write stays on its debounce: the store has just moved, so a
|
|
2850
|
-
// PUT fired from here would be refused anyway, and racing one against the write we are
|
|
2851
|
-
// reacting to buys nothing. `persist()` is idempotent and does not disarm the timer, so the
|
|
2852
|
-
// pending tick rewriting the same row a moment later changes nothing.
|
|
2853
|
-
// The RESULT matters: quota exceeded, private mode, storage disabled by policy — persist()
|
|
2854
|
-
// swallows each into a red pill, and offering "↻ Reload" over an edit that reached no storage
|
|
2855
|
-
// is offering the very loss this flush exists to prevent, with a button on it.
|
|
2856
|
-
const parked = flushLocalDraft ? flushLocalDraft() : false;
|
|
2857
|
-
if (!parked) console.warn('steel-editor: the pending edit could not be written to this browser — a reload would lose it');
|
|
2858
|
-
// WHAT happened, not a guess at who. Absent or unrecognised → today's wording byte for byte.
|
|
2859
|
-
// The contract PUT — the one writer that usually IS the terminal AI — deliberately sends no
|
|
2860
|
-
// reason, so the generic sentence stays correct for it; and a tab left open across an
|
|
2861
|
-
// auto-update can outlive its server, so a token from a NEWER build has to degrade quietly
|
|
2862
|
-
// rather than reach the bar.
|
|
2863
|
-
//
|
|
2864
|
-
// Read INSIDE this branch on purpose. Computed above the `if`, a `CHANGE_LEAD` that ever
|
|
2865
|
-
// became unreachable (P3 is actively refactoring `main()`'s closure) would throw here — and
|
|
2866
|
-
// an exception at this point means the tab neither banners NOR reloads, silently going deaf
|
|
2867
|
-
// to external writes with the error swallowed by the event loop. The reload path must not be
|
|
2868
|
-
// able to fail for a reason that only the banner path cares about.
|
|
2869
|
-
const lead = (typeof m.reason === 'string' && CHANGE_LEAD[m.reason]) || 'The AI updated this model';
|
|
2870
|
-
showAiUpdateBanner(parked
|
|
2871
|
-
? lead + ' — reload to see it (you have unsaved edits).'
|
|
2872
|
-
// No Reload offered here, deliberately: with nothing in storage it is a button that destroys
|
|
2873
|
-
// their work, and there is no second copy to offer back afterwards.
|
|
2874
|
-
: lead + ' — but this browser could not save your unsaved edits, so reloading would lose them. Copy them out first.',
|
|
2875
|
-
parked ? undefined : { noReload: true });
|
|
2876
|
-
} else location.reload();
|
|
2877
|
-
};
|
|
2878
|
-
es.onerror = () => {
|
|
2879
|
-
// Transient drops (readyState CONNECTING) auto-reconnect — ignore. A CLOSED channel is
|
|
2880
|
-
// terminal: live writeback detection is dead, so surface it (the banner's Reload re-opens
|
|
2881
|
-
// the editor and its EventSource) instead of leaving the user on a silently-stale view.
|
|
2882
|
-
if (es.readyState === EventSource.CLOSED) {
|
|
2883
|
-
// Every id we are still holding is now DEAD: the channel that would have carried its echo is
|
|
2884
|
-
// gone, so none can ever be matched. Holding them serves nothing and is the only way the list
|
|
2885
|
-
// grows without bound — the one case review raised against retaining an id past its response.
|
|
2886
|
-
ownWrites.length = 0;
|
|
2887
|
-
console.warn('steel-editor: SSE channel closed — live updates paused');
|
|
2888
|
-
showAiUpdateBanner('Live updates disconnected — reload to resume change detection.');
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
} catch (_) {
|
|
2892
|
-
// If EventSource construction itself throws (unusual), the Reload button still works
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2897
|
+
contractBootSnapshotInstalled=true;
|
|
2898
|
+
contractEventReady=true;
|
|
2899
|
+
drainContractEvents(contractEventEpoch);
|
|
2895
2900
|
}
|
|
2896
2901
|
|
|
2897
2902
|
/**
|
|
@@ -3062,6 +3067,7 @@ const newModelId=()=>`m-v2-${Date.now().toString(36)}-${(v2IdSeq++).toString(36)
|
|
|
3062
3067
|
V2_SESSION=V2Commands.createV2CommandSession(C,{
|
|
3063
3068
|
validate:doc=>V2Validation.validateClientSteelModelV2(doc,V2_SCHEMA),
|
|
3064
3069
|
mintId:newModelId,
|
|
3070
|
+
resolveSection:m=>{const d=profileDimsIn(m&&m.profile);return d?{...d,units:'in'}:null;},
|
|
3065
3071
|
afterCommit:()=>{v2InvalidateMemberIndex();if(DEV_MODE&&V2_PROJECTION)P=ModelCmd.deepFreezeProjection(V2_PROJECTION.plan);}
|
|
3066
3072
|
});
|
|
3067
3073
|
let mode='sel', drag=null, picking=false, pickKind='profile', pickEnd=null, geoMode=null;
|
|
@@ -3069,7 +3075,7 @@ let dimMode=false, dimDraft=null, dimAxis='free', selDimIds=new Set(), dimsVisib
|
|
|
3069
3075
|
let qdAnchorPt=(()=>{try{const v=localStorage.getItem('steel:qdAnchor:v2');return (v==='a'||v==='b'||v==='mid')?v:'a';}catch(_){return 'a';}})(); // F7 quick-dim: which point on each beam to space between (start/mid/end), persisted
|
|
3070
3076
|
let dimEdit=null; // F8: the open double-click value editor {id,l,r,pin} or null (a modal popup)
|
|
3071
3077
|
let _lastDimDown=null; // F8: {id,t} of the last dim pointerdown, for manual double-click detection
|
|
3072
|
-
let drawDraft=null; // Add-member tool: the first CLICKED start point (or null) —
|
|
3078
|
+
let drawDraft=null,drawBasisTok=null; // Add-member tool: the first CLICKED start point + immutable authoring-basis snapshot (or null) — both picks must stay in one frame
|
|
3073
3079
|
let calloutsVisible=true; // Workstream B: show/hide the clickable callout bubbles (details + section/elevation/detail-ref) on the plan in select mode
|
|
3074
3080
|
let showSelLen=(()=>{try{return localStorage.getItem('steel:selLen:v2')==='1';}catch(_){return false;}})(); // ⋯ Display → Show member length: paint each selected member's length on the canvas (opt-in, default off)
|
|
3075
3081
|
let refSheetOn=(()=>{try{return localStorage.getItem('steel:refSheet:v2')!=='0';}catch(_){return true;}})(); // ⋯ Display → Reference sheet (F13): show/hide the traced PDF/SVG overlay under the model (default ON; only an explicit '0' hides it)
|
|
@@ -3095,6 +3101,85 @@ let selGridIds=new Set(); // selected grid-line ids — synthetic keys 'gv:i'/
|
|
|
3095
3101
|
let selIds=new Set();
|
|
3096
3102
|
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
|
|
3097
3103
|
let undo=[], redo=[];
|
|
3104
|
+
let memberEndReview=null;
|
|
3105
|
+
let memberEndScan=null;
|
|
3106
|
+
let memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};
|
|
3107
|
+
const memberEndKey=f=>f.memberId+'\0'+f.end;
|
|
3108
|
+
function memberEndHistoryAction(direction){return direction==='redo'?{label:'Redo',tip:'Redo the newest member-end resolution'}:{label:'Undo',tip:'Undo the newest member-end resolution'};}
|
|
3109
|
+
function memberEndScope(){const plan=C.plans&&C.plans[C.active];return view3d?{kind:'model-3d'}:{kind:'active-view',viewId:plan&&plan.sheet||''};}
|
|
3110
|
+
function memberEndScopeSig(scope){return JSON.stringify(scope||memberEndScope());}
|
|
3111
|
+
function memberEndUnresolved(report){const c=report&&report.counts||{};return (c.needsReview||0)+(c.stale||0)+(c.notCheckable||0);}
|
|
3112
|
+
function updateMemberEndStatus(){
|
|
3113
|
+
const stale=!memberEndStatus.known||memberEndStatus.etag!==serverEtag||memberEndStatus.revision!==serverRevision||memberEndStatus.scopeSig!==memberEndScopeSig();
|
|
3114
|
+
const n=stale?null:memberEndStatus.count,el=document.getElementById('endsStat'),v=document.getElementById('endsCount'),b=document.getElementById('memberEndsB');
|
|
3115
|
+
if(v)v.textContent=n==null?'—':String(n);if(el)el.classList.toggle('has',n>0);if(b)b.textContent=n==null?'Check member ends short of supports':'Member ends short of supports ('+n+')';
|
|
3116
|
+
}
|
|
3117
|
+
function invalidateMemberEndReview(message){memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};if(memberEndReview||memberEndScan){memberEndReview=null;memberEndScan=null;document.body.classList.remove('member-end-review');selIds.clear();render();}updateMemberEndStatus();if(message)toast(message);}
|
|
3118
|
+
window.invalidateMemberEndReview=invalidateMemberEndReview;
|
|
3119
|
+
function memberEndGroup(f){if(f.basis&&f.basis.kind==='drawing'){for(const p of C.plans||[])for(const o of p.memberObservations||[])if(f.basis.origins.some(x=>x.observationId===o.id))return p.sheet+(p.viewKind==='elevation'?' · elevation':'');}return f.basis&&f.basis.kind==='geometry-review'?'3D geometry review':'Model';}
|
|
3120
|
+
function memberEndRole(f){return f.role==='horizontal-brace'?'Horizontal brace':f.role==='vertical-brace'?'Vertical brace':f.role==='brace-unknown'?'Brace':'Beam';}
|
|
3121
|
+
function memberEndClassification(f){return ({'aligned-auto':'Aligned automatically','aligned-manual':'Aligned after review','kept-short':'Kept intentionally short','needs-review':'Needs review','stale':'Decision needs review','not-checkable':'Not checkable'})[f.classification]||f.classification;}
|
|
3122
|
+
function memberEndReason(f){const words={
|
|
3123
|
+
'cross-view-conflict':'Source views disagree','brace-type-unknown':'Brace type is not recorded','multiple-targets':'Two possible work points','near-coincident-supports':'Nearby supports do not share one exact work point','candidate-overflow':'Too many nearby supports to prove one target','gap-too-large':'Gap larger than expected','crossing-angle-too-small':'Crossing angle is too small','target-out-of-reach':'Support does not span the work point','unresolved-profile':'Support footprint could not be proved','unsupported-placement':'Support placement could not be proved','existing-endpoint':'Existing endpoint requires review','unobserved-endpoint':'No drawing endpoint evidence','view-unregistered':'This view is not registered for geometry','stale-context':'The model changed since this decision'};
|
|
3124
|
+
return (f.reasonCodes||[]).map(r=>words[r]||r).join(' · ');
|
|
3125
|
+
}
|
|
3126
|
+
function memberEndTargetName(t){return (t.memberIds||[]).join(' + ')+' centerline';}
|
|
3127
|
+
function memberEndTargetEqual(a,b){
|
|
3128
|
+
if(!a||!b||a.kind!==b.kind)return false;
|
|
3129
|
+
const ai=a.memberIds||[],bi=b.memberIds||[],ap=a.point||{},bp=b.point||{},az=ap.z||{},bz=bp.z||{};
|
|
3130
|
+
return ai.length===bi.length&&ai.every((id,i)=>id===bi[i])&&ap.x===bp.x&&ap.y===bp.y&&az.known===bz.known;
|
|
3131
|
+
}
|
|
3132
|
+
function memberEndCanKeepShort(f){
|
|
3133
|
+
if(!f||f.classification!=='needs-review'||!f.basis||f.basis.kind!=='drawing')return !!f&&f.classification==='needs-review';
|
|
3134
|
+
const origins=f.basis.origins||[],first=origins[0]&&origins[0].observedPoint;
|
|
3135
|
+
return !!first&&origins.every(o=>{const p=o&&o.observedPoint;return !!p&&p.x===first.x&&p.y===first.y&&p.z&&first.z&&p.z.known===first.z.known;});
|
|
3136
|
+
}
|
|
3137
|
+
function memberEndChoicesForReport(report,previous){
|
|
3138
|
+
const chosen=new Map();
|
|
3139
|
+
for(const f of report&&report.findings||[]){
|
|
3140
|
+
if(f.classification!=='needs-review')continue;
|
|
3141
|
+
const key=memberEndKey(f),targets=f.targets||[],prior=previous&&previous.get(key);
|
|
3142
|
+
const retained=prior&&targets.find(t=>memberEndTargetEqual(t,prior));
|
|
3143
|
+
if(retained)chosen.set(key,retained);else if(targets.length===1)chosen.set(key,targets[0]);
|
|
3144
|
+
}
|
|
3145
|
+
return chosen;
|
|
3146
|
+
}
|
|
3147
|
+
function memberEndDistance(f,t){const a=f.currentPoint,z=a&&a.z&&Number.isFinite(a.z.known)?a.z.known:t.point.z.known;return Math.hypot(t.point.x-a.x,t.point.y-a.y,t.point.z.known-z);}
|
|
3148
|
+
function memberEndSnapshot(doc){return {v2:true,members:doc.members,grid:doc.grid||null,plans:(doc.plans||[]).map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null,datum_ref:p.datum_ref,control2_ref:p.control2_ref})),joints:doc.joints||[],connections:doc.connections||[],details:doc.detail_placements||[],views:doc.views||[],member_types:doc.member_types||[],dim_style:doc.dim_style||null,member_styles:doc.member_styles||{},...(Array.isArray(doc.reference_models)?{reference_models:doc.reference_models}:{})};}
|
|
3149
|
+
function installMemberEndContract(doc,etag,revision){
|
|
3150
|
+
V2_SESSION.restoreSnapshot(memberEndSnapshot(doc));V2_PROJECTIONS.clear();
|
|
3151
|
+
const activePlan=C.plans&&C.plans[C.active];
|
|
3152
|
+
if(activePlan&&activePlan.viewKind==='plan'){NO_PLAN_VIEW=false;V2_PROJECTION=v2ProjectionForSheet(activePlan.sheet);P=DEV_MODE?ModelCmd.deepFreezeProjection(V2_PROJECTION.plan):V2_PROJECTION.plan;}
|
|
3153
|
+
else{V2_PROJECTION=null;NO_PLAN_VIEW=true;if(!activePlan)C.active=0;P=activePlan?{...structuredClone(activePlan),members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:Number.isFinite(activePlan.elevation_in)?activePlan.elevation_in:0}:{sheet:'',members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:0};resetPlanViewState(C.active);}
|
|
3154
|
+
// A server command replaces the model underneath the editor's local history. Retaining those snapshots
|
|
3155
|
+
// would let Ctrl+Z resurrect pre-command geometry without the server-owned decision/audit metadata.
|
|
3156
|
+
undo.length=0;redo.length=0;updUR();
|
|
3157
|
+
const prev=serverEtag;serverEtag=etag;serverRevision=revision;restampDraftBase(prev,etag);conflicted=false;render();sync3D();
|
|
3158
|
+
}
|
|
3159
|
+
async function memberEndRequest(path,body){
|
|
3160
|
+
if(!PROJECT)throw new Error('Member-end review is available inside a project.');
|
|
3161
|
+
const mutating=path!=='scan',mid=mutating?newMutationId():null,headers={'content-type':'application/json'};if(mutating){headers['x-floless-mutation-id']=mid;if(serverEtag)headers['if-match']=serverEtag;claimMutation(mid);}
|
|
3162
|
+
let res;try{res=await fetch('/api/projects/'+encodeURIComponent(PROJECT)+'/member-ends/'+path,{method:'POST',headers,body:JSON.stringify(body)});}catch(e){if(mid)releaseMutation(mid);throw e;}
|
|
3163
|
+
const d=await res.json().catch(()=>({}));if(!res.ok){if(mid)releaseMutation(mid);const error=new Error(d.error||('Member-end request failed ('+res.status+')'));error.code=d.code;error.status=res.status;throw error;}return d;
|
|
3164
|
+
}
|
|
3165
|
+
async function scanMemberEnds(liveMessage){
|
|
3166
|
+
closeMore();if((memberEndScan&&memberEndScan.busy)||(memberEndReview&&memberEndReview.busy))return;if(!PROJECT){toast('Open this model from a project to check member ends.');return;}
|
|
3167
|
+
memberEndScan={busy:true,error:false,live:'Checking member ends against drawing and model evidence…'};panel();
|
|
3168
|
+
const b=document.getElementById('memberEndsB');if(b)b.textContent='Checking member ends…';
|
|
3169
|
+
try{await window.flushContract();const scope=memberEndScope();const d=await memberEndRequest('scan',{scope});serverEtag=d.etag;serverRevision=d.storeRevision;memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(scope)};
|
|
3170
|
+
if(!d.report.findings.length){memberEndReview=null;memberEndScan={busy:false,error:false,live:'No member ends are short of support centerlines.'};document.body.classList.remove('member-end-review');updateMemberEndStatus();panel();const settled=memberEndScan;if(b){b.classList.add('ok');b.textContent='No short member ends ✓';}setTimeout(()=>{if(memberEndScan===settled){memberEndScan=null;panel();}if(b)b.classList.remove('ok');updateMemberEndStatus();},1500);return;}
|
|
3171
|
+
const chosen=memberEndChoicesForReport(d.report),selected=new Set();for(const f of d.report.findings)if(f.classification==='needs-review'&&f.targets&&f.targets.length===1&&!f.geometryOnly)selected.add(memberEndKey(f));
|
|
3172
|
+
memberEndScan=null;memberEndReview={report:d.report,scope,chosen,selected,focus:0,busy:false,undoToken:d.undo&&d.undo.token||null,undoDirection:d.undo&&d.undo.direction||null,live:typeof liveMessage==='string'?liveMessage:'Check each endpoint against its drawing or model evidence.'};document.body.classList.add('member-end-review');selIds.clear();focusMemberEnd(0);updateMemberEndStatus();
|
|
3173
|
+
}catch(e){memberEndReview=null;memberEndStatus={known:false,count:null,etag:null,revision:null,scopeSig:null};document.body.classList.remove('member-end-review');selIds.clear();memberEndScan={busy:false,error:true,live:e&&e.message?e.message:'Could not check member ends.'};updateMemberEndStatus();panel();toast(memberEndScan.live);}
|
|
3174
|
+
}
|
|
3175
|
+
function closeMemberEndReview(){if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before closing.';panel();return;}memberEndReview=null;document.body.classList.remove('member-end-review');selIds.clear();render();moreBtn.focus();}
|
|
3176
|
+
function focusMemberEnd(index){if(!memberEndReview||memberEndReview.busy)return;const rows=memberEndReview.report.findings;if(!rows.length)return;memberEndReview.focus=(index+rows.length)%rows.length;const f=rows[memberEndReview.focus];selIds=new Set([f.memberId]);render();queueMicrotask(()=>document.querySelector('.mer-row.focused input,.mer-row.focused button')?.focus({preventScroll:true}));}
|
|
3177
|
+
function chooseMemberEndTarget(key,index){if(!memberEndReview||memberEndReview.busy)return;const f=memberEndReview.report.findings.find(x=>memberEndKey(x)===key);const t=f&&f.targets&&f.targets[index];if(!f||!t)return;memberEndReview.chosen.set(key,t);memberEndReview.selected.add(key);memberEndReview.live='Selected '+memberEndTargetName(t)+' for '+f.memberId+' end '+(f.end+1)+'.';panel();render();}
|
|
3178
|
+
async function applyMemberEndSelection(){if(!memberEndReview||memberEndReview.busy)return;const selections=[];for(const f of memberEndReview.report.findings){const key=memberEndKey(f),target=memberEndReview.chosen.get(key);if(f.classification==='needs-review'&&memberEndReview.selected.has(key)&&target)selections.push({findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end,target});}if(!selections.length)return;
|
|
3179
|
+
const review=memberEndReview;review.busy=true;review.live='Extending selected member ends…';panel();try{const d=await memberEndRequest('apply',{scope:review.scope,selections});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();const previousChosen=review.chosen;review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.clear();review.chosen=memberEndChoicesForReport(d.report,previousChosen);review.busy=false;review.live='Extended '+selections.length+' member end'+(selections.length===1?'':'s')+' to support centerlines.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();undoToast(review.live,()=>undoMemberEndResolution());}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'The model changed — check member ends again.';panel();}toast(e.message||'Could not extend member ends.');}}
|
|
3180
|
+
async function keepMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('keep-short',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end,reason:'other-reviewed'});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.selected.delete(memberEndKey(f));review.busy=false;review.live='Kept '+f.memberId+' end '+(f.end+1)+' short.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not keep this member end short.';panel();}}}
|
|
3181
|
+
async function restoreMemberEnd(f){if(!memberEndReview||memberEndReview.busy)return;const review=memberEndReview;review.busy=true;panel();try{const d=await memberEndRequest('restore',{scope:review.scope,findingId:f.findingId,contextHash:f.contextHash,memberId:f.memberId,end:f.end});installMemberEndContract(d.contract,d.etag,d.storeRevision);if(memberEndReview!==review)return scanMemberEnds();review.report=d.report;review.undoToken=d.undoToken;review.undoDirection='undo';review.busy=false;review.live='Restored the traced endpoint for '+f.memberId+'.';memberEndStatus={known:true,count:memberEndUnresolved(d.report),etag:d.etag,revision:d.storeRevision,scopeSig:memberEndScopeSig(review.scope)};updateMemberEndStatus();panel();}catch(e){if(memberEndReview===review){review.busy=false;review.live=e.message||'Could not restore the traced endpoint.';panel();}}}
|
|
3182
|
+
async function undoMemberEndResolution(){if(!memberEndReview||memberEndReview.busy||!memberEndReview.undoToken)return;const review=memberEndReview,token=review.undoToken;review.busy=true;review.live='Updating member-end history…';panel();try{const d=await memberEndRequest('undo',{token});installMemberEndContract(d.contract,d.etag,d.storeRevision);const next=memberEndHistoryAction(d.direction),completed=d.direction==='redo'?'Undid member-end changes':'Redid member-end changes';review.busy=false;await scanMemberEnds(completed+' · '+next.label+' is available');}catch(e){if(memberEndReview===review){review.busy=false;if(e.code==='member-end-undo-unavailable'){review.undoToken=null;review.undoDirection=null;review.live='This history action is no longer available. Check member ends again.';}else review.live='Could not confirm the history action. Check member ends again before retrying.';panel();}toast(e.message||'Could not update member-end history.');}}
|
|
3098
3183
|
// Selection is MODEL-WIDE, not per-sheet: the 3D shows every plan, so a pick / box-select / Ctrl-click can
|
|
3099
3184
|
// span sheets. byId + selArr therefore search ALL plans (not just the active P) so the inspector + edits see
|
|
3100
3185
|
// the whole selection — else selecting a roof (S-203) member while S-202 is active shows nothing, and a
|
|
@@ -3148,18 +3233,15 @@ function ensureMeta(m){return ModelCmd.ensureMeta(m);} // unit 5 P3a: the mode
|
|
|
3148
3233
|
// MIRROR of server/contract-to-scene.ts depthPosition (same 0.5774 ≈ 30° threshold, mm units) — the
|
|
3149
3234
|
// inspector must highlight the SAME default the bake uses, or the 3D differs from what the panel says.
|
|
3150
3235
|
function posDefault(m){
|
|
3151
|
-
if(m.position==='top'||m.position==='middle'||m.position==='bottom')return m.position;
|
|
3152
|
-
if(m.role==='column')return 'middle';
|
|
3153
|
-
if(isBrace(m)&&m.brace&&m.brace.type==='vertical')return 'middle';
|
|
3154
3236
|
const k=304.8/((P&&P.pt_per_ft>0)?P.pt_per_ft:1);
|
|
3155
3237
|
const z0=(m.ends&&m.ends[0]&&m.ends[0].tos!=null)?m.ends[0].tos:defaultTOS;
|
|
3156
3238
|
const z1=(m.ends&&m.ends[1]&&m.ends[1].tos!=null)?m.ends[1].tos:defaultTOS;
|
|
3157
3239
|
const dz=Math.abs((z0||0)-(z1||0))*25.4, horiz=Math.hypot(m.wp[1][0]-m.wp[0][0],m.wp[1][1]-m.wp[0][1])*k;
|
|
3158
|
-
return
|
|
3240
|
+
return SteelCore.effectiveDepthPosition(m.position,m.role==='column'?'column':'beam',dz,horiz,isBrace(m)&&m.brace&&m.brace.type==='vertical');}
|
|
3159
3241
|
// Effective HORIZONTAL profile position — where the work-line sits ACROSS the section. No heuristic:
|
|
3160
3242
|
// absent = centred, which is what every member did before the field existed. MIRROR of
|
|
3161
3243
|
// server/contract-to-scene.ts planePosition().
|
|
3162
|
-
function posHDefault(m){return (m.positionH
|
|
3244
|
+
function posHDefault(m){return SteelCore.effectiveWidthPosition(m.positionH);}
|
|
3163
3245
|
// Can this member take a Profile Position at all? It needs ONE thing: a section with faces to name. A
|
|
3164
3246
|
// resolved designation supplies that through profileDimsIn; a CUSTOM/imported section supplies w+d.
|
|
3165
3247
|
//
|
|
@@ -3269,6 +3351,52 @@ function posSectionSvg(m){
|
|
|
3269
3351
|
// on every untouched member would be noise on twelve sections' worth of rail.
|
|
3270
3352
|
const posOffDisp=v=>(typeof v==='number'&&isFinite(v)&&v!==0)?fmtFtIn(v/25.4):'';
|
|
3271
3353
|
const posOffSet=v=>typeof v==='number'&&isFinite(v)&&v!==0;
|
|
3354
|
+
let positionBasisGeneration=0,positionBasisFingerprint='',positionBasisListeners=new Set();
|
|
3355
|
+
let positionBasisViewUnsub=null;
|
|
3356
|
+
function positionAuthoringBasis(){
|
|
3357
|
+
let raw;
|
|
3358
|
+
if(view3d&&window.Steel3DView&&window.Steel3DView.positionAuthoringBasis){raw=window.Steel3DView.positionAuthoringBasis();}
|
|
3359
|
+
else if(!(P&&P.frame))raw={ok:true,kind:'global',x:[1,0,0],y:[0,1,0]};
|
|
3360
|
+
else{
|
|
3361
|
+
try{
|
|
3362
|
+
const plan={...P,modelGrid:C&&C.grid,grid:C&&C.grid},o=P.frame.o,u=P.frame.u,v=[u[1],-u[0]];
|
|
3363
|
+
const a=PlanXf.sheetPxToWorld(o,plan,{known:0}),bx=PlanXf.sheetPxToWorld([o[0]+u[0],o[1]+u[1]],plan,{known:0}),by=PlanXf.sheetPxToWorld([o[0]+v[0],o[1]+v[1]],plan,{known:0});
|
|
3364
|
+
const c=SteelCore.canonicalPositionBasis([bx.x-a.x,bx.y-a.y,0],[by.x-a.x,by.y-a.y,0]);
|
|
3365
|
+
raw=c?{ok:true,kind:'local',x:[...c.x],y:[...c.y]}:{ok:false,code:'position-authoring-basis-unavailable',message:'Profile Position unavailable: this plan’s local axes are not fully registered.'};
|
|
3366
|
+
}catch(_){raw={ok:false,code:'position-authoring-basis-unavailable',message:'Profile Position unavailable: this plan’s local axes are not fully registered.'};}
|
|
3367
|
+
}
|
|
3368
|
+
const fingerprint=JSON.stringify([view3d?'3d':'2d',P&&P.sheet,raw.ok,raw.kind,raw.x,raw.y,raw.code]);
|
|
3369
|
+
if(fingerprint!==positionBasisFingerprint){positionBasisFingerprint=fingerprint;positionBasisGeneration++;for(const fn of positionBasisListeners)try{fn();}catch(_){}}
|
|
3370
|
+
return Object.freeze({...raw,generation:positionBasisGeneration,capabilityVersion:SteelCore.POSITION_BASIS_CAPABILITY_VERSION,x:raw.x?Object.freeze([...raw.x]):undefined,y:raw.y?Object.freeze([...raw.y]):undefined});
|
|
3371
|
+
}
|
|
3372
|
+
function onPositionAuthoringBasisChange(listener){positionBasisListeners.add(listener);return()=>positionBasisListeners.delete(listener);}
|
|
3373
|
+
function positionFrameLabel(s){return !s.ok?'Unavailable':s.kind==='global'?'Global':(s.kind==='plane'?'Work plane X/Y':(view3d?'3D local X′/Y′':'2D local X′/Y′'));}
|
|
3374
|
+
function positionFrameHTML(){const s=positionAuthoringBasis();return `<div id=posFrame data-position-basis-capability="${SteelCore.POSITION_BASIS_CAPABILITY_VERSION}" class=hint style="margin:0 0 6px;color:${s.ok&&s.kind!=='global'?'var(--cyan)':'var(--mut)'}">Edit frame · <b>${esc(positionFrameLabel(s))}</b></div><div id=posPositionStatus class=hint role=status aria-live=polite aria-atomic=true style="margin:0 0 6px${s.ok?';display:none':';border:1px solid var(--line);border-radius:6px;padding:7px 8px'}">${s.ok?'':esc(s.message)}</div>`;}
|
|
3375
|
+
const POSITION_CONTROL_IDS=['posOff','posHOff','detRotZ','posTop','posMid','posBot','posHLeft','posHMid','posHRight','rot0','rot90','rot180','rot270'];
|
|
3376
|
+
function wirePositionAvailability(){const s=positionAuthoringBasis();for(const id of POSITION_CONTROL_IDS){const el=document.getElementById(id);if(!el)continue;el.setAttribute('aria-describedby','posFrame posPositionStatus');el.disabled=!s.ok;if(!s.ok)el.dataset.blockedReason=s.message;else delete el.dataset.blockedReason;}return s;}
|
|
3377
|
+
function refreshPositionFrameUI(){const s=positionAuthoringBasis(),frame=document.getElementById('posFrame'),status=document.getElementById('posPositionStatus');if(frame){frame.style.color=s.ok&&s.kind!=='global'?'var(--cyan)':'var(--mut)';const b=frame.querySelector&&frame.querySelector('b');if(b)b.textContent=positionFrameLabel(s);}if(status){status.textContent=s.ok?'':s.message;status.style.display=s.ok?'none':'block';}wirePositionAvailability();}
|
|
3378
|
+
onPositionAuthoringBasisChange(refreshPositionFrameUI);
|
|
3379
|
+
function positionRefuse(message,source){const el=document.getElementById('posPositionStatus');if(el){el.style.display='block';el.style.border='1px solid var(--line)';el.style.borderRadius='6px';el.style.padding='7px 8px';el.textContent=message;}toast(message,false,5200);if(source&&source.focus)source.focus();return false;}
|
|
3380
|
+
function positionRebaseInput(m){const c=v2CanonicalMember(m.id),z0=c&&SteelCore.knownZ(c.from&&c.from.z),z1=c&&SteelCore.knownZ(c.to&&c.to.z);if(!c||z0==null||z1==null)return null;
|
|
3381
|
+
const dims=profileDimsIn(c.profile),sec=dims?{w:dims.w*25.4,d:dims.d*25.4,round:!!dims.round}:((c.section&&c.section.w>0&&c.section.d>0)?{w:c.section.w,d:c.section.d,round:false}:null);
|
|
3382
|
+
const extents=sec?SteelCore.sectionExtents(SteelCore.outlineFor(c.profile,sec.w,sec.d,null,sec.round)):null;
|
|
3383
|
+
return {canonical:c,from:[c.from.x,c.from.y,z0],to:[c.to.x,c.to.y,z1],extents};}
|
|
3384
|
+
function positionBasisMatches(member,target){if(target.kind==='global')return !member.positionBasis;if(!member.positionBasis)return false;const c=SteelCore.canonicalPositionBasis(target.x,target.y);return !!c&&JSON.stringify(member.positionBasis)===JSON.stringify({x:[...c.x],y:[...c.y]});}
|
|
3385
|
+
function applyPositionAuthoringBasis(member,target){
|
|
3386
|
+
if(!target||!target.ok)return false;
|
|
3387
|
+
if(target.kind==='global'){delete member.positionBasis;return true;}
|
|
3388
|
+
const c=SteelCore.canonicalPositionBasis(target.x,target.y);if(!c)return false;
|
|
3389
|
+
member.positionBasis={x:[...c.x],y:[...c.y]};return true;
|
|
3390
|
+
}
|
|
3391
|
+
function commitPositionEdit(members,userPatch,source){const captured=positionAuthoringBasis();if(!captured.ok)return positionRefuse(captured.message,source);const prepared=[],blockers=[];
|
|
3392
|
+
for(const m of members){const input=positionRebaseInput(m);if(!input){blockers.push(m.id+' has incomplete work points');continue;}
|
|
3393
|
+
let patch={};if(!positionBasisMatches(input.canonical,captured)){const r=SteelCore.reexpressMemberPlacement(input.canonical,input.from,input.to,captured,input.extents);if(!r.ok){const msg=r.code==='position-rebase-section-unresolved'
|
|
3394
|
+
?m.id+' cannot be re-expressed because '+(m.profile||'its profile')+' has no resolved section'
|
|
3395
|
+
:m.id+' could not be re-expressed safely';blockers.push(msg);continue;}patch=r.patch;}
|
|
3396
|
+
prepared.push({m,patch:Object.assign({},patch,userPatch)});}
|
|
3397
|
+
if(blockers.length)return positionRefuse('No changes made — '+blockers.join('; ')+'. Resolve every blocker, or set Depth and Width to Middle in each stored frame first.',source);
|
|
3398
|
+
const current=positionAuthoringBasis();if(current.generation!==captured.generation)return positionRefuse('Frame changed — review the refreshed Profile Position and try again.',source);
|
|
3399
|
+
edit(()=>{for(const row of prepared)ModelCmd.patchMember(row.m,row.patch);});return true;}
|
|
3272
3400
|
/*
|
|
3273
3401
|
* ONE row of the Profile Position section: heading + offset box on the first line, named faces on the
|
|
3274
3402
|
* second. The mockup drew all three on one line; at 280 px — ~246 px of content once the rail's padding and
|
|
@@ -3283,7 +3411,7 @@ const posOffSet=v=>typeof v==='number'&&isFinite(v)&&v!==0;
|
|
|
3283
3411
|
const posRow=(label,offId,offLabel,offVal,offTip,buttons,ph)=>
|
|
3284
3412
|
`<div class=elabrow><span class=elab>${label}</span><label class="detf posoff"><span>${offLabel}</span>`
|
|
3285
3413
|
+`<input data-command-id="steel.position-offset#${esc(label.toLowerCase()+' axis')}" aria-label="${esc(label+' '+offLabel)}" id=${offId} class="${posOffSet(offVal)?'set':''}" inputmode=decimal value="${esc(posOffDisp(offVal))}" placeholder="${ph||'0"'}" data-tip="${offTip}" autocomplete=off></label></div>`
|
|
3286
|
-
+`<div class=seg2 style="margin-top:2px">${buttons}</div>`;
|
|
3414
|
+
+`<div class=seg2 role=group aria-label="${esc(label+' position')}" style="margin-top:2px">${buttons}</div>`;
|
|
3287
3415
|
/*
|
|
3288
3416
|
* A THIRD blank-commit behaviour, and it is not either of the two this file already has.
|
|
3289
3417
|
*
|
|
@@ -3296,16 +3424,16 @@ const posRow=(label,offId,offLabel,offVal,offTip,buttons,ph)=>
|
|
|
3296
3424
|
* than the neighbouring `defTos`/`mTos` handlers, which pass a possibly-null `parseLen` straight through —
|
|
3297
3425
|
* deliberately, and noted here so it is not "fixed" back down to match them. (ui-ux review.)
|
|
3298
3426
|
*/
|
|
3299
|
-
function posSetOff(m,key,raw){
|
|
3427
|
+
function posSetOff(m,key,raw,source){
|
|
3300
3428
|
const t=String(raw==null?'':raw).trim();
|
|
3301
|
-
if(t===''){
|
|
3429
|
+
if(t===''){commitPositionEdit([m],{[key]:undefined},source);return;}
|
|
3302
3430
|
const inch=parseLen(t);
|
|
3303
3431
|
// Reverting is right — a length we cannot read must never become 0, which would MOVE the steel. But the
|
|
3304
3432
|
// revert has to be announced: this panel toasts for everything else, so a field that silently blanks
|
|
3305
3433
|
// reads as "accepted, displayed oddly". `3-1/2"` is standard detailer shorthand AND the shape fmtFtIn
|
|
3306
3434
|
// itself emits, so it is typed often and rejected every time.
|
|
3307
3435
|
if(inch==null||!isFinite(inch)){toast(`Couldn’t read “${t}” as a length — try 3 1/2" or 1'-3 1/2".`);render();return;}
|
|
3308
|
-
|
|
3436
|
+
commitPositionEdit([m],{[key]:inch*25.4},source);}
|
|
3309
3437
|
// A member's UNIT direction in world mm, off the canonical model — or null when it has none (an unknown
|
|
3310
3438
|
// elevation, a zero-length line, or no canonical member at all). The one thing §1.10 needs in order to ask
|
|
3311
3439
|
// "did this member's axis actually reverse?", which is a question about the STORED geometry rather than
|
|
@@ -3363,11 +3491,12 @@ function swapMemberEnds(m){
|
|
|
3363
3491
|
// the plan points through sheet pixels and comes back a few nanometres out.
|
|
3364
3492
|
const reversed=!!(preAxis&&post&&Math.hypot(preAxis[0]+post[0],preAxis[1]+post[1],preAxis[2]+post[2])<1e-6);
|
|
3365
3493
|
const g=reversed?SteelCore.memberGeometryV2(v2CanonicalMember(m.id)):null;
|
|
3366
|
-
const
|
|
3494
|
+
const pb=m.positionBasis&&SteelCore.basisFromAxes(m.positionBasis.x,m.positionBasis.y);
|
|
3495
|
+
const fr=g&&SteelCore.partFrame(g.line[0],g.line[1],pb?pb.z:undefined,pb?pb.x:undefined);
|
|
3367
3496
|
// No canonical geometry (an unknown elevation) or no frame (zero length) ⇒ no placement change. Inventing
|
|
3368
3497
|
// a branch here would write a transform the bake will not honour, which is worse than leaving it alone.
|
|
3369
3498
|
if(fr){
|
|
3370
|
-
const cur={position:m.position,positionOffset:m.positionOffset,positionH:m.positionH,positionHOffset:m.positionHOffset,rot:m.rot};
|
|
3499
|
+
const cur={position:m.position,positionOffset:m.positionOffset,positionH:m.positionH,positionHOffset:m.positionHOffset,positionBasis:m.positionBasis,rot:m.rot};
|
|
3371
3500
|
const next=SteelCore.reversePlacement(cur,fr.degenerate);
|
|
3372
3501
|
const patch={};for(const k of Object.keys(next))if(!Object.is(next[k],cur[k]))patch[k]=next[k];
|
|
3373
3502
|
if(Object.keys(patch).length)ModelCmd.patchMember(m,patch);
|
|
@@ -3623,7 +3752,7 @@ function apply(json){
|
|
|
3623
3752
|
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
|
|
3624
3753
|
if(selGridIds.size)selGridIds.clear(); // grid ids are index-based synthetics — an undo can reshuffle the grid, so just drop the transient grid selection
|
|
3625
3754
|
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)
|
|
3626
|
-
|
|
3755
|
+
drawDraft=null;drawBasisTok=null;drawPrevClear(); // …likewise abandon an in-progress Add-member start point + its frame snapshot
|
|
3627
3756
|
cmDraft=null;cmPrevClear();cmHudClose(); // same for an in-progress Move/Copy pick — the base may reference removed geometry
|
|
3628
3757
|
if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // and the 3D-side draft/ghosts
|
|
3629
3758
|
if(window.Steel3DView&&window.Steel3DView.setClipState&&'clips' in d)window.Steel3DView.setClipState(d.clips); // restore clips + work area alongside the contract
|
|
@@ -3664,7 +3793,7 @@ function edit(fn){
|
|
|
3664
3793
|
try{fn();}
|
|
3665
3794
|
catch(err){
|
|
3666
3795
|
if(err&&err.name==='V2CommandError'){
|
|
3667
|
-
|
|
3796
|
+
drawDraft=null;drawBasisTok=null;dimDraft=null;cmDraft=null;drawPrevClear();dimPrevClear();cmPrevClear();
|
|
3668
3797
|
const text=err.code==='elevation-unknown'
|
|
3669
3798
|
?`Couldn’t complete that edit: the elevation is unknown. Enter the TOS first.`
|
|
3670
3799
|
:(err.message||'That edit could not be applied safely.');
|
|
@@ -3874,13 +4003,13 @@ async function persistServer(force){const seq=saveSeq;
|
|
|
3874
4003
|
// write is usually still in flight — the server broadcasts before it replies — so releasing here would
|
|
3875
4004
|
// make the tab read its OWN echo as external and reload itself mid-edit. The id is released when the
|
|
3876
4005
|
// echo consumes it, when the write fails, or when the SSE channel closes (nothing can echo after that).
|
|
3877
|
-
if(res.ok){const t=res.headers.get('ETag');if(t){const pv=serverEtag;serverEtag=t;restampDraftBase(pv,t);}conflicted=false;} // chain the next edit off the new tag, and
|
|
4006
|
+
if(res.ok){const d=await res.json().catch(()=>({})),t=d.etag||res.headers.get('ETag');if(d.contract&&t&&Number.isSafeInteger(d.storeRevision))installMemberEndContract(d.contract,t,d.storeRevision);else{if(t){const pv=serverEtag;serverEtag=t;restampDraftBase(pv,t);}if(Number.isSafeInteger(d.storeRevision))serverRevision=Math.max(serverRevision,d.storeRevision);}conflicted=false;} // chain the next edit off the new tag, and install any server-staled endpoint authority instead of leaving the browser on bytes the server deliberately transformed
|
|
3878
4007
|
else releaseMutation(mid); // 400/500: nothing was written, so nothing will echo
|
|
3879
4008
|
if(seq===saveSeq)setSaved(res.ok?'ok':'err'); // only the latest save owns the pill (a stale late response must not clobber a newer verdict)
|
|
3880
4009
|
if(!res.ok)console.error('server save rejected ('+res.status+')',await res.text().catch(()=>'')); // 400 = schema reject: edits won't be what Approve bakes
|
|
3881
4010
|
}catch(e){releaseMutation(mid);if(seq===saveSeq)setSaved('err');console.error('server save failed',e);}
|
|
3882
4011
|
});}
|
|
3883
|
-
function scheduleSave(){setSaved('dirty');++saveSeq;clearTimeout(saveT);saveT=setTimeout(()=>{saveT=null;persist();persistServer();},500);} // clear the handle as it fires: `saveT !== null` is read as "a write is still pending" (the project send refuses on it), and a spent timer id would read as pending forever // ++saveSeq: a fresh edit is a new save intent — it invalidates any still-in-flight PUT so that PUT's late response can't flip the pill to a stale 'Saved ✓' while this edit is still unsaved (persistServer below captures this same intent id)
|
|
4012
|
+
function scheduleSave(){if(memberEndStatus.known||memberEndReview)invalidateMemberEndReview();setSaved('dirty');++saveSeq;clearTimeout(saveT);saveT=setTimeout(()=>{saveT=null;persist();persistServer();},500);} // clear the handle as it fires: `saveT !== null` is read as "a write is still pending" (the project send refuses on it), and a spent timer id would read as pending forever // ++saveSeq: a fresh edit is a new save intent — it invalidates any still-in-flight PUT so that PUT's late response can't flip the pill to a stale 'Saved ✓' while this edit is still unsaved (persistServer below captures this same intent id)
|
|
3884
4013
|
// The boot-scope SSE handler's seam into that debounce — see `flushLocalDraft` for why the handler
|
|
3885
4014
|
// cannot reach `persist()` itself.
|
|
3886
4015
|
//
|
|
@@ -3937,7 +4066,7 @@ window.flushContract = async () => {
|
|
|
3937
4066
|
showConflictBanner();
|
|
3938
4067
|
throw new Error('save conflict');
|
|
3939
4068
|
}
|
|
3940
|
-
if (res.ok) { const t = res.headers.get('ETag'); if (t) { const pv = serverEtag; serverEtag = t; restampDraftBase(pv, t); } conflicted = false; }
|
|
4069
|
+
if (res.ok) { const d = await res.json().catch(() => ({})); const t = d.etag || res.headers.get('ETag'); if (d.contract && t && Number.isSafeInteger(d.storeRevision)) installMemberEndContract(d.contract, t, d.storeRevision); else { if (t) { const pv = serverEtag; serverEtag = t; restampDraftBase(pv, t); } if (Number.isSafeInteger(d.storeRevision)) serverRevision = Math.max(serverRevision, d.storeRevision); } conflicted = false; }
|
|
3941
4070
|
else releaseMutation(mid);
|
|
3942
4071
|
if (seq === saveSeq) setSaved(res.ok ? 'ok' : 'err'); // only the latest save owns the pill
|
|
3943
4072
|
if (!res.ok) throw new Error('save failed (' + res.status + ')');
|
|
@@ -4454,6 +4583,14 @@ function planRegistration(){
|
|
|
4454
4583
|
}
|
|
4455
4584
|
_planXfCache={key,xf};return xf;
|
|
4456
4585
|
}
|
|
4586
|
+
function positionEffectiveWorldRot(m){
|
|
4587
|
+
if(!m||!m.positionBasis)return +m.rot||0;
|
|
4588
|
+
const basis=SteelCore.basisFromAxes(m.positionBasis.x,m.positionBasis.y),g=SteelCore.memberGeometryV2(v2CanonicalMember(m.id));
|
|
4589
|
+
if(!basis||!g)return null;
|
|
4590
|
+
const a=SteelCore.partFrame(g.line[0],g.line[1],basis.z,basis.x),global=SteelCore.partFrame(g.line[0],g.line[1]);if(!a||!global)return null;
|
|
4591
|
+
const th=(+m.rot||0)*Math.PI/180,c=Math.cos(th),s=Math.sin(th),w=[c*a.y[0]+s*a.z[0],c*a.y[1]+s*a.z[1],c*a.y[2]+s*a.z[2]];
|
|
4592
|
+
return Math.atan2(w[0]*global.z[0]+w[1]*global.z[1]+w[2]*global.z[2],w[0]*global.y[0]+w[1]*global.y[1]+w[2]*global.y[2])*180/Math.PI;
|
|
4593
|
+
}
|
|
4457
4594
|
function columnSectionPoly(m){
|
|
4458
4595
|
const wp=m&&m.wp;if(!wp||!wp.length)return null;
|
|
4459
4596
|
const a=wp[0],b=wp[wp.length-1],cx=(a[0]+b[0])/2,cy=(a[1]+b[1])/2;
|
|
@@ -4480,7 +4617,7 @@ function columnSectionPoly(m){
|
|
|
4480
4617
|
// The roll goes through SteelCore, which owns the world→sheet-px placement (the Y flip and the sheet's
|
|
4481
4618
|
// registration angle). Applied raw here, as it was, the plan drew every section as the MIRROR of the
|
|
4482
4619
|
// 3D solid and the export — see sectionOutlinePx for the measurement and the algebra.
|
|
4483
|
-
const xf=planRegistration(),rotN
|
|
4620
|
+
const xf=planRegistration(),rotN=positionEffectiveWorldRot(m),wPx=sec.w/12*ppf,dPx=sec.d/12*ppf;if(rotN==null)return null;
|
|
4484
4621
|
const localComponents=sectionShapeComponents(m.profile,wPx,dPx,ppf,dims&&dims.round);
|
|
4485
4622
|
// A column now takes a Profile Position like every other member, so the FOOTPRINT has to move with it —
|
|
4486
4623
|
// otherwise the plan draws the section centred on a work point the 3D and the export put it off.
|
|
@@ -5593,6 +5730,7 @@ function stepSlotText(commandId){
|
|
|
5593
5730
|
}
|
|
5594
5731
|
}catch(e){/* cross-origin or torn-down parent */}
|
|
5595
5732
|
try{window.__instructor.dispose();}catch(e){}
|
|
5733
|
+
try{if(positionBasisViewUnsub)positionBasisViewUnsub();positionBasisViewUnsub=null;positionBasisListeners.clear();}catch(e){}
|
|
5596
5734
|
});
|
|
5597
5735
|
publishSoon(); // first report, so the shell is not blank until the first click
|
|
5598
5736
|
|
|
@@ -5726,6 +5864,19 @@ function doDup(){const arr=sel2d();if(!arr.length)return;const o=12,pv=snapshot(
|
|
|
5726
5864
|
mc.addMembers(P,[c]);ns.add(c.id);}
|
|
5727
5865
|
selIds=ns;selDimIds.clear();mode='sel';setMode();pushUndo(pv);render();}
|
|
5728
5866
|
function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'<','>':'>','&':'&','"':'"'}[c]));}
|
|
5867
|
+
function memberEndReviewSvg(){
|
|
5868
|
+
if(!memberEndReview||NO_PLAN_VIEW||!P||!P.members)return '';
|
|
5869
|
+
const f=memberEndReview.report.findings[memberEndReview.focus];if(!f)return '';
|
|
5870
|
+
const subject=P.members.find(m=>m.id===f.memberId);if(!subject)return '';
|
|
5871
|
+
const start=subject.wp&&subject.wp[f.end];if(!start)return '';
|
|
5872
|
+
const targets=f.classification==='needs-review'?(f.targets||[]):((f.classification==='aligned-auto'||f.classification==='aligned-manual')?[f.target]:[]);if(!targets.length)return '';
|
|
5873
|
+
const plan=C.plans&&C.plans[C.active],projected=[];for(const t of targets){try{projected.push(PlanXf.worldToSheetPx(t.point,{...plan,modelGrid:C.grid}));}catch(_){return '';}}
|
|
5874
|
+
let out='<g class=mer-overlay aria-hidden=true>';for(const id of new Set(targets.flatMap(t=>t.memberIds||[]))){const m=P.members.find(x=>x.id===id);if(m&&m.wp)out+=`<line class=mer-target-line x1="${m.wp[0][0]}" y1="${m.wp[0][1]}" x2="${m.wp[1][0]}" y2="${m.wp[1][1]}"/>`;}
|
|
5875
|
+
const r=7/zoom,chosen=memberEndReview.chosen.get(memberEndKey(f)),chosenIndex=chosen?targets.findIndex(t=>memberEndTargetEqual(t,chosen)):0;out+=`<polygon class=mer-end-marker points="${start[0]},${start[1]-r} ${start[0]+r},${start[1]} ${start[0]},${start[1]+r} ${start[0]-r},${start[1]}"/>`;
|
|
5876
|
+
projected.forEach((pt,i)=>{out+=`<line class=mer-extension x1="${start[0]}" y1="${start[1]}" x2="${pt[0]}" y2="${pt[1]}"/><rect class="mer-target-marker${i===chosenIndex?' selected':''}" data-mer-canvas-target="${i}" x="${pt[0]-r}" y="${pt[1]-r}" width="${2*r}" height="${2*r}"/><text class=mer-label x="${pt[0]+10/zoom}" y="${pt[1]-8/zoom}" style="font-size:${11/zoom}px">${String.fromCharCode(65+i)}</text>`;});
|
|
5877
|
+
const pt=projected[Math.max(0,chosenIndex)];if(pt)out+=`<text class=mer-label x="${(start[0]+pt[0])/2}" y="${(start[1]+pt[1])/2-8/zoom}" style="font-size:${11/zoom}px">${esc(fmtFtIn(memberEndDistance(f,targets[Math.max(0,chosenIndex)])/25.4))}</text>`;
|
|
5878
|
+
return out+'</g>';
|
|
5879
|
+
}
|
|
5729
5880
|
function render(){
|
|
5730
5881
|
/* The Instructor's second publish trigger, and the one that catches what input
|
|
5731
5882
|
events cannot: an arm or disarm inside a PROMISE callback (an async contract
|
|
@@ -5801,13 +5952,14 @@ function render(){
|
|
|
5801
5952
|
s+=renderDims();
|
|
5802
5953
|
s+=renderPropLabels(); // right-click property-label chips (2D); 3D labels ride the div-overlay pool
|
|
5803
5954
|
s+=renderSelLenLabels(); // on-select member-length chips (2D), gated by the ⋯ Display "Show member length" toggle
|
|
5955
|
+
s+=memberEndReviewSvg();
|
|
5804
5956
|
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)
|
|
5805
5957
|
// No datalist population here any more. The #profiles and #details <datalist>s went with the rest of
|
|
5806
5958
|
// them (an OS-drawn white popup has no themed mode), and COMBO_SRC.profiles/.details already read
|
|
5807
5959
|
// `profs` and `detTexts()` live — so the combobox offers the same list with no mirror to keep filled.
|
|
5808
5960
|
// Deleting the elements while these two writes stayed made render() throw on null here, which also
|
|
5809
5961
|
// killed every call after it on this line (stats/panel/upd*/syncDisplayRows). Measured in Chromium.
|
|
5810
|
-
svg.innerHTML=s; stats(); panel(); updUR(); updDup(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); syncDisplayRows();
|
|
5962
|
+
svg.innerHTML=s; stats(); panel(); updUR(); updDup(); updateMemberEndStatus(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); syncDisplayRows();
|
|
5811
5963
|
if(selFilterReady)reflectSelFilter(); // keep the Select-bar Members/Connections buttons in sync with the model — a new/removed connection kind (e.g. the first auto-detailed base plate) flips their on/off without a manual toggle. Gated on selFilterReady so it doesn't run until the deferred first reflect has armed it (that reflect needs BASE_MEMBER_TYPES, initialised later in main()).
|
|
5812
5964
|
if(view3dShown&&window.Steel3DView){window.Steel3DView.setSelection(selIds);if(window.Steel3DView.setGridSelection)window.Steel3DView.setGridSelection(selGridIds);updateIsolateBtn();if((selIds.size||selGridIds.size)&&window.Steel3DView.selectedClips&&window.Steel3DView.selectedClips().length)window.Steel3DView.setSelectedClips([]);refreshLegendSel();} // keep the 3D member + grid highlight in sync; selecting geometry clears any clip selection (exclusive)
|
|
5813
5965
|
try{updateConnCrumb();}catch(_){} // Connection Component breadcrumb follows the selection (3D-only; hidden at root)
|
|
@@ -6042,10 +6194,49 @@ function refPanelPreempted(){
|
|
|
6042
6194
|
if(view3d&&v&&v.frameArmed&&v.frameArmed())return 'mode';
|
|
6043
6195
|
return null;
|
|
6044
6196
|
}
|
|
6197
|
+
function renderMemberEndPanel(p){
|
|
6198
|
+
const state=memberEndReview,rows=state.report.findings,groups=new Map();rows.forEach((f,i)=>{const g=memberEndGroup(f);if(!groups.has(g))groups.set(g,[]);groups.get(g).push([f,i]);});
|
|
6199
|
+
const actionable=rows.filter(f=>f.classification==='needs-review'&&state.chosen.has(memberEndKey(f))),selected=actionable.filter(f=>state.selected.has(memberEndKey(f))).length;
|
|
6200
|
+
const historyAction=memberEndHistoryAction(state.undoDirection);
|
|
6201
|
+
p.setAttribute('aria-busy',String(!!state.busy));p.setAttribute('aria-labelledby','memberEndReviewTitle');
|
|
6202
|
+
const disabled=state.busy?' disabled':'';
|
|
6203
|
+
let html=`<div class=mer-head><div><div class=mer-title id=memberEndReviewTitle>Member ends short of support centerlines</div><div class=hint>${memberEndUnresolved(state.report)} unresolved end${memberEndUnresolved(state.report)===1?'':'s'} on ${new Set(rows.map(f=>f.memberId)).size} member${new Set(rows.map(f=>f.memberId)).size===1?'':'s'}</div></div><button id=merDone data-command-id="steel.member-end-review-close" class=ghost data-tip="Close member-end review"${disabled}>Done</button></div>`;
|
|
6204
|
+
const toolbar=[];if(actionable.length>selected)toolbar.push(`<button id=merAll data-command-id="steel.member-end-select-all" class=ghost${disabled}>Select all</button>`);if(selected)toolbar.push(`<button id=merClear data-command-id="steel.member-end-select-clear" class=ghost${disabled}>Clear</button>`);html+=`<div class=mer-toolbar>${toolbar.join('')}<span class=hint>${selected} selected</span></div>`;
|
|
6205
|
+
for(const [group,items] of groups){html+=`<section class=mer-group><div class=mer-group-title>${esc(group)}</div>`;for(const [f,i] of items){const key=memberEndKey(f),target=state.chosen.get(key),checked=state.selected.has(key),canCheck=f.classification==='needs-review'&&!!target;
|
|
6206
|
+
const evidence=target?memberEndTargetName(target)+' · Extend '+fmtFtIn(memberEndDistance(f,target)/25.4):memberEndReason(f)||memberEndClassification(f);
|
|
6207
|
+
html+=`<div class="mer-row${i===state.focus?' focused':''}" data-mer-row="${i}">${canCheck?`<input type=checkbox data-mer-check="${i}" data-command-id="steel.member-end-select#${esc(f.memberId+' end '+(f.end+1))}" aria-label="Include ${esc(f.memberId)} end ${f.end+1}" ${checked?'checked':''}${disabled}>`:'<span aria-hidden=true></span>'}<div><label${canCheck?` for="merCheck${i}"`:''}>${esc(memberEndRole(f)+' '+f.memberId+' · End '+(f.end+1))}</label><div class=mer-evidence>${esc(evidence)}</div><div class=mer-actions>`;
|
|
6208
|
+
if(f.classification==='needs-review'){
|
|
6209
|
+
if((f.targets||[]).length>1)html+=(f.targets||[]).map((t,ti)=>`<button data-command-id="steel.member-end-target#${esc(memberEndTargetName(t))}" class="ghost${memberEndTargetEqual(target,t)?' selected':''}" data-mer-target="${i}:${ti}" aria-pressed="${memberEndTargetEqual(target,t)}" data-tip="Choose ${esc(memberEndTargetName(t))}"${disabled}>${String.fromCharCode(65+ti)} · ${esc(memberEndTargetName(t))}</button>`).join('');
|
|
6210
|
+
if(memberEndCanKeepShort(f))html+=`<button data-command-id="steel.member-end-keep-short#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-keep="${i}" data-tip="Record this endpoint as intentionally short for the current model context"${disabled}>Keep short</button>`;
|
|
6211
|
+
}
|
|
6212
|
+
if((f.classification==='aligned-auto'||f.classification==='aligned-manual')&&f.basis&&f.basis.kind==='drawing')html+=`<button data-command-id="steel.member-end-restore#${esc(f.memberId+' end '+(f.end+1))}" class=ghost data-mer-restore="${i}" data-tip="Restore the immutable endpoint traced from the drawing"${disabled}>Restore traced end</button>`;
|
|
6213
|
+
html+='</div></div></div>';}
|
|
6214
|
+
html+='</section>';}
|
|
6215
|
+
html+=`<div class=mer-nav><button id=merPrev data-command-id="steel.member-end-review-nav#previous" class=ghost${disabled}>Previous</button><button id=merNext data-command-id="steel.member-end-review-nav#next" class=ghost${disabled}>Next</button>${state.undoToken?`<button id=merUndo data-command-id="steel.member-end-history#${esc(historyAction.label)}" class=ghost data-tip="${historyAction.tip}"${disabled}>${historyAction.label}</button>`:''}</div><div class=mer-live role=status aria-live=polite aria-atomic=true>${esc(state.live||'')}</div>`;
|
|
6216
|
+
if(selected)html+=`<button id=merApply data-command-id="steel.member-end-apply" class=mer-primary${disabled}>${state.busy?'Working…':'Extend '+selected+' end'+(selected===1?'':'s')+' to centerlines'}</button>`;else html+='<div class=hint style="margin-top:9px">No ends selected</div>';
|
|
6217
|
+
p.innerHTML=html;
|
|
6218
|
+
const done=document.getElementById('merDone');if(done)done.onclick=closeMemberEndReview;
|
|
6219
|
+
const all=document.getElementById('merAll');if(all)all.onclick=()=>{for(const f of actionable)state.selected.add(memberEndKey(f));panel();};
|
|
6220
|
+
const clear=document.getElementById('merClear');if(clear)clear.onclick=()=>{state.selected.clear();panel();};
|
|
6221
|
+
p.querySelectorAll('[data-mer-row]').forEach(row=>row.addEventListener('click',e=>{if(e.target.closest('button,input'))return;focusMemberEnd(+row.dataset.merRow);}));
|
|
6222
|
+
p.querySelectorAll('[data-mer-check]').forEach(input=>{input.id='merCheck'+input.dataset.merCheck;input.onchange=()=>{const f=rows[+input.dataset.merCheck],key=memberEndKey(f);input.checked?state.selected.add(key):state.selected.delete(key);state.focus=+input.dataset.merCheck;panel();render();};input.onfocus=()=>{state.focus=+input.dataset.merCheck;selIds=new Set([rows[state.focus].memberId]);if(view3dShown&&window.Steel3DView)window.Steel3DView.setSelection(selIds);};});
|
|
6223
|
+
p.querySelectorAll('[data-mer-target]').forEach(b=>b.onclick=()=>{const [i,t]=b.dataset.merTarget.split(':').map(Number);state.focus=i;chooseMemberEndTarget(memberEndKey(rows[i]),t);});
|
|
6224
|
+
p.querySelectorAll('[data-mer-keep]').forEach(b=>b.onclick=()=>keepMemberEnd(rows[+b.dataset.merKeep]));
|
|
6225
|
+
p.querySelectorAll('[data-mer-restore]').forEach(b=>b.onclick=()=>restoreMemberEnd(rows[+b.dataset.merRestore]));
|
|
6226
|
+
const prev=document.getElementById('merPrev'),next=document.getElementById('merNext'),applyB=document.getElementById('merApply'),undoB=document.getElementById('merUndo');if(prev)prev.onclick=()=>focusMemberEnd(state.focus-1);if(next)next.onclick=()=>focusMemberEnd(state.focus+1);if(applyB)applyB.onclick=applyMemberEndSelection;if(undoB)undoB.onclick=undoMemberEndResolution;
|
|
6227
|
+
}
|
|
6228
|
+
function renderMemberEndScanPanel(p){
|
|
6229
|
+
const state=memberEndScan;p.setAttribute('aria-busy',String(!!state.busy));p.setAttribute('aria-labelledby','memberEndScanTitle');
|
|
6230
|
+
p.innerHTML=`<div class=mer-head><div><div class=mer-title id=memberEndScanTitle>${state.error?'Member-end check needs attention':'Checking member ends'}</div><div class=hint>Drawing and model evidence</div></div></div><div class=mer-live role=status aria-live=polite aria-atomic=true>${esc(state.live)}</div>${state.error?'<button id=merRetry data-command-id="steel.member-end-retry" class=mer-primary>Check again</button>':''}`;
|
|
6231
|
+
const retry=document.getElementById('merRetry');if(retry)retry.onclick=()=>scanMemberEnds();
|
|
6232
|
+
}
|
|
6045
6233
|
function panel(){
|
|
6046
6234
|
const p=document.getElementById('panel');
|
|
6235
|
+
p.removeAttribute('aria-busy');p.removeAttribute('aria-labelledby');
|
|
6047
6236
|
queueMicrotask(()=>syncV2SelectionNotice(p));
|
|
6048
6237
|
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
|
|
6238
|
+
if(memberEndScan){renderMemberEndScanPanel(p);return;}
|
|
6239
|
+
if(memberEndReview){renderMemberEndPanel(p);return;}
|
|
6049
6240
|
if(gridMode){renderGridPanel(p);return;}
|
|
6050
6241
|
// FIRST after the grid takeover, and ABOVE the two "there is nothing to say" panels below — because for
|
|
6051
6242
|
// a drilled-into reference object there IS something to say, and it is true. A reference model is
|
|
@@ -6384,7 +6575,7 @@ function panel(){
|
|
|
6384
6575
|
// is skipped by the bake entirely, so folding it in would report a Varies (or a value) for a member
|
|
6385
6576
|
// nothing applies to. ONE subset for both axes and both offsets, because the bake has one answer for all
|
|
6386
6577
|
// four. Columns are IN it now: they take a Profile Position like every other member (design §4).
|
|
6387
|
-
const hOk=arr.filter(posEligible)
|
|
6578
|
+
const hOk=arr,hSkip=arr.filter(m=>!posEligible(m)).length;
|
|
6388
6579
|
const posA=hOk.length?agg(hOk,m=>posDefault(m)):null;
|
|
6389
6580
|
const posHA=hOk.length?agg(hOk,m=>posHDefault(m)):null;
|
|
6390
6581
|
// A mixed selection must read BLANK, not the first member's value — an offset silently inherited across a
|
|
@@ -6412,6 +6603,7 @@ function panel(){
|
|
|
6412
6603
|
<div class=row><button data-command-id="steel.selection-verified" class=ghostw id=verifyBtn${allVerified?' style="border-color:var(--ok-edge);color:var(--ok)"':''}>${allVerified?'✓ All verified — click to unverify':'Mark all verified'}</button></div>
|
|
6413
6604
|
${elev}
|
|
6414
6605
|
<div class=divrow><hr><span class=sect style="margin:0" data-tip="${POSTIP.head}">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
6606
|
+
${positionFrameHTML()}
|
|
6415
6607
|
${hOk.length?posRow('Depth','posOff','Offset',VV(offA)?null:offA,POSTIP.offD,
|
|
6416
6608
|
`<button data-command-id="steel.position-face#with its top face on the line" id=posTop class="${posA==='top'?'on':''}" aria-pressed="${posA==='top'?'true':'false'}" data-tip="${POSTIP.top}">Top</button><button data-command-id="steel.position-face#centred in depth" id=posMid class="${posA==='middle'?'on':''}" aria-pressed="${posA==='middle'?'true':'false'}" data-tip="${POSTIP.mid}">Middle</button><button data-command-id="steel.position-face#with its underside on the line" id=posBot class="${posA==='bottom'?'on':''}" aria-pressed="${posA==='bottom'?'true':'false'}" data-tip="${POSTIP.bot}">Bottom</button>`,
|
|
6417
6609
|
VV(offA)?'Varies':'0"')
|
|
@@ -6419,10 +6611,10 @@ function panel(){
|
|
|
6419
6611
|
`<button data-command-id="steel.position-face#with its left face on the line" id=posHLeft class="${posHA==='left'?'on':''}" aria-pressed="${posHA==='left'?'true':'false'}" data-tip="${POSTIP.left}">Left</button><button data-command-id="steel.position-face#centred across the line" id=posHMid class="${posHA==='middle'?'on':''}" aria-pressed="${posHA==='middle'?'true':'false'}" data-tip="${POSTIP.midH}">Middle</button><button data-command-id="steel.position-face#with its right face on the line" id=posHRight class="${posHA==='right'?'on':''}" aria-pressed="${posHA==='right'?'true':'false'}" data-tip="${POSTIP.right}">Right</button>`,
|
|
6420
6612
|
VV(offHA)?'Varies':'0"')
|
|
6421
6613
|
+((VV(posA)||VV(posHA))?`<div class=hint style="margin-top:4px">${VV(posA)&&VV(posHA)?'Depth and width vary across the selection, so neither row has a face lit':VV(posA)?'Depth varies across the selection, so no depth face is lit':'Width varies across the selection, so no width face is lit'}. Pick one to set every selected member.</div>`:'')
|
|
6422
|
-
+(hSkip?`<div class=hint style="margin-top:4px">${hSkip} of the ${arr.length} selected members ${hSkip>1?'have':'has'} no section
|
|
6614
|
+
+(hSkip?`<div class=hint style="margin-top:4px">${hSkip} of the ${arr.length} selected members ${hSkip>1?'have':'has'} no resolved section. Same-frame edits stay available; changing edit frame will refuse atomically if a named face cannot be decoded.</div>`:'')
|
|
6423
6615
|
:`<div class=hint style="margin-top:8px">None of the selected members has a section to place — their profiles do not resolve, so they are left unchanged. Any placement they already carry is kept, and applies again once the profile resolves.</div>`}
|
|
6424
6616
|
<div class=elabrow><span class=elab>Rotation</span><label class="detf posoff"><span>Angle °</span><input data-command-id="steel.position-rotation#a typed angle" aria-label="Rotation angle" id=detRotZ inputmode=decimal placeholder="${rotAgg===VARIES?'Varies':'0'}" value="${rotAgg===VARIES?'':esc(String(Number(rotAgg)||0))}" data-tip="${POSTIP.rot}" autocomplete=off></label></div>
|
|
6425
|
-
<div class=seg2 style="margin-top:2px"><button data-command-id="steel.position-rotation#0" id=rot0 class="${rotAgg===0?'on':''}" aria-pressed="${rotAgg===0?'true':'false'}" data-tip="${POSTIP.rot}">0°</button><button data-command-id="steel.position-rotation#90" id=rot90 class="${rotAgg===90?'on':''}" aria-pressed="${rotAgg===90?'true':'false'}" data-tip="${POSTIP.rot}">90°</button><button data-command-id="steel.position-rotation#180" id=rot180 class="${rotAgg===180?'on':''}" aria-pressed="${rotAgg===180?'true':'false'}" data-tip="${POSTIP.rot}">180°</button><button data-command-id="steel.position-rotation#270" id=rot270 class="${rotAgg===270?'on':''}" aria-pressed="${rotAgg===270?'true':'false'}" data-tip="${POSTIP.rot}">270°</button></div>
|
|
6617
|
+
<div class=seg2 role=group aria-label="Section rotation" style="margin-top:2px"><button data-command-id="steel.position-rotation#0" id=rot0 class="${rotAgg===0?'on':''}" aria-pressed="${rotAgg===0?'true':'false'}" data-tip="${POSTIP.rot}">0°</button><button data-command-id="steel.position-rotation#90" id=rot90 class="${rotAgg===90?'on':''}" aria-pressed="${rotAgg===90?'true':'false'}" data-tip="${POSTIP.rot}">90°</button><button data-command-id="steel.position-rotation#180" id=rot180 class="${rotAgg===180?'on':''}" aria-pressed="${rotAgg===180?'true':'false'}" data-tip="${POSTIP.rot}">180°</button><button data-command-id="steel.position-rotation#270" id=rot270 class="${rotAgg===270?'on':''}" aria-pressed="${rotAgg===270?'true':'false'}" data-tip="${POSTIP.rot}">270°</button></div>
|
|
6426
6618
|
<div class=divrow><hr><span class=sect style="margin:0">Modify geometry</span><hr></div>
|
|
6427
6619
|
<div class=seg2 style="margin-top:0"><button data-command-id="steel.extend-trim" id=geoEL class="${geoMode==='el'?'on':''}" aria-pressed="${geoMode==='el'?'true':'false'}">Extend / Trim all</button></div>
|
|
6428
6620
|
<div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> (member, segment, or grid line) — 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>
|
|
@@ -6431,7 +6623,7 @@ function panel(){
|
|
|
6431
6623
|
${qdHasBeam?`<div class=seg2 style="margin-top:0"><button data-command-id="steel.quick-dimension-anchor#start" id=qdPtA class="${qdAnchorPt==='a'?'on':''}" aria-pressed="${qdAnchorPt==='a'?'true':'false'}" data-tip="Measure between each beam's START point">Start</button><button data-command-id="steel.quick-dimension-anchor#middle" id=qdPtMid class="${qdAnchorPt==='mid'?'on':''}" aria-pressed="${qdAnchorPt==='mid'?'true':'false'}" data-tip="Measure between each beam's MIDPOINT">Middle</button><button data-command-id="steel.quick-dimension-anchor#end" id=qdPtB class="${qdAnchorPt==='b'?'on':''}" aria-pressed="${qdAnchorPt==='b'?'true':'false'}" data-tip="Measure between each beam's END point">End</button></div>`:''}
|
|
6432
6624
|
<div class=row style="margin-top:6px"><button data-command-id="steel.quick-dimension-place" class=ghostw id=qdPlace data-tip="Place spacing dimensions between the ${qdN} selected members · Shortcut: Q">📏 Place spacing dims (${qdN}) <span style="opacity:.55">(Q)</span></button></div>`:''}
|
|
6433
6625
|
<div class="row f"><button data-command-id="steel.members-delete" class=danger id=del>Delete selected (${arr.length})</button></div>`;
|
|
6434
|
-
wireTypeFilter(p);
|
|
6626
|
+
wireTypeFilter(p);wirePositionAvailability();
|
|
6435
6627
|
// wiring — every commit applies to the whole selection; a blank field is a no-op (leaves each member's own value).
|
|
6436
6628
|
document.getElementById('pf').onchange=e=>{const v=_canonDes(e.target.value);if(!v)return;edit(()=>{for(const m of selArr())ModelCmd.patchMember(m,{profile:v,rfi:_wt(v)==null});if(!profs.includes(v)){profs.push(v);profs.sort();}});};
|
|
6437
6629
|
document.getElementById('profileBrowseM').onclick=e=>openProfilePicker({ids:arr.map(m=>m.id),current:VV(profAgg)?null:profAgg,scope:`${arr.length} selected members`,invoker:e.currentTarget});
|
|
@@ -6454,10 +6646,8 @@ function panel(){
|
|
|
6454
6646
|
// so an all-ineligible selection must not enter it and leave an empty entry on the stack.
|
|
6455
6647
|
// COLUMNS ARE NO LONGER EXCLUDED — the old `if(m.role!=='column')` skipped every column silently, and a
|
|
6456
6648
|
// column now takes the same placement as anything else (design §4).
|
|
6457
|
-
{const setAll=patch=>
|
|
6458
|
-
|
|
6459
|
-
if(sk)toast(sk+' member'+(sk>1?'s':'')+' skipped — a profile that does not resolve to a section has no face to place');};
|
|
6460
|
-
const btn=(id,patch)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setAll(patch);};
|
|
6649
|
+
{const setAll=(patch,source)=>commitPositionEdit(selArr(),patch,source);
|
|
6650
|
+
const btn=(id,patch)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setAll(patch,b);};
|
|
6461
6651
|
btn('posTop',{position:'top'});btn('posMid',{position:'middle'});btn('posBot',{position:'bottom'});
|
|
6462
6652
|
btn('posHLeft',{positionH:'left'});btn('posHMid',{positionH:'middle'});btn('posHRight',{positionH:'right'});
|
|
6463
6653
|
// The offsets: a BLANK commit is a no-op here, not a clear — blank means "Varies, leave each alone" on
|
|
@@ -6466,12 +6656,12 @@ function panel(){
|
|
|
6466
6656
|
const off=(id,key)=>{const i=document.getElementById(id);if(i)i.onchange=e=>{const t=e.target.value.trim();if(t==='')return;
|
|
6467
6657
|
const inch=parseLen(t);
|
|
6468
6658
|
if(inch==null||!isFinite(inch)){toast(`Couldn’t read “${t}” as a length — try 3 1/2" or 1'-3 1/2".`);render();return;}
|
|
6469
|
-
setAll({[key]:inch*25.4});};};
|
|
6659
|
+
setAll({[key]:inch*25.4},i);};};
|
|
6470
6660
|
off('posOff','positionOffset');off('posHOff','positionHOffset');}
|
|
6471
6661
|
// Rotation — apply one angle to every selected member's section (blank input = no-op). Normalised (-360,360).
|
|
6472
6662
|
{const setRot=v=>{const raw=String(v).trim();let r=Number(raw.replace(',','.'));
|
|
6473
6663
|
if(!isFinite(r)){toast('Couldn’t read “'+raw+'” as an angle — enter degrees, e.g. 45 or -90.');render();return;}
|
|
6474
|
-
r=r%360;
|
|
6664
|
+
r=r%360;commitPositionEdit(selArr(),{rot:r},document.activeElement);};
|
|
6475
6665
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>{if(e.target.value.trim()==='')return;setRot(e.target.value);};
|
|
6476
6666
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
6477
6667
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
@@ -6703,14 +6893,15 @@ function panel(){
|
|
|
6703
6893
|
${defPts}
|
|
6704
6894
|
${bpSect}${spSect}${copeSect}
|
|
6705
6895
|
<div class=divrow><hr><span class=sect style="margin:0" data-tip="${POSTIP.head}">Profile Position <span style="opacity:.45;font-weight:400">ⓘ</span></span><hr></div>
|
|
6706
|
-
${
|
|
6896
|
+
${positionFrameHTML()}
|
|
6897
|
+
${posRow('Depth','posOff','Offset',m.positionOffset,POSTIP.offD,
|
|
6707
6898
|
`<button data-command-id="steel.position-face#with its top face on the line" id=posTop class="${pos==='top'?'on':''}" aria-pressed="${pos==='top'?'true':'false'}" data-tip="${POSTIP.top}">Top</button><button data-command-id="steel.position-face#centred in depth" id=posMid class="${pos==='middle'?'on':''}" aria-pressed="${pos==='middle'?'true':'false'}" data-tip="${POSTIP.mid}">Middle</button><button data-command-id="steel.position-face#with its underside on the line" id=posBot class="${pos==='bottom'?'on':''}" aria-pressed="${pos==='bottom'?'true':'false'}" data-tip="${POSTIP.bot}">Bottom</button>`)
|
|
6708
6899
|
+posRow('Width','posHOff','Offset',m.positionHOffset,POSTIP.offW,
|
|
6709
6900
|
`<button data-command-id="steel.position-face#with its left face on the line" id=posHLeft class="${posH==='left'?'on':''}" aria-pressed="${posH==='left'?'true':'false'}" data-tip="${POSTIP.left}">Left</button><button data-command-id="steel.position-face#centred across the line" id=posHMid class="${posH==='middle'?'on':''}" aria-pressed="${posH==='middle'?'true':'false'}" data-tip="${POSTIP.midH}">Middle</button><button data-command-id="steel.position-face#with its right face on the line" id=posHRight class="${posH==='right'?'on':''}" aria-pressed="${posH==='right'?'true':'false'}" data-tip="${POSTIP.right}">Right</button>`)
|
|
6710
6901
|
+(hApprox?`<div class=hint style="margin-top:4px">${hApprox}</div>`:'')
|
|
6711
|
-
|
|
6902
|
+
+(!hEl?`<div class=hint style="margin-top:4px">${hWhy} Same-frame edits remain available; changing edit frame will refuse if a named face cannot be decoded.</div>`:'')}
|
|
6712
6903
|
<div class=elabrow><span class=elab>Rotation</span><label class="detf posoff"><span>Angle °</span><input data-command-id="steel.position-rotation#a typed angle" aria-label="Rotation angle" id=detRotZ inputmode=decimal value="${rotDisp}" data-tip="${POSTIP.rot}" autocomplete=off></label></div>
|
|
6713
|
-
<div class=seg2 style="margin-top:2px"><button data-command-id="steel.position-rotation#0" id=rot0 class="${rotN===0?'on':''}" aria-pressed="${rotN===0?'true':'false'}" data-tip="${POSTIP.rot}">0°</button><button data-command-id="steel.position-rotation#90" id=rot90 class="${rotN===90?'on':''}" aria-pressed="${rotN===90?'true':'false'}" data-tip="${POSTIP.rot}">90°</button><button data-command-id="steel.position-rotation#180" id=rot180 class="${rotN===180?'on':''}" aria-pressed="${rotN===180?'true':'false'}" data-tip="${POSTIP.rot}">180°</button><button data-command-id="steel.position-rotation#270" id=rot270 class="${rotN===270?'on':''}" aria-pressed="${rotN===270?'true':'false'}" data-tip="${POSTIP.rot}">270°</button></div>
|
|
6904
|
+
<div class=seg2 role=group aria-label="Section rotation" style="margin-top:2px"><button data-command-id="steel.position-rotation#0" id=rot0 class="${rotN===0?'on':''}" aria-pressed="${rotN===0?'true':'false'}" data-tip="${POSTIP.rot}">0°</button><button data-command-id="steel.position-rotation#90" id=rot90 class="${rotN===90?'on':''}" aria-pressed="${rotN===90?'true':'false'}" data-tip="${POSTIP.rot}">90°</button><button data-command-id="steel.position-rotation#180" id=rot180 class="${rotN===180?'on':''}" aria-pressed="${rotN===180?'true':'false'}" data-tip="${POSTIP.rot}">180°</button><button data-command-id="steel.position-rotation#270" id=rot270 class="${rotN===270?'on':''}" aria-pressed="${rotN===270?'true':'false'}" data-tip="${POSTIP.rot}">270°</button></div>
|
|
6714
6905
|
${hEl?`<button class=psethd id=posSecHd data-command-id="steel.position-section-view" type=button aria-expanded="${posSecOpen?'true':'false'}" aria-controls=posSecBody data-tip="A drawing of this section looking along the member from its start point — the outline where the placement actually puts it, with the work-line marked">
|
|
6715
6906
|
<span class=chev>▶</span><span class=psn>Section view</span></button>
|
|
6716
6907
|
<div class="psetbody${posSecOpen?' open':''}" id=posSecBody style="padding-left:0">${posSectionSvg(m)}</div>`:''}
|
|
@@ -6719,7 +6910,7 @@ function panel(){
|
|
|
6719
6910
|
<div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — another member, a grey segment, or a grid line. 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>
|
|
6720
6911
|
${col?'':`<div class=row><button data-command-id="steel.ends-swap" class=ghostw id=swapEnds aria-keyshortcuts=P data-tip="Reverse the beam: swap its yellow start and magenta end handles · Shortcut: P">⇄ Swap start ↔ end <span style="opacity:.55">(P)</span></button></div>`}`}
|
|
6721
6912
|
<div class="row f"><button data-command-id="steel.member-delete" class=danger id=del>Delete member</button></div>`;
|
|
6722
|
-
wireTypeFilter(p);
|
|
6913
|
+
wireTypeFilter(p);wirePositionAvailability();
|
|
6723
6914
|
document.getElementById('pf').onchange=e=>edit(()=>{const v=_canonDes(e.target.value);ModelCmd.patchMember(m,{profile:v,rfi:_wt(v)==null});if(v&&!profs.includes(v)){profs.push(v);profs.sort();}});
|
|
6724
6915
|
document.getElementById('profileBrowseS').onclick=e=>openProfilePicker({ids:[m.id],current:m.profile,scope:`Member ${m.id}`,invoker:e.currentTarget});
|
|
6725
6916
|
document.getElementById('mat').onchange=e=>applyMaterialChoice([m.id],String(e.target.value||'').trim()||CatalogPicker.MATERIAL_DEFAULT);
|
|
@@ -6744,16 +6935,16 @@ function panel(){
|
|
|
6744
6935
|
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);};
|
|
6745
6936
|
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)
|
|
6746
6937
|
const _bsw=document.getElementById('brSwap');if(_bsw)_bsw.onclick=()=>edit(()=>{normBrace(m);ModelCmd.patchMemberBrace(m,{lowerEnd:1-braceLowerEnd(m)});});}
|
|
6747
|
-
{const setPos=v
|
|
6938
|
+
{const setPos=(v,source)=>commitPositionEdit([m],{position:v},source); // profile placement on the reference line; persists + re-extrudes the 3D
|
|
6748
6939
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
6749
|
-
if(_pt)_pt.onclick=()=>setPos('top');if(_pm)_pm.onclick=()=>setPos('middle');if(_pb)_pb.onclick=()=>setPos('bottom');}
|
|
6750
|
-
{const setPosH=v
|
|
6940
|
+
if(_pt)_pt.onclick=()=>setPos('top',_pt);if(_pm)_pm.onclick=()=>setPos('middle',_pm);if(_pb)_pb.onclick=()=>setPos('bottom',_pb);}
|
|
6941
|
+
{const setPosH=(v,source)=>commitPositionEdit([m],{positionH:v},source); // the width half of the same placement — shifts the section ACROSS the line (3D + exports)
|
|
6751
6942
|
const _hl=document.getElementById('posHLeft'),_hm=document.getElementById('posHMid'),_hr=document.getElementById('posHRight');
|
|
6752
|
-
if(_hl)_hl.onclick=()=>setPosH('left');if(_hm)_hm.onclick=()=>setPosH('middle');if(_hr)_hr.onclick=()=>setPosH('right');}
|
|
6943
|
+
if(_hl)_hl.onclick=()=>setPosH('left',_hl);if(_hm)_hm.onclick=()=>setPosH('middle',_hm);if(_hr)_hr.onclick=()=>setPosH('right',_hr);}
|
|
6753
6944
|
// The two numeric offsets — past the named face, on the section's OWN axis. See posSetOff for why a blank
|
|
6754
6945
|
// commit CLEARS rather than storing 0, and why an unparseable one leaves the model alone.
|
|
6755
|
-
{const _od=document.getElementById('posOff');if(_od)_od.onchange=e=>posSetOff(m,'positionOffset',e.target.value);
|
|
6756
|
-
const _ow=document.getElementById('posHOff');if(_ow)_ow.onchange=e=>posSetOff(m,'positionHOffset',e.target.value);}
|
|
6946
|
+
{const _od=document.getElementById('posOff');if(_od)_od.onchange=e=>posSetOff(m,'positionOffset',e.target.value,_od);
|
|
6947
|
+
const _ow=document.getElementById('posHOff');if(_ow)_ow.onchange=e=>posSetOff(m,'positionHOffset',e.target.value,_ow);}
|
|
6757
6948
|
// Section view: the panel's own themed disclosure (the property-set accordion), never <details> — whose
|
|
6758
6949
|
// native marker triangle is exactly the browser default this theme must not leak. `posSecOpen` is
|
|
6759
6950
|
// module-scoped so it survives p.innerHTML, and toggles in place rather than re-rendering the panel.
|
|
@@ -6766,7 +6957,7 @@ function panel(){
|
|
|
6766
6957
|
// the one thing a placement field may never do.
|
|
6767
6958
|
{const setRot=v=>{const raw=String(v).trim();let r=Number(raw.replace(',','.'));
|
|
6768
6959
|
if(!isFinite(r)){toast('Couldn’t read “'+raw+'” as an angle — enter degrees, e.g. 45 or -90.');render();return;}
|
|
6769
|
-
r=r%360;
|
|
6960
|
+
r=r%360;commitPositionEdit([m],{rot:r},document.activeElement);};
|
|
6770
6961
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>setRot(e.target.value);
|
|
6771
6962
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
6772
6963
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
@@ -6868,8 +7059,9 @@ function panel(){
|
|
|
6868
7059
|
document.getElementById('del').onclick=()=>edit(()=>{deleteV2Selection({memberIds:[m.id],dimIds:selDimIds});selIds.clear();selDimIds.clear();});
|
|
6869
7060
|
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{ModelCmd.patchMember(m,{verified:!m.verified});});}
|
|
6870
7061
|
}
|
|
6871
|
-
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();
|
|
7062
|
+
function addFromSeg(sid){const sg=P.segments.find(s=>s.id===sid);if(!sg)return;const basis=positionAuthoringBasis();if(!basis.ok){positionRefuse(basis.message);return;}const prof=addProfile;const id='m'+Date.now();const pv=snapshot();
|
|
6872
7063
|
const nm=ensureMeta({id,profile:prof,material:addMaterial||undefined,wp:[sg.a.slice(),sg.b.slice()],angle:sg.o,rfi:(_wt(prof)==null)});
|
|
7064
|
+
if(!applyPositionAuthoringBasis(nm,basis)){positionRefuse('Profile Position unavailable: the current authoring axes are invalid.');return;}
|
|
6873
7065
|
applyMemberType([nm],addType);MC().addMembers(P,[nm]); // applyMemberType writes role/memberType, not geometry — it stays here
|
|
6874
7066
|
if(prof&&!profs.includes(prof)){profs.push(prof);profs.sort();}pushUndo(pv);render();sync3D();}
|
|
6875
7067
|
// --- marquee hit-test (crossing selection): does segment ab touch rect [x0,y0,x1,y1]? ---
|
|
@@ -7159,7 +7351,7 @@ const PROP_DEFS=[
|
|
|
7159
7351
|
{key:'type', label:'Type', get:m=>memberTypeLabel(memberTypeOf(m)), fmt:v=>v==null?'':String(v)},
|
|
7160
7352
|
{key:'role', label:'Role', get:m=>m.role==='column'?'Column':'Beam', fmt:v=>v||''},
|
|
7161
7353
|
{key:'length', label:'Length', get:m=>_lenFt(m), labelGet:m=>_lenFtLabel(m), fmt:v=>v==null?'':v.toFixed(1)+' ft'},
|
|
7162
|
-
{key:'weight', label:'Weight', get:m=>{const w=_wt(m.profile);return w==null?undefined:_lenFt(m)*w;}, labelGet:m=>{const w=_wt(m.profile),l=_lenFtLabel(m);return (w==null||l==null)?undefined:l*w;}, fmt:v=>v==null?'':Math.round(v).toLocaleString()+' lb'},
|
|
7354
|
+
{key:'weight', label:'Weight', get:m=>{const w=_wt(m.profile);return w==null?undefined:_lenFt(m)*w;}, labelGet:m=>{const w=_wt(m.profile),l=_lenFtLabel(m);return (w==null||l==null)?undefined:l*w;}, fmt:v=>v==null?'':Math.round(v).toLocaleString('en-US')+' lb'},
|
|
7163
7355
|
// The column suppression is GONE: a column takes the same Profile Position as every other member now
|
|
7164
7356
|
// (design §4), so hiding its depth face would be the label lying about geometry the bake applies.
|
|
7165
7357
|
{key:'position', label:'Position', get:m=>posEligible(m)?posDefault(m):((m.position==='top'||m.position==='middle'||m.position==='bottom')?m.position+' (not applied)':undefined), fmt:v=>v?v[0].toUpperCase()+v.slice(1):''},
|
|
@@ -7553,14 +7745,16 @@ function dimHintText(){if(dimChainPrev)return 'Chaining — click the next point
|
|
|
7553
7745
|
return stepSlotText('steel.dimension')+' · '+a+(dimChain?' · Chain ON':'')+(loc?' · local axes':'');}
|
|
7554
7746
|
// ---- Add-member draw: click-to-start / click-to-finish (mirrors the Dimension tool; snaps on both clicks) ----
|
|
7555
7747
|
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
|
|
7556
|
-
if(!drawDraft){drawDraft=p;if(picking&&pickKind==='profile'){picking=false;render();}drawPrev(e);return;} // click 1
|
|
7748
|
+
if(!drawDraft){const basis=positionAuthoringBasis();if(!basis.ok){positionRefuse(basis.message,e.currentTarget);return;}drawDraft=p;drawBasisTok=basis;if(picking&&pickKind==='profile'){picking=false;render();}drawPrev(e);return;} // click 1 captures the frame with the start point
|
|
7749
|
+
const currentBasis=positionAuthoringBasis();if(!drawBasisTok||currentBasis.generation!==drawBasisTok.generation){drawDraft=null;drawBasisTok=null;drawPrevClear();positionRefuse('Frame changed — pick both member points again.',e.currentTarget);render();return;}
|
|
7557
7750
|
const a=drawDraft,b=e.shiftKey?orthoLock(a[0],a[1],p[0],p[1]):p; // Shift = straight (ortho, local-frame aware)
|
|
7558
7751
|
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)
|
|
7559
7752
|
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
|
|
7560
7753
|
const id='m'+Date.now(),pv=snapshot();const nm=ensureMeta({id,profile:addProfile,material:addMaterial||undefined,wp:[a,b],angle:o,rfi:(_wt(addProfile)==null)});
|
|
7754
|
+
if(!applyPositionAuthoringBasis(nm,drawBasisTok)){drawDraft=null;drawBasisTok=null;drawPrevClear();positionRefuse('Profile Position unavailable: the captured authoring axes are invalid.',e.currentTarget);return;}
|
|
7561
7755
|
applyMemberType([nm],addType);MC().addMembers(P,[nm]); // the Add-member panel's type owns role + legend category
|
|
7562
7756
|
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}pushUndo(pv);
|
|
7563
|
-
drawDraft=null;render();drawPrev(e);} // commit → clear the draft, keep the tool armed for the next member
|
|
7757
|
+
drawDraft=null;drawBasisTok=null;render();drawPrev(e);} // commit → clear the draft + basis, keep the tool armed for the next member
|
|
7564
7758
|
function drawPrevClear(){const g=document.getElementById('drawPrevLine');if(g)g.remove();snapClear();}
|
|
7565
7759
|
function drawPrev(e){if(mode!=='add'||view3d){drawPrevClear();return;}
|
|
7566
7760
|
{const h=document.getElementById('drawHint');if(h)h.innerHTML=drawHintText();} // keep the side-panel hint live (stage-aware)
|
|
@@ -8081,6 +8275,7 @@ function toast(msg,sticky,ms){let t=document.getElementById('toast');
|
|
|
8081
8275
|
t.textContent=msg;t.style.opacity='1';clearTimeout(t._h);if(!sticky)t._h=setTimeout(()=>{t.style.opacity='0';},ms>0?ms:TOAST_MS);}
|
|
8082
8276
|
// --- pointer: select(+ctrl toggle / box) + group-move + endpoint (Shift = ortho) ---
|
|
8083
8277
|
svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
8278
|
+
if(memberEndReview){const pick=t.closest&&t.closest('[data-mer-canvas-target]');if(pick&&!memberEndReview.busy){const f=memberEndReview.report.findings[memberEndReview.focus];chooseMemberEndTarget(memberEndKey(f),+pick.dataset.merCanvasTarget);}e.preventDefault();e.stopPropagation();return;}
|
|
8084
8279
|
if(csaxisMode){csClick(e);e.preventDefault();return;} // set-local-axes armed → clicks define origin then X-direction
|
|
8085
8280
|
if(dimMode){dimClick(e);e.preventDefault();return;} // tool armed → all clicks place dimension points
|
|
8086
8281
|
if(cmTool){cmClick(e);e.preventDefault();return;} // Move/Copy armed → clicks pick base/destination
|
|
@@ -8335,7 +8530,7 @@ svg.addEventListener('dblclick',e=>{ // dbl-click a grid bubble → rename tha
|
|
|
8335
8530
|
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'));}});
|
|
8336
8531
|
function setMode(){document.body.classList.toggle('add',mode==='add');document.getElementById('mAdd').classList.toggle('on',mode==='add');
|
|
8337
8532
|
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)
|
|
8338
|
-
if(mode!=='add'){drawDraft=null;drawPrevClear();cmHudClose();if(view3d&&window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}} // leaving Add-member drops the in-progress start + preview, closes any open typed-entry HUD, and clears the 3D draw start
|
|
8533
|
+
if(mode!=='add'){drawDraft=null;drawBasisTok=null;drawPrevClear();cmHudClose();if(view3d&&window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}} // leaving Add-member drops the in-progress start + basis + preview, closes any open typed-entry HUD, and clears the 3D draw start
|
|
8339
8534
|
document.getElementById('mAdd').onclick=()=>{if(dimMode){dimMode=false;setDimMode();}if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();if(qdPick){qdPick=null;setQdPickCls();}
|
|
8340
8535
|
if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // arming Add leaves the grid panel — same mutual exclusion Move/Copy already enforces. In 3D addActive() consumes the click AHEAD of the grid pick, so without this the Add gesture would run while the grid button + hint still claimed an armed pick (the A shortcut routes through this same handler)
|
|
8341
8536
|
if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();if(window.Steel3DView.armRefMeasure3d){window.Steel3DView.armRefMeasure3d(null);refMeasureClear();}} // the 3D dim tool + the local frame share the left-click — disarm both when entering add mode
|
|
@@ -8428,6 +8623,7 @@ document.getElementById('revB').onclick=()=>{const ids=reversedBeams(); // bea
|
|
|
8428
8623
|
setTimeout(()=>{delete b.dataset.flash;b.classList.remove('ok');b.textContent='Reversed beams';},1500);return;}
|
|
8429
8624
|
if(mode==='add'){mode='sel';setMode();}geoMode=null;setGeo();selDimIds.clear();selIds=new Set(ids);fitToWindow();render();
|
|
8430
8625
|
toast(ids.length+' reversed beam'+(ids.length>1?'s':'')+' selected — press P to swap direction');}; // select reversed → review → P swaps them
|
|
8626
|
+
document.getElementById('memberEndsB').onclick=scanMemberEnds;
|
|
8431
8627
|
document.getElementById('mrgB').onclick=()=>{const r=mergeCollinearJS(P.members); // conservative; result is undoable (Ctrl+Z)
|
|
8432
8628
|
if(!r.mergedAway){toast('Nothing to merge');return;}
|
|
8433
8629
|
// edit() returns FALSE on a refusal (and has already toasted the reason). The success toast must be
|
|
@@ -8449,6 +8645,7 @@ addEventListener('keydown',e=>{
|
|
|
8449
8645
|
// its own keydown stops them.
|
|
8450
8646
|
const _ae=document.activeElement||{};
|
|
8451
8647
|
const inForm=/^(INPUT|SELECT|TEXTAREA)$/.test(_ae.tagName)||_ae.id==='planTrigger';
|
|
8648
|
+
if(memberEndReview){if(e.key==='Escape'){e.preventDefault();closeMemberEndReview();}return;}
|
|
8452
8649
|
if(dimEdit){if(e.key==='Escape'){e.preventDefault();closeDimEdit();}return;} // F8 popup is modal — suppress every editor/tool shortcut (incl. Ctrl+Z under the popup). Its own input/buttons handle their keys and stopPropagation, so they never reach here (Codex R2 #8).
|
|
8453
8650
|
// A live drag-out to Tekla owns Escape: the 3D view cancels the gesture on its own handler (this one
|
|
8454
8651
|
// runs first). Without this, Escape would fall through to the deselect below and clear the very
|
|
@@ -8496,7 +8693,7 @@ addEventListener('keydown',e=>{
|
|
|
8496
8693
|
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
|
|
8497
8694
|
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
|
|
8498
8695
|
if(e.key==='Escape'&&view3d&&mode==='add'){if(cmHudIsOpen()){cmHudClose();return;}if(window.Steel3DView&&window.Steel3DView.drEscape&&window.Steel3DView.drEscape())return;} // 3D draw: Esc closes an open typed-entry HUD first, then drops the in-progress start pick, then exits add mode (falls through below)
|
|
8499
|
-
if(e.key==='Escape'&&!view3d&&mode==='add'&&drawDraft){drawDraft=null;drawPrevClear();render();return;} // 2D Add-member: 1st Esc drops the in-progress start point
|
|
8696
|
+
if(e.key==='Escape'&&!view3d&&mode==='add'&&drawDraft){drawDraft=null;drawBasisTok=null;drawPrevClear();render();return;} // 2D Add-member: 1st Esc drops the in-progress start point + frame snapshot
|
|
8500
8697
|
// Esc while typing the true distance leaves the BOX, and stops there. Without this the press falls all
|
|
8501
8698
|
// the way to the catch-all below — which is not guarded by `inForm` — and clears the user's member
|
|
8502
8699
|
// selection as the answer to "I have finished typing", which is not a thing they asked for.
|
|
@@ -9244,7 +9441,7 @@ const view3dApi={
|
|
|
9244
9441
|
closeCmHud:()=>{if(cmHudIsOpen())cmHudClose();}, // the view closes an open typed-entry HUD on frame drift / rebuild (invalidatePointEntry)
|
|
9245
9442
|
|
|
9246
9443
|
disarmAdd:()=>{if(mode==='add'){mode='sel';setMode();render();}},
|
|
9247
|
-
|
|
9444
|
+
onAddMember3d:(aMm,bMm,basis)=>{if(!basis||!basis.ok){positionRefuse('Profile Position unavailable: the captured 3D authoring axes are invalid.');return;}const k=304.8/((P&&P.pt_per_ft>0)?P.pt_per_ft:1),r6=n=>Math.round(n*1e6)/1e6; // mm → wp px (Y FLIPPED) + elevation inches
|
|
9248
9445
|
const wpA=[r6(aMm[0]/k),r6(-aMm[1]/k)],wpB=[r6(bMm[0]/k),r6(-bMm[1]/k)];
|
|
9249
9446
|
const zA=r6(aMm[2]/25.4),zB=r6(bMm[2]/25.4);
|
|
9250
9447
|
const hpx=Math.hypot(wpB[0]-wpA[0],wpB[1]-wpA[1]),hIn=hpx/FT*12,dzIn=Math.abs(zB-zA);
|
|
@@ -9252,10 +9449,11 @@ const view3dApi={
|
|
|
9252
9449
|
edit(()=>{let m;
|
|
9253
9450
|
if(hIn<6&&dzIn>6){m=ensureMeta({id,profile:addProfile,material:addMaterial||undefined,wp:[wpA.slice(),wpA.slice()],role:'column'}); // near-vertical run → a column at the plan point
|
|
9254
9451
|
m.col={bos:Math.min(zA,zB),tos:Math.max(zA,zB),note:'',tosDef:false,detail:''};}
|
|
9255
|
-
|
|
9452
|
+
else{const near=z=>Math.abs(z-defaultTOS)<0.5; // a pick ON the level stays default-linked
|
|
9256
9453
|
m=ensureMeta({id,profile:addProfile,material:addMaterial||undefined,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)
|
|
9257
9454
|
const mfNote=/(^|[^A-Z])MF/i.test(addProfile||'')?'moment':''; // a moment-frame profile keeps the auto note ensureMeta gives 2D-drawn members
|
|
9258
|
-
|
|
9455
|
+
m.ends=[{tos:near(zA)?null:zA,note:mfNote,tosDef:near(zA),detail:''},{tos:near(zB)?null:zB,note:mfNote,tosDef:near(zB),detail:''}];}
|
|
9456
|
+
if(!applyPositionAuthoringBasis(m,basis))throw new Error('Captured 3D authoring basis is invalid');
|
|
9259
9457
|
if((addType==='column')===(m.role==='column'))ModelCmd.setMemberType(m,addType); // 3D geometry decides column-vs-beam; only stamp the panel's type when it agrees with that role
|
|
9260
9458
|
m.rfi=(_wt(addProfile)==null);MC().addMembers(P,[m]);
|
|
9261
9459
|
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}
|
|
@@ -14950,7 +15148,7 @@ function reflectActivePane(){
|
|
|
14950
15148
|
// and Extend/Trim/Split (geoMode — the 3D view arms it via E/S and drives it through
|
|
14951
15149
|
// view3dApi.onTrimExtend/onSplit, so cancelling it would kill an active 3D trim).
|
|
14952
15150
|
function onActivePaneChange(){
|
|
14953
|
-
drawDraft=null;drawPrevClear();
|
|
15151
|
+
drawDraft=null;drawBasisTok=null;drawPrevClear();
|
|
14954
15152
|
let disarmed2d=gridMode||csaxisMode||picking;
|
|
14955
15153
|
if(gridMode)setGridMode(false);
|
|
14956
15154
|
if(csaxisMode){csaxisMode=false;setCsMode();}
|
|
@@ -15148,6 +15346,7 @@ let viewSeq=0; // monotonic per view switch — see the staleness check after
|
|
|
15148
15346
|
// show/hide/rebuild/fit: inferring those again from the DOM would be a second implementation of the rule
|
|
15149
15347
|
// the pure module exists to own.
|
|
15150
15348
|
async function setView(on,{remember=true}={}){
|
|
15349
|
+
if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before changing views.';panel();return;}
|
|
15151
15350
|
const seq=++viewSeq;
|
|
15152
15351
|
const mode=SplitView.sanitizeMode(on); // REQUESTED
|
|
15153
15352
|
const stageEl=document.getElementById('stagewrap');
|
|
@@ -15159,7 +15358,7 @@ async function setView(on,{remember=true}={}){
|
|
|
15159
15358
|
const want=resolved.mode; // EFFECTIVE
|
|
15160
15359
|
const effects=SplitView.nextMode(viewMode,want);
|
|
15161
15360
|
let failed=false; // a 3D open that threw: keep the shared tail, skip the persist
|
|
15162
|
-
drawDraft=null;drawPrevClear(); // any view switch drops an in-progress 2D Add-member start
|
|
15361
|
+
drawDraft=null;drawBasisTok=null;drawPrevClear(); // any view switch drops an in-progress 2D Add-member start + frame snapshot
|
|
15163
15362
|
// B6: cancel the 2D-only panel-takeover / armed-pick tools on any view switch. They have no 3D counterpart, so if
|
|
15164
15363
|
// left armed they take over the panel while you're in 3D or silently resume on return to 2D (the "active command
|
|
15165
15364
|
// survives a 2D↔3D switch" bug). Cross-view tools stay armed by design and setView only drops their in-progress
|
|
@@ -15184,7 +15383,8 @@ async function setView(on,{remember=true}={}){
|
|
|
15184
15383
|
// reverts for the same reason once the renderer exists; this branch is the path where it never did.
|
|
15185
15384
|
if(!window.Steel3DView){applyViewState('2d');toast('3D view unavailable (renderer failed to load)');return;} // stay in 2D
|
|
15186
15385
|
try{
|
|
15187
|
-
if(!view3dReady){window.Steel3DView.init(document.getElementById('stage3d'),view3dApi);view3dReady=true;
|
|
15386
|
+
if(!view3dReady){window.Steel3DView.init(document.getElementById('stage3d'),view3dApi);view3dReady=true;
|
|
15387
|
+
if(window.Steel3DView.onPositionAuthoringBasisChange)positionBasisViewUnsub=window.Steel3DView.onPositionAuthoringBasisChange(()=>{positionBasisFingerprint='';positionAuthoringBasis();});}
|
|
15188
15388
|
applyViewState(want);
|
|
15189
15389
|
window.Steel3DView.show();
|
|
15190
15390
|
updCS();if(typeof csSyncF3d==='function')csSyncF3d(); // reflect the (persisted) 3D local frame in the Axes chip IMMEDIATELY — before the awaited rebuild, else the chip shows a stale "Global" for the rebuild's duration (QA F14)
|
|
@@ -15231,6 +15431,7 @@ async function setView(on,{remember=true}={}){
|
|
|
15231
15431
|
// that survives that round trip today. The 2D pane keeps its viewBox; a narrower pane just shows less.
|
|
15232
15432
|
if(effects.show2d)render();
|
|
15233
15433
|
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
|
|
15434
|
+
if(memberEndReview&&memberEndScopeSig(memberEndReview.scope)!==memberEndScopeSig())invalidateMemberEndReview('The view changed — check member ends again.');
|
|
15234
15435
|
panel(); // repaint the inspector for the NOW-current view (view3d is final here): a cross-view tool stays armed but its in-progress draft was dropped above — Add-member's drawHint (:2288) and Move/Copy's cmHint are view-specific, so without this the panel keeps the stale 2D "Click 2: end" (drawDraft already null) instead of the 3D working-plane hint (and vice-versa on return)
|
|
15235
15436
|
refreshPropLabels3d();updatePropHint(); // push the label set to whichever view is now live (3D shows them; 2D hides the 3D host) + refresh the corner note
|
|
15236
15437
|
updCS();if(typeof csSyncF3d==='function')csSyncF3d(); // the Axes chip is view-scoped (2D=P.frame, 3D=frame3d) — resync it + the 3D-frame fields on every switch (applyViewState alone doesn't; Codex MAJOR 6)
|
|
@@ -16431,6 +16632,8 @@ function resetPlanViewState(i){
|
|
|
16431
16632
|
syncPlanSwitcher(i);}
|
|
16432
16633
|
// --- multi-plan: switch between all steel plan views ---
|
|
16433
16634
|
function setPlan(i){
|
|
16635
|
+
if(memberEndReview&&memberEndReview.busy){memberEndReview.live='Finish the current member-end action before changing views.';panel();return;}
|
|
16636
|
+
if(memberEndReview&&C.plans&&C.plans[i]&&memberEndReview.scope.kind==='active-view'&&memberEndReview.scope.viewId!==C.plans[i].sheet)invalidateMemberEndReview('The view changed — check member ends again.');
|
|
16434
16637
|
const canonical=C.plans[i];
|
|
16435
16638
|
if(!canonical){
|
|
16436
16639
|
NO_PLAN_VIEW=true;C.active=0;P={sheet:'',members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:0};
|