From 98b85c55ea5fdfb129c9cc64cb424c8d9bcc6366 Mon Sep 17 00:00:00 2001 From: karim Date: Mon, 19 Oct 2026 23:41:45 +0200 Subject: [PATCH] Markierrahmen ueber Kataster: Auswahl-Hervorhebung als ein Pfad, keine Griffe bei grossen Auswahlen, linearer Lookup entfernt --- src/plan/PlanView.tsx | 75 ++++++++++++++++++++----------------- src/state/useGripEditing.ts | 25 +++++++++++-- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/plan/PlanView.tsx b/src/plan/PlanView.tsx index 2b5aaca..81bf924 100644 --- a/src/plan/PlanView.tsx +++ b/src/plan/PlanView.tsx @@ -2722,11 +2722,17 @@ export const PlanView = forwardRef( // Linien kompakt gehaltener Zeichnungen entstehen nur für die gewählten (wenige). const underIds = getUnderlayIds(); if (!underIds || !selectedDrawingIds) return fromPrims; + // Pro Gruppe EIN Durchlauf über deren Zeichnungen (statt `find` je gewählter ID: + // bei tausenden gewählten Katasterobjekten sonst quadratisch). const extra: Array> = []; + const groups = new Set>>(); for (const id of selectedDrawingIds) { const g = underIds.get(id); - const d = g?.drawings.find((x) => x.id === id); - if (g && d) for (const pr of g.build([d])) if (pr.kind === "line") extra.push(pr); + if (g) groups.add(g); + } + for (const g of groups) { + const chosen = g.drawings.filter((d) => ids.has(d.id)); + if (chosen.length) for (const pr of g.build(chosen)) if (pr.kind === "line") extra.push(pr); } return extra.length ? [...fromPrims, ...extra] : fromPrims; }, [plan, selectedDrawingIds]); @@ -2743,6 +2749,33 @@ export const PlanView = forwardRef( return primsOwnedBy("drawingId", selectedDrawingIds, (p): p is Extract => p.kind === "drawingText" && p.drawingId !== editTextId); }, [plan, selectedDrawingIds, editTextId]); + // Auswahl-Hervorhebung als EIN je Art statt eines DOM-Elements je Objekt: + // bei tausenden gewählten Katasterobjekten war der DOM-Aufbau (nicht die Auswahl) + // der Engpass. Aussehen identisch (beide Klassen: fill none, Kontur). + const highlightDrawPath = useMemo(() => { + const parts: string[] = []; + for (const p of highlightDrawPrims) { + if (p.kind === "line") { + const a = toScreen(p.a), b = toScreen(p.b); + parts.push(`M${a.x} ${a.y}L${b.x} ${b.y}`); + } else if (p.pts.length > 1) { + const q = p.pts.map(toScreen); + parts.push(`M${q.map((s) => `${s.x} ${s.y}`).join("L")}Z`); + } + } + return parts.join(""); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [highlightDrawPrims]); + const highlightTextPath = useMemo(() => { + const parts: string[] = []; + for (const p of highlightTextFrames) { + const q = textFrameCorners(p).map(toScreen); + parts.push(`M${q.map((s) => `${s.x} ${s.y}`).join("L")}Z`); + } + return parts.join(""); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [highlightTextFrames]); + // Hervorhebung der selektierten Decken: alle Polygone JEDER gewählten Decke // (Fläche + Umriss) mit Akzentkontur überzeichnen — analog zur Wand-Auswahl. const highlightCeilingPolys = useMemo(() => { @@ -3291,44 +3324,16 @@ export const PlanView = forwardRef( ), )} {/* Hervorhebung der selektierten 2D-Zeichenelemente (Akzentkontur). */} - {highlightDrawPrims.map((p, i) => - p.kind === "line" ? ( - - ) : ( - `${s.x},${s.y}`) - .join(" ")} - pointerEvents="none" - /> - ), + {highlightDrawPath && ( + )} {/* Auswahl-Rahmen für Text-Objekte (geschätzte Box, kein echter Umriss wie bei Linie/Polygon — s. `text/textFrame.ts` `textFrameCorners`). Gestrichelt statt durchgezogen wie `.plan-sel-draw`, um sichtbar zu machen: das ist eine SCHÄTZUNG, keine exakt nachgezeichnete Geometrie. */} - {highlightTextFrames.map((p) => ( - `${s.x},${s.y}`) - .join(" ")} - pointerEvents="none" - /> - ))} + {highlightTextPath && ( + + )} )} {/* Gruppen-Auswahl: nur eine Bounding-Box mit vier Eckpunkten (kein diff --git a/src/state/useGripEditing.ts b/src/state/useGripEditing.ts index 2be193c..90107f5 100644 --- a/src/state/useGripEditing.ts +++ b/src/state/useGripEditing.ts @@ -139,6 +139,25 @@ export function useGripEditing(opts: { ? [selectedDrawingId] : []; + // Bei grossen Auswahlen (z. B. Rahmen über Katasterdaten) gibt es KEINE Griffe: + // je Stützpunkt ein Eck- und ein Kanten-Griff ergaben zehntausende DOM-Elemente + // (Sekunden Wartezeit) und sind bei so vielen Punkten nicht bedienbar. Massgebend + // ist die GESAMTZAHL der Stützpunkte (wenige Objekte können riesige Umrisse + // haben), nicht die Objektzahl. Die Auswahl selbst (Hervorhebung, Verschieben, + // Eigenschaften) bleibt unberührt. + const MAX_GRIP_DRAWINGS = 50; + const MAX_GRIP_VERTICES = 600; + const gripDrawingIds = (() => { + if (effectiveDrawingIds.length > MAX_GRIP_DRAWINGS) return []; + let total = 0; + for (const id of effectiveDrawingIds) { + const d = project.drawings2d.find((x) => x.id === id); + if (d) total += drawingVertices(d, scaleDenominator).length; + if (total > MAX_GRIP_VERTICES) return []; + } + return effectiveDrawingIds; + })(); + const grips: Vec2[] = (() => { // Öffnung (Fenster/Tür): EIN Mittelpunkt-Griff auf der Wandachse. Ziehen // verschiebt die Öffnung entlang der Wirts-Wand (siehe applyGrip → @@ -198,7 +217,7 @@ export function useGripEditing(opts: { const end = out.length - 1; for (let i = start; i <= end; i++) gripOwnerRange.push([start, end]); }; - for (const id of effectiveDrawingIds) { + for (const id of gripDrawingIds) { const d = project.drawings2d.find((x) => x.id === id); if (d) pushGroup(drawingVertices(d, scaleDenominator), { drawingId: id }); } @@ -219,7 +238,7 @@ export function useGripEditing(opts: { // bekommt eine Linie zu seinem/seinen benachbarten Griff(en). const gripHandleLines: { a: Vec2; b: Vec2 }[] = (() => { const out: { a: Vec2; b: Vec2 }[] = []; - for (const id of effectiveDrawingIds) { + for (const id of gripDrawingIds) { const d = project.drawings2d.find((x) => x.id === id); const g = d?.geom; if (!g || g.shape !== "bezier") continue; @@ -310,7 +329,7 @@ export function useGripEditing(opts: { return ringEdges(selectedRoom.boundary, {}); } const out: EdgeGrip[] = []; - for (const id of effectiveDrawingIds) { + for (const id of gripDrawingIds) { const d = project.drawings2d.find((x) => x.id === id); if (!d) continue; const verts = drawingVertices(d, scaleDenominator);