Kern/Huelle Phase A.1: Kern-Lecks behoben (View-/Detail-Typen nach model/viewTypes, Pick-Typen nach plan/pickTypes, geomTransform/curves/lineSegments/layoutModel in den Kern verschoben)

This commit is contained in:
karim committed 2026-10-27 19:25:06 +01:00
1 parent 1ea0fab6ce
commit cb79c13753
46 files changed
+373 -344

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@
import { Dropdown } from "./Dropdown";
import type { DropdownItem } from "./Dropdown";
import { t } from "../i18n";
import type { View3d, ViewType } from "./TopBar";
import type { View3d, ViewType } from "../model/viewTypes";
export interface AppMenuBarProps {
/** Datei: Neu/Neu aus Vorlage/Öffnen/Speichern/Importieren. */
+1 -1
View File
@@ -14,7 +14,7 @@ import type {
LayoutPaperFormat,
MasterLayout,
} from "../model/types";
import { PAPER_FORMAT_GROUPS } from "../panels/layoutModel";
import { PAPER_FORMAT_GROUPS } from "../model/layoutModel";
/** Startwerte eines neuen Blatts/Masters (Grösse). */
export interface LayoutSizeStart {
+1 -1
View File
@@ -32,7 +32,7 @@ import {
resolveTitleBlock,
resolveViewportScale,
visibleCodesFromSnapshot,
} from "../panels/layoutModel";
} from "../model/layoutModel";
import {
annotationBoundsMm,
applyHandleDrag,
+1 -47
View File
@@ -27,6 +27,7 @@ import {
isMarkActive,
toggleMark,
} from "../text/richText";
import type { DetailLevel, RenderMode, View3d, ViewType } from "../model/viewTypes";
import type {
Align,
BoolMark,
@@ -35,53 +36,6 @@ import type {
TextStylePreset,
} from "../text/richText";
/** Ansichtstyp eines Geschosses (wie in App). */
export type ViewType = "grundriss" | "perspektive";
/**
* Detailgrad der Darstellung (≙ DOSSIER Einfach/Standard/Detail). Wirkt im
* Grundriss auf Tür-/Fenstersymbole + Schraffuren/Linienfeinheit (siehe
* generatePlan.DetailLevel); in der Perspektive noch ohne Wirkung (deferred).
*/
export type DetailLevel = "grob" | "mittel" | "fein";
/**
* Render-/Anzeigemodus der 3D-Ansicht: schattiert, einheitlich weiss (Clay-Look),
* texturiert (echte PBR-Materialien je Bauteil), Drahtgitter, Verdeckte Kanten
* (Hidden-Line), Schattiert mit Kanten (typischer BIM-Look: Bauteilfarben +
* Modell-Kanten obenauf). Wirkt nur in der Perspektive. Der Slot „section"
* (Schnittschraffur, Welle B) ist bewusst freigelassen.
*/
export type RenderMode =
| "shaded"
| "white"
| "contour"
| "textured"
| "wireframe"
| "hidden"
| "shaded-edges";
/**
* Kanonischer Blickwinkel der 3D-Ansicht (Vectorworks/DOSSIER-Stil). „front"/
* „back"/„side"/„left" springen auf die vier Kardinalrichtungen (Vorne/Hinten/
* Rechts/Links — KEINE Himmelsrichtungs-Labels, da es noch keinen Nordwinkel
* gibt); „top" auf die Draufsicht. „iso"/„isoFrontLeft"/„isoBackRight"/
* „isoBackLeft" sind die vier oberen Iso-Oktanten (untere vier bleiben im
* Hochbau ungenutzt) — „iso" (vorne-oben-rechts) ist der bestehende Default.
* „perspective" ist der freie 3/4-Blick. Wirkt nur in der Perspektive.
*/
export type View3d =
| "front"
| "back"
| "side"
| "left"
| "top"
| "iso"
| "isoFrontLeft"
| "isoBackRight"
| "isoBackLeft"
| "perspective";
/**
* Farb-Modus des Grundrisses: „color" zeigt Kategorie-/Element-Farben (heutiges
* Verhalten), „mono" erzeugt einen reinen Schwarz-Weiss-Plan. Wirkt nur im
+1 -1
View File
@@ -10,7 +10,7 @@
import { useId } from "react";
import type { HatchStyle, LineStyle } from "../model/types";
import { dashHasDot } from "./lineSegments";
import { dashHasDot } from "../geometry/lineSegments";
// ── Kleiner deterministischer PRNG (mulberry32) ────────────────────────────
// Für „random"-Striche: stabil pro Seed, damit die Vorschau bei gleichem
-111
View File
@@ -1,111 +0,0 @@
// Modulares Linien-Segment-System: Abbildung Segmentliste ↔ dash-Array,
// Punkt-Erkennung (Round-Cap) und die Schnell-Presets.
import { describe, it, expect } from "vitest";
import {
segmentsToDash,
dashToSegments,
dashHasDot,
presetOfDash,
LINE_PRESETS,
type LineSegment,
} from "./lineSegments";
describe("segmentsToDash", () => {
it("bildet eine alternierende Strich/Lücke-Folge direkt ab", () => {
const segs: LineSegment[] = [
{ type: "dash", length: 2 },
{ type: "gap", length: 1 },
{ type: "dash", length: 3 },
{ type: "gap", length: 2 },
];
expect(segmentsToDash(segs)).toEqual([2, 1, 3, 2]);
});
it("bildet einen Punkt als 0-Länge ab (Strich-Punkt)", () => {
const segs: LineSegment[] = [
{ type: "dash", length: 4 },
{ type: "gap", length: 2 },
{ type: "dot", length: 0 },
{ type: "gap", length: 2 },
];
expect(segmentsToDash(segs)).toEqual([4, 2, 0, 2]);
});
it("fügt eine 0-Lücke zwischen zwei AN-Segmenten ein (Strich·Punkt)", () => {
const segs: LineSegment[] = [
{ type: "dash", length: 3 },
{ type: "dot", length: 0 },
];
// 3 (Strich), 0 (eingefügte Lücke), 0 (Punkt), 0 (Schluss-Lücke, gerade Länge)
expect(segmentsToDash(segs)).toEqual([3, 0, 0, 0]);
});
it("fasst zwei Lücken in Folge zusammen", () => {
const segs: LineSegment[] = [
{ type: "dash", length: 2 },
{ type: "gap", length: 1 },
{ type: "gap", length: 2 },
];
expect(segmentsToDash(segs)).toEqual([2, 3]);
});
it("endet stets auf einer AUS-Länge (gerade Array-Länge)", () => {
expect(segmentsToDash([{ type: "dash", length: 5 }])).toEqual([5, 0]);
});
it("leere Folge ⇒ null (Volllinie)", () => {
expect(segmentsToDash([])).toBeNull();
});
});
describe("dashToSegments", () => {
it("kehrt die Abbildung um (0 ⇒ Punkt)", () => {
expect(dashToSegments([4, 2, 0, 2])).toEqual([
{ type: "dash", length: 4 },
{ type: "gap", length: 2 },
{ type: "dot", length: 0 },
{ type: "gap", length: 2 },
]);
});
it("null ⇒ leere Folge", () => {
expect(dashToSegments(null)).toEqual([]);
});
it("round-trip: dash → segments → dash bleibt stabil", () => {
for (const d of [[2, 1, 3, 2], [4, 2, 0, 2], [0, 2], [3, 2]]) {
expect(segmentsToDash(dashToSegments(d))).toEqual(d);
}
});
});
describe("dashHasDot", () => {
it("erkennt Punkte (0 im dash) für die runde Kappe", () => {
expect(dashHasDot([0, 2])).toBe(true);
expect(dashHasDot([4, 2, 0, 2])).toBe(true);
});
it("keine Punkte ⇒ false (Butt-Kappe bleibt)", () => {
expect(dashHasDot([3, 2])).toBe(false);
expect(dashHasDot(null)).toBe(false);
expect(dashHasDot([])).toBe(false);
});
});
describe("Presets", () => {
it("die vier Grundtypen sind erkennbar", () => {
expect(presetOfDash(LINE_PRESETS.solid)).toBe("solid");
expect(presetOfDash(LINE_PRESETS.dash)).toBe("dash");
expect(presetOfDash(LINE_PRESETS.dot)).toBe("dot");
expect(presetOfDash(LINE_PRESETS.dashDot)).toBe("dashDot");
});
it("Punktlinie/Strich-Punkt enthalten einen Dot, Voll/Strich nicht", () => {
expect(dashHasDot(LINE_PRESETS.dot)).toBe(true);
expect(dashHasDot(LINE_PRESETS.dashDot)).toBe(true);
expect(dashHasDot(LINE_PRESETS.solid)).toBe(false);
expect(dashHasDot(LINE_PRESETS.dash)).toBe(false);
});
it("Abweichungen ⇒ custom", () => {
expect(presetOfDash([1, 2, 3, 4])).toBe("custom");
});
});
-107
View File
@@ -1,107 +0,0 @@
// Modulares Linien-Segment-System — die Brücke zwischen dem Segment-Editor
// (ResourceManager) und der Datenbasis `LineStyle.dash` (alternierend AN/AUS in
// mm, loopend). Eine musterbasierte Linie ist eine geordnete, loopende Folge aus
// drei Segment-Arten:
// • "dash" — ein sichtbarer Strich (Länge in mm > 0),
// • "dot" — ein Punkt (AN-Segment der Länge 0; wird mit runder Strichkappe zum
// Dot, siehe dashHasDot + `stroke-linecap: round` in den Renderern),
// • "gap" — eine Lücke (AUS-Länge in mm).
// Die letzte Lücke der Folge ist die „Schluss-Lücke" (Ende des Loops bis zum
// Start des nächsten). Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
/** Eine Segment-Art des Linien-Musters. */
export type LineSegmentType = "dash" | "dot" | "gap";
/** Ein Segment der Muster-Folge (Länge in mm; bei „dot" ignoriert/0). */
export interface LineSegment {
type: LineSegmentType;
/** Länge in mm (Papier). Bei „dot" stets 0. */
length: number;
}
/**
* Bildet eine geordnete Segment-Folge auf ein `dash`-Array ab
* (`[on, off, on, off, …]` in mm; ein `on`-Wert von 0 ⇒ Punkt). Da SVG-Dash
* strikt AN/AUS alterniert, werden 0-Längen eingefügt bzw. gleichartige
* Nachbarn zusammengefasst, um die Alternation zu wahren:
* • zwei AN-Segmente in Folge (z. B. Strich·Punkt) ⇒ 0-Lücke dazwischen,
* • zwei Lücken in Folge ⇒ zur vorigen Lücke addiert.
* Das Muster endet stets auf einer AUS-Länge (gerade Array-Länge), damit es
* sauber loopt. Leere Folge ⇒ `null` (Volllinie).
*/
export function segmentsToDash(segments: LineSegment[]): number[] | null {
const dash: number[] = [];
for (const seg of segments) {
const on = seg.type !== "gap";
const value = seg.type === "dot" ? 0 : Math.max(0, seg.length);
const nextSlotIsOn = dash.length % 2 === 0;
if (on) {
if (!nextSlotIsOn) dash.push(0); // 0-Lücke, um die AN/AUS-Alternation zu wahren
dash.push(value);
} else {
if (nextSlotIsOn) {
if (dash.length > 0) {
// zwei Lücken in Folge → in die vorherige Lücke einrechnen
dash[dash.length - 1] += value;
continue;
}
dash.push(0); // führende Lücke: 0-Strich davor
}
dash.push(value);
}
}
// Muster muss mit einer AUS-Länge enden (gerade Länge), damit es sauber loopt.
if (dash.length % 2 === 1) dash.push(0);
return dash.length ? dash : null;
}
/**
* Kehrt `segmentsToDash` um: ein `dash`-Array (`[on, off, …]`) wird zur
* Segment-Folge. Gerade Indizes sind AN (0 ⇒ Punkt, sonst Strich), ungerade
* Indizes sind Lücken. `null`/leer ⇒ leere Folge (Volllinie).
*/
export function dashToSegments(dash: number[] | null | undefined): LineSegment[] {
if (!dash) return [];
return dash.map((v, i) =>
i % 2 === 0
? { type: v === 0 ? "dot" : "dash", length: v }
: { type: "gap", length: v },
);
}
/**
* Enthält das Strichmuster einen Punkt (ein AN-Segment der Länge 0)? Solche
* Linien müssen mit runder Strichkappe (`stroke-linecap: round`) gezeichnet
* werden, damit die 0-Längen-Segmente als Dots sichtbar werden.
*/
export function dashHasDot(dash: number[] | null | undefined): boolean {
return !!dash && dash.some((v) => v === 0);
}
/** Schnell-Presets für die drei Grundtypen (+ Strich-Punkt), Längen in mm. */
export const LINE_PRESETS = {
/** Volllinie — durchgezogen. */
solid: null as number[] | null,
/** Strichlinie. */
dash: [3, 2] as number[] | null,
/** Punktlinie (Dots). */
dot: [0, 2] as number[] | null,
/** Strich-Punkt-Linie. */
dashDot: [4, 2, 0, 2] as number[] | null,
} as const;
export type LinePresetKey = keyof typeof LINE_PRESETS | "custom";
/** Erkennt, welchem Preset ein `dash`-Array entspricht (sonst „custom"). */
export function presetOfDash(dash: number[] | null | undefined): LinePresetKey {
const eq = (a: number[] | null, b: number[] | null): boolean => {
if (a === null || b === null) return a === b;
return a.length === b.length && a.every((v, i) => v === b[i]);
};
const d = dash ?? null;
if (eq(d, LINE_PRESETS.solid)) return "solid";
if (eq(d, LINE_PRESETS.dash)) return "dash";
if (eq(d, LINE_PRESETS.dot)) return "dot";
if (eq(d, LINE_PRESETS.dashDot)) return "dashDot";
return "custom";
}
+1 -1
View File
@@ -15,7 +15,7 @@ import {
type LineSegment,
type LineSegmentType,
type LinePresetKey,
} from "../lineSegments";
} from "../../geometry/lineSegments";
import { MotifEditor } from "../MotifEditor";
import { t } from "../../i18n";
import {