@floless/app 0.101.1 → 0.101.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +7 -2
- package/dist/schemas/steel.takeoff.v1.schema.json +5 -4
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +4 -2
- package/dist/web/grid-core.js +164 -44
- package/dist/web/steel-3d-core.js +110 -0
- package/dist/web/steel-3d-view.js +88 -50
- package/dist/web/steel-editor.html +109 -80
- package/dist/web/steel-view-generation.js +36 -2
- package/package.json +1 -1
|
@@ -424,6 +424,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
424
424
|
.gck{display:flex;align-items:center;gap:8px;color:var(--text);cursor:pointer;font-size:12px;padding:2px 0}
|
|
425
425
|
.gck input{accent-color:var(--brand);cursor:pointer;margin:0;width:14px;height:14px;flex:none} /* beat the panel's generic full-width input rule */
|
|
426
426
|
/* F11 generated views modal — baseline modal/tabs/inputs, sized for batch selection without crowding the 240px Views pane. */
|
|
427
|
+
#viewGenModal{z-index:60} /* the 3D toolbar is z:59; this modal must fully cover it, while later-appended toasts at z:60 and the z:80 tooltip still win */
|
|
427
428
|
#viewGenModal .mpanel{width:min(640px,92vw)}
|
|
428
429
|
#vgBody{display:flex;flex-direction:column;min-height:0}
|
|
429
430
|
#vgContext{padding:10px 14px;color:var(--mut);font-size:12px;border-bottom:1px solid var(--line)}
|
|
@@ -953,8 +954,8 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
953
954
|
Members + Connections open a type flyout (All on top). Default: everything on, so nothing is filtered. -->
|
|
954
955
|
<div id=selBar role=group aria-label="Selection filter">
|
|
955
956
|
<span class=lbl>Select</span>
|
|
956
|
-
<button data-cls=member data-fly=members aria-label="Members" data-tip="Members — click to choose which member types can be selected"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.6 stroke-linecap=round aria-hidden=true><path d="M4 4h10M4 14h10M9 4v10"/></svg><span class=car aria-hidden=true>▾</span></button>
|
|
957
|
-
<button data-cls=connection data-fly=connections aria-label="Connections" data-tip="Connections — click to choose which connection types can be selected"><svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="4" y="4" width="10" height="10" rx="1"/><circle cx="6.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="6.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/></svg><span class=car aria-hidden=true>▾</span></button>
|
|
957
|
+
<button data-cls=member data-fly=members aria-label="Members" data-tip="Members — click to choose which member types can be selected · Alt+click: toggle all types"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.6 stroke-linecap=round aria-hidden=true><path d="M4 4h10M4 14h10M9 4v10"/></svg><span class=car aria-hidden=true>▾</span></button>
|
|
958
|
+
<button data-cls=connection data-fly=connections aria-label="Connections" data-tip="Connections — click to choose which connection types can be selected · Alt+click: toggle all types"><svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="4" y="4" width="10" height="10" rx="1"/><circle cx="6.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="6.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/></svg><span class=car aria-hidden=true>▾</span></button>
|
|
958
959
|
<button data-cls=grid aria-label="Grid lines" data-tip="Grid lines — allow selecting grid lines (area-select / Ctrl+A)"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M6 2v14M12 2v14M2 6h14M2 12h14"/></svg></button>
|
|
959
960
|
<button data-cls=dim aria-label="Dimensions" data-tip="Dimensions — allow selecting dimensions"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M3 5v8M15 5v8M3 9h12M3 9l3-2M3 9l3 2M15 9l-3-2M15 9l-3 2"/></svg></button>
|
|
960
961
|
</div>
|
|
@@ -1922,7 +1923,7 @@ function gridSvg(){
|
|
|
1922
1923
|
geo.v.forEach((l,i)=>{s+=`<line class="gridln${gsel('gv:'+i)}" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}"/><line class="gridhit gv" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
1923
1924
|
geo.h.forEach((l,i)=>{s+=`<line class="gridln${gsel('gh:'+i)}" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}"/><line class="gridhit gh" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
1924
1925
|
(geo.lines||[]).forEach((l,i)=>{s+=`<line class="gridln${gsel('gl:'+(l.id!=null?l.id:i))}" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}"/><line class="gridhit gl" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
|
|
1925
|
-
const bub=(x,y,lb,ax,i,end)=>`<g class=gridbubg data-${ax}="${i}" data-end="${end}" data-tip="Grid ${esc(lb)} — drag to move or adjust · dbl-click to rename · click to
|
|
1926
|
+
const bub=(x,y,lb,ax,i,end)=>`<g class=gridbubg data-${ax}="${i}" data-end="${end}" data-tip="Grid ${esc(lb)} — drag to move or adjust · dbl-click to rename · click to select"><circle class=gridbub data-bx="${x}" data-by="${y}" cx="${x}" cy="${y}" r="${R}"/><text class=gridtx data-bx="${x}" data-by="${y}" x="${x}" y="${y}" style="font-size:${F}px">${esc(lb)}</text></g>`;
|
|
1926
1927
|
geo.v.forEach((l,i)=>{s+=bub(l.x,l.lo,l.label,'gv',i,0)+bub(l.x,l.hi,l.label,'gv',i,1);});
|
|
1927
1928
|
geo.h.forEach((l,i)=>{s+=bub(l.lo,l.y,l.label,'gh',i,0)+bub(l.hi,l.y,l.label,'gh',i,1);});
|
|
1928
1929
|
(geo.lines||[]).forEach((l,i)=>{s+=bub(l.a[0],l.a[1],l.label,'gl',i,0)+bub(l.b[0],l.b[1],l.label,'gl',i,1);});
|
|
@@ -1937,6 +1938,16 @@ function gridSelectables(){if(!gridOn())return [];const geo=gridGeo();if(!geo)re
|
|
|
1937
1938
|
(geo.h||[]).forEach((l,i)=>out.push({id:'gh:'+i,p1:[l.lo,l.y],p2:[l.hi,l.y]}));
|
|
1938
1939
|
(geo.lines||[]).forEach((l,i)=>out.push({id:'gl:'+(l.id!=null?l.id:i),p1:l.a.slice(),p2:l.b.slice()}));
|
|
1939
1940
|
return out;}
|
|
1941
|
+
// A grid bubble owns double-click rename, so its DOM identity must survive the first click. Rebuilding
|
|
1942
|
+
// svg.innerHTML (or even detaching/re-attaching #gridG) between the browser's two clicks prevents the
|
|
1943
|
+
// native dblclick event. Reflect this selection surgically; all geometry remains the same after a click.
|
|
1944
|
+
function reflect2dGridSelection(){const geo=gridGeo()||{};
|
|
1945
|
+
svg.querySelectorAll('#gridG line.gridln').forEach(line=>{let id=null;if(line.dataset.gv!=null)id='gv:'+line.dataset.gv;else if(line.dataset.gh!=null)id='gh:'+line.dataset.gh;else if(line.dataset.gl!=null){const g=(geo.lines||[])[+line.dataset.gl];id='gl:'+(g&&g.id!=null?g.id:line.dataset.gl);}line.classList.toggle('sel',!!id&&selGridIds.has(id));});
|
|
1946
|
+
svg.querySelectorAll('line.member,polygon.member,g.bracesym').forEach(el=>{const id=el.dataset.id,on=!!id&&selIds.has(id);el.classList.toggle('sel',on);if(!on&&!findHits.has(id))el.style.removeProperty('filter');});
|
|
1947
|
+
if(!selDimIds.size){svg.querySelectorAll('.dimsel').forEach(el=>el.classList.remove('dimsel'));svg.querySelectorAll('circle.dimhandle').forEach(el=>el.remove());} // an additive grid click keeps an already-selected dimension visibly selected; a plain grid click cleared selDimIds above
|
|
1948
|
+
if(!selIds.size)svg.querySelectorAll('circle.handle,circle.numbg,text.numtx,g.mlenlabels').forEach(el=>el.remove());
|
|
1949
|
+
panel();try{updateConnCrumb();}catch(_){}syncPropLabelsAfterRender();}
|
|
1950
|
+
function selectGridLine(id,additive,surgical=false){if(!id||!selGridOK())return;if(!additive){selDimIds.clear();sel3dDimIds.clear();selIds.clear();selGridIds=new Set([id]);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}else{selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}surgical?reflect2dGridSelection():render();} // additive grid picks preserve an intentional mixed dimension/grid selection in either click order
|
|
1940
1951
|
// selected grid lines → display rows {label,type} for the inspector (resolves labels/types from gridGeo)
|
|
1941
1952
|
function gridSelSummary(){const geo=gridGeo()||{};const out=[];
|
|
1942
1953
|
for(const id of selGridIds){
|
|
@@ -1987,10 +1998,14 @@ function gridRenameBubble(axis,gi,anchorEl){
|
|
|
1987
1998
|
else if(ev.key==='Escape'){ev.preventDefault();finish(false);}});
|
|
1988
1999
|
inp.addEventListener('blur',()=>finish(true));}
|
|
1989
2000
|
function validGridLine(l){return l&&Array.isArray(l.a)&&Array.isArray(l.b)&&isFinite(l.a[0])&&isFinite(l.a[1])&&isFinite(l.b[0])&&isFinite(l.b[1])&&Math.hypot(l.b[0]-l.a[0],l.b[1]-l.a[1])>1e-6;}
|
|
1990
|
-
function
|
|
2001
|
+
function gridLabelText(v){const s=String(v==null?'':v).trim(),gc=GC();return gc&&gc.truncateText?gc.truncateText(s,40):Array.from(s).slice(0,40).join('');}
|
|
2002
|
+
function sanitizeGridLines(g){if(!g)return;g.labels_z=Array.isArray(g.labels_z)?g.labels_z.map(gridLabelText):[];if(!Array.isArray(g.lines))return;const used=new Set();g.lines=g.lines.filter(validGridLine).map((l,i)=>{const root=String(l.id||('line-'+(i+1)));let id=root,n=2;while(used.has(id))id=root+'-'+n++;used.add(id);return{id,label:String(l.label||('L'+(i+1))),a:[+l.a[0],+l.a[1]],b:[+l.b[0],+l.b[1]]};});if(!g.lines.length)delete g.lines;}
|
|
2003
|
+
function sanitizePlanGrid(pl){if(!pl||pl.grid==null)return;const g=pl.grid;
|
|
2004
|
+
if(typeof g!=='object'||Array.isArray(g)||!Array.isArray(g.origin)||g.origin.length<2||!isFinite(g.origin[0])||!isFinite(g.origin[1])){console.warn('discarding malformed grid on '+pl.sheet);pl.grid=null;return;}
|
|
2005
|
+
sanitizeGridLines(g);}
|
|
1991
2006
|
function gridLineId(){return 'gl'+Date.now().toString(36)+Math.floor(Math.random()*1000).toString(36);}
|
|
1992
2007
|
function gridNextLineLabel(){const n=(P&&P.grid&&Array.isArray(P.grid.lines))?P.grid.lines.length+1:1;return 'L'+n;}
|
|
1993
|
-
function gridEnsureForLine(a){const gc=GC();if(P.grid)return;P.grid={on:true,origin:a.slice(),x:'',y:'',z:'0
|
|
2008
|
+
function gridEnsureForLine(a){const gc=GC();if(P.grid)return;P.grid={on:true,origin:a.slice(),x:'',y:'',z:"0'-0\"",labels_x:'',labels_y:'',labels_z:[],ext:gc?5*gc.FT_MM:1524,lines:[]};}
|
|
1994
2009
|
function gridAddFreeLine(a,b,label){const gc=GC();if(Math.hypot(b[0]-a[0],b[1]-a[1])<6/zoom){toast('Line is too short to create a grid line');return false;}
|
|
1995
2010
|
gridEnsureForLine(a);if(!Array.isArray(P.grid.lines))P.grid.lines=[];
|
|
1996
2011
|
P.grid.lines.push({id:gridLineId(),label:label||gridNextLineLabel(),a:a.slice(),b:b.slice()});return true;}
|
|
@@ -2013,7 +2028,8 @@ function gridReadFromDrawing(keep){
|
|
|
2013
2028
|
const g=r.grid;
|
|
2014
2029
|
if(keep){g.z=keep.z; // the user's levels always survive a re-read; their hand-set labels beat detected ones (the tooltip promises it)
|
|
2015
2030
|
if(keep.labels_x)g.labels_x=keep.labels_x;
|
|
2016
|
-
if(keep.labels_y)g.labels_y=keep.labels_y;
|
|
2031
|
+
if(keep.labels_y)g.labels_y=keep.labels_y;
|
|
2032
|
+
g.labels_z=Array.isArray(keep.labels_z)?keep.labels_z.slice():[];}
|
|
2017
2033
|
edit(()=>{P.grid=g;});
|
|
2018
2034
|
toast('Grid read from the drawing — '+r.info.v+' × '+r.info.h+' lines'+(r.info.labeled?'':'. Labels are auto — Ask AI can read the printed marks.'));}
|
|
2019
2035
|
// The bubble marks on most CAD sets are OUTLINED (not text), so the detector can't read them. The
|
|
@@ -2092,20 +2108,30 @@ function renderGridPanel(p){
|
|
|
2092
2108
|
const bb=document.getElementById('gridBlankB');if(bb)bb.onclick=()=>{const o=gridDefaultOrigin();edit(()=>{P.grid=gc.defaultGrid(o);});};
|
|
2093
2109
|
return;}
|
|
2094
2110
|
const g=P.grid,nCols=planColumnCount();
|
|
2111
|
+
const normSp=v=>{const r=gc.parseSpacings(v);return r.err?String(v||''):gc.formatSpacings(r.offsets);};
|
|
2112
|
+
const zParsed=gc.parseLevels(g.z,g.labels_z),normZ=zParsed.err?String(g.z||''):gc.formatLevels(zParsed.levels.map(l=>l.mm));
|
|
2113
|
+
const zLabels=Array.isArray(g.labels_z)?g.labels_z:[];
|
|
2114
|
+
const levelWarningText=r=>{const parts=[],dupSeen=new Set();for(const w of (r.warnings||[])){if(w.kind==='duplicate-label'||w.kind==='duplicate-level'){if(dupSeen.has(w.sourceIndex))continue;dupSeen.add(w.sourceIndex);const token=(r.tokens||[])[w.sourceIndex]||'this elevation';parts.push(w.kind==='duplicate-label'?`Duplicate elevation ${token}: the first label was kept; the later label remains saved as an extra.`:`Duplicate elevation ${token} was ignored.`);}}const orphan=(r.warnings||[]).filter(w=>w.kind==='orphan-label').length;if(orphan)parts.push(`${orphan} saved label${orphan===1?' has':'s have'} no matching elevation.`);return parts.join(' ');};
|
|
2115
|
+
const zNormalizedLabels=gc.normalizeLevelLabels(zParsed,zLabels),zWarningText=levelWarningText(zParsed),zExtraCount=zNormalizedLabels.extraCount;
|
|
2116
|
+
const zLabelRows=zParsed.err?'':zParsed.levels.map((lv,i)=>`<label class=vgfield style="margin-top:6px"><span>${esc(gc.fmtLen(lv.mm))}</span><input class=gin data-zlabel="${i}" value="${esc(zLabels[lv.sourceIndex]||'')}" placeholder="${esc(gc.fmtLen(lv.mm))}" autocomplete=off spellcheck=false></label>`).join('');
|
|
2095
2117
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
2096
2118
|
<div class=hint style="margin-top:8px">A plan reference — doesn't constrain members. <b>n*d</b> repeats a bay (e.g. <b>3*25'</b>); tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>
|
|
2097
2119
|
<label class=gck style="margin-top:10px"><input type=checkbox id=gShow ${gridOn()?'checked':''}><span>Show grid lines</span></label>
|
|
2098
2120
|
<div class=sect style="margin-top:12px">X spacings <span style="color:var(--mut);font-weight:400;text-transform:none">· lines 1, 2, 3…</span></div>
|
|
2099
|
-
<input id=gX class=gin value="${esc(g.x
|
|
2121
|
+
<input id=gX class=gin value="${esc(normSp(g.x))}" placeholder="e.g. 0'-0", 3*25'-0", 20'-6 1/2"" autocomplete=off spellcheck=false>
|
|
2100
2122
|
<div id=gXfb class=gfb></div>
|
|
2101
2123
|
<div class=sect style="margin-top:10px">Y spacings <span style="color:var(--mut);font-weight:400;text-transform:none">· lines A, B, C…</span></div>
|
|
2102
|
-
<input id=gY class=gin value="${esc(g.y
|
|
2124
|
+
<input id=gY class=gin value="${esc(normSp(g.y))}" placeholder="e.g. 0'-0", 4*30'-0"" autocomplete=off spellcheck=false>
|
|
2103
2125
|
<div id=gYfb class=gfb></div>
|
|
2104
2126
|
<div class=sect style="margin-top:10px">Levels (Z)</div>
|
|
2105
|
-
<input id=gZ class=gin value="${esc(
|
|
2127
|
+
<input id=gZ class=gin value="${esc(normZ)}" placeholder="e.g. 0'-0", 16'-6", 33'-0"" autocomplete=off spellcheck=false>
|
|
2106
2128
|
<div id=gZfb class=gfb></div>
|
|
2107
2129
|
<div class=hint style="margin-top:3px">Absolute elevations, one per level — shown as tags in the 3D view.</div>
|
|
2108
|
-
<div class=sect style="margin-top:10px">
|
|
2130
|
+
<div class=sect style="margin-top:10px">Z elevation labels</div>
|
|
2131
|
+
${zLabelRows||'<div class=gfb>No readable Z elevations to label.</div>'}
|
|
2132
|
+
${zWarningText?`<div id=gZwarn class=gerr role=status>${esc(zWarningText)}</div>`:''}
|
|
2133
|
+
${zExtraCount?`<button id=gridDropZLabels class=ghostw style="margin-top:7px" data-tip="Remove only saved Z labels that no longer have a matching elevation. Undoable.">Remove ${zExtraCount} extra label${zExtraCount===1?'':'s'}</button>`:''}
|
|
2134
|
+
<div class=sect style="margin-top:10px">Grid labels (X / Y)</div>
|
|
2109
2135
|
<div style="display:flex;gap:6px"><input id=gLX class=gin value="${esc(g.labels_x||'')}" placeholder="auto: 1 2 3…" autocomplete=off spellcheck=false><input id=gLY class=gin value="${esc(g.labels_y||'')}" placeholder="auto: A B C…" autocomplete=off spellcheck=false></div>
|
|
2110
2136
|
<div id=gLfb class=gfb></div>
|
|
2111
2137
|
${(!g.labels_x&&!g.labels_y)?'<div class=gbtns style="margin-top:6px"><button id=gridLabelsAiB class=ghostw data-tip="Many drawings outline their bubble text, so the marks can’t be read deterministically. This sends a request to your AI terminal — it reads the printed marks from the source drawing and fills the labels as a contract update.">Ask AI to read the labels ▸</button></div>':''}
|
|
@@ -2122,22 +2148,23 @@ function renderGridPanel(p){
|
|
|
2122
2148
|
<div class=gbtns style="margin-top:16px"><button id=gridRemoveB class=ghostw style="flex:1" data-tip="Delete all grid lines and levels. Undoable.">Remove grid</button><button id=gridDoneB>Done</button></div>`;
|
|
2123
2149
|
const fbSpacing=(inpId,fbId,style,override,emptyMsg)=>{
|
|
2124
2150
|
const el=document.getElementById(fbId),v=document.getElementById(inpId).value;
|
|
2125
|
-
|
|
2151
|
+
const r=gc.parseSpacings(v);
|
|
2152
|
+
document.getElementById(inpId).setAttribute('aria-invalid',String(!!r.err));
|
|
2126
2153
|
if(r.err){el.className='gerr';el.textContent=r.err.replace(/^c/,'C')+(r.err.indexOf('read')>=0?" — expected n*distance, like 3*25'.":'');return;}
|
|
2127
2154
|
el.className='gfb';
|
|
2128
2155
|
if(!r.offsets.length){el.textContent=emptyMsg;return;}
|
|
2129
2156
|
const lbs=gc.labelsFor(document.getElementById(override).value,style,r.offsets.length);
|
|
2130
2157
|
const run=r.offsets[r.offsets.length-1]-r.offsets[0];
|
|
2131
2158
|
el.textContent=r.offsets.length+' line'+(r.offsets.length===1?'':'s')+' · '+lbs[0]+(r.offsets.length>1?'–'+lbs[lbs.length-1]:'')+(run>0?' · '+gc.fmtLen(run)+' total':'');};
|
|
2132
|
-
const
|
|
2133
|
-
|
|
2134
|
-
|
|
2159
|
+
const fbZ2=()=>{const el=document.getElementById('gZfb'),inp=document.getElementById('gZ'),r=gc.parseLevels(inp.value,g.labels_z);inp.setAttribute('aria-invalid',String(!!r.err));
|
|
2160
|
+
if(r.err){el.className='gerr';el.textContent=r.err;return;}
|
|
2161
|
+
const warning=levelWarningText(r),count=r.levels.length?(r.levels.length+' level'+(r.levels.length===1?'':'s')):'No levels — grid draws at elevation 0 in 3D.';el.className=warning?'gerr':'gfb';el.textContent=count+(warning?' · '+warning:'');};
|
|
2135
2162
|
const fbLabels=()=>{const el=document.getElementById('gLfb');
|
|
2136
2163
|
for(const [id,style,n] of [['gLX','num',gc.parseSpacings(document.getElementById('gX').value).offsets.length],['gLY','alpha',gc.parseSpacings(document.getElementById('gY').value).offsets.length]]){
|
|
2137
2164
|
const lbs=gc.labelsFor(document.getElementById(id).value,style,n),seen=new Set();
|
|
2138
2165
|
for(const lb of lbs){if(seen.has(lb)){el.className='gerr';el.textContent='Duplicate label “'+lb+'” — labels must be unique per direction.';return;}seen.add(lb);}}
|
|
2139
2166
|
el.className='gfb';el.textContent='';};
|
|
2140
|
-
const fbAll=()=>{fbSpacing('gX','gXfb','num','gLX','No X lines — grid runs Y only.');fbSpacing('gY','gYfb','alpha','gLY','No Y lines — grid runs X only.');
|
|
2167
|
+
const fbAll=()=>{fbSpacing('gX','gXfb','num','gLX','No X lines — grid runs Y only.');fbSpacing('gY','gYfb','alpha','gLY','No Y lines — grid runs X only.');fbZ2();fbLabels();};
|
|
2141
2168
|
fbAll();
|
|
2142
2169
|
// commit on change (blur/Enter); Esc restores the field; keystrokes refresh only the feedback line
|
|
2143
2170
|
const wire=(id,commit)=>{const el=document.getElementById(id),orig=el.value;
|
|
@@ -2146,24 +2173,26 @@ function renderGridPanel(p){
|
|
|
2146
2173
|
if(ev.key==='Enter'){ev.preventDefault();el.blur();}
|
|
2147
2174
|
else if(ev.key==='Escape'){ev.preventDefault();el.value=orig;fbAll();}});
|
|
2148
2175
|
el.addEventListener('change',()=>commit(el.value.trim(),el));};
|
|
2149
|
-
wire('gX',(v)=>{const r=gc.parseSpacings(v);if(r.err)return;if(
|
|
2176
|
+
wire('gX',(v,el)=>{const r=gc.parseSpacings(v);if(r.err)return;const next=gc.formatSpacings(r.offsets);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.x||''))edit(()=>{ // a changed LINE COUNT invalidates the index-keyed per-line ends (they'd re-bind to the wrong lines)
|
|
2150
2177
|
if(P.grid.ends_x&&r.offsets.length!==gc.parseSpacings(P.grid.x).offsets.length)delete P.grid.ends_x;
|
|
2151
|
-
P.grid.x=
|
|
2152
|
-
wire('gY',(v)=>{const r=gc.parseSpacings(v);if(r.err)return;if(
|
|
2178
|
+
P.grid.x=next;});});
|
|
2179
|
+
wire('gY',(v,el)=>{const r=gc.parseSpacings(v);if(r.err)return;const next=gc.formatSpacings(r.offsets);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.y||''))edit(()=>{
|
|
2153
2180
|
if(P.grid.ends_y&&r.offsets.length!==gc.parseSpacings(P.grid.y).offsets.length)delete P.grid.ends_y;
|
|
2154
|
-
P.grid.y=
|
|
2155
|
-
wire('gZ',(v)=>{const
|
|
2181
|
+
P.grid.y=next;});});
|
|
2182
|
+
wire('gZ',(v,el)=>{const r=gc.parseLevels(v);if(r.err)return;const next=gc.formatLevels(r.levels.map(l=>l.mm)),old=Array.isArray(g.labels_z)?g.labels_z:[],labels=gc.reconcileLevelLabels(zParsed,zNormalizedLabels.labels,r).labels,warning=levelWarningText(r);if(el.value!==next){el.value=next;fbAll();}if(next!==(g.z||'')||JSON.stringify(labels)!==JSON.stringify(old))edit(()=>{P.grid.z=next;P.grid.labels_z=labels;});if(warning)toast(warning);});
|
|
2156
2183
|
wire('gLX',(v)=>{if(v!==(g.labels_x||''))edit(()=>{P.grid.labels_x=v;});});
|
|
2157
2184
|
wire('gLY',(v)=>{if(v!==(g.labels_y||''))edit(()=>{P.grid.labels_y=v;});});
|
|
2185
|
+
document.querySelectorAll('[data-zlabel]').forEach(el=>{const orig=el.value;el.addEventListener('input',()=>{const limited=gc.truncateText(el.value,40);if(limited!==el.value)el.value=limited;});el.addEventListener('keydown',ev=>{ev.stopPropagation();if(ev.key==='Enter'){ev.preventDefault();el.blur();}else if(ev.key==='Escape'){ev.preventDefault();el.value=orig;}});el.addEventListener('change',()=>{const i=+el.dataset.zlabel,nv=gc.truncateText(el.value.trim(),40),labels=zNormalizedLabels.labels.slice();if(labels[i]===nv&&g.z===normZ)return;labels[i]=nv;edit(()=>{P.grid.z=normZ;P.grid.labels_z=labels;});});});
|
|
2158
2186
|
wire('gExt',(v,el)=>{const mm=gc.parseLen(v);if(!isFinite(mm)||mm<0){el.style.borderColor='#fca5a5';return;}el.style.borderColor='';if(Math.abs(mm-(isFinite(g.ext)?g.ext:1524))>0.5)edit(()=>{P.grid.ext=mm;});});
|
|
2159
2187
|
const gsh=document.getElementById('gShow');if(gsh)gsh.addEventListener('change',()=>gridSetVisible(gsh.checked));
|
|
2160
2188
|
const grx=document.getElementById('gridResetExtB');if(grx)grx.onclick=()=>{edit(()=>{delete P.grid.ends_x;delete P.grid.ends_y;});}; // drop every per-line extent override → all lines follow the global Extension again
|
|
2189
|
+
const gdz=document.getElementById('gridDropZLabels');if(gdz)gdz.onclick=()=>{const labels=zNormalizedLabels.labels.slice(0,zParsed.levels.length);edit(()=>{P.grid.z=normZ;P.grid.labels_z=labels;});toast(`${zExtraCount} extra Z label${zExtraCount===1?'':'s'} removed`);}; // labels are sorted by elevation, so canonicalize z in the same atomic edit (an imported unsorted z must not rebind them by source index)
|
|
2161
2190
|
document.getElementById('gridLineB').onclick=gridStartLinePick;
|
|
2162
2191
|
const gcl=document.getElementById('gridClearLinesB');if(gcl)gcl.onclick=()=>{edit(()=>{delete P.grid.lines;});};
|
|
2163
2192
|
document.getElementById('gridPickB').onclick=()=>{gridPick=!gridPick;gridLinePick=null;gridSetPickClass();panel();};
|
|
2164
2193
|
const r2=document.getElementById('gridReadB2');if(r2)r2.onclick=()=>gridReadFromDrawing(P.grid);
|
|
2165
2194
|
const lb=document.getElementById('gridLabelsAiB');if(lb)lb.onclick=gridAskAiLabels;
|
|
2166
|
-
const a2=document.getElementById('gridAutoB2');if(a2)a2.onclick=()=>{const ng=gc.inferGrid(P.members,ppf);if(!ng){toast('No columns to infer a grid from');return;}ng.z=P.grid.z;ng.labels_x=P.grid.labels_x;ng.labels_y=P.grid.labels_y;ng.ext=P.grid.ext;edit(()=>{P.grid=ng;});}; // re-infer geometry, keep the user's levels/labels/extension
|
|
2195
|
+
const a2=document.getElementById('gridAutoB2');if(a2)a2.onclick=()=>{const ng=gc.inferGrid(P.members,ppf);if(!ng){toast('No columns to infer a grid from');return;}ng.z=P.grid.z;ng.labels_x=P.grid.labels_x;ng.labels_y=P.grid.labels_y;ng.labels_z=Array.isArray(P.grid.labels_z)?P.grid.labels_z.slice():[];ng.ext=P.grid.ext;edit(()=>{P.grid=ng;});}; // re-infer geometry, keep the user's levels/labels/extension
|
|
2167
2196
|
document.getElementById('gridRemoveB').onclick=()=>{edit(()=>{P.grid=null;});};
|
|
2168
2197
|
document.getElementById('gridDoneB').onclick=()=>{setGridMode(false);render();};
|
|
2169
2198
|
}
|
|
@@ -2345,7 +2374,7 @@ function render(){
|
|
|
2345
2374
|
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)
|
|
2346
2375
|
svg.innerHTML=s; document.getElementById('profiles').innerHTML=profs.map(p=>`<option value="${esc(p)}">`).join(''); document.getElementById('details').innerHTML=(P.details||[]).map(d=>`<option value="${esc(d.text)}">`).join(''); stats(); panel(); updUR(); updDup(); updConf(); updCS(); updConnBtn(); updBpBtn(); updSpBtn(); updGridToggle(); updLenToggle(); updDimToggle(); updCalloutToggle(); updPlToggle(); updRefToggle();
|
|
2347
2376
|
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()).
|
|
2348
|
-
if(view3d&&window.Steel3DView){window.Steel3DView.setSelection(selIds);updateIsolateBtn();if(selIds.size&&window.Steel3DView.selectedClips&&window.Steel3DView.selectedClips().length)window.Steel3DView.setSelectedClips([]);refreshLegendSel();} // keep the 3D
|
|
2377
|
+
if(view3d&&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)
|
|
2349
2378
|
try{updateConnCrumb();}catch(_){} // Connection Component breadcrumb follows the selection (3D-only; hidden at root)
|
|
2350
2379
|
syncPropLabelsAfterRender(); // corner-note + push labels to 3D + refresh the popup rows against the (possibly changed) selection
|
|
2351
2380
|
}
|
|
@@ -2434,17 +2463,17 @@ function selTree(){
|
|
|
2434
2463
|
// Shift-range; treeAnchor = the range anchor; treeExpanded = which connection nodes are open (transient).
|
|
2435
2464
|
let treeExpanded=new Set(), treeAnchor=null, treeRowIds=[];
|
|
2436
2465
|
function treeSelectLeaf(id,mods){
|
|
2437
|
-
let next;
|
|
2466
|
+
const additive=!!(mods&&(mods.ctrl||mods.meta));let next;
|
|
2438
2467
|
if(mods&&mods.shift&&treeAnchor!=null&&treeRowIds.includes(treeAnchor)&&treeRowIds.includes(id)){const i0=treeRowIds.indexOf(treeAnchor),i1=treeRowIds.indexOf(id);next=treeRowIds.slice(Math.min(i0,i1),Math.max(i0,i1)+1);}
|
|
2439
|
-
else if(
|
|
2468
|
+
else if(additive){next=new Set(selIds);next.has(id)?next.delete(id):next.add(id);next=[...next];treeAnchor=id;}
|
|
2440
2469
|
else{next=[id];treeAnchor=id;}
|
|
2441
|
-
selIds=new Set(next);selDimIds.clear();sel3dDimIds.clear();render();
|
|
2470
|
+
selIds=new Set(next);selDimIds.clear();sel3dDimIds.clear();if(!additive)selGridIds.clear();render();
|
|
2442
2471
|
}
|
|
2443
2472
|
function treeSelectConn(conn,mods){
|
|
2444
2473
|
const cids=connChildIdsEditor(conn);
|
|
2445
2474
|
if(mods&&(mods.ctrl||mods.meta)){const next=new Set(selIds);const all=cids.length&&cids.every(id=>next.has(id));cids.forEach(id=>all?next.delete(id):next.add(id));selIds=next;selDimIds.clear();sel3dDimIds.clear();treeAnchor=cids[0]||null;render();}
|
|
2446
2475
|
else if(window.Steel3DView&&window.Steel3DView.selectWholeConn){window.Steel3DView.selectWholeConn(conn);treeAnchor=cids[0]||null;} // plain → whole connection (envelope + inspector), same as a 3D click
|
|
2447
|
-
else{selIds=new Set(cids);selDimIds.clear();sel3dDimIds.clear();treeAnchor=cids[0]||null;render();}
|
|
2476
|
+
else{selIds=new Set(cids);selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();treeAnchor=cids[0]||null;render();}
|
|
2448
2477
|
}
|
|
2449
2478
|
// The floating breadcrumb over the 3D canvas: Model ▸ <Connection> [▸ <Part>]. Segments jump levels via the
|
|
2450
2479
|
// 3D view's own ascend/whole-select so the canvas selection + envelope stay in lockstep. 3D-only; hidden at root.
|
|
@@ -2628,7 +2657,7 @@ function panel(){
|
|
|
2628
2657
|
<button class=danger id=cmpDel data-tip="Remove this whole imported connection">Delete connection</button>
|
|
2629
2658
|
<button class=ghostw id=cmpFav data-tip="Save this imported geometry to your Favourites — drops in place, will not re-fit">★ Save to Favourites</button>
|
|
2630
2659
|
</div>`;
|
|
2631
|
-
{const b=document.getElementById('cmpMember');if(b)b.onclick=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();render();};}
|
|
2660
|
+
{const b=document.getElementById('cmpMember');if(b)b.onclick=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();render();};}
|
|
2632
2661
|
{const b=document.getElementById('cmpAsk');if(b)b.onclick=()=>connModifyRequest(j);}
|
|
2633
2662
|
{const b=document.getElementById('cmpDel');if(b)b.onclick=()=>edit(()=>{C.joints=(C.joints||[]).filter(x=>x!==j);selIds.clear();});}
|
|
2634
2663
|
{const b=document.getElementById('cmpFav');if(b)b.onclick=()=>openFavModalFor(j);}
|
|
@@ -2656,7 +2685,7 @@ function panel(){
|
|
|
2656
2685
|
<button class=danger id=cmpDel data-tip="Remove this whole connection">Delete connection</button>
|
|
2657
2686
|
<button class="ghostw${savedFav?' faved':''}" id=cmpFav data-tip="${savedFav?'Edit this favourite’s name or category':('Save this connection to your Favourites — reusable on any '+(isBP?'column':'beam'))}">${savedFav?'★ Saved to Favourites':'★ Save to Favourites'}</button>
|
|
2658
2687
|
</div>`;
|
|
2659
|
-
const toMember=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();render();};
|
|
2688
|
+
const toMember=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();render();};
|
|
2660
2689
|
{const b=document.getElementById('cmpMember');if(b)b.onclick=toMember;}
|
|
2661
2690
|
{const b=document.getElementById('cmpEdit');if(b)b.onclick=toMember;}
|
|
2662
2691
|
{const b=document.getElementById('cmpTrim');if(b)b.onclick=()=>armBaseTrim(j.main);}
|
|
@@ -2724,7 +2753,7 @@ function panel(){
|
|
|
2724
2753
|
<div class=divrow><hr></div>
|
|
2725
2754
|
<div class="row f" style="gap:6px;flex-wrap:wrap"><button class=ghostw id=partBack data-tip="Back to the whole connection (Esc)">◂ Connection</button><button class=ghostw id=partEdit data-tip="Select the parent member to edit this connection">✎ Edit on ${esc(j.main)} →</button></div>`;
|
|
2726
2755
|
{const bb=document.getElementById('partBack');if(bb)bb.onclick=()=>{if(window.Steel3DView&&window.Steel3DView.ascendConn)window.Steel3DView.ascendConn();};}
|
|
2727
|
-
const eb=document.getElementById('partEdit');if(eb)eb.onclick=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();render();};
|
|
2756
|
+
const eb=document.getElementById('partEdit');if(eb)eb.onclick=()=>{if(window.Steel3DView&&window.Steel3DView.clearConnSel)window.Steel3DView.clearConnSel();selIds=new Set([j.main]);selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();render();};
|
|
2728
2757
|
return;
|
|
2729
2758
|
}}
|
|
2730
2759
|
if(selGridIds.size&&!selIds.size&&!selDimIds.size&&!view3d&&mode==='sel'){ // grid-only selection → a grid inspector (was falling through to the Legend)
|
|
@@ -4015,21 +4044,21 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
4015
4044
|
e.preventDefault();return;}
|
|
4016
4045
|
if(gridPick){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear(); // armed pick-origin → one snapped click sets the grid's 1-A corner (undoable)
|
|
4017
4046
|
gridPick=false;gridSetPickClass();if(P.grid)edit(()=>{P.grid.origin=[x,y];});else panel();e.preventDefault();return;}
|
|
4018
|
-
{const gb=t.closest&&t.closest('g.gridbubg'),ghit=(t.classList&&t.classList.contains('gridhit'))?t:null; // grid line body OR label bubble → drag slides the line
|
|
4047
|
+
{const gb=t.closest&&t.closest('g.gridbubg'),ghit=(t.classList&&t.classList.contains('gridhit'))?t:null; // grid line body OR label bubble → drag slides the line; a no-move click selects it (bubble double-click still renames)
|
|
4019
4048
|
const gel=gb||ghit;
|
|
4020
4049
|
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&P.grid){
|
|
4021
4050
|
const free=gel.dataset.gl!=null,axis=free?'l':(gel.dataset.gv!=null?'v':'h'),gi=+(free?gel.dataset.gl:(gel.dataset.gv!=null?gel.dataset.gv:gel.dataset.gh));
|
|
4022
4051
|
if(isFinite(gi)){buildSnap(null,{noGrid:true,noDims:true});const q=toSvg(e);const geo=gridGeo();const line=geo&&(free?(geo.lines||[])[gi]:geo[axis][gi]);
|
|
4023
4052
|
if(line){const end=gb?+(gb.dataset.end||0):null; // a bubble grab can become an END drag; a body grab translates the line
|
|
4024
|
-
if(free)drag={type:'gridfree',gi,startPt:[q.x,q.y],origA:line.a.slice(),origB:line.b.slice(),end,bubble:!!gb,moved:false,pre:snapshot()};
|
|
4053
|
+
if(free)drag={type:'gridfree',gi,startPt:[q.x,q.y],origA:line.a.slice(),origB:line.b.slice(),end,bubble:!!gb,moved:false,add:e.ctrlKey||e.metaKey||e.shiftKey,pre:snapshot()};
|
|
4025
4054
|
else drag={type:'gridline',axis,gi,startPt:[q.x,q.y],orig:axis==='v'?line.x:line.y,origEnd:end===0?line.lo:line.hi,end,
|
|
4026
|
-
base:geo[axis].map(l=>axis==='v'?l.x:l.y),bubble:!!gb,moved:false,dir:null,pre:snapshot()}; // base = dragstart positions so one drag quantizes the string ONCE (no 1/16" creep on unmoved lines)
|
|
4055
|
+
base:geo[axis].map(l=>axis==='v'?l.x:l.y),bubble:!!gb,moved:false,add:e.ctrlKey||e.metaKey||e.shiftKey,dir:null,pre:snapshot()}; // base = dragstart positions so one drag quantizes the string ONCE (no 1/16" creep on unmoved lines)
|
|
4027
4056
|
svg.setPointerCapture(e.pointerId);e.preventDefault();return;}}}}
|
|
4028
4057
|
if(gridMode)setGridMode(false); // any other canvas click leaves the grid panel — selection takes the panel back (fields commit on blur first)
|
|
4029
4058
|
if(dimStyleMode)setDimStyleMode(false); // …and the Dimension style pane, so clicking a dim hands the panel to its inspector
|
|
4030
4059
|
if(dimSplitMode&&selDimIds.size&&dimsVisible&&mode==='sel'){let q=toSvg(e),x=q.x,y=q.y;if(!e.altKey){buildSnap(null);const sn=snap(x,y);x=sn.x;y=sn.y;}snapClear();dimSplitAt([x,y]);e.preventDefault();return;} // split mode → each click inserts a point into the selected dim under it
|
|
4031
4060
|
if(t.dataset.dimend!=null&&mode==='sel'){const id=t.dataset.dim,end=+t.dataset.dimend;buildSnap(id);drag={type:'dimend',id,end,pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // drag a selected dim's anchor handle → re-measure (snaps; exclude this dim so the end can't snap to its own line/midpoint)
|
|
4032
|
-
if(t.dataset.dim&&mode==='sel'&&selDimOK()){const did=t.dataset.dim;selIds.clear(); // a dim click is
|
|
4061
|
+
if(t.dataset.dim&&mode==='sel'&&selDimOK()){const did=t.dataset.dim,add=e.ctrlKey||e.metaKey;selIds.clear();if(!add)selGridIds.clear(); // a plain dim click is exclusive (clears member + grid selection); Ctrl keeps an intentional mixed grid/dim selection. Dimensions select-switch off → click falls through (inert)
|
|
4033
4062
|
if(e.ctrlKey||e.metaKey){selDimIds.has(did)?selDimIds.delete(did):selDimIds.add(did);render();return;} // Ctrl+click toggles this dim within the dim selection
|
|
4034
4063
|
selDimIds=new Set([did]);const d=P.dims.find(x=>x.id===did); // plain click → exactly this dim (collapses any multi-selection, so Delete removes only it)
|
|
4035
4064
|
if(d){drag={type:'dim',id:d.id,pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();}render();return;} // drag the dim line to slide its offset
|
|
@@ -4183,20 +4212,12 @@ svg.addEventListener('pointermove',e=>{
|
|
|
4183
4212
|
m.wp[drag.h]=[x,y];updateLine(m);updateHandles(m);
|
|
4184
4213
|
{let g=document.getElementById('epPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='epPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}epPrevDraw(g,drag.orig,drag.anchor,[x,y],m);}}); // live moved + length readout
|
|
4185
4214
|
svg.addEventListener('pointerup',()=>{if(!drag)return;snapClear();epPrevClear();
|
|
4186
|
-
if(drag.type==='gridfree'){const
|
|
4187
|
-
if(!moved){
|
|
4188
|
-
svg.querySelectorAll('line.member.sel,polygon.member.sel').forEach(n=>{n.classList.remove('sel');n.style.filter='';});svg.querySelectorAll('g.bracesym').forEach(n=>{n.classList.remove('sel');n.style.filter='';});
|
|
4189
|
-
svg.querySelectorAll('circle.handle,circle.dimhandle,circle.numbg,text.numtx').forEach(n=>n.remove());
|
|
4190
|
-
svg.querySelectorAll('.dimsel').forEach(n=>n.classList.remove('dimsel'));svg.querySelectorAll('line.gridln.sel').forEach(n=>n.classList.remove('sel'));} // grid mode clears selGridIds (data); drop the highlight VISUAL too since this path does no render()
|
|
4191
|
-
return;}
|
|
4215
|
+
if(drag.type==='gridfree'){const moved=drag.moved,pre=drag.pre,add=drag.add,geo=gridGeo(),line=geo&&(geo.lines||[])[drag.gi],gid='gl:'+(line&&line.id!=null?line.id:drag.gi);drag=null;gridReadoutHide();snapOnlyClear2d();
|
|
4216
|
+
if(!moved){selectGridLine(gid,add,true);return;}
|
|
4192
4217
|
if(pre&&snapshot()!==pre)pushUndo(pre);refresh3DGrid();render();return;}
|
|
4193
|
-
if(drag.type==='gridline'){const
|
|
4218
|
+
if(drag.type==='gridline'){const moved=drag.moved,pre=drag.pre,add=drag.add,gid=(drag.axis==='v'?'gv:':'gh:')+drag.gi;drag=null;gridReadoutHide();
|
|
4194
4219
|
snapOnlyClear2d(); // a grid-line drag is one discrete operation → its single-shot snap override always reverts (grid-line drags can run while the grid panel is open, so don't gate on anyToolActive())
|
|
4195
|
-
if(!moved){
|
|
4196
|
-
svg.querySelectorAll('line.member.sel,polygon.member.sel').forEach(n=>{n.classList.remove('sel');n.style.filter='';});svg.querySelectorAll('g.bracesym').forEach(n=>{n.classList.remove('sel');n.style.filter='';}); // …so drop the stale selection VISUALS surgically instead
|
|
4197
|
-
svg.querySelectorAll('circle.handle,circle.dimhandle,circle.numbg,text.numtx').forEach(n=>n.remove());
|
|
4198
|
-
svg.querySelectorAll('.dimsel').forEach(n=>n.classList.remove('dimsel'));svg.querySelectorAll('line.gridln.sel').forEach(n=>n.classList.remove('sel'));} // grid mode clears selGridIds (data); drop the highlight VISUAL too since this path does no render()
|
|
4199
|
-
return;} // a no-move line-body click is a no-op (selection untouched)
|
|
4220
|
+
if(!moved){selectGridLine(gid,add,true);return;}
|
|
4200
4221
|
if(pre&&snapshot()!==pre)pushUndo(pre);refresh3DGrid();render();return;}
|
|
4201
4222
|
if(drag.type==='marquee'){const r=drag.cur,win=drag.window!==false,add=drag.add;
|
|
4202
4223
|
if(r&&(r[2]-r[0]>2||r[3]-r[1]>2)){
|
|
@@ -4379,12 +4400,13 @@ addEventListener('keydown',e=>{
|
|
|
4379
4400
|
else if(k==='y'||(k==='z'&&e.shiftKey)){e.preventDefault();doRedo();}
|
|
4380
4401
|
else if(k==='d'&&selIds.size){e.preventDefault();doDup();}
|
|
4381
4402
|
else if(k==='a'&&!inForm){e.preventDefault(); // Ctrl+A — select all MEMBERS (honouring the Members switch) plus, in 2D, the visible dims + grid lines. Was: active-plan members only, and it CLEARED dims + never grabbed grids.
|
|
4382
|
-
// Scope to what's VISIBLE: 3D
|
|
4383
|
-
|
|
4403
|
+
// Scope to what's VISIBLE: 3D asks the renderer for visible member meshes after legend/isolate/work-area filtering; 2D uses the active plan (matching its marquee). Connections + 3D dims are picked by click/box, not swept by Ctrl+A.
|
|
4404
|
+
const memberIds=view3d?(window.Steel3DView&&window.Steel3DView.visibleMemberIds?window.Steel3DView.visibleMemberIds():[]):P.members.map(m=>m.id);
|
|
4405
|
+
selIds=new Set(memberIds.filter(id=>{const m=byId(id);return m&&selMemberOK(m);}));
|
|
4384
4406
|
selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();
|
|
4385
|
-
if(
|
|
4407
|
+
if(selGridOK())selGridIds=new Set(gridSelectables().map(g=>g.id));
|
|
4408
|
+
if(!view3d){ // the 2D-drawable dimensions join the sweep
|
|
4386
4409
|
if(selDimOK()&&dimsVisible)selDimIds=new Set((P.dims||[]).map(d=>d.id)); // dimensions now included — fixes the reported "Ctrl+A doesn't select dimensions" (skip when dims are hidden, like the marquee)
|
|
4387
|
-
if(selGridOK())selGridIds=new Set(gridSelectables().map(g=>g.id)); // grids too
|
|
4388
4410
|
}
|
|
4389
4411
|
render();}
|
|
4390
4412
|
else if(k==='s'){e.preventDefault();persist();(window.flushContract?window.flushContract():Promise.resolve()).then(()=>toast('Saved ✓')).catch(()=>toast('Save failed'));}}); // edits autosave; Ctrl+S just flushes now (no browser "save page" dialog)
|
|
@@ -4491,13 +4513,17 @@ function renderSelFly(grp){const def=selGroupDef(grp);selFly.dataset.grp=grp;con
|
|
|
4491
4513
|
function openSelFly(grp,btn){renderSelFly(grp);selFly.classList.add('open');
|
|
4492
4514
|
const r=btn.getBoundingClientRect();selFly.style.left=Math.max(8,Math.min(r.left,innerWidth-selFly.offsetWidth-8))+'px';selFly.style.top=(r.top-selFly.offsetHeight-8)+'px';} // bar at bottom → open upward
|
|
4493
4515
|
function closeSelFly(){selFly.classList.remove('open');selFly.dataset.grp='';}
|
|
4516
|
+
function toggleSelAll(grp){const def=selGroupDef(grp),allOn=def.records.length>0&&def.records.every(r=>def.store[r.k]!==false);
|
|
4517
|
+
if(allOn)def.records.forEach(r=>def.store[r.k]=false);else def.records.forEach(r=>{delete def.store[r.k];}); // All: everything off ⇄ everything on (clears per-type overrides → absent===on); empty list → no-op
|
|
4518
|
+
saveSelFilter();reflectSelFilter();render();}
|
|
4494
4519
|
selBar.querySelectorAll('button').forEach(b=>{b.onclick=e=>{e.stopPropagation();
|
|
4495
|
-
if(b.dataset.fly){if(
|
|
4496
|
-
|
|
4520
|
+
if(b.dataset.fly){if(e.altKey){toggleSelAll(b.dataset.fly);return;} // Alt+click = toggle every type at once, without opening the flyout (same as the flyout's All row)
|
|
4521
|
+
if(selFly.classList.contains('open')&&selFly.dataset.grp===b.dataset.fly)closeSelFly();else openSelFly(b.dataset.fly,b);}
|
|
4522
|
+
else toggleSelClass(b.dataset.cls);};
|
|
4523
|
+
b.onkeydown=e=>{if((e.key==='Enter'||e.key===' ')&&!e.repeat){e.preventDefault();e.stopPropagation();b.onclick(e);}};}); // keyboard parity, mirroring the tfchip pattern: the global idle-repeat handler can eat native Enter/Space, and a synthesized click wouldn't carry live e.altKey — activate here so Alt+Enter/Space toggles all too
|
|
4497
4524
|
selFly.addEventListener('click',e=>{const row=e.target.closest('.frow');if(!row)return;e.stopPropagation();const def=selGroupDef(selFly.dataset.grp);
|
|
4498
|
-
if(row.dataset.all){
|
|
4499
|
-
|
|
4500
|
-
else{const k=row.dataset.k;def.store[k]=!(def.store[k]!==false);}
|
|
4525
|
+
if(row.dataset.all){toggleSelAll(selFly.dataset.grp);return;}
|
|
4526
|
+
const k=row.dataset.k;def.store[k]=!(def.store[k]!==false);
|
|
4501
4527
|
saveSelFilter();reflectSelFilter();render();});
|
|
4502
4528
|
document.addEventListener('click',e=>{if(selFly.classList.contains('open')&&!selFly.contains(e.target)&&!selBar.contains(e.target))closeSelFly();});
|
|
4503
4529
|
Promise.resolve().then(()=>{selFilterReady=true;reflectSelFilter();}).catch(e=>console.warn('selFilter: initial reflect failed',e)); // defer the first paint: memberTypeRecords() reads BASE_MEMBER_TYPES, a const declared later in main() — run once main() has fully initialized (microtask flushes before paint, so no flash). Arm selFilterReady BEFORE the first reflect so a throw here can't permanently disable render()'s per-edit sync (reflectSelFilter is idempotent — arm-then-run is safe). Log a throw rather than swallow it: a silent failure leaves the bar in its inert default HTML state while selFilter is still active.
|
|
@@ -4547,13 +4573,14 @@ const view3dApi={
|
|
|
4547
4573
|
for(const p of (C.detail_placements||[])){if(!p||!p.id)continue;const raw=C.custom_details[p.detailName];if(raw==null)continue;const url=String(raw).startsWith('data:')?raw:'data:image/jpeg;base64,'+raw;const el={kind:'image',id:'det:'+p.id,group:'detail',url,pos:p.pos||[0,0,0],u:p.u,n:p.n,rotZ:p.rotZ||0,size:p.size||1000,opacity:p.opacity==null?1:p.opacity};sc.elements.push(el);pb[el.id]=el;}
|
|
4548
4574
|
copesByMember=cm;partsById=pb;return sc;}, // cache resolved parts by id (real dims for the part Inspector) AND cope labels per member; placed details ride in as image elements
|
|
4549
4575
|
|
|
4550
|
-
onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears
|
|
4576
|
+
onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();if(!additive)selGridIds.clear();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);selGridIds.clear();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
|
|
4551
4577
|
onSelectMany:(ids,additive)=>{const ids2=(ids||[]).filter(selIdOK); // 3D box / whole-connection → gate each framed id through the Select switches (members by type, connection parts by kind)
|
|
4552
4578
|
if(!additive&&(ids||[]).length&&!ids2.length)return; // a direct pick / box that caught ONLY filtered objects → inert (leave the current selection), matching a filtered single-pick; a genuinely empty box (ids empty) still falls through and clears
|
|
4553
4579
|
selDimIds.clear();sel3dDimIds.clear();
|
|
4554
4580
|
if(additive){for(const id of ids2)selIds.has(id)?selIds.delete(id):selIds.add(id);} // Ctrl/Shift + 3D area-select → toggle each framed object into the current selection (add/remove), like Tekla — spans sheets
|
|
4555
|
-
else
|
|
4581
|
+
else{selIds=new Set(ids2);selGridIds.clear();}
|
|
4556
4582
|
if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
|
|
4583
|
+
onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
|
|
4557
4584
|
getMembers:()=>P.members, // active-sheet members (wp) for snap geometry (one ppf)
|
|
4558
4585
|
allMembers, // EVERY sheet's members — the 3D box-select tests all visible meshes, not just the active sheet's
|
|
4559
4586
|
membersByPlan:()=>((C&&Array.isArray(C.plans))?C.plans:[]).map(p=>({members:p.members||[],ptPerFt:(p.pt_per_ft>0?p.pt_per_ft:1),defaultTosMm:(p.default_tos!=null?p.default_tos:0)*25.4})), // every sheet's members WITH its OWN px→ft scale AND its OWN default T.O.S — 3D snapping targets the whole model (any elevation), each plan resolved exactly like the server bake (contract-to-scene: per-plan pt_per_ft + `default_tos ?? 0`) so candidates land on the rendered steel. Guards a not-yet-loaded contract (C.plans absent) so a hover can't throw out of the pointer handler.
|
|
@@ -4561,6 +4588,7 @@ const view3dApi={
|
|
|
4561
4588
|
snap3dFree:()=>snap3dFree, // SNAP-bar "3D snapping" mode — ON: free 3D snap; OFF: 3D placement snap constrained to the working plane
|
|
4562
4589
|
originGrid:()=>({on:originGridOn,incMm:originGridInc*25.4}), // UCS Stage 6 origin-relative snap — read live per hover; incMm from the inches step. Off ⇒ view skips it; requires a local frame to have any effect
|
|
4563
4590
|
canSelectId:(id)=>selIdOK(id), // Select-filter predicate for the 3D view (e.g. don't draw a whole-connection envelope for a fully-filtered connection)
|
|
4591
|
+
canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
|
|
4564
4592
|
ptPerFt:()=>(P&&P.pt_per_ft>0?P.pt_per_ft:1),
|
|
4565
4593
|
defaultTosMm:()=>(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
|
|
4566
4594
|
geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
|
|
@@ -4589,7 +4617,7 @@ const view3dApi={
|
|
|
4589
4617
|
onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
|
|
4590
4618
|
if(id&&!selDimOK())return; // Dimensions select-switch off → a 3D dim is inert too
|
|
4591
4619
|
if(!id){sel3dDimIds.clear();render();return;}
|
|
4592
|
-
selIds=new Set();selDimIds.clear();if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
|
|
4620
|
+
selIds=new Set();selDimIds.clear();selGridIds.clear();if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
|
|
4593
4621
|
const ids=(C.dims3d||[]).map(d=>d.id),cur=new Set(sel3dDimIds);let next;
|
|
4594
4622
|
if(mods&&mods.shift&&dim3dAnchor!=null&&ids.includes(dim3dAnchor)&&ids.includes(id)){const i0=ids.indexOf(dim3dAnchor),i1=ids.indexOf(id);next=ids.slice(Math.min(i0,i1),Math.max(i0,i1)+1);}
|
|
4595
4623
|
else if(mods&&(mods.ctrl||mods.meta)){next=new Set(cur);next.has(id)?next.delete(id):next.add(id);next=[...next];dim3dAnchor=id;}
|
|
@@ -4803,10 +4831,10 @@ function legendIsolate(k,e){
|
|
|
4803
4831
|
}
|
|
4804
4832
|
let clipAnchor=null;
|
|
4805
4833
|
// Clip-list selection — same multi-select as parts/dims: plain = select only this clip; Ctrl = toggle it in/out;
|
|
4806
|
-
// Shift = the range from the anchor (in list order). Selecting a clip clears member/dim selection (exclusive).
|
|
4834
|
+
// Shift = the range from the anchor (in list order). Selecting a clip clears member/dim/grid selection (exclusive).
|
|
4807
4835
|
function clipSelect(id,e){
|
|
4808
4836
|
if(!window.Steel3DView)return;
|
|
4809
|
-
if(selIds.size||sel3dDimIds.size||(typeof selDimIds!=='undefined'&&selDimIds.size)){selIds=new Set();sel3dDimIds.clear();if(typeof selDimIds!=='undefined')selDimIds.clear();render();}
|
|
4837
|
+
if(selIds.size||sel3dDimIds.size||selGridIds.size||(typeof selDimIds!=='undefined'&&selDimIds.size)){selIds=new Set();sel3dDimIds.clear();selGridIds.clear();if(typeof selDimIds!=='undefined')selDimIds.clear();render();}
|
|
4810
4838
|
const ids=window.Steel3DView.getClips().map(c=>c.id),cur=new Set(window.Steel3DView.selectedClips());
|
|
4811
4839
|
let next;
|
|
4812
4840
|
if(e.shiftKey&&clipAnchor!=null&&ids.includes(clipAnchor)&&ids.includes(id)){
|
|
@@ -4896,17 +4924,13 @@ function memberTypeField(id,ms){
|
|
|
4896
4924
|
return `<div class="mtype-field f"><div class=elab>Member type</div><input id=${id} class="combo member-type-combo" data-src=membertypes placeholder="${v?'':'Varies'}" value="${esc(v)}" autocomplete=off></div>`;
|
|
4897
4925
|
}
|
|
4898
4926
|
// ── F4: select-by-type filter for a MIXED selection ─────────────────────────────────────────────────────────
|
|
4899
|
-
// A marquee can grab a mix of object types (members of several member types + dimensions
|
|
4900
|
-
//
|
|
4927
|
+
// A marquee can grab a mix of object types (members of several member types + dimensions + grid lines).
|
|
4928
|
+
// typeFilterGroups buckets the CURRENT selection by type; typeFilterHTML renders one
|
|
4901
4929
|
// chip per type, but ONLY when more than one type is present (a single-type selection shows nothing).
|
|
4902
4930
|
// Plain-clicking a chip (wireTypeFilter) DROPS that type from the selection; Alt-clicking ISOLATES it (keeps only
|
|
4903
4931
|
// that type, deselects the rest — the "solo this layer" gesture). Both are real narrowing → render() resyncs the
|
|
4904
4932
|
// 2D glow/badges, the 3D highlight, AND re-runs panel(), which re-derives the strip from the now-smaller selection.
|
|
4905
|
-
// GRIDS: grid lines
|
|
4906
|
-
// selection. This assumes it will expose a global `selGridIds` (a Set of grid-line ids, sibling to selIds/
|
|
4907
|
-
// selDimIds) and stays INERT until then — the `typeof selGridIds` guard in gridSelSet() means no ReferenceError
|
|
4908
|
-
// now, and the Grids chip + its drop/isolate light up automatically once that Set exists and the marquee fills
|
|
4909
|
-
// it. (That session still owns the render() selection highlight + Delete for a selected grid.)
|
|
4933
|
+
// GRIDS: selected regular/free grid lines participate through selGridIds, alongside members and dimensions.
|
|
4910
4934
|
function gridSelSet(){return (typeof selGridIds!=='undefined'&&selGridIds&&typeof selGridIds.size==='number')?selGridIds:null;}
|
|
4911
4935
|
function typeFilterGroups(){
|
|
4912
4936
|
const g=[],by=new Map();
|
|
@@ -4914,7 +4938,7 @@ function typeFilterGroups(){
|
|
|
4914
4938
|
for(const rec of memberTypeRecords())if(by.has(rec.k))g.push({kind:'member',key:rec.k,label:rec.label,ids:by.get(rec.k)}); // canonical member-type order (Column, Beam, Brace, Ledger, Frame, then custom)
|
|
4915
4939
|
for(const [k,ids] of by)if(!g.some(x=>x.key===k))g.push({kind:'member',key:k,label:memberTypeLabel(k),ids}); // any stray key not in the records list (defensive)
|
|
4916
4940
|
if(selDimIds.size)g.push({kind:'dim',key:'__dims',label:'Dimensions',ids:[...selDimIds]});
|
|
4917
|
-
const G=gridSelSet();if(G&&G.size)g.push({kind:'grid',key:'__grids',label:'Grids',ids:[...G]});
|
|
4941
|
+
const G=gridSelSet();if(G&&G.size)g.push({kind:'grid',key:'__grids',label:'Grids',ids:[...G]});
|
|
4918
4942
|
return g;
|
|
4919
4943
|
}
|
|
4920
4944
|
function typeFilterHTML(){
|
|
@@ -5139,6 +5163,7 @@ function renderViewsTab(){const host=document.getElementById('m3dViewsBody');if(
|
|
|
5139
5163
|
split.append(saveBtn,moreBtn);
|
|
5140
5164
|
const searchTog=document.createElement('button');searchTog.type='button';searchTog.id='vwSearchTog';searchTog.setAttribute('aria-label','Search views');searchTog.dataset.tip='Search views by name';if(viewsSearchOpen)searchTog.classList.add('on');searchTog.appendChild(magnifierSvg());searchTog.addEventListener('click',toggleViewsSearch);
|
|
5141
5165
|
head.append(split,searchTog);host.appendChild(head);
|
|
5166
|
+
const genBtn=document.createElement('button');genBtn.type='button';genBtn.id='vwGenerateBtn';genBtn.className='ghostw';genBtn.textContent='Generate views from grids or levels…';genBtn.dataset.tip='Batch-create editable orthographic views from the active plan’s regular grid lines or Z levels';genBtn.addEventListener('click',()=>openViewGenerator(genBtn));host.appendChild(genBtn);
|
|
5142
5167
|
// Search box (revealed on demand)
|
|
5143
5168
|
if(viewsSearchOpen){const sb=document.createElement('div');sb.id='vwSearch';sb.className='show'+(viewsQuery?' has':'');
|
|
5144
5169
|
const ico=Object.assign(document.createElement('span'),{className:'lsico'});ico.setAttribute('aria-hidden','true');ico.appendChild(magnifierSvg());
|
|
@@ -5200,11 +5225,12 @@ function closeViewGenerator(){const modal=document.getElementById('viewGenModal'
|
|
|
5200
5225
|
const target=viewGenLauncher&&viewGenLauncher.isConnected?viewGenLauncher:document.getElementById('vwSaveMore');viewGenLauncher=null;if(target)target.focus();}
|
|
5201
5226
|
function openViewGenerator(launcher){const geo=gridGeo(),gc=GC();if(!geo||!gc){toast('This plan has no usable structural grid');return;}
|
|
5202
5227
|
const sources=ViewGen.sourcesFromGrid(geo,gc.mmPerPx(P.pt_per_ft),P.sheet);
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5228
|
+
const selected=ViewGen.preselectedSourceKeys(selGridIds,sources),ignoredFree=ViewGen.unsupportedFreeGridCount(selGridIds);
|
|
5229
|
+
viewGenLauncher=launcher||document.activeElement;viewGenState={tab:'grid',look:'positive',selected,lastAnchor:null,sources,ignoredFree,
|
|
5230
|
+
depths:{grid:{ahead:'2\'-0"',behind:'2\'-0"'},levels:{above:'2\'-0"',below:'2\'-0"'}},committedDepths:{grid:{ahead:'2\'-0"',behind:'2\'-0"'},levels:{above:'2\'-0"',below:'2\'-0"'}}};
|
|
5231
|
+
document.getElementById('vgContext').textContent='Active plan · '+(P.sheet||'Untitled sheet')+(ignoredFree?' · '+ignoredFree+' selected free-angle grid'+(ignoredFree===1?' is':'s are')+' not a view source; use regular X/Y grids or levels.':'');
|
|
5206
5232
|
document.getElementById('viewGenModal').style.display='flex';renderViewGenerator();document.getElementById('vgGridTab').focus();}
|
|
5207
|
-
function viewGenSetTab(tab){if(!viewGenState)return;viewGenState.tab=tab;renderViewGenerator();}
|
|
5233
|
+
function viewGenSetTab(tab){if(!viewGenState)return;viewGenState.tab=tab;viewGenState.lastAnchor=null;renderViewGenerator();}
|
|
5208
5234
|
function viewGenSyncInputs(){if(!viewGenState)return;const level=viewGenState.tab==='levels',raw=viewGenState.depths[viewGenState.tab];
|
|
5209
5235
|
document.querySelector('#vgFieldA label').textContent=level?'Above':'Ahead';document.querySelector('#vgFieldB label').textContent=level?'Below':'Behind';
|
|
5210
5236
|
document.getElementById('vgDepthA').value=level?raw.above:raw.ahead;document.getElementById('vgDepthB').value=level?raw.below:raw.behind;
|
|
@@ -5216,12 +5242,14 @@ function viewGenValidate(){if(!viewGenState)return null;const level=viewGenState
|
|
|
5216
5242
|
const n=viewGenCurrentSources().filter(s=>viewGenState.selected.has(viewGenKey(s))).length,create=document.getElementById('vgCreate');create.textContent='Create '+n+' view'+(n===1?'':'s');create.disabled=!parsed.ok||n===0;return parsed;}
|
|
5217
5243
|
function viewGenInput(){if(!viewGenState)return;const level=viewGenState.tab==='levels',a=document.getElementById('vgDepthA').value,b=document.getElementById('vgDepthB').value;
|
|
5218
5244
|
viewGenState.depths[viewGenState.tab]=level?{above:a,below:b}:{ahead:a,behind:b};viewGenValidate();}
|
|
5245
|
+
function viewGenCommitDepths(){if(!viewGenState)return;viewGenInput();const level=viewGenState.tab==='levels',tab=viewGenState.tab,n=ViewGen.normalizeDepths(level?'level':'grid',viewGenState.depths[tab]);if(!n.ok){viewGenValidate();return;}viewGenState.depths[tab]=n.formatted;viewGenState.committedDepths[tab]={...n.formatted};viewGenSyncInputs();viewGenValidate();}
|
|
5246
|
+
function viewGenRestoreDepths(){if(!viewGenState)return;const tab=viewGenState.tab;viewGenState.depths[tab]={...viewGenState.committedDepths[tab]};viewGenSyncInputs();viewGenValidate();}
|
|
5219
5247
|
function renderViewGenerator(){if(!viewGenState)return;const level=viewGenState.tab==='levels',gridTab=document.getElementById('vgGridTab'),levelTab=document.getElementById('vgLevelTab');
|
|
5220
5248
|
gridTab.setAttribute('aria-selected',String(!level));levelTab.setAttribute('aria-selected',String(level));
|
|
5221
5249
|
const list=document.getElementById('vgList');list.replaceChildren();list.setAttribute('aria-label',level?'Levels':'Grid lines');
|
|
5222
5250
|
const addGroup=(title,axis,sources)=>{if(!sources.length)return;const gh=Object.assign(document.createElement('div'),{className:'vggroup',textContent:title});list.appendChild(gh);
|
|
5223
5251
|
for(const s of sources){const row=document.createElement('label');row.className='vgrow';const ck=document.createElement('input');ck.type='checkbox';ck.checked=viewGenState.selected.has(viewGenKey(s));ck.dataset.source=viewGenKey(s);
|
|
5224
|
-
ck.addEventListener('
|
|
5252
|
+
ck.addEventListener('click',(ev)=>{ev.preventDefault();const key=viewGenKey(s),keys=viewGenCurrentSources().map(viewGenKey);if(ev.shiftKey&&viewGenState.lastAnchor)viewGenState.selected=ViewGen.addRange(keys,viewGenState.selected,viewGenState.lastAnchor,key);else{if(viewGenState.selected.has(key))viewGenState.selected.delete(key);else viewGenState.selected.add(key);viewGenState.lastAnchor=key;}renderViewGenerator();const next=list.querySelector('input[data-source="'+CSS.escape(key)+'"]');if(next)next.focus();});
|
|
5225
5253
|
const ax=Object.assign(document.createElement('span'),{className:'vgaxis',textContent:axis});const nm=Object.assign(document.createElement('span'),{className:'vgname',textContent:s.label});row.append(ck,ax,nm);list.appendChild(row);}};
|
|
5226
5254
|
if(level)addGroup('Z elevations','Z',viewGenState.sources.levels);else{addGroup('X grids','X',viewGenState.sources.x);addGroup('Y grids','Y',viewGenState.sources.y);}
|
|
5227
5255
|
if(!list.children.length){const empty=Object.assign(document.createElement('div'),{className:'vgempty',textContent:level?'This active plan has no Z levels. Add levels in Grid lines, then reopen this dialog.':'This active plan has no regular X or Y grid lines. Add grid spacings, then reopen this dialog.'});list.appendChild(empty);}
|
|
@@ -5229,7 +5257,7 @@ function renderViewGenerator(){if(!viewGenState)return;const level=viewGenState.
|
|
|
5229
5257
|
document.getElementById('vgNegative').classList.toggle('on',viewGenState.look==='negative');document.getElementById('vgNegative').setAttribute('aria-pressed',String(viewGenState.look==='negative'));
|
|
5230
5258
|
viewGenSyncInputs();viewGenReflectSelection();}
|
|
5231
5259
|
function viewGenReflectSelection(){if(!viewGenState)return;const current=viewGenCurrentSources(),n=current.filter(s=>viewGenState.selected.has(viewGenKey(s))).length;document.getElementById('vgCount').textContent=n+' of '+current.length+' selected';viewGenValidate();}
|
|
5232
|
-
function viewGenSelectAll(on){if(!viewGenState)return;for(const s of viewGenCurrentSources()){const k=viewGenKey(s);if(on)viewGenState.selected.add(k);else viewGenState.selected.delete(k);}renderViewGenerator();}
|
|
5260
|
+
function viewGenSelectAll(on){if(!viewGenState)return;viewGenState.lastAnchor=null;for(const s of viewGenCurrentSources()){const k=viewGenKey(s);if(on)viewGenState.selected.add(k);else viewGenState.selected.delete(k);}renderViewGenerator();}
|
|
5233
5261
|
function createGeneratedViews(){if(!viewGenState)return;const parsed=viewGenValidate();if(!parsed||!parsed.ok)return;const V=window.Steel3DView,bounds=V&&V.sceneBounds?V.sceneBounds():null;
|
|
5234
5262
|
if(!bounds){document.getElementById('vgError').textContent='The 3D model is not ready. Close this dialog and try again.';return;}
|
|
5235
5263
|
const selected=viewGenCurrentSources().filter(s=>viewGenState.selected.has(viewGenKey(s))),made=[],skipped=[],taken=new Set((C.views||[]).map(v=>v.name));
|
|
@@ -5247,6 +5275,7 @@ document.getElementById('vgLevelTab').addEventListener('click',()=>viewGenSetTab
|
|
|
5247
5275
|
document.getElementById('vgAll').addEventListener('click',()=>viewGenSelectAll(true));document.getElementById('vgClear').addEventListener('click',()=>viewGenSelectAll(false));
|
|
5248
5276
|
document.getElementById('vgPositive').addEventListener('click',()=>{if(viewGenState){viewGenState.look='positive';renderViewGenerator();}});document.getElementById('vgNegative').addEventListener('click',()=>{if(viewGenState){viewGenState.look='negative';renderViewGenerator();}});
|
|
5249
5277
|
document.getElementById('vgDepthA').addEventListener('input',viewGenInput);document.getElementById('vgDepthB').addEventListener('input',viewGenInput);
|
|
5278
|
+
for(const el of [document.getElementById('vgDepthA'),document.getElementById('vgDepthB')]){el.addEventListener('blur',viewGenCommitDepths);el.addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();e.stopPropagation();el.blur();}else if(e.key==='Escape'){e.preventDefault();e.stopPropagation();viewGenRestoreDepths();el.select();}});}
|
|
5250
5279
|
document.getElementById('vgCreate').addEventListener('click',createGeneratedViews);document.getElementById('vgCancel').addEventListener('click',closeViewGenerator);document.getElementById('vgClose').addEventListener('click',closeViewGenerator);document.getElementById('vgBackdrop').addEventListener('click',closeViewGenerator);
|
|
5251
5280
|
document.getElementById('viewGenModal').addEventListener('keydown',e=>{e.stopPropagation();if(e.key==='Escape'){e.preventDefault();closeViewGenerator();return;}if(e.key!=='Tab')return;
|
|
5252
5281
|
const focusable=[...document.querySelectorAll('#viewGenModal button:not(:disabled),#viewGenModal input:not(:disabled)')].filter(el=>el.offsetParent!==null);if(!focusable.length)return;const first=focusable[0],last=focusable[focusable.length-1];if(e.shiftKey&&document.activeElement===first){e.preventDefault();last.focus();}else if(!e.shiftKey&&document.activeElement===last){e.preventDefault();first.focus();}});
|
|
@@ -5653,10 +5682,10 @@ function legendSelect(row,mods){
|
|
|
5653
5682
|
if(mods&&mods.shift&&legendSelAnchor&&document.body.contains(legendSelAnchor)){ // Shift → union every VISIBLE object row from the anchor to here (a search-hidden row can't be range-selected)
|
|
5654
5683
|
const rows=[...document.querySelectorAll('#m3dLegend .lrow[data-key]:not(.qhide),#m3dLegend .lrow[data-connkey]:not(.qhide)')];
|
|
5655
5684
|
const i0=rows.indexOf(legendSelAnchor),i1=rows.indexOf(row);
|
|
5656
|
-
if(i0>=0&&i1>=0){const next=new Set();rows.slice(Math.min(i0,i1),Math.max(i0,i1)+1).forEach(r=>legRowIds(r).forEach(id=>next.add(id)));selIds=next;selDimIds.clear();sel3dDimIds.clear();render();return;}
|
|
5685
|
+
if(i0>=0&&i1>=0){const next=new Set();rows.slice(Math.min(i0,i1),Math.max(i0,i1)+1).forEach(r=>legRowIds(r).forEach(id=>next.add(id)));selIds=next;selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();render();return;}
|
|
5657
5686
|
}
|
|
5658
5687
|
if(mods&&mods.ctrl){const next=new Set(selIds);const all=ids.every(id=>next.has(id));ids.forEach(id=>all?next.delete(id):next.add(id));selIds=next;} // Ctrl → toggle this group in/out of the selection
|
|
5659
|
-
else
|
|
5688
|
+
else{selIds=new Set(ids);selGridIds.clear();} // plain → replace the selection
|
|
5660
5689
|
legendSelAnchor=row;selDimIds.clear();sel3dDimIds.clear();render();
|
|
5661
5690
|
}
|
|
5662
5691
|
// A row lights up (.lsel) when EVERY object it represents is selected — so a legend click that selects the whole group shows it. Synced from render()'s 3D block + build3DLegend.
|
|
@@ -5932,7 +5961,6 @@ async function setView(on){
|
|
|
5932
5961
|
if(csaxisMode){csaxisMode=false;setCsMode();} // drops the in-progress origin (csDraft) + the set-axes panel
|
|
5933
5962
|
if(picking){picking=false;pickKind='profile';pickEnd=null;} // an armed inspector ⌖ pick
|
|
5934
5963
|
if(on){
|
|
5935
|
-
if(selGridIds.size){selGridIds.clear();disarmed2d=true;} // grids are 2D-only — a grid selection is invisible in 3D and would be silently removed by a 3D Delete (or a member-Delete), so drop it on entry
|
|
5936
5964
|
if(dimMode||dimChain||dimSplitMode){disarmed2d=true;dimMode=dimChain=dimSplitMode=false;selDimIds.clear();setDimMode();document.body.classList.remove('dimsplit');} // entering 3D disarms the 2D dim/chain/split tools so their X/Y/F/S/Esc keys don't double-fire with the 3D tool
|
|
5937
5965
|
if(dimStyleMode){disarmed2d=true;dimStyleMode=false;} // …and closes the 2D Dimension style pane (it styles the 2D overlay only)
|
|
5938
5966
|
if(disarmed2d)render(); // repaint the 2D SVG + inspector ONCE, now that EVERY 2D-only tool is disarmed and view3d is still false (2D render path): they suppress callouts / draw pick hotspots (:2061,:2069) and take over #panel, and the return-to-2D path never render()s — so a render here (like the Esc paths) un-stales the canvas + panel. Deferred past the dim/dim-style disarm so it can't paint a still-armed Dimension panel (dimMode can coexist with grid/pick) that then goes stale.
|
|
@@ -5946,6 +5974,7 @@ async function setView(on){
|
|
|
5946
5974
|
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)
|
|
5947
5975
|
await window.Steel3DView.rebuild(true); // fit the camera on entering 3D
|
|
5948
5976
|
window.Steel3DView.setSelection(selIds);
|
|
5977
|
+
if(window.Steel3DView.setGridSelection)window.Steel3DView.setGridSelection(selGridIds); // carry the shared 2D grid selection across the rebuild; rebuild replaces the line objects/materials
|
|
5949
5978
|
wire3DBar();wireLegendTabs();loadSteelFavourites();build3DLegend();showLegendPanel(); // build the Objects body + load the (global) favourites library, then open the panel on the last-used tab
|
|
5950
5979
|
reflectProj();reflectMode(); // reflect persisted projection + display mode into the Camera/Display dropdown triggers
|
|
5951
5980
|
}catch(e){ // a failed open must not strand the UI in 3D with a blank canvas
|
|
@@ -6478,10 +6507,7 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
6478
6507
|
if(!Array.isArray(P.segments))P.segments=[];
|
|
6479
6508
|
sanitizeDims(P); // …and its dimensions: drop any whose geometry isn't numeric (they render straight into SVG attributes)
|
|
6480
6509
|
sanitizeFrame(P); // tolerate a hand-edited/AI-written frame: normalize or drop to global
|
|
6481
|
-
//
|
|
6482
|
-
// the renderers assume a finite [x,y] origin; the spacing strings report their own errors inline.
|
|
6483
|
-
if(P.grid!=null&&(typeof P.grid!=='object'||Array.isArray(P.grid)||!Array.isArray(P.grid.origin)||P.grid.origin.length<2||!isFinite(P.grid.origin[0])||!isFinite(P.grid.origin[1]))){console.warn('discarding malformed grid on '+P.sheet);P.grid=null;}
|
|
6484
|
-
if(P.grid)sanitizeGridLines(P.grid);
|
|
6510
|
+
sanitizePlanGrid(P); // finite origin + canonical labels/free lines; spacing strings report their own errors inline
|
|
6485
6511
|
// clip = the drawing's display-space crop. A contract may ship WITHOUT a raster/clip (a shared or
|
|
6486
6512
|
// committed contract strips raster_b64 for confidentiality), so fall back to the members' bounding
|
|
6487
6513
|
// box (padded) → the editor renders members on a blank canvas instead of crashing on P.clip[0].
|
|
@@ -6527,6 +6553,9 @@ const _restored=restoreSaved(); // bring back this brows
|
|
|
6527
6553
|
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
6528
6554
|
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
6529
6555
|
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
6556
|
+
// Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
|
|
6557
|
+
// not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
|
|
6558
|
+
for(const _p of (C.plans||[]))sanitizePlanGrid(_p);
|
|
6530
6559
|
setPlan(C.active==null?0:C.active);
|
|
6531
6560
|
setSaved(_restored?'ok':'idle', _restored?'Restored ✓':'Auto-save on');
|
|
6532
6561
|
try{stage.focus({preventScroll:true});}catch(_){} // grab keyboard focus on open so shortcuts work before the first click
|