@floless/app 0.116.0 → 0.117.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +262 -31
- package/dist/schemas/steel.model.v2.schema.json +9 -4
- package/dist/schemas/steel.takeoff.v1.staging-snapshot.json +263 -0
- package/dist/skills/floless-app-steel-model/SKILL.md +9 -6
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +24 -6
- package/dist/web/app.css +0 -5
- package/dist/web/json-schema-subset.js +72 -0
- package/dist/web/steel-editor.html +533 -148
- package/dist/web/steel-model-commands.js +154 -14
- package/dist/web/steel-model-v2-client-validation.js +95 -0
- package/dist/web/steel-model-v2-commands.js +836 -0
- package/dist/web/steel-model-v2-projection.js +170 -0
- package/dist/web/steel-plan-transform.js +151 -0
- package/package.json +2 -1
|
@@ -749,7 +749,6 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
749
749
|
#m3dFavBody .favname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--text)}
|
|
750
750
|
#m3dFavBody .favbadge{flex:none;font-size:10px;line-height:1.4;padding:0 5px;border-radius:4px;border:1px solid var(--line);color:var(--mut)}
|
|
751
751
|
#m3dFavBody .favbadge.portable{border-color:var(--brand);color:#bfdbfe}
|
|
752
|
-
#m3dFavBody .favrow input.favedit{flex:1;min-width:0;font:12px system-ui;background:#0b1220;color:var(--text);border:1px solid var(--brand);border-radius:4px;padding:0 4px;outline:none}
|
|
753
752
|
#m3dFavBody .favrow .vx{flex:none;color:var(--mut);padding:0 3px;border-radius:4px;visibility:hidden;font-size:13px;line-height:1}
|
|
754
753
|
#m3dFavBody .favrow:hover .vx,#m3dFavBody .favrow:focus-within .vx{visibility:visible}
|
|
755
754
|
#m3dFavBody .favrow .vx:hover{color:#fecaca;background:#7f1d1d}
|
|
@@ -1301,9 +1300,11 @@ const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
|
|
|
1301
1300
|
// own validator says so and falls back to exactly this (contract-schema.ts, validateContract), so
|
|
1302
1301
|
// diverging here would refuse documents this app itself wrote.
|
|
1303
1302
|
const EDITOR_TYPE = 'steel.takeoff/v1';
|
|
1304
|
-
// The canonical model format
|
|
1305
|
-
//
|
|
1303
|
+
// The canonical model format. New and migrated projects edit this shape through validated,
|
|
1304
|
+
// transactional commands; the v1 branch remains as a compatibility reader during the rollout.
|
|
1306
1305
|
const MODEL_V2_TYPE = 'steel.model/v2';
|
|
1306
|
+
// P3's single activation switch. Reads and writes consult this same constant; there is no half-v2 mode.
|
|
1307
|
+
const MODEL_V2_LIVE = true;
|
|
1307
1308
|
// Every type this page will open. A type NOT in here is refused before anything mutates the document; the
|
|
1308
1309
|
// refusal copy below still tells a newer STEEL model apart from "you opened the wrong workflow".
|
|
1309
1310
|
const OPENABLE_TYPES = [EDITOR_TYPE, MODEL_V2_TYPE];
|
|
@@ -1312,10 +1313,10 @@ const OPENABLE_TYPES = [EDITOR_TYPE, MODEL_V2_TYPE];
|
|
|
1312
1313
|
// draft it was writing (persist and restoreSaved would address different rows).
|
|
1313
1314
|
let DRAFT_TYPE = EDITOR_TYPE;
|
|
1314
1315
|
/**
|
|
1315
|
-
* Is the open document READ-ONLY to this editor?
|
|
1316
|
+
* Is the open document READ-ONLY to this editor?
|
|
1316
1317
|
*
|
|
1317
|
-
* True
|
|
1318
|
-
* — a mode that can change identity mid-session is a mode that guards nothing.
|
|
1318
|
+
* True only if the v2 activation switch is disabled. Pinned ONCE from the type boot() validated, for the
|
|
1319
|
+
* same reason DRAFT_TYPE is — a mode that can change identity mid-session is a mode that guards nothing.
|
|
1319
1320
|
*
|
|
1320
1321
|
* READ-ONLY IS ENFORCED HERE, NOT BY DISABLED BUTTONS. Disabled controls are the UX; they are not the
|
|
1321
1322
|
* enforcement, and the leak that matters is upstream of any user action. v2's `plan` schema is
|
|
@@ -1324,9 +1325,10 @@ let DRAFT_TYPE = EDITOR_TYPE;
|
|
|
1324
1325
|
* user has done anything, and the corruption only surfaces later, as a save the server refuses for edits
|
|
1325
1326
|
* they never made. See docs/superpowers/specs/2026-07-26-steel-v2-p7d-design.md §8.4.
|
|
1326
1327
|
*
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
1328
|
+
* This preserves the pre-activation safety gate without creating a half-live mode:
|
|
1329
|
+
* MODEL_V2_LIVE enables both reads and canonical writes together.
|
|
1329
1330
|
*/
|
|
1331
|
+
let MODEL_V2 = false;
|
|
1330
1332
|
let MODEL_RO = false;
|
|
1331
1333
|
/** Ask before any model write. One name, so a new write site refuses by default rather than by remembering. */
|
|
1332
1334
|
function canWriteModel() { return !MODEL_RO; }
|
|
@@ -1476,8 +1478,12 @@ let C, PAL, WT;
|
|
|
1476
1478
|
let SteelCore = null; // steel-3d-core.js module namespace — boot() awaits its dynamic import before main() so the classic script can call its pure helpers (sanitizeDims3d) at load
|
|
1477
1479
|
let ViewGen = null; // steel-view-generation.js pure F11 helpers — loaded before saved views are sanitised
|
|
1478
1480
|
let ModelCmd = null; // steel-model-commands.js — the model boundary's WRITE half (unit 5, P3a); the read half is steel-model-adapter.js
|
|
1481
|
+
let V2Projection = null, V2Commands = null, V2Validation = null;
|
|
1482
|
+
let V2_SCHEMA = null, V2_SESSION = null, V2_PROJECTION = null;
|
|
1483
|
+
let V2_PROJECTIONS = new Map();
|
|
1479
1484
|
let DetailRefs = null; // steel-detail-refs.js — what detail callouts a plan carries (details[] ∪ callouts[]); the ⌖ pick tool, the Connection-detail combobox and the Details list must all read the SAME answer (#397)
|
|
1480
1485
|
let TARGET_CONF = null; // the app's target_confidence input default (%), or null when undeclared — drives the chip's "· target N%" goal
|
|
1486
|
+
let DEV_MODE = false; // /api/health.appChannel; every distribution uses localhost, so hostname cannot identify dev
|
|
1481
1487
|
let view3d = false, view3dReady = false; // 2D|3D toggle state; view3dReady once Steel3DView.init has run
|
|
1482
1488
|
// Fallback palette (colorFor indexes this array by profile order) when a contract ships no `palette`
|
|
1483
1489
|
// — e.g. a contract shared/committed with raster_b64 + palette stripped for confidentiality.
|
|
@@ -1660,7 +1666,11 @@ function contractFailureState(status, code, serverError, projectScoped) {
|
|
|
1660
1666
|
async function boot() {
|
|
1661
1667
|
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; }
|
|
1662
1668
|
armEarlyViewToggle(); // BEFORE the first await — that is the whole point; see above
|
|
1663
|
-
[SteelCore, ViewGen, ModelCmd, DetailRefs] = await Promise.all([
|
|
1669
|
+
[SteelCore, ViewGen, ModelCmd, DetailRefs, V2Projection, V2Commands, V2Validation] = await Promise.all([
|
|
1670
|
+
import('./steel-3d-core.js'), import('./steel-view-generation.js'), import('./steel-model-commands.js'),
|
|
1671
|
+
import('./steel-detail-refs.js'), import('./steel-model-v2-projection.js'),
|
|
1672
|
+
import('./steel-model-v2-commands.js'), import('./steel-model-v2-client-validation.js'),
|
|
1673
|
+
]);
|
|
1664
1674
|
const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS);
|
|
1665
1675
|
if (!res.ok) {
|
|
1666
1676
|
if (res.status === 404) {
|
|
@@ -1751,7 +1761,17 @@ async function boot() {
|
|
|
1751
1761
|
// Pin the draft identity for the rest of the session. Read once, from the validated value, never from
|
|
1752
1762
|
// the mutable `C` — see draftKey().
|
|
1753
1763
|
DRAFT_TYPE = loadedType == null ? EDITOR_TYPE : loadedType;
|
|
1754
|
-
|
|
1764
|
+
MODEL_V2 = DRAFT_TYPE === MODEL_V2_TYPE;
|
|
1765
|
+
MODEL_RO = MODEL_V2 && !MODEL_V2_LIVE; // reads and writes activate together; inactive means both refuse
|
|
1766
|
+
if (MODEL_V2) {
|
|
1767
|
+
const schemaRes = await fetch('/api/schema/steel-model-v2');
|
|
1768
|
+
if (!schemaRes.ok) throw new Error('steel.model/v2 schema unavailable');
|
|
1769
|
+
V2_SCHEMA = await schemaRes.json();
|
|
1770
|
+
}
|
|
1771
|
+
try {
|
|
1772
|
+
const hr = await fetch('/api/health');
|
|
1773
|
+
if (hr.ok) DEV_MODE = (await hr.json()).appChannel === 'dev';
|
|
1774
|
+
} catch (_) { /* production-safe default: the diagnostic freeze stays off */ }
|
|
1755
1775
|
sweepOrphanDrafts(); // now that the identity is pinned, retire rows keyed by an older one
|
|
1756
1776
|
C = loaded;
|
|
1757
1777
|
// The server's tag for the contract we just read. Every write echoes it back, so a write that would
|
|
@@ -2072,8 +2092,32 @@ function main() {
|
|
|
2072
2092
|
* A v2 document does not need the pass: it arrives SERVER-VALIDATED (P7b validates schema plus referential
|
|
2073
2093
|
* integrity on every PUT), which is a stronger guarantee than any of these clamps.
|
|
2074
2094
|
*/
|
|
2075
|
-
if(
|
|
2076
|
-
let P, X0,Y0,X1,Y1, FT, RB64, EXTX, EXTY, profs; // per-plan, set by setPlan()
|
|
2095
|
+
if(!MODEL_V2)C.member_styles=sanitizeMemberStyles(C.member_styles); // v2 arrives closed + validated; v1 needs repair
|
|
2096
|
+
let P, X0,Y0,X1,Y1, FT, RB64, EXTX, EXTY, profs, NO_PLAN_VIEW=false; // per-plan, set by setPlan()
|
|
2097
|
+
let v2IdSeq=0;
|
|
2098
|
+
const newModelId=()=>`m-v2-${Date.now().toString(36)}-${(v2IdSeq++).toString(36)}`;
|
|
2099
|
+
if(MODEL_V2){
|
|
2100
|
+
/*
|
|
2101
|
+
* BACKFILL `viewKind` ON A v2 DOCUMENT WRITTEN BEFORE THE FIELD EXISTED.
|
|
2102
|
+
*
|
|
2103
|
+
* `plans[].viewKind` became a REQUIRED v2 field in this unit, and nothing backfills a document already
|
|
2104
|
+
* on disk. Migration has shipped since app-v0.111.3 and the migrate modal is ungated, so a real user can
|
|
2105
|
+
* hold a v2 project whose plans predate the field — and for them the document reads back fine (the read
|
|
2106
|
+
* path does not validate) and then fails on the FIRST SAVE, plus refuses to project into 2D because
|
|
2107
|
+
* steel-plan-transform keys on `viewKind === 'plan'`. Open-but-unsaveable is the worst of the options.
|
|
2108
|
+
*
|
|
2109
|
+
* `'plan'` is the correct value rather than a convenient one: only `previewMigration` could have written
|
|
2110
|
+
* these plans, and it maps v1's `plans[]` — which IS the reader's framing-plan collection — one-to-one,
|
|
2111
|
+
* which is exactly why it now stamps `viewKind:'plan'` itself. So this reconstructs what that migration
|
|
2112
|
+
* would have written, for the documents it wrote before it did. A plan that HAS a kind is never touched,
|
|
2113
|
+
* so an authored `elevation`/`section`/`unknown` keeps its meaning and `unknown` stays not-a-default.
|
|
2114
|
+
*/
|
|
2115
|
+
if(C.origin==='migrated')for(const _p of (C.plans||[]))if(_p&&typeof _p==='object'&&_p.viewKind===undefined)_p.viewKind='plan';
|
|
2116
|
+
V2_SESSION=V2Commands.createV2CommandSession(C,{
|
|
2117
|
+
validate:doc=>V2Validation.validateClientSteelModelV2(doc,V2_SCHEMA),
|
|
2118
|
+
mintId:newModelId,
|
|
2119
|
+
afterCommit:()=>{v2InvalidateMemberIndex();if(DEV_MODE&&V2_PROJECTION)P=ModelCmd.deepFreezeProjection(V2_PROJECTION.plan);}
|
|
2120
|
+
});}
|
|
2077
2121
|
let mode='sel', drag=null, picking=false, pickKind='profile', pickEnd=null, geoMode=null;
|
|
2078
2122
|
let dimMode=false, dimDraft=null, dimAxis='free', selDimIds=new Set(), dimsVisible=true; // Dimension tool: armed flag, in-progress {a,b,axis}, sticky axis, selected dim ids (multi-select), show/hide
|
|
2079
2123
|
let qdAnchorPt=(()=>{try{const v=localStorage.getItem('steel:qdAnchor:v1');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
|
|
@@ -2103,19 +2147,25 @@ let undo=[], redo=[];
|
|
|
2103
2147
|
// `C.plans[].members` answers EMPTY for a populated model, silently. That silent empty is what puts an
|
|
2104
2148
|
// unusable Send-to-Tekla and an empty Inspector beside a full 3D scene, so both resolve model-wide.
|
|
2105
2149
|
//
|
|
2106
|
-
// A v2 record has a different SHAPE (world-mm `from`/`to`, no `wp`/`col
|
|
2107
|
-
//
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
const
|
|
2114
|
-
const
|
|
2150
|
+
// A v2 record has a different SHAPE (world-mm `from`/`to`, no `wp`/`col`). Every legacy-shaped UI
|
|
2151
|
+
// consumer receives a tagged projection; canonical commands resolve that tag back to the root member.
|
|
2152
|
+
function v2ProjectionForSheet(sheet){
|
|
2153
|
+
let projection=V2_PROJECTIONS.get(sheet);
|
|
2154
|
+
if(!projection){projection=V2Projection.createV2Projection(C,sheet,{session:V2_SESSION});V2_SESSION.registerProjection(projection);V2_PROJECTIONS.set(sheet,projection);}
|
|
2155
|
+
return projection;}
|
|
2156
|
+
function v2ProjectedMember(id){
|
|
2157
|
+
const here=(P&&P.members||[]).find(m=>m&&m.id===id);if(here)return here;
|
|
2158
|
+
const sheet=V2Projection.memberSheets(C,id)[0];if(!sheet)return undefined;
|
|
2159
|
+
return v2ProjectionForSheet(sheet).plan.members.find(m=>m&&m.id===id);}
|
|
2160
|
+
const allMembers=()=>MODEL_V2?modelMembersV2():C.plans.flatMap(p=>p.members||[]);
|
|
2161
|
+
const legacyAllMembers=()=>MODEL_V2?(C.members||[]).map(m=>v2ProjectedMember(m.id)).filter(Boolean):allMembers();
|
|
2162
|
+
const byId=id=>{if(MODEL_V2)return v2ProjectedMember(id);for(const p of C.plans){const m=(p.members||[]).find(x=>x.id===id);if(m)return m;}return undefined;};
|
|
2163
|
+
const planeOf=id=>{if(MODEL_V2){const sheet=V2Projection.memberSheets(C,id)[0];return sheet?v2ProjectionForSheet(sheet).plan:P;}for(const p of C.plans)if((p.members||[]).some(m=>m.id===id))return p;return P;}; // the plane that owns a member id
|
|
2164
|
+
const planeOfMember=m=>{if(MODEL_V2){const link=V2Projection.projectionLink(m);return link?.sheet?v2ProjectionForSheet(link.sheet).plan:null;}for(const p of C.plans)if((p.members||[]).includes(m))return p;return null;};
|
|
2165
|
+
const selArr=()=>MODEL_V2?[...selIds].map(byId).filter(Boolean):allMembers().filter(m=>selIds.has(m.id));
|
|
2115
2166
|
// The active-sheet subset of the selection — for 2D coordinate/decoration ops (handles, badges, move/copy,
|
|
2116
2167
|
// 2D drag/zoom) that draw or compute in THIS sheet's px space, where an off-sheet member's wp is meaningless.
|
|
2117
2168
|
const sel2d=()=>P.members.filter(m=>selIds.has(m.id));
|
|
2118
|
-
const numOrNull=v=>{const n=parseFloat(v);return (v===''||v==null||isNaN(n))?null:n;};
|
|
2119
2169
|
// elevation = canonical decimal INCHES. parseLen accepts 5.75 | 5 3/4 | 1'-0 1/4" | 16'-6"
|
|
2120
2170
|
function parseLen(str){if(str==null)return null;
|
|
2121
2171
|
let s=String(str).trim().replace(/[”″]/g,'"').replace(/[’′]/g,"'");
|
|
@@ -2163,14 +2213,14 @@ function swapMemberEnds(m){
|
|
|
2163
2213
|
if(Array.isArray(m.ends)&&m.ends.length>=2)ModelCmd.reverseEnds(m); // the length guard stays OUTSIDE the primitive: a one-ended member is broken, and swallowing that inside would hide it at every call site
|
|
2164
2214
|
if(m.col)ModelCmd.swapColElevation(m.col,defaultTOS); // materialises BOTH sides first (bos null->0, tos null->defaultTOS), then swaps; a beam's vestigial col is swapped too, as it always was
|
|
2165
2215
|
if(braceOld){
|
|
2166
|
-
if(braceOld.tie||(m.brace.lowerEnd===0||m.brace.lowerEnd===1))m
|
|
2216
|
+
if(braceOld.tie||(m.brace.lowerEnd===0||m.brace.lowerEnd===1))ModelCmd.patchMemberBrace(m,{lowerEnd:(1-braceOld.old)});
|
|
2167
2217
|
// braceDisplayLine takes its perpendicular from the a→b direction, so reversing wp flips which SIDE the
|
|
2168
2218
|
// symbol is drawn on. Negate the offset to keep the drawn line exactly where it was (ui-ux review).
|
|
2169
|
-
if(m.brace.offset)m
|
|
2219
|
+
if(m.brace.offset)ModelCmd.patchMemberBrace(m,{offset:-m.brace.offset});
|
|
2170
2220
|
}
|
|
2171
2221
|
// F9: reversing swaps m's two physical points, so a dim ref's pt 'a'↔'b' must swap to keep pointing at the same
|
|
2172
2222
|
// real end. Plan-scoped by member identity — only THIS member's owning plan's dims (never by id across plans, Codex R4 #4).
|
|
2173
|
-
{const own=planeOfMember(m);for(const d of (own&&own.dims||[]))for(const rk of ['aRef','bRef']){const r=d[rk];if(r&&r.m===m.id&&(r.pt==='a'||r.pt==='b'))r.pt=r.pt==='a'?'b':'a';}}
|
|
2223
|
+
if(!MODEL_V2){const own=planeOfMember(m);for(const d of (own&&own.dims||[]))for(const rk of ['aRef','bRef']){const r=d[rk];if(r&&r.m===m.id&&(r.pt==='a'||r.pt==='b'))r.pt=r.pt==='a'?'b':'a';}}
|
|
2174
2224
|
return m;}
|
|
2175
2225
|
// Bulk "Swap start ↔ end" (multi-select button + the P shortcut). Braces are EXCLUDED: reversing a brace is
|
|
2176
2226
|
// the inspector's "Swap lower ↔ higher end" (arrow assignment, no geometry move). (ui-ux + Codex review: the
|
|
@@ -2200,7 +2250,7 @@ function braceLowerEnd(m){const b=(m&&m.brace)||{};if(b.lowerEnd===0||b.lowerEnd
|
|
|
2200
2250
|
// Seed defaults when entering brace, strip a stale sub-object off non-braces, clamp values. Idempotent —
|
|
2201
2251
|
// safe to call at load (all plans) AND after applyMemberType. Codex round-1/2: no stale/garbage m.brace.
|
|
2202
2252
|
function normBrace(m){
|
|
2203
|
-
if(!isBrace(m)){if(m&&m.brace)
|
|
2253
|
+
if(!isBrace(m)){if(m&&m.brace)ModelCmd.setMemberBrace(m,null);return m;}
|
|
2204
2254
|
const b=(m.brace&&typeof m.brace==='object')?m.brace:{};
|
|
2205
2255
|
const out={type:(b.type==='lateral')?'lateral':'vertical',
|
|
2206
2256
|
floor:(b.floor==='below')?'below':'above',
|
|
@@ -2211,7 +2261,7 @@ function normBrace(m){
|
|
|
2211
2261
|
// Display-only fields, hence a console warning rather than a toast. (silent-failure review)
|
|
2212
2262
|
const bad=['type','floor','offset','lowerEnd'].filter(k=>b[k]!==undefined&&b[k]!==out[k]);
|
|
2213
2263
|
if(bad.length)console.warn('normBrace: member '+(m.id||'?')+' had invalid brace field(s) '+bad.join(', ')+' — clamped',{was:b,now:out});
|
|
2214
|
-
m
|
|
2264
|
+
ModelCmd.setMemberBrace(m,out);return m;}
|
|
2215
2265
|
// The DRAWN line for a brace — READ-ONLY (pick / marquee / zoom-fit / label anchors), NEVER a mutation.
|
|
2216
2266
|
// Lateral & offset-0 = the true WPs; a vertical brace shifts perpendicular by brace.offset (inches→px).
|
|
2217
2267
|
function braceDisplayLine(m){const a=m.wp[0],b=m.wp[1];
|
|
@@ -2350,7 +2400,10 @@ const autofillTOS=syncDefaults;
|
|
|
2350
2400
|
// removed". Undo is not free here and this is the whole reason: the per-sheet capture below is blind to a
|
|
2351
2401
|
// grid that does not live on a sheet, so without this line every grid edit on a v2 document would be
|
|
2352
2402
|
// unundoable — silently, since Ctrl+Z would restore the sheets and report success.
|
|
2353
|
-
function snapshot(){
|
|
2403
|
+
function snapshot(){
|
|
2404
|
+
if(MODEL_V2)return JSON.stringify({v2:true,members:C.members,grid:C.grid||null,plans:C.plans.map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null})),joints:C.joints||[],connections:C.connections||[],details:C.detail_placements||[],views:C.views||[],member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
|
|
2405
|
+
return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],connections:Array.isArray(C.connections)?C.connections:null,clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
|
|
2406
|
+
}
|
|
2354
2407
|
// Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
|
|
2355
2408
|
// members, so one whole-model stack is coherent — undo restores all planes at once, and a cross-
|
|
2356
2409
|
// sheet edit/delete/to-level round-trips fully. (Earlier this was per-plane — `undo=P.undo` swapped
|
|
@@ -2374,6 +2427,11 @@ function apply(json){
|
|
|
2374
2427
|
// unused, and it is guarded for the same reason the other two are: an entry that arrives some other way
|
|
2375
2428
|
// would write `P.members` and a per-plan `grid`, both of which v2's plan schema forbids.
|
|
2376
2429
|
const d=JSON.parse(json);
|
|
2430
|
+
if(d.v2&&MODEL_V2){
|
|
2431
|
+
V2_SESSION.restoreSnapshot(d);
|
|
2432
|
+
V2_PROJECTION=v2ProjectionForSheet(C.plans[C.active].sheet);
|
|
2433
|
+
P=DEV_MODE?ModelCmd.deepFreezeProjection(V2_PROJECTION.plan):V2_PROJECTION.plan;
|
|
2434
|
+
}
|
|
2377
2435
|
// THE MODEL-LEVEL GRID, restored first and on its own path (unit 5, P7d). The per-sheet restore below
|
|
2378
2436
|
// cannot carry it — a v2 plan has no `grid` — so without this Ctrl+Z would walk every sheet back and
|
|
2379
2437
|
// leave the grid edit standing, reporting success. Keyed on the KEY being present, not on its value:
|
|
@@ -2386,9 +2444,9 @@ function apply(json){
|
|
|
2386
2444
|
// unpainted. Unreachable rather than merely unused, since edit() refuses before pushUndo; guarded for
|
|
2387
2445
|
// the same reason the other write primitives are, because an entry arriving some other way would write
|
|
2388
2446
|
// `P.members` and a per-plan `grid`, both of which v2's plan schema forbids.
|
|
2389
|
-
if(canWriteModel()){
|
|
2447
|
+
if(canWriteModel()&&!d.v2){
|
|
2390
2448
|
if(Array.isArray(d))P.members=d; // legacy member-only snapshot — no longer produced (dedupe/all paths now push whole-model snapshot()); kept defensively for any in-flight entry
|
|
2391
|
-
else if(Array.isArray(d.planes)){for(const o of d.planes){const tp=C.plans.find(p=>p.sheet===o.sheet);if(tp){tp.members=(o.members||[]).map(ensureMeta);if(Array.isArray(o.dims))tp
|
|
2449
|
+
else if(Array.isArray(d.planes)){for(const o of d.planes){const tp=C.plans.find(p=>p.sheet===o.sheet);if(tp){tp.members=(o.members||[]).map(ensureMeta);if(Array.isArray(o.dims))ModelCmd.setPlanDims(tp,o.dims);if('frame' in o)ModelCmd.setPlanFrame(tp,o.frame||null);if('grid' in o)tp.grid=o.grid;}else{console.error('undo: sheet '+o.sheet+' not found - slice skipped');toast('Undo couldn’t restore sheet '+o.sheet);}}if('joints' in d)C.joints=Array.isArray(d.joints)?d.joints:[];} // whole-model → restore EVERY sheet's OWN members/dims/frame/grid (cross-sheet undo restores each sheet's own, never the active sheet's over another's); joints captured whole
|
|
2392
2450
|
else{console.error('undo: legacy non-planes stack entry — no producer emits this any more; restoring members/joints only. dims/frame/grid are PER-SHEET in the planes format, so they are deliberately NOT written to the active plane here (that was the cross-sheet wrong-sheet footgun).');
|
|
2393
2451
|
const pmOld=new Set((P.members||[]).map(m=>m.id));P.members=d.members||[];
|
|
2394
2452
|
if('joints' in d){const own=new Set([...pmOld,...P.members.map(m=>m.id)]);C.joints=(C.joints||[]).filter(j=>!(j&&own.has(j.main))).concat(d.joints||[]);}
|
|
@@ -2428,7 +2486,8 @@ function apply(json){
|
|
|
2428
2486
|
function doUndo(){if(!undo.length)return;redo.push(snapshotLike());apply(undo.pop());}
|
|
2429
2487
|
function doRedo(){if(!redo.length)return;undo.push(snapshotLike());apply(redo.pop());}
|
|
2430
2488
|
/**
|
|
2431
|
-
* The
|
|
2489
|
+
* The grid transaction. In the live v2 editor it routes through the same canonical command session as
|
|
2490
|
+
* every other edit; the narrow flag remains for the pre-activation read-only fallback.
|
|
2432
2491
|
*
|
|
2433
2492
|
* Named, not flagged at the call site, so the exemption is a small closed set that can be read in one place
|
|
2434
2493
|
* instead of a boolean threaded through 148 `edit()` calls. Identical to `edit()` for v1.
|
|
@@ -2451,7 +2510,7 @@ function editGrid(fn){return edit(fn,GRID_EDIT);}
|
|
|
2451
2510
|
* initiates it, which is the rule this epic applies everywhere else.
|
|
2452
2511
|
*/
|
|
2453
2512
|
function editGridTopology(fn){
|
|
2454
|
-
if(
|
|
2513
|
+
if(MODEL_V2||!canWriteModel()){toast('Re-spacing changes which grid lines exist, so it goes through a reviewed model update — ask your terminal AI to change the grid.');return;}
|
|
2455
2514
|
return edit(fn,GRID_EDIT);}
|
|
2456
2515
|
function edit(fn,opts){
|
|
2457
2516
|
// READ-ONLY DOCUMENTS STOP HERE (unit 5, P7d). One refusal, at the transaction wrapper every model edit in
|
|
@@ -2470,7 +2529,17 @@ function edit(fn,opts){
|
|
|
2470
2529
|
// silently. Only that banner is dismissed — the AI-update and conflict bars MUST survive edits, which is
|
|
2471
2530
|
// the entire reason the conflict bar exists. (unit 5, P1c-3)
|
|
2472
2531
|
const _b=document.getElementById('aiUpdateBanner'); if(_b&&_b.dataset.kind==='staleBase')_b.remove();
|
|
2473
|
-
const pv=snapshot();
|
|
2532
|
+
const pv=snapshot();
|
|
2533
|
+
try{fn();}
|
|
2534
|
+
catch(err){
|
|
2535
|
+
if(err&&err.name==='V2CommandError'){
|
|
2536
|
+
drawDraft=null;dimDraft=null;cmDraft=null;drawPrevClear();dimPrevClear();cmPrevClear();
|
|
2537
|
+
const text=err.code==='elevation-unknown'
|
|
2538
|
+
?`Couldn’t complete that edit: the elevation is unknown. Enter the TOS first.`
|
|
2539
|
+
:(err.message||'That edit could not be applied safely.');
|
|
2540
|
+
toast(text);render();return false;}
|
|
2541
|
+
throw err;}
|
|
2542
|
+
pushUndo(pv);render();sync3D();return true;}
|
|
2474
2543
|
// --- auto-save: edits persist to this browser (localStorage). Raster stays embedded; only members + TOS are stored. ---
|
|
2475
2544
|
const LSKEY = draftKey(); // app + project + type — see draftKey() in the outer scope, which boot()'s SSE handler shares (it cannot see this closure, which is why the key used to be spelled out twice)
|
|
2476
2545
|
// A structural guard, NOT a base identity — it only knows sheet names and segment counts, so two genuinely
|
|
@@ -2513,9 +2582,10 @@ function sanitizeViews(arr){return ViewGen.sanitizeViews(arr);}
|
|
|
2513
2582
|
// after an external write discarded it with no offer and no warning. See applyDraftReadOnlyFields for
|
|
2514
2583
|
// restore half. Undefined on v1, where JSON.stringify simply drops it.
|
|
2515
2584
|
function persist(){try{localStorage.setItem(LSKEY,JSON.stringify({sig:dataSig(),baseEtag:serverEtag,ts:Date.now(),active:C.active,
|
|
2585
|
+
members:MODEL_V2?C.members:undefined,
|
|
2516
2586
|
grid:C.grid,
|
|
2517
2587
|
custom_details:C.custom_details, profile_colors:C.profile_colors, member_styles:C.member_styles, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, connections:C.connections, detail_placements:C.detail_placements, views:C.views,
|
|
2518
|
-
plans:C.plans.map(p=>
|
|
2588
|
+
plans:C.plans.map(p=>MODEL_V2?p:{sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,callouts:p.callouts,dims:p.dims,frame:p.frame||null,grid:p.grid||null})}));return true;}catch(e){setSaved('err');console.error('local autosave failed',e);return false;}}
|
|
2519
2589
|
// --- server-side draft save: PUT the FULL contract C — this is the copy Approve bakes.
|
|
2520
2590
|
// localStorage (persist) stays the instant per-browser draft cache; this is the durable one.
|
|
2521
2591
|
// fetch does NOT reject on HTTP 400 (schema rejection), so treat !res.ok as 'err' (not a false 'Saved ✓'). ---
|
|
@@ -2763,6 +2833,24 @@ window.flushContract = async () => {
|
|
|
2763
2833
|
* is defence-in-depth against a future caller that skips the gate.
|
|
2764
2834
|
*/
|
|
2765
2835
|
function applyDraftFields(d){
|
|
2836
|
+
if(MODEL_V2){
|
|
2837
|
+
const candidate=structuredClone(C);
|
|
2838
|
+
const rootKeys=['members','grid','custom_details','profile_colors','member_styles','member_types','target_confidence','dims3d','dim_overlays','dim_style','prop_labels','joints','connections','detail_placements','views'];
|
|
2839
|
+
for(const key of rootKeys)if(key in d)candidate[key]=structuredClone(d[key]);
|
|
2840
|
+
if(Array.isArray(d.plans)){
|
|
2841
|
+
const bySheet=new Map(d.plans.filter(p=>p&&typeof p.sheet==='string').map(p=>[p.sheet,p]));
|
|
2842
|
+
candidate.plans=candidate.plans.map(p=>bySheet.has(p.sheet)?structuredClone(bySheet.get(p.sheet)):p);
|
|
2843
|
+
}
|
|
2844
|
+
if(d.active!=null)candidate.active=d.active;
|
|
2845
|
+
try{
|
|
2846
|
+
V2_SESSION.replaceDocument(candidate,'restore browser draft');
|
|
2847
|
+
C.active=candidate.active;
|
|
2848
|
+
return true;
|
|
2849
|
+
}catch(err){
|
|
2850
|
+
console.warn('steel-editor: a stored v2 draft failed canonical validation and was not applied',err);
|
|
2851
|
+
return false;
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2766
2854
|
// The per-plan pass below is V1-SHAPED, and overlaying it onto a read-only v2 document is one of the
|
|
2767
2855
|
// three leaks §8.4 names: it writes `members`, `default_tos` and `grid`, all three of which v2's plan
|
|
2768
2856
|
// schema forbids. Refused at the primitive rather than at each caller, so the automatic restore and the
|
|
@@ -2785,7 +2873,7 @@ function applyDraftFields(d){
|
|
|
2785
2873
|
// callouts ride along with details: a detail RENAME rewrites both (applyDetailRename), so restoring one
|
|
2786
2874
|
// without the other brings back renamed member ends pointing at a callout that still says the old name —
|
|
2787
2875
|
// every one of those ends silently stops resolving, with the drawing showing the contradiction (#397).
|
|
2788
|
-
C.plans.forEach(p=>{const s=by[p.sheet];if(s){if(Array.isArray(s.members))p.members=s.members;if(s.default_tos!=null)p.default_tos=s.default_tos;if(Array.isArray(s.details))p.details=s.details;if(Array.isArray(s.callouts))p.callouts=s.callouts;if(Array.isArray(s.dims))p
|
|
2876
|
+
C.plans.forEach(p=>{const s=by[p.sheet];if(s){if(Array.isArray(s.members))p.members=s.members;if(s.default_tos!=null)p.default_tos=s.default_tos;if(Array.isArray(s.details))p.details=s.details;if(Array.isArray(s.callouts))p.callouts=s.callouts;if(Array.isArray(s.dims))ModelCmd.setPlanDims(p,s.dims);if('frame' in s)ModelCmd.setPlanFrame(p,s.frame||null);if('grid' in s)p.grid=s.grid||null;p.autofilled=true;}});
|
|
2789
2877
|
if(Array.isArray(d.dims3d))C.dims3d=SteelCore?SteelCore.sanitizeDims3d(d.dims3d):d.dims3d; // restore model-global 3D dims from the local draft — re-sanitise axisDir (a stale draft could carry junk that would wedge the next save)
|
|
2790
2878
|
if(Array.isArray(d.detail_placements))C.detail_placements=d.detail_placements; // restore placed details
|
|
2791
2879
|
if(d.dim_overlays&&typeof d.dim_overlays==='object'&&!Array.isArray(d.dim_overlays)){const o=d.dim_overlays;C.dim_overlays={bolt_pitch:o.bolt_pitch!==false,edge_clearance:o.edge_clearance!==false,cope_size:o.cope_size!==false,base_plate:o.base_plate!==false,anchor_depth:o.anchor_depth!==false};} // restore the legend DIMENSIONS toggles — sanitised to the known boolean keys (a corrupt/partial draft can't desync the legend from what's drawn; on unless explicitly false)
|
|
@@ -2843,6 +2931,14 @@ function v2DraftFits(d){
|
|
|
2843
2931
|
// JSON compare: both sides descend from the same object graph (C → persist → JSON.parse), so key
|
|
2844
2932
|
// order matches whenever the values do. A false "differs" would only cost a no-op offer; a false
|
|
2845
2933
|
// "same" would drop the user's edit, so the comparison errs in the safe direction by construction.
|
|
2934
|
+
if(MODEL_V2_LIVE){
|
|
2935
|
+
const rootKeys=['members','grid','custom_details','profile_colors','member_styles','member_types','target_confidence','dims3d','dim_overlays','dim_style','prop_labels','joints','connections','detail_placements','views'];
|
|
2936
|
+
if(rootKeys.some(k=>k in d&&JSON.stringify(d[k])!==JSON.stringify(C&&C[k])))return true;
|
|
2937
|
+
if(Array.isArray(d.plans)){
|
|
2938
|
+
const bySheet=new Map((C.plans||[]).map(p=>[p.sheet,p]));
|
|
2939
|
+
if(d.plans.some(p=>!bySheet.has(p.sheet)||JSON.stringify(p)!==JSON.stringify(bySheet.get(p.sheet))))return true;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2846
2942
|
return RO_DRAFT_KEYS.some(k=>k in d&&JSON.stringify(d[k])!==JSON.stringify(C&&C[k]));
|
|
2847
2943
|
}
|
|
2848
2944
|
/**
|
|
@@ -3236,7 +3332,22 @@ function columnSectionPoly(m){
|
|
|
3236
3332
|
const wp=m&&m.wp;if(!wp||!wp.length)return null;
|
|
3237
3333
|
const a=wp[0],b=wp[wp.length-1],cx=(a[0]+b[0])/2,cy=(a[1]+b[1])/2;
|
|
3238
3334
|
const ppf=(P&&P.pt_per_ft>0)?P.pt_per_ft:0,dims=profileDimsIn(m.profile);
|
|
3239
|
-
|
|
3335
|
+
// Both arms hand INCHES to the one conversion below. profileDimsIn already returns inches; the
|
|
3336
|
+
// reader's traced `section` is MILLIMETRES — contract-to-scene feeds those very numbers into a
|
|
3337
|
+
// scene declared `units:'mm'`, and the steel-takeoff skill tells readers to trace in mm. Neither
|
|
3338
|
+
// schema said so until #502, which is how the two units drifted apart; both now declare it.
|
|
3339
|
+
// Feeding mm through the inch path drew every traced column 25.4x oversize — on a 1/4" sheet a
|
|
3340
|
+
// W14x193 spanned 33 feet, and the translucent fills stacked into a wash that hid the drawing (#502).
|
|
3341
|
+
const traced=(m.section&&m.section.w>0&&m.section.d>0&&ppf)?{w:m.section.w/25.4,d:m.section.d/25.4}:null;
|
|
3342
|
+
// A trace can also be mis-scaled the OTHER way — contract-to-scene records seeing {3.3,3.3} on an
|
|
3343
|
+
// HSS6X6X3/8. Drawn honestly that is 0.2pt on a 1/4" sheet and rounds to nothing on a 1/8" one, and
|
|
3344
|
+
// because this polygon IS the click target the column would be invisible AND unselectable — leaving
|
|
3345
|
+
// the user no way to click it and set the profile. Under the tool's own "meaningfully there" floor
|
|
3346
|
+
// we therefore fall through to the generic marker, which claims no size at all, rather than clamping
|
|
3347
|
+
// to one that would misreport the trace. A legitimately small column is unaffected: the smallest in
|
|
3348
|
+
// #502 draws 6.6pt, above the floor.
|
|
3349
|
+
const sec=(dims&&ppf)?{w:dims.w,d:dims.d}
|
|
3350
|
+
:((traced&&Math.min(traced.w,traced.d)/12*ppf>=GRID_LINE_MIN_DISP)?traced:null);
|
|
3240
3351
|
// Profile-derived section (primary) OR the reader's traced footprint (fallback) — an RFI column with a
|
|
3241
3352
|
// traced `section` still renders at its REAL size instead of a tiny generic marker.
|
|
3242
3353
|
if(sec){
|
|
@@ -3251,11 +3362,59 @@ const _polyStr=pts=>pts.map(p=>p[0].toFixed(1)+','+p[1].toFixed(1)).join(' ');
|
|
|
3251
3362
|
// the blurry raster JPEG. Vector PDFs expose filterElsForPlan(); a genuinely scanned sheet (no vectors)
|
|
3252
3363
|
// falls back to the RB64 raster. ponytail: all line d's are merged into ONE <path> so the browser parses
|
|
3253
3364
|
// one node, not thousands — fast to re-render on pan/zoom.
|
|
3254
|
-
function hasOverlay(){
|
|
3365
|
+
function hasOverlay(){const d=drawablePlan();return d?d.renders:!!RB64;} // F13: the active plan carries a reference sheet — vector linework or a scanned raster. Keyed on whether anything DRAWABLE actually paints, so a vector sheet whose every layer is hidden (or whose survivors are all text) greys the toggle out instead of offering to show a blank page; only a sheet with NO vectors falls through to the raster (#507)
|
|
3366
|
+
// #507: `filter.layers[].drawable === false` means "listed but not drawn (e.g. a text/title-block
|
|
3367
|
+
// layer)" — the schema's own words. Only the Steel Filter's row styling ever honoured it; the plan drew
|
|
3368
|
+
// every element regardless, so a reader that marked its noise non-drawable exactly as instructed still
|
|
3369
|
+
// got the noise. On a faithfully-read sheet that is ~27 backdrop strokes per steel stroke, and the only
|
|
3370
|
+
// escape was to DELETE those elements from the contract — which throws away the user's ability to switch
|
|
3371
|
+
// the layer back on, the very thing the filter exists for.
|
|
3372
|
+
// The layer stays LISTED with its true count (that panel is steel-filter's and is untouched); this skips
|
|
3373
|
+
// the draw alone. Layers are global — one list applies to every sheet — per the takeoff schema.
|
|
3374
|
+
function nonDrawableLayers(){const f=C&&C.filter,out=new Set();
|
|
3375
|
+
for(const l of (f&&f.layers)||[]) if(l&&l.drawable===false&&typeof l.name==='string') out.add(l.name);
|
|
3376
|
+
return out;}
|
|
3377
|
+
// The sheet's linework MINUS every non-drawable layer — the one set all three overlay consumers share
|
|
3378
|
+
// (draw, snap, has-a-sheet), so what you can see, what you can snap to, and whether the toggle is even
|
|
3379
|
+
// enabled can never disagree. null and [] mean DIFFERENT things and callers must keep them apart:
|
|
3380
|
+
// null = this plan carries no vector overlay at all (a scanned sheet, so the raster IS the reference
|
|
3381
|
+
// sheet); [] = it carries one but every layer of it is hidden, and the raster must NOT stand in for it
|
|
3382
|
+
// — that bitmap is a picture of the whole sheet, so it would put the very text and title block the user
|
|
3383
|
+
// suppressed straight back on screen.
|
|
3384
|
+
// NOT folded into filterElsForPlan(): gridReadFromDrawing() reads the RAW set to detect the printed
|
|
3385
|
+
// grid, and the bubbles it hunts routinely sit on an annotation layer a reader would mark non-drawable.
|
|
3386
|
+
// Hiding them from the canvas must not blind the detector.
|
|
3387
|
+
// Memoised on the source array's identity AND the hidden-layer set, because overlaySnapGeom() caches
|
|
3388
|
+
// its parse by identity: handing it a fresh array each call would re-parse ~25k elements every snap.
|
|
3389
|
+
// The memo holds the ANSWER, not loose parallel variables: the filtered elements, how many layers were
|
|
3390
|
+
// hidden to get them, and whether any of them will actually paint. Keeping the count beside the array
|
|
3391
|
+
// is not tidiness — a count stored separately went stale on a cache HIT (sheet A hidden, switch to a
|
|
3392
|
+
// vectorless sheet B, switch back: B zeroed the count, A's early return handed back its cached array
|
|
3393
|
+
// without restoring it, and the tooltip then claimed nothing was excluded). Found by review.
|
|
3394
|
+
let _draw=null,_drawSrc=null,_drawKey=null;
|
|
3395
|
+
function drawablePlan(){
|
|
3396
|
+
const els=filterElsForPlan();
|
|
3397
|
+
if(!els){_draw=null;_drawSrc=null;_drawKey=null;return null;} // no vector overlay at all — every memo slot invalidated together, so nothing can survive into the next sheet
|
|
3398
|
+
const nd=nonDrawableLayers(),key=nd.size?JSON.stringify(Array.from(nd).sort()):''; // JSON, not a join: it escapes any separator character a CAD layer name might itself contain, so two different sets cannot produce one key — and unlike a NUL separator it leaves no control byte in this file (a raw one makes the browser's script tokenizer read U+FFFD where the node harness reads U+0000, and turns the file binary to grep)
|
|
3399
|
+
if(els===_drawSrc&&key===_drawKey&&_draw)return _draw;
|
|
3400
|
+
let out=els,hidden=0; // no hidden layer: the SAME array, so overlaySnapGeom's identity cache still hits
|
|
3401
|
+
if(nd.size){const seen=new Set();out=[];
|
|
3402
|
+
for(const e of els){if(e&&nd.has(e.layer)){seen.add(e.layer);continue;}out.push(e);}
|
|
3403
|
+
hidden=seen.size;} // counted from the ELEMENTS, so a layer marked non-drawable but absent from this sheet is never reported as hidden here
|
|
3404
|
+
let renders=false; // …and does anything LEFT actually paint? Raw length is not the question: a sheet of nothing but text spans, or of lines with no usable geometry, is length>0 and draws a blank white backdrop that reads as a failed read
|
|
3405
|
+
for(const e of out){if(!e)continue;
|
|
3406
|
+
if(e.kind==='line'&&((typeof e.d==='string'&&e.d)||(e.x1!=null&&e.x2!=null))){renders=true;break;}
|
|
3407
|
+
if(e.kind==='circle'&&e.r>0){renders=true;break;}}
|
|
3408
|
+
_drawSrc=els;_drawKey=key;_draw={els:out,hidden,renders};
|
|
3409
|
+
return _draw;}
|
|
3410
|
+
function drawableElsForPlan(){const d=drawablePlan();return d?d.els:null;}
|
|
3411
|
+
function hiddenLayerCount(){const d=drawablePlan();return d?d.hidden:0;}
|
|
3255
3412
|
function overlaySvg(){
|
|
3256
3413
|
if(!refSheetOn)return ''; // F13: reference sheet hidden → draw neither the raster/vector linework NOR the white pdfsheet backdrop
|
|
3257
|
-
const
|
|
3258
|
-
if(!
|
|
3414
|
+
const d0=drawablePlan();
|
|
3415
|
+
if(!d0)return RB64?`<image href="data:image/jpeg;base64,${RB64}" x="${X0}" y="${Y0}" width="${X1-X0}" height="${Y1-Y0}"/>`:''; // no vectors at all: the scanned raster IS the reference sheet
|
|
3416
|
+
if(!d0.renders)return ''; // vectors exist but nothing left will paint: draw NOTHING. Not the white backdrop (that reads as a failed read), and emphatically not RB64 — the raster pictures the WHOLE sheet, so it would put the suppressed text and title block straight back on screen
|
|
3417
|
+
const els=d0.els;
|
|
3259
3418
|
let d='',circ='';
|
|
3260
3419
|
for(const e of els){if(!e)continue;
|
|
3261
3420
|
if(e.kind==='line'){if(typeof e.d==='string'&&e.d)d+=e.d+' ';else if(e.x1!=null&&e.x2!=null)d+=`M${e.x1} ${e.y1}L${e.x2} ${e.y2}`;}
|
|
@@ -3293,10 +3452,10 @@ function dominantAxis(a,p){const dx=p[0]-a[0],dy=p[1]-a[1];
|
|
|
3293
3452
|
// minimal validator can't express unit-length, so we sanitize at the load boundary — UI-set frames are clean.)
|
|
3294
3453
|
function sanitizeFrame(p){const f=p&&p.frame;if(!f)return;
|
|
3295
3454
|
const okPt=a=>Array.isArray(a)&&a.length>=2&&isFinite(a[0])&&isFinite(a[1]);
|
|
3296
|
-
if(!okPt(f.u)||!okPt(f.o)){p
|
|
3455
|
+
if(!okPt(f.u)||!okPt(f.o)){ModelCmd.setPlanFrame(p,null);return;}
|
|
3297
3456
|
const L=Math.hypot(f.u[0],f.u[1]);
|
|
3298
|
-
if(!(L>1e-6)){p
|
|
3299
|
-
if(Math.abs(L-1)>1e-6)f
|
|
3457
|
+
if(!(L>1e-6)){ModelCmd.setPlanFrame(p,null);return;} // zero-length → no usable axis → global
|
|
3458
|
+
if(Math.abs(L-1)>1e-6)ModelCmd.setPlanFrame(p,{...f,u:[f.u[0]/L,f.u[1]/L]});} // normalize a non-unit direction
|
|
3300
3459
|
// --- dimension geometry (display space, y-down). `off` meaning by axis: x -> the dim-line Y;
|
|
3301
3460
|
// y -> the dim-line X; free -> signed perpendicular distance from the a->b baseline. ---
|
|
3302
3461
|
// `rot` (rad) = the dim's baked local frame; 0 = global (screen-aligned x/y, today's behavior). For x/y
|
|
@@ -3335,6 +3494,10 @@ function resolveDimGridAnchor(plan,gid,d){
|
|
|
3335
3494
|
if(gid.startsWith('gv:')){const l=(geo.v||[])[+gid.slice(3)];if(l){p1=[l.x,l.lo];p2=[l.x,l.hi];}}
|
|
3336
3495
|
else if(gid.startsWith('gh:')){const l=(geo.h||[])[+gid.slice(3)];if(l){p1=[l.lo,l.y];p2=[l.hi,l.y];}}
|
|
3337
3496
|
else if(gid.startsWith('gl:')){const lid=gid.slice(3),l=(geo.lines||[]).find((x,i)=>String(x.id!=null?x.id:i)===lid);if(l){p1=l.a;p2=l.b;}}
|
|
3497
|
+
else{const axis=(plan.grid.axes||[]).find(row=>row&&String(row.id)===gid);
|
|
3498
|
+
if(axis){const rows=(plan.grid.axes||[]).filter(row=>row&&row.dir===axis.dir),i=rows.indexOf(axis),l=axis.dir==='x'?(geo.v||[])[i]:axis.dir==='y'?(geo.h||[])[i]:null;
|
|
3499
|
+
if(l&&axis.dir==='x'){p1=[l.x,l.lo];p2=[l.x,l.hi];}else if(l&&axis.dir==='y'){p1=[l.lo,l.y];p2=[l.hi,l.y];}}
|
|
3500
|
+
else{const l=(geo.lines||[]).find(row=>String(row&&row.id)===gid);if(l){p1=l.a;p2=l.b;}}}
|
|
3338
3501
|
if(!p1)return null;
|
|
3339
3502
|
const rot=d.rot||0,lyv=q=>rotPt(q,-rot)[1];
|
|
3340
3503
|
const l1=lyv(p1),l2=lyv(p2);if(Math.abs(l2-l1)<1e-6)return null; // grid runs along the row → no stable anchor
|
|
@@ -3356,11 +3519,18 @@ function reanchorDim(plan,d){let dropped=false;
|
|
|
3356
3519
|
// Pre-render pass over EVERY plan: keep magnetic dims glued to their members. O(dims), idempotent. One toast
|
|
3357
3520
|
// when any ref is dropped this pass (its member vanished) — naturally once per deletion.
|
|
3358
3521
|
function reanchorAllPlans(){let dropped=false;
|
|
3359
|
-
|
|
3522
|
+
if(MODEL_V2&&P){const dims=JSON.parse(JSON.stringify(P.dims||[])),before=JSON.stringify(dims);
|
|
3523
|
+
for(const d of dims)if(d&&(d.aRef||d.bRef)){if(reanchorDim({...P,dims},d))dropped=true;}
|
|
3524
|
+
if(JSON.stringify(dims)!==before)V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3525
|
+
}else for(const plan of (C.plans||[]))for(const d of (plan.dims||[]))if(d&&(d.aRef||d.bRef)){if(reanchorDim(plan,d))dropped=true;}
|
|
3360
3526
|
if(dropped)toast('A dimension lost its link to a removed member or grid line');}
|
|
3361
3527
|
// Live path for the 2D member/endpoint drag, which updateLine()s WITHOUT a full render (:4135/:4141): reanchor
|
|
3362
3528
|
// only the active plan's magnetic dims + rebuild the dim overlay group, so dims track while the pointer is down.
|
|
3363
|
-
function refreshMagneticDims2D(){
|
|
3529
|
+
function refreshMagneticDims2D(){
|
|
3530
|
+
if(MODEL_V2){const dims=JSON.parse(JSON.stringify(P.dims||[])),before=JSON.stringify(dims);
|
|
3531
|
+
for(const d of dims)if(d&&(d.aRef||d.bRef))reanchorDim({...P,dims},d);
|
|
3532
|
+
if(JSON.stringify(dims)!==before)V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3533
|
+
}else for(const d of (P.dims||[]))if(d&&(d.aRef||d.bRef))reanchorDim(P,d);
|
|
3364
3534
|
const dg=svg.querySelector('g.dimsg');if(dg)dg.innerHTML=renderDimsInner();}
|
|
3365
3535
|
// F9 (QA 2026-07-16): the ref a hand-dragged dim anchor should carry after landing at pt — so magnetism
|
|
3366
3536
|
// SURVIVES handle moves instead of silently detaching. Drop on a member end/mid → {m,pt}; on a grid line
|
|
@@ -3437,7 +3607,7 @@ const _dEnd=v=>DIM_ENDS.includes(v),_dPlace=v=>v==='on'||v==='above',_dBg=v=>typ
|
|
|
3437
3607
|
// or an AI-authored contract can't put junk on the canvas.
|
|
3438
3608
|
function sanitizeDimStyle(){const s=(C&&C.dim_style&&typeof C.dim_style==='object'&&!Array.isArray(C.dim_style))?C.dim_style:{};
|
|
3439
3609
|
C.dim_style={end:_dEnd(s.end)?s.end:DIM_DEF.end,bg:_dBg(s.bg)?s.bg:DIM_DEF.bg,place:_dPlace(s.place)?s.place:DIM_DEF.place};}
|
|
3440
|
-
if(
|
|
3610
|
+
if(!MODEL_V2)sanitizeDimStyle(); // v2 arrives closed + validated; v1 needs repair
|
|
3441
3611
|
function dimStyle(d){const g=(C&&C.dim_style)||DIM_DEF;return {
|
|
3442
3612
|
end: (d&&_dEnd(d.end)) ?d.end :(_dEnd(g.end) ?g.end :DIM_DEF.end),
|
|
3443
3613
|
bg: (d&&_dBg(d.bg)) ?d.bg :(_dBg(g.bg) ?g.bg :DIM_DEF.bg),
|
|
@@ -3448,7 +3618,7 @@ const dimHasOverride=d=>!!d&&(_dEnd(d.end)||_dBg(d.bg)||_dPlace(d.place));
|
|
|
3448
3618
|
// is interpolated straight into SVG attributes, so a non-numeric anchor is attribute injection, not merely
|
|
3449
3619
|
// a broken drawing — drop any dim we can't trust, and keep only style fields with a known value.
|
|
3450
3620
|
function sanitizeDims(p){if(!p)return;
|
|
3451
|
-
if(!Array.isArray(p.dims)){p
|
|
3621
|
+
if(!Array.isArray(p.dims)){ModelCmd.setPlanDims(p,[]);return;}
|
|
3452
3622
|
// NOT the global isFinite: isFinite(null) and isFinite('') are both true, which would silently REPAIR a
|
|
3453
3623
|
// junk anchor into 0 rather than drop the dim. A numeric string is still accepted (a hand-edited file).
|
|
3454
3624
|
const num=v=>{const n=(typeof v==='number')?v:((typeof v==='string'&&v.trim()!=='')?Number(v):NaN);return Number.isFinite(n)?n:null;};
|
|
@@ -3465,13 +3635,15 @@ function sanitizeDims(p){if(!p)return;
|
|
|
3465
3635
|
// a/b/mid. Grid ref {g}: kept when it has the synthetic-id shape and THIS plan has a grid (the resolver
|
|
3466
3636
|
// safe-freezes an index that no longer exists). Else dropped.
|
|
3467
3637
|
const okMRef=x=>x&&typeof x==='object'&&typeof x.m==='string'&&(x.pt==='a'||x.pt==='b'||x.pt==='mid')&&(p.members||[]).some(mm=>mm&&mm.id===x.m&&isDimAnchorableMember(mm));
|
|
3468
|
-
const okGRef=x=>x&&typeof x==='object'&&typeof x.g==='string'
|
|
3638
|
+
const okGRef=x=>{if(!(x&&typeof x==='object'&&typeof x.g==='string'&&p.grid))return false;
|
|
3639
|
+
if(!MODEL_V2)return /^g[vhl]:/.test(x.g);
|
|
3640
|
+
return [...(p.grid.axes||[]),...(p.grid.lines||[])].some(row=>row&&String(row.id)===x.g);};
|
|
3469
3641
|
const cpRef=x=>okGRef(x)?{g:x.g}:(okMRef(x)?{m:x.m,pt:x.pt}:null);
|
|
3470
3642
|
{const ar=cpRef(d.aRef),br=cpRef(d.bRef);if(ar)q.aRef=ar;if(br)q.bRef=br;}
|
|
3471
3643
|
if(d.pin===false&&(q.aRef||q.bRef))q.pin=false; // F9: a dormant (unpinned) link survives the load — but only alongside a surviving ref
|
|
3472
3644
|
out.push(q);}
|
|
3473
3645
|
if(out.length!==p.dims.length)console.warn('discarding '+(p.dims.length-out.length)+' malformed dimension(s) on '+p.sheet);
|
|
3474
|
-
p
|
|
3646
|
+
ModelCmd.setPlanDims(p,out);}
|
|
3475
3647
|
// the two end markers, sized in 1/dz so they track the label's shrink. `dot` is a disc on the anchor;
|
|
3476
3648
|
// `tick` is the drafting oblique slash (the dim-line direction turned 45°); `arrow` puts its tip on the
|
|
3477
3649
|
// anchor and its tail inboard.
|
|
@@ -3579,7 +3751,10 @@ function gridOf(){const h=gridHost();return (h&&h.grid)||null;}
|
|
|
3579
3751
|
* is the re-space; `moveGridLineEnd` writes v1's index-keyed `ends_x`/`ends_y`, a vocabulary v2 replaced
|
|
3580
3752
|
* with an axis-id map; and `setGridLineEnds` moves a free line whose coordinates would be display px.
|
|
3581
3753
|
*/
|
|
3582
|
-
function gridDragAllowed(){
|
|
3754
|
+
function gridDragAllowed(kind='regular'){
|
|
3755
|
+
if(MODEL_V2&&kind!=='free'){
|
|
3756
|
+
toast('Re-spacing or trimming regular grid axes needs a reviewed model update because dimensions reference their stable ids.');
|
|
3757
|
+
return false;}
|
|
3583
3758
|
if(canWriteModel())return true;
|
|
3584
3759
|
console.warn('steel-editor: a grid drag was refused — this document is open read-only');
|
|
3585
3760
|
return false;}
|
|
@@ -3771,6 +3946,17 @@ function setGridMode(on){if(!C)return;gridMode=!!on;
|
|
|
3771
3946
|
function setDimStyleMode(on){if(!C||(on&&view3d))return;dimStyleMode=!!on; // 2D-only: the pane styles the 2D dim overlay, so refuse to arm it in 3D (the menu entry is hidden there too)
|
|
3772
3947
|
if(dimStyleMode){if(mode==='add'){mode='sel';setMode();}if(dimMode){dimMode=false;setDimMode();}if(gridMode)setGridMode(false);if(csaxisMode){csaxisMode=false;setCsMode();}if(cmTool)disarmCm();geoMode=null;setGeo();selIds.clear();selDimIds.clear();}
|
|
3773
3948
|
panel();}
|
|
3949
|
+
function updatePlanDims(fn){
|
|
3950
|
+
if(!MODEL_V2){const before=JSON.stringify((P&&P.dims)||[]);fn(P.dims);return JSON.stringify(P.dims)!==before;}
|
|
3951
|
+
const dims=JSON.parse(JSON.stringify((P&&P.dims)||[])),before=JSON.stringify(dims);fn(dims);
|
|
3952
|
+
if(JSON.stringify(dims)===before)return false;
|
|
3953
|
+
V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3954
|
+
return true;}
|
|
3955
|
+
function updatePlanDim(id,fn){return updatePlanDims(dims=>{const d=dims.find(row=>row&&row.id===id);if(d)fn(d);});}
|
|
3956
|
+
function deleteV2Selection(args){
|
|
3957
|
+
const effect=V2_SESSION.deleteSelection(P.sheet,args),n=effect&&effect.value&&effect.value.presentationOnly?effect.value.presentationOnly.length:0;
|
|
3958
|
+
if(n)toast(`${n} crossing column${n===1?' is':'s are'} derived from this sheet's cut and remain visible; no geometry was deleted.`);
|
|
3959
|
+
return effect;}
|
|
3774
3960
|
function renderDimStylePanel(p){
|
|
3775
3961
|
const g=C.dim_style,over=(P.dims||[]).filter(dimHasOverride).length;
|
|
3776
3962
|
p.innerHTML=`<span class=badge>Dimension style</span>
|
|
@@ -3786,12 +3972,12 @@ function renderDimStylePanel(p){
|
|
|
3786
3972
|
<div class=hint style="margin-top:4px"><b>${over}</b> dimension${over===1?'':'s'} on this sheet ${over===1?'has its':'have their'} own style and ${over===1?'ignores':'ignore'} these defaults.</div>
|
|
3787
3973
|
<button id=dimClearOv class=ghostw style="margin-top:8px" data-tip="Drop the per-dimension styles on this sheet so every dimension follows the defaults again. Undoable.">Follow defaults again</button>`:''}
|
|
3788
3974
|
<div class=hint style="margin-top:10px"><b>Esc</b> closes. Select a dimension to give it its own style.</div>`;
|
|
3789
|
-
const setG=fn=>edit(()=>{fn(C.dim_style);}); // undoable: snapshot() carries dim_style like every other model-global field
|
|
3975
|
+
const setG=fn=>edit(()=>{if(MODEL_V2){const next=JSON.parse(JSON.stringify(C.dim_style||{}));fn(next);V2_SESSION.patchModel({dim_style:next});}else fn(C.dim_style);}); // undoable: snapshot() carries dim_style like every other model-global field
|
|
3790
3976
|
p.querySelectorAll('button[data-gend]').forEach(b=>b.onclick=()=>setG(s=>{s.end=b.dataset.gend;}));
|
|
3791
3977
|
p.querySelectorAll('button[data-gplace]').forEach(b=>b.onclick=()=>setG(s=>{s.place=b.dataset.gplace;}));
|
|
3792
3978
|
document.getElementById('gDimBg').onchange=e=>setG(s=>{s.bg=e.target.checked;});
|
|
3793
3979
|
const cl=document.getElementById('dimClearOv');
|
|
3794
|
-
if(cl)cl.onclick=()=>{const n=over;edit(()=>{for(const d of
|
|
3980
|
+
if(cl)cl.onclick=()=>{const n=over;edit(()=>{updatePlanDims(dims=>{for(const d of dims){delete d.end;delete d.bg;delete d.place;}});});toast(`${n} dimension${n===1?'':'s'} now follow${n===1?'s':''} the defaults`);};}
|
|
3795
3981
|
// The grid panel (armed-tool takeover, like the Dimension tool). Empty state = two explicit create
|
|
3796
3982
|
// buttons (nothing is created just by opening — UX review); fields commit on change (blur/Enter),
|
|
3797
3983
|
// one undo step each; keystrokes only update the live feedback line.
|
|
@@ -3804,10 +3990,10 @@ function renderGridPanel(p){
|
|
|
3804
3990
|
// The no-grid branch CREATES one, which mints the very axes the re-space refusal exists to protect —
|
|
3805
3991
|
// so on a read-only document all four of its actions are topological. Gated at the transaction as well
|
|
3806
3992
|
// (editGridTopology); this is the chrome saying so. (unit 5, P7d — Codex H9.)
|
|
3807
|
-
const roTopo=MODEL_RO?' disabled aria-describedby=gridRoWhy':'';
|
|
3993
|
+
const roTopo=(MODEL_V2||MODEL_RO)?' disabled aria-describedby=gridRoWhy':'';
|
|
3808
3994
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
3809
3995
|
<div class=hint style="margin-top:8px">No grid yet. Grid lines are a plan reference — they don't constrain members.</div>
|
|
3810
|
-
${MODEL_RO?'<div class=hint id=gridRoWhy style="margin-top:8px">Starting a grid decides which grid lines <i>exist</i>, and dimensions anchor to them — so it goes through a reviewed model update. Ask your terminal AI to add a grid, and you can move and relabel it here.</div>':''}
|
|
3996
|
+
${(MODEL_V2||MODEL_RO)?'<div class=hint id=gridRoWhy style="margin-top:8px">Starting a grid decides which grid lines <i>exist</i>, and dimensions anchor to them — so it goes through a reviewed model update. Ask your terminal AI to add a grid, and you can move and relabel it here.</div>':''}
|
|
3811
3997
|
<div class=gbtns><button id=gridLineB${roTopo} class="${gridLinePick?'on':''}" data-tip="Add an individual grid line at any angle with two clicks. Undoable.">Add single line</button><button id=gridReadB${roTopo} ${hasEls?'':'disabled'} data-tip="${hasEls?'Detect the printed grid lines and bubbles in this sheet’s linework. Undoable.':'Needs this sheet’s filter linework — re-read the drawing with the steel filter step to capture it.'}">From drawing</button><button id=gridAutoB${roTopo} ${nCols<2?'disabled':''} data-tip="${nCols<2?'Needs at least two columns in the model to infer spacing.':'Infer spacings and origin from the column layout. Undoable.'}">Auto from columns</button><button id=gridBlankB${roTopo} data-tip="Start from a 4×4 grid of 30' bays and edit the spacings. Undoable.">Start blank</button></div>
|
|
3812
3998
|
${gridLinePick?'<div class=hint style="margin-top:6px">'+(gridPickHasFirst()?'Pick the second point for the grid line':'Pick the first point for the grid line')+(view3d?' — snaps to the model and the grid.':' — snaps to linework (<b>Alt</b> off).')+' <b>Esc</b> cancels.</div>':''}
|
|
3813
3999
|
<div class=hint style="margin-top:10px">Spacing uses <b>n*d</b> to repeat (e.g. <b>3*25'</b> = three 25' bays). Tokens: <b>25'-6"</b>, <b>6"</b>, <b>7.5m</b>, bare mm.</div>`;
|
|
@@ -3823,8 +4009,8 @@ function renderGridPanel(p){
|
|
|
3823
4009
|
// control that simply vanishes reads as "this editor is broken", which is the opposite of the truth.
|
|
3824
4010
|
// aria-describedby, not data-tip alone: data-tip is hover-driven and never reaches a keyboard or
|
|
3825
4011
|
// screen-reader user (§8.5).
|
|
3826
|
-
const ro=MODEL_RO;
|
|
3827
|
-
const roTopo=
|
|
4012
|
+
const ro=MODEL_RO,topologyLocked=MODEL_V2||ro;
|
|
4013
|
+
const roTopo=topologyLocked?' disabled aria-describedby=gridRoWhy':'', roNo2d=ro?' disabled aria-describedby=gridNo2dWhy':'';
|
|
3828
4014
|
const og=(Array.isArray(g.origin)&&g.origin.length>=2&&isFinite(g.origin[0])&&isFinite(g.origin[1]))?g.origin:[0,0];
|
|
3829
4015
|
const normSp=v=>{const r=gc.parseSpacings(v);return r.err?String(v||''):gc.formatSpacings(r.offsets);};
|
|
3830
4016
|
const zParsed=gc.parseLevels(g.z,g.labels_z),normZ=zParsed.err?String(g.z||''):gc.formatLevels(zParsed.levels.map(l=>l.mm));
|
|
@@ -3835,7 +4021,7 @@ function renderGridPanel(p){
|
|
|
3835
4021
|
const zLabelRows=zParsed.err?'':zParsed.levels.map((lv,i)=>{const elevation=gc.fmtLen(lv.mm),label=zLabels[lv.sourceIndex]||'',visible=!hiddenZKeys.has(gc.gridLevelKey(lv.mm)),name=label||elevation;return `<div class=vgfield style="display:grid;grid-template-columns:minmax(96px,auto) minmax(0,1fr);align-items:center;gap:7px;margin-top:6px;${visible?'':'opacity:.68'}"><label class=gck data-tip="Show / hide this 3D level grid and tag"><input type=checkbox data-zvisible="${i}" aria-label="Show ${esc(name)} at ${esc(elevation)} in 3D" ${visible?'checked':''}><span>${esc(elevation)}</span></label><input class=gin data-zlabel="${i}" value="${esc(label)}" placeholder="${esc(elevation)}" autocomplete=off spellcheck=false></div>`;}).join('');
|
|
3836
4022
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
3837
4023
|
<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>
|
|
3838
|
-
${
|
|
4024
|
+
${topologyLocked?'<div class=hint id=gridRoWhy style="margin-top:8px">Spacings and levels decide which grid lines <i>exist</i>, and dimensions are anchored to them — so changing those goes through a reviewed model update. Ask your terminal AI. Labels, which levels show, the extension and the origin are editable right here.</div>':''}
|
|
3839
4025
|
<label class=gck style="margin-top:10px"><input type=checkbox id=gShow ${gridOn()?'checked':''}><span>Show grid lines</span></label>
|
|
3840
4026
|
<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>
|
|
3841
4027
|
<input id=gX class=gin${roTopo} value="${esc(normSp(g.x))}" placeholder="e.g. 0'-0", 3*25'-0", 20'-6 1/2"" autocomplete=off spellcheck=false>
|
|
@@ -3951,10 +4137,16 @@ function snapEndMulti(ms,tA,tB){const pv=snapshot();let n=0,skipped=0;
|
|
|
3951
4137
|
for(const m of ms){
|
|
3952
4138
|
if(isBrace(m)){skipped++;continue;} // extend/trim never moves a brace work point (it must stay on the column ℄) — matches doSplit
|
|
3953
4139
|
const I=lineX(m.wp[0],m.wp[1],tA,tB);if(!I)continue;
|
|
3954
|
-
const h=len(m.wp[0],I)<=len(m.wp[1],I)?0:1;mc.setEndpoint(m,h,I);m
|
|
4140
|
+
const h=len(m.wp[0],I)<=len(m.wp[1],I)?0:1;mc.setEndpoint(m,h,I);ModelCmd.patchMember(m,{rfi:_wt(m.profile)==null});n++;} // h is DATA — the end nearer the intersection
|
|
3955
4141
|
if(skipped)toast(n?(skipped+' brace'+(skipped>1?'s':'')+' skipped — braces can’t be extended/trimmed'):'Braces can’t be extended/trimmed — edit them from the inspector');
|
|
3956
4142
|
if(n){pushUndo(pv);render();sync3D();}return n;}
|
|
3957
4143
|
function doSplit(m,pt){if(isBrace(m)){toast('Braces can’t be split — edit them from the inspector');return;} // split/extend/trim disabled on braces (offset would create off-℄ WPs · Codex round-2)
|
|
4144
|
+
if(MODEL_V2){
|
|
4145
|
+
const link=V2Projection.projectionLink(m);let made=[];
|
|
4146
|
+
const ok=edit(()=>{made=V2_SESSION.splitMember(link.sheet,link.memberId,pt).value;selIds=new Set(made);selDimIds.clear();});
|
|
4147
|
+
if(ok!==false){geoMode=null;setGeo();}
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
3958
4150
|
const pv=snapshot();ensureMeta(m);const base=JSON.parse(JSON.stringify(m));
|
|
3959
4151
|
// F9: split keeps m.id for the first half with CHANGED endpoints (the clone gets a fresh id), so a dim ref to m
|
|
3960
4152
|
// would silently jump — detach every ref to m in its plan before geometry moves (safe-freeze; pv above still has
|
|
@@ -4024,7 +4216,7 @@ function isReversed(m){if(!m||!m.wp||m.wp.length<2)return false;
|
|
|
4024
4216
|
function reversedBeams(){return P.members.filter(m=>m.role!=='column'&&!isBrace(m)&&isReversed(m)).map(m=>m.id);} // braces excluded — their reverse is the inspector's swap lower/higher (Codex round-1)
|
|
4025
4217
|
function mergeCollinearJS(members){
|
|
4026
4218
|
const idx=members.map((_,i)=>i).filter(i=>_mElig(members[i]));
|
|
4027
|
-
const adj=new Map();for(const i of idx)adj.set(i,[]);
|
|
4219
|
+
const adj=new Map(),merges=[];for(const i of idx)adj.set(i,[]);
|
|
4028
4220
|
for(let p=0;p<idx.length;p++)for(let q=p+1;q<idx.length;q++){const i=idx[p],j=idx[q];const s=_mAble(members[i],members[j]);
|
|
4029
4221
|
if(s){adj.get(i).push({j,s});adj.get(j).push({j:i,s:{aEnd:s.bEnd,bEnd:s.aEnd}});}}
|
|
4030
4222
|
const seen=new Set(),runByAnchor=new Map(),merged=new Set();let mergedAway=0;
|
|
@@ -4040,11 +4232,11 @@ function mergeCollinearJS(members){
|
|
|
4040
4232
|
m.wp=[[a[0],a[1]],[b[0],b[1]]];
|
|
4041
4233
|
if(Array.isArray(members[first].ends)&&Array.isArray(members[last].ends))m.ends=[JSON.parse(JSON.stringify(members[first].ends[fo])),JSON.parse(JSON.stringify(members[last].ends[lo]))];
|
|
4042
4234
|
m.angle=_mAngle(m.wp);m.mf=ordered.some(n=>members[n].mf===true);m.verified=ordered.every(n=>members[n].verified===true);
|
|
4043
|
-
runByAnchor.set(Math.min(...ordered),m);mergedAway+=ordered.length-1;for(const n of ordered)merged.add(n);}
|
|
4044
|
-
if(mergedAway===0)return{members,mergedAway:0,runs:0,affectedIds:[]};
|
|
4235
|
+
runByAnchor.set(Math.min(...ordered),m);merges.push({memberIds:ordered.map(n=>members[n].id),wp:m.wp.map(pt=>pt.slice())});mergedAway+=ordered.length-1;for(const n of ordered)merged.add(n);}
|
|
4236
|
+
if(mergedAway===0)return{members,mergedAway:0,runs:0,affectedIds:[],merges:[]};
|
|
4045
4237
|
const out=[];for(let i=0;i<members.length;i++){if(runByAnchor.has(i))out.push(runByAnchor.get(i));else if(!merged.has(i))out.push(members[i]);}
|
|
4046
4238
|
const affectedIds=[...merged].map(i=>members[i]&&members[i].id).filter(Boolean); // F9: every id in a merged run (survivor keeps members[first].id with changed endpoints + the consumed ids) — the caller detaches dim refs to this set (Codex R3 #3)
|
|
4047
|
-
return{members:out,mergedAway,runs:runByAnchor.size,affectedIds};}
|
|
4239
|
+
return{members:out,mergedAway,runs:runByAnchor.size,affectedIds,merges};}
|
|
4048
4240
|
const svg=document.getElementById('svg');
|
|
4049
4241
|
function toSvg(e){const p=svg.createSVGPoint();p.x=e.clientX;p.y=e.clientY;return p.matrixTransform(svg.getScreenCTM().inverse());}
|
|
4050
4242
|
// --- zoom + pan ---
|
|
@@ -4318,11 +4510,45 @@ function renderPanelV2(p){
|
|
|
4318
4510
|
// draft of this copy predated.
|
|
4319
4511
|
p.innerHTML='<span class=badge>Read-only</span>'+
|
|
4320
4512
|
'<div class=hint style="margin-top:8px">This model is saved in FloLess’s canonical format. You can look around it in 3D, edit its <b>grid</b>, and export it — editing members, connections and dimensions here is still catching up.</div>'+
|
|
4321
|
-
|
|
4513
|
+
'<div class=hint style="margin-top:10px">Nothing is wrong with the model. Ask your terminal AI to change it, and it will show up here.</div>';}
|
|
4514
|
+
function syncV2SelectionNotice(p){
|
|
4515
|
+
if(!MODEL_V2||!p||!selIds.size)return;
|
|
4516
|
+
p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning').forEach(el=>el.remove());
|
|
4517
|
+
const ids=[...selIds].filter(id=>!!(C.members||[]).find(m=>m&&m.id===id));
|
|
4518
|
+
if(!ids.length)return;
|
|
4519
|
+
const other=[];
|
|
4520
|
+
for(const plan of C.plans||[]){
|
|
4521
|
+
if(plan.sheet===P.sheet)continue;
|
|
4522
|
+
if(ids.some(id=>V2Projection.memberSheets(C,id).includes(plan.sheet)))other.push(plan.sheet);
|
|
4523
|
+
}
|
|
4524
|
+
const anchor=p.querySelector(':scope > h3,:scope > .badge');
|
|
4525
|
+
let after=anchor;
|
|
4526
|
+
if(other.length){
|
|
4527
|
+
const n=document.createElement('div');n.className='hint v2-selection-notice';n.setAttribute('role','status');n.setAttribute('aria-live','polite');n.style.marginTop='8px';
|
|
4528
|
+
n.textContent=(ids.length===1?'Also on ':'Selected members also appear on ')+[...new Set(other)].join(', ')+'.';
|
|
4529
|
+
if(after)after.after(n);else p.prepend(n);after=n;
|
|
4530
|
+
}
|
|
4531
|
+
const selected=(C.members||[]).filter(m=>ids.includes(m.id));
|
|
4532
|
+
const unknown=selected.reduce((n,m)=>n+(!Number.isFinite(m?.from?.z?.known)?1:0)+(!Number.isFinite(m?.to?.z?.known)?1:0),0);
|
|
4533
|
+
if(unknown){
|
|
4534
|
+
const row=document.createElement('div');row.className='drow v2-elevation-warning';row.setAttribute('role','status');row.setAttribute('aria-live','polite');row.style.marginTop='8px';
|
|
4535
|
+
const msg=document.createElement('div');msg.className='dmsg warn';msg.textContent=`${unknown} selected endpoint${unknown===1?' has':'s have'} unknown elevation. Enter TOS or BOS before using an elevation-dependent command.`;
|
|
4536
|
+
row.appendChild(msg);if(after)after.after(row);else p.prepend(row);
|
|
4537
|
+
}
|
|
4538
|
+
const projected=selArr();
|
|
4539
|
+
const mark=(id,on)=>{const input=document.getElementById(id);if(!input||!on)return;input.value='';input.placeholder='Unknown';input.setAttribute('aria-label',(input.getAttribute('aria-label')||id)+' — unknown elevation');};
|
|
4540
|
+
if(projected.length===1){
|
|
4541
|
+
const m=projected[0],canonical=selected[0];
|
|
4542
|
+
if(m&&canonical&&m.role==='column'){mark('bos',!Number.isFinite(canonical.from?.z?.known));mark('tosC',!Number.isFinite(canonical.to?.z?.known));}
|
|
4543
|
+
else if(m&&canonical){mark('tosA',!Number.isFinite(canonical.from?.z?.known));mark('tosB',!Number.isFinite(canonical.to?.z?.known));}
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4322
4546
|
function panel(){
|
|
4323
4547
|
const p=document.getElementById('panel');
|
|
4548
|
+
if(MODEL_V2)queueMicrotask(()=>syncV2SelectionNotice(p));
|
|
4324
4549
|
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
|
|
4325
4550
|
if(gridMode){renderGridPanel(p);return;}
|
|
4551
|
+
if(NO_PLAN_VIEW){p.innerHTML='<span class=badge>No editable plan view</span><div class=hint style="margin-top:8px">This model has no registered plan view to map into the 2D canvas. Elevation, section, detail, and unknown views stay available in 3D, but they are not edited as plans.</div>';return;}
|
|
4326
4552
|
if(MODEL_RO){renderPanelV2(p);return;} // …after the grid panel, which is the one panel a v2 document does reach
|
|
4327
4553
|
if(dimStyleMode&&(selIds.size||selDimIds.size))dimStyleMode=false; // anything that selects (Ctrl+A, Duplicates, Reversed beams, a legend/RFI locate…) takes the panel back from the style pane — one guard instead of a disarm call at every such command
|
|
4328
4554
|
if(dimStyleMode){renderDimStylePanel(p);return;}
|
|
@@ -4374,6 +4600,18 @@ function panel(){
|
|
|
4374
4600
|
const nOver=dsel.filter(dimHasOverride).length; // >0 ⇒ offer the way back to the model-global default
|
|
4375
4601
|
const linked=dsel.filter(d=>d.aRef||d.bRef); // F9: dims carrying a magnetic link (dormant or live)
|
|
4376
4602
|
const pinV=linked.length?agg(linked,d=>d.pin!==false):null; // true | false | VARIES across the linked ones
|
|
4603
|
+
if(MODEL_V2){
|
|
4604
|
+
p.innerHTML=`<span class=badge>Dimension${selDimIds.size>1?'s · '+selDimIds.size:''}</span>
|
|
4605
|
+
${one?`<div class=hint style="margin-top:8px">Length <b>${esc(dimValueText(dimGeo(one.a,one.b,one.axis,one.off,one.rot).px))}</b> · ${({free:'Free (aligned)',x:'X (horizontal)',y:'Y (vertical)'})[one.axis]}</div>`:''}
|
|
4606
|
+
${linked.length?`<button id=dimPinT class="pintog${pinV===true?' on':''}" role=switch aria-checked="${pinV===true?'true':'false'}" style="margin-top:8px" data-tip="Magnetic link: pinned, the dimension follows its member(s). Unpinned, the link stays dormant until re-pinned."><span class=mck aria-hidden=true></span>${DIMEDIT_GLY.pin}Pinned${dsel.length>1?` · ${linked.length} linked`:''}${pinV===VARIES?' · mixed':''}</button>`:''}
|
|
4607
|
+
<div class=hint style="margin-top:10px">This model keeps dimension styling in the shared Dimension style defaults.</div>
|
|
4608
|
+
<div class=sect style="margin-top:12px">Edit</div>
|
|
4609
|
+
<div class=seg2><button id=dimSplitB class="${dimSplitMode?'on':''}" data-tip="Split / Extend (S) — click between the dimension's ends to split it, or beyond an end to continue it. Esc ends.">Split / Extend</button></div>
|
|
4610
|
+
<div class=hint style="margin-top:8px">${dimSplitMode?'Click <b>between</b> the ends to split, <b>beyond</b> an end to extend. <b>Alt</b> = no snap · <b>Esc</b> ends.':'Drag an end handle to re-measure · <b>Del</b> removes · <b>Esc</b> deselects.'}</div>`;
|
|
4611
|
+
{const pk=document.getElementById('dimPinT');if(pk)pk.onclick=()=>{const turnOn=pinV!==true;
|
|
4612
|
+
edit(()=>{updatePlanDims(dims=>{for(const d of dims)if(selDimIds.has(d.id)&&(d.aRef||d.bRef)){if(turnOn)delete d.pin;else d.pin=false;}});});};}
|
|
4613
|
+
document.getElementById('dimSplitB').onclick=()=>toggleDimSplit();
|
|
4614
|
+
return;}
|
|
4377
4615
|
p.innerHTML=`<span class=badge>Dimension${selDimIds.size>1?'s · '+selDimIds.size:''}</span>
|
|
4378
4616
|
${one?`<div class=hint style="margin-top:8px">Length <b>${esc(dimValueText(dimGeo(one.a,one.b,one.axis,one.off,one.rot).px))}</b> · ${({free:'Free (aligned)',x:'X (horizontal)',y:'Y (vertical)'})[one.axis]}</div>`:''}
|
|
4379
4617
|
${linked.length?`<button id=dimPinT class="pintog${pinV===true?' on':''}" role=switch aria-checked="${pinV===true?'true':'false'}" style="margin-top:8px" data-tip="Magnetic link: pinned, the dimension follows its member(s) and editing its value moves them. Unpinned, the link stays but goes dormant — the dimension holds still until re-pinned."><span class=mck aria-hidden=true></span>${DIMEDIT_GLY.pin}Pinned to member${dsel.length>1?` · ${linked.length} linked`:''}${pinV===VARIES?' · mixed':''}</button>`:''}
|
|
@@ -4388,7 +4626,7 @@ function panel(){
|
|
|
4388
4626
|
<div class=sect style="margin-top:12px">Edit</div>
|
|
4389
4627
|
<div class=seg2><button id=dimSplitB class="${dimSplitMode?'on':''}" data-tip="Split / Extend (S) — click between the dimension's ends to split it, or beyond an end to add a new segment that continues it. Esc ends.">Split / Extend</button></div>
|
|
4390
4628
|
<div class=hint style="margin-top:8px">${dimSplitMode?'Click <b>between</b> the ends to split, <b>beyond</b> an end to extend — keep clicking to chain more. <b>Alt</b> = no snap · <b>Esc</b> ends.':'Drag an end handle to re-measure · <b>Del</b> removes · <b>Esc</b> deselects.'}</div>`;
|
|
4391
|
-
const setAll=fn=>edit(()=>{for(const d of
|
|
4629
|
+
const setAll=fn=>edit(()=>{updatePlanDims(dims=>{for(const d of dims)if(selDimIds.has(d.id))fn(d);});}); // a style edit applies to every selected dim, and rides edit() → undoable
|
|
4392
4630
|
p.querySelectorAll('button[data-dend]').forEach(b=>b.onclick=()=>setAll(d=>{d.end=b.dataset.dend;}));
|
|
4393
4631
|
p.querySelectorAll('button[data-dplace]').forEach(b=>b.onclick=()=>setAll(d=>{d.place=b.dataset.dplace;}));
|
|
4394
4632
|
const cb=document.getElementById('dimBg');cb.indeterminate=(bgV===null);cb.onchange=e=>setAll(d=>{d.bg=e.target.checked;});
|
|
@@ -4654,9 +4892,9 @@ function panel(){
|
|
|
4654
4892
|
<div class="row f"><button class=danger id=del>Delete selected (${arr.length})</button></div>`;
|
|
4655
4893
|
wireTypeFilter(p);
|
|
4656
4894
|
// wiring — every commit applies to the whole selection; a blank field is a no-op (leaves each member's own value).
|
|
4657
|
-
document.getElementById('pf').onchange=e=>{const v=e.target.value.toUpperCase().replace(/ /g,'');if(!v)return;edit(()=>{for(const m of selArr()){
|
|
4895
|
+
document.getElementById('pf').onchange=e=>{const v=e.target.value.toUpperCase().replace(/ /g,'');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();}});};
|
|
4658
4896
|
document.getElementById('mTypeM').onchange=e=>{const v=e.target.value;if(!normMemberTypeKey(v)){e.target.value=memberTypeValueFor(selArr());return;}edit(()=>{const k=memberTypeFromInput(v);if(!k)return;applyMemberType(selArr(),k);});}; // type owns Column-vs-beam-style role and legend category
|
|
4659
|
-
document.getElementById('verifyBtn').onclick=()=>edit(()=>{const v=!allVerified;for(const m of selArr())m
|
|
4897
|
+
document.getElementById('verifyBtn').onclick=()=>edit(()=>{const v=!allVerified;for(const m of selArr())ModelCmd.patchMember(m,{verified:v});});
|
|
4660
4898
|
{const _gel=document.getElementById('geoEL');if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};}
|
|
4661
4899
|
{const _sw=document.getElementById('swapEnds');if(_sw)_sw.onclick=()=>swapSelectionEnds();} // reverse start↔end for the whole selection (2D + 3D via render+sync3D); braces excluded, and it owns its edit()/toast
|
|
4662
4900
|
{const setQd=k=>{qdAnchorPt=k;try{localStorage.setItem('steel:qdAnchor:v1',k);}catch(_){}for(const [id,kk] of [['qdPtA','a'],['qdPtMid','mid'],['qdPtB','b']]){const b=document.getElementById(id);if(b)b.classList.toggle('on',qdAnchorPt===kk);}}; // F7 anchor-point toggle (persisted)
|
|
@@ -4664,12 +4902,14 @@ function panel(){
|
|
|
4664
4902
|
const _qm=document.getElementById('qdPtMid');if(_qm)_qm.onclick=()=>setQd('mid');
|
|
4665
4903
|
const _qb=document.getElementById('qdPtB');if(_qb)_qb.onclick=()=>setQd('b');
|
|
4666
4904
|
const _qp=document.getElementById('qdPlace');if(_qp)_qp.onclick=()=>quickDimSpacing(qdAnchorPt);}
|
|
4667
|
-
document.getElementById('del').onclick=()=>edit(()=>{
|
|
4668
|
-
|
|
4905
|
+
document.getElementById('del').onclick=()=>edit(()=>{if(MODEL_V2)deleteV2Selection({memberIds:selIds,dimIds:selDimIds});
|
|
4906
|
+
else for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));
|
|
4907
|
+
selIds.clear();if(selDimIds.size&&!MODEL_V2)ModelCmd.setPlanDims(P,P.dims.filter(d=>!selDimIds.has(d.id)));selDimIds.clear();}); // selection spans sheets → remove from every plane; a mixed marquee also holds dims (active sheet) — remove them too (matches keyboard Delete)
|
|
4908
|
+
{const sp=v=>edit(()=>{for(const m of selArr())if(m.role!=='column')ModelCmd.patchMember(m,{position:v});});
|
|
4669
4909
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
4670
4910
|
if(_pt)_pt.onclick=()=>sp('top');if(_pm)_pm.onclick=()=>sp('middle');if(_pb)_pb.onclick=()=>sp('bottom');}
|
|
4671
4911
|
// Rotation — apply one angle to every selected member's section (blank input = no-op). Normalised (-360,360).
|
|
4672
|
-
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{for(const m of selArr())m
|
|
4912
|
+
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{for(const m of selArr())ModelCmd.patchMember(m,{rot:r});});};
|
|
4673
4913
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>{if(e.target.value.trim()==='')return;setRot(e.target.value);};
|
|
4674
4914
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
4675
4915
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
@@ -4679,10 +4919,10 @@ function panel(){
|
|
|
4679
4919
|
const wMText=(id,os,set)=>{const i=document.getElementById(id);if(i)i.onchange=e=>{const t=e.target.value.trim();if(!t)return;edit(()=>{for(const o of os)set(o,t);});};};
|
|
4680
4920
|
if(allCol){const cs=cols.map(m=>m.col);
|
|
4681
4921
|
{const i=document.getElementById('bos');if(i)i.onchange=e=>{const t=e.target.value.trim();if(!t)return;edit(()=>{const v=parseLen(t);for(const o of cs)ModelCmd.setBos(o,v);});}}
|
|
4682
|
-
wMTos('tosC',cs);wMText('ntC',cs,(o,v)=>o
|
|
4922
|
+
wMTos('tosC',cs);wMText('ntC',cs,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtC',cs,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));}
|
|
4683
4923
|
else if(allBeam){const s0=beams.map(m=>m.ends[0]),s1=beams.map(m=>m.ends[1]);
|
|
4684
|
-
wMTos('tosA',s0);wMText('ntA',s0,(o,v)=>o
|
|
4685
|
-
wMTos('tosB',s1);wMText('ntB',s1,(o,v)=>o
|
|
4924
|
+
wMTos('tosA',s0);wMText('ntA',s0,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtA',s0,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));
|
|
4925
|
+
wMTos('tosB',s1);wMText('ntB',s1,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtB',s1,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));
|
|
4686
4926
|
// Braces are skipped: copying end0's TOS onto end1 would FLATTEN a brace's slope (and re-derive its
|
|
4687
4927
|
// lower/higher arrowheads to the tie default) — silently, from a mixed box-select. (code review)
|
|
4688
4928
|
// edit() pushes undo unconditionally, so an all-brace selection must not enter it (Codex round-4).
|
|
@@ -4895,14 +5135,14 @@ function panel(){
|
|
|
4895
5135
|
<div class=row><button class=ghostw id=swapEnds data-tip="Reverse the member: swap the start (${col?'bottom':'yellow'}) and end (${col?'top':'magenta'}) handles · Shortcut: P">⇄ Swap start ↔ end <span style="opacity:.55">(P)</span></button></div>`}
|
|
4896
5136
|
<div class="row f"><button class=danger id=del>Delete member</button></div>`;
|
|
4897
5137
|
wireTypeFilter(p);
|
|
4898
|
-
document.getElementById('pf').onchange=e=>edit(()=>{const v=e.target.value.toUpperCase().replace(/ /g,'');m
|
|
5138
|
+
document.getElementById('pf').onchange=e=>edit(()=>{const v=e.target.value.toUpperCase().replace(/ /g,'');ModelCmd.patchMember(m,{profile:v,rfi:_wt(v)==null});if(v&&!profs.includes(v)){profs.push(v);profs.sort();}});
|
|
4899
5139
|
{const rp=document.getElementById('rfiPill');if(rp){const go=()=>openRFI(m.id);rp.onclick=go;rp.onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();e.stopPropagation();go();}};}} // F12: the RFI pill opens the list focused on THIS member (role=button span → keydown for Enter/Space). stopPropagation so idle Space/Enter doesn't ALSO hit the global repeat-last handler (:3804) — matches the editor's local-keydown convention (:1738,:4212)
|
|
4900
5140
|
document.getElementById('pickProf').onclick=()=>{if(picking&&pickKind==='profile'){picking=false;}else{picking=true;pickKind='profile';pickEnd=null;}render();};
|
|
4901
5141
|
document.getElementById('mTypeS').onchange=e=>{const v=e.target.value;if(!normMemberTypeKey(v)){e.target.value=memberTypeLabel(memberTypeOf(m));return;}edit(()=>{const k=memberTypeFromInput(v);if(k&&memberTypeOf(m)!==k)applyMemberType([m],k);});}; // retype → role + legend recategorize (edit() → sync3D → build3DLegend); undoable
|
|
4902
5142
|
{const _cc=document.getElementById('msColor');if(_cc)_cc.onchange=e=>{C.profile_colors[m.profile]=e.target.value;scheduleSave();render();sync3D();};} // F1: recolour this member's profile (same write as the legend swatch) — sync3D() repaints a live 3D scene (no-op in 2D) so colour is truly 2D+3D
|
|
4903
5143
|
document.querySelectorAll('.msW').forEach(b=>b.onclick=()=>setMemberLineStyle(memberTypeOf(m),'weight',b.dataset.w)); // F5: per member-type line weight
|
|
4904
5144
|
document.querySelectorAll('.msD').forEach(b=>b.onclick=()=>setMemberLineStyle(memberTypeOf(m),'dash',b.dataset.d)); // F5: per member-type line dash
|
|
4905
|
-
document.querySelectorAll('.mfsug').forEach(b=>b.onclick=()=>edit(()=>{
|
|
5145
|
+
document.querySelectorAll('.mfsug').forEach(b=>b.onclick=()=>edit(()=>{const profile=b.dataset.s;ModelCmd.patchMember(m,{profile,mf:true,rfi:_wt(profile)==null});if(!profs.includes(profile)){profs.push(profile);profs.sort();}})); // record the moment-frame provenance (drives the confidence "schedule-resolved" factor)
|
|
4906
5146
|
const _gel=document.getElementById('geoEL'),_gsp=document.getElementById('geoSplit');
|
|
4907
5147
|
if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};
|
|
4908
5148
|
if(_gsp)_gsp.onclick=()=>{geoMode=(geoMode==='split'?null:'split');setGeo();render();};
|
|
@@ -4915,19 +5155,19 @@ function panel(){
|
|
|
4915
5155
|
const _bb=document.getElementById('brBelow');if(_bb)_bb.onclick=()=>setBr(b=>b.floor='below');
|
|
4916
5156
|
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);};
|
|
4917
5157
|
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)
|
|
4918
|
-
const _bsw=document.getElementById('brSwap');if(_bsw)_bsw.onclick=()=>edit(()=>{normBrace(m);m
|
|
4919
|
-
{const setPos=v=>edit(()=>{m
|
|
5158
|
+
const _bsw=document.getElementById('brSwap');if(_bsw)_bsw.onclick=()=>edit(()=>{normBrace(m);ModelCmd.patchMemberBrace(m,{lowerEnd:1-braceLowerEnd(m)});});}
|
|
5159
|
+
{const setPos=v=>edit(()=>{ModelCmd.patchMember(m,{position:v});}); // profile placement on the reference line; persists + re-extrudes the 3D
|
|
4920
5160
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
4921
5161
|
if(_pt)_pt.onclick=()=>setPos('top');if(_pm)_pm.onclick=()=>setPos('middle');if(_pb)_pb.onclick=()=>setPos('bottom');}
|
|
4922
5162
|
// Rotation — spin the section about the reference line. Normalised to (-360,360); 0 = as drawn.
|
|
4923
5163
|
// edit() re-renders 2D (columnSectionPoly reads m.rot) AND re-extrudes 3D (steel-3d-view el.rot).
|
|
4924
|
-
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{m
|
|
5164
|
+
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{ModelCmd.patchMember(m,{rot:r});});};
|
|
4925
5165
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>setRot(e.target.value);
|
|
4926
5166
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
4927
5167
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
4928
5168
|
const wireTos=(id,o)=>{const ck=document.getElementById(id+'_ck');if(ck)ck.onchange=e=>edit(()=>{ModelCmd.setTosDefault(o,e.target.checked,defaultTOS);});
|
|
4929
5169
|
const inp=document.getElementById(id);if(inp)inp.onchange=e=>edit(()=>{ModelCmd.setTosValue(o,parseLen(e.target.value));});};
|
|
4930
|
-
const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{o
|
|
5170
|
+
const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{ModelCmd.patchEnd(o,{detail:e.target.value.trim()});});
|
|
4931
5171
|
const pk=document.getElementById(id+'_pk');if(pk)pk.onclick=()=>{if(picking&&pickKind==='detail'&&pickEnd===o){picking=false;pickEnd=null;}else{picking=true;pickKind='detail';pickEnd=o;}render();};
|
|
4932
5172
|
const op=document.getElementById(id+'_open');if(op)op.onclick=()=>openPreview(o.detail);};
|
|
4933
5173
|
// The detail→connection actions under the field. `which` identifies the end so the resolver can reach
|
|
@@ -4954,7 +5194,7 @@ function panel(){
|
|
|
4954
5194
|
const retry=document.getElementById(id+'_retry');
|
|
4955
5195
|
if(retry)retry.onclick=()=>{invalidateConnectionDiagnostics(true);panel();};
|
|
4956
5196
|
};
|
|
4957
|
-
const wireConn=(id,o)=>{const i=document.getElementById(id);if(!i)return;i.onchange=e=>edit(()=>{const v=(e.target.value||'').trim();o
|
|
5197
|
+
const wireConn=(id,o)=>{const i=document.getElementById(id);if(!i)return;i.onchange=e=>edit(()=>{const v=(e.target.value||'').trim();ModelCmd.patchEnd(o,{conn:(!v||v==='— none —')?'':v.split(' · ')[0]});});};
|
|
4958
5198
|
if(col){
|
|
4959
5199
|
document.getElementById('bos').onchange=e=>edit(()=>{ModelCmd.setBos(m.col,parseLen(e.target.value));});
|
|
4960
5200
|
wireTos('tosC',m.col);
|
|
@@ -5021,8 +5261,8 @@ function panel(){
|
|
|
5021
5261
|
if(Pt)_dpCommit(i,Pt);};};
|
|
5022
5262
|
const wireEnd=i=>_dpAxes.forEach((ax,a)=>{dpWire('dpG_'+i+'_'+a,i,a,false);if(_dpLocal)dpWire('dpL_'+i+'_'+a,i,a,true);});
|
|
5023
5263
|
wireEnd(0);wireEnd(1);} // both points (beam Start/End, column Bottom/Top)
|
|
5024
|
-
document.getElementById('del').onclick=()=>edit(()=>{P.members=P.members.filter(x=>x.id!==m.id);selIds.clear();if(selDimIds.size)
|
|
5025
|
-
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{m
|
|
5264
|
+
document.getElementById('del').onclick=()=>edit(()=>{if(MODEL_V2)deleteV2Selection({memberIds:[m.id],dimIds:selDimIds});else P.members=P.members.filter(x=>x.id!==m.id);selIds.clear();if(selDimIds.size&&!MODEL_V2)ModelCmd.setPlanDims(P,P.dims.filter(d=>!selDimIds.has(d.id)));selDimIds.clear();}); // also drop any dims a mixed marquee selected
|
|
5265
|
+
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{ModelCmd.patchMember(m,{verified:!m.verified});});}
|
|
5026
5266
|
}
|
|
5027
5267
|
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();
|
|
5028
5268
|
const nm=ensureMeta({id,profile:prof,wp:[sg.a.slice(),sg.b.slice()],angle:sg.o,rfi:(_wt(prof)==null)});
|
|
@@ -5099,8 +5339,8 @@ function _segX(a,b,c,d){const rx=b[0]-a[0],ry=b[1]-a[1],sx=d[0]-c[0],sy=d[1]-c[1
|
|
|
5099
5339
|
let _ovSnap=null,_ovSnapEls=null;
|
|
5100
5340
|
function overlaySnapGeom(){
|
|
5101
5341
|
if(!refSheetOn){_ovSnap=null;_ovSnapEls=null;return null;} // F13: hidden reference sheet contributes no snap candidates (don't snap to invisible linework — buildSnap :3062 + snapPerpTargets :3085)
|
|
5102
|
-
const els=
|
|
5103
|
-
if(!els){_ovSnap=null;_ovSnapEls=null;return null;}
|
|
5342
|
+
const els=drawableElsForPlan(); // …and a non-drawable LAYER is invisible for the same reason, so it owes the same silence (#507). The toggle's own tooltip promises hiding stops snap points; a layer the user cannot see must not capture an endpoint, midpoint or perpendicular either.
|
|
5343
|
+
if(!els||!els.length){_ovSnap=null;_ovSnapEls=null;return null;} // scanned raster / empty / every layer hidden → nothing traced to snap to
|
|
5104
5344
|
if(els===_ovSnapEls&&_ovSnap)return _ovSnap; // same sheet's vectors → reuse the parse
|
|
5105
5345
|
const pts=[],segs=[],mids=[];
|
|
5106
5346
|
const add=(a,b)=>{if(!(isFinite(a[0])&&isFinite(a[1])&&isFinite(b[0])&&isFinite(b[1])))return;
|
|
@@ -5236,7 +5476,58 @@ function _len3dFt(m,ppf,dTos){
|
|
|
5236
5476
|
else{z0=eff(m.ends&&m.ends[0]); z1=eff(m.ends&&m.ends[1]);} // start TOS → end TOS
|
|
5237
5477
|
const dz=((z1==null?0:z1)-(z0==null?0:z0))/12; // vertical rise, feet
|
|
5238
5478
|
return Math.hypot(dx,dy,dz);}
|
|
5239
|
-
|
|
5479
|
+
/*
|
|
5480
|
+
* A member's length comes from the CANONICAL model whenever there is one, never from its plan projection.
|
|
5481
|
+
*
|
|
5482
|
+
* Two traps met here, and both produced a confidently wrong number rather than an error:
|
|
5483
|
+
*
|
|
5484
|
+
* 1. THE PREDICATE IS THE FORMAT, NOT WRITABILITY. This shipped as `MODEL_RO ? …`, which was
|
|
5485
|
+
* indistinguishable from MODEL_V2 while v2 was read-only. The moment MODEL_V2_LIVE turned on, MODEL_RO
|
|
5486
|
+
* became permanently false and every v2 length fell back to the v1 plan path.
|
|
5487
|
+
* 2. ON v2 THE CALLER HANDS US A PROJECTED MEMBER. `selArr()`/`byId()` resolve through
|
|
5488
|
+
* `v2ProjectedMember`, which returns the plan-space twin (it carries `wp`, not `from`/`to`) because the
|
|
5489
|
+
* 2D editor draws and edits in plan px. `_len3dFt` measures that `wp` against the ACTIVE plan's
|
|
5490
|
+
* pt_per_ft, so the answer is only right when a plan's pt_per_ft happens to agree with its
|
|
5491
|
+
* datum→control2 calibration. Where they disagree it silently reports the calibration span instead —
|
|
5492
|
+
* 65 ft for a 7,620 mm (25 ft) beam. Resolving back to the canonical member removes that dependence
|
|
5493
|
+
* entirely: world mm is the truth, and the projection is a drawing artifact.
|
|
5494
|
+
*
|
|
5495
|
+
* The fallback still runs for a member with no canonical twin — v1 documents, and the synthetic
|
|
5496
|
+
* `{role,wp}` objects the self-checks below measure — so neither of those changes behaviour.
|
|
5497
|
+
*/
|
|
5498
|
+
/*
|
|
5499
|
+
* id -> canonical member, memoized, because `_lenFt` is called once per member inside several
|
|
5500
|
+
* per-repaint loops (stats(), the BOM and RFI list builders, refreshSelLen3d) and a linear scan there is
|
|
5501
|
+
* O(N**2) on a real 200+ member model. Both reviewers raised it.
|
|
5502
|
+
*
|
|
5503
|
+
* WHAT ACTUALLY INVALIDATES IT is array identity, and that is sufficient today for a reason worth
|
|
5504
|
+
* writing down: every v2 mutation goes through `V2Commands.transact`, which does `clone(model)` -> mutate
|
|
5505
|
+
* the DRAFT -> `replaceRoot(model, draft)`. So although the individual mutators call
|
|
5506
|
+
* `doc.members.push(...)`, the model's `members` is a FRESH array after every commit — the in-place push
|
|
5507
|
+
* happens on a draft that is then swapped in wholesale, and an identity check cannot miss it.
|
|
5508
|
+
*
|
|
5509
|
+
* The other two guards are defence-in-depth for a future writer that does NOT go through transact, and
|
|
5510
|
+
* are honestly unkillable by any test today (MEASURED: removing both leaves the suite green, because no
|
|
5511
|
+
* reachable path mutates `members` in place on the live model). They are kept because a stale entry does
|
|
5512
|
+
* not read as slow — it reads as a MISS, which sends `_lenFt` down the v1 plan fallback and produces a
|
|
5513
|
+
* confidently wrong length, silently recreating the exact defect this memo sits inside:
|
|
5514
|
+
* 1. `v2InvalidateMemberIndex()` from the command session's afterCommit.
|
|
5515
|
+
* 2. The array length, checked alongside identity on every lookup.
|
|
5516
|
+
*/
|
|
5517
|
+
let _v2MemberIndex=null,_v2MemberIndexFor=null,_v2MemberIndexLen=-1;
|
|
5518
|
+
function v2InvalidateMemberIndex(){_v2MemberIndex=null;_v2MemberIndexFor=null;_v2MemberIndexLen=-1;}
|
|
5519
|
+
function v2CanonicalMember(id){
|
|
5520
|
+
if(id==null)return undefined;
|
|
5521
|
+
const members=modelMembersV2();
|
|
5522
|
+
if(_v2MemberIndex===null||_v2MemberIndexFor!==members||_v2MemberIndexLen!==members.length){
|
|
5523
|
+
_v2MemberIndex=new Map();
|
|
5524
|
+
for(const m of members)if(m&&m.id!=null)_v2MemberIndex.set(m.id,m);
|
|
5525
|
+
_v2MemberIndexFor=members;_v2MemberIndexLen=members.length;
|
|
5526
|
+
}
|
|
5527
|
+
return _v2MemberIndex.get(id);}
|
|
5528
|
+
function _lenFt(m){
|
|
5529
|
+
if(MODEL_V2&&m){const canon=v2CanonicalMember(m.id);if(canon)return modelReadsV2().lengthFt(canon);}
|
|
5530
|
+
return _len3dFt(m,FT,defaultTOS);}
|
|
5240
5531
|
const PROP_DEFS=[
|
|
5241
5532
|
{key:'id', label:'Mark', get:m=>m.id, fmt:v=>v==null?'':String(v)},
|
|
5242
5533
|
{key:'profile', label:'Profile', get:m=>m.profile, fmt:v=>v==null?'':String(v)},
|
|
@@ -5268,7 +5559,7 @@ function sanitizePropLabels(x){const o=(x&&typeof x==='object'&&!Array.isArray(x
|
|
|
5268
5559
|
// …all three skipped for v2 — see the repair-pass note at the top of main(). These two are the pair the
|
|
5269
5560
|
// schema check caught: prop_labels gains vis2d/vis3d, and views gains `projection` while LOSING each
|
|
5270
5561
|
// generated view's `axisId`.
|
|
5271
|
-
if(
|
|
5562
|
+
if(!MODEL_V2){
|
|
5272
5563
|
C.prop_labels=sanitizePropLabels(C.prop_labels); // normalise the contract's incoming value now (PROP_KEYS is initialised above; runs before main's bootstrap render + restoreSaved override)
|
|
5273
5564
|
C.views=sanitizeViews(C.views); // normalise the incoming saved views now — inside main() where sanitizeViews is in scope (boot() only guaranteed an array); runs before the bootstrap render + restoreSaved override, same pattern as prop_labels above
|
|
5274
5565
|
if(SteelCore)C.dims3d=SteelCore.sanitizeDims3d(C.dims3d); // UCS Stage 5: canonicalise each 3D dim's axisDir (drop junk / normalise non-unit) so a bad value can't wedge the schema-validated save — the SERVER contract copy; restoreSaved re-sanitises the localStorage draft below
|
|
@@ -5282,7 +5573,7 @@ function propLabelMembers(){const pl=C.prop_labels;if(!pl||!pl.props.length)retu
|
|
|
5282
5573
|
// plan-local PIXEL coordinates into the ACTIVE sheet's SVG, so an off-sheet member would be painted in
|
|
5283
5574
|
// the wrong place on any multi-sheet project. A repair briefly widened this to allMembers() to stop a
|
|
5284
5575
|
// v2 TypeError and introduced exactly that regression; the v2 half is what needed the model-wide list.
|
|
5285
|
-
let base=
|
|
5576
|
+
let base=P.members;
|
|
5286
5577
|
if(pl.selected_only){const ids=new Set(pl.ids||[]);base=base.filter(m=>ids.has(m.id));}
|
|
5287
5578
|
return base.filter(m=>propLabelLinesFor(m).length>0);}
|
|
5288
5579
|
// one popup row's aggregate across the current selection: a shared value, "Varies", or N/A (disabled)
|
|
@@ -5550,7 +5841,7 @@ function dimAnchor(){return dimChainPrev?dimChainPrev.point:(dimDraft&&!dimDraft
|
|
|
5550
5841
|
function dimClick(e){const s=dimSnapAt(e,dimAnchor());
|
|
5551
5842
|
if(dimChainPrev){const a=dimChainPrev.point,b=[s.x,s.y],axis=dimChainPrev.axis,off=dimChainPrev.off,rot=dimChainPrev.rot||0; // CHAIN: each click adds the next dim from the previous point, on the same axis + offset line + baked frame
|
|
5552
5843
|
if(dimGeo(a,b,axis,off,rot).px<1){dimPrev(e);return;} // ignore a zero / sub-pixel click (measured length in the frame) — don't commit a degenerate dim
|
|
5553
|
-
edit(()=>{
|
|
5844
|
+
edit(()=>{ModelCmd.addPlanDims(P,[{id:'d'+Date.now()+'_'+(dimSeq++),a,b,axis,off,rot}]);});
|
|
5554
5845
|
dimChainPrev={point:b,axis,off,rot};dimPrev(e);return;} // keep going from b; Esc/Enter ends the chain
|
|
5555
5846
|
if(!dimDraft){dimDraft={a:[s.x,s.y],b:null,axis:dimAxis};dimPrev(e);return;} // click 1 → first anchor
|
|
5556
5847
|
if(!dimDraft.b){dimDraft.b=[s.x,s.y];dimPrev(e);return;} // click 2 → second anchor (value locks)
|
|
@@ -5558,7 +5849,7 @@ function dimClick(e){const s=dimSnapAt(e,dimAnchor());
|
|
|
5558
5849
|
const rot=axis==='free'?0:frameRot(); // bake the active frame so a later Reset/redefine never moves this dim (free is frame-independent)
|
|
5559
5850
|
const off=dimOffFromPointer(dimDraft.a,dimDraft.b,axis,s.raw,rot); // click 3 → offset/side from raw pointer
|
|
5560
5851
|
const a=dimDraft.a,b=dimDraft.b;
|
|
5561
|
-
edit(()=>{
|
|
5852
|
+
edit(()=>{ModelCmd.addPlanDims(P,[{id:'d'+Date.now()+'_'+(dimSeq++),a,b,axis,off,rot}]);}); // undoable; render() clears the preview
|
|
5562
5853
|
if(dimChain)dimChainPrev={point:b,axis,off,rot}; // chain mode → continue from b along this same offset line + baked frame
|
|
5563
5854
|
dimDraft=null;}
|
|
5564
5855
|
function dimPrevClear(){const g=document.getElementById('dimPrevG');if(g)g.remove();snapClear();}
|
|
@@ -5637,18 +5928,18 @@ function dimSplitAt(m){
|
|
|
5637
5928
|
if(t>EPS&&t<1-EPS){ // INTERIOR → split into two (both halves keep d.off → offset line stays continuous, no kink)
|
|
5638
5929
|
const mid=d.axis==='free'?[d.a[0]+(d.b[0]-d.a[0])*t,d.a[1]+(d.b[1]-d.a[1])*t]:m.slice(); // x/y: split AT the clicked feature (like extend) — the graphic stays on the fixed offset line, so the witness points to what you clicked; free: project onto the baseline to keep the point on the measured line
|
|
5639
5930
|
const id1='d'+Date.now()+'_'+(dimSeq++),id2='d'+Date.now()+'_'+(dimSeq++);
|
|
5640
|
-
|
|
5931
|
+
ModelCmd.setPlanDims(P,P.dims.filter(x=>x.id!==d.id));
|
|
5641
5932
|
const sty=dimStyleOverrides(d); // both halves inherit the split dim's style
|
|
5642
5933
|
const cp=r=>r?(r.g?{g:r.g}:{m:r.m,pt:r.pt}):null; // F9: each half keeps its OUTER ref — member or grid — (+ a dormant pin state); the new interior end is raw (Codex R4 #3)
|
|
5643
5934
|
const pn=d.pin===false?{pin:false}:{};
|
|
5644
|
-
|
|
5935
|
+
ModelCmd.addPlanDims(P,[{id:id1,a:d.a.slice(),b:mid.slice(),axis:d.axis,off:d.off,rot:d.rot,...sty,...(d.aRef?{aRef:cp(d.aRef),...pn}:{})},{id:id2,a:mid.slice(),b:d.b.slice(),axis:d.axis,off:d.off,rot:d.rot,...sty,...(d.bRef?{bRef:cp(d.bRef),...pn}:{})}]);
|
|
5645
5936
|
selDimIds.delete(d.id);selDimIds.add(id1);selDimIds.add(id2);
|
|
5646
5937
|
}else{ // BEYOND an end → add a continuing dimension from that end to the clicked point (same axis/off/rot)
|
|
5647
5938
|
const beyondB=t>=1-EPS,nearEnd=beyondB?d.b.slice():d.a.slice(); // discriminator must match the EPS band above (else branch runs for t≤EPS OR t≥1-EPS): t≥1-EPS → past the b end, else past a — otherwise a click just inside b extended from a, making a reversed near-full-length dim
|
|
5648
5939
|
const far=d.axis==='free'?[d.a[0]+(d.b[0]-d.a[0])*t,d.a[1]+(d.b[1]-d.a[1])*t]:m.slice(); // free: project to stay collinear; x/y: measure to the actual clicked point (graphic sits on the fixed offset line)
|
|
5649
5940
|
const id='d'+Date.now()+'_'+(dimSeq++);
|
|
5650
5941
|
const nr=beyondB?d.bRef:d.aRef,ncp=nr?(nr.g?{g:nr.g}:{m:nr.m,pt:nr.pt}):null,nref=ncp?{...(beyondB?{aRef:ncp}:{bRef:ncp}),...(d.pin===false?{pin:false}:{})}:{}; // F9: the continuation's NEAR end keeps that end's ref — member or grid — (+ dormant pin state); far end raw (Codex R4 #3)
|
|
5651
|
-
|
|
5942
|
+
ModelCmd.addPlanDims(P,[{id,a:beyondB?nearEnd:far,b:beyondB?far:nearEnd,axis:d.axis,off:d.off,rot:d.rot,...dimStyleOverrides(d),...nref}]); // keep the original a→b orientation + style
|
|
5652
5943
|
selDimIds.add(id);
|
|
5653
5944
|
}
|
|
5654
5945
|
pushUndo(pv);render();sync3D();
|
|
@@ -5708,7 +5999,7 @@ function quickDimSpacing(pt,pick){
|
|
|
5708
5999
|
if(Math.abs(lx(B.p)-lx(A.p))<1)continue; // coincident projection → no spacing to show
|
|
5709
6000
|
const rf=E=>E.m?{m:E.m.id,pt:isCol(E.m)?'a':pt}:{g:E.g}; // a column stores a canonical pt 'a' (its two wp are one plan point)
|
|
5710
6001
|
const id='d'+Date.now()+'_'+(dimSeq++);made.push(id);
|
|
5711
|
-
|
|
6002
|
+
ModelCmd.addPlanDims(P,[{id,a:A.p.slice(),b:B.p.slice(),axis:'x',off,rot,aRef:rf(A),bRef:rf(B)}]);}
|
|
5712
6003
|
if(!made.length){toast('Those members share a spacing point — nothing to dimension');return;}
|
|
5713
6004
|
pushUndo(pv);selIds.clear();selGridIds.clear();selDimIds=new Set(made);dimsVisible=true;updDimToggle();render();sync3D();
|
|
5714
6005
|
toast('Placed '+made.length+' spacing dimension'+(made.length===1?'':'s')+' — they follow their members and grids');
|
|
@@ -5759,7 +6050,7 @@ function buildDimEditPop(){
|
|
|
5759
6050
|
val.onkeydown=e=>{e.stopPropagation();if(e.key==='Enter'){e.preventDefault();dimEditCommit();}else if(e.key==='Escape'){e.preventDefault();closeDimEdit();}};
|
|
5760
6051
|
val.oninput=()=>val.classList.remove('bad');
|
|
5761
6052
|
const setTog=k=>{if(k==='pin'){dimEdit.pin=!dimEdit.pin; // applies IMMEDIATELY (QA 2026-07-16: a toggle that waits for Enter reads as broken) — undoable; re-pinning reanchors live, unpinning freezes now
|
|
5762
|
-
edit(()=>{
|
|
6053
|
+
edit(()=>{updatePlanDim(dimEdit.id,dd=>{if(dd.aRef||dd.bRef){if(dimEdit.pin)delete dd.pin;else dd.pin=false;}});});}
|
|
5763
6054
|
else{const other=k==='l'?'r':'l';if(dimEdit[k]&&!dimEdit[other])return; // keep at least one end driven
|
|
5764
6055
|
dimEdit[k]=!dimEdit[k];try{localStorage.setItem('steel:dimEdit:ends:v1',JSON.stringify({l:dimEdit.l,r:dimEdit.r}));}catch(_){}}
|
|
5765
6056
|
buildDimEditPop();const v2=document.getElementById('dimEditVal');if(v2)v2.focus();};
|
|
@@ -5797,14 +6088,16 @@ function dimEditCommit(){
|
|
|
5797
6088
|
if(aRef.pt==='mid'||bRef.pt==='mid'){toast('One end is this member’s midpoint — unpin 📌 to edit the dimension only');return;}}
|
|
5798
6089
|
const mem=id=>(P.members||[]).find(x=>x&&x.id===id),addv=(p,v)=>[p[0]+v[0],p[1]+v[1]];
|
|
5799
6090
|
edit(()=>{
|
|
5800
|
-
|
|
6091
|
+
const target=MODEL_V2?JSON.parse(JSON.stringify(d)):d;
|
|
6092
|
+
if(aRef||bRef){if(dimEdit.pin)delete target.pin;else target.pin=false;} // the popup's pin state commits onto the dim. Unpinned keeps the refs DORMANT (reanchor skips d.pin===false), so the typed value sticks AND the link can be re-pinned later — supersedes the old detach-both (Codex R1 #12) now that magnetism itself is pin-gated.
|
|
5801
6093
|
const mcD=MC(); // safe to hoist because setEndpointsInPlace/setEndpoint read NOTHING from the command object's closure — only their member argument. MC() also snapshots defaultTOS BY VALUE, so anything that reads defaultTosIn (translate) must NOT be hoisted past a datum change.
|
|
5802
6094
|
const doEnd=(driven,ref,mv,rawKey)=>{if(!driven)return;
|
|
5803
6095
|
if(dimEdit.pin&&ref){const m=mem(ref.m);if(m&&Array.isArray(m.wp)&&m.wp.length>=2){
|
|
5804
6096
|
if(ref.pt==='mid'||m.role==='column'){mcD.setEndpointsInPlace(m,addv(m.wp[0],mv),addv(m.wp[1],mv));} // mid = rigid; a COLUMN always moves rigidly (one plumb plan point — both wp stay coincident). Both args evaluate before either assignment, and neither reads the other's target.
|
|
5805
6097
|
else{const k=ref.pt==='a'?0:1;mcD.setEndpoint(m,k,addv(m.wp[k],mv));}}} // same endpoint the inline pair addressed: 'a' -> wp[0], anything else -> wp[1]
|
|
5806
|
-
else{
|
|
6098
|
+
else{target[rawKey]=addv(target[rawKey],mv);}}; // pin OFF, or an unref'd end → move the dim's own coord
|
|
5807
6099
|
doEnd(effA>0,aRef,mvA,'a');doEnd(effB>0,bRef,mvB,'b');
|
|
6100
|
+
if(MODEL_V2)updatePlanDim(target.id,row=>{for(const key of Object.keys(row))delete row[key];Object.assign(row,target);});
|
|
5808
6101
|
});
|
|
5809
6102
|
if(redirected)toast('The grid-linked end stays put — the value moved the other end instead');
|
|
5810
6103
|
closeDimEdit();
|
|
@@ -6034,6 +6327,14 @@ function openLevelModal(tool){ // works from 2D and 3D — the commit is plan-
|
|
|
6034
6327
|
function toLevelCommit(tool,ti){const sel=selArr();const T=C.plans[ti];const mc=MC(); // model-wide: a cross-sheet selection all moves/copies to the target level (counts match the modal, which reads selIds)
|
|
6035
6328
|
if(!sel.length){toast('Selection is empty — nothing to '+(tool==='move'?'move':'copy'));return;}
|
|
6036
6329
|
if(!T)return;
|
|
6330
|
+
if(MODEL_V2){
|
|
6331
|
+
const entries=sel.map(m=>{const sheets=V2Projection.memberSheets(C,m.id),sourceSheet=sheets.includes(P.sheet)?P.sheet:sheets[0];return sourceSheet?{id:m.id,sourceSheet}:null;})
|
|
6332
|
+
.filter(row=>row&&row.sourceSheet!==T.sheet);
|
|
6333
|
+
if(!entries.length){toast('Selection is already on '+T.sheet);return;}
|
|
6334
|
+
let effect=null;
|
|
6335
|
+
const ok=edit(()=>{effect=V2_SESSION.moveOrCopyToSheet(T.sheet,entries,tool==='copy');if(tool==='copy')selIds=new Set(effect.value||[]);});
|
|
6336
|
+
if(ok)toast((tool==='move'?'Moved ':'Copied ')+entries.length+' member'+(entries.length===1?'':'s')+' to '+T.sheet+(tool==='move'?' — source evidence, where present, remains visible':''));
|
|
6337
|
+
return;}
|
|
6037
6338
|
if(!Array.isArray(T.members))T.members=[]; // stays BEFORE snapshot(): a non-array captured into the undo entry breaks restore code that maps over it. mc.addMembers deliberately does not do this.
|
|
6038
6339
|
const dstDef=(T.default_tos!=null?T.default_tos:198);
|
|
6039
6340
|
const pv=snapshot(); // whole-model pre-mutation → one global-stack entry undoes the source removals AND the target adds
|
|
@@ -6060,14 +6361,14 @@ function csClick(e){const p=csSnapAt(e);
|
|
|
6060
6361
|
if(L<1e-6){toast('Pick two distinct points for the X axis');return;} // degenerate → stay armed
|
|
6061
6362
|
const o=csDraft.slice(),u=[dx/L,dy/L];
|
|
6062
6363
|
csaxisMode=false;setCsMode();
|
|
6063
|
-
edit(()=>{P
|
|
6364
|
+
edit(()=>{ModelCmd.setPlanFrame(P,{o,u});}); // undoable + persisted; render() draws the glyph
|
|
6064
6365
|
toast('Local axes set ('+Math.round(Math.atan2(u[1],u[0])*180/Math.PI)+'°) — ortho & X/Y dims now follow them');}
|
|
6065
6366
|
function csPrevClear(){const g=document.getElementById('csPrevG');if(g)g.remove();snapClear();}
|
|
6066
6367
|
function csPrev(e){if(!csaxisMode){csPrevClear();return;}
|
|
6067
6368
|
const p=csSnapAt(e);(!e.altKey)?snapMark(p[0],p[1]):snapClear();
|
|
6068
6369
|
let g=document.getElementById('csPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='csPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}
|
|
6069
6370
|
g.innerHTML=csDraft?axisGlyphSvg(csDraft,[p[0]-csDraft[0],p[1]-csDraft[1]],true):'';} // before click 1 → just the snap marker; after → rubber-band axes toward the pointer
|
|
6070
|
-
function resetFrame(){if(!P.frame)return;edit(()=>{P
|
|
6371
|
+
function resetFrame(){if(!P.frame)return;edit(()=>{ModelCmd.setPlanFrame(P,null);});toast('Axes reset to global');}
|
|
6071
6372
|
// One coordinate-axes glyph → SVG string. `dir` = any vector along local-X (normalized here). Screen-constant
|
|
6072
6373
|
// size (÷zoom), re-synced on zoom by updateBadges. Tekla axis colours: X = red, Y = green, origin = Z blue
|
|
6073
6374
|
// (local-Y = [uy,-ux], plan X-right→Y-up; in plan view Z points out of screen, so it's the origin dot).
|
|
@@ -6124,8 +6425,9 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
6124
6425
|
if(qdPick){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();const pp=qdPick;qdPick=null;setQdPickCls();quickDimSpacing(pp.pt,[x,y]);e.preventDefault();return;} // F7 grid quick-dim: the armed one-shot station pick consumes this click BEFORE the grid-line hit test — the picked station often lies ON a grid line, which must not start a grid drag instead (Codex final-review #6)
|
|
6125
6426
|
{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)
|
|
6126
6427
|
const gel=gb||ghit;
|
|
6127
|
-
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&gridOf()
|
|
6128
|
-
const free=gel.dataset.gl!=null
|
|
6428
|
+
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&gridOf()){
|
|
6429
|
+
const free=gel.dataset.gl!=null;if(!gridDragAllowed(free?'free':'regular'))return;
|
|
6430
|
+
const axis=free?'l':(gel.dataset.gv!=null?'v':'h'),gi=+(free?gel.dataset.gl:(gel.dataset.gv!=null?gel.dataset.gv:gel.dataset.gh));
|
|
6129
6431
|
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]);
|
|
6130
6432
|
if(line){const end=gb?+(gb.dataset.end||0):null; // a bubble grab can become an END drag; a body grab translates the line
|
|
6131
6433
|
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()};
|
|
@@ -6170,12 +6472,12 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
6170
6472
|
if(t.classList.contains('handle')){const id=t.dataset.mid||[...selIds][0],m=byId(id),h=+t.dataset.h;if(!m)return;buildSnap(id);
|
|
6171
6473
|
drag={type:'end',h,id,anchor:m.wp[1-h].slice(),orig:m.wp[h].slice(),pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // anchor = the fixed end (length ref); orig = where this end started (moved ref)
|
|
6172
6474
|
if(t.classList.contains('lblhot')){const prof=t.dataset.prof;
|
|
6173
|
-
if(mode!=='add'&&picking&&pickKind==='profile'&&selIds.size===1){const id=[...selIds][0];picking=false;edit(()=>{const m=byId(id);m
|
|
6475
|
+
if(mode!=='add'&&picking&&pickKind==='profile'&&selIds.size===1){const id=[...selIds][0];picking=false;edit(()=>{const m=byId(id);ModelCmd.patchMember(m,{profile:prof,rfi:_wt(prof)==null});if(!profs.includes(prof)){profs.push(prof);profs.sort();}});return;} // in Add mode a profile pick ALWAYS means "adopt as the current add profile" (a 3D draw can leave a member selected)
|
|
6174
6476
|
if(mode==='add'&&!drawDraft){addProfile=prof;if(picking&&pickKind==='profile'){picking=false;render();return;} // adopt a label's profile ONLY before the first click; mid-draw a label click falls through to drawClick → places the END on that label's point (mirrors the seg guard)
|
|
6175
6477
|
const hi=document.getElementById('addProf');if(hi)hi.value=addProfile;const ph=document.getElementById('pickHint');if(ph){ph.classList.add('pick');setTimeout(()=>ph&&ph.classList.remove('pick'),450);}return;}
|
|
6176
6478
|
return;}
|
|
6177
6479
|
if(t.classList.contains('dethot')){const det=t.dataset.det;
|
|
6178
|
-
if(picking&&pickKind==='detail'&&pickEnd){const o=pickEnd;picking=false;pickEnd=null;edit(()=>{o
|
|
6480
|
+
if(picking&&pickKind==='detail'&&pickEnd){const o=pickEnd;picking=false;pickEnd=null;edit(()=>{ModelCmd.patchEnd(o,{detail:det});});}return;}
|
|
6179
6481
|
{const cg=t.closest('g.cohot');if(cg){const sheet=cg.dataset.coSheet,prev=cg.dataset.coPrev; // Workstream B smart jump
|
|
6180
6482
|
const idx=sheet?C.plans.findIndex(p=>p.sheet&&p.sheet.toUpperCase()===sheet.toUpperCase()):-1;
|
|
6181
6483
|
if(idx>=0){if(idx!==C.active)setPlan(idx);else fitToWindow();} // referenced sheet is loaded → switch to it (or re-frame if already here)
|
|
@@ -6214,7 +6516,7 @@ svg.addEventListener('pointermove',e=>{
|
|
|
6214
6516
|
if(!drag)return;const p=toSvg(e);
|
|
6215
6517
|
if(drag.type==='gridfree'){const dxc=p.x-drag.startPt[0],dyc=p.y-drag.startPt[1];
|
|
6216
6518
|
if(!drag.moved){if(Math.hypot(dxc,dyc)<=4/zoom)return;drag.moved=true;}
|
|
6217
|
-
const _dg=gridOf();const line=_dg&&_dg.lines&&_dg.lines[drag.gi];if(!line||!gridDragAllowed())return;
|
|
6519
|
+
const _dg=gridOf();const line=_dg&&_dg.lines&&_dg.lines[drag.gi];if(!line||!gridDragAllowed('free'))return;
|
|
6218
6520
|
let a=drag.origA.slice(),b=drag.origB.slice();
|
|
6219
6521
|
if(drag.end!=null){const target=drag.end===0?a:b;let x=target[0]+dxc,y=target[1]+dyc;
|
|
6220
6522
|
if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
@@ -6269,9 +6571,9 @@ svg.addEventListener('pointermove',e=>{
|
|
|
6269
6571
|
const mcG=MC(); // built inside the grip branch, so the far more common ungripped dim drag pays nothing
|
|
6270
6572
|
if(gp.rigid){const dx=x-gp.oa[0],dy=y-gp.oa[1];mcG.setEndpointsInPlace(m,[gp.ow[0][0]+dx,gp.ow[0][1]+dy],[gp.ow[1][0]+dx,gp.ow[1][1]+dy]);} // ABSOLUTE from the grab-time origin gp.ow, as the inline pair was
|
|
6271
6573
|
else mcG.setEndpoint(m,gp.pt==='a'?0:1,[x,y]);}}
|
|
6272
|
-
if(drag.end===0)
|
|
6574
|
+
if(drag.grip)refreshMagneticDims2D();else updatePlanDim(d.id,row=>{if(drag.end===0)row.a=[x,y];else row.b=[x,y];});render();}return;} // dragging a dim anchor → snap + re-measure live (render() reanchors every OTHER magnetic dim off the grip-moved member too)
|
|
6273
6575
|
if(drag.type==='dim'){if(!drag.moved){if(Math.hypot(e.clientX-drag.cx0,e.clientY-drag.cy0)<4)return;drag.moved=true;} // below the threshold it's a click/double-click, not an offset slide — don't touch off or write an undo entry (Codex code-review #4)
|
|
6274
|
-
const d=P.dims.find(x=>x.id===drag.id);if(d){
|
|
6576
|
+
const d=P.dims.find(x=>x.id===drag.id);if(d){const off=dimOffFromPointer(d.a,d.b,d.axis,[p.x,p.y],d.rot);updatePlanDim(d.id,row=>{row.off=off;});render();}return;}
|
|
6275
6577
|
if(drag.type==='marquee'){const x=Math.min(drag.x0,p.x),y=Math.min(drag.y0,p.y),w=Math.abs(p.x-drag.x0),h=Math.abs(p.y-drag.y0);
|
|
6276
6578
|
drag.window=(e.clientX>=drag.sx0); // Tekla: drag L→R = window (enclose); R→L = crossing (touch)
|
|
6277
6579
|
drag.rect.classList.toggle('window',drag.window); // solid rect = window, dashed = crossing (visual affordance)
|
|
@@ -6342,8 +6644,9 @@ svg.addEventListener('pointerup',()=>{if(!drag)return;snapClear();epPrevClear();
|
|
|
6342
6644
|
else if(drag.type==='dimend'){const d=P.dims.find(x=>x.id===drag.id); // F9: a hand-dragged anchor RE-LINKS to whatever it landed on (member point / grid line) so magnetism survives handle moves (QA 2026-07-16); a free-space drop detaches so the manual position wins (Codex R1 #13). Only when it actually moved.
|
|
6343
6645
|
if(d&&drag.pre&&snapshot()!==drag.pre){const rk=drag.end===0?'aRef':'bRef',had=!!d[rk];
|
|
6344
6646
|
const nr=dimRefAtPoint(P,drag.end===0?d.a:d.b,d);
|
|
6345
|
-
if(nr)
|
|
6346
|
-
|
|
6647
|
+
updatePlanDim(d.id,row=>{if(nr)row[rk]=nr;else delete row[rk];});
|
|
6648
|
+
if(nr)toast((nr.g?'Dimension end linked to grid line':'Dimension end linked to member')+(d.pin===false?' — unpinned':''));
|
|
6649
|
+
else if(had)toast('Dimension end unlinked');}}
|
|
6347
6650
|
if((drag.type==='dim'||drag.type==='dimend')&&drag.pre&&snapshot()!==drag.pre)_lastDimDown=null; // a dim that was actually dragged (off slid / anchor moved) must not pair with the next click as a double-click (Codex code-review #5)
|
|
6348
6651
|
if(drag.pre&&snapshot()!==drag.pre)pushUndo(drag.pre);
|
|
6349
6652
|
if(!anyToolActive())snapOnlyClear2d(); // a select-mode drag WAS the operation → the override was single-shot
|
|
@@ -6447,7 +6750,13 @@ document.getElementById('plToggleB').onclick=e=>{e.stopPropagation();if(!canWrit
|
|
|
6447
6750
|
// hasOverlay() answers true — leaving this row live over a canvas that draws nothing. Worse than inert:
|
|
6448
6751
|
// the handler persists to `steel:refSheet:v1`, which is not project-scoped, so a click here would follow
|
|
6449
6752
|
// the user into their next v1 project and hide the traced sheet there.
|
|
6450
|
-
|
|
6753
|
+
const REF_TIP='Show or hide the traced reference sheet (the PDF/SVG drawing under the model). Hidden, it also stops contributing snap points.';
|
|
6754
|
+
function updRefToggle(){const b=document.getElementById('refToggleB');if(!b)return;const on=!MODEL_RO&&refSheetOn;b.disabled=MODEL_RO||!hasOverlay();b.classList.toggle('on',on);b.setAttribute('aria-checked',String(on)); // F13: grey the row out on a plan with no reference sheet (mirrors updGridToggle's no-grid disable)
|
|
6755
|
+
// #507: a non-drawable layer is excluded whatever this toggle says, and NOTHING in the editor sets
|
|
6756
|
+
// that flag — the reader writes it and Steel Filter only dims the row. So say it here, on the one
|
|
6757
|
+
// control a user consults to reason about the backdrop, instead of leaving the omission silent.
|
|
6758
|
+
const n=hiddenLayerCount();
|
|
6759
|
+
b.setAttribute('data-tip',REF_TIP+(n?(' '+n+' layer'+(n===1?'':'s')+' marked “listed but not drawn” '+(n===1?'is':'are')+' always excluded — review them in Steel Filter.'):''));}
|
|
6451
6760
|
document.getElementById('refToggleB').onclick=e=>{e.stopPropagation();if(MODEL_RO)return;refSheetOn=!refSheetOn;try{localStorage.setItem('steel:refSheet:v1',refSheetOn?'1':'0');}catch(_){}updRefToggle();render();}; // render() rebuilds the SVG (overlaySvg gone/back) and buildSnap re-reads overlaySnapGeom (snap candidates gone/back)
|
|
6452
6761
|
document.getElementById('gridEditB').onclick=()=>{setGridMode(!gridMode);render();};
|
|
6453
6762
|
{const ghb=document.getElementById('gridHdrB');if(ghb)ghb.onclick=()=>{setGridMode(!gridMode);render();};} // the header twin (read-only mode only) — same one action, not a second implementation
|
|
@@ -6535,10 +6844,24 @@ function roLock(el){
|
|
|
6535
6844
|
* built lazily by build3DLegend() long after boot; disabling it once at boot would miss it.
|
|
6536
6845
|
*/
|
|
6537
6846
|
function roDisablePropLabelToggles(){
|
|
6538
|
-
|
|
6847
|
+
// MODEL_V2, not MODEL_RO: the flag has no home in v2's closed `prop_labels` whether or not the document
|
|
6848
|
+
// is writable, so a live v2 model must disable these two exactly as a read-only one did. Leaving them
|
|
6849
|
+
// enabled over a refused write is the silent no-op this whole mode exists to avoid.
|
|
6850
|
+
if(!MODEL_V2)return;
|
|
6539
6851
|
for(const id of ['plToggleB','m3dPropLabels']){
|
|
6540
6852
|
const el=document.getElementById(id);
|
|
6541
|
-
if(el)
|
|
6853
|
+
if(!el)continue;
|
|
6854
|
+
el.disabled=true;
|
|
6855
|
+
// REPORT OFF, not just unavailable. `m3dPropLabels` is static markup carrying `checked`, and nothing
|
|
6856
|
+
// syncs it until the user opens the View menu — so without this the first frame (and the closed menu's
|
|
6857
|
+
// accessibility state) says "checked, and you cannot turn it off" for a flag plVis answers false to.
|
|
6858
|
+
// That is the same lie the read-only repair removed from the 2D rows, which stay honest because
|
|
6859
|
+
// updPlToggle derives both `on` and aria-checked from plVis. (Found by Codex reviewing this fix.)
|
|
6860
|
+
if(el.type==='checkbox')el.checked=plVis(id==='m3dPropLabels');
|
|
6861
|
+
// The ribbon only renders under `body.model-ro`, so pointing a LIVE v2 control at it would name an
|
|
6862
|
+
// element that is not on the page — and its text says the whole model is read-only, which is no longer
|
|
6863
|
+
// true here. Describe it only where the ribbon actually exists.
|
|
6864
|
+
if(MODEL_RO)el.setAttribute('aria-describedby','roRibbon');else el.removeAttribute('aria-describedby');
|
|
6542
6865
|
}
|
|
6543
6866
|
}
|
|
6544
6867
|
/** The Views tab's header write actions, disabled on each render (the tab rebuilds its own buttons). */
|
|
@@ -6562,8 +6885,10 @@ document.getElementById('revB').onclick=()=>{const ids=reversedBeams(); // bea
|
|
|
6562
6885
|
toast(ids.length+' reversed beam'+(ids.length>1?'s':'')+' selected — press P to swap direction');}; // select reversed → review → P swaps them
|
|
6563
6886
|
document.getElementById('mrgB').onclick=()=>{const r=mergeCollinearJS(P.members); // conservative; result is undoable (Ctrl+Z)
|
|
6564
6887
|
if(!r.mergedAway){toast('Nothing to merge');return;}
|
|
6565
|
-
edit(()=>{
|
|
6566
|
-
ModelCmd.
|
|
6888
|
+
edit(()=>{if(MODEL_V2)V2_SESSION.mergeMemberGroups(P.sheet,r.merges);
|
|
6889
|
+
else{ModelCmd.detachDimRefs(P,r.affectedIds); // F9: detach dim refs to every merged member (safe-freeze; Codex R3 #3). What matters is that this lands before the next render() — reanchorAllPlans() runs there, and the survivor keeps its id, so a ref left attached would silently re-anchor to the merged end. edit() renders after the callback, so this and the line below are order-independent; the original's order is kept regardless.
|
|
6890
|
+
ModelCmd.setPlanMembers(P,r.members);}
|
|
6891
|
+
selIds=new Set();selDimIds.clear();});
|
|
6567
6892
|
toast('Merged '+r.mergedAway+' segment'+(r.mergedAway===1?'':'s')+' into '+r.runs+' member'+(r.runs===1?'':'s'));};
|
|
6568
6893
|
document.getElementById('undoB').onclick=doUndo;
|
|
6569
6894
|
document.getElementById('redoB').onclick=doRedo;
|
|
@@ -6633,9 +6958,15 @@ addEventListener('keydown',e=>{
|
|
|
6633
6958
|
const hadReg=[...selGridIds].some(id=>id.startsWith('gv:')||id.startsWith('gh:')); // regular (spacing-generated) lines can't be individually deleted
|
|
6634
6959
|
const willMutate=selDimIds.size||selIds.size||freeToDelete.length;
|
|
6635
6960
|
if(willMutate)edit(()=>{
|
|
6636
|
-
if(
|
|
6961
|
+
if(MODEL_V2){
|
|
6962
|
+
const jids=selJointIds(),memberIds=new Set([...selIds].filter(id=>!!byId(id)));
|
|
6963
|
+
deleteV2Selection({memberIds,dimIds:selDimIds,jointIds:jids,gridLineIds:new Set(freeToDelete.map(line=>String(line.id)))});
|
|
6964
|
+
selIds.clear();selDimIds.clear();selGridIds.clear();return;
|
|
6965
|
+
}
|
|
6966
|
+
if(selDimIds.size){ModelCmd.setPlanDims(P,P.dims.filter(d=>!selDimIds.has(d.id)));selDimIds.clear();}
|
|
6637
6967
|
if(selIds.size){const jids=selJointIds();if(jids.size)C.joints=(C.joints||[]).filter(j=>!(j&&jids.has(j.id))); // any selected connection parts → remove their joints too (a mixed member+connection or connection+grid Delete)
|
|
6638
|
-
for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));
|
|
6968
|
+
for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));
|
|
6969
|
+
selIds.clear();} // selection spans sheets → remove from every plane, not just the active one
|
|
6639
6970
|
if(freeToDelete.length)ModelCmd.removeGridLines(gridOf(),glLids);
|
|
6640
6971
|
selGridIds.clear();});
|
|
6641
6972
|
else{selGridIds.clear();render();} // only regular grid lines were selected → nothing to delete (no phantom undo step); repaint to drop the highlight
|
|
@@ -7077,9 +7408,16 @@ async function sendSelectionToHost(host,ids,hostPid){
|
|
|
7077
7408
|
*
|
|
7078
7409
|
* This is the same line drawn everywhere else in this mode: display state stays live where v2's schema
|
|
7079
7410
|
* allows it (`dim_overlays` is open, and its toggles are untouched), and is refused where v2 closed it.
|
|
7411
|
+
*
|
|
7412
|
+
* BOTH GATES ASK THE FORMAT, NOT WRITABILITY. They shipped as `canWriteModel()` / `MODEL_RO`, which were
|
|
7413
|
+
* indistinguishable from MODEL_V2 while v2 was read-only. Activating v2 (MODEL_V2_LIVE) made MODEL_RO
|
|
7414
|
+
* permanently false and re-opened both: the click handlers began writing `vis2d`/`vis3d` onto a closed
|
|
7415
|
+
* `prop_labels` — corrupting the document so the NEXT save is refused for a toggle the user flicked — and
|
|
7416
|
+
* `plVis` began answering from those flags, which is the TypeError path the paragraph above describes.
|
|
7417
|
+
* Making v2 writable does not give v2 a place to keep this flag, nor a label derivation that could use it.
|
|
7080
7418
|
*/
|
|
7081
|
-
function canWritePropLabelVis(){return canWriteModel();}
|
|
7082
|
-
function plVis(is3d){if(
|
|
7419
|
+
function canWritePropLabelVis(){return canWriteModel()&&!MODEL_V2;}
|
|
7420
|
+
function plVis(is3d){if(MODEL_V2)return false;const pl=C&&C.prop_labels;return !!(pl&&(is3d?pl.vis3d:pl.vis2d));}
|
|
7083
7421
|
/** v2's ONE root member array. Not a plan property — see §8.3 on why reading `C.plans[].members` is worse than useless here. */
|
|
7084
7422
|
function modelMembersV2(){return (C&&Array.isArray(C.members))?C.members:[];}
|
|
7085
7423
|
/** Refuse a read the v2 arm cannot answer truthfully. THROWS — never a default, never a silent empty. */
|
|
@@ -7149,7 +7487,7 @@ function modelReadsV2(){
|
|
|
7149
7487
|
const view3dApi={
|
|
7150
7488
|
// The model read half — see modelReadsV1 / modelReadsV2 above. Built ONCE per view init; the arm is
|
|
7151
7489
|
// decided by MODEL_RO, which boot() pinned from the validated type and nothing changes afterwards.
|
|
7152
|
-
model:()=>
|
|
7490
|
+
model:()=>MODEL_V2?modelReadsV2():modelReadsV1(),
|
|
7153
7491
|
onFrame3dChange:()=>{updCS();if(typeof csSyncF3d==='function')csSyncF3d();
|
|
7154
7492
|
// F14: the Definition-points local (X′/Y′/Z′) row reads the 3D frame — refresh the inspector when the
|
|
7155
7493
|
// frame changes outside a render() path (notably Reset-to-global, which only fires this callback). Skip
|
|
@@ -7194,21 +7532,21 @@ const view3dApi={
|
|
|
7194
7532
|
// so for v2 both of these answer the same list, truthfully, rather than the silent [] that reading
|
|
7195
7533
|
// `C.plans[].members` would give (§8.3). The view only ever takes ids and hands the records back to
|
|
7196
7534
|
// `model().geometryOf`, so a v2 record travelling through here is read by nothing that assumes `wp`.
|
|
7197
|
-
getMembers:()=>
|
|
7535
|
+
getMembers:()=>MODEL_V2?modelMembersV2():P.members, // v1: active-sheet members (wp); v2 3D reads canonical world members.
|
|
7198
7536
|
allMembers, // EVERY member in the model — already format-aware (see its definition); the 3D box-select tests all visible meshes, not just the active sheet's
|
|
7199
7537
|
// ── The three reads §8.3 names as plausible-but-FALSE for v2. Each is a v1 PLAN concept, and each has a
|
|
7200
7538
|
// wrong answer that looks right: an empty member list, a substituted default T.O.S that silently
|
|
7201
7539
|
// relocates members, and a world-mm grid read through v1's display-space assumptions. The 3D view no
|
|
7202
7540
|
// longer asks any of them — every one moved behind `model()` above — so these throws are TRIPWIRES: if
|
|
7203
7541
|
// one fires, a v1-shaped read has crept back in, and it says so instead of answering.
|
|
7204
|
-
membersByPlan:()=>
|
|
7542
|
+
membersByPlan:()=>MODEL_V2?v2Refuse('membersByPlan — v2 has no per-plan members'):((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
|
|
7205
7543
|
snapEnabled:()=>snapEnabled, // the persistent running-snaps (⋯ menu → Snapping) — 3D honours the same on/off set
|
|
7206
7544
|
snap3dFree:()=>snap3dFree, // SNAP-bar "3D snapping" mode — ON: free 3D snap; OFF: 3D placement snap constrained to the working plane
|
|
7207
7545
|
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
|
|
7208
7546
|
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)
|
|
7209
7547
|
canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
|
|
7210
|
-
ptPerFt:()=>
|
|
7211
|
-
defaultTosMm:()=>
|
|
7548
|
+
ptPerFt:()=>MODEL_V2?v2Refuse('ptPerFt — a drawing scale belongs to a SHEET; v2 members and grid are world mm'):(P&&P.pt_per_ft>0?P.pt_per_ft:1),
|
|
7549
|
+
defaultTosMm:()=>MODEL_V2?v2Refuse('defaultTosMm — v2 materialised every elevation, so a substituted default would silently relocate members'):(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
|
|
7212
7550
|
geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
|
|
7213
7551
|
onMoveMember:(id,newWp)=>{edit(()=>{const m=byId(id);if(m)MC().replaceEndpoints(m,newWp);});}, // 3D drag → write wp (undoable, autosaves, syncs 2D/chip/BOM). NOTE: the Select filter gates SELECTION (pick/marquee/Ctrl+A), NOT direct 3D drag-manipulation — gating here would strand the renderer's live preview (the mesh is already moved), so a filtered member is still directly draggable in 3D by design.
|
|
7214
7552
|
dragMoveEnabled:()=>dragMoveOn, // the 3D view gates its plain member-drag on this
|
|
@@ -7236,7 +7574,7 @@ const view3dApi={
|
|
|
7236
7574
|
geoMode=null;setGeo();snapEndMulti(sel,tm.wp[0],tm.wp[1]);}, // 3D Trim/Extend → every selected member's nearest end to the target line (snapEndMulti skips braces)
|
|
7237
7575
|
onSplit:(id,wp)=>{const m=byId(id);if(m){doSplit(m,wp);sync3D();}}, // 3D Split → cut at the clicked point on the member
|
|
7238
7576
|
getDims3d:()=>C.dims3d||[],
|
|
7239
|
-
getGrid:()=>
|
|
7577
|
+
getGrid:()=>MODEL_V2?v2Refuse('getGrid — the model grid is world mm; ask model().gridDraw() so the space comes with it'):((P&&P.grid)||null), // the ACTIVE plan's structural grid for the 3D render + plan-locked snapping (per-plan, display-space)
|
|
7240
7578
|
getDimOverlays:()=>C.dim_overlays||{}, // the legend DIMENSIONS toggles {bolt_pitch,edge_clearance,cope_size} — the 3D view derives + filters overlays from this
|
|
7241
7579
|
// dims3d is model-global: mutate + persist directly. NOT via edit() — a plan-scoped undo snapshot would corrupt dims3d across plans (undo on plan A could wipe dims added on plan B), and edit()'s sync3D would needlessly re-extrude every member mesh for a pure annotation. boot() guarantees C.dims3d is an array.
|
|
7242
7580
|
// May the VIEW arm a tool that writes? It cannot infer this from a disabled button — the dim tool also
|
|
@@ -7302,7 +7640,7 @@ const view3dApi={
|
|
|
7302
7640
|
m=ensureMeta({id,profile:addProfile,wp:[wpA,wpB],role:'beam',angle:_mAngle([wpA,wpB])}); // classify H/V/D from the PLAN delta — same rule as _mAngle + the 2D add path (all three agree)
|
|
7303
7641
|
const mfNote=/(^|[^A-Z])MF/i.test(addProfile||'')?'moment':''; // a moment-frame profile keeps the auto note ensureMeta gives 2D-drawn members
|
|
7304
7642
|
m.ends=[{tos:near(zA)?null:zA,note:mfNote,tosDef:near(zA),detail:''},{tos:near(zB)?null:zB,note:mfNote,tosDef:near(zB),detail:''}];}
|
|
7305
|
-
if((addType==='column')===(m.role==='column'))m
|
|
7643
|
+
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
|
|
7306
7644
|
m.rfi=(_wt(addProfile)==null);MC().addMembers(P,[m]);
|
|
7307
7645
|
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}
|
|
7308
7646
|
selIds=new Set([id]);});
|
|
@@ -7566,11 +7904,14 @@ function applyMemberType(ms,k){
|
|
|
7566
7904
|
let dropped=0,unsupported=0;
|
|
7567
7905
|
for(const m of ms){if(!m)continue;
|
|
7568
7906
|
const wasBrace=isBrace(m);
|
|
7569
|
-
|
|
7907
|
+
if(MODEL_V2){
|
|
7908
|
+
const brace=type==='brace'?{type:(m.brace&&m.brace.type)==='lateral'?'lateral':'vertical',floor:(m.brace&&m.brace.floor)==='below'?'below':'above',offset:Number.isFinite(+(m.brace&&m.brace.offset))?+m.brace.offset:0}:undefined;
|
|
7909
|
+
ModelCmd.patchMember(m,{role,memberType:type,brace});
|
|
7910
|
+
}else{m.role=role;ensureMeta(m);ModelCmd.setMemberType(m,type);normBrace(m);} // normBrace: seed m.brace on entering brace, DELETE it on leaving (Codex round-1/2)
|
|
7570
7911
|
// Becoming a brace ORPHANS any connection hanging off this member: the bake (steel-joints.expandJoints)
|
|
7571
7912
|
// refuses a brace `main`, so the joint would linger in C.joints, never render, and vanish from 3D with no
|
|
7572
7913
|
// explanation. Purge it here and say so, rather than leave a recipe that can never bake. (silent-failure review)
|
|
7573
|
-
if(!wasBrace&&
|
|
7914
|
+
if(!wasBrace&&type==='brace'&&Array.isArray(C.joints)&&C.joints.length){
|
|
7574
7915
|
const before=C.joints.length;
|
|
7575
7916
|
C.joints=C.joints.filter(j=>!(j&&j.main===m.id));
|
|
7576
7917
|
dropped+=before-C.joints.length;
|
|
@@ -7754,9 +8095,16 @@ function magnifierSvg(){const NS='http://www.w3.org/2000/svg',svg=document.creat
|
|
|
7754
8095
|
// ── Save current view + New from direction ───────────────────────────────────────────────────────────────────
|
|
7755
8096
|
// Capture the FULL A1 snapshot from the live editor. name defaults to "View N"; a fresh id + order-at-top.
|
|
7756
8097
|
function captureView(name){const V=window.Steel3DView;
|
|
7757
|
-
|
|
7758
|
-
camera:V.cameraState?V.cameraState():null,
|
|
7759
|
-
clips:V.clipState?V.clipState():null,objects:V.objectsPaneState?V.objectsPaneState():null};
|
|
8098
|
+
const view={v:1,id:'v'+Math.random().toString(36).slice(2,9),name:name||('View '+((C.views||[]).length+1)),order:0,
|
|
8099
|
+
camera:V.cameraState?V.cameraState():null,mode:V.mode?V.mode():'solid',
|
|
8100
|
+
clips:V.clipState?V.clipState():null,objects:V.objectsPaneState?V.objectsPaneState():null};
|
|
8101
|
+
// The ROOT `projection` key is v1's shape and v2's `view` is closed against it — saving one corrupts the
|
|
8102
|
+
// document, so the next save is refused for a view the user just pressed Save on. v2 keeps the projection
|
|
8103
|
+
// in `camera.proj`, which `cameraState()` already writes and `setCameraState()` already restores; the
|
|
8104
|
+
// root key is only activateView's fallback for a view that has NO camera, which capture never produces.
|
|
8105
|
+
// (While v2 was read-only this was unreachable because the whole Views library was; P3 made it writable.)
|
|
8106
|
+
if(!MODEL_V2)view.projection=V.projection?V.projection():'persp';
|
|
8107
|
+
return view;}
|
|
7760
8108
|
// Push a captured view to the TOP (order 0; bump the rest), then persist + re-render + inline-rename it.
|
|
7761
8109
|
function addView(v,{rename=true}={}){if(!canWriteViews())return;if(!Array.isArray(C.views))C.views=[];
|
|
7762
8110
|
for(const x of C.views)x.order=(x.order||0)+1;v.order=0;C.views.push(v);activeViewId=v.id;scheduleSave();renderViewsTab();
|
|
@@ -7802,7 +8150,12 @@ function startViewRename(v,row){const nameEl=row.querySelector('.vwname');if(!na
|
|
|
7802
8150
|
inp.addEventListener('blur',()=>finish(true));
|
|
7803
8151
|
}
|
|
7804
8152
|
// ── Row ⋯ menu: Rename / Duplicate / Update to current ──────────────────────────────────────────────────────────
|
|
7805
|
-
function updateViewToCurrent(v){if(!canWriteViews())return;const snap=captureView(v.name);snap.id=v.id;snap.order=v.order;v.camera=snap.camera;
|
|
8153
|
+
function updateViewToCurrent(v){if(!canWriteViews())return;const snap=captureView(v.name);snap.id=v.id;snap.order=v.order;v.camera=snap.camera;
|
|
8154
|
+
// DELETE rather than assign on v2: `snap.projection` is absent there, and `v.projection=undefined` still
|
|
8155
|
+
// leaves the forbidden key on the object for the client-side validator to reject. It also scrubs the key
|
|
8156
|
+
// off a view that arrived carrying it from a v1 migration.
|
|
8157
|
+
if(MODEL_V2)delete v.projection;else v.projection=snap.projection;
|
|
8158
|
+
v.mode=snap.mode;v.clips=snap.clips;v.objects=snap.objects;delete v.generated;v.v=1;activeViewId=v.id;scheduleSave();renderViewsTab();toast('Updated “'+v.name+'” to the current view');}
|
|
7806
8159
|
function duplicateView(v){
|
|
7807
8160
|
if(!canWriteViews())return;
|
|
7808
8161
|
const copy=JSON.parse(JSON.stringify(v));copy.id='v'+Math.random().toString(36).slice(2,9);copy.name=uniqueViewName(v.name+' copy');
|
|
@@ -7915,7 +8268,6 @@ function openNewFromDirectionMenu(anchorEl){closeViewRowMenu();
|
|
|
7915
8268
|
}
|
|
7916
8269
|
|
|
7917
8270
|
// ── F11: batch-generate orthographic saved views from the active plan's regular X/Y grids or Z levels. ──
|
|
7918
|
-
function viewGenOpen(){return document.getElementById('viewGenModal').style.display==='flex';}
|
|
7919
8271
|
function viewGenCurrentSources(){if(!viewGenState)return [];return viewGenState.tab==='levels'?viewGenState.sources.levels:[...viewGenState.sources.x,...viewGenState.sources.y];}
|
|
7920
8272
|
function viewGenKey(s){return s.kind+':'+s.index;}
|
|
7921
8273
|
function closeViewGenerator(){const modal=document.getElementById('viewGenModal');if(modal)modal.style.display='none';viewGenState=null;
|
|
@@ -7960,7 +8312,11 @@ function createGeneratedViews(){if(!canWriteViews())return;if(!viewGenState)retu
|
|
|
7960
8312
|
const selected=viewGenCurrentSources().filter(s=>viewGenState.selected.has(viewGenKey(s))),made=[],skipped=[],taken=new Set((C.views||[]).map(v=>v.name));
|
|
7961
8313
|
const freshName=base=>{let name=base,i=2;while(taken.has(name))name=base+' '+i++;taken.add(name);return name;};
|
|
7962
8314
|
for(const source of selected){const base=ViewGen.nameForSource(source),name=freshName(base),cut=ViewGen.cutForSource(source,parsed.values,viewGenState.look,bounds),snap=cut&&V.sectionViewState?V.sectionViewState(cut.box,cut.direction,name):null;
|
|
7963
|
-
if(!cut||!snap){taken.delete(name);skipped.push(base);continue;}
|
|
8315
|
+
if(!cut||!snap){taken.delete(name);skipped.push(base);continue;}// The same closed-`view` rule as captureView: no root `projection` on v2. These are always ortho and
|
|
8316
|
+
// `snap.camera.proj` already says so, so v2 loses nothing by omitting it.
|
|
8317
|
+
const view={v:2,id:'v'+Math.random().toString(36).slice(2,9),name,order:made.length,camera:snap.camera,mode:'solid',clips:snap.clips,objects:{v:1,hidden:[],solo:[],isolated:null,connHidden:[]},generated:cut.generated};
|
|
8318
|
+
if(!MODEL_V2)view.projection='ortho';
|
|
8319
|
+
made.push(view);}
|
|
7964
8320
|
if(!made.length){document.getElementById('vgError').textContent=skipped.length?'No selected cut intersects the model. Increase the cut depths or choose another source.':'No views were created.';return;}
|
|
7965
8321
|
if(!Array.isArray(C.views))C.views=[];for(const old of C.views)old.order=(old.order||0)+made.length;C.views.push(...made);scheduleSave();closeViewGenerator();renderViewsTab();
|
|
7966
8322
|
setTimeout(()=>{for(const v of made){const row=document.querySelector('#m3dViewsBody .vwrow[data-id="'+v.id+'"]');if(row){row.classList.add('flash');setTimeout(()=>row.classList.remove('flash'),650);}}},0);
|
|
@@ -8898,7 +9254,7 @@ function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||isBrace(beam
|
|
|
8898
9254
|
if(beam.mf===true||/^MF/i.test(beam.profile||''))return false; // a moment-frame girder (resolved via Frames → m.mf, or an unresolved MF mark) takes a MOMENT connection, not a shear tab
|
|
8899
9255
|
const end=beam.ends[endIdx];if(!end)return false;
|
|
8900
9256
|
const t=spConnText(end);if(spIsMoment(t))return false;if(spIsShear(t))return true;return !!spInferSupport(beam,endIdx);} // explicit moment → no; explicit shear → yes; else propose only where the end frames into a support
|
|
8901
|
-
function spEligibleEnds(){const out=[];for(const m of
|
|
9257
|
+
function spEligibleEnds(){const out=[];for(const m of legacyAllMembers()){if(!m||m.role==='column'||isBrace(m))continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;} // EVERY sheet's beams — eligibility per end still resolves the support within the beam's own sheet (spInferSupport)
|
|
8902
9258
|
function spBeamIds(){const s=new Set();for(const m of allMembers())if(m&&m.role!=='column'&&!isBrace(m)&&m.id)s.add(m.id);return s;} // EVERY sheet's beams (never braces) — selection/joints/undo are model-wide, so a model-wide selection scopes correctly
|
|
8903
9259
|
function spJointOf(beamId,endIdx){return (C.joints||[]).find(j=>j&&j.kind==='shear-plate'&&j.main===beamId&&j.at==='end'+endIdx);}
|
|
8904
9260
|
function spTargetEnds(){const e=spEligibleEnds();return selIds.size?e.filter(({beam})=>selIds.has(beam.id)):e;} // eligible ends of the SELECTED beams; empty selection = every eligible end (issue: create for selection, still supports all)
|
|
@@ -9125,7 +9481,7 @@ function openRFI(focusId){focusId=(typeof focusId==='string')?focusId:null; //
|
|
|
9125
9481
|
<td><button class=ghost data-loc="${esc(m.id)}">Locate</button></td></tr>`;}).join('')+'</tbody></table>')
|
|
9126
9482
|
:'<div class=hint>No unresolved members — every member has a resolved AISC size. ✓</div>';
|
|
9127
9483
|
g.querySelectorAll('input.combo[data-mid]').forEach(inp=>inp.onchange=e=>{const m=byId(inp.dataset.mid);if(!m)return;
|
|
9128
|
-
const v=e.target.value.toUpperCase().replace(/ /g,'');edit(()=>{m
|
|
9484
|
+
const v=e.target.value.toUpperCase().replace(/ /g,'');edit(()=>{ModelCmd.patchMember(m,{profile:v,rfi:_wt(v)==null});if(v&&!profs.includes(v)){profs.push(v);profs.sort();}});openRFI();});
|
|
9129
9485
|
g.querySelectorAll('button[data-loc]').forEach(b=>b.onclick=()=>{const m=byId(b.dataset.loc);if(!m)return;selDimIds.clear();selIds=new Set([m.id]);geoMode=null;setGeo();closeRFI();render();zoomToMember(m);});
|
|
9130
9486
|
document.getElementById('rfiModal').style.display='flex';
|
|
9131
9487
|
if(focusId){const inp=[...g.querySelectorAll('input.combo[data-mid]')].find(i=>i.dataset.mid===focusId);const row=inp&&inp.closest('tr'); // find via the row's profile input — avoids CSS-escaping the id
|
|
@@ -9148,7 +9504,6 @@ const BANDPILL={verified:'background:#166534;color:#86efac',high:'background:#14
|
|
|
9148
9504
|
// actually exists in the AISC catalogue (SHAPES), so a regex-matching but non-standard string (e.g. W99X999)
|
|
9149
9505
|
// stays unresolved (RFI) instead of being trusted for a bogus name-encoded weight.
|
|
9150
9506
|
function _nominalPlf(p){const k=String(p||'').toUpperCase().replace(/\s/g,'').replace(/×/g,'X');const m=k.match(/^(W|M|S|HP|C|MC|WT|MT|ST)\d+(?:\.\d+)?X([\d.]+)$/);if(!m)return null;const _S=window.__AISC_SHAPES;if(_S&&!_S.has(k))return null;return parseFloat(m[2]);}
|
|
9151
|
-
function _ensureWt(p){if(p&&WT&&WT[p]==null){const v=_nominalPlf(p);if(v!=null)WT[p]=v;}}
|
|
9152
9507
|
function _wt(profile){if(!profile)return null;
|
|
9153
9508
|
if(WT&&profile in WT&&WT[profile]!=null)return WT[profile];
|
|
9154
9509
|
if(WT){const t=canonProfile(profile);const h=Object.entries(WT).find(([k])=>canonProfile(k)===t);if(h&&h[1]!=null)return h[1];} // shared canonProfile identity so a ×/spaced designation matches its weight-map key
|
|
@@ -9496,7 +9851,7 @@ function jointAtEnd(memberId,which){const at=jointAtFor(which);
|
|
|
9496
9851
|
// Every (member, end) in the MODEL that carries a callout or a library reference — the population the
|
|
9497
9852
|
// bulk action walks. Model-wide, like joints and the selection.
|
|
9498
9853
|
function detailEndTargets(){const out=[];
|
|
9499
|
-
for(const m of
|
|
9854
|
+
for(const m of legacyAllMembers()){if(!m)continue;
|
|
9500
9855
|
if(m.role==='column'){if(m.col&&(m.col.detail||m.col.conn))out.push({m,which:'col'});continue;}
|
|
9501
9856
|
if(isBrace(m))continue; // a brace carries neither a shear plate nor a base plate — the engine skips the joint, so we must not claim to have applied one
|
|
9502
9857
|
for(const w of [0,1]){const e=(m.ends||[])[w];if(e&&(e.detail||e.conn))out.push({m,which:w});}}
|
|
@@ -9752,7 +10107,7 @@ function captureDetailRecipe(m,which,opt,type){
|
|
|
9752
10107
|
// so this is for the reader, not for correctness.
|
|
9753
10108
|
sched.sort((a,b)=>schedRank(a&&a.match)-schedRank(b&&b.match));
|
|
9754
10109
|
rec.schedule=sched;}
|
|
9755
|
-
e
|
|
10110
|
+
ModelCmd.patchEnd(e,{conn:rowId});j.conn=rowId; // the end and the joint both cite the row, so the confidence report sees the reference
|
|
9756
10111
|
});
|
|
9757
10112
|
return {rowId:rowId,droppedSchedule:droppedSchedule};}
|
|
9758
10113
|
const comboPop=document.createElement('div');comboPop.id='comboPop';document.body.appendChild(comboPop);
|
|
@@ -9810,13 +10165,37 @@ function setPlanV2(i){
|
|
|
9810
10165
|
refresh3DGrid();
|
|
9811
10166
|
syncPlanSwitcher(i);}
|
|
9812
10167
|
// --- multi-plan: switch between all steel plan views ---
|
|
9813
|
-
function setPlan(i){
|
|
9814
|
-
|
|
9815
|
-
if(
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
10168
|
+
function setPlan(i){
|
|
10169
|
+
const canonical=C.plans[i];
|
|
10170
|
+
if(MODEL_V2&&!canonical){
|
|
10171
|
+
NO_PLAN_VIEW=true;C.active=0;P={sheet:'',members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:0};
|
|
10172
|
+
setPlanV2(0);return;
|
|
10173
|
+
}
|
|
10174
|
+
if(MODEL_V2&&canonical&&canonical.viewKind!=='plan'){
|
|
10175
|
+
const kind=canonical.viewKind||'unknown',current=C.plans[C.active];
|
|
10176
|
+
if(!current||current.viewKind!=='plan'){
|
|
10177
|
+
NO_PLAN_VIEW=true;C.active=i;
|
|
10178
|
+
P={...structuredClone(canonical),members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:Number.isFinite(canonical.elevation_in)?canonical.elevation_in:0};
|
|
10179
|
+
setPlanV2(i);return;
|
|
10180
|
+
}
|
|
10181
|
+
toast(kind==='unknown'
|
|
10182
|
+
?`FloLess couldn’t determine ${canonical.sheet||'this sheet'}’s view type, so it can’t safely map it into 2D.`
|
|
10183
|
+
:`${canonical.sheet||'This sheet'} is a ${kind} view. ${kind[0].toUpperCase()+kind.slice(1)} views aren’t editable in 2D yet; stayed on ${(current&¤t.sheet)||'the current plan'}.`);
|
|
10184
|
+
syncPlanSwitcher(C.active);return;}
|
|
10185
|
+
C.active=i;
|
|
10186
|
+
if(MODEL_V2){
|
|
10187
|
+
NO_PLAN_VIEW=false;
|
|
10188
|
+
V2_PROJECTION=v2ProjectionForSheet(canonical.sheet);
|
|
10189
|
+
P=DEV_MODE?ModelCmd.deepFreezeProjection(V2_PROJECTION.plan):V2_PROJECTION.plan;
|
|
10190
|
+
}else P=C.plans[i];
|
|
10191
|
+
if(MODEL_RO){setPlanV2(i);return;}
|
|
10192
|
+
if(!MODEL_V2){
|
|
10193
|
+
if(!Array.isArray(P.members))P.members=[];
|
|
10194
|
+
if(!Array.isArray(P.segments))P.segments=[];
|
|
10195
|
+
sanitizeDims(P); // …and its dimensions: drop any whose geometry isn't numeric (they render straight into SVG attributes)
|
|
10196
|
+
sanitizeFrame(P); // tolerate a hand-edited/AI-written frame: normalize or drop to global
|
|
10197
|
+
sanitizePlanGrid(P); // finite origin + canonical labels/free lines; spacing strings report their own errors inline
|
|
10198
|
+
}
|
|
9820
10199
|
// clip = the drawing's display-space crop. A contract may ship WITHOUT a raster/clip (a shared or
|
|
9821
10200
|
// committed contract strips raster_b64 for confidentiality), so fall back to the members' bounding
|
|
9822
10201
|
// box (padded) → the editor renders members on a blank canvas instead of crashing on P.clip[0].
|
|
@@ -9828,12 +10207,12 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
9828
10207
|
else clip=[0,0,1000,1000];}
|
|
9829
10208
|
X0=clip[0];Y0=clip[1];X1=clip[2];Y1=clip[3];FT=P.pt_per_ft||12;RB64=P.raster_b64||'';EXTX=X1-X0;EXTY=Y1-Y0;
|
|
9830
10209
|
svg.setAttribute('viewBox',`${X0} ${Y0} ${X1-X0} ${Y1-Y0}`);
|
|
9831
|
-
P.members.forEach(ensureMeta);
|
|
10210
|
+
if(!MODEL_V2)P.members.forEach(ensureMeta);
|
|
9832
10211
|
// Auto-dedupe coincident members on first load of each plan — the read can bind one segment to
|
|
9833
10212
|
// two labels (a W-size + its MF mark) or overlap tile reads, producing stacked duplicates that
|
|
9834
10213
|
// double-count the BOM. Collapse them automatically (keep the most-resolved copy), undoable, once
|
|
9835
10214
|
// per plan. The "Duplicates" button stays for any made while editing.
|
|
9836
|
-
if(!P.deduped){P.deduped=true;const red=new Set(redundantDups());
|
|
10215
|
+
if(!MODEL_V2&&!P.deduped){P.deduped=true;const red=new Set(redundantDups());
|
|
9837
10216
|
if(red.size){const _pv=snapshot();P.members=P.members.filter(m=>!red.has(m.id));pushUndo(_pv); // whole-model snapshot pre-filter → the global stack can undo the dedupe from any plane
|
|
9838
10217
|
setTimeout(()=>toast('Auto-removed '+red.size+' duplicate member'+(red.size>1?'s':'')),60);}}
|
|
9839
10218
|
profs=[...new Set([...P.members.map(m=>m.profile), ...Object.keys(WT)])].sort();
|
|
@@ -9847,9 +10226,11 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
9847
10226
|
csaxisMode=false;setCsMode(); // set-axes tool resets per plan; P.frame itself is per-plan data (persisted), so it stays
|
|
9848
10227
|
snapOnlyClear2d();closeSnapMenu(); // a snap override never outlives its plan (different geometry)
|
|
9849
10228
|
disarmCm(); // Move/Copy resets per plan too (its counts persist — they're session prefs, not plan data)
|
|
9850
|
-
defaultTOS=(P.default_tos!=null?P.default_tos:198);
|
|
9851
|
-
|
|
9852
|
-
|
|
10229
|
+
defaultTOS=(!MODEL_V2&&P.default_tos!=null?P.default_tos:198);
|
|
10230
|
+
if(!MODEL_V2){
|
|
10231
|
+
ModelCmd.setPlanDefaultTos(P,defaultTOS); // v2 retired default links; every endpoint elevation is explicit or unknown
|
|
10232
|
+
if(!P.autofilled){autofillTOS();P.autofilled=true;}
|
|
10233
|
+
}
|
|
9853
10234
|
document.getElementById('detailsBtn').textContent='Details ('+detTexts().length+')'; // counts what the modal LISTS — openDetails() sets the same label from the same list, and the two disagreed on a callouts-only sheet (#397)
|
|
9854
10235
|
setMode();render();fitToWindow();
|
|
9855
10236
|
refresh3DGrid(); // the grid is PER-PLAN, so a plan switch must re-render it in 3D too. The plan switcher is 2D-only, but the Confidence report's Locate buttons switch sheets from 3D — without this the 3D view keeps drawing the OLD sheet's grid while snapping reads the NEW sheet's (found by Codex on the grid-level review)
|
|
@@ -10140,13 +10521,13 @@ const _restored=restoreSaved(); // bring back this brows
|
|
|
10140
10521
|
// the user has done anything. And it would be MEANINGLESS: v2 owns no per-plan members, so the member loops
|
|
10141
10522
|
// iterate nothing and sanitizeDims would re-validate v2 dim refs against v1's member index. A v2 document
|
|
10142
10523
|
// arrives server-validated (P7b validates it on PUT); it does not need v1's repair pass.
|
|
10143
|
-
if(
|
|
10524
|
+
if(!MODEL_V2){
|
|
10144
10525
|
// B4: normalize brace sub-objects across ALL plans — seed defaults on a brace, strip a stale m.brace off a
|
|
10145
10526
|
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
10146
10527
|
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
10147
10528
|
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
10148
10529
|
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))ensureMeta(_m); // normalize role/ends/col on EVERY sheet, not just the active one setPlan() does — model-wide detailing (Base/Shear plates) reads off-sheet members, so a beam with no authored `ends` must be normalized here or it reads as ineligible until its sheet is opened. Same order as the active plan (normBrace → ensureMeta).
|
|
10149
|
-
for(const _p of (C.plans||[]))sanitizeDims(_p); // F9:
|
|
10530
|
+
if(!MODEL_V2)for(const _p of (C.plans||[]))sanitizeDims(_p); // F9: v1 validates every plan here. v2 is already schema/reference-validated and is sanitized through each projected sheet, because canonical plans intentionally do not own `members`.
|
|
10150
10531
|
// Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
|
|
10151
10532
|
// not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
|
|
10152
10533
|
for(const _p of (C.plans||[]))sanitizePlanGrid(_p);
|
|
@@ -10154,6 +10535,10 @@ if(canWriteModel()){
|
|
|
10154
10535
|
setPlan(C.active==null?0:C.active);
|
|
10155
10536
|
invalidateConnectionDiagnostics(); // 2D asks the same server bake as 3D before it promises a connection will build
|
|
10156
10537
|
applyReadOnlyChrome(); // …after setPlan, so the controls it touches are the ones the render just wired
|
|
10538
|
+
// Called OUTSIDE applyReadOnlyChrome as well, because that one returns early unless the document is
|
|
10539
|
+
// read-only and this disable is a FORMAT rule: a live v2 model has nowhere to keep vis2d/vis3d either.
|
|
10540
|
+
// It self-gates on MODEL_V2, so the read-only path calling it too is a harmless second pass.
|
|
10541
|
+
roDisablePropLabelToggles();
|
|
10157
10542
|
// ONE WORD FOR BOTH MODES. This said "Grid restored ✓" on a read-only document, on the premise that the
|
|
10158
10543
|
// grid is the only thing such a draft can hold — which review disproved (see RO_DRAFT_KEYS: the overlay
|
|
10159
10544
|
// swatches, the confidence target and the palette are ungated too). A chip that names the grid over a
|