[G10][C1] Merge: Plan-Overlay relativ zu lokalem Ursprung (LV95-Griffe pixelgenau, Lineal, keine inneren Kanten-Griffe)
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
13 files changed
+505
-198
No files matched your search
@@ -595,7 +595,7 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
- ○ **[G7] Robuste Booleans bei bündigen Flächen** — wächst mit jeder Phase. · L (laufend)
|
||||
- ✅ **[G8] Abzugskörper (senkrechte Prismen)** — Grundriss, Schnitt, 3D, STEP. Offen: Ansicht,
|
||||
Schraffur-Deckel im 3D-Live-Schnitt.
|
||||
- ○ **[G10] render2d-Punkte f32** (Fund aus [K3b], geprüft 27.10.): `render2d::types::Scene` speichert Punkte
|
||||
- ◐ **[G10] render2d-Punkte f32** (Fund aus [K3b], geprüft 27.10.): `render2d::types::Scene` speichert Punkte
|
||||
als f32 (~0.25 m Auflösung bei ~2.6e6 m). **Real betroffen:** DXF/DWG-Import mit Platzierung „origin"
|
||||
(Vorgabe im Import-Dialog, `ImportDialog.tsx`) behält die Landeskoordinaten → im Browser-/Electron-Pfad
|
||||
(WASM-render2d, `useWasmPlanRenderer.ts`) wackeln/verschmelzen Linien eines Katasterplans. **Nicht
|
||||
@@ -610,6 +610,17 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
Hover-Kreis einer Kreis-Zeichnung, HUD-Kasten. Lösung: Overlay relativ zu einem Ursprung (viewBox und
|
||||
`toScreen` in PlanView minus Ursprung). Auch die CLI-SVG (`plan --out`) schreibt Landeskoordinaten
|
||||
(senkrechte Linien fehlten im Chromium-Screenshot eines LV95-Plans).
|
||||
29.10. **SVG-Overlay erledigt:** lokaler Ursprung nahe dem Ausschnitt (`views/plan/planView/overlayOrigin.ts`,
|
||||
bleibt stehen bis der Ausschnitt > 64 Ausschnitt-Grössen entfernt ist; lokale Projekte: (0, 0) wie bisher).
|
||||
viewBox, Griffe, Kanten-Griffe, Fang, Hervorhebung, Vorschau, Texte, Raster, Lineal, HUD, Marquee, Luftbilder
|
||||
zeichnen relativ dazu; Ausschnitt, Treffer, Fang bleiben absolut in f64. `vbCircle` wieder entfernt (lokal
|
||||
passen `<circle>`-Werte in die CSS-Längen). Gemessen Chromium, Kataster-Ecke: vorher 1.6 px (Übersicht 80 m),
|
||||
5.0 px (10 m), 31 px (1 m); nachher ≤ 0.003 px. Lineal: Ticks über ganzzahligen Index (aufsummiert drifteten
|
||||
sie bei LV95). Plan-Rad: eigener nicht-passiver Listener (React-`onWheel` ist passiv, `preventDefault` warf
|
||||
in Chromium Konsolenfehler). e2e `kataster.spec.ts` (Griffe ± 1 px bei 80/10/1 m, Lineal, Vorschau-Kreis).
|
||||
Nicht in Tauri/WKWebView geprüft. Offen: CLI-SVG; render2d meldet headless beim schnellen Rad-Zoom
|
||||
„recursive use of an object … unsafe aliasing" (`render`/`set_scene_bin` überlappen, auch vor der Änderung;
|
||||
Plan bleibt danach teils leer) — prüfen.
|
||||
- ✅ **[G9] Dach-Gehrung an Walm-/Zeltspitzen** (neu 27.10.): an Punkten mit ≥ 3 Dachflächen trifft die
|
||||
paarweise Gehrung der Unterseite nicht exakt (Restlücke < 0.01 m²); solche Dächer gehen als nicht
|
||||
geschlossenes Face-Set ins IFC. · S–M
|
||||
@@ -1148,7 +1159,11 @@ Code-Übernahme Lizenz der Abhängigkeiten prüfen, Pflicht [51].
|
||||
= − DXF-Bulge** (Modell: Scheitel links der Sehne, DXF: Gegenuhrzeigersinn). Tests: Rust, vitest,
|
||||
e2e `kataster.spec.ts` (Fixture `e2e/fixtures/kataster.dxf`, LV95: Klick, Griffe auf den Ecken, Ziehen,
|
||||
Rückgängig). Synthetischer Kataster (6750 Elemente, DXF und DWG) nur im Browser-Build (Chromium) geprüft,
|
||||
nicht in Tauri/macOS. Offen: f32-Versatz des SVG-Overlays bei LV95, s. [G10].
|
||||
nicht in Tauri/macOS. Offen: f32-Versatz des SVG-Overlays bei LV95, s. [G10] (29.10. erledigt, Vieleck
|
||||
wieder `<circle>`).
|
||||
- ✅ **Kanten-Griffe einer Polylinie** (29.10.): liefen auch über die angehängten Bogen-Mitten-Griffe von
|
||||
`drawingVertices` → Dreiecke quer im Innern jeder Polylinie. Jetzt nur über die Eckpunkte und nur an
|
||||
geraden Segmenten (Bogen: eigener Mitten-Griff), `state/edgeGrips.ts` + vitest, e2e.
|
||||
- ✅ **[C2] DXF als eigenes Rust-Crate** (Lesen und Schreiben über acadrust, 28.10.)
|
||||
28.10. **DXF-Export in Rust:** statt eigenem Writer über acadrust (`fileio/src/export.rs`), **R2018 ASCII
|
||||
(UTF-8)** statt des alten AC1015-Kopfs mit UTF-8-Inhalt. `buildPlanDxf` (gleiche Signatur) sammelt nur noch
|
||||
|
||||
+125
-7
@@ -3,7 +3,8 @@
|
||||
// (`fixtures/kataster.dxf`: Parzellen als geschlossene LWPOLYLINE teils mit Bögen, Grenzpunkte als
|
||||
// INSERT mit ATTRIB, Nummern als TEXT/MTEXT, Gebäude mit HATCH, Strassenparzelle mit Bögen).
|
||||
// Gewählt wird per Klick in den Plan (das Picken läuft im Kern auf dem Plan-Puffer, headless ok);
|
||||
// Bildschirm-Punkte aus der viewBox-Abbildung des SVG-Overlays (`toScreen`: x·90, −y·90).
|
||||
// Bildschirm-Punkte aus der viewBox-Abbildung des SVG-Overlays (`toScreen`: x·90, −y·90, minus
|
||||
// lokalem Ursprung `data-origin-x/y`, s. `planView/overlayOrigin.ts`).
|
||||
import { readFile } from "node:fs/promises";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, expect, fileMenu, startNewProject, test } from "./app";
|
||||
@@ -32,11 +33,13 @@ async function screenOf(page: Page, dx: number, dy: number): Promise<{ x: number
|
||||
return page.locator("svg.plan-svg").evaluate(
|
||||
(el, [x, y]) => {
|
||||
const [vx, vy, vw, vh] = el.getAttribute("viewBox")!.split(/\s+/).map(Number);
|
||||
const ox = Number(el.getAttribute("data-origin-x") ?? 0);
|
||||
const oy = Number(el.getAttribute("data-origin-y") ?? 0);
|
||||
const r = el.getBoundingClientRect();
|
||||
const s = Math.min(r.width / vw, r.height / vh);
|
||||
return {
|
||||
x: r.left + (r.width - vw * s) / 2 + (x * 90 - vx) * s,
|
||||
y: r.top + (r.height - vh * s) / 2 + (-y * 90 - vy) * s,
|
||||
x: r.left + (r.width - vw * s) / 2 + (x * 90 - ox - vx) * s,
|
||||
y: r.top + (r.height - vh * s) / 2 + (-y * 90 - oy - vy) * s,
|
||||
};
|
||||
},
|
||||
[E0 + dx, N0 + dy],
|
||||
@@ -48,8 +51,8 @@ async function clickModel(page: Page, dx: number, dy: number): Promise<void> {
|
||||
await page.mouse.click(p.x, p.y);
|
||||
}
|
||||
|
||||
/** Ein gezeichneter Griff liegt (± 3 px) am Bildschirmort des Modellpunkts. */
|
||||
async function expectGripAt(page: Page, dx: number, dy: number): Promise<void> {
|
||||
/** Abstand (px) des nächsten gezeichneten Griffs zum Bildschirmort des Modellpunkts. */
|
||||
async function gripOffset(page: Page, dx: number, dy: number): Promise<number> {
|
||||
const want = await screenOf(page, dx, dy);
|
||||
const boxes = await page.locator(".plan-grip").evaluateAll((els) =>
|
||||
els.map((e) => {
|
||||
@@ -57,8 +60,32 @@ async function expectGripAt(page: Page, dx: number, dy: number): Promise<void> {
|
||||
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
||||
}),
|
||||
);
|
||||
const d = Math.min(...boxes.map((b) => Math.hypot(b.x - want.x, b.y - want.y)));
|
||||
expect(d, `Griff bei ${dx}/${dy}: nächster gezeichneter ${d.toFixed(1)} px entfernt`).toBeLessThan(3);
|
||||
return Math.min(...boxes.map((b) => Math.hypot(b.x - want.x, b.y - want.y)));
|
||||
}
|
||||
|
||||
/** Ein gezeichneter Griff liegt (± 1 px) am Bildschirmort des Modellpunkts. */
|
||||
async function expectGripAt(page: Page, dx: number, dy: number): Promise<void> {
|
||||
const d = await gripOffset(page, dx, dy);
|
||||
expect(d, `Griff bei ${dx}/${dy}: nächster gezeichneter ${d.toFixed(2)} px entfernt`).toBeLessThan(1);
|
||||
}
|
||||
|
||||
/** Breite des Ausschnitts in Metern (viewBox-Breite / 90). */
|
||||
async function viewWidthM(page: Page): Promise<number> {
|
||||
const vb = await page.locator("svg.plan-svg").getAttribute("viewBox");
|
||||
return Number(vb!.split(/\s+/)[2]) / 90;
|
||||
}
|
||||
|
||||
/** Mit dem Mausrad um den Modellpunkt hineinzoomen, bis der Ausschnitt höchstens `widthM` breit ist. */
|
||||
async function zoomTo(page: Page, dx: number, dy: number, widthM: number): Promise<void> {
|
||||
for (let k = 0; k < 200 && (await viewWidthM(page)) > widthM; k++) {
|
||||
const p = await screenOf(page, dx, dy);
|
||||
await page.mouse.move(p.x, p.y);
|
||||
await page.mouse.wheel(0, -400);
|
||||
await page.waitForTimeout(100); // Rad-Zoom wird nach 70 ms Ruhe festgeschrieben
|
||||
}
|
||||
// Pan/Zoom wird imperativ angewandt und erst nach einer Pause festgeschrieben.
|
||||
await page.waitForTimeout(400);
|
||||
expect(await viewWidthM(page)).toBeLessThanOrEqual(widthM);
|
||||
}
|
||||
|
||||
const widthField = (page: Page) => page.locator(".objinfo-field").filter({ hasText: "Breite" }).locator("input");
|
||||
@@ -76,6 +103,7 @@ test("Kataster-DXF in LV95: Parzelle anklicken, Eckgriff ziehen, Rückgängig",
|
||||
// Browser als CSS-Länge auf ±33.5 Mio. geklemmt → weit ausserhalb des Bildes).
|
||||
await expectGripAt(page, 68, 68);
|
||||
await expectGripAt(page, 38, 38);
|
||||
await expectGripAt(page, 38, 68);
|
||||
|
||||
// Ecke oben rechts 5 m nach rechts ziehen → 35 m breit. Der Griff bleibt nach dem Loslassen
|
||||
// „bewaffnet" und folgt dem Cursor; abgeschlossen wird mit einem zweiten Klick.
|
||||
@@ -125,3 +153,93 @@ test("Kataster: einzeln gewähltes Element mit über 600 Stützpunkten bekommt G
|
||||
// Gezeichnet werden nur die sichtbaren, je Bildschirmzelle einer (gripCull.ts) — nie alle 1400.
|
||||
expect(await grips.count()).toBeLessThanOrEqual(1400);
|
||||
});
|
||||
|
||||
test("Kataster in LV95: Griffe auf den Ecken auch stark hineingezoomt, Lineal stimmt", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await importDxf(page, "kataster.dxf", await readFile(KATASTER_DXF, "utf8"));
|
||||
await clickModel(page, 38, 53);
|
||||
await expect(page.locator(".plan-grip")).toHaveCount(4);
|
||||
await expectGripAt(page, 68, 68);
|
||||
|
||||
// Bisher (Overlay in absoluten viewBox-Einheiten, Browser rechnet f32): ~6 px bei 11 m,
|
||||
// ~80 px bei 1.5 m Ausschnitt.
|
||||
await zoomTo(page, 68, 68, 11);
|
||||
await expectGripAt(page, 68, 68);
|
||||
await zoomTo(page, 68, 68, 1);
|
||||
await expectGripAt(page, 68, 68);
|
||||
|
||||
// Lineal (`<rect>`/Ticks, früher als CSS-Länge geklemmt → unsichtbar): Leiste über die ganze
|
||||
// Breite, Beschriftung oben an der richtigen Stelle (Text beginnt 3 px rechts vom Tick).
|
||||
const strip = await page.locator(".plan-ruler-strip").first().boundingBox();
|
||||
const svgBox = await page.locator("svg.plan-svg").boundingBox();
|
||||
expect(strip!.width).toBeGreaterThan(svgBox!.width - 2);
|
||||
expect(strip!.x).toBeGreaterThanOrEqual(svgBox!.x - 1);
|
||||
const labels = await page
|
||||
.locator(".plan-ruler-text:not([transform])")
|
||||
.evaluateAll((els) => els.map((e) => ({ text: e.textContent ?? "", left: e.getBoundingClientRect().left })));
|
||||
expect(labels.length).toBeGreaterThan(1);
|
||||
for (const l of labels) {
|
||||
const m = Number.parseFloat(l.text);
|
||||
expect(m).toBeGreaterThan(E0 + 66);
|
||||
expect(m).toBeLessThan(E0 + 70);
|
||||
const want = await screenOf(page, m - E0, 0);
|
||||
expect(Math.abs(l.left - (want.x + 3)), `Lineal ${l.text}`).toBeLessThan(2);
|
||||
}
|
||||
});
|
||||
|
||||
test("Kataster: geschlossene Bogen-Polylinie hat keine Kanten-Griffe im Innern", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await importDxf(page, "kataster.dxf", await readFile(KATASTER_DXF, "utf8"));
|
||||
// Strassenparzelle: jedes Segment ein Bogen → Bogen-Mitten-Griffe, keine Kanten-Dreiecke
|
||||
// (früher liefen die Kanten-Griffe auch über die Bogen-Mitten: Dreiecke quer durchs Innere).
|
||||
await clickModel(page, -6 + 3 * 8, -3);
|
||||
await expect(page.locator(".plan-grip")).toHaveCount(44);
|
||||
await expect(page.locator(".plan-edge-grip")).toHaveCount(0);
|
||||
// Parzelle mit geraden Kanten: genau 4 Kanten-Griffe, je auf der Kantenmitte.
|
||||
await clickModel(page, 38, 53);
|
||||
await expect(page.locator(".plan-grip")).toHaveCount(4);
|
||||
await expect(page.locator(".plan-edge-grip")).toHaveCount(4);
|
||||
// Parzelle 0..30 m mit zwei Bogen- und zwei geraden Seiten: 4 Ecken + 2 Bogen-Mitten,
|
||||
// Kanten-Griffe nur an den geraden Seiten (rechts bei x = 30, links bei x = 0).
|
||||
await clickModel(page, 30, 15);
|
||||
await expect(page.locator(".plan-grip")).toHaveCount(6);
|
||||
const edges = page.locator(".plan-edge-grip");
|
||||
await expect(edges).toHaveCount(2);
|
||||
const right = await screenOf(page, 30, 15);
|
||||
const left = await screenOf(page, 0, 15);
|
||||
const centres = await edges.evaluateAll((els) =>
|
||||
els.map((e) => {
|
||||
const r = e.getBoundingClientRect();
|
||||
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
||||
}),
|
||||
);
|
||||
for (const c of centres) {
|
||||
const d = Math.min(Math.hypot(c.x - right.x, c.y - right.y), Math.hypot(c.x - left.x, c.y - left.y));
|
||||
expect(d, "Kanten-Griff auf einer geraden Seite").toBeLessThan(12);
|
||||
}
|
||||
});
|
||||
|
||||
test("Kataster: Vorschau-Kreis eines Grenzpunkts (Liste beim Strg-Klick) sitzt in LV95 am Ort", async ({ page }) => {
|
||||
await startNewProject(page);
|
||||
await importDxf(page, "kataster.dxf", await readFile(KATASTER_DXF, "utf8"));
|
||||
await zoomTo(page, 30, 0, 4);
|
||||
// Grenzpunkt (Kreis r = 0.25 m um 30/0) auf dem Rand anklicken, mit Strg: Liste der Objekte.
|
||||
const at = await screenOf(page, 30.25, 0);
|
||||
await page.keyboard.down("Control");
|
||||
await page.mouse.click(at.x, at.y);
|
||||
await page.keyboard.up("Control");
|
||||
const list = page.locator(".pick-list");
|
||||
await expect(list).toBeVisible();
|
||||
// Eintrag „Kreis" überfahren → Vorschau-Kreis im Plan (`<circle>`: cx/cy/r sind CSS-Längen,
|
||||
// früher bei LV95 auf ±33.5 Mio. geklemmt und damit ausserhalb des Bildes).
|
||||
await list.getByRole("option", { name: /Kreis/ }).hover();
|
||||
const circle = page.locator(".plan-hover-pick circle");
|
||||
await expect(circle).toHaveCount(1);
|
||||
const box = (await circle.boundingBox())!;
|
||||
const c = await screenOf(page, 30, 0);
|
||||
const e = await screenOf(page, 30.25, 0);
|
||||
const rPx = e.x - c.x;
|
||||
expect(Math.abs(box.x + box.width / 2 - c.x)).toBeLessThan(1);
|
||||
expect(Math.abs(box.y + box.height / 2 - c.y)).toBeLessThan(1);
|
||||
expect(Math.abs(box.width / 2 - rPx)).toBeLessThan(3); // Box mit Strich (≈ 4 px)
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { polylineEdgeGrips } from "./edgeGrips";
|
||||
|
||||
const sq = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 30, y: 0 },
|
||||
{ x: 30, y: 30 },
|
||||
{ x: 0, y: 30 },
|
||||
];
|
||||
|
||||
describe("polylineEdgeGrips", () => {
|
||||
it("geschlossen, gerade: 4 Kanten auf den Seitenmitten, Normalen nach aussen", () => {
|
||||
const e = polylineEdgeGrips({ shape: "polyline", pts: sq, closed: true }, { drawingId: "d" });
|
||||
expect(e.map((g) => g.mid)).toEqual([
|
||||
{ x: 15, y: 0 },
|
||||
{ x: 30, y: 15 },
|
||||
{ x: 15, y: 30 },
|
||||
{ x: 0, y: 15 },
|
||||
]);
|
||||
expect(e.map((g) => [g.aIndex, g.bIndex])).toEqual([[0, 1], [1, 2], [2, 3], [3, 0]]);
|
||||
expect(e[0].normal.y).toBeCloseTo(-1);
|
||||
expect(e[1].normal.x).toBeCloseTo(1);
|
||||
});
|
||||
|
||||
it("geschlossen mit Bögen: nur gerade Seiten, keine Kanten über die Bogen-Mitten (nichts im Innern)", () => {
|
||||
const e = polylineEdgeGrips(
|
||||
{ shape: "polyline", pts: sq, closed: true, bulge: [0.12, 0, -0.15, 0] },
|
||||
{ drawingId: "d" },
|
||||
);
|
||||
expect(e.map((g) => g.mid)).toEqual([
|
||||
{ x: 30, y: 15 },
|
||||
{ x: 0, y: 15 },
|
||||
]);
|
||||
// Lauter Bögen (Strassenparzelle): keine Kanten-Griffe.
|
||||
expect(polylineEdgeGrips({ shape: "polyline", pts: sq, closed: true, bulge: [0.1, 0.1, 0.1, 0.1] }, {})).toEqual([]);
|
||||
});
|
||||
|
||||
it("offen: je gerades Segment ein freier Griff, ohne Schlusskante", () => {
|
||||
const e = polylineEdgeGrips({ shape: "polyline", pts: sq, closed: false, bulge: [0, 0.3, 0] }, {});
|
||||
expect(e.map((g) => [g.aIndex, g.bIndex, g.free])).toEqual([[0, 1, true], [2, 3, true]]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
// Kanten-Griffe (je Seite ein Anfasser mit Aussennormale) eines gewählten Elements — reine
|
||||
// Geometrie, ausgelagert aus `useGripEditing.ts`.
|
||||
|
||||
import { leftNormal, normalize, scale, sub } from "../model/geometry";
|
||||
import type { Drawing2DGeom, EdgeGrip, Vec2 } from "../model/types";
|
||||
|
||||
type Owner = { drawingId?: string; wallId?: string };
|
||||
|
||||
/** Geschlossener Ring aus Vertices → Kanten-Griffe mit Aussennormale (vom Eckpunkt-Mittel weg). */
|
||||
export function ringEdges(verts: Vec2[], owner: Owner): EdgeGrip[] {
|
||||
const n = verts.length;
|
||||
if (n < 3) return [];
|
||||
// Schwerpunkt (Mittel der Eckpunkte) als Innenbezug.
|
||||
let cx = 0, cy = 0;
|
||||
for (const v of verts) { cx += v.x; cy += v.y; }
|
||||
const centroid: Vec2 = { x: cx / n, y: cy / n };
|
||||
const out: EdgeGrip[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const a = verts[i];
|
||||
const b = verts[(i + 1) % n];
|
||||
const mid: Vec2 = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
||||
let nrm = normalize(leftNormal(sub(b, a)));
|
||||
// Nach aussen orientieren: Normale soll von centroid → mid weisen.
|
||||
const outward = sub(mid, centroid);
|
||||
if (nrm.x * outward.x + nrm.y * outward.y < 0) nrm = scale(nrm, -1);
|
||||
out.push({ mid, normal: nrm, aIndex: i, bIndex: (i + 1) % n, owner });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offene Kette (Linie/offene Polylinie) → ein Griff je Segment, OHNE Schlusskante. `normal` dient
|
||||
* nur der Darstellung (leftNormal der Kante); die Bewegung ist frei (`free: true`).
|
||||
*/
|
||||
export function openEdges(verts: Vec2[], owner: Owner): EdgeGrip[] {
|
||||
const n = verts.length;
|
||||
if (n < 2) return [];
|
||||
const out: EdgeGrip[] = [];
|
||||
for (let i = 0; i < n - 1; i++) {
|
||||
const a = verts[i];
|
||||
const b = verts[i + 1];
|
||||
const mid: Vec2 = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
||||
const nrm = normalize(leftNormal(sub(b, a)));
|
||||
out.push({ mid, normal: nrm, aIndex: i, bIndex: i + 1, free: true, owner });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kanten-Griffe einer Polylinie: nur über die Eckpunkte (`drawingVertices` hängt dahinter je
|
||||
* Segment einen Bogen-Mitten-Griff an — liefen die Kanten auch über diese, sassen Dreiecke quer im
|
||||
* Innern, Fund 29.10.) und nur an geraden Segmenten: ein Bogen hat seinen Bogen-Mitten-Griff, die
|
||||
* Sehnen-Mitte läge neben der Linie.
|
||||
*/
|
||||
export function polylineEdgeGrips(g: Extract<Drawing2DGeom, { shape: "polyline" }>, owner: Owner): EdgeGrip[] {
|
||||
const all = g.closed ? ringEdges(g.pts, owner) : openEdges(g.pts, owner);
|
||||
return all.filter((e) => Math.abs(g.bulge?.[e.aIndex] ?? 0) <= 1e-9);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import type { Ceiling, Drawing2D, EdgeGrip, Project, Room, Stair, Vec2 } from ".
|
||||
import { wallTypeThickness } from "../model/types";
|
||||
import { drawingVertices } from "./projectSlice";
|
||||
import { gripDrawingIdsFor } from "./gripLimits";
|
||||
import { openEdges, polylineEdgeGrips, ringEdges } from "./edgeGrips";
|
||||
import { areaMovePreview } from "../tools/transform";
|
||||
import { mvGeom } from "../core";
|
||||
import { drawingPreviewShapes } from "../tools/drawingPreview";
|
||||
@@ -371,45 +372,7 @@ export function useGripEditing(opts: {
|
||||
// Ecken wandern mit, die Nachbar-Segmente dehnen sich nach (Parallel-
|
||||
// Verschieben EINER Kante einer komplexen Polylinie, §Task B).
|
||||
const edgeGrips: EdgeGrip[] = (() => {
|
||||
// Geschlossener Ring aus Vertices → Kanten-Griffe mit Außennormale.
|
||||
const ringEdges = (verts: Vec2[], owner: { drawingId?: string; wallId?: string }): EdgeGrip[] => {
|
||||
const n = verts.length;
|
||||
if (n < 3) return [];
|
||||
// Schwerpunkt (Mittel der Eckpunkte) als Innenbezug.
|
||||
let cx = 0, cy = 0;
|
||||
for (const v of verts) { cx += v.x; cy += v.y; }
|
||||
const centroid: Vec2 = { x: cx / n, y: cy / n };
|
||||
const out: EdgeGrip[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const a = verts[i];
|
||||
const b = verts[(i + 1) % n];
|
||||
const mid: Vec2 = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
||||
const edge = sub(b, a);
|
||||
let nrm = normalize(leftNormal(edge));
|
||||
// Nach außen orientieren: Normale soll von centroid → mid weisen.
|
||||
const outward = sub(mid, centroid);
|
||||
if (nrm.x * outward.x + nrm.y * outward.y < 0) nrm = scale(nrm, -1);
|
||||
out.push({ mid, normal: nrm, aIndex: i, bIndex: (i + 1) % n, owner });
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// Offene Kette (Linie/offene Polylinie) → ein Griff je Segment, OHNE
|
||||
// Schlusskante. `normal` dient nur der Griff-Darstellung (leftNormal der
|
||||
// Kante); die Bewegung ist frei (volles Delta), nicht auf die Normale
|
||||
// beschränkt — daher `free: true`.
|
||||
const openEdges = (verts: Vec2[], owner: { drawingId?: string; wallId?: string }): EdgeGrip[] => {
|
||||
const n = verts.length;
|
||||
if (n < 2) return [];
|
||||
const out: EdgeGrip[] = [];
|
||||
for (let i = 0; i < n - 1; i++) {
|
||||
const a = verts[i];
|
||||
const b = verts[i + 1];
|
||||
const mid: Vec2 = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
||||
const nrm = normalize(leftNormal(sub(b, a)));
|
||||
out.push({ mid, normal: nrm, aIndex: i, bIndex: i + 1, free: true, owner });
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// ringEdges/openEdges/polylineEdgeGrips: s. edgeGrips.ts.
|
||||
// Decke: geschlossener Ring aus dem Umriss (Auswahl exklusiv, wie bei grips).
|
||||
if (modelEditable && selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
return ringEdges(selectedCeiling.outline, {});
|
||||
@@ -432,8 +395,7 @@ export function useGripEditing(opts: {
|
||||
const g = d.geom;
|
||||
const owner = { drawingId: id };
|
||||
if (g.shape === "rect" || g.shape === "image") out.push(...ringEdges(verts, owner));
|
||||
else if (g.shape === "polyline" && g.closed) out.push(...ringEdges(verts, owner));
|
||||
else if (g.shape === "polyline" && !g.closed) out.push(...openEdges(verts, owner));
|
||||
else if (g.shape === "polyline") out.push(...polylineEdgeGrips(g, owner));
|
||||
else if (g.shape === "spline" && g.closed) out.push(...ringEdges(verts, owner));
|
||||
else if (g.shape === "spline" && !g.closed) out.push(...openEdges(verts, owner));
|
||||
else if (g.shape === "line") out.push(...openEdges(verts, owner));
|
||||
|
||||
+82
-66
@@ -42,7 +42,7 @@ import {
|
||||
} from "./planView/primitives";
|
||||
import { DraftOverlay } from "./planView/overlays";
|
||||
import { visibleGripIndices } from "./planView/gripCull";
|
||||
import { VbCircle } from "./planView/vbCircle";
|
||||
import { localViewBoxAttr, makeToLocal, pickOverlayOrigin } from "./planView/overlayOrigin";
|
||||
import { PlanRulers } from "./planView/PlanRulers";
|
||||
import { PlanGrid } from "./planView/PlanGrid";
|
||||
import { expandRegion, indexedInRegion, regionContains, type Bounds } from "../../core";
|
||||
@@ -925,6 +925,13 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// der Resize-Beobachter stets den aktuellen Stand lesen (Handle hat leere Deps).
|
||||
const viewRef = useRef(view);
|
||||
viewRef.current = view;
|
||||
// Lokaler Ursprung des SVG-Overlays (viewBox-Einheiten, s. planView/overlayOrigin.ts): alles, was
|
||||
// ins DOM geht, ist relativ dazu (f32-sicher auch bei LV95); `view`, Treffer und Fang bleiben
|
||||
// absolut. Bleibt dasselbe Objekt, solange der Ausschnitt in der Nähe bleibt (Memos unten).
|
||||
const overlayOriginRef = useRef<Vec2 | null>(null);
|
||||
const overlayOrigin = pickOverlayOrigin(view, overlayOriginRef.current);
|
||||
overlayOriginRef.current = overlayOrigin;
|
||||
const toLocal = useMemo(() => makeToLocal(overlayOrigin), [overlayOrigin]);
|
||||
// Live-Massstab für bildschirmkonstante Overlays während Pan/Zoom (s. liveMeet.tsx).
|
||||
const meetStore = useMemo(() => createMeetStore(), []);
|
||||
// Live-Ausschnitt (Lineal) während Pan/Zoom.
|
||||
@@ -1861,7 +1868,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
// Frame SCHARF neu gerastert (ein CSS-Transform würde die Ebene als Bitmap
|
||||
// strecken → verpixelt). Bildschirmkonstante Griffe skalieren dabei mit.
|
||||
svg.style.transform = "";
|
||||
svg.setAttribute("viewBox", `${v.x} ${v.y} ${v.w} ${v.h}`);
|
||||
svg.setAttribute("viewBox", localViewBoxAttr(v, overlayOriginRef.current ?? { x: 0, y: 0 }));
|
||||
return;
|
||||
}
|
||||
// Schweres Overlay (z. B. riesiger Auswahlpfad): GPU-komponierter CSS-Transform.
|
||||
@@ -2543,8 +2550,17 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
const wheelCommitTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const WHEEL_COMMIT_MS = 70;
|
||||
|
||||
// Seiten-Scroll/-Zoom des Browsers beim Rad über dem Plan unterdrücken: React hängt `onWheel`
|
||||
// passiv an (dort `preventDefault` wirkungslos, Chromium meldet einen Konsolenfehler) — daher
|
||||
// ein eigener, nicht-passiver Listener am SVG.
|
||||
useEffect(() => {
|
||||
const el = svgRef.current;
|
||||
if (!el) return;
|
||||
const stop = (e: WheelEvent) => e.preventDefault();
|
||||
el.addEventListener("wheel", stop, { passive: false });
|
||||
return () => el.removeEventListener("wheel", stop);
|
||||
}, []);
|
||||
const onWheel = (e: React.WheelEvent<SVGSVGElement>) => {
|
||||
e.preventDefault();
|
||||
if (useGpuRenderer) {
|
||||
// Aktueller (logischer) Ausschnitt: ein laufender imperativer Zoom/Pan gewinnt.
|
||||
const base = panPending.current ?? viewRef.current;
|
||||
@@ -2724,26 +2740,24 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
const parts: string[] = [];
|
||||
for (const p of highlightDrawPrims) {
|
||||
if (p.kind === "line") {
|
||||
const a = toScreen(p.a), b = toScreen(p.b);
|
||||
const a = toLocal(p.a), b = toLocal(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);
|
||||
const q = p.pts.map(toLocal);
|
||||
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, nativeHighlight]);
|
||||
}, [highlightDrawPrims, nativeHighlight, toLocal]);
|
||||
overlayHeavyRef.current = highlightDrawPath.length > 300_000;
|
||||
const highlightTextPath = useMemo(() => {
|
||||
const parts: string[] = [];
|
||||
for (const p of highlightTextFrames) {
|
||||
const q = textFrameCorners(p).map(toScreen);
|
||||
const q = textFrameCorners(p).map(toLocal);
|
||||
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]);
|
||||
}, [highlightTextFrames, toLocal]);
|
||||
|
||||
// Hervorhebung der selektierten Decken: alle Polygone JEDER gewählten Decke
|
||||
// (Fläche + Umriss) mit Akzentkontur überzeichnen — analog zur Wand-Auswahl.
|
||||
@@ -2976,14 +2990,13 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={i}
|
||||
p={p}
|
||||
index={i}
|
||||
toScreen={toScreen}
|
||||
toScreen={toLocal}
|
||||
hairline={!!hairline}
|
||||
paperScale={paperScale}
|
||||
/>
|
||||
),
|
||||
),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- toScreen ist modulweit konstant
|
||||
[culledIndexed, hairline, paperScale, editTextId],
|
||||
[culledIndexed, hairline, paperScale, editTextId, toLocal],
|
||||
);
|
||||
const drawingRunEls = useMemo(
|
||||
() =>
|
||||
@@ -2994,13 +3007,12 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<DrawingRunShape
|
||||
key={`run-${i}`}
|
||||
run={run}
|
||||
toScreen={toScreen}
|
||||
toScreen={toLocal}
|
||||
hairline={!!hairline}
|
||||
paperScale={paperScale}
|
||||
/>
|
||||
)),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- toScreen ist modulweit konstant
|
||||
[drawingRuns, hairline, paperScale, useGpuRenderer],
|
||||
[drawingRuns, hairline, paperScale, useGpuRenderer, toLocal],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -3041,7 +3053,9 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<svg
|
||||
ref={svgRef}
|
||||
className="plan-svg"
|
||||
viewBox={`${view.x} ${view.y} ${view.w} ${view.h}`}
|
||||
viewBox={localViewBoxAttr(view, overlayOrigin)}
|
||||
data-origin-x={overlayOrigin.x}
|
||||
data-origin-y={overlayOrigin.y}
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
onPointerDown={onPointerDown}
|
||||
onPointerMove={onPointerMove}
|
||||
@@ -3085,8 +3099,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
aktivem GL löscht die WebGL-Ebene das Blatt → hier transparent halten
|
||||
(bleibt aber Klick-/Pan-Trefferfläche für Leerraum). */}
|
||||
<rect
|
||||
x={view.x}
|
||||
y={view.y}
|
||||
x={view.x - overlayOrigin.x}
|
||||
y={view.y - overlayOrigin.y}
|
||||
width={view.w}
|
||||
height={view.h}
|
||||
className={useGpuRenderer ? undefined : "plan-bg"}
|
||||
@@ -3098,6 +3112,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
{showGrid && (
|
||||
<PlanGrid
|
||||
vb={{ x0: view.x, y0: view.y, w: view.w, h: view.h }}
|
||||
origin={overlayOrigin}
|
||||
pxPerMeter={currentPxPerMeter()}
|
||||
/>
|
||||
)}
|
||||
@@ -3114,8 +3129,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<image
|
||||
key={img.id}
|
||||
href={img.src}
|
||||
x={img.min.x * PX_PER_M}
|
||||
y={-img.max.y * PX_PER_M}
|
||||
x={img.min.x * PX_PER_M - overlayOrigin.x}
|
||||
y={-img.max.y * PX_PER_M - overlayOrigin.y}
|
||||
width={w}
|
||||
height={h}
|
||||
opacity={img.opacity}
|
||||
@@ -3144,7 +3159,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`sel-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3156,7 +3171,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selc-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3168,7 +3183,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selrm-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3180,7 +3195,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selrf-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3192,7 +3207,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selctx-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3204,7 +3219,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selsl-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3216,7 +3231,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selex-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3228,7 +3243,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selcol-${i}`}
|
||||
className="plan-selected"
|
||||
points={poly.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3240,20 +3255,20 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<line
|
||||
key={`selo-${i}`}
|
||||
className="plan-sel-draw"
|
||||
x1={toScreen(p.a).x}
|
||||
y1={toScreen(p.a).y}
|
||||
x2={toScreen(p.b).x}
|
||||
y2={toScreen(p.b).y}
|
||||
x1={toLocal(p.a).x}
|
||||
y1={toLocal(p.a).y}
|
||||
x2={toLocal(p.b).x}
|
||||
y2={toLocal(p.b).y}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
) : p.kind === "arc" ? (
|
||||
<line
|
||||
key={`selo-${i}`}
|
||||
className="plan-sel-draw"
|
||||
x1={toScreen(p.from).x}
|
||||
y1={toScreen(p.from).y}
|
||||
x2={toScreen(p.to).x}
|
||||
y2={toScreen(p.to).y}
|
||||
x1={toLocal(p.from).x}
|
||||
y1={toLocal(p.from).y}
|
||||
x2={toLocal(p.to).x}
|
||||
y2={toLocal(p.to).y}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
) : (
|
||||
@@ -3261,7 +3276,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selo-${i}`}
|
||||
className="plan-sel-draw"
|
||||
points={p.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3274,10 +3289,10 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<line
|
||||
key={`selst-${i}`}
|
||||
className="plan-sel-draw"
|
||||
x1={toScreen(p.a).x}
|
||||
y1={toScreen(p.a).y}
|
||||
x2={toScreen(p.b).x}
|
||||
y2={toScreen(p.b).y}
|
||||
x1={toLocal(p.a).x}
|
||||
y1={toLocal(p.a).y}
|
||||
x2={toLocal(p.b).x}
|
||||
y2={toLocal(p.b).y}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
) : (
|
||||
@@ -3285,7 +3300,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
key={`selst-${i}`}
|
||||
className="plan-selected"
|
||||
points={p.pts
|
||||
.map(toScreen)
|
||||
.map(toLocal)
|
||||
.map((s) => `${s.x},${s.y}`)
|
||||
.join(" ")}
|
||||
pointerEvents="none"
|
||||
@@ -3308,10 +3323,10 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
{/* Gruppen-Auswahl: nur eine Bounding-Box mit vier Eckpunkten (kein
|
||||
Umriss jedes einzelnen Mitglieds) — s. `groupBBox`. */}
|
||||
{groupBBox && (<LiveMeet store={meetStore} base={meetScale(view, canvasRef.current ?? svgRef.current) ?? 1}>{(meet) => {
|
||||
const c1 = toScreen({ x: groupBBox.minX, y: groupBBox.minY });
|
||||
const c2 = toScreen({ x: groupBBox.maxX, y: groupBBox.minY });
|
||||
const c3 = toScreen({ x: groupBBox.maxX, y: groupBBox.maxY });
|
||||
const c4 = toScreen({ x: groupBBox.minX, y: groupBBox.maxY });
|
||||
const c1 = toLocal({ x: groupBBox.minX, y: groupBBox.minY });
|
||||
const c2 = toLocal({ x: groupBBox.maxX, y: groupBBox.minY });
|
||||
const c3 = toLocal({ x: groupBBox.maxX, y: groupBBox.maxY });
|
||||
const c4 = toLocal({ x: groupBBox.minX, y: groupBBox.maxY });
|
||||
const size = (4 * gripK(meet)) / meet;
|
||||
const corners = [c1, c2, c3, c4];
|
||||
return (
|
||||
@@ -3322,7 +3337,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
pointerEvents="none"
|
||||
/>
|
||||
{corners.map((s, i) => (
|
||||
<VbCircle
|
||||
<circle
|
||||
key={`gbb-${i}`}
|
||||
className="plan-grip plan-group-bbox-corner"
|
||||
cx={s.x}
|
||||
@@ -3340,16 +3355,16 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<g className="plan-hover-pick" pointerEvents="none">
|
||||
{hoverPrims.map((p, i) => {
|
||||
const key = `hp-${i}`;
|
||||
const pts = (list: Vec2[]) => list.map(toScreen).map((q) => `${q.x},${q.y}`).join(" ");
|
||||
const pts = (list: Vec2[]) => list.map(toLocal).map((q) => `${q.x},${q.y}`).join(" ");
|
||||
switch (p.kind) {
|
||||
case "line":
|
||||
return <line key={key} x1={toScreen(p.a).x} y1={toScreen(p.a).y} x2={toScreen(p.b).x} y2={toScreen(p.b).y} />;
|
||||
return <line key={key} x1={toLocal(p.a).x} y1={toLocal(p.a).y} x2={toLocal(p.b).x} y2={toLocal(p.b).y} />;
|
||||
case "arc":
|
||||
return <line key={key} x1={toScreen(p.from).x} y1={toScreen(p.from).y} x2={toScreen(p.to).x} y2={toScreen(p.to).y} />;
|
||||
return <line key={key} x1={toLocal(p.from).x} y1={toLocal(p.from).y} x2={toLocal(p.to).x} y2={toLocal(p.to).y} />;
|
||||
case "polygon":
|
||||
return <polygon key={key} className="plan-hover-fill" points={pts(p.pts)} />;
|
||||
case "drawingCircle": {
|
||||
const c = toScreen(p.center);
|
||||
const c = toLocal(p.center);
|
||||
return <circle key={key} cx={c.x} cy={c.y} r={p.r * PX_PER_M} />;
|
||||
}
|
||||
case "drawingArc": {
|
||||
@@ -3387,8 +3402,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
? "plan-marquee plan-marquee-crossing"
|
||||
: "plan-marquee"
|
||||
}
|
||||
x={marqueeRect.x}
|
||||
y={marqueeRect.y}
|
||||
x={marqueeRect.x - overlayOrigin.x}
|
||||
y={marqueeRect.y - overlayOrigin.y}
|
||||
width={marqueeRect.w}
|
||||
height={marqueeRect.h}
|
||||
style={{ stroke: marqueeColor, fill: marqueeColor }}
|
||||
@@ -3403,10 +3418,10 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
<line
|
||||
key={`gripline-${i}`}
|
||||
className="plan-grip-line"
|
||||
x1={toScreen(l.a).x}
|
||||
y1={toScreen(l.a).y}
|
||||
x2={toScreen(l.b).x}
|
||||
y2={toScreen(l.b).y}
|
||||
x1={toLocal(l.a).x}
|
||||
y1={toLocal(l.a).y}
|
||||
x2={toLocal(l.b).x}
|
||||
y2={toLocal(l.b).y}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
))}
|
||||
@@ -3419,10 +3434,10 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
{(meet) =>
|
||||
// Viele Griffe (Kataster): nur die sichtbaren zeichnen (gripCull.ts).
|
||||
(visibleGripIndices(grips!, toScreen, view, meet) ?? grips!.map((_, i) => i)).map((i) => {
|
||||
const s = toScreen(grips![i]);
|
||||
const s = toLocal(grips![i]);
|
||||
const size = (4.5 * gripK(meet)) / meet;
|
||||
return (
|
||||
<VbCircle
|
||||
<circle
|
||||
key={`grip-${i}`}
|
||||
className="plan-grip"
|
||||
cx={s.x}
|
||||
@@ -3440,7 +3455,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
Editor. Bildschirmkonstante Größe. */}
|
||||
{roomStamp && (
|
||||
<LiveMeet store={meetStore} base={meetScale(view, canvasRef.current ?? svgRef.current) ?? 1}>{(meet) => {
|
||||
const s = toScreen(roomStamp.anchor);
|
||||
const s = toLocal(roomStamp.anchor);
|
||||
const size = 4 / meet;
|
||||
const pts = [
|
||||
`${s.x},${s.y - size}`,
|
||||
@@ -3466,7 +3481,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
{(s) =>
|
||||
(visibleGripIndices(edgeGrips!.map((g) => g.mid), toScreen, view, s) ?? edgeGrips!.map((_, i) => i)).map((i) => {
|
||||
const eg = edgeGrips![i];
|
||||
const m = toScreen(eg.mid);
|
||||
const m = toLocal(eg.mid);
|
||||
// Normale in den Bildschirmraum (Y spiegeln); auf Bildschirm-px-Größen.
|
||||
const sn = screenNormal(eg.normal);
|
||||
const hVb = (EDGE_GRIP_H_PX * gripK(s)) / s; // Dreieckshöhe (nach außen)
|
||||
@@ -3501,7 +3516,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
{(meet) => (
|
||||
<DraftOverlay
|
||||
draft={toolHandlers.draft!}
|
||||
toScreen={toScreen}
|
||||
toScreen={toLocal}
|
||||
vbPerPx={1 / meet}
|
||||
snapColor={snapColor}
|
||||
hudFields={hudFields ?? null}
|
||||
@@ -3524,9 +3539,9 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
return (
|
||||
<g className="plan-hover-divide" pointerEvents="none">
|
||||
{pts.map((pt, i) => {
|
||||
const s = toScreen(pt);
|
||||
const s = toLocal(pt);
|
||||
return (
|
||||
<VbCircle
|
||||
<circle
|
||||
key={i}
|
||||
cx={s.x}
|
||||
cy={s.y}
|
||||
@@ -3651,7 +3666,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
return (
|
||||
<svg
|
||||
className="plan-ruler-overlay"
|
||||
viewBox={`${vb.x0} ${vb.y0} ${vb.w} ${vb.h}`}
|
||||
viewBox={`${vb.x0 - overlayOrigin.x} ${vb.y0 - overlayOrigin.y} ${vb.w} ${vb.h}`}
|
||||
preserveAspectRatio="none"
|
||||
style={{
|
||||
position: "absolute",
|
||||
@@ -3664,6 +3679,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
|
||||
>
|
||||
<LiveRulers
|
||||
vb={vb}
|
||||
origin={overlayOrigin}
|
||||
vbPerPx={1 / scale}
|
||||
pxPerMeter={scale * PX_PER_M}
|
||||
store={rulerCursor}
|
||||
|
||||
@@ -6,15 +6,19 @@
|
||||
// (`ZOOM_MIN`/`ZOOM_MAX` in PlanView.tsx) auf ≤ ~Bildschirmbreite/64px
|
||||
// begrenzt, unabhängig davon, wie weit heraus- oder hereingezoomt ist.
|
||||
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import { PX_PER_M } from "../../../core";
|
||||
import { rulerStep } from "./PlanRulers";
|
||||
|
||||
export function PlanGrid({
|
||||
vb,
|
||||
origin = { x: 0, y: 0 },
|
||||
pxPerMeter,
|
||||
}: {
|
||||
/** Sichtbarer Ausschnitt in viewBox-Einheiten. */
|
||||
/** Sichtbarer Ausschnitt in (absoluten) viewBox-Einheiten. */
|
||||
vb: { x0: number; y0: number; w: number; h: number };
|
||||
/** Lokaler Ursprung des Overlays (s. `overlayOrigin.ts`), wird vor dem Zeichnen abgezogen. */
|
||||
origin?: Vec2;
|
||||
pxPerMeter: number;
|
||||
}) {
|
||||
const step = rulerStep(pxPerMeter);
|
||||
@@ -26,18 +30,22 @@ export function PlanGrid({
|
||||
const myTop = -vb.y0 / PX_PER_M;
|
||||
const myBottom = -(vb.y0 + vb.h) / PX_PER_M;
|
||||
|
||||
// Ganzzahliger Index statt aufsummiertem `v += step` (driftet bei Landeskoordinaten).
|
||||
const xs: number[] = [];
|
||||
for (let v = Math.ceil(mx0 / step) * step; v <= mx1 + 1e-9; v += step) xs.push(v);
|
||||
for (let k = Math.ceil(mx0 / step); k * step <= mx1 + 1e-9; k++) xs.push(k * step);
|
||||
const ys: number[] = [];
|
||||
for (let v = Math.ceil(myBottom / step) * step; v <= myTop + 1e-9; v += step) ys.push(v);
|
||||
for (let k = Math.ceil(myBottom / step); k * step <= myTop + 1e-9; k++) ys.push(k * step);
|
||||
|
||||
// Lokal zeichnen (minus Ursprung), s. `overlayOrigin.ts`.
|
||||
const x0 = vb.x0 - origin.x;
|
||||
const y0 = vb.y0 - origin.y;
|
||||
return (
|
||||
<g className="plan-grid" pointerEvents="none">
|
||||
{xs.map((v, i) => (
|
||||
<line key={`gx${i}`} x1={v * PX_PER_M} y1={vb.y0} x2={v * PX_PER_M} y2={vb.y0 + vb.h} />
|
||||
<line key={`gx${i}`} x1={v * PX_PER_M - origin.x} y1={y0} x2={v * PX_PER_M - origin.x} y2={y0 + vb.h} />
|
||||
))}
|
||||
{ys.map((v, i) => (
|
||||
<line key={`gy${i}`} x1={vb.x0} y1={-v * PX_PER_M} x2={vb.x0 + vb.w} y2={-v * PX_PER_M} />
|
||||
<line key={`gy${i}`} x1={x0} y1={-v * PX_PER_M - origin.y} x2={x0 + vb.w} y2={-v * PX_PER_M - origin.y} />
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
|
||||
@@ -26,12 +26,18 @@ export function rulerStep(pxPerMeter: number): number {
|
||||
*/
|
||||
export function PlanRulers({
|
||||
vb,
|
||||
origin = { x: 0, y: 0 },
|
||||
vbPerPx,
|
||||
pxPerMeter,
|
||||
cursor,
|
||||
}: {
|
||||
/** Sichtbarer Ausschnitt in viewBox-Einheiten. */
|
||||
/** Sichtbarer Ausschnitt in (absoluten) viewBox-Einheiten. */
|
||||
vb: { x0: number; y0: number; w: number; h: number };
|
||||
/**
|
||||
* Lokaler Ursprung (viewBox-Einheiten, s. `overlayOrigin.ts`): gezeichnet wird relativ dazu,
|
||||
* damit bei Landeskoordinaten keine Werte über f32/CSS-Längen-Grenzen ins DOM gehen.
|
||||
*/
|
||||
origin?: Vec2;
|
||||
vbPerPx: number;
|
||||
pxPerMeter: number;
|
||||
cursor: Vec2 | null;
|
||||
@@ -49,21 +55,22 @@ export function PlanRulers({
|
||||
const myTop = -vb.y0 / PX_PER_M;
|
||||
const myBottom = -(vb.y0 + vb.h) / PX_PER_M;
|
||||
|
||||
// Ticks über den ganzzahligen Index k (Wert k · minor, Hauptstrich bei k mod 5 = 0): ein
|
||||
// aufsummiertes `v += minor` driftet bei Landeskoordinaten (≈ 2.6e6 m) und verliert Hauptstriche.
|
||||
// Positionen lokal (minus Ursprung), Beschriftung absolut.
|
||||
const xTicks: { vbX: number; model: number; major: boolean }[] = [];
|
||||
const startX = Math.floor(mx0 / minor) * minor;
|
||||
for (let v = startX; v <= mx1 + 1e-9; v += minor) {
|
||||
const major = Math.abs(v / step - Math.round(v / step)) < 1e-6;
|
||||
xTicks.push({ vbX: v * PX_PER_M, model: v, major });
|
||||
for (let k = Math.floor(mx0 / minor); k * minor <= mx1 + 1e-9; k++) {
|
||||
const v = k * minor;
|
||||
xTicks.push({ vbX: v * PX_PER_M - origin.x, model: v, major: k % 5 === 0 });
|
||||
}
|
||||
const yTicks: { vbY: number; model: number; major: boolean }[] = [];
|
||||
const startY = Math.floor(myBottom / minor) * minor;
|
||||
for (let v = startY; v <= myTop + 1e-9; v += minor) {
|
||||
const major = Math.abs(v / step - Math.round(v / step)) < 1e-6;
|
||||
yTicks.push({ vbY: -v * PX_PER_M, model: v, major });
|
||||
for (let k = Math.floor(myBottom / minor); k * minor <= myTop + 1e-9; k++) {
|
||||
const v = k * minor;
|
||||
yTicks.push({ vbY: -v * PX_PER_M - origin.y, model: v, major: k % 5 === 0 });
|
||||
}
|
||||
|
||||
const x0 = vb.x0;
|
||||
const y0 = vb.y0;
|
||||
const x0 = vb.x0 - origin.x;
|
||||
const y0 = vb.y0 - origin.y;
|
||||
return (
|
||||
<g className="plan-ruler" pointerEvents="none">
|
||||
{/* Leisten + Trennlinien. */}
|
||||
@@ -120,7 +127,7 @@ export function PlanRulers({
|
||||
<>
|
||||
<rect
|
||||
className="plan-ruler-cursor"
|
||||
x={cursor.x * PX_PER_M - 1 * vbPerPx}
|
||||
x={cursor.x * PX_PER_M - origin.x - 1 * vbPerPx}
|
||||
y={y0}
|
||||
width={2 * vbPerPx}
|
||||
height={TH}
|
||||
@@ -128,7 +135,7 @@ export function PlanRulers({
|
||||
<rect
|
||||
className="plan-ruler-cursor"
|
||||
x={x0}
|
||||
y={-cursor.y * PX_PER_M - 1 * vbPerPx}
|
||||
y={-cursor.y * PX_PER_M - origin.y - 1 * vbPerPx}
|
||||
width={TH}
|
||||
height={2 * vbPerPx}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ORIGIN_REACH, localView, localViewBoxAttr, makeToLocal, pickOverlayOrigin } from "./overlayOrigin";
|
||||
|
||||
const PX = 90;
|
||||
const E = 2_600_000;
|
||||
const N = 1_200_000;
|
||||
/** Ausschnitt `wM` Meter breit (Seitenverhältnis 3:2) um den Modellpunkt (cx, cy). */
|
||||
const viewAt = (cx: number, cy: number, wM: number) => {
|
||||
const w = wM * PX;
|
||||
const h = (wM * PX * 2) / 3;
|
||||
return { x: cx * PX - w / 2, y: -cy * PX - h / 2, w, h };
|
||||
};
|
||||
|
||||
describe("pickOverlayOrigin", () => {
|
||||
it("lokales Projekt: Ursprung bleibt (0, 0) — Overlay wie bisher", () => {
|
||||
expect(pickOverlayOrigin(viewAt(10, 5, 40), null)).toEqual({ x: 0, y: 0 });
|
||||
expect(pickOverlayOrigin(viewAt(10, 5, 1), null)).toEqual({ x: 0, y: 0 });
|
||||
expect(pickOverlayOrigin(viewAt(-300, 200, 600), null)).toEqual({ x: 0, y: 0 });
|
||||
});
|
||||
|
||||
it("LV95: Ursprung nahe der Ausschnitt-Mitte, lokale Werte klein", () => {
|
||||
for (const wM of [500, 11, 1.5, 0.05]) {
|
||||
const v = viewAt(E + 37.25, N + 12.5, wM);
|
||||
const o = pickOverlayOrigin(v, null);
|
||||
const lv = localView(v, o);
|
||||
const size = Math.max(v.w, v.h);
|
||||
expect(Math.abs(lv.x) + lv.w).toBeLessThan(ORIGIN_REACH * size);
|
||||
expect(Math.abs(lv.y) + lv.h).toBeLessThan(ORIGIN_REACH * size);
|
||||
expect(Math.abs(o.x - (v.x + v.w / 2))).toBeLessThanOrEqual(size);
|
||||
}
|
||||
});
|
||||
|
||||
it("Ursprung bleibt beim Schwenken/Zoomen in der Nähe (gleiches Objekt) und springt erst weit weg", () => {
|
||||
const o = pickOverlayOrigin(viewAt(E, N, 50), null);
|
||||
expect(pickOverlayOrigin(viewAt(E + 300, N - 200, 50), o)).toBe(o);
|
||||
expect(pickOverlayOrigin(viewAt(E + 10, N, 2), o)).toBe(o);
|
||||
const far = pickOverlayOrigin(viewAt(E + 10, N, 0.1), o);
|
||||
expect(far).not.toBe(o);
|
||||
// Zurück ins lokale Gebiet → wieder (0, 0).
|
||||
expect(pickOverlayOrigin(viewAt(3, 3, 30), far)).toEqual({ x: 0, y: 0 });
|
||||
});
|
||||
|
||||
it("unsinniger Ausschnitt → bisheriger Ursprung", () => {
|
||||
const o = { x: 5, y: 6 };
|
||||
expect(pickOverlayOrigin({ x: NaN, y: 0, w: 1, h: 1 }, o)).toBe(o);
|
||||
expect(pickOverlayOrigin({ x: 0, y: 0, w: 0, h: 0 }, null)).toEqual({ x: 0, y: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("lokale Abbildung", () => {
|
||||
it("toLocal = toScreen − Ursprung; viewBox-Attribut lokal", () => {
|
||||
const o = { x: 900, y: -450 };
|
||||
expect(makeToLocal(o)({ x: 20, y: 10 })).toEqual({ x: 20 * PX - 900, y: -10 * PX + 450 });
|
||||
expect(localViewBoxAttr({ x: 1000, y: -500, w: 30, h: 20 }, o)).toBe("100 -50 30 20");
|
||||
});
|
||||
|
||||
it("f32-Fehler eines Griffs bei LV95 im 1-m-Ausschnitt: absolut px-weit daneben, lokal < 0.01 px", () => {
|
||||
const corner = { x: E + 68.123, y: N + 68.456 };
|
||||
const v = viewAt(corner.x + 0.2, corner.y - 0.1, 1);
|
||||
const pxPerUnit = 1500 / v.w; // 1500 px breite Fläche
|
||||
// Bildschirm-Abstand zum Ausschnitt-Rand, wie ihn der Browser in f32 rechnet, gegen f64.
|
||||
const err = (x: number, vx: number) => Math.abs(Math.fround(x) - Math.fround(vx) - (x - vx)) * pxPerUnit;
|
||||
expect(err(corner.x * PX, v.x)).toBeGreaterThan(1); // bisher: absolut
|
||||
const o = pickOverlayOrigin(v, null);
|
||||
const s = makeToLocal(o)(corner);
|
||||
const lv = localView(v, o);
|
||||
expect(err(s.x, lv.x)).toBeLessThan(0.01);
|
||||
expect(err(s.y, lv.y)).toBeLessThan(0.01);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
// Lokaler Ursprung des SVG-Overlays der Plan-Ansicht ([G10], 29.10.).
|
||||
//
|
||||
// Das Overlay (Griffe, Fang-Marken, Hervorhebung, Vorschau, Texte, Raster, Lineal, HUD, Marquee)
|
||||
// zeichnet in viewBox-Einheiten = Modell-m · PX_PER_M. Browser rechnen SVG-Koordinaten in f32 und
|
||||
// klemmen CSS-Längen (`cx`, `x`, `width` …) auf ±33.5 Mio.: bei Landeskoordinaten LV95
|
||||
// (≈ 2.6e6 m → 2.3e8 Einheiten) lagen Griffe beim Hineinzoomen pixelweit neben der Ecke, Lineal und
|
||||
// Kreise fehlten ganz. Darum zieht die Ansicht vor dem Schreiben ins DOM (in f64) einen Ursprung
|
||||
// nahe dem Ausschnitt ab — alle Werte im DOM bleiben klein. Ausschnitt (`view`), Treffer und Fang
|
||||
// rechnen weiter absolut in f64; nur die Darstellung ist verschoben.
|
||||
//
|
||||
// Der Ursprung bleibt stehen, solange der Ausschnitt in f32 genau genug darstellbar ist (sonst
|
||||
// müsste jedes Schwenken den ganzen Overlay-Baum neu aufbauen). Bei lokal gezeichneten Projekten
|
||||
// bleibt er praktisch immer (0, 0) — das Overlay ist dann gleich wie vor der Umstellung.
|
||||
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import type { ViewBox__plan_planView_geometry as ViewBox } from "../../../core";
|
||||
import { PX_PER_M } from "../../../core";
|
||||
|
||||
/**
|
||||
* Höchster Abstand (in Ausschnitt-Grössen) einer Ausschnitt-Kante vom Ursprung. f32 hat ~6e-8
|
||||
* relative Genauigkeit: bei Abstand d und Ausschnitt-Breite w (≈ 2000 px) ist der Fehler
|
||||
* ≈ d/w · 1.2e-4 px; 64 → unter 0.01 px.
|
||||
*/
|
||||
export const ORIGIN_REACH = 64;
|
||||
|
||||
const ZERO: Vec2 = Object.freeze({ x: 0, y: 0 });
|
||||
|
||||
/** Weitester Abstand einer Ausschnitt-Kante vom Ursprung, gemessen in Ausschnitt-Grössen. */
|
||||
function reach(view: ViewBox, o: Vec2): number {
|
||||
const size = Math.max(view.w, view.h);
|
||||
const d = Math.max(
|
||||
Math.abs(view.x - o.x),
|
||||
Math.abs(view.x + view.w - o.x),
|
||||
Math.abs(view.y - o.y),
|
||||
Math.abs(view.y + view.h - o.y),
|
||||
);
|
||||
return d / size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ursprung (viewBox-Einheiten) für den Ausschnitt `view`. `prev` bleibt (gleiches Objekt), solange
|
||||
* er nah genug liegt; sonst (0, 0), wenn das reicht, sonst die auf eine Zehnerpotenz unter der
|
||||
* Ausschnitt-Grösse gerundete Mitte. Unsinnige Ausschnitte → `prev` bzw. (0, 0).
|
||||
*/
|
||||
export function pickOverlayOrigin(view: ViewBox, prev: Vec2 | null): Vec2 {
|
||||
const size = Math.max(view.w, view.h);
|
||||
if (![view.x, view.y, view.w, view.h].every(Number.isFinite) || !(size > 0)) return prev ?? ZERO;
|
||||
if (prev && reach(view, prev) <= ORIGIN_REACH) return prev;
|
||||
if (reach(view, ZERO) <= ORIGIN_REACH) return ZERO;
|
||||
const step = Math.pow(10, Math.floor(Math.log10(size)));
|
||||
return {
|
||||
x: Math.round((view.x + view.w / 2) / step) * step,
|
||||
y: Math.round((view.y + view.h / 2) / step) * step,
|
||||
};
|
||||
}
|
||||
|
||||
/** Modell (m) → lokale viewBox-Einheiten: wie `toScreen`, minus Ursprung (in f64). */
|
||||
export function makeToLocal(o: Vec2): (p: Vec2) => Vec2 {
|
||||
return (p) => ({ x: p.x * PX_PER_M - o.x, y: -p.y * PX_PER_M - o.y });
|
||||
}
|
||||
|
||||
/** Absoluter Ausschnitt → lokaler. */
|
||||
export function localView(view: ViewBox, o: Vec2): ViewBox {
|
||||
return { x: view.x - o.x, y: view.y - o.y, w: view.w, h: view.h };
|
||||
}
|
||||
|
||||
/** `viewBox`-Attribut des lokalen Ausschnitts. */
|
||||
export function localViewBoxAttr(view: ViewBox, o: Vec2): string {
|
||||
return `${view.x - o.x} ${view.y - o.y} ${view.w} ${view.h}`;
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import type { SnapResult, ToolDraft } from "../../../tools/types";
|
||||
import { hudSegments, type HudFieldsState } from "../../../tools/hudFormat";
|
||||
import { VbCircle } from "./vbCircle";
|
||||
|
||||
/**
|
||||
* Zeichnet die Werkzeug-Vorschau: Vorschau-Formen (gestrichelte Akzentlinien /
|
||||
@@ -59,7 +58,7 @@ export function DraftOverlay({
|
||||
{draft.vertices.map((v, i) => {
|
||||
const s = toScreen(v);
|
||||
return (
|
||||
<VbCircle
|
||||
<circle
|
||||
key={`v${i}`}
|
||||
className="tool-vertex"
|
||||
cx={s.x}
|
||||
@@ -290,7 +289,7 @@ function SnapMarker({
|
||||
/>
|
||||
)}
|
||||
{snap.kind === "grid" && (
|
||||
<VbCircle
|
||||
<circle
|
||||
className="snap-glyph snap-fill"
|
||||
cx={s.x}
|
||||
cy={s.y}
|
||||
@@ -328,7 +327,7 @@ function SnapMarker({
|
||||
</>
|
||||
)}
|
||||
{(snap.kind === "center" || snap.kind === "quadrant") && (
|
||||
<VbCircle className="snap-glyph" cx={s.x} cy={s.y} r={r} style={glyphStyle} vectorEffect="non-scaling-stroke" />
|
||||
<circle className="snap-glyph" cx={s.x} cy={s.y} r={r} style={glyphStyle} vectorEffect="non-scaling-stroke" />
|
||||
)}
|
||||
{snap.kind === "onEdge" && (
|
||||
<polygon
|
||||
@@ -353,7 +352,7 @@ function SnapMarker({
|
||||
{/* Tangente: kleiner Kreis (wie „center") plus eine kurze Berührlinie. */}
|
||||
{snap.kind === "tangent" && (
|
||||
<>
|
||||
<VbCircle className="snap-glyph" cx={s.x} cy={s.y} r={r * 0.7} style={glyphStyle} vectorEffect="non-scaling-stroke" />
|
||||
<circle className="snap-glyph" cx={s.x} cy={s.y} r={r * 0.7} style={glyphStyle} vectorEffect="non-scaling-stroke" />
|
||||
<line
|
||||
className="snap-glyph"
|
||||
x1={s.x - r}
|
||||
@@ -373,7 +372,7 @@ function SnapMarker({
|
||||
</>
|
||||
)}
|
||||
{(snap.kind === "endpoint" || snap.kind === "ortho" || snap.kind === "extension") && (
|
||||
<VbCircle
|
||||
<circle
|
||||
className="snap-glyph"
|
||||
cx={s.x}
|
||||
cy={s.y}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { circlePoints } from "./vbCircle";
|
||||
|
||||
describe("circlePoints", () => {
|
||||
it("Vieleck um den Mittelpunkt, auch bei LV95-viewBox-Koordinaten (≈ 2.3e8)", () => {
|
||||
const cx = 2_600_068 * 90;
|
||||
const cy = -1_200_068 * 90;
|
||||
const pts = circlePoints(cx, cy, 4).split(" ").map((p) => p.split(",").map(Number));
|
||||
expect(pts).toHaveLength(24);
|
||||
for (const [x, y] of pts) expect(Math.hypot(x - cx, y - cy)).toBeCloseTo(4, 6);
|
||||
});
|
||||
|
||||
it("unsinnige Eingaben ergeben kein Vieleck", () => {
|
||||
expect(circlePoints(Number.NaN, 0, 1)).toBe("");
|
||||
expect(circlePoints(0, 0, -1)).toBe("");
|
||||
});
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
// Kleiner Kreis im Plan-SVG als Vieleck (`<polygon points>`) statt `<circle cx cy r>`.
|
||||
//
|
||||
// Grund (Kataster-Fund 29.10.): `cx`/`cy`/`r` sind in SVG 2 CSS-Eigenschaften; Chromium und WebKit
|
||||
// klemmen CSS-Längen auf ±33 554 429 (LayoutUnit-Bereich). Die viewBox-Einheiten des Plans sind
|
||||
// Meter · 90 (`toScreen`), Landeskoordinaten LV95 (≈ 2.6e6 m) liegen also bei ≈ 2.3e8 — ein
|
||||
// `<circle>` dort landet weit ausserhalb des Bildes: Editier-Griffe und Fang-Marken eines
|
||||
// importierten Katasters waren unsichtbar („keine Eckpunkte"). Die Punkte eines `<polygon>` sind
|
||||
// keine CSS-Längen und werden nicht geklemmt (ab ~370 km vom Modell-Ursprung betroffen, auch LV03).
|
||||
//
|
||||
// Rest: Der Browser rechnet SVG-Koordinaten in f32 (bei 2.3e8 auf ±8 viewBox-Einheiten genau); bei
|
||||
// starkem Zoom liegt ein Griff dann einige Pixel neben der Ecke (Treffer rechnet PlanView in f64).
|
||||
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
/** Eckenzahl des Vielecks (bei Griff-Grösse ~5 px nicht von einem Kreis zu unterscheiden). */
|
||||
const SIDES = 24;
|
||||
|
||||
/** `points`-Attribut eines Kreis-Vielecks; leer bei unsinniger Eingabe. */
|
||||
export function circlePoints(cx: number, cy: number, r: number): string {
|
||||
if (!(Number.isFinite(cx) && Number.isFinite(cy) && Number.isFinite(r) && r > 0)) return "";
|
||||
const out: string[] = new Array(SIDES);
|
||||
for (let i = 0; i < SIDES; i++) {
|
||||
const a = (2 * Math.PI * i) / SIDES;
|
||||
out[i] = `${cx + r * Math.cos(a)},${cy + r * Math.sin(a)}`;
|
||||
}
|
||||
return out.join(" ");
|
||||
}
|
||||
|
||||
/** Ersatz für `<circle>` im Plan-SVG (gleiche Klassen/Stile), s. Dateikopf. */
|
||||
export function VbCircle(props: {
|
||||
cx: number;
|
||||
cy: number;
|
||||
r: number;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
vectorEffect?: "non-scaling-stroke";
|
||||
pointerEvents?: "none";
|
||||
}) {
|
||||
const { cx, cy, r, ...rest } = props;
|
||||
return <polygon points={circlePoints(cx, cy, r)} {...rest} />;
|
||||
}
|
||||
Reference in new issue
Block a user