@reekon-tools/boldr-cad 1.5.0 → 1.7.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/README.md +12 -1
- package/dist/app/state.d.ts +3 -3
- package/dist/data/provider.d.ts +2 -1
- package/dist/data/sync.js +4 -1
- package/dist/data/sync.js.map +1 -1
- package/dist/editor/actions.js +122 -19
- package/dist/editor/actions.js.map +1 -1
- package/dist/editor/advance.d.ts +2 -0
- package/dist/editor/advance.js +23 -0
- package/dist/editor/advance.js.map +1 -0
- package/dist/editor/dimSize.d.ts +13 -0
- package/dist/editor/dimSize.js +50 -0
- package/dist/editor/dimSize.js.map +1 -0
- package/dist/editor/gestures.js +30 -7
- package/dist/editor/gestures.js.map +1 -1
- package/dist/editor/keypad.d.ts +8 -0
- package/dist/editor/keypad.js +15 -1
- package/dist/editor/keypad.js.map +1 -1
- package/dist/editor/keys.js +2 -1
- package/dist/editor/keys.js.map +1 -1
- package/dist/editor/laser.d.ts +13 -2
- package/dist/editor/laser.js +42 -14
- package/dist/editor/laser.js.map +1 -1
- package/dist/editor/linkActions.d.ts +29 -11
- package/dist/editor/linkActions.js +76 -29
- package/dist/editor/linkActions.js.map +1 -1
- package/dist/editor/links.d.ts +13 -0
- package/dist/editor/links.js +7 -1
- package/dist/editor/links.js.map +1 -1
- package/dist/editor/mode.d.ts +2 -1
- package/dist/editor/mode.js +7 -5
- package/dist/editor/mode.js.map +1 -1
- package/dist/editor/ports.d.ts +9 -0
- package/dist/editor/ports.js +2 -0
- package/dist/editor/ports.js.map +1 -1
- package/dist/editor/selection.js +1 -1
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/tooltips.js +1 -0
- package/dist/editor/tooltips.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/clockwise.d.ts +11 -0
- package/dist/model/clockwise.js +123 -0
- package/dist/model/clockwise.js.map +1 -0
- package/dist/model/constraints.js +2 -0
- package/dist/model/constraints.js.map +1 -1
- package/dist/model/geom.d.ts +2 -0
- package/dist/model/geom.js +11 -0
- package/dist/model/geom.js.map +1 -1
- package/dist/model/links.d.ts +6 -1
- package/dist/model/links.js +6 -1
- package/dist/model/links.js.map +1 -1
- package/dist/model/scale.js +3 -0
- package/dist/model/scale.js.map +1 -1
- package/dist/model/settings.d.ts +2 -0
- package/dist/model/settings.js +1 -1
- package/dist/model/settings.js.map +1 -1
- package/dist/model/sketch.d.ts +5 -1
- package/dist/model/sketch.js +19 -18
- package/dist/model/sketch.js.map +1 -1
- package/dist/model/trim.d.ts +54 -0
- package/dist/model/trim.js +219 -0
- package/dist/model/trim.js.map +1 -0
- package/dist/model/types.d.ts +24 -2
- package/dist/react/BottomBar.js +94 -25
- package/dist/react/BottomBar.js.map +1 -1
- package/dist/react/CadEditor.js +18 -9
- package/dist/react/CadEditor.js.map +1 -1
- package/dist/react/Drawer.js +3 -2
- package/dist/react/Drawer.js.map +1 -1
- package/dist/react/PlanCanvas.native.js +15 -9
- package/dist/react/PlanCanvas.native.js.map +1 -1
- package/dist/react/PlanCanvas.web.js +17 -5
- package/dist/react/PlanCanvas.web.js.map +1 -1
- package/dist/react/ShapeMenu.js +3 -2
- package/dist/react/ShapeMenu.js.map +1 -1
- package/dist/react/ToolTip.js +3 -2
- package/dist/react/ToolTip.js.map +1 -1
- package/dist/react/TopBar.js +4 -3
- package/dist/react/TopBar.js.map +1 -1
- package/dist/react/editorBox.d.ts +8 -0
- package/dist/react/editorBox.js +10 -0
- package/dist/react/editorBox.js.map +1 -0
- package/dist/react/host.d.ts +7 -1
- package/dist/react/host.js +12 -2
- package/dist/react/host.js.map +1 -1
- package/dist/react/pageLock.native.d.ts +2 -0
- package/dist/react/pageLock.native.js +2 -0
- package/dist/react/pageLock.native.js.map +1 -1
- package/dist/react/pageLock.web.d.ts +6 -0
- package/dist/react/pageLock.web.js +12 -3
- package/dist/react/pageLock.web.js.map +1 -1
- package/dist/react/ports.js +10 -4
- package/dist/react/ports.js.map +1 -1
- package/dist/react/saving.d.ts +7 -1
- package/dist/react/saving.js +10 -2
- package/dist/react/saving.js.map +1 -1
- package/dist/react/store.d.ts +5 -2
- package/dist/react/store.js +4 -1
- package/dist/react/store.js.map +1 -1
- package/dist/render/draw.d.ts +7 -0
- package/dist/render/draw.js +41 -15
- package/dist/render/draw.js.map +1 -1
- package/dist/render/linkTile.js +2 -2
- package/dist/render/linkTile.js.map +1 -1
- package/dist/render/navigate.d.ts +11 -6
- package/dist/render/navigate.js +34 -20
- package/dist/render/navigate.js.map +1 -1
- package/dist/render/snap.d.ts +5 -0
- package/dist/render/snap.js +84 -14
- package/dist/render/snap.js.map +1 -1
- package/dist/render/view.js +7 -2
- package/dist/render/view.js.map +1 -1
- package/dist/solver/equations.js +30 -16
- package/dist/solver/equations.js.map +1 -1
- package/dist/tools/dim.d.ts +6 -0
- package/dist/tools/dim.js +28 -4
- package/dist/tools/dim.js.map +1 -1
- package/dist/tools/modify.d.ts +32 -4
- package/dist/tools/modify.js +247 -97
- package/dist/tools/modify.js.map +1 -1
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.js +8 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/select.d.ts +11 -8
- package/dist/tools/select.js +51 -19
- package/dist/tools/select.js.map +1 -1
- package/package.json +1 -1
- package/src/app/state.ts +3 -3
- package/src/data/provider.ts +2 -2
- package/src/data/sync.ts +4 -1
- package/src/editor/actions.ts +98 -16
- package/src/editor/advance.ts +23 -0
- package/src/editor/dimSize.ts +53 -0
- package/src/editor/gestures.ts +31 -9
- package/src/editor/keypad.ts +17 -1
- package/src/editor/keys.ts +2 -1
- package/src/editor/laser.ts +45 -14
- package/src/editor/linkActions.ts +87 -26
- package/src/editor/links.ts +17 -1
- package/src/editor/mode.ts +7 -5
- package/src/editor/ports.ts +10 -0
- package/src/editor/selection.ts +1 -1
- package/src/editor/tooltips.ts +1 -0
- package/src/index.ts +2 -2
- package/src/model/clockwise.ts +121 -0
- package/src/model/constraints.ts +1 -0
- package/src/model/geom.ts +10 -0
- package/src/model/links.ts +6 -1
- package/src/model/scale.ts +2 -0
- package/src/model/settings.ts +3 -1
- package/src/model/sketch.ts +14 -7
- package/src/model/trim.ts +188 -0
- package/src/model/types.ts +19 -2
- package/src/react/BottomBar.tsx +109 -25
- package/src/react/CadEditor.tsx +19 -9
- package/src/react/Drawer.tsx +3 -2
- package/src/react/PlanCanvas.native.tsx +25 -12
- package/src/react/PlanCanvas.web.tsx +17 -5
- package/src/react/ShapeMenu.tsx +3 -2
- package/src/react/ToolTip.tsx +3 -2
- package/src/react/TopBar.tsx +4 -3
- package/src/react/editorBox.ts +20 -0
- package/src/react/host.ts +12 -2
- package/src/react/pageLock.native.ts +2 -0
- package/src/react/pageLock.web.ts +12 -3
- package/src/react/ports.ts +10 -4
- package/src/react/saving.ts +10 -2
- package/src/react/store.ts +5 -2
- package/src/render/draw.ts +38 -16
- package/src/render/linkTile.ts +2 -2
- package/src/render/navigate.ts +31 -20
- package/src/render/snap.ts +80 -15
- package/src/render/view.ts +6 -2
- package/src/solver/equations.ts +30 -16
- package/src/tools/dim.ts +28 -4
- package/src/tools/modify.ts +205 -69
- package/src/tools/registry.ts +8 -0
- package/src/tools/select.ts +47 -20
- package/src/ui/domPorts.ts +2 -0
- package/dist/react/LaserTray.d.ts +0 -4
- package/dist/react/LaserTray.js +0 -26
- package/dist/react/LaserTray.js.map +0 -1
- package/src/react/LaserTray.tsx +0 -42
package/src/tools/modify.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { afterEdit, holdFaces,
|
|
2
|
-
import { ed } from '../app/state';
|
|
3
|
-
import { splitFaces } from '../model/faces';
|
|
4
|
-
import { clamp, hyp,
|
|
1
|
+
import { afterEdit, holdFaces, solveSketch, tryAddConstraint, undo } from '../app/edit';
|
|
2
|
+
import { ed, type Preview } from '../app/state';
|
|
3
|
+
import { faceKey, splitFaces } from '../model/faces';
|
|
4
|
+
import { clamp, hyp, norm2, projT } from '../model/geom';
|
|
5
5
|
import { dropHistory, pushHistory } from '../model/history';
|
|
6
6
|
import { uid } from '../model/ids';
|
|
7
7
|
import { findFace, maybeRoom, roomGeom } from '../model/rooms';
|
|
8
|
-
import { addLine, addPoint } from '../model/sketch';
|
|
9
|
-
import { SK } from '../model/store';
|
|
10
|
-
import type
|
|
8
|
+
import { addCons, addLine, addPoint } from '../model/sketch';
|
|
9
|
+
import { replaceSK, SK } from '../model/store';
|
|
10
|
+
import { distTo, nearestOn, pieceAt, pieceKey, pieceShape, trimItemAt, type Cut, type TrimItem, type TrimKind, type TrimPiece } from '../model/trim';
|
|
11
|
+
import type { Constraint, Sketch, XY } from '../model/types';
|
|
11
12
|
import { hitAny } from '../render/hit';
|
|
12
13
|
import { outsideSide } from '../model/planGeom';
|
|
13
|
-
import {
|
|
14
|
+
import { TH } from '../render/theme';
|
|
15
|
+
import { mainT, requestDraw, requestOverlayDraw, S, s2w } from '../render/view';
|
|
14
16
|
import { placeTargets, snapSlide } from '../editor/elevation';
|
|
15
17
|
import { fmtArea, fmtLen } from '../units';
|
|
16
18
|
import type { PEv } from './registry';
|
|
@@ -24,82 +26,216 @@ const hoverOnly = (types: string[]) => (ev: PEv) => {
|
|
|
24
26
|
requestDraw();
|
|
25
27
|
};
|
|
26
28
|
|
|
29
|
+
/*
|
|
30
|
+
Trim (T; the rail, after Arc — on a phone, under Draw to shape): tap a piece of a line, wall, arc or circle and it
|
|
31
|
+
goes, cut back to where something crosses it or meets it on either side (model/trim.ts); drag across several and
|
|
32
|
+
each one the stroke crosses goes when it lifts. What's about to go is shown in red. One undo step a tap or a stroke.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** A piece a tap or a stroke took: where on what it's of (in the drawing), and the piece then. */
|
|
36
|
+
interface TrimMark { at: XY; pc: TrimPiece; key: string }
|
|
37
|
+
|
|
38
|
+
/** How near (inches) a point is to count as on what's trimmed, and cuts to count as one: a couple of pixels. */
|
|
39
|
+
const cutTol = (): number => Math.min(0.5, 2 / mainT().s);
|
|
40
|
+
|
|
41
|
+
/** The piece under screen point (sx, sy). */
|
|
42
|
+
function trimMarkAt(sx: number, sy: number, touch: boolean): TrimMark | null {
|
|
43
|
+
const [x, y] = s2w(sx, sy), sk = SK();
|
|
44
|
+
const it = trimItemAt(sk, { x, y }, (touch ? 20 : 10) / mainT().s);
|
|
45
|
+
if (!it) return null;
|
|
46
|
+
// (where on it: found again there as it's cut, on it or on a piece an earlier cut split off)
|
|
47
|
+
const at = nearestOn(sk, it, { x, y }), pc = pieceAt(sk, it, at, cutTol());
|
|
48
|
+
return { at, pc, key: pieceKey(pc) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What's about to be cut away, drawn over the drawing in red. */
|
|
52
|
+
const trimPreview = (pcs: TrimPiece[]): Preview => (c, T) => {
|
|
53
|
+
const sk = SK();
|
|
54
|
+
c.save();
|
|
55
|
+
c.strokeStyle = TH.red; c.lineWidth = 4; c.lineCap = 'round'; c.globalAlpha = 0.85;
|
|
56
|
+
for (const pc of pcs) {
|
|
57
|
+
const g = pieceShape(sk, pc);
|
|
58
|
+
if (!g) continue;
|
|
59
|
+
c.beginPath();
|
|
60
|
+
if ('a' in g) { const [x1, y1] = S(T, g.a.x, g.a.y), [x2, y2] = S(T, g.b.x, g.b.y); c.moveTo(x1, y1); c.lineTo(x2, y2); }
|
|
61
|
+
else { const [x, y] = S(T, g.o.x, g.o.y); c.arc(x, y, g.r * T.s, -g.t0, -g.t1, true); }
|
|
62
|
+
c.stroke();
|
|
63
|
+
}
|
|
64
|
+
c.restore();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const freshTrim = () => ({ down: null as XY | null, last: null as XY | null, stroke: false, marks: [] as TrimMark[] });
|
|
68
|
+
|
|
27
69
|
export const trimTool = {
|
|
28
|
-
|
|
29
|
-
hover
|
|
30
|
-
|
|
31
|
-
|
|
70
|
+
st: freshTrim(),
|
|
71
|
+
reset() { this.st = freshTrim(); ed.hover = null; ed.preview = null; requestOverlayDraw(); },
|
|
72
|
+
show(marks: TrimMark[]) { ed.preview = marks.length ? trimPreview(marks.map(m => m.pc)) : null; requestOverlayDraw(); },
|
|
73
|
+
hover(ev: PEv) { const m = trimMarkAt(ev.sx, ev.sy, ev.touch); this.show(m ? [m] : []); },
|
|
74
|
+
down(ev: PEv) {
|
|
75
|
+
const m = trimMarkAt(ev.sx, ev.sy, ev.touch);
|
|
76
|
+
this.st = { down: { x: ev.sx, y: ev.sy }, last: { x: ev.sx, y: ev.sy }, stroke: false, marks: m ? [m] : [] };
|
|
77
|
+
this.show(this.st.marks);
|
|
78
|
+
},
|
|
79
|
+
move(ev: PEv) {
|
|
80
|
+
const st = this.st;
|
|
81
|
+
if (!st.down) { this.hover(ev); return; }
|
|
82
|
+
if (!st.stroke && hyp(ev.sx - st.down.x, ev.sy - st.down.y) < 12) return;
|
|
83
|
+
st.stroke = true;
|
|
84
|
+
// every few pixels of the way since the last move, so a quick stroke doesn't skip a short piece
|
|
85
|
+
const from = st.last!, n = Math.max(1, Math.ceil(hyp(ev.sx - from.x, ev.sy - from.y) / 6));
|
|
86
|
+
for (let i = 1; i <= n; i++) {
|
|
87
|
+
const m = trimMarkAt(from.x + ((ev.sx - from.x) * i) / n, from.y + ((ev.sy - from.y) * i) / n, ev.touch);
|
|
88
|
+
if (m && !st.marks.some(k => k.key === m.key)) st.marks.push(m);
|
|
89
|
+
}
|
|
90
|
+
st.last = { x: ev.sx, y: ev.sy };
|
|
91
|
+
this.show(st.marks);
|
|
92
|
+
},
|
|
32
93
|
up(ev: PEv) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
else if (h.type === 'circle') { pushHistory(); delete SK().circles[h.id]; afterEdit(); }
|
|
94
|
+
const st = this.st, tap = trimMarkAt(ev.sx, ev.sy, ev.touch);
|
|
95
|
+
const marks = st.stroke ? st.marks : tap ? [tap] : [];
|
|
96
|
+
this.reset();
|
|
97
|
+
if (marks.length) trimMarks(marks);
|
|
38
98
|
},
|
|
39
|
-
hint() { return 'Tap the
|
|
99
|
+
hint() { return 'Tap the piece to cut away, or drag across several. Each cuts back to where something crosses or meets it.'; },
|
|
40
100
|
};
|
|
41
101
|
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (id === lid) continue;
|
|
50
|
-
const o = sk.lines[id];
|
|
51
|
-
const r = segInter(A, B, sk.points[o.a], sk.points[o.b]);
|
|
52
|
-
if (r && r.t > 1e-6 && r.t < 1 - 1e-6) ts.push({ t: r.t, line: id });
|
|
53
|
-
}
|
|
54
|
-
for (const id in sk.circles) { const ci = sk.circles[id]; for (const t of lineCircleT(A, B, sk.points[ci.c], ci.r)) ts.push({ t, circle: id }); }
|
|
102
|
+
/**
|
|
103
|
+
* Cut away a tap's or a stroke's pieces, as one undo step. Each is found again as it's cut — on what it was of, or on a
|
|
104
|
+
* piece an earlier cut split off — so cutting one doesn't upset the next. If the drawing can't solve after, it's put
|
|
105
|
+
* back as it was and says so.
|
|
106
|
+
*/
|
|
107
|
+
export function trimMarks(marks: TrimMark[]): void {
|
|
108
|
+
const sk = SK(), was = JSON.stringify(sk), tol = cutTol(), near = 3 * tol;
|
|
55
109
|
pushHistory();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
110
|
+
const made: TrimItem[] = [];
|
|
111
|
+
let cut = 0, whole: TrimKind | null = null;
|
|
112
|
+
for (const m of marks) {
|
|
113
|
+
const it = [m.pc.item, ...made].find(c => distTo(sk, c, m.at) <= near);
|
|
114
|
+
if (!it) continue;
|
|
115
|
+
const pc = pieceAt(sk, it, m.at, tol);
|
|
116
|
+
if (!pc.lo && !pc.hi) whole = it.kind;
|
|
117
|
+
made.push(...trimPiece(sk, pc));
|
|
118
|
+
cut++;
|
|
119
|
+
}
|
|
120
|
+
if (!cut) { dropHistory(); return; }
|
|
121
|
+
if (!solveSketch().ok) {
|
|
122
|
+
replaceSK(JSON.parse(was) as Sketch);
|
|
123
|
+
dropHistory();
|
|
124
|
+
afterEdit();
|
|
125
|
+
toast('Can’t trim that — it conflicts with other constraints.', { warn: true });
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
afterEdit();
|
|
129
|
+
// (a tap that took a whole thing: nothing crossed it, so there was nothing to cut back to)
|
|
130
|
+
if (marks.length === 1 && whole) toast((whole === 'line' ? 'Line' : whole === 'arc' ? 'Arc' : 'Circle') + ' removed — ' + (whole === 'circle' ? 'it takes two crossings to cut a piece out.' : 'nothing crossed it.'));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Cut piece `pc` away. A line or wall is shortened from an end, or split in two around a middle piece that goes (the
|
|
135
|
+
* two kept in line); an arc the same (the two one circle still); a circle opens into an arc round the rest; with no cut
|
|
136
|
+
* either side, the whole thing goes. Where a cut is a point already there, the new end is that point, so what meets
|
|
137
|
+
* there stays joined; a crossing makes a new point, held on what it crosses. Constraints carry over (product rule 9):
|
|
138
|
+
* a length, a midpoint or Equal on a cut line no longer say what they did and go. Edits the sketch only: the caller
|
|
139
|
+
* pushes history, solves and runs afterEdit. Returns what it made (a split's second piece).
|
|
140
|
+
*/
|
|
141
|
+
export function trimPiece(sk: Sketch, pc: TrimPiece): TrimItem[] {
|
|
142
|
+
const { item, lo, hi } = pc, made: TrimItem[] = [];
|
|
143
|
+
/** A cut's point: the one there, or a new one, held on what crosses there. */
|
|
144
|
+
const at = (c: Cut): string => {
|
|
145
|
+
if (c.pt) return c.pt;
|
|
146
|
+
const id = addPoint(sk, c.x, c.y);
|
|
147
|
+
if (c.line) addCons(sk, { type: 'online', p: id, l: c.line });
|
|
148
|
+
if (c.curve) addCons(sk, { type: 'oncircle', p: id, c: c.curve });
|
|
64
149
|
return id;
|
|
65
150
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
151
|
+
if (item.kind === 'line') trimLinePiece(sk, item.id, lo, hi, at, made);
|
|
152
|
+
else if (item.kind === 'arc') {
|
|
153
|
+
const a = sk.arcs[item.id];
|
|
154
|
+
if (!lo && !hi) delete sk.arcs[item.id];
|
|
155
|
+
else if (!lo) a.a = at(hi!);
|
|
156
|
+
else if (!hi) a.b = at(lo);
|
|
157
|
+
else {
|
|
158
|
+
const p1 = at(lo), p2 = at(hi), oldB = a.b, nid = uid('ar');
|
|
159
|
+
a.b = p1;
|
|
160
|
+
sk.arcs[nid] = { ...a, a: p2, b: oldB };
|
|
161
|
+
// one circle still; a tangent at its old end goes with the piece that ends there now
|
|
162
|
+
addCons(sk, { type: 'eqr', c1: item.id, c2: nid });
|
|
163
|
+
for (const c of Object.values(sk.cons)) if (c.type === 'tan' && c.c === item.id) { const l = sk.lines[c.l!]; if (l && (l.a === oldB || l.b === oldB)) c.c = nid; }
|
|
164
|
+
made.push({ kind: 'arc', id: nid });
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
const ci = sk.circles[item.id];
|
|
168
|
+
if (!lo || !hi) delete sk.circles[item.id];
|
|
169
|
+
else {
|
|
170
|
+
// what's left runs from the cut after the piece round to the one before: an arc, with the circle's id, so what
|
|
171
|
+
// refers to it (its size, a tangent, Concentric) refers to the arc
|
|
172
|
+
const { c, constr, kind, thick } = ci, a = at(hi), b = at(lo);
|
|
173
|
+
delete sk.circles[item.id];
|
|
174
|
+
sk.arcs[item.id] = { c, a, b, ...(constr ? { constr } : {}), ...(kind ? { kind } : {}), ...(thick ? { thick } : {}) };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// a point held on a line or an arc that's that line's or arc's end now: an end is on it already
|
|
178
|
+
const ids = new Set([item.id, ...made.map(m => m.id)]);
|
|
179
|
+
for (const id in sk.cons) {
|
|
180
|
+
const c = sk.cons[id], l = c.l ? sk.lines[c.l] : undefined, a = c.c ? sk.arcs[c.c] : undefined;
|
|
181
|
+
if (c.type === 'online' && !c.face && l && ids.has(c.l!) && (l.a === c.p || l.b === c.p)) delete sk.cons[id];
|
|
182
|
+
else if (c.type === 'oncircle' && a && ids.has(c.c!) && (a.a === c.p || a.b === c.p)) delete sk.cons[id];
|
|
183
|
+
}
|
|
184
|
+
return made;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function trimLinePiece(sk: Sketch, lid: string, lo: Cut | null, hi: Cut | null, at: (c: Cut) => string, made: TrimItem[]): void {
|
|
188
|
+
const l = sk.lines[lid];
|
|
189
|
+
if (!lo && !hi) { delete sk.lines[lid]; return; }
|
|
190
|
+
const A = sk.points[l.a], B = sk.points[l.b], L = hyp(B.x - A.x, B.y - A.y), oldA = l.a, oldB = l.b;
|
|
191
|
+
// its length, its middle, Equal to another: they no longer say what they did
|
|
192
|
+
for (const id in sk.cons) {
|
|
193
|
+
const c = sk.cons[id];
|
|
194
|
+
if ((c.type === 'dist' && c.line === lid) || (c.type === 'mid' && c.l === lid) || (c.type === 'eq' && (c.l1 === lid || c.l2 === lid))) delete sk.cons[id];
|
|
195
|
+
}
|
|
196
|
+
if (lo && hi) {
|
|
197
|
+
// a middle piece: split at both cuts (splitLineAt carries constraints, spaces, doors and windows, and what's on its
|
|
198
|
+
// faces) and the piece between goes; the two left stay in line
|
|
199
|
+
const p1 = at(lo), p2 = at(hi), mid = splitLineAt(sk, lid, p1), rest = mid && splitLineAt(sk, mid, p2);
|
|
200
|
+
if (!mid || !rest) return;
|
|
201
|
+
delete sk.lines[mid];
|
|
69
202
|
for (const id in sk.cons) {
|
|
70
203
|
const c = sk.cons[id];
|
|
71
|
-
|
|
72
|
-
if (c.type === '
|
|
73
|
-
if (c.type === 'mid' && c.l === lid) delete sk.cons[id];
|
|
204
|
+
const across = (c.type === 'h' || c.type === 'v') && ((c.a === p1 && c.b === p2) || (c.a === p2 && c.b === p1));
|
|
205
|
+
if (across || (c.type === 'online' && c.p === p2 && c.l === lid)) delete sk.cons[id];
|
|
74
206
|
}
|
|
75
|
-
|
|
207
|
+
addCons(sk, { type: 'col', l1: lid, l2: rest });
|
|
208
|
+
made.push({ kind: 'line', id: rest });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const hv = (c: Constraint) => (c.type === 'h' || c.type === 'v') && ((c.a === oldA && c.b === oldB) || (c.a === oldB && c.b === oldA));
|
|
76
212
|
if (!lo) {
|
|
77
|
-
|
|
213
|
+
// from its start: it starts at the cut now, and what's measured from its start is measured from there
|
|
214
|
+
const p = at(hi!), s = hi!.at * L;
|
|
78
215
|
l.a = p;
|
|
79
|
-
|
|
80
|
-
for (const id in sk.openings) { const o = sk.openings[id]; if (o.line
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
l.b = p;
|
|
84
|
-
retarget(oldA, p);
|
|
216
|
+
for (const c of Object.values(sk.cons)) if (hv(c)) { c.a = p; c.b = oldB; }
|
|
217
|
+
for (const id in sk.openings) { const o = sk.openings[id]; if (o.line !== lid) continue; if (o.at < s) delete sk.openings[id]; else o.at -= s; }
|
|
218
|
+
shiftWallFace(sk, lid, -1, -s);
|
|
219
|
+
for (const side of [1, -1]) for (const e of sk.elev?.[lid + '|' + side] ?? []) { e.a[0] -= s; e.b[0] -= s; }
|
|
85
220
|
} else {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
for (const id in sk.
|
|
91
|
-
|
|
92
|
-
if ((c.type === 'par' || c.type === 'perp' || c.type === 'col') && (c.l1 === lid || c.l2 === lid)) copies.push(Object.assign({}, c, c.l1 === lid ? { l1: nid } : { l2: nid }));
|
|
93
|
-
if (isHV(c)) copies.push({ type: c.type, a: p2, b: oldB });
|
|
94
|
-
}
|
|
95
|
-
retarget(oldA, p1);
|
|
96
|
-
for (const c of copies) tryAddConstraint(c, { silent: true });
|
|
97
|
-
tryAddConstraint({ type: 'online', p: p2, l: lid }, { silent: true });
|
|
98
|
-
tryAddConstraint({ type: 'par', l1: lid, l2: nid }, { silent: true });
|
|
99
|
-
for (const id in sk.openings) { const o = sk.openings[id]; if (o.line === lid && o.at > hi.t * L) { o.line = nid; o.at -= hi.t * L; } }
|
|
221
|
+
// to its end: it ends at the cut now
|
|
222
|
+
const p = at(lo), s = lo.at * L;
|
|
223
|
+
l.b = p;
|
|
224
|
+
for (const c of Object.values(sk.cons)) if (hv(c)) { c.a = oldA; c.b = p; }
|
|
225
|
+
for (const id in sk.openings) { const o = sk.openings[id]; if (o.line === lid && o.at > s) delete sk.openings[id]; }
|
|
226
|
+
shiftWallFace(sk, lid, 1, s - L);
|
|
100
227
|
}
|
|
101
|
-
|
|
102
|
-
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* What's drawn on one face of wall `lid`, moved across it by dx: the face's x runs from the wall's start seen from side
|
|
232
|
+
* −1, and from its end seen from side 1 (see splitFaces), so a trim moving that end moves it.
|
|
233
|
+
*/
|
|
234
|
+
function shiftWallFace(sk: Sketch, lid: string, side: 1 | -1, dx: number): void {
|
|
235
|
+
const face = sk.faces?.[faceKey(lid, side)];
|
|
236
|
+
if (!face || !dx) return;
|
|
237
|
+
delete face.wall; // (its corners are recounted at its next placing)
|
|
238
|
+
for (const p of Object.values(face.points)) if (!p.anchor) p.x += dx;
|
|
103
239
|
}
|
|
104
240
|
|
|
105
241
|
export const offsetTool = {
|
package/src/tools/registry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tryAddConstraint } from '../app/edit';
|
|
2
2
|
import { ed, type Snap } from '../app/state';
|
|
3
3
|
import { hyp } from '../model/geom';
|
|
4
|
+
import { edgeOf } from '../model/planGeom';
|
|
4
5
|
import { settings } from '../model/settings';
|
|
5
6
|
import { addPoint, WALL_THICK } from '../model/sketch';
|
|
6
7
|
import { SK } from '../model/store';
|
|
@@ -81,9 +82,16 @@ export function commitPoint(s: Snap): { id: string; cons: Constraint[] } {
|
|
|
81
82
|
else if (s.kind === 'online') cons.push({ type: 'online', p: id, l: s.ref! });
|
|
82
83
|
else if (s.kind === 'oncircle') cons.push({ type: 'oncircle', p: id, c: s.ref! });
|
|
83
84
|
else if (s.kind === 'inter' && s.refs) cons.push({ type: 'online', p: id, l: s.refs[0] }, { type: 'online', p: id, l: s.refs[1] });
|
|
85
|
+
else cons.push(...faceSnapCons(s, id));
|
|
84
86
|
return { id, cons };
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
/** A snap onto a wall's face, or where two faces meet: point `p` on that face (on each), not on the wall's centreline. */
|
|
90
|
+
export function faceSnapCons(s: Snap, p: string): Constraint[] {
|
|
91
|
+
const edges = s.kind === 'onface' && s.ref ? [s.ref] : s.kind === 'facecorner' && s.refs ? s.refs : [];
|
|
92
|
+
return edges.map(e => { const [l, face] = edgeOf(e); return { type: 'online', p, l, face }; });
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
export function applyPending(list: Constraint[]): void {
|
|
88
96
|
if (!settings.autoCons) return;
|
|
89
97
|
for (const c of list) tryAddConstraint(c, { silent: true });
|
package/src/tools/select.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { hitAny } from '../render/hit';
|
|
|
20
20
|
import { onGrid, snap45, snapAt } from '../render/snap';
|
|
21
21
|
import { linkExtent, mainT, NOTE_TEXT_IN, NOTE_TEXT_MAX_IN, NOTE_TEXT_MIN_IN, noteBox, noteTextBox, noteTextIn, paintPending, requestDraw, requestImageDraw, requestOverlayDraw, S, s2w, type HandlePart, underlayAt, underlayH, underlayLocal } from '../render/view';
|
|
22
22
|
import { solver } from '../solver';
|
|
23
|
-
import type
|
|
23
|
+
import { faceSnapCons, type PEv } from './registry';
|
|
24
24
|
import { onSessionReset } from '../model/session';
|
|
25
25
|
import { openDrawer, setCursor, toast, updateCtx, updateHint } from '../editor/ports';
|
|
26
26
|
import { selectionHint } from '../editor/selection';
|
|
@@ -32,6 +32,12 @@ import { openImageLink } from '../editor/linkActions';
|
|
|
32
32
|
*/
|
|
33
33
|
interface ArcEnd { id: string; other: string; end: 'a' | 'b'; sweep: number; closed: boolean }
|
|
34
34
|
|
|
35
|
+
/** Whether point `id` is a wall's (an end, or a curved one's centre): walls join along their centrelines, not onto faces. */
|
|
36
|
+
const wallPoint = (sk: Sketch, id: string): boolean =>
|
|
37
|
+
Object.values(sk.lines).some(l => l.kind === 'wall' && (l.a === id || l.b === id)) ||
|
|
38
|
+
Object.values(sk.arcs).some(a => a.kind === 'wall' && (a.a === id || a.b === id || a.c === id)) ||
|
|
39
|
+
Object.values(sk.circles).some(c => c.kind === 'wall' && c.c === id);
|
|
40
|
+
|
|
35
41
|
type Drag =
|
|
36
42
|
| { kind: 'point'; id: string; start: { x: number; y: number }; grab: { x: number; y: number }; snap: Snap | null; arcs: ArcEnd[] }
|
|
37
43
|
/** cab: dragging a cabinet (its box where it started): it snaps to corners, the floor, other cabinets */
|
|
@@ -54,7 +60,7 @@ type Drag =
|
|
|
54
60
|
/** several pieces of markup (and photos) selected, one of them dragged: they all move by as much */
|
|
55
61
|
| { kind: 'group'; notes: { id: string; start: Note }[]; images: { id: string; start: { x: number; y: number } }[]; grab: { x: number; y: number } }
|
|
56
62
|
| { kind: 'umove'; id: string; start: { x: number; y: number }; grab: { x: number; y: number } }
|
|
57
|
-
| { kind: 'uresize'; id: string; part: HandlePart; start:
|
|
63
|
+
| { kind: 'uresize'; id: string; part: HandlePart; start: ImageBox }
|
|
58
64
|
/** reshape markup: move an arrow end, or resize the box of a cloud / pen stroke */
|
|
59
65
|
| { kind: 'nresize'; id: string; part: string; start: Note };
|
|
60
66
|
|
|
@@ -197,8 +203,10 @@ export const selectTool = {
|
|
|
197
203
|
: st.down.touch && st.again ? h
|
|
198
204
|
: doubleTapOf(st.down, h, now);
|
|
199
205
|
const sk = SK();
|
|
200
|
-
// a corner point stands for the lines meeting there
|
|
201
|
-
|
|
206
|
+
// a corner point stands for the lines meeting there: its walls and lines, if it has any (a guide drawn off a
|
|
207
|
+
// shape's corner leaves the shape's), else its guides
|
|
208
|
+
const at = first?.type === 'point' ? Object.keys(sk.lines).filter(id => !sk.lines[id].anchor && (sk.lines[id].a === first.id || sk.lines[id].b === first.id)) : [];
|
|
209
|
+
const from = at.some(id => !sk.lines[id].constr) ? at.filter(id => !sk.lines[id].constr) : at;
|
|
202
210
|
if (first && ((first.type === 'line' && !sk.lines[first.id]?.anchor) || first.type === 'arc' || from.length)) {
|
|
203
211
|
// double tap a line or arc (or a point on one): select everything connected to it
|
|
204
212
|
const g = connectedGeometry(sk, first.type === 'line' ? [first.id] : from, first.type === 'arc' ? [first.id] : []);
|
|
@@ -449,7 +457,7 @@ function beginDrag(h: Hit, down: PEv): Drag | null {
|
|
|
449
457
|
if (!u) return null;
|
|
450
458
|
if (u.locked) { toast('This image is locked. Tap Unlock in the bar below to move or resize it.', { warn: true }); return null; }
|
|
451
459
|
if (h.type === 'underlay') return { kind: 'umove', id: u.id, start: { x: u.x, y: u.y }, grab: { x: wx, y: wy } };
|
|
452
|
-
return { kind: 'uresize', id: u.id, part: h.part as HandlePart, start: { x: u.x, y: u.y, w: u.w, h: underlayH(u) } };
|
|
460
|
+
return { kind: 'uresize', id: u.id, part: h.part as HandlePart, start: { x: u.x, y: u.y, w: u.w, h: underlayH(u), crop: u.crop } };
|
|
453
461
|
}
|
|
454
462
|
return null;
|
|
455
463
|
}
|
|
@@ -548,8 +556,8 @@ function dragTo(d: Drag, ev: PEv): void {
|
|
|
548
556
|
// here left a Shift-drag frozen on the screen until the pointer lifted)
|
|
549
557
|
if (!locked) {
|
|
550
558
|
// (an arc's end, round onto its other end: closed — see closeArcs)
|
|
551
|
-
const s = closeArcs(sk, d.arcs, snapAt(ev.sx, ev.sy, { exclude: new Set([d.id]), touch: ev.touch }), { x: wx, y: wy }, (ev.touch ? 16 : 10) / mainT().s);
|
|
552
|
-
d.snap = s.kind === 'point' || s.kind === 'mid' || s.kind === 'online' || s.kind === 'oncircle' ? s : null;
|
|
559
|
+
const s = closeArcs(sk, d.arcs, snapAt(ev.sx, ev.sy, { exclude: new Set([d.id]), touch: ev.touch, faces: !wallPoint(sk, d.id) }), { x: wx, y: wy }, (ev.touch ? 16 : 10) / mainT().s);
|
|
560
|
+
d.snap = s.kind === 'point' || s.kind === 'mid' || s.kind === 'online' || s.kind === 'oncircle' || s.kind === 'onface' || s.kind === 'facecorner' ? s : null;
|
|
553
561
|
ed.snapState = d.snap ? s : null;
|
|
554
562
|
go([d.id], [{ x: s.x, y: s.y }]);
|
|
555
563
|
}
|
|
@@ -649,7 +657,7 @@ function dragTo(d: Drag, ev: PEv): void {
|
|
|
649
657
|
if (n) n.leader = [s.x, s.y];
|
|
650
658
|
} else reshapeNote(d.id, d.part, d.start, wx, wy);
|
|
651
659
|
} else if (d.kind === 'uresize') {
|
|
652
|
-
resizeUnderlay(d.id, d.part, d.start, wx, wy
|
|
660
|
+
resizeUnderlay(d.id, d.part, d.start, wx, wy);
|
|
653
661
|
}
|
|
654
662
|
resolveOpeningsNow();
|
|
655
663
|
// on a wall face, a door or window tied to what's dragged (a dimension to a cabinet) moves on the face as it's
|
|
@@ -687,6 +695,7 @@ function endDrag(d: Drag): void {
|
|
|
687
695
|
} else if (s.kind === 'mid') tryAddConstraint({ type: sk.lines[s.ref!]?.anchor ? 'online' : 'mid', p: d.id, l: s.ref! }, { silent: !!sk.lines[s.ref!]?.anchor }); // (on a wall face's own edge: on it, free to slide)
|
|
688
696
|
else if (s.kind === 'online') tryAddConstraint({ type: 'online', p: d.id, l: s.ref! }, { silent: true });
|
|
689
697
|
else if (s.kind === 'oncircle') tryAddConstraint({ type: 'oncircle', p: d.id, c: s.ref! }, { silent: true });
|
|
698
|
+
else for (const c of faceSnapCons(s, d.id)) tryAddConstraint(c, { silent: true });
|
|
690
699
|
}
|
|
691
700
|
if (d.kind === 'point') {
|
|
692
701
|
const p = SK().points[d.id];
|
|
@@ -719,11 +728,22 @@ function joinDropped(via: string): void {
|
|
|
719
728
|
afterEdit();
|
|
720
729
|
}
|
|
721
730
|
|
|
731
|
+
/** An image's box as a drag on it began (h as it's drawn, its own or from its picture), and its crop then. */
|
|
732
|
+
interface ImageBox { x: number; y: number; w: number; h: number; crop?: Underlay['crop'] }
|
|
733
|
+
|
|
734
|
+
/** A crop as it's kept: a side trimmed by next to nothing isn't, and nothing trimmed is no crop at all. */
|
|
735
|
+
function tidyCrop(k: NonNullable<Underlay['crop']>): Underlay['crop'] {
|
|
736
|
+
const v = (n: number) => (n < 1e-6 ? 0 : n), out = { l: v(k.l), t: v(k.t), r: v(k.r), b: v(k.b) };
|
|
737
|
+
return out.l || out.t || out.r || out.b ? out : undefined;
|
|
738
|
+
}
|
|
739
|
+
|
|
722
740
|
/**
|
|
723
|
-
* Resize
|
|
724
|
-
*
|
|
741
|
+
* Resize an image from a handle. A corner scales it, its shape kept, about the opposite corner; a side crops it — the
|
|
742
|
+
* side follows the pointer, in to a sliver short of the other side, out as far as the picture's own edge. Never
|
|
743
|
+
* stretched (the user's call, 2026-11-03: "get rid of stretch - make the side bars crop"): a plan stretched would have
|
|
744
|
+
* one scale across and another down.
|
|
725
745
|
*/
|
|
726
|
-
function resizeUnderlay(id: string, part: HandlePart, s0:
|
|
746
|
+
function resizeUnderlay(id: string, part: HandlePart, s0: ImageBox, ptx: number, pty: number): void {
|
|
727
747
|
const u = imageById(id), min = 8 / mainT().s;
|
|
728
748
|
if (!u) return;
|
|
729
749
|
// worked in the image's own frame (from its middle as the drag began, unturned), so a turned image resizes along its
|
|
@@ -731,25 +751,32 @@ function resizeUnderlay(id: string, part: HandlePart, s0: { x: number; y: number
|
|
|
731
751
|
const was: Underlay = { ...u, x: s0.x, y: s0.y, w: s0.w, h: s0.h }, { x: wx, y: wy } = underlayLocal(was, ptx, pty);
|
|
732
752
|
const left = -s0.w / 2, right = s0.w / 2, top = s0.h / 2, bottom = -s0.h / 2;
|
|
733
753
|
const W = part.includes('w'), E = part.includes('e'), N = part.includes('n'), Sth = part.includes('s');
|
|
734
|
-
let
|
|
735
|
-
if (part.length === 2
|
|
736
|
-
//
|
|
754
|
+
let L = left, R = right, Tp = top, B = bottom, crop = s0.crop;
|
|
755
|
+
if (part.length === 2) {
|
|
756
|
+
// a corner: project the pointer onto the diagonal from the fixed corner
|
|
737
757
|
const ax = W ? right : left, ay = N ? bottom : top;
|
|
738
758
|
const cx = W ? left : right, cy = N ? top : bottom;
|
|
739
759
|
const dx = cx - ax, dy = cy - ay;
|
|
740
760
|
const f = Math.max(min / Math.min(s0.w, s0.h), ((wx - ax) * dx + (wy - ay) * dy) / (dx * dx + dy * dy));
|
|
741
|
-
w = s0.w * f
|
|
761
|
+
const w = s0.w * f, h = s0.h * f;
|
|
762
|
+
if (W) L = right - w; else R = left + w;
|
|
763
|
+
if (N) Tp = bottom + h; else B = top - h;
|
|
742
764
|
} else {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (
|
|
765
|
+
// a side: where the picture's own edges are, in this frame (past the crop), as far out as it can go
|
|
766
|
+
const k = s0.crop ?? { l: 0, t: 0, r: 0, b: 0 }, fw = s0.w / (1 - k.l - k.r), fh = s0.h / (1 - k.t - k.b);
|
|
767
|
+
const fl = left - k.l * fw, fr = right + k.r * fw, ft = top + k.t * fh, fb = bottom - k.b * fh;
|
|
768
|
+
if (E) R = clamp(wx, left + min, fr);
|
|
769
|
+
if (W) L = clamp(wx, fl, right - min);
|
|
770
|
+
if (N) Tp = clamp(wy, bottom + min, ft);
|
|
771
|
+
if (Sth) B = clamp(wy, fb, top - min);
|
|
772
|
+
crop = tidyCrop({ l: (L - fl) / fw, r: (fr - R) / fw, t: (ft - Tp) / fh, b: (B - fb) / fh });
|
|
747
773
|
}
|
|
748
|
-
const
|
|
774
|
+
const w = R - L, h = Tp - B, mid = underlayAt(was, (L + R) / 2, (Tp + B) / 2);
|
|
749
775
|
u.w = w;
|
|
750
776
|
u.h = h;
|
|
751
777
|
u.x = mid.x - w / 2;
|
|
752
778
|
u.y = mid.y + h / 2;
|
|
779
|
+
if (crop) u.crop = crop; else delete u.crop;
|
|
753
780
|
}
|
|
754
781
|
|
|
755
782
|
/**
|
package/src/ui/domPorts.ts
CHANGED
|
@@ -67,6 +67,8 @@ export const domPorts: EditorPorts = {
|
|
|
67
67
|
toggleImageRotation: anchor => toggleRotation(anchor as HTMLElement | undefined),
|
|
68
68
|
// (this interface has no link tiles: no host links)
|
|
69
69
|
toggleTileSize: () => {},
|
|
70
|
+
// (the harness's page has no slider for it: its hosts' editor does)
|
|
71
|
+
toggleDimSize: () => {},
|
|
70
72
|
editRoomName,
|
|
71
73
|
setCursor: cursor => { cvs.cv.style.cursor = cursor; },
|
|
72
74
|
// (this page's chrome stays put while a gesture moves)
|
package/dist/react/LaserTray.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Text, View } from 'react-native';
|
|
3
|
-
import { laser, useTrayReading } from '../editor/laser';
|
|
4
|
-
import { fmtLen } from '../units';
|
|
5
|
-
import { notify, useEditorKey } from './store';
|
|
6
|
-
import { C, FONT, shadow } from './theme';
|
|
7
|
-
import { Tap } from './motion';
|
|
8
|
-
import { createSheet } from './corners';
|
|
9
|
-
/** Readings that arrived with nothing to go to: tap one to put it on the selected line. */
|
|
10
|
-
export function LaserTray({ phone }) {
|
|
11
|
-
useEditorKey(() => (laser.on ? [laser.external, ...laser.readings.map(r => r.id + ':' + fmtLen(r.v))].join('|') : ''));
|
|
12
|
-
if (!laser.on)
|
|
13
|
-
return null;
|
|
14
|
-
return (_jsxs(View, { style: [s.tray, phone ? { left: 12, bottom: 160 } : { left: 90, bottom: 92 }], testID: "tray", children: [_jsxs(View, { style: s.head, children: [_jsx(Text, { style: s.title, children: "Laser readings" }), !laser.external && _jsx(Tap, { accessibilityRole: "button", onPress: () => { laser.on = false; laser.readings = []; notify(); }, children: _jsx(Text, { style: s.link, children: "Disconnect" }) })] }), laser.readings.length ? (_jsx(View, { style: s.chips, children: laser.readings.map(r => (_jsx(Tap, { accessibilityRole: "button", accessibilityLabel: 'Reading ' + fmtLen(r.v) + '. Tap to put it on the selected line.', onPress: () => useTrayReading(r.id), style: s.chip, children: _jsx(Text, { style: s.chipText, children: fmtLen(r.v) }) }, r.id))) })) : _jsx(Text, { style: s.help, children: "Select a wall and take a reading, or tap a reading here to put it on the selected line." })] }));
|
|
15
|
-
}
|
|
16
|
-
const s = createSheet({
|
|
17
|
-
tray: { position: 'absolute', zIndex: 23, backgroundColor: C.g1, borderRadius: 15, padding: 10, width: 250, ...shadow },
|
|
18
|
-
head: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 },
|
|
19
|
-
title: { fontFamily: FONT, fontSize: 13, fontWeight: '600', color: C.lg2 },
|
|
20
|
-
link: { fontFamily: FONT, fontSize: 12, fontWeight: '600', color: C.lblue, padding: 4 },
|
|
21
|
-
chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 },
|
|
22
|
-
chip: { height: 38, paddingHorizontal: 12, borderRadius: 8, backgroundColor: C.blue, justifyContent: 'center' },
|
|
23
|
-
chipText: { fontFamily: FONT, fontSize: 15, fontWeight: '600', color: '#fff' },
|
|
24
|
-
help: { fontFamily: FONT, fontSize: 12, color: C.g4, lineHeight: 16 },
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=LaserTray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LaserTray.js","sourceRoot":"","sources":["../../src/react/LaserTray.tsx"],"names":[],"mappings":"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"}
|
package/src/react/LaserTray.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Text, View } from 'react-native';
|
|
2
|
-
import { laser, useTrayReading } from '../editor/laser';
|
|
3
|
-
import { fmtLen } from '../units';
|
|
4
|
-
import { notify, useEditorKey } from './store';
|
|
5
|
-
import { C, FONT, shadow } from './theme';
|
|
6
|
-
import { Tap } from './motion';
|
|
7
|
-
import { createSheet } from './corners';
|
|
8
|
-
|
|
9
|
-
/** Readings that arrived with nothing to go to: tap one to put it on the selected line. */
|
|
10
|
-
export function LaserTray({ phone }: { phone: boolean }) {
|
|
11
|
-
useEditorKey(() => (laser.on ? [laser.external, ...laser.readings.map(r => r.id + ':' + fmtLen(r.v))].join('|') : ''));
|
|
12
|
-
if (!laser.on) return null;
|
|
13
|
-
return (
|
|
14
|
-
// (beside the rail on a tablet or computer, where the rail runs to the bottom of the screen)
|
|
15
|
-
<View style={[s.tray, phone ? { left: 12, bottom: 160 } : { left: 90, bottom: 92 }]} testID="tray">
|
|
16
|
-
<View style={s.head}>
|
|
17
|
-
<Text style={s.title}>Laser readings</Text>
|
|
18
|
-
{!laser.external && <Tap accessibilityRole="button" onPress={() => { laser.on = false; laser.readings = []; notify(); }}><Text style={s.link}>Disconnect</Text></Tap>}
|
|
19
|
-
</View>
|
|
20
|
-
{laser.readings.length ? (
|
|
21
|
-
<View style={s.chips}>
|
|
22
|
-
{laser.readings.map(r => (
|
|
23
|
-
<Tap key={r.id} accessibilityRole="button" accessibilityLabel={'Reading ' + fmtLen(r.v) + '. Tap to put it on the selected line.'} onPress={() => useTrayReading(r.id)} style={s.chip}>
|
|
24
|
-
<Text style={s.chipText}>{fmtLen(r.v)}</Text>
|
|
25
|
-
</Tap>
|
|
26
|
-
))}
|
|
27
|
-
</View>
|
|
28
|
-
) : <Text style={s.help}>Select a wall and take a reading, or tap a reading here to put it on the selected line.</Text>}
|
|
29
|
-
</View>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const s = createSheet({
|
|
34
|
-
tray: { position: 'absolute', zIndex: 23, backgroundColor: C.g1, borderRadius: 15, padding: 10, width: 250, ...shadow },
|
|
35
|
-
head: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 },
|
|
36
|
-
title: { fontFamily: FONT, fontSize: 13, fontWeight: '600', color: C.lg2 },
|
|
37
|
-
link: { fontFamily: FONT, fontSize: 12, fontWeight: '600', color: C.lblue, padding: 4 },
|
|
38
|
-
chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 },
|
|
39
|
-
chip: { height: 38, paddingHorizontal: 12, borderRadius: 8, backgroundColor: C.blue, justifyContent: 'center' },
|
|
40
|
-
chipText: { fontFamily: FONT, fontSize: 15, fontWeight: '600', color: '#fff' },
|
|
41
|
-
help: { fontFamily: FONT, fontSize: 12, color: C.g4, lineHeight: 16 },
|
|
42
|
-
});
|