@reekon-tools/boldr-cad 1.1.0 → 1.3.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.
@@ -0,0 +1,286 @@
1
+ import { afterEdit, analyze, tryAddConstraint } from '../app/edit';
2
+ import { ed } from '../app/state';
3
+ import { measure } from '../model/constraints';
4
+ import { hyp } from '../model/geom';
5
+ import { pushHistory } from '../model/history';
6
+ import { maybeRoom, roomGeom } from '../model/rooms';
7
+ import { onSessionReset, sessionState } from '../model/session';
8
+ import { addLine, addPoint, gc, lineBetween, pinnedPoints } from '../model/sketch';
9
+ import { page, SK, store } from '../model/store';
10
+ import { TH } from '../render/theme';
11
+ import { requestDraw, requestOverlayDraw, S, V } from '../render/view';
12
+ import { fmtArea, fmtLen } from '../units';
13
+ import { elevOpen } from '../editor/elevation';
14
+ import { keypadOpen } from '../editor/keypad';
15
+ import { drawsWalls, setMode } from '../editor/mode';
16
+ import { toast, updateCtx, updateHint } from '../editor/ports';
17
+ import { close3d } from '../editor/view3d';
18
+ import { is3d } from '../editor/view3dState';
19
+ import { anchorMark, lengthPreview, setTool } from './registry';
20
+ /*
21
+ The templator: points measured by a device in the host app (BOLDR's T1R) build the drawing directly. Each point joins
22
+ the last with a line (or a wall, with the Walls toggle on), and the drawing holds what was measured: a driving
23
+ length on every edge, and a driving angle at every corner. That fixes the shape's FORM — a later drag moves it
24
+ whole, it doesn't flex it — while leaving it free to be moved and turned into place. On a closed shape the last
25
+ edge and the corners either side of it are already set by the rest, so they come out as reference dimensions
26
+ (grey, in parentheses) rather than being refused: rule 3, and the closing edge's length still shows.
27
+
28
+ Where it lands: the device measures from itself, not from the page. The first point taken on a page puts its frame
29
+ there — that point at the middle of the screen — and every later point keeps its true place relative to it, for
30
+ the rest of the session. Kept per page and not per run on purpose: a cutout taken after its outline, from the same
31
+ setup, has to land where it really is relative to the outline, or templating it was pointless.
32
+
33
+ Points come in on the plan's own axes — x to the right, y up (render/view.ts's S) — and are placed as given. Which
34
+ way a device's angle turns is the host's business, not the editor's: the host turns its device's frame into this
35
+ one, and that's where a mirror gets in or doesn't. BOLDR's T1R turns clockwise, so the app negates y
36
+ (templatorPlanInches); passing its x = r·cos θ, y = r·sin θ straight in drew every template mirrored (seen on a device,
37
+ 2026-10-28).
38
+ */
39
+ /** How close a point has to land to the first one to close the shape: about 50 mm, inside the device's own error. */
40
+ export const SURVEY_CLOSE_IN = 2;
41
+ /** A point this close to the last one is the same point taken twice (a double press), not a new corner. */
42
+ export const SURVEY_SAME_IN = 1 / 16;
43
+ /** Each page's frame for the session: what's added to a device point to place it on the plan. */
44
+ const frames = sessionState(() => ({ byPage: {} }));
45
+ const fresh = () => ({ chain: [], captures: {} });
46
+ const withCapture = (capture) => (capture !== undefined ? { capture } : {});
47
+ /** A driving length on line `lid`, as the two points it joins are now (so nothing moves). */
48
+ function holdLength(lid, a, b, capture) {
49
+ const sk = SK(), pa = sk.points[a], pb = sk.points[b];
50
+ if (!pa || !pb)
51
+ return;
52
+ tryAddConstraint({ type: 'dist', a, b, kind: 'al', value: hyp(pb.x - pa.x, pb.y - pa.y), line: lid, driving: true, off: 0, ...withCapture(capture) }, { silent: true });
53
+ }
54
+ /**
55
+ * A corner this close to dead straight (or folded right back) is held as Collinear, not as an angle: the angle's
56
+ * equation turns on |cross|, whose slope vanishes there, so the solver reads a 180° angle as adding nothing (a
57
+ * reference dimension) and the corner is left as a hinge. Collinear says the same thing and holds it. 1e-4° is far
58
+ * outside where that happens (about 2e-6°) and far inside any real capture's spread, so a measured corner is never
59
+ * squared off by it — over a 30" edge it's a micrometre.
60
+ */
61
+ const STRAIGHT_DEG = 1e-4;
62
+ /** A driving angle at the corner where `l1` and `l2` meet, as it is now (Collinear, if it's straight). */
63
+ function holdAngle(l1, l2, capture) {
64
+ if (!l1 || !l2 || l1 === l2)
65
+ return;
66
+ const c = { type: 'angle', l1, l2, value: 0, driving: true };
67
+ c.value = measure(SK(), c);
68
+ if (c.value < STRAIGHT_DEG || c.value > 180 - STRAIGHT_DEG) {
69
+ tryAddConstraint({ type: 'col', l1, l2 }, { silent: true });
70
+ return;
71
+ }
72
+ tryAddConstraint({ ...c, ...withCapture(capture) }, { silent: true });
73
+ }
74
+ export const surveyTool = {
75
+ st: fresh(),
76
+ /** Picked up (by a point arriving with another tool in hand): a new run. */
77
+ enter() { this.st = fresh(); },
78
+ /**
79
+ * Put down by cancelTool. Deliberately NOT the end of the run: undo cancels the tool in hand before it steps back,
80
+ * and ending the run there would leave a gap after every bad point undone. The run ends on Finish, Close shape,
81
+ * Esc or Enter (key, below) — which also put the templator down — or when another tool is picked up; either way the
82
+ * next point starts a new run (enter).
83
+ */
84
+ reset() { ed.preview = null; },
85
+ busy() { return false; },
86
+ /** Esc and Enter finish the run here, before the generic Esc (which can't tell itself from undo's cancel). */
87
+ key(e) {
88
+ if ((e.key === 'Escape' || e.key === 'Enter') && this.st.chain.length) {
89
+ this.finish();
90
+ return true;
91
+ }
92
+ return false;
93
+ },
94
+ /**
95
+ * End the run: the shape stays as drawn, and the templator is put down (back to Select). Left in hand it would
96
+ * swallow every tap — it has no pointer handling, its points come from the device — so the shape just made couldn't
97
+ * be selected, and a phone's bar, which drops the "Templator" label, wouldn't even say why. The next point picks it
98
+ * up again, in the same frame. A run of one point leaves nothing (a point on its own isn't a shape).
99
+ */
100
+ finish() {
101
+ const first = this.st.chain[0];
102
+ if (first)
103
+ pinnedPoints.delete(first);
104
+ this.st = fresh();
105
+ ed.preview = null;
106
+ if (store.project) {
107
+ gc(SK());
108
+ analyze();
109
+ }
110
+ if (ed.tool === 'survey')
111
+ setTool('select');
112
+ updateCtx();
113
+ updateHint();
114
+ requestDraw();
115
+ },
116
+ /** Close the run back to its first point (the bar's Close shape, or a point taken there). */
117
+ closeShape() {
118
+ if (liveChain().length < 3)
119
+ return;
120
+ pushHistory();
121
+ closeRun(undefined);
122
+ afterEdit();
123
+ },
124
+ hint() {
125
+ return this.st.chain.length
126
+ ? 'Take the next point with your templator. Take one back at the first point to close the shape.'
127
+ : 'Take points with your templator: each one joins the last.';
128
+ },
129
+ };
130
+ /** The run's points that are still in the drawing (an undo since can have taken the last few back). */
131
+ function liveChain() {
132
+ const sk = SK(), st = surveyTool.st;
133
+ const keep = st.chain.filter(id => sk.points[id]);
134
+ if (keep.length !== st.chain.length)
135
+ st.chain = keep;
136
+ return keep;
137
+ }
138
+ /**
139
+ * The run's first and last points, marked — where the next point joins, and where one would close the shape — and,
140
+ * while the device streams its live point (setSurveyCursor), the edge the next point would make: dashed from the last
141
+ * point to it, with its length, as the tool's own screen draws it. Worked out as the overlay paints, so it follows
142
+ * the live point (and a point undone) without being set again.
143
+ */
144
+ function showRun() {
145
+ ed.preview = (c, T) => {
146
+ const sk = SK(), ch = surveyTool.st.chain.filter(id => sk.points[id]);
147
+ if (!ch.length)
148
+ return;
149
+ const last = sk.points[ch[ch.length - 1]], cur = ed.surveyCursor;
150
+ if (cur && cur.page === page().id) {
151
+ const [x1, y1] = S(T, last.x, last.y), [x2, y2] = S(T, cur.x, cur.y);
152
+ c.save();
153
+ c.strokeStyle = TH.blue;
154
+ c.lineWidth = 1.5;
155
+ c.setLineDash([6, 5]);
156
+ c.beginPath();
157
+ c.moveTo(x1, y1);
158
+ c.lineTo(x2, y2);
159
+ c.stroke();
160
+ c.restore();
161
+ lengthPreview(c, T, last, cur);
162
+ }
163
+ for (const id of new Set([ch[0], ch[ch.length - 1]])) {
164
+ const p = sk.points[id];
165
+ const [x, y] = S(T, p.x, p.y);
166
+ anchorMark(c, x, y);
167
+ }
168
+ };
169
+ requestOverlayDraw();
170
+ }
171
+ /**
172
+ * A device point on the current page's plan: the page's frame added. The page's first point or first live point,
173
+ * whichever comes first, sets the frame — that point at the middle of the screen — so the first point taken lands
174
+ * under the cursor that was showing it. (The caller has made sure no wall view is open: V() would be the wall's.)
175
+ */
176
+ function onPlan(x, y) {
177
+ const pg = page().id;
178
+ if (!frames.byPage[pg]) {
179
+ const v = V();
180
+ frames.byPage[pg] = { dx: v.cx - x, dy: v.cy - y };
181
+ }
182
+ const f = frames.byPage[pg];
183
+ return { x: x + f.dx, y: y + f.dy };
184
+ }
185
+ /**
186
+ * The device's live point, in inches on the plan's axes as takeSurveyPoint takes one, or null to hide it: a ring
187
+ * where its next point would land (render/draw.ts), plus the would-be edge while a run is open (showRun). Overlay
188
+ * only — it never touches the drawing, the undo history or React, so a host can call it many times a second.
189
+ * Whether it's showing afterwards: never in a wall view (its points belong to the plan) or a view-only drawing.
190
+ */
191
+ export function setSurveyCursor(p) {
192
+ if (!p || ed.readOnly || elevOpen() || !store.project) {
193
+ if (ed.surveyCursor) {
194
+ ed.surveyCursor = null;
195
+ requestOverlayDraw();
196
+ }
197
+ return false;
198
+ }
199
+ const at = onPlan(p.x, p.y);
200
+ ed.surveyCursor = { x: at.x, y: at.y, page: page().id };
201
+ // (an undo cancels the tool's preview: the run's would-be edge comes back with the next live point)
202
+ if (ed.tool === 'survey' && !ed.preview && surveyTool.st.chain.length)
203
+ showRun();
204
+ else
205
+ requestOverlayDraw();
206
+ return true;
207
+ }
208
+ /** Close the run: the last edge back to the first point, its length, the two corners it makes, and a space. */
209
+ function closeRun(capture) {
210
+ const sk = SK(), st = surveyTool.st, ch = st.chain;
211
+ const first = ch[0], last = ch[ch.length - 1];
212
+ const lid = addLine(sk, last, first, { kind: drawsWalls() ? 'wall' : 'line', constr: !drawsWalls() && ed.drawConstr });
213
+ // (already set by the rest of the shape: these come out as reference dimensions)
214
+ holdLength(lid, last, first, capture ?? st.captures[first]);
215
+ holdAngle(lineBetween(sk, ch[ch.length - 2], last), lid, st.captures[last]);
216
+ holdAngle(lid, lineBetween(sk, first, ch[1]), st.captures[first]);
217
+ const n = ch.length, rid = drawsWalls() || !ed.drawConstr ? maybeRoom(sk, ch.slice()) : null;
218
+ surveyTool.finish();
219
+ toast(rid ? sk.rooms[rid].name + ' added — ' + fmtArea(roomGeom(sk, sk.rooms[rid]).area) : 'Closed shape, ' + n + ' sides');
220
+ }
221
+ /**
222
+ * A point from the host's device, in inches, on the plan's axes — y up (see the note at the top). Starts the
223
+ * templator if it isn't in hand, and the run's frame on a page with none yet. False when the drawing can't take it
224
+ * now (the toast says why).
225
+ */
226
+ export function takeSurveyPoint(x, y, capture) {
227
+ if (ed.readOnly)
228
+ return false;
229
+ if (elevOpen()) {
230
+ toast('Back out of the wall view to take templator points on the plan.', { warn: true });
231
+ return false;
232
+ }
233
+ if (keypadOpen()) {
234
+ toast('Close the keypad, then take the point again.', { warn: true });
235
+ return false;
236
+ }
237
+ // (the templator works on the plan: from the 3D tab or Annotate, back to Draft)
238
+ if (is3d())
239
+ close3d();
240
+ if (ed.mode !== 'draft')
241
+ setMode('draft');
242
+ if (ed.tool !== 'survey')
243
+ setTool('survey');
244
+ const sk = SK(), st = surveyTool.st, ch = liveChain();
245
+ const { x: wx, y: wy } = onPlan(x, y);
246
+ const last = ch.length ? sk.points[ch[ch.length - 1]] : null;
247
+ if (last && hyp(wx - last.x, wy - last.y) < SURVEY_SAME_IN) {
248
+ toast('Same point as the last one — move the templator, then take the next.', { warn: true });
249
+ return false;
250
+ }
251
+ if (ch.length >= 3) {
252
+ const p0 = sk.points[ch[0]];
253
+ if (hyp(wx - p0.x, wy - p0.y) < SURVEY_CLOSE_IN) {
254
+ pushHistory();
255
+ closeRun(capture);
256
+ afterEdit();
257
+ return true;
258
+ }
259
+ }
260
+ pushHistory();
261
+ const id = addPoint(sk, wx, wy);
262
+ if (capture !== undefined)
263
+ st.captures[id] = capture;
264
+ if (!ch.length) {
265
+ // (on its own until the next point, garbage collection would take it: kept until the run ends)
266
+ pinnedPoints.add(id);
267
+ }
268
+ else {
269
+ const prev = ch[ch.length - 1];
270
+ const lid = addLine(sk, prev, id, { kind: drawsWalls() ? 'wall' : 'line', constr: !drawsWalls() && ed.drawConstr });
271
+ holdLength(lid, prev, id, capture);
272
+ if (ch.length >= 2)
273
+ holdAngle(lineBetween(sk, ch[ch.length - 2], prev), lid, st.captures[prev]);
274
+ }
275
+ st.chain.push(id);
276
+ ed.sel = [];
277
+ afterEdit();
278
+ showRun();
279
+ updateHint();
280
+ const n = st.chain.length, a = sk.points[st.chain[n - 2]];
281
+ toast(n === 1 ? 'Templator: point 1, at the middle of the screen' : 'Point ' + n + ' · ' + fmtLen(hyp(wx - a.x, wy - a.y)));
282
+ return true;
283
+ }
284
+ // a new session (another drawing): every page's frame and the run start again
285
+ onSessionReset(() => { surveyTool.st = fresh(); });
286
+ //# sourceMappingURL=survey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"survey.js","sourceRoot":"","sources":["../../src/tools/survey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,O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ad",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "BOLDR's 2D layout editor (React Native, iOS/Android/web) and how its drawings are kept in BOLDR.",
5
5
  "author": "REEKON Tools",
6
6
  "license": "MIT",
package/src/app/state.ts CHANGED
@@ -69,6 +69,11 @@ export const ed = sessionState(() => ({
69
69
  snapState: null as Snap | null,
70
70
  boxSel: null as BoxSel | null,
71
71
  preview: null as Preview | null,
72
+ /**
73
+ * The templating device's live point (surveyCursor): where its next point would land, on that page's plan. Its own
74
+ * overlay layer rather than `preview`, which belongs to the tool in hand — the cursor shows whatever tool that is.
75
+ */
76
+ surveyCursor: null as { x: number; y: number; page: string } | null,
72
77
  highlight: new Set<string>(),
73
78
  conflictTint: false,
74
79
  /** tap targets from the last painted frame (whoever paints stores drawPlan()'s result here) */
@@ -13,6 +13,7 @@ import { convertNote } from '../tools/annotate';
13
13
  import { cornerAngle, dimCurve, dimEdges, dimLine, dimPointLine, dimPoints, dimTwoLines, editDim, faceChoices, onChoice, setDimFace, toggleRef } from '../tools/dim';
14
14
  import { edgeLabel, edgeOf } from '../model/planGeom';
15
15
  import type { LineTool } from '../tools/line';
16
+ import type { SurveyTool } from '../tools/survey';
16
17
  import { offsetPrompt, splitLine } from '../tools/modify';
17
18
  import { filletable, filletPrompt } from '../tools/fillet';
18
19
  import { chamferPrompt } from '../tools/chamfer';
@@ -128,6 +129,15 @@ function ctxItems(): CtxEntry[] {
128
129
  // drawing: no bar (tap the last point again to finish, the first to close the shape; Esc or Enter on a keyboard)
129
130
  if (st.start) return items;
130
131
  }
132
+ if (ed.tool === 'survey') {
133
+ // The templator: its points come from the device, not from taps on the drawing — so unlike Line, nothing on the
134
+ // canvas can finish or close a run, and the bar has to. (A phone's bar drops the label; the toasts name it there.)
135
+ const n = (tools.survey as SurveyTool).st.chain.length;
136
+ items.push({ lbl: 'Templator' });
137
+ if (n >= 3) add('closeShape', 'Close shape', 'closeShape');
138
+ if (n >= 1) add('finish', 'Finish', 'finish');
139
+ return items;
140
+ }
131
141
  if (ed.tool === 'dim') { add('dim', 'Driving', 'dimDrive', { on: ed.dimLayer === 'drive' }); add('ref', 'Print', 'dimPrint', { on: ed.dimLayer === 'print' }); return items; }
132
142
  // nothing selected: the bar stays empty (Fit and Icons live in the top bar; grid snap and auto-constrain in Settings).
133
143
  // Just placed a door, window or cabinet (its tool still on): its bar, for its sizes
@@ -455,8 +465,9 @@ export function applyCtxAction(act: string, anchor?: unknown): void {
455
465
  break;
456
466
  case 'showcons': settings.showCons = !settings.showCons; updateTopBar(); break;
457
467
  case 'typelen': (tools[ed.tool] as LineTool).typeLength(''); return;
458
- case 'closeShape': (tools[ed.tool] as LineTool).closeShape(); updateCtx(); return;
459
- case 'finish': (tools[ed.tool] as LineTool).finish(); updateCtx(); return;
468
+ // (the Line tool's, or the templator's: both close and finish a run of points)
469
+ case 'closeShape': (tools[ed.tool] as LineTool | SurveyTool).closeShape(); updateCtx(); return;
470
+ case 'finish': (tools[ed.tool] as LineTool | SurveyTool).finish(); updateCtx(); return;
460
471
  case 'dimDrive': ed.dimLayer = 'drive'; break;
461
472
  case 'dimPrint': ed.dimLayer = 'print'; break;
462
473
  case 'h': case 'v': case 'par': case 'perp': case 'col': case 'eq': case 'mid': case 'online': case 'oncircle': case 'tan': case 'eqr': case 'conc':
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ export type { CadDataProvider, CadFileMeta, CadMeasurements, CadMeasurementValue
10
10
  export type { Unit } from './units';
11
11
  export { memoryProvider } from './data/memory';
12
12
  export { setFileSaver } from './react/ports';
13
- export { laserReading, setLaserConnected } from './react/host';
13
+ export { laserReading, setLaserConnected, surveyCursor, surveyPoint } from './react/host';
14
14
  export type { HostKeypad, HostKeypadExtra, HostKeypadRequest, MeasurementList, MeasurementListPage } from './react/hostKeypad';
15
15
  export type { CadLinkPick, CadLinks, CadSaveMeasurement, MeasurementKind } from './editor/links';
16
16
  export type { LinkInfo, LinkTarget } from './model/types';
package/src/react/host.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { applyReading, laser } from '../editor/laser';
2
2
  import { store } from '../model/store';
3
+ import { setSurveyCursor, takeSurveyPoint } from '../tools/survey';
3
4
  import { notify } from './store';
4
5
 
5
6
  /*
6
7
  For the host app's measuring devices (BOLDR's Bluetooth lasers and tapes): say when one is connected, and pass its
7
- readings in. A reading goes into an open keypad, onto the one selected wall or line, or into the tray.
8
+ readings in. A reading goes into an open keypad, onto the one selected wall or line, or into the tray. A templating
9
+ device's points (surveyPoint) build the drawing itself.
8
10
  */
9
11
 
10
12
  /** Whether an editor is on screen (CadEditor sets it): readings that arrive after it closed are left to the host. */
@@ -30,3 +32,33 @@ export function laserReading(inches: number, capture?: unknown): boolean {
30
32
  notify();
31
33
  return true;
32
34
  }
35
+
36
+ /**
37
+ * A point measured by a templating device (BOLDR's T1R), in inches, on the plan's axes: x to the right, y UP. Turning
38
+ * the device's own frame into that is the host's job, and it's where the handedness goes: a device whose angle turns
39
+ * clockwise (the T1R's does) has to negate y, or every template is drawn mirrored. Each point joins the last, with its length and the
40
+ * corner's angle held (src/tools/survey.ts). The first one on a page lands at the middle of the screen, and the rest
41
+ * keep their true place relative to it for the session. False when no drawing is open to take it, or it can't now
42
+ * (a wall view or keypad open: the editor says so). `capture`: the host's record of the point, kept with the
43
+ * dimensions it sets and handed back on Save to group, as laserReading's is.
44
+ */
45
+ export function surveyPoint(x: number, y: number, capture?: unknown): boolean {
46
+ if (!editorHost.open || !store.project || !Number.isFinite(x) || !Number.isFinite(y)) return false;
47
+ const ok = takeSurveyPoint(x, y, capture);
48
+ notify();
49
+ return ok;
50
+ }
51
+
52
+ /**
53
+ * The templating device's live point — where its next surveyPoint would land — on the same axes as surveyPoint, or
54
+ * null to hide it (the device stopped, its reading went stale, the host left the screen). Drawn as a ring, with the
55
+ * edge the next point would make while a run is open. The first live point on a page sets the page's frame as a first
56
+ * surveyPoint would, so the point taken next lands under the ring. Overlay only: no undo step, no React render, so it
57
+ * can be called on every notification (BOLDR's T1R streams it at 20 Hz). Whether it's showing afterwards: never with
58
+ * no drawing open, in a wall view, or in a view-only drawing.
59
+ */
60
+ export function surveyCursor(point: { x: number; y: number } | null): boolean {
61
+ if (!editorHost.open || !store.project) return false;
62
+ const ok = point && Number.isFinite(point.x) && Number.isFinite(point.y) ? point : null;
63
+ return setSurveyCursor(ok);
64
+ }
@@ -1201,11 +1201,28 @@ function paintWall(ctx: C2D, W: number, fixed: C2D): void {
1201
1201
  drawKeyPlan(fixed, W - k - 14, 70, k, plan, f);
1202
1202
  }
1203
1203
 
1204
+ /**
1205
+ * The templating device's live point (tools/survey.ts setSurveyCursor): a ring with a dot, where its next point would
1206
+ * land. Screen-sized, so it reads the same at any zoom. Only on the plan it was placed on: a wall view has other axes.
1207
+ */
1208
+ function drawSurveyCursor(ctx: C2D, T: Xform): void {
1209
+ const c = ed.surveyCursor;
1210
+ if (!c || elevOpen() || c.page !== page().id) return;
1211
+ const [x, y] = S(T, c.x, c.y);
1212
+ ctx.save();
1213
+ ctx.setLineDash([]); ctx.lineWidth = 2; ctx.strokeStyle = TH.blue; ctx.fillStyle = TH.blue;
1214
+ ctx.beginPath(); ctx.arc(x, y, 10, 0, Math.PI * 2); ctx.stroke();
1215
+ ctx.beginPath(); ctx.arc(x, y, 2.5, 0, Math.PI * 2); ctx.fill();
1216
+ ctx.restore();
1217
+ }
1218
+
1204
1219
  function paintOverlay(ctx: C2D, W: number, H: number, fixed: C2D = ctx): void {
1205
1220
  const T = mainT();
1206
1221
  // a selected image's outline and handles: with the moving parts, as it's turned, moved or sized (over the drawing)
1207
1222
  drawUnderlaySelection(ctx, T);
1208
1223
  if (ed.preview) ed.preview(ctx, T);
1224
+ // (over the tool's preview — the templator's would-be edge runs into it — whatever tool is in hand)
1225
+ drawSurveyCursor(ctx, T);
1209
1226
  drawSnap(ctx, T);
1210
1227
  if (ed.boxSel) {
1211
1228
  const { x0, y0, x1, y1 } = ed.boxSel;
@@ -10,10 +10,12 @@ import { ed } from '../app/state';
10
10
  import { tools } from './registry';
11
11
  import { selectTool } from './select';
12
12
  import { arcTool, circleTool, rectTool } from './shapes';
13
+ import { surveyTool } from './survey';
13
14
  import { cabinetTool, heightTool, wallDoorTool, wallWindowTool } from '../editor/elevation';
14
15
 
15
16
  export { tools, setTool, cancelTool } from './registry';
16
17
  export type { LineTool } from './line';
18
+ export type { SurveyTool } from './survey';
17
19
 
18
20
  /** Register every tool. Called once from main (not at import time, so import cycles stay harmless). */
19
21
  export function registerTools(): void {
@@ -31,6 +33,8 @@ export function registerTools(): void {
31
33
  door: Object.assign({}, openingTool, { enter() { ed.openingType = 'door'; } }),
32
34
  window: Object.assign({}, openingTool, { enter() { ed.openingType = 'window'; } }),
33
35
  room: roomTool,
36
+ // the templator: not on the rail — a point from the host's device picks it up (see react/host.ts surveyPoint)
37
+ survey: surveyTool,
34
38
  aselect: makeAselectTool(),
35
39
  // markup tools: a press on a handle of the just-drawn markup reshapes it instead of drawing new
36
40
  pen: withHandles(penTool),