@floless/app 0.137.4 → 0.138.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 +47618 -26808
- package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
- package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
- package/dist/schemas/steel.model.v2.schema.json +218 -27
- package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
- package/dist/skills/floless-app-rfi/SKILL.md +410 -0
- package/dist/skills/floless-app-routines/SKILL.md +7 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
- package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
- package/dist/templates/floless-workspace-knowledge.flo +20 -4
- package/dist/templates/steel-model.flo +27 -15
- package/dist/web/app.css +559 -131
- package/dist/web/app.js +216 -54
- package/dist/web/aware.js +982 -128
- package/dist/web/checkpoint-standard.js +218 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +237 -5
- package/dist/web/commands-steel.js +172 -47
- package/dist/web/connection-review-client.js +2 -2
- package/dist/web/display-units.js +243 -0
- package/dist/web/grid-core.js +470 -56
- package/dist/web/grid-display.js +344 -0
- package/dist/web/index.html +106 -66
- package/dist/web/instructor-reporter.js +5 -0
- package/dist/web/instructor.js +175 -33
- package/dist/web/json-schema-subset.js +145 -25
- package/dist/web/steel-3d-core.js +124 -140
- package/dist/web/steel-3d-view.js +352 -100
- package/dist/web/steel-catalog-picker.js +98 -15
- package/dist/web/steel-detail-refs.js +1 -1
- package/dist/web/steel-editor.html +6458 -915
- package/dist/web/steel-filter.html +404 -57
- package/dist/web/steel-model-adapter.js +1 -1
- package/dist/web/steel-model-commands.js +71 -64
- package/dist/web/steel-model-v2-client-validation.js +10 -3
- package/dist/web/steel-model-v2-commands.js +268 -76
- package/dist/web/steel-model-v2-projection.js +18 -17
- package/dist/web/steel-plan-transform.js +13 -13
- package/dist/web/steel-plan-view-id.js +1 -7
- package/dist/web/steel-read-confidence.js +454 -5
- package/dist/web/steel-units.js +17 -3
- package/dist/web/steel-view-generation.js +21 -7
- package/dist/web/workspaces.js +2178 -497
- package/package.json +4 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { planViewId } from './steel-plan-view-id.js';
|
|
14
14
|
import { sheetPxToWorld, worldToSheetPx } from './steel-plan-transform.js';
|
|
15
15
|
import { memberPresence, projectionLink } from './steel-model-v2-projection.js';
|
|
16
|
-
import {
|
|
16
|
+
import { gridLabelPatch, parseSpacings } from './grid-core.js';
|
|
17
17
|
import { IN_TO_MM as IN_MM } from './steel-units.js';
|
|
18
18
|
import {
|
|
19
19
|
basisFromAxes, effectiveDepthPosition, effectiveWidthPosition, outlineFor, partFrame,
|
|
@@ -31,7 +31,30 @@ const known = (z, label) => {
|
|
|
31
31
|
if (!isKnown(z)) throw new V2CommandError('elevation-unknown', `${label} has unknown elevation; this command cannot invent it`);
|
|
32
32
|
return z.known;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
/* A world-millimetre elevation, snapped to nine decimals so a float tail never reaches the document.
|
|
35
|
+
It used to take INCHES and multiply; the editor is metric now, so the multiplication is gone and the
|
|
36
|
+
name says which unit it wants. `IN_MM` still has one caller below — section dims that genuinely
|
|
37
|
+
declare `units: 'in'` — and that is a different question from an elevation. */
|
|
38
|
+
const elevMm = (mm) => ({ known: Math.round(Number(mm) * 1e9) / 1e9 });
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Carry a PLACED-but-unproven mark across a move (#1155).
|
|
42
|
+
*
|
|
43
|
+
* An endpoint the server placed because the drawings did not settle it is `{known, assumed, why,
|
|
44
|
+
* checked}`. Every writer below produced a bare `{known}`, so nudging such a member — even sideways,
|
|
45
|
+
* where `moveWorkPoints` rewrites BOTH ends whatever moved — silently erased the mark and the guess
|
|
46
|
+
* published as a proven height. That is the laundering the mark exists to prevent, reached by the
|
|
47
|
+
* most ordinary action in the editor.
|
|
48
|
+
*
|
|
49
|
+
* THE RULE, and it is about who is speaking. Moving geometry is not a statement about elevation: a
|
|
50
|
+
* translated or copied guess is still a guess, so the mark rides along. Typing an ABSOLUTE elevation
|
|
51
|
+
* is a person stating the height, which is exactly what the question was asking for — so `elevMm` and
|
|
52
|
+
* the commands that take a number from the user clear it. That makes "confirm this value" the same
|
|
53
|
+
* gesture as "correct this value", which is what a detailer actually does.
|
|
54
|
+
*/
|
|
55
|
+
const carryAssumed = (prev, next) => (prev && prev.assumed === true
|
|
56
|
+
? { ...next, assumed: true, why: prev.why, checked: prev.checked }
|
|
57
|
+
: next);
|
|
35
58
|
|
|
36
59
|
/*
|
|
37
60
|
* The drag-start snapshot `moveWorkPoints` compares against — every field the gizmo's availability, its
|
|
@@ -61,9 +84,12 @@ export function memberFingerprint(member) {
|
|
|
61
84
|
for (const k of FINGERPRINT_KEYS) if (member[k] !== undefined) out[k] = clone(member[k]);
|
|
62
85
|
return out;
|
|
63
86
|
}
|
|
64
|
-
|
|
87
|
+
function memberFingerprintKey(fp) {
|
|
65
88
|
return stableKey(fp);
|
|
66
89
|
}
|
|
90
|
+
function isMemberFingerprint(fp) {
|
|
91
|
+
return !!fp && typeof fp === 'object' && !Array.isArray(fp) && !!fp.from && !!fp.to;
|
|
92
|
+
}
|
|
67
93
|
|
|
68
94
|
export class V2CommandError extends Error {
|
|
69
95
|
constructor(code, message, details = []) {
|
|
@@ -182,12 +208,12 @@ function detachCopiedEngineeringReferences(member) {
|
|
|
182
208
|
return member;
|
|
183
209
|
}
|
|
184
210
|
|
|
185
|
-
function assertNoWholeMemberRefs(doc, ids) {
|
|
211
|
+
function assertNoWholeMemberRefs(doc, ids, { carryEndpointRefs = false } = {}) {
|
|
186
212
|
const blockers = [];
|
|
187
213
|
for (const member of doc.members || []) {
|
|
188
214
|
if (ids.has(member.id)) {
|
|
189
215
|
if (member.brace) blockers.push(`member ${member.id} brace`);
|
|
190
|
-
if ((member.ends || []).some((end) => end?.conn)) blockers.push(`member ${member.id} connection`);
|
|
216
|
+
if (!carryEndpointRefs && (member.ends || []).some((end) => end?.conn)) blockers.push(`member ${member.id} connection`);
|
|
191
217
|
} else if (referencesString(member.brace, ids)) blockers.push(`member ${member.id} brace`);
|
|
192
218
|
}
|
|
193
219
|
if (referencesString(doc.connections, ids)) blockers.push('connections');
|
|
@@ -202,34 +228,59 @@ function assertNoWholeMemberRefs(doc, ids) {
|
|
|
202
228
|
}
|
|
203
229
|
}
|
|
204
230
|
|
|
205
|
-
function
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
231
|
+
function point3(memberPoint, label) {
|
|
232
|
+
return [Number(memberPoint?.x), Number(memberPoint?.y), known(memberPoint?.z, label)];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function splitParameter(point, a, b, label) {
|
|
236
|
+
const ab = vsub(b, a), ap = vsub(point, a), len2 = vdot(ab, ab);
|
|
237
|
+
if (!(len2 > 0)) throw new V2CommandError('split-point-invalid', `${label} has no usable length`);
|
|
238
|
+
const t = vdot(ap, ab) / len2;
|
|
239
|
+
const nearest = vadd(a, vmul(ab, t));
|
|
240
|
+
if (vdist(point, nearest) > 0.001) {
|
|
241
|
+
throw new V2CommandError('joint-anchor-ambiguous', `${label} is not on the member being split`);
|
|
242
|
+
}
|
|
243
|
+
return t;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function jointEndpoint(member, at, label) {
|
|
247
|
+
if (at === 'base' || at === 'end0') return point3(member.from, `${label}.from`);
|
|
248
|
+
if (at === 'end1') return point3(member.to, `${label}.to`);
|
|
249
|
+
throw new V2CommandError('joint-anchor-ambiguous', `${label} does not name end0, end1, or base`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function repointJoint(doc, joint, oldId, first, second, cutT) {
|
|
253
|
+
if (joint.main === oldId) {
|
|
254
|
+
if (joint.at === 'base' || joint.at === 'end0') joint.main = first.id;
|
|
255
|
+
else if (joint.at === 'end1') joint.main = second.id;
|
|
256
|
+
else throw new V2CommandError('joint-anchor-ambiguous', `joint "${joint.id}" does not name which endpoint of "${oldId}" it follows`);
|
|
257
|
+
}
|
|
258
|
+
if (!(joint.secondaries || []).includes(oldId)) return;
|
|
259
|
+
if (joint.main === first.id || joint.main === second.id) {
|
|
260
|
+
throw new V2CommandError('joint-anchor-ambiguous', `joint "${joint.id}" names "${oldId}" as both main and secondary`);
|
|
261
|
+
}
|
|
262
|
+
const main = memberById(doc, joint.main);
|
|
263
|
+
const anchor = jointEndpoint(main, joint.at, `joint "${joint.id}"`);
|
|
264
|
+
const old = memberById(doc, oldId);
|
|
265
|
+
const t = splitParameter(anchor, point3(old.from, `${oldId}.from`), point3(old.to, `${oldId}.to`), `joint "${joint.id}" anchor`);
|
|
266
|
+
if (Math.abs(t - cutT) <= 1e-9) {
|
|
267
|
+
throw new V2CommandError('joint-anchor-ambiguous', `joint "${joint.id}" lands exactly on the new internal split endpoint`);
|
|
215
268
|
}
|
|
269
|
+
const replacement = t < cutT ? first.id : second.id;
|
|
270
|
+
joint.secondaries = joint.secondaries.map((id) => id === oldId ? replacement : id);
|
|
216
271
|
}
|
|
217
272
|
|
|
218
|
-
function repointSplitDims(
|
|
273
|
+
function repointSplitDims(plan, oldId, first, second) {
|
|
219
274
|
for (const dim of plan.dims || []) {
|
|
220
275
|
for (const side of ['a', 'b']) {
|
|
221
276
|
const ref = dim[`${side}Ref`];
|
|
222
277
|
if (ref?.m !== oldId) continue;
|
|
223
|
-
|
|
224
|
-
if (Math.hypot(point.x - split.x, point.y - split.y) <= 1e-6) {
|
|
278
|
+
if (ref.pt === 'mid') {
|
|
225
279
|
throw new V2CommandError('dim-anchor-at-split', `dimension "${dim.id}" is anchored exactly at the split point`);
|
|
226
280
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
throw new V2CommandError('dim-anchor-ambiguous', `dimension "${dim.id}" does not resolve to exactly one split segment`);
|
|
231
|
-
}
|
|
232
|
-
ref.m = onFirst ? first.id : second.id;
|
|
281
|
+
if (ref.pt === 'a') ref.m = first.id;
|
|
282
|
+
else if (ref.pt === 'b') ref.m = second.id;
|
|
283
|
+
else throw new V2CommandError('dim-anchor-ambiguous', `dimension "${dim.id}" has an unknown member anchor`);
|
|
233
284
|
}
|
|
234
285
|
}
|
|
235
286
|
}
|
|
@@ -240,10 +291,117 @@ function rebindSplitObservations(doc, oldId, replacements) {
|
|
|
240
291
|
if (!(obs.binding?.memberIds || []).includes(oldId)) continue;
|
|
241
292
|
obs.binding.memberIds = replaceInList(obs.binding.memberIds, new Set([oldId]), replacements);
|
|
242
293
|
obs.binding.inherited = true;
|
|
294
|
+
if (Array.isArray(obs.binding.endpointLineage)) {
|
|
295
|
+
for (const row of obs.binding.endpointLineage) {
|
|
296
|
+
if (row.memberId !== oldId) continue;
|
|
297
|
+
if (row.memberEnd === 0) row.memberId = replacements[0];
|
|
298
|
+
else if (row.memberEnd === 1) row.memberId = replacements[1];
|
|
299
|
+
else delete obs.binding.endpointLineage;
|
|
300
|
+
}
|
|
301
|
+
if (Array.isArray(obs.binding.endpointLineage)) {
|
|
302
|
+
const covered = new Set(obs.binding.endpointLineage.map((row) => row.memberId));
|
|
303
|
+
const wanted = new Set(obs.binding.memberIds);
|
|
304
|
+
if (covered.size !== wanted.size || [...wanted].some((id) => !covered.has(id))) delete obs.binding.endpointLineage;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
243
307
|
}
|
|
244
308
|
}
|
|
245
309
|
}
|
|
246
310
|
|
|
311
|
+
function assertSplitDecisionAuthority(doc, original) {
|
|
312
|
+
for (const member of doc.members || []) for (const end of member.ends || []) {
|
|
313
|
+
const kind = end?.workPointDecision?.kind;
|
|
314
|
+
if (kind === 'aligned' || kind === 'keep-short') {
|
|
315
|
+
throw new V2CommandError(
|
|
316
|
+
'split-decision-authority',
|
|
317
|
+
'Split is unavailable while the model has a live work-point decision; review or retire that decision first.',
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if ((original.ends || []).some((end) => end?.workPointDecision)) {
|
|
322
|
+
throw new V2CommandError(
|
|
323
|
+
'split-decision-authority',
|
|
324
|
+
'Split is unavailable because this member carries work-point decision history that cannot be reassigned automatically.',
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function assertSplitInferredSupportAuthority(doc) {
|
|
330
|
+
for (const joint of doc.joints || []) {
|
|
331
|
+
if ((joint.kind !== 'shear-plate' && joint.kind !== 'brace-gusset') || (joint.secondaries || []).length) continue;
|
|
332
|
+
throw new V2CommandError(
|
|
333
|
+
'split-inferred-support-authority',
|
|
334
|
+
'Split is unavailable while a connection relies on inferred support; name or review that support first.',
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function interpolatedSplitPoint(original, t) {
|
|
340
|
+
const point = {
|
|
341
|
+
x: quantizeMm(original.from.x + (original.to.x - original.from.x) * t),
|
|
342
|
+
y: quantizeMm(original.from.y + (original.to.y - original.from.y) * t),
|
|
343
|
+
// A point interpolated between two ends is only as sound as those ends. If EITHER was placed
|
|
344
|
+
// rather than proven, so is this one (#1155) — splitting a member is not evidence about its
|
|
345
|
+
// height, and a split that quietly produced a bare `{known}` would launder the guess into two
|
|
346
|
+
// new members with new ids that no diff against the original could catch.
|
|
347
|
+
z: isKnown(original.from.z) && isKnown(original.to.z)
|
|
348
|
+
? carryAssumed(
|
|
349
|
+
original.from.z.assumed === true ? original.from.z : original.to.z,
|
|
350
|
+
{ known: quantizeMm(original.from.z.known + (original.to.z.known - original.from.z.known) * t) },
|
|
351
|
+
)
|
|
352
|
+
: { unknown: true },
|
|
353
|
+
};
|
|
354
|
+
return point;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function sameStoredPoint(a, b) {
|
|
358
|
+
if (a.x !== b.x || a.y !== b.y) return false;
|
|
359
|
+
if (isKnown(a.z) && isKnown(b.z)) return a.z.known === b.z.known;
|
|
360
|
+
return !isKnown(a.z) && !isKnown(b.z);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function splitMemberAt(doc, memberId, t, expect, mintId, { requireKnownElevation = false } = {}) {
|
|
364
|
+
const original = memberById(doc, memberId);
|
|
365
|
+
if (expect && memberFingerprintKey(expect) !== memberFingerprintKey(memberFingerprint(original))) {
|
|
366
|
+
throw new V2CommandError('member-stale', `member "${memberId}" changed after the Split gesture began`);
|
|
367
|
+
}
|
|
368
|
+
if (!Number.isFinite(t) || !(t > 0) || !(t < 1)) {
|
|
369
|
+
throw new V2CommandError('split-point-invalid', 'the split point must lie strictly inside the member');
|
|
370
|
+
}
|
|
371
|
+
if (requireKnownElevation && (!isKnown(original.from.z) || !isKnown(original.to.z))) {
|
|
372
|
+
throw new V2CommandError('elevation-unknown', `member "${memberId}" has unknown elevation and cannot be picked in 3D`);
|
|
373
|
+
}
|
|
374
|
+
assertSplitDecisionAuthority(doc, original);
|
|
375
|
+
// The server owns support inference. A split changes the candidate identity set globally, so the
|
|
376
|
+
// browser cannot prove that an unnamed support will still resolve to the same physical member. Refuse
|
|
377
|
+
// before minting instead of letting server revalidation silently author one arbitrary child id.
|
|
378
|
+
assertSplitInferredSupportAuthority(doc);
|
|
379
|
+
assertNoWholeMemberRefs(doc, new Set([memberId]), { carryEndpointRefs: true });
|
|
380
|
+
const split = interpolatedSplitPoint(original, t);
|
|
381
|
+
if (sameStoredPoint(split, original.from) || sameStoredPoint(split, original.to)) {
|
|
382
|
+
throw new V2CommandError('split-point-invalid', 'the quantized split point would create a zero-length member');
|
|
383
|
+
}
|
|
384
|
+
const first = clone(original), second = clone(original);
|
|
385
|
+
first.id = mintId(); second.id = mintId();
|
|
386
|
+
first.to = clone(split); second.from = clone(split);
|
|
387
|
+
if (Array.isArray(original.ends)) {
|
|
388
|
+
first.ends = [clone(original.ends[0] || {}), {}];
|
|
389
|
+
second.ends = [{}, clone(original.ends[1] || {})];
|
|
390
|
+
} else {
|
|
391
|
+
delete first.ends; delete second.ends;
|
|
392
|
+
}
|
|
393
|
+
for (const joint of doc.joints || []) repointJoint(doc, joint, memberId, first, second, t);
|
|
394
|
+
for (const plan of doc.plans || []) repointSplitDims(plan, memberId, first, second);
|
|
395
|
+
rebindSplitObservations(doc, memberId, [first.id, second.id]);
|
|
396
|
+
for (const plan of doc.plans || []) {
|
|
397
|
+
plan.memberRefs = replaceInList(plan.memberRefs, new Set([memberId]), [first.id, second.id]);
|
|
398
|
+
}
|
|
399
|
+
if (doc.prop_labels?.ids) doc.prop_labels.ids = replaceInList(doc.prop_labels.ids, new Set([memberId]), [first.id, second.id]);
|
|
400
|
+
doc.members = doc.members.filter((m) => m.id !== memberId);
|
|
401
|
+
doc.members.push(first, second);
|
|
402
|
+
return [first.id, second.id];
|
|
403
|
+
}
|
|
404
|
+
|
|
247
405
|
function rebindMergedObservations(doc, oldIds, replacement) {
|
|
248
406
|
for (const plan of doc.plans || []) {
|
|
249
407
|
for (const obs of plan.memberObservations || []) {
|
|
@@ -372,8 +530,12 @@ function mergeMemberGroup(doc, sheet, memberIds, mergedPx, mintId, resolveSectio
|
|
|
372
530
|
const physical=physicalMergePreflight(sources,resolveSection);
|
|
373
531
|
const merged = physical.survivor;
|
|
374
532
|
merged.id = mintId();
|
|
375
|
-
|
|
376
|
-
|
|
533
|
+
// MERGE is split's inverse and needs the same rule: if either source end was placed rather than
|
|
534
|
+
// proven, so is the survivor's. The survivor gets a NEW id, so nothing downstream can compare it
|
|
535
|
+
// against the originals to notice the mark went missing.
|
|
536
|
+
const anyAssumed = sources.flatMap((m) => [m.from.z, m.to.z]).find((z) => z && z.assumed === true) || null;
|
|
537
|
+
merged.from = {x:physical.from[0],y:physical.from[1],z:carryAssumed(anyAssumed,{known:physical.from[2]})};
|
|
538
|
+
merged.to = {x:physical.to[0],y:physical.to[1],z:carryAssumed(anyAssumed,{known:physical.to[2]})};
|
|
377
539
|
for (const joint of doc.joints || []) {
|
|
378
540
|
if (oldIds.has(joint.main)) joint.main = merged.id;
|
|
379
541
|
if (joint.secondaries) joint.secondaries = joint.secondaries.map((id) => oldIds.has(id) ? merged.id : id);
|
|
@@ -438,6 +600,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
438
600
|
restoreSnapshot(saved) {
|
|
439
601
|
return session.transact('restore undo snapshot', (draft) => {
|
|
440
602
|
draft.members = Array.isArray(saved.members) ? clone(saved.members) : [];
|
|
603
|
+
if (Object.hasOwn(saved, 'provisional_members')) {
|
|
604
|
+
draft.provisional_members = Array.isArray(saved.provisional_members) ? clone(saved.provisional_members) : [];
|
|
605
|
+
}
|
|
441
606
|
draft.grid = Object.hasOwn(saved, 'grid') ? clone(saved.grid) : null;
|
|
442
607
|
// Keyed by VIEW ID, not page (#938): with two views on one sheet a page-keyed map holds one of
|
|
443
608
|
// them, and every sibling would be restored from its neighbour's dims, refs and observations.
|
|
@@ -607,7 +772,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
607
772
|
}
|
|
608
773
|
for (const [key, index] of [['from', 0], ['to', 1]]) {
|
|
609
774
|
const [x, y, z] = next[key];
|
|
610
|
-
|
|
775
|
+
// Both ends are rewritten whatever actually moved, so without `carryAssumed` an x/y drag on
|
|
776
|
+
// one end erases the mark on the other too.
|
|
777
|
+
setEndpoint(member, index, { x, y, z: carryAssumed(member[key]?.z, { known: z }) });
|
|
611
778
|
}
|
|
612
779
|
if (need.pin !== undefined) member.position = need.pin;
|
|
613
780
|
return { changedIds: [memberId] };
|
|
@@ -619,12 +786,12 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
619
786
|
const id = projected.id && !(doc.members || []).some((m) => m.id === projected.id)
|
|
620
787
|
? projected.id : mintId();
|
|
621
788
|
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
622
|
-
const fromZ = projected.role === 'column' ? projected.col?.
|
|
623
|
-
const toZ = projected.role === 'column' ? projected.col?.
|
|
789
|
+
const fromZ = projected.role === 'column' ? projected.col?.bosMm : projected.ends?.[0]?.tosMm;
|
|
790
|
+
const toZ = projected.role === 'column' ? projected.col?.tosMm : projected.ends?.[1]?.tosMm;
|
|
624
791
|
const from = sheetPxToWorld(projected.wp[0], plan,
|
|
625
|
-
Number.isFinite(fromZ) ?
|
|
792
|
+
Number.isFinite(fromZ) ? elevMm(fromZ) : { unknown: true });
|
|
626
793
|
const to = sheetPxToWorld(projected.wp[1], plan,
|
|
627
|
-
Number.isFinite(toZ) ?
|
|
794
|
+
Number.isFinite(toZ) ? elevMm(toZ) : { unknown: true });
|
|
628
795
|
const member = {
|
|
629
796
|
id, profile: projected.profile || '', from, to,
|
|
630
797
|
provenance: 'manual',
|
|
@@ -635,7 +802,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
635
802
|
if (Array.isArray(projected.ends)) {
|
|
636
803
|
member.ends = projected.ends.map((end) => {
|
|
637
804
|
const out = clone(end);
|
|
638
|
-
|
|
805
|
+
// `tosMm`, not `tos`. The elevation lives in the work point, so the display row's copy of it
|
|
806
|
+
// must never reach the document — and `steel.model/v2` is `additionalProperties:false`, so a
|
|
807
|
+
// stale key here does not degrade gracefully: the whole write fails validation and the edit
|
|
808
|
+
// silently does not happen. That is exactly what the rename caught, and why it was a rename.
|
|
809
|
+
delete out.tosMm; delete out.tosDef;
|
|
639
810
|
return out;
|
|
640
811
|
});
|
|
641
812
|
}
|
|
@@ -663,10 +834,13 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
663
834
|
const member = memberById(doc, id);
|
|
664
835
|
const a = sheetPxToWorld(worldPoint(member.from, plan, offset), plan, clone(member.from.z));
|
|
665
836
|
const b = sheetPxToWorld(worldPoint(member.to, plan, offset), plan, clone(member.to.z));
|
|
666
|
-
const dz = Number(offset?.[2] || 0)
|
|
837
|
+
const dz = Number(offset?.[2] || 0); // MILLIMETRES — the caller's Z offset is world mm, like every other elevation here
|
|
667
838
|
if (dz) {
|
|
668
|
-
a
|
|
669
|
-
|
|
839
|
+
// Moving a member up or down says nothing about whether its height was ever proven, so a
|
|
840
|
+
// placed-but-unverified mark rides along with the arithmetic (#1155). Only a person
|
|
841
|
+
// TYPING an elevation clears it.
|
|
842
|
+
a.z = carryAssumed(a.z, { known: known(a.z, `${id}.from`) + dz });
|
|
843
|
+
b.z = carryAssumed(b.z, { known: known(b.z, `${id}.to`) + dz });
|
|
670
844
|
}
|
|
671
845
|
member.from = a; member.to = b;
|
|
672
846
|
}
|
|
@@ -674,9 +848,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
674
848
|
});
|
|
675
849
|
},
|
|
676
850
|
|
|
677
|
-
setElevation(memberId, index,
|
|
851
|
+
setElevation(memberId, index, mm) {
|
|
678
852
|
return session.transact('set elevation', (doc) => {
|
|
679
|
-
setEndpoint(memberById(doc, memberId), index, { ...endpoint(memberById(doc, memberId), index), z:
|
|
853
|
+
setEndpoint(memberById(doc, memberId), index, { ...endpoint(memberById(doc, memberId), index), z: elevMm(mm) });
|
|
680
854
|
return { changedIds: [memberId] };
|
|
681
855
|
});
|
|
682
856
|
},
|
|
@@ -708,6 +882,14 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
708
882
|
});
|
|
709
883
|
},
|
|
710
884
|
|
|
885
|
+
patchMemberBrace(memberId, patch) {
|
|
886
|
+
return session.transact('patch member brace', (doc) => {
|
|
887
|
+
const member = memberById(doc, memberId);
|
|
888
|
+
member.brace = { ...(member.brace || {}), ...clone(patch || {}) };
|
|
889
|
+
return { changedIds: [memberId] };
|
|
890
|
+
});
|
|
891
|
+
},
|
|
892
|
+
|
|
711
893
|
patchEnd(memberId, index, patch) {
|
|
712
894
|
return session.transact('patch member end', (doc) => {
|
|
713
895
|
const member = memberById(doc, memberId);
|
|
@@ -751,20 +933,20 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
751
933
|
});
|
|
752
934
|
},
|
|
753
935
|
|
|
754
|
-
setElevationDefault(memberId, index, on,
|
|
936
|
+
setElevationDefault(memberId, index, on, defaultMm) {
|
|
755
937
|
if (!on) return { changedIds: new Set(), structural: false };
|
|
756
938
|
return session.transact('apply elevation default', (doc) => {
|
|
757
939
|
const member = memberById(doc, memberId);
|
|
758
940
|
known(endpoint(member, index).z, `${memberId}.${index}`);
|
|
759
|
-
setEndpoint(member, index, { ...endpoint(member, index), z:
|
|
941
|
+
setEndpoint(member, index, { ...endpoint(member, index), z: elevMm(defaultMm) });
|
|
760
942
|
return { changedIds: [memberId] };
|
|
761
943
|
});
|
|
762
944
|
},
|
|
763
945
|
|
|
764
|
-
|
|
946
|
+
setBosMm(memberId, mm) {
|
|
765
947
|
return session.transact('set column base', (doc) => {
|
|
766
948
|
const member = memberById(doc, memberId);
|
|
767
|
-
member.from = { ...member.from, z:
|
|
949
|
+
member.from = { ...member.from, z: elevMm(mm) };
|
|
768
950
|
return { changedIds: [memberId] };
|
|
769
951
|
});
|
|
770
952
|
},
|
|
@@ -782,14 +964,14 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
782
964
|
});
|
|
783
965
|
},
|
|
784
966
|
|
|
785
|
-
syncToDefault(memberId,
|
|
967
|
+
syncToDefault(memberId, defaultMm) {
|
|
786
968
|
return session.transact('synchronise elevation', (doc) => {
|
|
787
969
|
const member = memberById(doc, memberId);
|
|
788
970
|
known(member.from.z, `${memberId}.from`);
|
|
789
971
|
known(member.to.z, `${memberId}.to`);
|
|
790
972
|
// v2 deliberately has no persisted default link. This action is explicit and applies both ends.
|
|
791
|
-
member.from = { ...member.from, z:
|
|
792
|
-
member.to = { ...member.to, z:
|
|
973
|
+
member.from = { ...member.from, z: elevMm(defaultMm) };
|
|
974
|
+
member.to = { ...member.to, z: elevMm(defaultMm) };
|
|
793
975
|
return { changedIds: [memberId] };
|
|
794
976
|
});
|
|
795
977
|
},
|
|
@@ -805,12 +987,12 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
805
987
|
});
|
|
806
988
|
},
|
|
807
989
|
|
|
808
|
-
offsetElevation(memberId,
|
|
990
|
+
offsetElevation(memberId, deltaMm) {
|
|
809
991
|
return session.transact('offset member elevation', (doc) => {
|
|
810
992
|
const member = memberById(doc, memberId);
|
|
811
|
-
const delta = Number(
|
|
812
|
-
member.from = { ...member.from, z: { known: known(member.from.z, `${memberId}.from`) + delta } };
|
|
813
|
-
member.to = { ...member.to, z: { known: known(member.to.z, `${memberId}.to`) + delta } };
|
|
993
|
+
const delta = Number(deltaMm);
|
|
994
|
+
member.from = { ...member.from, z: carryAssumed(member.from.z, { known: known(member.from.z, `${memberId}.from`) + delta }) };
|
|
995
|
+
member.to = { ...member.to, z: carryAssumed(member.to.z, { known: known(member.to.z, `${memberId}.to`) + delta }) };
|
|
814
996
|
return { changedIds: [memberId] };
|
|
815
997
|
});
|
|
816
998
|
},
|
|
@@ -948,10 +1130,14 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
948
1130
|
copy.source = { kind: 'copy', copiedFrom: source.id };
|
|
949
1131
|
copy.from = sheetPxToWorld(worldPoint(source.from, plan, offsetPx), plan, clone(source.from.z));
|
|
950
1132
|
copy.to = sheetPxToWorld(worldPoint(source.to, plan, offsetPx), plan, clone(source.to.z));
|
|
951
|
-
const dz = Number(offsetPx[2] || 0)
|
|
1133
|
+
const dz = Number(offsetPx[2] || 0); // MILLIMETRES, like `translateMembers` above — only x/y are pixels
|
|
952
1134
|
if (dz) {
|
|
953
|
-
|
|
954
|
-
|
|
1135
|
+
// Without `carryAssumed` this laundered or not DEPENDING ON THE OFFSET: with `dz === 0`
|
|
1136
|
+
// the clone above preserves the mark, with any dz it was rewritten bare. One command,
|
|
1137
|
+
// two behaviours, contradicting `carryAssumed`'s own stated rule that a translated OR
|
|
1138
|
+
// COPIED guess is still a guess.
|
|
1139
|
+
copy.from.z = carryAssumed(copy.from.z, { known: known(copy.from.z, `${source.id}.from`) + dz });
|
|
1140
|
+
copy.to.z = carryAssumed(copy.to.z, { known: known(copy.to.z, `${source.id}.to`) + dz });
|
|
955
1141
|
}
|
|
956
1142
|
doc.members.push(copy);
|
|
957
1143
|
planByViewId(doc, viewId).memberRefs = [...new Set([...(planByViewId(doc, viewId).memberRefs || []), copy.id])];
|
|
@@ -966,20 +1152,23 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
966
1152
|
moveOrCopyToView(targetViewId, entries, copy = false) {
|
|
967
1153
|
return session.transact(copy ? 'copy members to view' : 'move members to view', (doc) => {
|
|
968
1154
|
const target = planByViewId(doc, targetViewId);
|
|
969
|
-
if (!Number.isFinite(target.
|
|
1155
|
+
if (!Number.isFinite(target.elevation_mm)) {
|
|
970
1156
|
throw new V2CommandError('target-elevation-unknown', `drawing view "${targetViewId}" has no known plan elevation`);
|
|
971
1157
|
}
|
|
972
1158
|
const made = [];
|
|
973
1159
|
for (const entry of entries || []) {
|
|
974
1160
|
const sourcePlan = planByViewId(doc, entry.sourceViewId);
|
|
975
|
-
if (!Number.isFinite(sourcePlan.
|
|
1161
|
+
if (!Number.isFinite(sourcePlan.elevation_mm)) {
|
|
976
1162
|
throw new V2CommandError('source-elevation-unknown', `drawing view "${entry.sourceViewId}" has no known plan elevation`);
|
|
977
1163
|
}
|
|
978
1164
|
const source = memberById(doc, entry.id);
|
|
979
1165
|
const member = copy ? detachCopiedEngineeringReferences(clone(source)) : source;
|
|
980
|
-
const dz =
|
|
981
|
-
member
|
|
982
|
-
|
|
1166
|
+
const dz = target.elevation_mm - sourcePlan.elevation_mm; // both are already mm
|
|
1167
|
+
// Moving a member to another view shifts it by the gap between two plan elevations. That is
|
|
1168
|
+
// a move, not a statement about whether its height was ever established — and this one
|
|
1169
|
+
// overwrote unconditionally, so the mark was ALWAYS lost.
|
|
1170
|
+
member.from.z = carryAssumed(source.from.z, { known: known(source.from.z, `${source.id}.from`) + dz });
|
|
1171
|
+
member.to.z = carryAssumed(source.to.z, { known: known(source.to.z, `${source.id}.to`) + dz });
|
|
983
1172
|
if (copy) {
|
|
984
1173
|
member.id = mintId();
|
|
985
1174
|
member.provenance = 'manual';
|
|
@@ -998,27 +1187,30 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
998
1187
|
splitMember(viewId, memberId, splitPx) {
|
|
999
1188
|
return session.transact('split member', (doc) => {
|
|
1000
1189
|
const original = memberById(doc, memberId);
|
|
1001
|
-
assertNoWholeMemberRefs(doc, new Set([memberId]));
|
|
1002
1190
|
const split = sheetPxToWorld(splitPx, {
|
|
1003
1191
|
...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid,
|
|
1004
|
-
},
|
|
1005
|
-
if (!pointOnSegment(split, original.from, original.to)
|
|
1006
|
-
|| Math.hypot(split.x - original.from.x, split.y - original.from.y) <= 1e-6
|
|
1007
|
-
|| Math.hypot(split.x - original.to.x, split.y - original.to.y) <= 1e-6) {
|
|
1192
|
+
}, { unknown: true });
|
|
1193
|
+
if (!pointOnSegment(split, original.from, original.to)) {
|
|
1008
1194
|
throw new V2CommandError('split-point-invalid', 'the split point must lie strictly inside the member');
|
|
1009
1195
|
}
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
for (const plan of doc.plans || []) repointSplitDims(doc, plan, memberId, first, second, split);
|
|
1015
|
-
rebindSplitObservations(doc, memberId, [first.id, second.id]);
|
|
1016
|
-
for (const plan of doc.plans || []) {
|
|
1017
|
-
plan.memberRefs = replaceInList(plan.memberRefs, new Set([memberId]), [first.id, second.id]);
|
|
1196
|
+
const dx = original.to.x - original.from.x, dy = original.to.y - original.from.y;
|
|
1197
|
+
const len2 = dx * dx + dy * dy;
|
|
1198
|
+
if (!(len2 > 0)) {
|
|
1199
|
+
throw new V2CommandError('split-point-invalid', 'this member has no plan length; split it from the 3D view');
|
|
1018
1200
|
}
|
|
1019
|
-
|
|
1020
|
-
doc
|
|
1021
|
-
return { changedIds:
|
|
1201
|
+
const t = ((split.x - original.from.x) * dx + (split.y - original.from.y) * dy) / len2;
|
|
1202
|
+
const made = splitMemberAt(doc, memberId, t, null, mintId);
|
|
1203
|
+
return { changedIds: made, structural: true, value: made };
|
|
1204
|
+
});
|
|
1205
|
+
},
|
|
1206
|
+
|
|
1207
|
+
splitMemberWorld(memberId, t, expect) {
|
|
1208
|
+
return session.transact('split member', (doc) => {
|
|
1209
|
+
if (!isMemberFingerprint(expect)) {
|
|
1210
|
+
throw new V2CommandError('gesture-authority-missing', 'the 3D Split gesture has no valid drag-start member snapshot');
|
|
1211
|
+
}
|
|
1212
|
+
const made = splitMemberAt(doc, memberId, Number(t), expect, mintId, { requireKnownElevation: true });
|
|
1213
|
+
return { changedIds: made, structural: true, value: made };
|
|
1022
1214
|
});
|
|
1023
1215
|
},
|
|
1024
1216
|
|
|
@@ -1079,7 +1271,7 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1079
1271
|
if (!link?.session) return false;
|
|
1080
1272
|
const s = link.session;
|
|
1081
1273
|
switch (operation) {
|
|
1082
|
-
case '
|
|
1274
|
+
case 'setTosValueMm': {
|
|
1083
1275
|
const index = link.kind === 'column' ? 1 : link.end;
|
|
1084
1276
|
s.setElevation(link.memberId, index, args[0]); return true;
|
|
1085
1277
|
}
|
|
@@ -1087,7 +1279,7 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1087
1279
|
const index = link.kind === 'column' ? 1 : link.end;
|
|
1088
1280
|
s.setElevationDefault(link.memberId, index, args[0], args[1]); return true;
|
|
1089
1281
|
}
|
|
1090
|
-
case '
|
|
1282
|
+
case 'setBosMm': s.setBosMm(link.memberId, args[0]); return true;
|
|
1091
1283
|
case 'syncToDefault': s.syncToDefault(link.memberId, args[0]); return true;
|
|
1092
1284
|
case 'swapColElevation': s.swapColumnElevation(link.memberId); return true;
|
|
1093
1285
|
case 'copyEndTo': s.copyEndTo(link.memberId, args[0], args[1]); return true;
|
|
@@ -1107,7 +1299,7 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1107
1299
|
case 'patchMember': s.patchMember(link.memberId, args[0]); return true;
|
|
1108
1300
|
case 'patchEnd': s.patchEnd(link.memberId, link.kind === 'column' ? 1 : link.end, args[0]); return true;
|
|
1109
1301
|
case 'setMemberBrace': s.patchMember(link.memberId, { brace: args[0] == null ? undefined : args[0] }); return true;
|
|
1110
|
-
case 'patchMemberBrace': s.
|
|
1302
|
+
case 'patchMemberBrace': s.patchMemberBrace(link.memberId, args[0]); return true;
|
|
1111
1303
|
case 'patchGrid': s.patchGrid(link.viewId, args[0]); return true;
|
|
1112
1304
|
case 'setGridLabels': s.setGridLabels(args[0], args[1]); return true;
|
|
1113
1305
|
case 'setPlanGrid': s.setPlanGrid(link.viewId, args[0]); return true;
|
|
@@ -1123,7 +1315,7 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1123
1315
|
}
|
|
1124
1316
|
case 'setGridLineEnds': s.setGridLineEnds(link.viewId, link.gridLineId, args[0], args[1]); return true;
|
|
1125
1317
|
case 'addGridLine': s.addGridLine(link.viewId, args[0]); return true;
|
|
1126
|
-
case '
|
|
1318
|
+
case 'setPlanDefaultTosMm':
|
|
1127
1319
|
throw new V2CommandError('default-tos-retired', 'steel.model/v2 stores explicit endpoint elevations and has no sheet default T.O.S link');
|
|
1128
1320
|
case 'setPlanMembers':
|
|
1129
1321
|
throw new V2CommandError('structural-operation-explicit', 'v2 merge/split/delete commands must declare identity and reference reconciliation');
|