@floless/app 0.116.0 → 0.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +262 -31
- package/dist/schemas/steel.model.v2.schema.json +9 -4
- package/dist/schemas/steel.takeoff.v1.schema.json +7 -0
- 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 +473 -142
- 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){
|
|
@@ -3293,10 +3404,10 @@ function dominantAxis(a,p){const dx=p[0]-a[0],dy=p[1]-a[1];
|
|
|
3293
3404
|
// minimal validator can't express unit-length, so we sanitize at the load boundary — UI-set frames are clean.)
|
|
3294
3405
|
function sanitizeFrame(p){const f=p&&p.frame;if(!f)return;
|
|
3295
3406
|
const okPt=a=>Array.isArray(a)&&a.length>=2&&isFinite(a[0])&&isFinite(a[1]);
|
|
3296
|
-
if(!okPt(f.u)||!okPt(f.o)){p
|
|
3407
|
+
if(!okPt(f.u)||!okPt(f.o)){ModelCmd.setPlanFrame(p,null);return;}
|
|
3297
3408
|
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
|
|
3409
|
+
if(!(L>1e-6)){ModelCmd.setPlanFrame(p,null);return;} // zero-length → no usable axis → global
|
|
3410
|
+
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
3411
|
// --- dimension geometry (display space, y-down). `off` meaning by axis: x -> the dim-line Y;
|
|
3301
3412
|
// y -> the dim-line X; free -> signed perpendicular distance from the a->b baseline. ---
|
|
3302
3413
|
// `rot` (rad) = the dim's baked local frame; 0 = global (screen-aligned x/y, today's behavior). For x/y
|
|
@@ -3335,6 +3446,10 @@ function resolveDimGridAnchor(plan,gid,d){
|
|
|
3335
3446
|
if(gid.startsWith('gv:')){const l=(geo.v||[])[+gid.slice(3)];if(l){p1=[l.x,l.lo];p2=[l.x,l.hi];}}
|
|
3336
3447
|
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
3448
|
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;}}
|
|
3449
|
+
else{const axis=(plan.grid.axes||[]).find(row=>row&&String(row.id)===gid);
|
|
3450
|
+
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;
|
|
3451
|
+
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];}}
|
|
3452
|
+
else{const l=(geo.lines||[]).find(row=>String(row&&row.id)===gid);if(l){p1=l.a;p2=l.b;}}}
|
|
3338
3453
|
if(!p1)return null;
|
|
3339
3454
|
const rot=d.rot||0,lyv=q=>rotPt(q,-rot)[1];
|
|
3340
3455
|
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 +3471,18 @@ function reanchorDim(plan,d){let dropped=false;
|
|
|
3356
3471
|
// Pre-render pass over EVERY plan: keep magnetic dims glued to their members. O(dims), idempotent. One toast
|
|
3357
3472
|
// when any ref is dropped this pass (its member vanished) — naturally once per deletion.
|
|
3358
3473
|
function reanchorAllPlans(){let dropped=false;
|
|
3359
|
-
|
|
3474
|
+
if(MODEL_V2&&P){const dims=JSON.parse(JSON.stringify(P.dims||[])),before=JSON.stringify(dims);
|
|
3475
|
+
for(const d of dims)if(d&&(d.aRef||d.bRef)){if(reanchorDim({...P,dims},d))dropped=true;}
|
|
3476
|
+
if(JSON.stringify(dims)!==before)V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3477
|
+
}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
3478
|
if(dropped)toast('A dimension lost its link to a removed member or grid line');}
|
|
3361
3479
|
// Live path for the 2D member/endpoint drag, which updateLine()s WITHOUT a full render (:4135/:4141): reanchor
|
|
3362
3480
|
// only the active plan's magnetic dims + rebuild the dim overlay group, so dims track while the pointer is down.
|
|
3363
|
-
function refreshMagneticDims2D(){
|
|
3481
|
+
function refreshMagneticDims2D(){
|
|
3482
|
+
if(MODEL_V2){const dims=JSON.parse(JSON.stringify(P.dims||[])),before=JSON.stringify(dims);
|
|
3483
|
+
for(const d of dims)if(d&&(d.aRef||d.bRef))reanchorDim({...P,dims},d);
|
|
3484
|
+
if(JSON.stringify(dims)!==before)V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3485
|
+
}else for(const d of (P.dims||[]))if(d&&(d.aRef||d.bRef))reanchorDim(P,d);
|
|
3364
3486
|
const dg=svg.querySelector('g.dimsg');if(dg)dg.innerHTML=renderDimsInner();}
|
|
3365
3487
|
// F9 (QA 2026-07-16): the ref a hand-dragged dim anchor should carry after landing at pt — so magnetism
|
|
3366
3488
|
// SURVIVES handle moves instead of silently detaching. Drop on a member end/mid → {m,pt}; on a grid line
|
|
@@ -3437,7 +3559,7 @@ const _dEnd=v=>DIM_ENDS.includes(v),_dPlace=v=>v==='on'||v==='above',_dBg=v=>typ
|
|
|
3437
3559
|
// or an AI-authored contract can't put junk on the canvas.
|
|
3438
3560
|
function sanitizeDimStyle(){const s=(C&&C.dim_style&&typeof C.dim_style==='object'&&!Array.isArray(C.dim_style))?C.dim_style:{};
|
|
3439
3561
|
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(
|
|
3562
|
+
if(!MODEL_V2)sanitizeDimStyle(); // v2 arrives closed + validated; v1 needs repair
|
|
3441
3563
|
function dimStyle(d){const g=(C&&C.dim_style)||DIM_DEF;return {
|
|
3442
3564
|
end: (d&&_dEnd(d.end)) ?d.end :(_dEnd(g.end) ?g.end :DIM_DEF.end),
|
|
3443
3565
|
bg: (d&&_dBg(d.bg)) ?d.bg :(_dBg(g.bg) ?g.bg :DIM_DEF.bg),
|
|
@@ -3448,7 +3570,7 @@ const dimHasOverride=d=>!!d&&(_dEnd(d.end)||_dBg(d.bg)||_dPlace(d.place));
|
|
|
3448
3570
|
// is interpolated straight into SVG attributes, so a non-numeric anchor is attribute injection, not merely
|
|
3449
3571
|
// a broken drawing — drop any dim we can't trust, and keep only style fields with a known value.
|
|
3450
3572
|
function sanitizeDims(p){if(!p)return;
|
|
3451
|
-
if(!Array.isArray(p.dims)){p
|
|
3573
|
+
if(!Array.isArray(p.dims)){ModelCmd.setPlanDims(p,[]);return;}
|
|
3452
3574
|
// NOT the global isFinite: isFinite(null) and isFinite('') are both true, which would silently REPAIR a
|
|
3453
3575
|
// junk anchor into 0 rather than drop the dim. A numeric string is still accepted (a hand-edited file).
|
|
3454
3576
|
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 +3587,15 @@ function sanitizeDims(p){if(!p)return;
|
|
|
3465
3587
|
// a/b/mid. Grid ref {g}: kept when it has the synthetic-id shape and THIS plan has a grid (the resolver
|
|
3466
3588
|
// safe-freezes an index that no longer exists). Else dropped.
|
|
3467
3589
|
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'
|
|
3590
|
+
const okGRef=x=>{if(!(x&&typeof x==='object'&&typeof x.g==='string'&&p.grid))return false;
|
|
3591
|
+
if(!MODEL_V2)return /^g[vhl]:/.test(x.g);
|
|
3592
|
+
return [...(p.grid.axes||[]),...(p.grid.lines||[])].some(row=>row&&String(row.id)===x.g);};
|
|
3469
3593
|
const cpRef=x=>okGRef(x)?{g:x.g}:(okMRef(x)?{m:x.m,pt:x.pt}:null);
|
|
3470
3594
|
{const ar=cpRef(d.aRef),br=cpRef(d.bRef);if(ar)q.aRef=ar;if(br)q.bRef=br;}
|
|
3471
3595
|
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
3596
|
out.push(q);}
|
|
3473
3597
|
if(out.length!==p.dims.length)console.warn('discarding '+(p.dims.length-out.length)+' malformed dimension(s) on '+p.sheet);
|
|
3474
|
-
p
|
|
3598
|
+
ModelCmd.setPlanDims(p,out);}
|
|
3475
3599
|
// the two end markers, sized in 1/dz so they track the label's shrink. `dot` is a disc on the anchor;
|
|
3476
3600
|
// `tick` is the drafting oblique slash (the dim-line direction turned 45°); `arrow` puts its tip on the
|
|
3477
3601
|
// anchor and its tail inboard.
|
|
@@ -3579,7 +3703,10 @@ function gridOf(){const h=gridHost();return (h&&h.grid)||null;}
|
|
|
3579
3703
|
* is the re-space; `moveGridLineEnd` writes v1's index-keyed `ends_x`/`ends_y`, a vocabulary v2 replaced
|
|
3580
3704
|
* with an axis-id map; and `setGridLineEnds` moves a free line whose coordinates would be display px.
|
|
3581
3705
|
*/
|
|
3582
|
-
function gridDragAllowed(){
|
|
3706
|
+
function gridDragAllowed(kind='regular'){
|
|
3707
|
+
if(MODEL_V2&&kind!=='free'){
|
|
3708
|
+
toast('Re-spacing or trimming regular grid axes needs a reviewed model update because dimensions reference their stable ids.');
|
|
3709
|
+
return false;}
|
|
3583
3710
|
if(canWriteModel())return true;
|
|
3584
3711
|
console.warn('steel-editor: a grid drag was refused — this document is open read-only');
|
|
3585
3712
|
return false;}
|
|
@@ -3771,6 +3898,17 @@ function setGridMode(on){if(!C)return;gridMode=!!on;
|
|
|
3771
3898
|
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
3899
|
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
3900
|
panel();}
|
|
3901
|
+
function updatePlanDims(fn){
|
|
3902
|
+
if(!MODEL_V2){const before=JSON.stringify((P&&P.dims)||[]);fn(P.dims);return JSON.stringify(P.dims)!==before;}
|
|
3903
|
+
const dims=JSON.parse(JSON.stringify((P&&P.dims)||[])),before=JSON.stringify(dims);fn(dims);
|
|
3904
|
+
if(JSON.stringify(dims)===before)return false;
|
|
3905
|
+
V2_SESSION.patchPlan(P.sheet,{dims});
|
|
3906
|
+
return true;}
|
|
3907
|
+
function updatePlanDim(id,fn){return updatePlanDims(dims=>{const d=dims.find(row=>row&&row.id===id);if(d)fn(d);});}
|
|
3908
|
+
function deleteV2Selection(args){
|
|
3909
|
+
const effect=V2_SESSION.deleteSelection(P.sheet,args),n=effect&&effect.value&&effect.value.presentationOnly?effect.value.presentationOnly.length:0;
|
|
3910
|
+
if(n)toast(`${n} crossing column${n===1?' is':'s are'} derived from this sheet's cut and remain visible; no geometry was deleted.`);
|
|
3911
|
+
return effect;}
|
|
3774
3912
|
function renderDimStylePanel(p){
|
|
3775
3913
|
const g=C.dim_style,over=(P.dims||[]).filter(dimHasOverride).length;
|
|
3776
3914
|
p.innerHTML=`<span class=badge>Dimension style</span>
|
|
@@ -3786,12 +3924,12 @@ function renderDimStylePanel(p){
|
|
|
3786
3924
|
<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
3925
|
<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
3926
|
<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
|
|
3927
|
+
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
3928
|
p.querySelectorAll('button[data-gend]').forEach(b=>b.onclick=()=>setG(s=>{s.end=b.dataset.gend;}));
|
|
3791
3929
|
p.querySelectorAll('button[data-gplace]').forEach(b=>b.onclick=()=>setG(s=>{s.place=b.dataset.gplace;}));
|
|
3792
3930
|
document.getElementById('gDimBg').onchange=e=>setG(s=>{s.bg=e.target.checked;});
|
|
3793
3931
|
const cl=document.getElementById('dimClearOv');
|
|
3794
|
-
if(cl)cl.onclick=()=>{const n=over;edit(()=>{for(const d of
|
|
3932
|
+
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
3933
|
// The grid panel (armed-tool takeover, like the Dimension tool). Empty state = two explicit create
|
|
3796
3934
|
// buttons (nothing is created just by opening — UX review); fields commit on change (blur/Enter),
|
|
3797
3935
|
// one undo step each; keystrokes only update the live feedback line.
|
|
@@ -3804,10 +3942,10 @@ function renderGridPanel(p){
|
|
|
3804
3942
|
// The no-grid branch CREATES one, which mints the very axes the re-space refusal exists to protect —
|
|
3805
3943
|
// so on a read-only document all four of its actions are topological. Gated at the transaction as well
|
|
3806
3944
|
// (editGridTopology); this is the chrome saying so. (unit 5, P7d — Codex H9.)
|
|
3807
|
-
const roTopo=MODEL_RO?' disabled aria-describedby=gridRoWhy':'';
|
|
3945
|
+
const roTopo=(MODEL_V2||MODEL_RO)?' disabled aria-describedby=gridRoWhy':'';
|
|
3808
3946
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
3809
3947
|
<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>':''}
|
|
3948
|
+
${(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
3949
|
<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
3950
|
${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
3951
|
<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 +3961,8 @@ function renderGridPanel(p){
|
|
|
3823
3961
|
// control that simply vanishes reads as "this editor is broken", which is the opposite of the truth.
|
|
3824
3962
|
// aria-describedby, not data-tip alone: data-tip is hover-driven and never reaches a keyboard or
|
|
3825
3963
|
// screen-reader user (§8.5).
|
|
3826
|
-
const ro=MODEL_RO;
|
|
3827
|
-
const roTopo=
|
|
3964
|
+
const ro=MODEL_RO,topologyLocked=MODEL_V2||ro;
|
|
3965
|
+
const roTopo=topologyLocked?' disabled aria-describedby=gridRoWhy':'', roNo2d=ro?' disabled aria-describedby=gridNo2dWhy':'';
|
|
3828
3966
|
const og=(Array.isArray(g.origin)&&g.origin.length>=2&&isFinite(g.origin[0])&&isFinite(g.origin[1]))?g.origin:[0,0];
|
|
3829
3967
|
const normSp=v=>{const r=gc.parseSpacings(v);return r.err?String(v||''):gc.formatSpacings(r.offsets);};
|
|
3830
3968
|
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 +3973,7 @@ function renderGridPanel(p){
|
|
|
3835
3973
|
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
3974
|
p.innerHTML=`<span class=badge>Grid lines</span>
|
|
3837
3975
|
<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
|
-
${
|
|
3976
|
+
${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
3977
|
<label class=gck style="margin-top:10px"><input type=checkbox id=gShow ${gridOn()?'checked':''}><span>Show grid lines</span></label>
|
|
3840
3978
|
<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
3979
|
<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 +4089,16 @@ function snapEndMulti(ms,tA,tB){const pv=snapshot();let n=0,skipped=0;
|
|
|
3951
4089
|
for(const m of ms){
|
|
3952
4090
|
if(isBrace(m)){skipped++;continue;} // extend/trim never moves a brace work point (it must stay on the column ℄) — matches doSplit
|
|
3953
4091
|
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
|
|
4092
|
+
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
4093
|
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
4094
|
if(n){pushUndo(pv);render();sync3D();}return n;}
|
|
3957
4095
|
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)
|
|
4096
|
+
if(MODEL_V2){
|
|
4097
|
+
const link=V2Projection.projectionLink(m);let made=[];
|
|
4098
|
+
const ok=edit(()=>{made=V2_SESSION.splitMember(link.sheet,link.memberId,pt).value;selIds=new Set(made);selDimIds.clear();});
|
|
4099
|
+
if(ok!==false){geoMode=null;setGeo();}
|
|
4100
|
+
return;
|
|
4101
|
+
}
|
|
3958
4102
|
const pv=snapshot();ensureMeta(m);const base=JSON.parse(JSON.stringify(m));
|
|
3959
4103
|
// 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
4104
|
// would silently jump — detach every ref to m in its plan before geometry moves (safe-freeze; pv above still has
|
|
@@ -4024,7 +4168,7 @@ function isReversed(m){if(!m||!m.wp||m.wp.length<2)return false;
|
|
|
4024
4168
|
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
4169
|
function mergeCollinearJS(members){
|
|
4026
4170
|
const idx=members.map((_,i)=>i).filter(i=>_mElig(members[i]));
|
|
4027
|
-
const adj=new Map();for(const i of idx)adj.set(i,[]);
|
|
4171
|
+
const adj=new Map(),merges=[];for(const i of idx)adj.set(i,[]);
|
|
4028
4172
|
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
4173
|
if(s){adj.get(i).push({j,s});adj.get(j).push({j:i,s:{aEnd:s.bEnd,bEnd:s.aEnd}});}}
|
|
4030
4174
|
const seen=new Set(),runByAnchor=new Map(),merged=new Set();let mergedAway=0;
|
|
@@ -4040,11 +4184,11 @@ function mergeCollinearJS(members){
|
|
|
4040
4184
|
m.wp=[[a[0],a[1]],[b[0],b[1]]];
|
|
4041
4185
|
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
4186
|
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:[]};
|
|
4187
|
+
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);}
|
|
4188
|
+
if(mergedAway===0)return{members,mergedAway:0,runs:0,affectedIds:[],merges:[]};
|
|
4045
4189
|
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
4190
|
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};}
|
|
4191
|
+
return{members:out,mergedAway,runs:runByAnchor.size,affectedIds,merges};}
|
|
4048
4192
|
const svg=document.getElementById('svg');
|
|
4049
4193
|
function toSvg(e){const p=svg.createSVGPoint();p.x=e.clientX;p.y=e.clientY;return p.matrixTransform(svg.getScreenCTM().inverse());}
|
|
4050
4194
|
// --- zoom + pan ---
|
|
@@ -4318,11 +4462,45 @@ function renderPanelV2(p){
|
|
|
4318
4462
|
// draft of this copy predated.
|
|
4319
4463
|
p.innerHTML='<span class=badge>Read-only</span>'+
|
|
4320
4464
|
'<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
|
-
|
|
4465
|
+
'<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>';}
|
|
4466
|
+
function syncV2SelectionNotice(p){
|
|
4467
|
+
if(!MODEL_V2||!p||!selIds.size)return;
|
|
4468
|
+
p.querySelectorAll('.v2-selection-notice,.v2-elevation-warning').forEach(el=>el.remove());
|
|
4469
|
+
const ids=[...selIds].filter(id=>!!(C.members||[]).find(m=>m&&m.id===id));
|
|
4470
|
+
if(!ids.length)return;
|
|
4471
|
+
const other=[];
|
|
4472
|
+
for(const plan of C.plans||[]){
|
|
4473
|
+
if(plan.sheet===P.sheet)continue;
|
|
4474
|
+
if(ids.some(id=>V2Projection.memberSheets(C,id).includes(plan.sheet)))other.push(plan.sheet);
|
|
4475
|
+
}
|
|
4476
|
+
const anchor=p.querySelector(':scope > h3,:scope > .badge');
|
|
4477
|
+
let after=anchor;
|
|
4478
|
+
if(other.length){
|
|
4479
|
+
const n=document.createElement('div');n.className='hint v2-selection-notice';n.setAttribute('role','status');n.setAttribute('aria-live','polite');n.style.marginTop='8px';
|
|
4480
|
+
n.textContent=(ids.length===1?'Also on ':'Selected members also appear on ')+[...new Set(other)].join(', ')+'.';
|
|
4481
|
+
if(after)after.after(n);else p.prepend(n);after=n;
|
|
4482
|
+
}
|
|
4483
|
+
const selected=(C.members||[]).filter(m=>ids.includes(m.id));
|
|
4484
|
+
const unknown=selected.reduce((n,m)=>n+(!Number.isFinite(m?.from?.z?.known)?1:0)+(!Number.isFinite(m?.to?.z?.known)?1:0),0);
|
|
4485
|
+
if(unknown){
|
|
4486
|
+
const row=document.createElement('div');row.className='drow v2-elevation-warning';row.setAttribute('role','status');row.setAttribute('aria-live','polite');row.style.marginTop='8px';
|
|
4487
|
+
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.`;
|
|
4488
|
+
row.appendChild(msg);if(after)after.after(row);else p.prepend(row);
|
|
4489
|
+
}
|
|
4490
|
+
const projected=selArr();
|
|
4491
|
+
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');};
|
|
4492
|
+
if(projected.length===1){
|
|
4493
|
+
const m=projected[0],canonical=selected[0];
|
|
4494
|
+
if(m&&canonical&&m.role==='column'){mark('bos',!Number.isFinite(canonical.from?.z?.known));mark('tosC',!Number.isFinite(canonical.to?.z?.known));}
|
|
4495
|
+
else if(m&&canonical){mark('tosA',!Number.isFinite(canonical.from?.z?.known));mark('tosB',!Number.isFinite(canonical.to?.z?.known));}
|
|
4496
|
+
}
|
|
4497
|
+
}
|
|
4322
4498
|
function panel(){
|
|
4323
4499
|
const p=document.getElementById('panel');
|
|
4500
|
+
if(MODEL_V2)queueMicrotask(()=>syncV2SelectionNotice(p));
|
|
4324
4501
|
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
4502
|
if(gridMode){renderGridPanel(p);return;}
|
|
4503
|
+
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
4504
|
if(MODEL_RO){renderPanelV2(p);return;} // …after the grid panel, which is the one panel a v2 document does reach
|
|
4327
4505
|
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
4506
|
if(dimStyleMode){renderDimStylePanel(p);return;}
|
|
@@ -4374,6 +4552,18 @@ function panel(){
|
|
|
4374
4552
|
const nOver=dsel.filter(dimHasOverride).length; // >0 ⇒ offer the way back to the model-global default
|
|
4375
4553
|
const linked=dsel.filter(d=>d.aRef||d.bRef); // F9: dims carrying a magnetic link (dormant or live)
|
|
4376
4554
|
const pinV=linked.length?agg(linked,d=>d.pin!==false):null; // true | false | VARIES across the linked ones
|
|
4555
|
+
if(MODEL_V2){
|
|
4556
|
+
p.innerHTML=`<span class=badge>Dimension${selDimIds.size>1?'s · '+selDimIds.size:''}</span>
|
|
4557
|
+
${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>`:''}
|
|
4558
|
+
${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>`:''}
|
|
4559
|
+
<div class=hint style="margin-top:10px">This model keeps dimension styling in the shared Dimension style defaults.</div>
|
|
4560
|
+
<div class=sect style="margin-top:12px">Edit</div>
|
|
4561
|
+
<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>
|
|
4562
|
+
<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>`;
|
|
4563
|
+
{const pk=document.getElementById('dimPinT');if(pk)pk.onclick=()=>{const turnOn=pinV!==true;
|
|
4564
|
+
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;}});});};}
|
|
4565
|
+
document.getElementById('dimSplitB').onclick=()=>toggleDimSplit();
|
|
4566
|
+
return;}
|
|
4377
4567
|
p.innerHTML=`<span class=badge>Dimension${selDimIds.size>1?'s · '+selDimIds.size:''}</span>
|
|
4378
4568
|
${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
4569
|
${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 +4578,7 @@ function panel(){
|
|
|
4388
4578
|
<div class=sect style="margin-top:12px">Edit</div>
|
|
4389
4579
|
<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
4580
|
<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
|
|
4581
|
+
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
4582
|
p.querySelectorAll('button[data-dend]').forEach(b=>b.onclick=()=>setAll(d=>{d.end=b.dataset.dend;}));
|
|
4393
4583
|
p.querySelectorAll('button[data-dplace]').forEach(b=>b.onclick=()=>setAll(d=>{d.place=b.dataset.dplace;}));
|
|
4394
4584
|
const cb=document.getElementById('dimBg');cb.indeterminate=(bgV===null);cb.onchange=e=>setAll(d=>{d.bg=e.target.checked;});
|
|
@@ -4654,9 +4844,9 @@ function panel(){
|
|
|
4654
4844
|
<div class="row f"><button class=danger id=del>Delete selected (${arr.length})</button></div>`;
|
|
4655
4845
|
wireTypeFilter(p);
|
|
4656
4846
|
// 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()){
|
|
4847
|
+
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
4848
|
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
|
|
4849
|
+
document.getElementById('verifyBtn').onclick=()=>edit(()=>{const v=!allVerified;for(const m of selArr())ModelCmd.patchMember(m,{verified:v});});
|
|
4660
4850
|
{const _gel=document.getElementById('geoEL');if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};}
|
|
4661
4851
|
{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
4852
|
{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 +4854,14 @@ function panel(){
|
|
|
4664
4854
|
const _qm=document.getElementById('qdPtMid');if(_qm)_qm.onclick=()=>setQd('mid');
|
|
4665
4855
|
const _qb=document.getElementById('qdPtB');if(_qb)_qb.onclick=()=>setQd('b');
|
|
4666
4856
|
const _qp=document.getElementById('qdPlace');if(_qp)_qp.onclick=()=>quickDimSpacing(qdAnchorPt);}
|
|
4667
|
-
document.getElementById('del').onclick=()=>edit(()=>{
|
|
4668
|
-
|
|
4857
|
+
document.getElementById('del').onclick=()=>edit(()=>{if(MODEL_V2)deleteV2Selection({memberIds:selIds,dimIds:selDimIds});
|
|
4858
|
+
else for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));
|
|
4859
|
+
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)
|
|
4860
|
+
{const sp=v=>edit(()=>{for(const m of selArr())if(m.role!=='column')ModelCmd.patchMember(m,{position:v});});
|
|
4669
4861
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
4670
4862
|
if(_pt)_pt.onclick=()=>sp('top');if(_pm)_pm.onclick=()=>sp('middle');if(_pb)_pb.onclick=()=>sp('bottom');}
|
|
4671
4863
|
// 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
|
|
4864
|
+
{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
4865
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>{if(e.target.value.trim()==='')return;setRot(e.target.value);};
|
|
4674
4866
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
4675
4867
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
@@ -4679,10 +4871,10 @@ function panel(){
|
|
|
4679
4871
|
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
4872
|
if(allCol){const cs=cols.map(m=>m.col);
|
|
4681
4873
|
{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
|
|
4874
|
+
wMTos('tosC',cs);wMText('ntC',cs,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtC',cs,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));}
|
|
4683
4875
|
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
|
|
4876
|
+
wMTos('tosA',s0);wMText('ntA',s0,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtA',s0,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));
|
|
4877
|
+
wMTos('tosB',s1);wMText('ntB',s1,(o,v)=>ModelCmd.patchEnd(o,{note:v}));wMText('dtB',s1,(o,v)=>ModelCmd.patchEnd(o,{detail:v}));
|
|
4686
4878
|
// Braces are skipped: copying end0's TOS onto end1 would FLATTEN a brace's slope (and re-derive its
|
|
4687
4879
|
// lower/higher arrowheads to the tie default) — silently, from a mixed box-select. (code review)
|
|
4688
4880
|
// edit() pushes undo unconditionally, so an all-brace selection must not enter it (Codex round-4).
|
|
@@ -4895,14 +5087,14 @@ function panel(){
|
|
|
4895
5087
|
<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
5088
|
<div class="row f"><button class=danger id=del>Delete member</button></div>`;
|
|
4897
5089
|
wireTypeFilter(p);
|
|
4898
|
-
document.getElementById('pf').onchange=e=>edit(()=>{const v=e.target.value.toUpperCase().replace(/ /g,'');m
|
|
5090
|
+
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
5091
|
{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
5092
|
document.getElementById('pickProf').onclick=()=>{if(picking&&pickKind==='profile'){picking=false;}else{picking=true;pickKind='profile';pickEnd=null;}render();};
|
|
4901
5093
|
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
5094
|
{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
5095
|
document.querySelectorAll('.msW').forEach(b=>b.onclick=()=>setMemberLineStyle(memberTypeOf(m),'weight',b.dataset.w)); // F5: per member-type line weight
|
|
4904
5096
|
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(()=>{
|
|
5097
|
+
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
5098
|
const _gel=document.getElementById('geoEL'),_gsp=document.getElementById('geoSplit');
|
|
4907
5099
|
if(_gel)_gel.onclick=()=>{geoMode=(geoMode==='el'?null:'el');setGeo();render();};
|
|
4908
5100
|
if(_gsp)_gsp.onclick=()=>{geoMode=(geoMode==='split'?null:'split');setGeo();render();};
|
|
@@ -4915,19 +5107,19 @@ function panel(){
|
|
|
4915
5107
|
const _bb=document.getElementById('brBelow');if(_bb)_bb.onclick=()=>setBr(b=>b.floor='below');
|
|
4916
5108
|
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
5109
|
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
|
|
5110
|
+
const _bsw=document.getElementById('brSwap');if(_bsw)_bsw.onclick=()=>edit(()=>{normBrace(m);ModelCmd.patchMemberBrace(m,{lowerEnd:1-braceLowerEnd(m)});});}
|
|
5111
|
+
{const setPos=v=>edit(()=>{ModelCmd.patchMember(m,{position:v});}); // profile placement on the reference line; persists + re-extrudes the 3D
|
|
4920
5112
|
const _pt=document.getElementById('posTop'),_pm=document.getElementById('posMid'),_pb=document.getElementById('posBot');
|
|
4921
5113
|
if(_pt)_pt.onclick=()=>setPos('top');if(_pm)_pm.onclick=()=>setPos('middle');if(_pb)_pb.onclick=()=>setPos('bottom');}
|
|
4922
5114
|
// Rotation — spin the section about the reference line. Normalised to (-360,360); 0 = as drawn.
|
|
4923
5115
|
// 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
|
|
5116
|
+
{const setRot=v=>{let r=Number(String(v).replace(',','.'));if(!isFinite(r))return;r=r%360;edit(()=>{ModelCmd.patchMember(m,{rot:r});});};
|
|
4925
5117
|
const _ri=document.getElementById('detRotZ');if(_ri)_ri.onchange=e=>setRot(e.target.value);
|
|
4926
5118
|
const chip=(id,val)=>{const b=document.getElementById(id);if(b)b.onclick=()=>setRot(val);};
|
|
4927
5119
|
chip('rot0',0);chip('rot90',90);chip('rot180',180);chip('rot270',270);}
|
|
4928
5120
|
const wireTos=(id,o)=>{const ck=document.getElementById(id+'_ck');if(ck)ck.onchange=e=>edit(()=>{ModelCmd.setTosDefault(o,e.target.checked,defaultTOS);});
|
|
4929
5121
|
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
|
|
5122
|
+
const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{ModelCmd.patchEnd(o,{detail:e.target.value.trim()});});
|
|
4931
5123
|
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
5124
|
const op=document.getElementById(id+'_open');if(op)op.onclick=()=>openPreview(o.detail);};
|
|
4933
5125
|
// The detail→connection actions under the field. `which` identifies the end so the resolver can reach
|
|
@@ -4954,7 +5146,7 @@ function panel(){
|
|
|
4954
5146
|
const retry=document.getElementById(id+'_retry');
|
|
4955
5147
|
if(retry)retry.onclick=()=>{invalidateConnectionDiagnostics(true);panel();};
|
|
4956
5148
|
};
|
|
4957
|
-
const wireConn=(id,o)=>{const i=document.getElementById(id);if(!i)return;i.onchange=e=>edit(()=>{const v=(e.target.value||'').trim();o
|
|
5149
|
+
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
5150
|
if(col){
|
|
4959
5151
|
document.getElementById('bos').onchange=e=>edit(()=>{ModelCmd.setBos(m.col,parseLen(e.target.value));});
|
|
4960
5152
|
wireTos('tosC',m.col);
|
|
@@ -5021,8 +5213,8 @@ function panel(){
|
|
|
5021
5213
|
if(Pt)_dpCommit(i,Pt);};};
|
|
5022
5214
|
const wireEnd=i=>_dpAxes.forEach((ax,a)=>{dpWire('dpG_'+i+'_'+a,i,a,false);if(_dpLocal)dpWire('dpL_'+i+'_'+a,i,a,true);});
|
|
5023
5215
|
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
|
|
5216
|
+
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
|
|
5217
|
+
{const vb=document.getElementById('verifyBtn');if(vb)vb.onclick=()=>edit(()=>{ModelCmd.patchMember(m,{verified:!m.verified});});}
|
|
5026
5218
|
}
|
|
5027
5219
|
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
5220
|
const nm=ensureMeta({id,profile:prof,wp:[sg.a.slice(),sg.b.slice()],angle:sg.o,rfi:(_wt(prof)==null)});
|
|
@@ -5236,7 +5428,58 @@ function _len3dFt(m,ppf,dTos){
|
|
|
5236
5428
|
else{z0=eff(m.ends&&m.ends[0]); z1=eff(m.ends&&m.ends[1]);} // start TOS → end TOS
|
|
5237
5429
|
const dz=((z1==null?0:z1)-(z0==null?0:z0))/12; // vertical rise, feet
|
|
5238
5430
|
return Math.hypot(dx,dy,dz);}
|
|
5239
|
-
|
|
5431
|
+
/*
|
|
5432
|
+
* A member's length comes from the CANONICAL model whenever there is one, never from its plan projection.
|
|
5433
|
+
*
|
|
5434
|
+
* Two traps met here, and both produced a confidently wrong number rather than an error:
|
|
5435
|
+
*
|
|
5436
|
+
* 1. THE PREDICATE IS THE FORMAT, NOT WRITABILITY. This shipped as `MODEL_RO ? …`, which was
|
|
5437
|
+
* indistinguishable from MODEL_V2 while v2 was read-only. The moment MODEL_V2_LIVE turned on, MODEL_RO
|
|
5438
|
+
* became permanently false and every v2 length fell back to the v1 plan path.
|
|
5439
|
+
* 2. ON v2 THE CALLER HANDS US A PROJECTED MEMBER. `selArr()`/`byId()` resolve through
|
|
5440
|
+
* `v2ProjectedMember`, which returns the plan-space twin (it carries `wp`, not `from`/`to`) because the
|
|
5441
|
+
* 2D editor draws and edits in plan px. `_len3dFt` measures that `wp` against the ACTIVE plan's
|
|
5442
|
+
* pt_per_ft, so the answer is only right when a plan's pt_per_ft happens to agree with its
|
|
5443
|
+
* datum→control2 calibration. Where they disagree it silently reports the calibration span instead —
|
|
5444
|
+
* 65 ft for a 7,620 mm (25 ft) beam. Resolving back to the canonical member removes that dependence
|
|
5445
|
+
* entirely: world mm is the truth, and the projection is a drawing artifact.
|
|
5446
|
+
*
|
|
5447
|
+
* The fallback still runs for a member with no canonical twin — v1 documents, and the synthetic
|
|
5448
|
+
* `{role,wp}` objects the self-checks below measure — so neither of those changes behaviour.
|
|
5449
|
+
*/
|
|
5450
|
+
/*
|
|
5451
|
+
* id -> canonical member, memoized, because `_lenFt` is called once per member inside several
|
|
5452
|
+
* per-repaint loops (stats(), the BOM and RFI list builders, refreshSelLen3d) and a linear scan there is
|
|
5453
|
+
* O(N**2) on a real 200+ member model. Both reviewers raised it.
|
|
5454
|
+
*
|
|
5455
|
+
* WHAT ACTUALLY INVALIDATES IT is array identity, and that is sufficient today for a reason worth
|
|
5456
|
+
* writing down: every v2 mutation goes through `V2Commands.transact`, which does `clone(model)` -> mutate
|
|
5457
|
+
* the DRAFT -> `replaceRoot(model, draft)`. So although the individual mutators call
|
|
5458
|
+
* `doc.members.push(...)`, the model's `members` is a FRESH array after every commit — the in-place push
|
|
5459
|
+
* happens on a draft that is then swapped in wholesale, and an identity check cannot miss it.
|
|
5460
|
+
*
|
|
5461
|
+
* The other two guards are defence-in-depth for a future writer that does NOT go through transact, and
|
|
5462
|
+
* are honestly unkillable by any test today (MEASURED: removing both leaves the suite green, because no
|
|
5463
|
+
* reachable path mutates `members` in place on the live model). They are kept because a stale entry does
|
|
5464
|
+
* not read as slow — it reads as a MISS, which sends `_lenFt` down the v1 plan fallback and produces a
|
|
5465
|
+
* confidently wrong length, silently recreating the exact defect this memo sits inside:
|
|
5466
|
+
* 1. `v2InvalidateMemberIndex()` from the command session's afterCommit.
|
|
5467
|
+
* 2. The array length, checked alongside identity on every lookup.
|
|
5468
|
+
*/
|
|
5469
|
+
let _v2MemberIndex=null,_v2MemberIndexFor=null,_v2MemberIndexLen=-1;
|
|
5470
|
+
function v2InvalidateMemberIndex(){_v2MemberIndex=null;_v2MemberIndexFor=null;_v2MemberIndexLen=-1;}
|
|
5471
|
+
function v2CanonicalMember(id){
|
|
5472
|
+
if(id==null)return undefined;
|
|
5473
|
+
const members=modelMembersV2();
|
|
5474
|
+
if(_v2MemberIndex===null||_v2MemberIndexFor!==members||_v2MemberIndexLen!==members.length){
|
|
5475
|
+
_v2MemberIndex=new Map();
|
|
5476
|
+
for(const m of members)if(m&&m.id!=null)_v2MemberIndex.set(m.id,m);
|
|
5477
|
+
_v2MemberIndexFor=members;_v2MemberIndexLen=members.length;
|
|
5478
|
+
}
|
|
5479
|
+
return _v2MemberIndex.get(id);}
|
|
5480
|
+
function _lenFt(m){
|
|
5481
|
+
if(MODEL_V2&&m){const canon=v2CanonicalMember(m.id);if(canon)return modelReadsV2().lengthFt(canon);}
|
|
5482
|
+
return _len3dFt(m,FT,defaultTOS);}
|
|
5240
5483
|
const PROP_DEFS=[
|
|
5241
5484
|
{key:'id', label:'Mark', get:m=>m.id, fmt:v=>v==null?'':String(v)},
|
|
5242
5485
|
{key:'profile', label:'Profile', get:m=>m.profile, fmt:v=>v==null?'':String(v)},
|
|
@@ -5268,7 +5511,7 @@ function sanitizePropLabels(x){const o=(x&&typeof x==='object'&&!Array.isArray(x
|
|
|
5268
5511
|
// …all three skipped for v2 — see the repair-pass note at the top of main(). These two are the pair the
|
|
5269
5512
|
// schema check caught: prop_labels gains vis2d/vis3d, and views gains `projection` while LOSING each
|
|
5270
5513
|
// generated view's `axisId`.
|
|
5271
|
-
if(
|
|
5514
|
+
if(!MODEL_V2){
|
|
5272
5515
|
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
5516
|
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
5517
|
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 +5525,7 @@ function propLabelMembers(){const pl=C.prop_labels;if(!pl||!pl.props.length)retu
|
|
|
5282
5525
|
// plan-local PIXEL coordinates into the ACTIVE sheet's SVG, so an off-sheet member would be painted in
|
|
5283
5526
|
// the wrong place on any multi-sheet project. A repair briefly widened this to allMembers() to stop a
|
|
5284
5527
|
// v2 TypeError and introduced exactly that regression; the v2 half is what needed the model-wide list.
|
|
5285
|
-
let base=
|
|
5528
|
+
let base=P.members;
|
|
5286
5529
|
if(pl.selected_only){const ids=new Set(pl.ids||[]);base=base.filter(m=>ids.has(m.id));}
|
|
5287
5530
|
return base.filter(m=>propLabelLinesFor(m).length>0);}
|
|
5288
5531
|
// one popup row's aggregate across the current selection: a shared value, "Varies", or N/A (disabled)
|
|
@@ -5550,7 +5793,7 @@ function dimAnchor(){return dimChainPrev?dimChainPrev.point:(dimDraft&&!dimDraft
|
|
|
5550
5793
|
function dimClick(e){const s=dimSnapAt(e,dimAnchor());
|
|
5551
5794
|
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
5795
|
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(()=>{
|
|
5796
|
+
edit(()=>{ModelCmd.addPlanDims(P,[{id:'d'+Date.now()+'_'+(dimSeq++),a,b,axis,off,rot}]);});
|
|
5554
5797
|
dimChainPrev={point:b,axis,off,rot};dimPrev(e);return;} // keep going from b; Esc/Enter ends the chain
|
|
5555
5798
|
if(!dimDraft){dimDraft={a:[s.x,s.y],b:null,axis:dimAxis};dimPrev(e);return;} // click 1 → first anchor
|
|
5556
5799
|
if(!dimDraft.b){dimDraft.b=[s.x,s.y];dimPrev(e);return;} // click 2 → second anchor (value locks)
|
|
@@ -5558,7 +5801,7 @@ function dimClick(e){const s=dimSnapAt(e,dimAnchor());
|
|
|
5558
5801
|
const rot=axis==='free'?0:frameRot(); // bake the active frame so a later Reset/redefine never moves this dim (free is frame-independent)
|
|
5559
5802
|
const off=dimOffFromPointer(dimDraft.a,dimDraft.b,axis,s.raw,rot); // click 3 → offset/side from raw pointer
|
|
5560
5803
|
const a=dimDraft.a,b=dimDraft.b;
|
|
5561
|
-
edit(()=>{
|
|
5804
|
+
edit(()=>{ModelCmd.addPlanDims(P,[{id:'d'+Date.now()+'_'+(dimSeq++),a,b,axis,off,rot}]);}); // undoable; render() clears the preview
|
|
5562
5805
|
if(dimChain)dimChainPrev={point:b,axis,off,rot}; // chain mode → continue from b along this same offset line + baked frame
|
|
5563
5806
|
dimDraft=null;}
|
|
5564
5807
|
function dimPrevClear(){const g=document.getElementById('dimPrevG');if(g)g.remove();snapClear();}
|
|
@@ -5637,18 +5880,18 @@ function dimSplitAt(m){
|
|
|
5637
5880
|
if(t>EPS&&t<1-EPS){ // INTERIOR → split into two (both halves keep d.off → offset line stays continuous, no kink)
|
|
5638
5881
|
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
5882
|
const id1='d'+Date.now()+'_'+(dimSeq++),id2='d'+Date.now()+'_'+(dimSeq++);
|
|
5640
|
-
|
|
5883
|
+
ModelCmd.setPlanDims(P,P.dims.filter(x=>x.id!==d.id));
|
|
5641
5884
|
const sty=dimStyleOverrides(d); // both halves inherit the split dim's style
|
|
5642
5885
|
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
5886
|
const pn=d.pin===false?{pin:false}:{};
|
|
5644
|
-
|
|
5887
|
+
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
5888
|
selDimIds.delete(d.id);selDimIds.add(id1);selDimIds.add(id2);
|
|
5646
5889
|
}else{ // BEYOND an end → add a continuing dimension from that end to the clicked point (same axis/off/rot)
|
|
5647
5890
|
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
5891
|
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
5892
|
const id='d'+Date.now()+'_'+(dimSeq++);
|
|
5650
5893
|
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
|
-
|
|
5894
|
+
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
5895
|
selDimIds.add(id);
|
|
5653
5896
|
}
|
|
5654
5897
|
pushUndo(pv);render();sync3D();
|
|
@@ -5708,7 +5951,7 @@ function quickDimSpacing(pt,pick){
|
|
|
5708
5951
|
if(Math.abs(lx(B.p)-lx(A.p))<1)continue; // coincident projection → no spacing to show
|
|
5709
5952
|
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
5953
|
const id='d'+Date.now()+'_'+(dimSeq++);made.push(id);
|
|
5711
|
-
|
|
5954
|
+
ModelCmd.addPlanDims(P,[{id,a:A.p.slice(),b:B.p.slice(),axis:'x',off,rot,aRef:rf(A),bRef:rf(B)}]);}
|
|
5712
5955
|
if(!made.length){toast('Those members share a spacing point — nothing to dimension');return;}
|
|
5713
5956
|
pushUndo(pv);selIds.clear();selGridIds.clear();selDimIds=new Set(made);dimsVisible=true;updDimToggle();render();sync3D();
|
|
5714
5957
|
toast('Placed '+made.length+' spacing dimension'+(made.length===1?'':'s')+' — they follow their members and grids');
|
|
@@ -5759,7 +6002,7 @@ function buildDimEditPop(){
|
|
|
5759
6002
|
val.onkeydown=e=>{e.stopPropagation();if(e.key==='Enter'){e.preventDefault();dimEditCommit();}else if(e.key==='Escape'){e.preventDefault();closeDimEdit();}};
|
|
5760
6003
|
val.oninput=()=>val.classList.remove('bad');
|
|
5761
6004
|
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(()=>{
|
|
6005
|
+
edit(()=>{updatePlanDim(dimEdit.id,dd=>{if(dd.aRef||dd.bRef){if(dimEdit.pin)delete dd.pin;else dd.pin=false;}});});}
|
|
5763
6006
|
else{const other=k==='l'?'r':'l';if(dimEdit[k]&&!dimEdit[other])return; // keep at least one end driven
|
|
5764
6007
|
dimEdit[k]=!dimEdit[k];try{localStorage.setItem('steel:dimEdit:ends:v1',JSON.stringify({l:dimEdit.l,r:dimEdit.r}));}catch(_){}}
|
|
5765
6008
|
buildDimEditPop();const v2=document.getElementById('dimEditVal');if(v2)v2.focus();};
|
|
@@ -5797,14 +6040,16 @@ function dimEditCommit(){
|
|
|
5797
6040
|
if(aRef.pt==='mid'||bRef.pt==='mid'){toast('One end is this member’s midpoint — unpin 📌 to edit the dimension only');return;}}
|
|
5798
6041
|
const mem=id=>(P.members||[]).find(x=>x&&x.id===id),addv=(p,v)=>[p[0]+v[0],p[1]+v[1]];
|
|
5799
6042
|
edit(()=>{
|
|
5800
|
-
|
|
6043
|
+
const target=MODEL_V2?JSON.parse(JSON.stringify(d)):d;
|
|
6044
|
+
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
6045
|
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
6046
|
const doEnd=(driven,ref,mv,rawKey)=>{if(!driven)return;
|
|
5803
6047
|
if(dimEdit.pin&&ref){const m=mem(ref.m);if(m&&Array.isArray(m.wp)&&m.wp.length>=2){
|
|
5804
6048
|
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
6049
|
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{
|
|
6050
|
+
else{target[rawKey]=addv(target[rawKey],mv);}}; // pin OFF, or an unref'd end → move the dim's own coord
|
|
5807
6051
|
doEnd(effA>0,aRef,mvA,'a');doEnd(effB>0,bRef,mvB,'b');
|
|
6052
|
+
if(MODEL_V2)updatePlanDim(target.id,row=>{for(const key of Object.keys(row))delete row[key];Object.assign(row,target);});
|
|
5808
6053
|
});
|
|
5809
6054
|
if(redirected)toast('The grid-linked end stays put — the value moved the other end instead');
|
|
5810
6055
|
closeDimEdit();
|
|
@@ -6034,6 +6279,14 @@ function openLevelModal(tool){ // works from 2D and 3D — the commit is plan-
|
|
|
6034
6279
|
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
6280
|
if(!sel.length){toast('Selection is empty — nothing to '+(tool==='move'?'move':'copy'));return;}
|
|
6036
6281
|
if(!T)return;
|
|
6282
|
+
if(MODEL_V2){
|
|
6283
|
+
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;})
|
|
6284
|
+
.filter(row=>row&&row.sourceSheet!==T.sheet);
|
|
6285
|
+
if(!entries.length){toast('Selection is already on '+T.sheet);return;}
|
|
6286
|
+
let effect=null;
|
|
6287
|
+
const ok=edit(()=>{effect=V2_SESSION.moveOrCopyToSheet(T.sheet,entries,tool==='copy');if(tool==='copy')selIds=new Set(effect.value||[]);});
|
|
6288
|
+
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':''));
|
|
6289
|
+
return;}
|
|
6037
6290
|
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
6291
|
const dstDef=(T.default_tos!=null?T.default_tos:198);
|
|
6039
6292
|
const pv=snapshot(); // whole-model pre-mutation → one global-stack entry undoes the source removals AND the target adds
|
|
@@ -6060,14 +6313,14 @@ function csClick(e){const p=csSnapAt(e);
|
|
|
6060
6313
|
if(L<1e-6){toast('Pick two distinct points for the X axis');return;} // degenerate → stay armed
|
|
6061
6314
|
const o=csDraft.slice(),u=[dx/L,dy/L];
|
|
6062
6315
|
csaxisMode=false;setCsMode();
|
|
6063
|
-
edit(()=>{P
|
|
6316
|
+
edit(()=>{ModelCmd.setPlanFrame(P,{o,u});}); // undoable + persisted; render() draws the glyph
|
|
6064
6317
|
toast('Local axes set ('+Math.round(Math.atan2(u[1],u[0])*180/Math.PI)+'°) — ortho & X/Y dims now follow them');}
|
|
6065
6318
|
function csPrevClear(){const g=document.getElementById('csPrevG');if(g)g.remove();snapClear();}
|
|
6066
6319
|
function csPrev(e){if(!csaxisMode){csPrevClear();return;}
|
|
6067
6320
|
const p=csSnapAt(e);(!e.altKey)?snapMark(p[0],p[1]):snapClear();
|
|
6068
6321
|
let g=document.getElementById('csPrevG');if(!g){g=document.createElementNS(SVGNS,'g');g.id='csPrevG';g.setAttribute('pointer-events','none');svg.appendChild(g);}
|
|
6069
6322
|
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
|
|
6323
|
+
function resetFrame(){if(!P.frame)return;edit(()=>{ModelCmd.setPlanFrame(P,null);});toast('Axes reset to global');}
|
|
6071
6324
|
// One coordinate-axes glyph → SVG string. `dir` = any vector along local-X (normalized here). Screen-constant
|
|
6072
6325
|
// size (÷zoom), re-synced on zoom by updateBadges. Tekla axis colours: X = red, Y = green, origin = Z blue
|
|
6073
6326
|
// (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 +6377,9 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
6124
6377
|
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
6378
|
{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
6379
|
const gel=gb||ghit;
|
|
6127
|
-
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&gridOf()
|
|
6128
|
-
const free=gel.dataset.gl!=null
|
|
6380
|
+
if(gel&&mode==='sel'&&!geoMode&&!dimSplitMode&&!picking&&gridOf()){
|
|
6381
|
+
const free=gel.dataset.gl!=null;if(!gridDragAllowed(free?'free':'regular'))return;
|
|
6382
|
+
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
6383
|
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
6384
|
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
6385
|
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 +6424,12 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
|
|
|
6170
6424
|
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
6425
|
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
6426
|
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
|
|
6427
|
+
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
6428
|
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
6429
|
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
6430
|
return;}
|
|
6177
6431
|
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
|
|
6432
|
+
if(picking&&pickKind==='detail'&&pickEnd){const o=pickEnd;picking=false;pickEnd=null;edit(()=>{ModelCmd.patchEnd(o,{detail:det});});}return;}
|
|
6179
6433
|
{const cg=t.closest('g.cohot');if(cg){const sheet=cg.dataset.coSheet,prev=cg.dataset.coPrev; // Workstream B smart jump
|
|
6180
6434
|
const idx=sheet?C.plans.findIndex(p=>p.sheet&&p.sheet.toUpperCase()===sheet.toUpperCase()):-1;
|
|
6181
6435
|
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 +6468,7 @@ svg.addEventListener('pointermove',e=>{
|
|
|
6214
6468
|
if(!drag)return;const p=toSvg(e);
|
|
6215
6469
|
if(drag.type==='gridfree'){const dxc=p.x-drag.startPt[0],dyc=p.y-drag.startPt[1];
|
|
6216
6470
|
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;
|
|
6471
|
+
const _dg=gridOf();const line=_dg&&_dg.lines&&_dg.lines[drag.gi];if(!line||!gridDragAllowed('free'))return;
|
|
6218
6472
|
let a=drag.origA.slice(),b=drag.origB.slice();
|
|
6219
6473
|
if(drag.end!=null){const target=drag.end===0?a:b;let x=target[0]+dxc,y=target[1]+dyc;
|
|
6220
6474
|
if(!e.altKey){const sn=snap(x,y);x=sn.x;y=sn.y;sn.hit?snapMark(x,y):snapClear();}else snapClear();
|
|
@@ -6269,9 +6523,9 @@ svg.addEventListener('pointermove',e=>{
|
|
|
6269
6523
|
const mcG=MC(); // built inside the grip branch, so the far more common ungripped dim drag pays nothing
|
|
6270
6524
|
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
6525
|
else mcG.setEndpoint(m,gp.pt==='a'?0:1,[x,y]);}}
|
|
6272
|
-
if(drag.end===0)
|
|
6526
|
+
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
6527
|
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){
|
|
6528
|
+
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
6529
|
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
6530
|
drag.window=(e.clientX>=drag.sx0); // Tekla: drag L→R = window (enclose); R→L = crossing (touch)
|
|
6277
6531
|
drag.rect.classList.toggle('window',drag.window); // solid rect = window, dashed = crossing (visual affordance)
|
|
@@ -6342,8 +6596,9 @@ svg.addEventListener('pointerup',()=>{if(!drag)return;snapClear();epPrevClear();
|
|
|
6342
6596
|
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
6597
|
if(d&&drag.pre&&snapshot()!==drag.pre){const rk=drag.end===0?'aRef':'bRef',had=!!d[rk];
|
|
6344
6598
|
const nr=dimRefAtPoint(P,drag.end===0?d.a:d.b,d);
|
|
6345
|
-
if(nr)
|
|
6346
|
-
|
|
6599
|
+
updatePlanDim(d.id,row=>{if(nr)row[rk]=nr;else delete row[rk];});
|
|
6600
|
+
if(nr)toast((nr.g?'Dimension end linked to grid line':'Dimension end linked to member')+(d.pin===false?' — unpinned':''));
|
|
6601
|
+
else if(had)toast('Dimension end unlinked');}}
|
|
6347
6602
|
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
6603
|
if(drag.pre&&snapshot()!==drag.pre)pushUndo(drag.pre);
|
|
6349
6604
|
if(!anyToolActive())snapOnlyClear2d(); // a select-mode drag WAS the operation → the override was single-shot
|
|
@@ -6535,10 +6790,24 @@ function roLock(el){
|
|
|
6535
6790
|
* built lazily by build3DLegend() long after boot; disabling it once at boot would miss it.
|
|
6536
6791
|
*/
|
|
6537
6792
|
function roDisablePropLabelToggles(){
|
|
6538
|
-
|
|
6793
|
+
// MODEL_V2, not MODEL_RO: the flag has no home in v2's closed `prop_labels` whether or not the document
|
|
6794
|
+
// is writable, so a live v2 model must disable these two exactly as a read-only one did. Leaving them
|
|
6795
|
+
// enabled over a refused write is the silent no-op this whole mode exists to avoid.
|
|
6796
|
+
if(!MODEL_V2)return;
|
|
6539
6797
|
for(const id of ['plToggleB','m3dPropLabels']){
|
|
6540
6798
|
const el=document.getElementById(id);
|
|
6541
|
-
if(el)
|
|
6799
|
+
if(!el)continue;
|
|
6800
|
+
el.disabled=true;
|
|
6801
|
+
// REPORT OFF, not just unavailable. `m3dPropLabels` is static markup carrying `checked`, and nothing
|
|
6802
|
+
// syncs it until the user opens the View menu — so without this the first frame (and the closed menu's
|
|
6803
|
+
// accessibility state) says "checked, and you cannot turn it off" for a flag plVis answers false to.
|
|
6804
|
+
// That is the same lie the read-only repair removed from the 2D rows, which stay honest because
|
|
6805
|
+
// updPlToggle derives both `on` and aria-checked from plVis. (Found by Codex reviewing this fix.)
|
|
6806
|
+
if(el.type==='checkbox')el.checked=plVis(id==='m3dPropLabels');
|
|
6807
|
+
// The ribbon only renders under `body.model-ro`, so pointing a LIVE v2 control at it would name an
|
|
6808
|
+
// element that is not on the page — and its text says the whole model is read-only, which is no longer
|
|
6809
|
+
// true here. Describe it only where the ribbon actually exists.
|
|
6810
|
+
if(MODEL_RO)el.setAttribute('aria-describedby','roRibbon');else el.removeAttribute('aria-describedby');
|
|
6542
6811
|
}
|
|
6543
6812
|
}
|
|
6544
6813
|
/** The Views tab's header write actions, disabled on each render (the tab rebuilds its own buttons). */
|
|
@@ -6562,8 +6831,10 @@ document.getElementById('revB').onclick=()=>{const ids=reversedBeams(); // bea
|
|
|
6562
6831
|
toast(ids.length+' reversed beam'+(ids.length>1?'s':'')+' selected — press P to swap direction');}; // select reversed → review → P swaps them
|
|
6563
6832
|
document.getElementById('mrgB').onclick=()=>{const r=mergeCollinearJS(P.members); // conservative; result is undoable (Ctrl+Z)
|
|
6564
6833
|
if(!r.mergedAway){toast('Nothing to merge');return;}
|
|
6565
|
-
edit(()=>{
|
|
6566
|
-
ModelCmd.
|
|
6834
|
+
edit(()=>{if(MODEL_V2)V2_SESSION.mergeMemberGroups(P.sheet,r.merges);
|
|
6835
|
+
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.
|
|
6836
|
+
ModelCmd.setPlanMembers(P,r.members);}
|
|
6837
|
+
selIds=new Set();selDimIds.clear();});
|
|
6567
6838
|
toast('Merged '+r.mergedAway+' segment'+(r.mergedAway===1?'':'s')+' into '+r.runs+' member'+(r.runs===1?'':'s'));};
|
|
6568
6839
|
document.getElementById('undoB').onclick=doUndo;
|
|
6569
6840
|
document.getElementById('redoB').onclick=doRedo;
|
|
@@ -6633,9 +6904,15 @@ addEventListener('keydown',e=>{
|
|
|
6633
6904
|
const hadReg=[...selGridIds].some(id=>id.startsWith('gv:')||id.startsWith('gh:')); // regular (spacing-generated) lines can't be individually deleted
|
|
6634
6905
|
const willMutate=selDimIds.size||selIds.size||freeToDelete.length;
|
|
6635
6906
|
if(willMutate)edit(()=>{
|
|
6636
|
-
if(
|
|
6907
|
+
if(MODEL_V2){
|
|
6908
|
+
const jids=selJointIds(),memberIds=new Set([...selIds].filter(id=>!!byId(id)));
|
|
6909
|
+
deleteV2Selection({memberIds,dimIds:selDimIds,jointIds:jids,gridLineIds:new Set(freeToDelete.map(line=>String(line.id)))});
|
|
6910
|
+
selIds.clear();selDimIds.clear();selGridIds.clear();return;
|
|
6911
|
+
}
|
|
6912
|
+
if(selDimIds.size){ModelCmd.setPlanDims(P,P.dims.filter(d=>!selDimIds.has(d.id)));selDimIds.clear();}
|
|
6637
6913
|
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));
|
|
6914
|
+
for(const pl of C.plans)pl.members=(pl.members||[]).filter(m=>!selIds.has(m.id));
|
|
6915
|
+
selIds.clear();} // selection spans sheets → remove from every plane, not just the active one
|
|
6639
6916
|
if(freeToDelete.length)ModelCmd.removeGridLines(gridOf(),glLids);
|
|
6640
6917
|
selGridIds.clear();});
|
|
6641
6918
|
else{selGridIds.clear();render();} // only regular grid lines were selected → nothing to delete (no phantom undo step); repaint to drop the highlight
|
|
@@ -7077,9 +7354,16 @@ async function sendSelectionToHost(host,ids,hostPid){
|
|
|
7077
7354
|
*
|
|
7078
7355
|
* This is the same line drawn everywhere else in this mode: display state stays live where v2's schema
|
|
7079
7356
|
* allows it (`dim_overlays` is open, and its toggles are untouched), and is refused where v2 closed it.
|
|
7357
|
+
*
|
|
7358
|
+
* BOTH GATES ASK THE FORMAT, NOT WRITABILITY. They shipped as `canWriteModel()` / `MODEL_RO`, which were
|
|
7359
|
+
* indistinguishable from MODEL_V2 while v2 was read-only. Activating v2 (MODEL_V2_LIVE) made MODEL_RO
|
|
7360
|
+
* permanently false and re-opened both: the click handlers began writing `vis2d`/`vis3d` onto a closed
|
|
7361
|
+
* `prop_labels` — corrupting the document so the NEXT save is refused for a toggle the user flicked — and
|
|
7362
|
+
* `plVis` began answering from those flags, which is the TypeError path the paragraph above describes.
|
|
7363
|
+
* Making v2 writable does not give v2 a place to keep this flag, nor a label derivation that could use it.
|
|
7080
7364
|
*/
|
|
7081
|
-
function canWritePropLabelVis(){return canWriteModel();}
|
|
7082
|
-
function plVis(is3d){if(
|
|
7365
|
+
function canWritePropLabelVis(){return canWriteModel()&&!MODEL_V2;}
|
|
7366
|
+
function plVis(is3d){if(MODEL_V2)return false;const pl=C&&C.prop_labels;return !!(pl&&(is3d?pl.vis3d:pl.vis2d));}
|
|
7083
7367
|
/** 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
7368
|
function modelMembersV2(){return (C&&Array.isArray(C.members))?C.members:[];}
|
|
7085
7369
|
/** Refuse a read the v2 arm cannot answer truthfully. THROWS — never a default, never a silent empty. */
|
|
@@ -7149,7 +7433,7 @@ function modelReadsV2(){
|
|
|
7149
7433
|
const view3dApi={
|
|
7150
7434
|
// The model read half — see modelReadsV1 / modelReadsV2 above. Built ONCE per view init; the arm is
|
|
7151
7435
|
// decided by MODEL_RO, which boot() pinned from the validated type and nothing changes afterwards.
|
|
7152
|
-
model:()=>
|
|
7436
|
+
model:()=>MODEL_V2?modelReadsV2():modelReadsV1(),
|
|
7153
7437
|
onFrame3dChange:()=>{updCS();if(typeof csSyncF3d==='function')csSyncF3d();
|
|
7154
7438
|
// F14: the Definition-points local (X′/Y′/Z′) row reads the 3D frame — refresh the inspector when the
|
|
7155
7439
|
// frame changes outside a render() path (notably Reset-to-global, which only fires this callback). Skip
|
|
@@ -7194,21 +7478,21 @@ const view3dApi={
|
|
|
7194
7478
|
// so for v2 both of these answer the same list, truthfully, rather than the silent [] that reading
|
|
7195
7479
|
// `C.plans[].members` would give (§8.3). The view only ever takes ids and hands the records back to
|
|
7196
7480
|
// `model().geometryOf`, so a v2 record travelling through here is read by nothing that assumes `wp`.
|
|
7197
|
-
getMembers:()=>
|
|
7481
|
+
getMembers:()=>MODEL_V2?modelMembersV2():P.members, // v1: active-sheet members (wp); v2 3D reads canonical world members.
|
|
7198
7482
|
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
7483
|
// ── The three reads §8.3 names as plausible-but-FALSE for v2. Each is a v1 PLAN concept, and each has a
|
|
7200
7484
|
// wrong answer that looks right: an empty member list, a substituted default T.O.S that silently
|
|
7201
7485
|
// relocates members, and a world-mm grid read through v1's display-space assumptions. The 3D view no
|
|
7202
7486
|
// longer asks any of them — every one moved behind `model()` above — so these throws are TRIPWIRES: if
|
|
7203
7487
|
// one fires, a v1-shaped read has crept back in, and it says so instead of answering.
|
|
7204
|
-
membersByPlan:()=>
|
|
7488
|
+
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
7489
|
snapEnabled:()=>snapEnabled, // the persistent running-snaps (⋯ menu → Snapping) — 3D honours the same on/off set
|
|
7206
7490
|
snap3dFree:()=>snap3dFree, // SNAP-bar "3D snapping" mode — ON: free 3D snap; OFF: 3D placement snap constrained to the working plane
|
|
7207
7491
|
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
7492
|
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
7493
|
canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
|
|
7210
|
-
ptPerFt:()=>
|
|
7211
|
-
defaultTosMm:()=>
|
|
7494
|
+
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),
|
|
7495
|
+
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
7496
|
geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
|
|
7213
7497
|
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
7498
|
dragMoveEnabled:()=>dragMoveOn, // the 3D view gates its plain member-drag on this
|
|
@@ -7236,7 +7520,7 @@ const view3dApi={
|
|
|
7236
7520
|
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
7521
|
onSplit:(id,wp)=>{const m=byId(id);if(m){doSplit(m,wp);sync3D();}}, // 3D Split → cut at the clicked point on the member
|
|
7238
7522
|
getDims3d:()=>C.dims3d||[],
|
|
7239
|
-
getGrid:()=>
|
|
7523
|
+
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
7524
|
getDimOverlays:()=>C.dim_overlays||{}, // the legend DIMENSIONS toggles {bolt_pitch,edge_clearance,cope_size} — the 3D view derives + filters overlays from this
|
|
7241
7525
|
// 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
7526
|
// May the VIEW arm a tool that writes? It cannot infer this from a disabled button — the dim tool also
|
|
@@ -7302,7 +7586,7 @@ const view3dApi={
|
|
|
7302
7586
|
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
7587
|
const mfNote=/(^|[^A-Z])MF/i.test(addProfile||'')?'moment':''; // a moment-frame profile keeps the auto note ensureMeta gives 2D-drawn members
|
|
7304
7588
|
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
|
|
7589
|
+
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
7590
|
m.rfi=(_wt(addProfile)==null);MC().addMembers(P,[m]);
|
|
7307
7591
|
if(addProfile&&!profs.includes(addProfile)){profs.push(addProfile);profs.sort();}
|
|
7308
7592
|
selIds=new Set([id]);});
|
|
@@ -7566,11 +7850,14 @@ function applyMemberType(ms,k){
|
|
|
7566
7850
|
let dropped=0,unsupported=0;
|
|
7567
7851
|
for(const m of ms){if(!m)continue;
|
|
7568
7852
|
const wasBrace=isBrace(m);
|
|
7569
|
-
|
|
7853
|
+
if(MODEL_V2){
|
|
7854
|
+
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;
|
|
7855
|
+
ModelCmd.patchMember(m,{role,memberType:type,brace});
|
|
7856
|
+
}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
7857
|
// Becoming a brace ORPHANS any connection hanging off this member: the bake (steel-joints.expandJoints)
|
|
7571
7858
|
// refuses a brace `main`, so the joint would linger in C.joints, never render, and vanish from 3D with no
|
|
7572
7859
|
// explanation. Purge it here and say so, rather than leave a recipe that can never bake. (silent-failure review)
|
|
7573
|
-
if(!wasBrace&&
|
|
7860
|
+
if(!wasBrace&&type==='brace'&&Array.isArray(C.joints)&&C.joints.length){
|
|
7574
7861
|
const before=C.joints.length;
|
|
7575
7862
|
C.joints=C.joints.filter(j=>!(j&&j.main===m.id));
|
|
7576
7863
|
dropped+=before-C.joints.length;
|
|
@@ -7754,9 +8041,16 @@ function magnifierSvg(){const NS='http://www.w3.org/2000/svg',svg=document.creat
|
|
|
7754
8041
|
// ── Save current view + New from direction ───────────────────────────────────────────────────────────────────
|
|
7755
8042
|
// Capture the FULL A1 snapshot from the live editor. name defaults to "View N"; a fresh id + order-at-top.
|
|
7756
8043
|
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};
|
|
8044
|
+
const view={v:1,id:'v'+Math.random().toString(36).slice(2,9),name:name||('View '+((C.views||[]).length+1)),order:0,
|
|
8045
|
+
camera:V.cameraState?V.cameraState():null,mode:V.mode?V.mode():'solid',
|
|
8046
|
+
clips:V.clipState?V.clipState():null,objects:V.objectsPaneState?V.objectsPaneState():null};
|
|
8047
|
+
// The ROOT `projection` key is v1's shape and v2's `view` is closed against it — saving one corrupts the
|
|
8048
|
+
// document, so the next save is refused for a view the user just pressed Save on. v2 keeps the projection
|
|
8049
|
+
// in `camera.proj`, which `cameraState()` already writes and `setCameraState()` already restores; the
|
|
8050
|
+
// root key is only activateView's fallback for a view that has NO camera, which capture never produces.
|
|
8051
|
+
// (While v2 was read-only this was unreachable because the whole Views library was; P3 made it writable.)
|
|
8052
|
+
if(!MODEL_V2)view.projection=V.projection?V.projection():'persp';
|
|
8053
|
+
return view;}
|
|
7760
8054
|
// Push a captured view to the TOP (order 0; bump the rest), then persist + re-render + inline-rename it.
|
|
7761
8055
|
function addView(v,{rename=true}={}){if(!canWriteViews())return;if(!Array.isArray(C.views))C.views=[];
|
|
7762
8056
|
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 +8096,12 @@ function startViewRename(v,row){const nameEl=row.querySelector('.vwname');if(!na
|
|
|
7802
8096
|
inp.addEventListener('blur',()=>finish(true));
|
|
7803
8097
|
}
|
|
7804
8098
|
// ── 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;
|
|
8099
|
+
function updateViewToCurrent(v){if(!canWriteViews())return;const snap=captureView(v.name);snap.id=v.id;snap.order=v.order;v.camera=snap.camera;
|
|
8100
|
+
// DELETE rather than assign on v2: `snap.projection` is absent there, and `v.projection=undefined` still
|
|
8101
|
+
// leaves the forbidden key on the object for the client-side validator to reject. It also scrubs the key
|
|
8102
|
+
// off a view that arrived carrying it from a v1 migration.
|
|
8103
|
+
if(MODEL_V2)delete v.projection;else v.projection=snap.projection;
|
|
8104
|
+
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
8105
|
function duplicateView(v){
|
|
7807
8106
|
if(!canWriteViews())return;
|
|
7808
8107
|
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 +8214,6 @@ function openNewFromDirectionMenu(anchorEl){closeViewRowMenu();
|
|
|
7915
8214
|
}
|
|
7916
8215
|
|
|
7917
8216
|
// ── 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
8217
|
function viewGenCurrentSources(){if(!viewGenState)return [];return viewGenState.tab==='levels'?viewGenState.sources.levels:[...viewGenState.sources.x,...viewGenState.sources.y];}
|
|
7920
8218
|
function viewGenKey(s){return s.kind+':'+s.index;}
|
|
7921
8219
|
function closeViewGenerator(){const modal=document.getElementById('viewGenModal');if(modal)modal.style.display='none';viewGenState=null;
|
|
@@ -7960,7 +8258,11 @@ function createGeneratedViews(){if(!canWriteViews())return;if(!viewGenState)retu
|
|
|
7960
8258
|
const selected=viewGenCurrentSources().filter(s=>viewGenState.selected.has(viewGenKey(s))),made=[],skipped=[],taken=new Set((C.views||[]).map(v=>v.name));
|
|
7961
8259
|
const freshName=base=>{let name=base,i=2;while(taken.has(name))name=base+' '+i++;taken.add(name);return name;};
|
|
7962
8260
|
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;}
|
|
8261
|
+
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
|
|
8262
|
+
// `snap.camera.proj` already says so, so v2 loses nothing by omitting it.
|
|
8263
|
+
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};
|
|
8264
|
+
if(!MODEL_V2)view.projection='ortho';
|
|
8265
|
+
made.push(view);}
|
|
7964
8266
|
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
8267
|
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
8268
|
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 +9200,7 @@ function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||isBrace(beam
|
|
|
8898
9200
|
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
9201
|
const end=beam.ends[endIdx];if(!end)return false;
|
|
8900
9202
|
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
|
|
9203
|
+
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
9204
|
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
9205
|
function spJointOf(beamId,endIdx){return (C.joints||[]).find(j=>j&&j.kind==='shear-plate'&&j.main===beamId&&j.at==='end'+endIdx);}
|
|
8904
9206
|
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 +9427,7 @@ function openRFI(focusId){focusId=(typeof focusId==='string')?focusId:null; //
|
|
|
9125
9427
|
<td><button class=ghost data-loc="${esc(m.id)}">Locate</button></td></tr>`;}).join('')+'</tbody></table>')
|
|
9126
9428
|
:'<div class=hint>No unresolved members — every member has a resolved AISC size. ✓</div>';
|
|
9127
9429
|
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
|
|
9430
|
+
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
9431
|
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
9432
|
document.getElementById('rfiModal').style.display='flex';
|
|
9131
9433
|
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 +9450,6 @@ const BANDPILL={verified:'background:#166534;color:#86efac',high:'background:#14
|
|
|
9148
9450
|
// actually exists in the AISC catalogue (SHAPES), so a regex-matching but non-standard string (e.g. W99X999)
|
|
9149
9451
|
// stays unresolved (RFI) instead of being trusted for a bogus name-encoded weight.
|
|
9150
9452
|
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
9453
|
function _wt(profile){if(!profile)return null;
|
|
9153
9454
|
if(WT&&profile in WT&&WT[profile]!=null)return WT[profile];
|
|
9154
9455
|
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 +9797,7 @@ function jointAtEnd(memberId,which){const at=jointAtFor(which);
|
|
|
9496
9797
|
// Every (member, end) in the MODEL that carries a callout or a library reference — the population the
|
|
9497
9798
|
// bulk action walks. Model-wide, like joints and the selection.
|
|
9498
9799
|
function detailEndTargets(){const out=[];
|
|
9499
|
-
for(const m of
|
|
9800
|
+
for(const m of legacyAllMembers()){if(!m)continue;
|
|
9500
9801
|
if(m.role==='column'){if(m.col&&(m.col.detail||m.col.conn))out.push({m,which:'col'});continue;}
|
|
9501
9802
|
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
9803
|
for(const w of [0,1]){const e=(m.ends||[])[w];if(e&&(e.detail||e.conn))out.push({m,which:w});}}
|
|
@@ -9752,7 +10053,7 @@ function captureDetailRecipe(m,which,opt,type){
|
|
|
9752
10053
|
// so this is for the reader, not for correctness.
|
|
9753
10054
|
sched.sort((a,b)=>schedRank(a&&a.match)-schedRank(b&&b.match));
|
|
9754
10055
|
rec.schedule=sched;}
|
|
9755
|
-
e
|
|
10056
|
+
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
10057
|
});
|
|
9757
10058
|
return {rowId:rowId,droppedSchedule:droppedSchedule};}
|
|
9758
10059
|
const comboPop=document.createElement('div');comboPop.id='comboPop';document.body.appendChild(comboPop);
|
|
@@ -9810,13 +10111,37 @@ function setPlanV2(i){
|
|
|
9810
10111
|
refresh3DGrid();
|
|
9811
10112
|
syncPlanSwitcher(i);}
|
|
9812
10113
|
// --- multi-plan: switch between all steel plan views ---
|
|
9813
|
-
function setPlan(i){
|
|
9814
|
-
|
|
9815
|
-
if(
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
10114
|
+
function setPlan(i){
|
|
10115
|
+
const canonical=C.plans[i];
|
|
10116
|
+
if(MODEL_V2&&!canonical){
|
|
10117
|
+
NO_PLAN_VIEW=true;C.active=0;P={sheet:'',members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:0};
|
|
10118
|
+
setPlanV2(0);return;
|
|
10119
|
+
}
|
|
10120
|
+
if(MODEL_V2&&canonical&&canonical.viewKind!=='plan'){
|
|
10121
|
+
const kind=canonical.viewKind||'unknown',current=C.plans[C.active];
|
|
10122
|
+
if(!current||current.viewKind!=='plan'){
|
|
10123
|
+
NO_PLAN_VIEW=true;C.active=i;
|
|
10124
|
+
P={...structuredClone(canonical),members:[],segments:[],dims:[],details:[],callouts:[],tos_callouts:[],grid:null,default_tos:Number.isFinite(canonical.elevation_in)?canonical.elevation_in:0};
|
|
10125
|
+
setPlanV2(i);return;
|
|
10126
|
+
}
|
|
10127
|
+
toast(kind==='unknown'
|
|
10128
|
+
?`FloLess couldn’t determine ${canonical.sheet||'this sheet'}’s view type, so it can’t safely map it into 2D.`
|
|
10129
|
+
:`${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'}.`);
|
|
10130
|
+
syncPlanSwitcher(C.active);return;}
|
|
10131
|
+
C.active=i;
|
|
10132
|
+
if(MODEL_V2){
|
|
10133
|
+
NO_PLAN_VIEW=false;
|
|
10134
|
+
V2_PROJECTION=v2ProjectionForSheet(canonical.sheet);
|
|
10135
|
+
P=DEV_MODE?ModelCmd.deepFreezeProjection(V2_PROJECTION.plan):V2_PROJECTION.plan;
|
|
10136
|
+
}else P=C.plans[i];
|
|
10137
|
+
if(MODEL_RO){setPlanV2(i);return;}
|
|
10138
|
+
if(!MODEL_V2){
|
|
10139
|
+
if(!Array.isArray(P.members))P.members=[];
|
|
10140
|
+
if(!Array.isArray(P.segments))P.segments=[];
|
|
10141
|
+
sanitizeDims(P); // …and its dimensions: drop any whose geometry isn't numeric (they render straight into SVG attributes)
|
|
10142
|
+
sanitizeFrame(P); // tolerate a hand-edited/AI-written frame: normalize or drop to global
|
|
10143
|
+
sanitizePlanGrid(P); // finite origin + canonical labels/free lines; spacing strings report their own errors inline
|
|
10144
|
+
}
|
|
9820
10145
|
// clip = the drawing's display-space crop. A contract may ship WITHOUT a raster/clip (a shared or
|
|
9821
10146
|
// committed contract strips raster_b64 for confidentiality), so fall back to the members' bounding
|
|
9822
10147
|
// box (padded) → the editor renders members on a blank canvas instead of crashing on P.clip[0].
|
|
@@ -9828,12 +10153,12 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
9828
10153
|
else clip=[0,0,1000,1000];}
|
|
9829
10154
|
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
10155
|
svg.setAttribute('viewBox',`${X0} ${Y0} ${X1-X0} ${Y1-Y0}`);
|
|
9831
|
-
P.members.forEach(ensureMeta);
|
|
10156
|
+
if(!MODEL_V2)P.members.forEach(ensureMeta);
|
|
9832
10157
|
// Auto-dedupe coincident members on first load of each plan — the read can bind one segment to
|
|
9833
10158
|
// two labels (a W-size + its MF mark) or overlap tile reads, producing stacked duplicates that
|
|
9834
10159
|
// double-count the BOM. Collapse them automatically (keep the most-resolved copy), undoable, once
|
|
9835
10160
|
// per plan. The "Duplicates" button stays for any made while editing.
|
|
9836
|
-
if(!P.deduped){P.deduped=true;const red=new Set(redundantDups());
|
|
10161
|
+
if(!MODEL_V2&&!P.deduped){P.deduped=true;const red=new Set(redundantDups());
|
|
9837
10162
|
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
10163
|
setTimeout(()=>toast('Auto-removed '+red.size+' duplicate member'+(red.size>1?'s':'')),60);}}
|
|
9839
10164
|
profs=[...new Set([...P.members.map(m=>m.profile), ...Object.keys(WT)])].sort();
|
|
@@ -9847,9 +10172,11 @@ function setPlan(i){C.active=i;P=C.plans[i];
|
|
|
9847
10172
|
csaxisMode=false;setCsMode(); // set-axes tool resets per plan; P.frame itself is per-plan data (persisted), so it stays
|
|
9848
10173
|
snapOnlyClear2d();closeSnapMenu(); // a snap override never outlives its plan (different geometry)
|
|
9849
10174
|
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
|
-
|
|
10175
|
+
defaultTOS=(!MODEL_V2&&P.default_tos!=null?P.default_tos:198);
|
|
10176
|
+
if(!MODEL_V2){
|
|
10177
|
+
ModelCmd.setPlanDefaultTos(P,defaultTOS); // v2 retired default links; every endpoint elevation is explicit or unknown
|
|
10178
|
+
if(!P.autofilled){autofillTOS();P.autofilled=true;}
|
|
10179
|
+
}
|
|
9853
10180
|
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
10181
|
setMode();render();fitToWindow();
|
|
9855
10182
|
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 +10467,13 @@ const _restored=restoreSaved(); // bring back this brows
|
|
|
10140
10467
|
// the user has done anything. And it would be MEANINGLESS: v2 owns no per-plan members, so the member loops
|
|
10141
10468
|
// iterate nothing and sanitizeDims would re-validate v2 dim refs against v1's member index. A v2 document
|
|
10142
10469
|
// arrives server-validated (P7b validates it on PUT); it does not need v1's repair pass.
|
|
10143
|
-
if(
|
|
10470
|
+
if(!MODEL_V2){
|
|
10144
10471
|
// B4: normalize brace sub-objects across ALL plans — seed defaults on a brace, strip a stale m.brace off a
|
|
10145
10472
|
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
10146
10473
|
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
10147
10474
|
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
10148
10475
|
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:
|
|
10476
|
+
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
10477
|
// Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
|
|
10151
10478
|
// not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
|
|
10152
10479
|
for(const _p of (C.plans||[]))sanitizePlanGrid(_p);
|
|
@@ -10154,6 +10481,10 @@ if(canWriteModel()){
|
|
|
10154
10481
|
setPlan(C.active==null?0:C.active);
|
|
10155
10482
|
invalidateConnectionDiagnostics(); // 2D asks the same server bake as 3D before it promises a connection will build
|
|
10156
10483
|
applyReadOnlyChrome(); // …after setPlan, so the controls it touches are the ones the render just wired
|
|
10484
|
+
// Called OUTSIDE applyReadOnlyChrome as well, because that one returns early unless the document is
|
|
10485
|
+
// read-only and this disable is a FORMAT rule: a live v2 model has nowhere to keep vis2d/vis3d either.
|
|
10486
|
+
// It self-gates on MODEL_V2, so the read-only path calling it too is a harmless second pass.
|
|
10487
|
+
roDisablePropLabelToggles();
|
|
10157
10488
|
// ONE WORD FOR BOTH MODES. This said "Grid restored ✓" on a read-only document, on the premise that the
|
|
10158
10489
|
// grid is the only thing such a draft can hold — which review disproved (see RO_DRAFT_KEYS: the overlay
|
|
10159
10490
|
// swatches, the confidence target and the palette are ungated too). A chip that names the grid over a
|