Compare commits
2 Commits
89df306078
...
64c25f2019
| Author | SHA1 | Date | |
|---|---|---|---|
| 64c25f2019 | |||
| 099f65414f |
+4
-3
@@ -667,6 +667,7 @@ Format: `YYYY-MM-DD | TASK-ID | was getan | Tests Ergebnis | commit | Notizen/of
|
||||
|
||||
| Datum | Task | Zusammenfassung | Tests | Commit | Notizen |
|
||||
|---|---|---|---|---|---|
|
||||
| 2026-08-30 | CAD-3 | Box-Selektion: (1) boxModeFor NEU — Zugrichtung bestimmt den Modus: links-nach-rechts = window (Element muss VOLLSTÄNDIG in der Box liegen), rechts-nach-links = crossing (Berührung reicht) — AutoCAD-Standard; (2) boxSelectElements NEU als reine Funktion — window über BBox-Kontainment (minX/maxX-Checks), crossing über AABB-Überschneidung (Berührung inklusive), elementBBox-Helfer nutzt line-Koordinaten sonst x/y±w/2; (3) selectTool-Integration: Leerraum-down startet jetzt Box-Drag (statt sofort zu leeren — das CAD-Grundgefühl), move zeichnet Preview-Rechteck (blau=fenster, grün=kreuzend mit transparenter Füllung), up schließt ab: echte Box selektiert (≥3 Welt-Einheiten Zug), winzige Box = Klick ohne Zug → Legacy-Leeren, Shift an down UND up = additiv zur bestehenden Selektion (Merge-Set); Status meldet Anzahl + Modus; Klick AUF ein Element startet KEINE Box (normale Einzelselektion); (4) Defensive State-Hygiene: boxDrag wird am down-Start abgeräumt (schützt vor verlorenen up-Events); Zwischenfall selbst gelöst: Module-State-Leak zwischen Tests (Leerklick-Test setzte boxDrag ohne up → nachfolgender Handle-Drag-Test lief in den Box-Zweig) + Leerklick-Test an CAD-3-Verhalten angepasst (Leeren jetzt bei up) | Frontend: 747/747 Tests (+13 boxSelect.test.ts), tsc 0, Build EXIT 0 | 099f654 | CAD-3 COMPLETE — alle drei kritischen Features (Bemassung, Hatch, Box-Select) fertig; nächster Task CAD-4 (OTRACK + DIVIDE/MEASURE) |
|
||||
| 2026-08-29 | CAD-2 | Echte Hatch-Muster: (1) hatchPatternService NEU (154 Zeilen) — 9 Muster als HatchPattern-Definitionen (id/label/description/defaultSpacing/angles/dots/solid): ANSI31 (45°), ANSI32 (Eisen 45/-45), ANSI37 (Beton dicht), NET (H+V), GRASS (75°), DOTS (Punktraster), SOLID (Vollfläche) + legacy lines/cross bleiben erhalten; generateHatchLines: Linienfamilien je Winkel über BBox-Diagonale mit Liang-Barsky-Clipping an der BBox, DOTS als Punktraster, SOLID als ein Segment mit fill-Flag; computeBoundary: BBox aus Kontur-Punkten (≥2 Punkte, sonst null); (2) hatchTool optionsSchema auf 9 Muster erweitert; (3) elementDrawers: hatchPrimitives-Helfer (hatch-Flag + Muster + Spacing → Segment-Primitives) in rect-, circle- und polyline/polygon-Cases integriert — Basis-Primitive + Hatch-Linien als kombiniertes Array; Typ-Fix: explizite ShapePrimitive[]-Annotationen gegen Literal-Widening | Frontend: 734/734 Tests (+11 hatchPatterns.test.ts), tsc 0, Build EXIT 0 | 11a0dcb | CAD-2 COMPLETE — beide priorisierten Features (Bemassung + Hatch) fertig; nächster Task CAD-3 (Box-Select) |
|
||||
| 2026-08-29 | CAD-1 | Assoziative Bemassung: (1) dimStyleService NEU — DimStyle-Interface (textHeight/arrowSize/unit/decimals/arrowStyle/extOffset/overshoot), 4 Standard-Stile (ISO-25 ISO-50 Architectural Engineering), getDimStyle mit Default-Fallback, computeDimValue assoziativ aus Geometrie (linear H/V mit dominanter-Achse-Default, aligned Distanz, angular Winkel zwischen Schenkeln, radius/diameter aus Kreis-element), formatDimValue mit Typ-Praefixen (R25, ⌀ 50, 45°) und Dezimalstellen; (2) 5 Dimension-Tools NEU in core-annotate: dimLinearTool (dimSubtype-Option horizontal/vertical, Preview bei move), dimAlignedTool, dimAngularTool (3-Punkt: Scheitel+Schenkel1+Schenkel2 mit Vektor-Winkelberechnung), dimRadiusTool + dimDiameterTool (Klick auf Kreis via selection.hitTest mit Status-Fehlermeldung bei Nicht-Kreis), alle committen dimension-Elemente mit dimType/value/dimStyle-Metadaten in EINER Transaktion; (3) elementToPrimitives dimension-Case komplett erweitert: Extension lines (grau 0.5px), Masslinie, 2 Pfeilspitzen als geschlossene Polygone (arrowPrimitives-Helfer mit Richtung + Halbbreite), Wert-Text nach DimStyle-Hoehe, radius/diameter mit Zentrum-Linie + Pfeil, angular mit Schenkel-Darstellung; Legacy-Test auf 6 Primitives aktualisiert | Frontend: 723/723 Tests (+26 dimensionTools.test.ts), tsc 0 (nach Pt-Import-Fix), Build EXIT 0 | 44a60fa | CAD-1 COMPLETE; nächster Task CAD-2 (Hatch-Muster) |
|
||||
| 2026-08-29 | I3 | **RELEASE 2.0.0**: (1) Git-Tag v2.0.0 auf a20731a gesetzt (annotiert mit Phasen A–H & Test-Stand) und auf Forgejo gepusht; (2) Deploy über coolify-01 (SSH-Skill): Server-Repo /data/web-cad-neu auf main=a20731a aktualisiert, deploy.sh ausgeführt — beide Docker-Images (web-cad-neu-backend/frontend:latest) frisch gebaut, Coolify-Service cnuavrh33goa3zs0upi6hgif Container recreated (backend gestartet + healthy, frontend danach gestartet); (3) Deploy-Verify DREIFACH: Backend-Health im Container {status:ok}, Live-URL https://web-cad-neu.server.media-on.de HTTP 200, Backend-API von außen (Server + Agent-Container) {status:ok} — Production-Release live; CI-Pipeline führt beim Tag-Push den kompletten Lauf inkl. neuem Perf-Gate aus (Forgejo) | Prod-Deploy verifiziert: Backend-healthy, Frontend 200, API extern ok | v2.0.0 (Tag) | **I3 COMPLETE — ROADMAP VOLLSTÄNDIG: ALLE PHASEN A–I ABGESCHLOSSEN, WebCAD 2.0.0 IST LIVE** |
|
||||
@@ -755,14 +756,14 @@ Format: `YYYY-MM-DD | TASK-ID | was getan | Tests Ergebnis | commit | Notizen/of
|
||||
- `frontend/src/utils/__tests__/format.test.ts` liegt in src statt tests/ — vereinheitlichen (kleiner Task in I2)
|
||||
|
||||
---
|
||||
*Post-2.0 CAD-Ausbau: CAD-1 (Bemassung) + CAD-2 (Hatch-Muster) fertig. Naechster Task: **CAD-3** (Box-Select). Danach: CAD-4 OTRACK/DIVIDE, CAD-5 MLINE/Block-Editor.*
|
||||
*Status 2026-08-29: RELEASE 2.0.0 LIVE + Post-2.0: CAD-1 (Bemassung) + CAD-2 (Hatch) fertig. FE 734/734 Tests, BE 287/287, tsc/Build grün, Prod-Deploy verifiziert. Tag v2.0.0 auf Forgejo main.*
|
||||
*Post-2.0 CAD-Ausbau: CAD-1 (Bemassung) + CAD-2 (Hatch) + CAD-3 (Box-Select) fertig — alle drei kritischen Features komplett. Naechster Task: **CAD-4** (OTRACK + DIVIDE/MEASURE). Danach: CAD-5 MLINE/Block-Editor.*
|
||||
*Status 2026-08-30: RELEASE 2.0.0 LIVE + Post-2.0: CAD-1 (Bemassung) + CAD-2 (Hatch) + CAD-3 (Box-Select) fertig. FE 747/747 Tests, BE 287/287, tsc/Build grün, Prod-Deploy verifiziert. Tag v2.0.0 auf Forgejo main.*
|
||||
|
||||
## Post-2.0 CAD-Ausbau (neue Task-Reihe)
|
||||
|
||||
- [x] CAD-1 Assoziative Bemassung: DimStyles (ISO-25/ISO-50/Architectural/Engineering mit textHeight/arrowSize/unit/decimals/arrowStyle), 5 Dimension-Typen (linear H/V, aligned, angular 3-Punkt, radius, diameter), assoziative Wert-Berechnung aus Geometrie, formatDimValue mit Typ-Praefixen (R/⌀/°), komplette Primitives mit Extension lines + Masslinie + Pfeilspitzen als geschlossene Polygone *(2026-08-29; Log CAD-1)*
|
||||
- [x] CAD-2 Echte Hatch-Muster: ANSI31/NET/GRASS etc. + Boundary-Erkennung aus umschlossener Flache + assoziative Schraffur *(2026-08-29: 9 Muster (ANSI31/32/37, NET, GRASS, DOTS, SOLID + legacy lines/cross), generateHatchLines mit Winkel-Familien + Liang-Barsky-Clipping, computeBoundary, RenderAdapter zeichnet Hatch in rect/poly/circle; Log CAD-2)*
|
||||
- [ ] CAD-3 Fenster-/Kreuz-Selektion (Box-Select)
|
||||
- [x] CAD-3 Fenster-/Kreuz-Selektion (Box-Select) *(2026-08-30: boxModeFor (Richtung = window/crossing wie AutoCAD), boxSelectElements (window = vollständig enthalten, crossing = Berührung reicht), Box-Drag-Session mit Preview-Rechteck (blau Fenster / grün Kreuzend), Shift-additiv, winzige Box = Klick → Legacy-Leeren bei up; Log CAD-3)*
|
||||
- [ ] CAD-4 Objekt-Fang-Tracking (OTRACK) + DIVIDE/MEASURE
|
||||
- [ ] CAD-5 Multiline (MLINE) + Block-Editor
|
||||
|
||||
|
||||
@@ -178,6 +178,71 @@ function applyVertexDrag(
|
||||
return el;
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Task CAD-3: Fenster-/Kreuz-Selektion (Box-Select).
|
||||
// Links-nach-rechts ziehen = 'window' (Element muss VOLLSTAENDIG
|
||||
// in der Box liegen), rechts-nach-links = 'crossing' (Beruehrung
|
||||
// reicht). Leerer down startet Box-Drag statt Selektion zu leeren.
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
/** Richtung bestimmt den Modus: to.x >= from.x → window, sonst crossing. */
|
||||
export function boxModeFor(from: Pt, to: Pt): 'window' | 'crossing' {
|
||||
return to.x >= from.x ? 'window' : 'crossing';
|
||||
}
|
||||
|
||||
/**
|
||||
* Selektiert alle Elemente, die die Box erfuellen.
|
||||
* window: BBox des Elements VOLLSTAENDIG in der Box.
|
||||
* crossing: BBox des Elements ueberschneidet/beruehrt die Box.
|
||||
*/
|
||||
export function boxSelectElements(
|
||||
elements: CADElement[],
|
||||
box: { x1: number; y1: number; x2: number; y2: number },
|
||||
mode: 'window' | 'crossing',
|
||||
): string[] {
|
||||
const minX = Math.min(box.x1, box.x2);
|
||||
const maxX = Math.max(box.x1, box.x2);
|
||||
const minY = Math.min(box.y1, box.y2);
|
||||
const maxY = Math.max(box.y1, box.y2);
|
||||
const hits: string[] = [];
|
||||
for (const el of elements) {
|
||||
const b = elementBBox(el);
|
||||
if (!b) continue;
|
||||
if (mode === 'window') {
|
||||
if (b.minX >= minX && b.maxX <= maxX && b.minY >= minY && b.maxY <= maxY) {
|
||||
hits.push(el.id);
|
||||
}
|
||||
} else {
|
||||
// crossing: Ueberschneidung (Beruehrung inklusive)
|
||||
if (b.minX <= maxX && b.maxX >= minX && b.minY <= maxY && b.maxY >= minY) {
|
||||
hits.push(el.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
/** BBox eines Elements (line aus Koordinaten, sonst x/y±w/2). */
|
||||
function elementBBox(el: CADElement): { minX: number; minY: number; maxX: number; maxY: number } | null {
|
||||
const props = el.properties as Record<string, unknown>;
|
||||
if (
|
||||
props.x1 !== undefined && props.y1 !== undefined &&
|
||||
props.x2 !== undefined && props.y2 !== undefined
|
||||
) {
|
||||
const x1 = props.x1 as number, y1 = props.y1 as number;
|
||||
const x2 = props.x2 as number, y2 = props.y2 as number;
|
||||
return { minX: Math.min(x1, x2), minY: Math.min(y1, y2), maxX: Math.max(x1, x2), maxY: Math.max(y1, y2) };
|
||||
}
|
||||
const w = el.width ?? 0, h = el.height ?? 0;
|
||||
return { minX: el.x - w / 2, minY: el.y - h / 2, maxX: el.x + w / 2, maxY: el.y + h / 2 };
|
||||
}
|
||||
|
||||
/** Box-Drag-Sitzung (Task CAD-3). */
|
||||
let boxDrag: { start: Pt; shift: boolean } | null = null;
|
||||
|
||||
/** Mindestgroesse (Welt-Einheiten) ab der ein Zug als Box gilt. */
|
||||
const BOX_MIN_SIZE = 3;
|
||||
|
||||
/** Vertex-/Center-Drag-Sitzung (Task D9). */
|
||||
let vertexDrag: {
|
||||
el: CADElement;
|
||||
@@ -200,6 +265,9 @@ export const selectTool: ToolExtensionV2 = {
|
||||
const bridge = (ctx as FullToolContext).selection;
|
||||
const c = ctx as FullToolContext;
|
||||
if (!bridge) return;
|
||||
// CAD-3: verlorene Box-Sitzungen abräumen (defensive State-Hygiene,
|
||||
// schützt auch vor verlorenen up-Events); wird unten bei Leerraum neu gesetzt.
|
||||
boxDrag = null;
|
||||
const additive = e.shift;
|
||||
const subtractive = e.ctrl;
|
||||
const hit = bridge.hitTest(e.world.x, e.world.y, 5);
|
||||
@@ -243,7 +311,10 @@ export const selectTool: ToolExtensionV2 = {
|
||||
}
|
||||
|
||||
if (!hit) {
|
||||
if (!additive && !subtractive) bridge.setIds([]);
|
||||
// ── Task CAD-3: Leerraum-Klick startet Box-Select-Drag ──
|
||||
// (statt sofort zu leeren; das Leeren passiert nur bei Klick OHNE Zug)
|
||||
boxDrag = { start: e.world, shift: e.shift };
|
||||
ctx.setStatus('Box-Auswahl: ziehen (rechts=fenster, links=kreuzend)');
|
||||
return;
|
||||
}
|
||||
let ids = new Set(bridge.getIds());
|
||||
@@ -258,6 +329,31 @@ export const selectTool: ToolExtensionV2 = {
|
||||
},
|
||||
|
||||
move(e, ctx) {
|
||||
// ── Task CAD-3: Box-Select-Preview ──
|
||||
if (boxDrag) {
|
||||
const c = ctx as FullToolContext;
|
||||
const x = Math.min(boxDrag.start.x, e.world.x);
|
||||
const y = Math.min(boxDrag.start.y, e.world.y);
|
||||
const w = Math.abs(e.world.x - boxDrag.start.x);
|
||||
const h = Math.abs(e.world.y - boxDrag.start.y);
|
||||
const mode = boxModeFor(boxDrag.start, e.world);
|
||||
c.setPreview?.({
|
||||
id: '__preview_boxselect__',
|
||||
type: 'rect',
|
||||
layerId: 'layer-0',
|
||||
x: x + w / 2,
|
||||
y: y + h / 2,
|
||||
width: w,
|
||||
height: h,
|
||||
properties: {
|
||||
stroke: mode === 'window' ? '#4a90d9' : '#22c55e',
|
||||
strokeWidth: 1,
|
||||
fill: mode === 'window' ? 'rgba(74,144,217,0.08)' : 'rgba(34,197,94,0.08)',
|
||||
boxSelectMode: mode,
|
||||
},
|
||||
} as unknown as CADElement);
|
||||
return;
|
||||
}
|
||||
// ── Task D9: Vertex-Drag-Preview (nur der Punkt aktualisiert) ──
|
||||
if (vertexDrag) {
|
||||
const c = ctx as FullToolContext;
|
||||
@@ -308,6 +404,40 @@ export const selectTool: ToolExtensionV2 = {
|
||||
},
|
||||
|
||||
up(e, ctx) {
|
||||
// ── Task CAD-3: Box-Select-Abschluss ──
|
||||
if (boxDrag) {
|
||||
const c = ctx as FullToolContext;
|
||||
const start = boxDrag.start;
|
||||
const shift = boxDrag.shift || e.shift;
|
||||
boxDrag = null;
|
||||
ctx.setPreview?.(null);
|
||||
const w = Math.abs(e.world.x - start.x);
|
||||
const h = Math.abs(e.world.y - start.y);
|
||||
// Winzige Box = Klick ohne Zug → Legacy: Selektion leeren
|
||||
if (w < BOX_MIN_SIZE && h < BOX_MIN_SIZE) {
|
||||
if (!shift) (c.selection ?? { setIds: () => {} }).setIds([]);
|
||||
ctx.setStatus('Selektion geleert');
|
||||
return;
|
||||
}
|
||||
const mode = boxModeFor(start, e.world);
|
||||
const all = c.doc ? c.doc.getAllElements() : [];
|
||||
const hits = boxSelectElements(all, {
|
||||
x1: start.x, y1: start.y, x2: e.world.x, y2: e.world.y,
|
||||
}, mode);
|
||||
const bridge = (ctx as FullToolContext).selection;
|
||||
if (!bridge) return;
|
||||
if (shift) {
|
||||
const merged = new Set([...bridge.getIds(), ...hits]);
|
||||
bridge.setIds(Array.from(merged));
|
||||
} else {
|
||||
bridge.setIds(hits);
|
||||
}
|
||||
const count = shift
|
||||
? new Set([...(bridge.getIds())]).size
|
||||
: hits.length;
|
||||
ctx.setStatus(`Box-Auswahl (${mode === 'window' ? 'Fenster' : 'Kreuzend'}): ${count} Element(e)`);
|
||||
return;
|
||||
}
|
||||
// ── Task D9: Vertex-Commit (nur der Punkt, 1 Undo-Schritt) ──
|
||||
if (vertexDrag) {
|
||||
const c = ctx as FullToolContext;
|
||||
@@ -379,6 +509,7 @@ export const selectTool: ToolExtensionV2 = {
|
||||
cancel(ctx) {
|
||||
handleDrag = null;
|
||||
vertexDrag = null;
|
||||
boxDrag = null;
|
||||
ctx.setPreview?.(null);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* Task CAD-3 - Fenster-/Kreuz-Selektion (Box-Select).
|
||||
*
|
||||
* boxSelectElements: reine Funktion. Links-nach-rechts ziehen =
|
||||
* 'window' (Element muss VOLLSTAENDIG in der Box liegen),
|
||||
* rechts-nach-links = 'crossing' (Element darf die Box beruehren).
|
||||
* Im selectTool: Leerer down startet Box-Drag, up selektiert.
|
||||
*/
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { boxSelectElements, boxModeFor } from '../src/plugins/builtin/core-modify';
|
||||
import { selectTool } from '../src/plugins/builtin/core-modify';
|
||||
import { CADDocument } from '../src/kernel/document/CADDocument';
|
||||
import { createInMemoryDoc } from './helpers/inMemoryDoc';
|
||||
import type { CADElement, Pt } from '../src/types/cad.types';
|
||||
|
||||
function mkCtx(elements: CADElement[]) {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
for (const el of elements) doc.addElement(el);
|
||||
const selectedIds = new Set<string>();
|
||||
const previews: (CADElement | null)[] = [];
|
||||
const statuses: string[] = [];
|
||||
const ctx: any = {
|
||||
doc,
|
||||
options: {},
|
||||
setStatus: (m: string) => statuses.push(m),
|
||||
setPreview: (el: CADElement | null) => previews.push(el),
|
||||
selection: {
|
||||
getIds: () => Array.from(selectedIds),
|
||||
setIds: (ids: string[]) => {
|
||||
selectedIds.clear();
|
||||
for (const id of ids) selectedIds.add(id);
|
||||
},
|
||||
hitTest: (x: number, y: number, _tol: number) => {
|
||||
for (const el of elements) {
|
||||
const p = el.properties as Record<string, unknown>;
|
||||
if (p.x1 !== undefined) {
|
||||
const minX = Math.min(p.x1 as number, p.x2 as number);
|
||||
const maxX = Math.max(p.x1 as number, p.x2 as number);
|
||||
const minY = Math.min(p.y1 as number, p.y2 as number);
|
||||
const maxY = Math.max(p.y1 as number, p.y2 as number);
|
||||
if (x >= minX - 5 && x <= maxX + 5 && y >= minY - 5 && y <= maxY + 5) return el;
|
||||
}
|
||||
if (
|
||||
x >= el.x - el.width / 2 && x <= el.x + el.width / 2 &&
|
||||
y >= el.y - el.height / 2 && y <= el.y + el.height / 2
|
||||
) return el;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
};
|
||||
return { ctx, doc, selectedIds, previews, statuses };
|
||||
}
|
||||
|
||||
function pe(x: number, y: number, mods: { shift?: boolean } = {}): { world: Pt; shift: boolean; ctrl: boolean } {
|
||||
return { world: { x, y }, shift: mods.shift ?? false, ctrl: false } as never;
|
||||
}
|
||||
|
||||
function rect(id: string, x: number, y: number, w: number, h: number): CADElement {
|
||||
return { id, type: 'rect', layerId: 'l', x, y, width: w, height: h, properties: {} } as unknown as CADElement;
|
||||
}
|
||||
function line(id: string, x1: number, y1: number, x2: number, y2: number): CADElement {
|
||||
return {
|
||||
id, type: 'line', layerId: 'l',
|
||||
x: (x1 + x2) / 2, y: (y1 + y2) / 2,
|
||||
width: Math.abs(x2 - x1), height: Math.abs(y2 - y1),
|
||||
properties: { x1, y1, x2, y2 },
|
||||
} as unknown as CADElement;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
selectTool.handlers.cancel?.({ setStatus: () => {}, setPreview: () => {} } as never);
|
||||
});
|
||||
|
||||
// ─── boxModeFor: Richtung bestimmt Modus ──────────────────────
|
||||
|
||||
describe('CAD-3: boxModeFor', () => {
|
||||
it('Links-nach-rechts = window', () => {
|
||||
expect(boxModeFor({ x: 0, y: 0 }, { x: 100, y: 100 })).toBe('window');
|
||||
});
|
||||
it('Rechts-nach-links = crossing', () => {
|
||||
expect(boxModeFor({ x: 100, y: 0 }, { x: 0, y: 100 })).toBe('crossing');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── boxSelectElements: window (vollstaendig enthalten) ─────
|
||||
|
||||
describe('CAD-3: window-Selektion (vollstaendig enthalten)', () => {
|
||||
it('Element komplett in Box wird selektiert', () => {
|
||||
const els = [rect('r1', 50, 50, 20, 20)];
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
const hit = boxSelectElements(els, box, 'window');
|
||||
expect(hit).toContain('r1');
|
||||
});
|
||||
|
||||
it('Element, das die Box-Kante durchstoesst, wird NICHT selektiert (window)', () => {
|
||||
// rect 90..110, Box 0..100: ragt raus
|
||||
const els = [rect('r1', 100, 50, 20, 20)];
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
const hit = boxSelectElements(els, box, 'window');
|
||||
expect(hit).not.toContain('r1');
|
||||
});
|
||||
|
||||
it('Line mit beiden Endpunkten in Box wird selektiert', () => {
|
||||
const els = [line('l1', 10, 10, 80, 80)];
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
expect(boxSelectElements(els, box, 'window')).toContain('l1');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── boxSelectElements: crossing (Beruehrung reicht) ─────────
|
||||
|
||||
describe('CAD-3: crossing-Selektion (Beruehrung reicht)', () => {
|
||||
it('Element, das die Box nur teilweise durchstoesst, WIRD selektiert', () => {
|
||||
const els = [rect('r1', 100, 50, 20, 20)]; // 90..110
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
const hit = boxSelectElements(els, box, 'crossing');
|
||||
expect(hit).toContain('r1');
|
||||
});
|
||||
|
||||
it('Element ausserhalb der Box wird nicht selektiert', () => {
|
||||
const els = [rect('r1', 500, 500, 20, 20)];
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
expect(boxSelectElements(els, box, 'crossing')).not.toContain('r1');
|
||||
});
|
||||
|
||||
it('Element, das die Box nur beruehrt (Kante = Kante), wird selektiert', () => {
|
||||
// rect endet exakt bei x=100 (Kante = Box-Kante)
|
||||
const els = [rect('r1', 95, 50, 10, 20)]; // 90..100
|
||||
const box = { x1: 0, y1: 0, x2: 100, y2: 100 };
|
||||
expect(boxSelectElements(els, box, 'crossing')).toContain('r1');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Tool-Integration: Box-Drag im selectTool ────────────────
|
||||
|
||||
describe('CAD-3: selectTool Box-Drag', () => {
|
||||
it('Leerer down + move + up fuehrt Box-Selektion aus (window: links nach rechts)', () => {
|
||||
const inside = rect('r1', 50, 50, 20, 20);
|
||||
const outside = rect('r2', 500, 500, 20, 20);
|
||||
const { ctx, selectedIds, previews } = mkCtx([inside, outside]);
|
||||
|
||||
// down auf Leerraum (kein Element getroffen)
|
||||
selectTool.handlers.down!(pe(0, 0), ctx);
|
||||
// move zieht Box auf
|
||||
selectTool.handlers.move!(pe(100, 100), ctx);
|
||||
expect(previews.length).toBeGreaterThanOrEqual(1); // Box-Preview
|
||||
// up schliesst ab
|
||||
selectTool.handlers.up!(pe(100, 100), ctx);
|
||||
|
||||
expect(selectedIds.has('r1')).toBe(true);
|
||||
expect(selectedIds.has('r2')).toBe(false);
|
||||
});
|
||||
|
||||
it('Klick OHNE Zug (winzige Box) leert die Selektion (Legacy-Verhalten bleibt)', () => {
|
||||
const inside = rect('r1', 50, 50, 20, 20);
|
||||
const { ctx, selectedIds } = mkCtx([inside]);
|
||||
selectedIds.add('r1');
|
||||
// down + up am selben Punkt = kein Zug
|
||||
selectTool.handlers.down!(pe(300, 300), ctx);
|
||||
selectTool.handlers.up!(pe(300, 300), ctx);
|
||||
expect(Array.from(selectedIds)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('Shift + Box-Select addiert zur bestehenden Selektion', () => {
|
||||
const a = rect('a', 50, 50, 20, 20);
|
||||
const b = rect('b', 200, 50, 20, 20);
|
||||
const { ctx, selectedIds } = mkCtx([a, b]);
|
||||
selectedIds.add('a'); // schon selektiert
|
||||
// Shift-Box um b (Shift an down UND up, wie der echte Dispatcher)
|
||||
selectTool.handlers.down!(pe(150, 0, { shift: true }), ctx);
|
||||
selectTool.handlers.up!(pe(250, 100, { shift: true }), ctx);
|
||||
expect(selectedIds.has('a')).toBe(true);
|
||||
expect(selectedIds.has('b')).toBe(true);
|
||||
});
|
||||
|
||||
it('Status meldet Anzahl und Modus', () => {
|
||||
const els = [rect('r1', 50, 50, 20, 20), rect('r2', 60, 60, 20, 20)];
|
||||
const { ctx, statuses } = mkCtx(els);
|
||||
selectTool.handlers.down!(pe(0, 0), ctx);
|
||||
selectTool.handlers.up!(pe(100, 100), ctx);
|
||||
const last = statuses[statuses.length - 1];
|
||||
expect(last).toContain('2');
|
||||
});
|
||||
|
||||
it('Box-Drag startet NICHT wenn ein Element getroffen wurde', () => {
|
||||
const el = rect('r1', 50, 50, 20, 20);
|
||||
const { ctx, selectedIds } = mkCtx([el]);
|
||||
// down AUF das Element: normale Einzelselektion, kein Box-Start
|
||||
selectTool.handlers.down!(pe(50, 50), ctx);
|
||||
expect(selectedIds.has('r1')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -807,6 +807,8 @@ describe('A3 pilot: select tool', () => {
|
||||
selectTool.handlers.down!(pe(10, 10), ctx);
|
||||
expect(getIds()).toEqual(['a']);
|
||||
selectTool.handlers.down!(pe(999, 999), ctx);
|
||||
// CAD-3: Leerklick leert erst bei up (Klick ohne Zug) — Box-Select-Follow-up
|
||||
selectTool.handlers.up!(pe(999, 999), ctx);
|
||||
expect(getIds()).toEqual([]);
|
||||
|
||||
expect(coreModifyPlugin.manifest.enabledByDefault).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user