[109][110] Merge: SIA-400-Schraffuren (Dämmschlange, EPS/XPS, Holzfaser, Holz, Naturstein, Erdreich, Kies …), Linientyp ohne Strichstärke (Format 4, Migration)
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
35 files changed
+855
-411
No files matched your search
@@ -131,6 +131,7 @@ export {
|
||||
export {
|
||||
DASH_MM_TO_M,
|
||||
buildRandomHatchRuns,
|
||||
buildHatchRuns,
|
||||
motifPoints,
|
||||
zigzagPoints,
|
||||
} from "../plan/glPlan/glPlanHatch";
|
||||
|
||||
+11
-2
@@ -1204,6 +1204,9 @@ export const de = {
|
||||
"resources.col.component": "Bauteil",
|
||||
"resources.col.thickness": "Dicke (mm)",
|
||||
"resources.col.joint": "Fuge",
|
||||
"resources.col.jointWeight": "Fugen-Strichstärke (mm, 0 = Standard)",
|
||||
"resources.col.hatchLineWeight": "Strichstärke (mm)",
|
||||
"resources.col.hatchLineWeight.hint": "Stärke der Musterlinien auf dem Papier; der Linienstil legt nur das Muster fest.",
|
||||
"resources.joint.default": "— (Haarlinie)",
|
||||
"resources.layer.add": "Schicht hinzufügen",
|
||||
"resources.layer.remove": "Schicht entfernen",
|
||||
@@ -1405,13 +1408,19 @@ export const de = {
|
||||
// Schraffur-Muster.
|
||||
"pattern.none": "Ohne",
|
||||
"pattern.solid": "Vollfläche",
|
||||
"pattern.insulation": "Wärmedämmung",
|
||||
"pattern.insulation": "Wärmedämmung weich (Dämmschlange)",
|
||||
"pattern.insulationHard": "Wärmedämmung hart (Zickzack)",
|
||||
"pattern.insulationWave": "Holzfaser-Dämmung (Welle)",
|
||||
"pattern.timber": "Holz im Querschnitt",
|
||||
"pattern.stone": "Naturstein",
|
||||
"pattern.earth": "Erdreich",
|
||||
"pattern.gravel": "Kies",
|
||||
"pattern.diagonal": "Diagonal",
|
||||
"pattern.crosshatch": "Kreuzschraffur",
|
||||
"pattern.custom": "Eigenes Motiv",
|
||||
|
||||
// Linien.
|
||||
"resources.lines.hint": "Strichstärke in Millimetern (Paper-Space). Strichmuster: durchgezogen, gestrichelt oder gepunktet.",
|
||||
"resources.lines.hint": "Linientyp = Muster (durchgezogen, gestrichelt, gepunktet, Zickzack …) und Farbe. Die Strichstärke legt das Element, die Schraffur, die Schichtfuge oder die Ebene fest.",
|
||||
"resources.lines.empty": "Noch keine Linienstile.",
|
||||
"resources.lines.placeholder": "Linienstil",
|
||||
"resources.col.weight": "Stärke (mm)",
|
||||
|
||||
+11
-2
@@ -1198,6 +1198,9 @@ export const en: Record<TranslationKey, string> = {
|
||||
"resources.col.component": "Component",
|
||||
"resources.col.thickness": "Thickness (mm)",
|
||||
"resources.col.joint": "Joint",
|
||||
"resources.col.jointWeight": "Joint line weight (mm, 0 = default)",
|
||||
"resources.col.hatchLineWeight": "Line weight (mm)",
|
||||
"resources.col.hatchLineWeight.hint": "Weight of the pattern lines on paper; the line style only sets the pattern.",
|
||||
"resources.joint.default": "— (hairline)",
|
||||
"resources.layer.add": "Add layer",
|
||||
"resources.layer.remove": "Remove layer",
|
||||
@@ -1396,12 +1399,18 @@ export const en: Record<TranslationKey, string> = {
|
||||
|
||||
"pattern.none": "None",
|
||||
"pattern.solid": "Solid",
|
||||
"pattern.insulation": "Insulation",
|
||||
"pattern.insulation": "Soft insulation (loop line)",
|
||||
"pattern.insulationHard": "Rigid insulation (zigzag)",
|
||||
"pattern.insulationWave": "Wood-fibre insulation (wave)",
|
||||
"pattern.timber": "Timber cross-section",
|
||||
"pattern.stone": "Natural stone",
|
||||
"pattern.earth": "Earth",
|
||||
"pattern.gravel": "Gravel",
|
||||
"pattern.diagonal": "Diagonal",
|
||||
"pattern.crosshatch": "Crosshatch",
|
||||
"pattern.custom": "Custom motif",
|
||||
|
||||
"resources.lines.hint": "Line weight in millimetres (paper space). Stroke: solid, dashed or dotted.",
|
||||
"resources.lines.hint": "Line type = pattern (solid, dashed, dotted, zigzag …) and colour. The line weight is set by the element, the hatch, the layer joint or the layer.",
|
||||
"resources.lines.empty": "No line styles yet.",
|
||||
"resources.lines.placeholder": "Line style",
|
||||
"resources.col.weight": "Weight (mm)",
|
||||
|
||||
@@ -21,7 +21,7 @@ import { documentFor, sharedDocument } from "../core/document";
|
||||
import type { LoadFileResult } from "../core/document";
|
||||
|
||||
/** Aktuelle Version des Dateiformats (muss `PROJECT_FORMAT_VERSION` im Kern entsprechen — Test). */
|
||||
export const PROJECT_FORMAT_VERSION = 3;
|
||||
export const PROJECT_FORMAT_VERSION = 4;
|
||||
|
||||
export type ParseProjectResult = LoadFileResult;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export function richProject(): Project {
|
||||
const lvl = sampleProject.drawingLevels[0].id;
|
||||
return {
|
||||
...sampleProject,
|
||||
formatVersion: 3,
|
||||
formatVersion: 4,
|
||||
// Blatt-Ebene des Layouts „lay1" (2D-Zeichnung auf dem Blatt).
|
||||
drawingLevels: [...sampleProject.drawingLevels, { id: "sheet-lay1", name: "Blatt 1", kind: "drawing", visible: true, locked: false, layoutId: "lay1" }],
|
||||
textStyles: [{ id: "ts1", label: "Titel", marks: { bold: true, font: "Helvetica", sizePt: 14 } }],
|
||||
|
||||
+16
-21
@@ -26,18 +26,13 @@ export const sampleProject: Project = {
|
||||
id: "demo",
|
||||
name: "Demo-Haus",
|
||||
// ── Ressourcen-Bibliotheken (zentral verwiesen per id) ──────────────────
|
||||
// Linienstile: aufgeräumt auf kanonische VOLLLINIEN je Strichstärke (dash=null)
|
||||
// + eine gestrichelte Linie. Früher gab es drei funktional identische 0.13-
|
||||
// Volllinien ("thin"/"hatch-line"/"joint-massive") — zusammengeführt auf "thin"
|
||||
// ("Volllinie 0.13"); Schraffur-/Schichtfugen-Referenzen zeigen jetzt darauf.
|
||||
// (Die ids bleiben stabil, damit geladene Projekte + interne Referenzen halten.)
|
||||
// Linienstile: nur Muster + Farbe ([110]) — die Strichstärke tragen Schraffur (`lineWeight`),
|
||||
// Schichtfuge (`jointWeightMm`) bzw. Element/Ebene. Früher gab es „Volllinie 0.02/0.13/0.25/0.5";
|
||||
// zusammengeführt auf „thin" (Volllinie). Die ids bleiben stabil.
|
||||
lineStyles: [
|
||||
{ id: "hatch-hair", name: "Volllinie 0.02", weight: 0.02, color: "#1a1a1a", dash: null },
|
||||
{ id: "thin", name: "Volllinie 0.13", weight: 0.13, color: "#1a1a1a", dash: null },
|
||||
{ id: "medium", name: "Volllinie 0.25", weight: 0.25, color: "#1a1a1a", dash: null },
|
||||
{ id: "thick", name: "Volllinie 0.5", weight: 0.5, color: "#0a0a0a", dash: null },
|
||||
// Gestrichelte Haarlinie für die Dämmung (Striche quer durch die Wanddicke).
|
||||
{ id: "hatch-dash", name: "Dämmungsstrich", weight: 0.02, color: "#1a1a1a", dash: [0.35, 0.3] },
|
||||
{ id: "thin", name: "Volllinie", color: "#1a1a1a", dash: null },
|
||||
// Gestrichelte Linie (z. B. Dämmung, Striche quer durch die Wanddicke).
|
||||
{ id: "hatch-dash", name: "Dämmungsstrich", color: "#1a1a1a", dash: [0.35, 0.3] },
|
||||
],
|
||||
// Schraffuren: color = Linien-/Vollfüllfarbe des Musters; angle in Grad.
|
||||
// "none" = keine Schraffur (nur Component-Füllung).
|
||||
@@ -52,7 +47,7 @@ export const sampleProject: Project = {
|
||||
scale: 1,
|
||||
angle: 0,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "thin",
|
||||
lineWeight: 0.13,
|
||||
},
|
||||
{
|
||||
id: "diagonal",
|
||||
@@ -61,7 +56,7 @@ export const sampleProject: Project = {
|
||||
scale: 1,
|
||||
angle: 45,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "thin",
|
||||
lineWeight: 0.13,
|
||||
},
|
||||
{
|
||||
id: "crosshatch",
|
||||
@@ -70,7 +65,7 @@ export const sampleProject: Project = {
|
||||
scale: 1,
|
||||
angle: 0,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "thin",
|
||||
lineWeight: 0.13,
|
||||
},
|
||||
{
|
||||
id: "solid-concrete",
|
||||
@@ -79,7 +74,7 @@ export const sampleProject: Project = {
|
||||
scale: 1,
|
||||
angle: 0,
|
||||
color: "#9aa0a6",
|
||||
lineStyleId: "thin",
|
||||
lineWeight: 0.13,
|
||||
},
|
||||
// ── SIA-Schnittschraffuren (Haarlinie) ──────────────────────────────────
|
||||
// Dichte Teilung (scale < 1; Muster-Kachel = 8·scale) für den SIA-Look.
|
||||
@@ -91,7 +86,7 @@ export const sampleProject: Project = {
|
||||
scale: 0.5,
|
||||
angle: 45,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "hatch-hair",
|
||||
lineWeight: 0.02,
|
||||
},
|
||||
// Backstein: Diagonale, 45° RELATIV zur Wandachse (dreht mit der Wand mit).
|
||||
{
|
||||
@@ -102,7 +97,7 @@ export const sampleProject: Project = {
|
||||
angle: 45,
|
||||
relativeToWall: true,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "hatch-hair",
|
||||
lineWeight: 0.02,
|
||||
},
|
||||
// Dämmung: DURCHGEZOGENE (nicht gestrichelte) Linien QUER durch die Wanddicke
|
||||
// (senkrecht zur Wandachse), wandbezogen. Basiswinkel 0 = Musterlinie steht
|
||||
@@ -115,7 +110,7 @@ export const sampleProject: Project = {
|
||||
angle: 0,
|
||||
relativeToWall: true,
|
||||
color: "#1a1a1a",
|
||||
lineStyleId: "hatch-hair",
|
||||
lineWeight: 0.02,
|
||||
},
|
||||
],
|
||||
// Bauteil-Materialien: color = Poché-Füllung im Grundriss UND 3D-Diffusfarbe;
|
||||
@@ -182,7 +177,7 @@ export const sampleProject: Project = {
|
||||
layers: [
|
||||
{ componentId: "render-ext", thickness: 0.02 },
|
||||
// Innere Fuge der Dämmung trifft auf den Backstein (massiv↔massiv) → 0.13 mm.
|
||||
{ componentId: "insulation", thickness: 0.16, jointLineStyleId: "thin" },
|
||||
{ componentId: "insulation", thickness: 0.16, jointLineStyleId: "thin", jointWeightMm: 0.13 },
|
||||
{ componentId: "brick", thickness: 0.15 },
|
||||
{ componentId: "render-int", thickness: 0.015 },
|
||||
],
|
||||
@@ -209,7 +204,7 @@ export const sampleProject: Project = {
|
||||
// Estrich (schwimmend) → Trittschalldämmung.
|
||||
{ componentId: "screed", thickness: 0.06 },
|
||||
// Innere Fuge der Dämmung trifft auf die Betondecke (massiv) → 0.13 mm.
|
||||
{ componentId: "insulation", thickness: 0.04, jointLineStyleId: "thin" },
|
||||
{ componentId: "insulation", thickness: 0.04, jointLineStyleId: "thin", jointWeightMm: 0.13 },
|
||||
// Betondecke (Rohdecke, tragend) — innerste/unterste Schicht.
|
||||
{ componentId: "concrete", thickness: 0.2 },
|
||||
],
|
||||
@@ -222,7 +217,7 @@ export const sampleProject: Project = {
|
||||
// Aussen (Eindeckung) → innen (Verkleidung); Bauteile aus der Bibliothek.
|
||||
layers: [
|
||||
{ componentId: "roof-tiles", thickness: 0.04 }, // Eindeckung (Tonziegel)
|
||||
{ componentId: "insulation", thickness: 0.22, jointLineStyleId: "thin" }, // Sparren/Dämmung
|
||||
{ componentId: "insulation", thickness: 0.22, jointLineStyleId: "thin", jointWeightMm: 0.13 }, // Sparren/Dämmung
|
||||
{ componentId: "render-int", thickness: 0.0125 }, // Innenverkleidung (GK)
|
||||
],
|
||||
},
|
||||
|
||||
@@ -728,7 +728,7 @@ export type Drawing2D = {
|
||||
fillColor?: string;
|
||||
/**
|
||||
* Optionale direkte Strichstärke-Übersteuerung in Millimetern; hat Vorrang
|
||||
* vor dem LineStyle-Gewicht und der Kategorie-Strichstärke.
|
||||
* vor der Kategorie-Strichstärke (Linienstile tragen keine Stärke, [110]).
|
||||
*/
|
||||
weightMm?: number;
|
||||
/**
|
||||
@@ -742,8 +742,8 @@ export type Drawing2D = {
|
||||
backgroundSource?: AttributeSource;
|
||||
/**
|
||||
* Quelle der Strichstärke, wenn kein explizites `weightMm` gesetzt ist:
|
||||
* "layer" erzwingt `LayerCategory.lw` (unter Umgehung des LineStyle-Gewichts),
|
||||
* "object"/`undefined` (Default) = heutige Kette (LineStyle.weight ?? Kategorie).
|
||||
* "layer" erzwingt `LayerCategory.lw`,
|
||||
* "object"/`undefined` (Default) = Kategorie-Strichstärke.
|
||||
*/
|
||||
strokeWeightSource?: AttributeSource;
|
||||
/**
|
||||
@@ -1190,7 +1190,19 @@ export type Group = {
|
||||
};
|
||||
|
||||
/** Mögliche Schraffur-Muster im Plan/Schnitt. */
|
||||
export type HatchPattern = "none" | "solid" | "insulation" | "diagonal" | "crosshatch" | "custom";
|
||||
export type HatchPattern =
|
||||
| "none"
|
||||
| "solid"
|
||||
| "insulation"
|
||||
| "diagonal"
|
||||
| "crosshatch"
|
||||
| "custom"
|
||||
| "insulationHard"
|
||||
| "insulationWave"
|
||||
| "timber"
|
||||
| "earth"
|
||||
| "gravel"
|
||||
| "stone";
|
||||
|
||||
/** Eine wiederverwendbare Schraffur (Hatch Manager). */
|
||||
export type HatchStyle = {
|
||||
@@ -1259,8 +1271,10 @@ export type HatchStyle = {
|
||||
* Vollfüllfarbe, bei `pattern==="none"` ungenutzt.
|
||||
*/
|
||||
color: string;
|
||||
/** Optionaler Linienstil für die Musterlinien (Line Manager). */
|
||||
/** Optionaler Linienstil für die Musterlinien (Line Manager): nur Muster/Farbe. */
|
||||
lineStyleId?: string;
|
||||
/** Strichstärke der Musterlinien in Papier-mm ([110]); fehlt sie, gilt 0.13. */
|
||||
lineWeight?: number;
|
||||
/**
|
||||
* Steuer-Parameter der Random-Vektor-Schraffur (`kind`/"vector" + `lines`===
|
||||
* "random", z. B. Kies/Splitt). ALLE additiv & optional — fehlen sie, gilt das
|
||||
@@ -1335,6 +1349,8 @@ export type Layer = {
|
||||
* Fehlt das Feld, wird die Standard-Haarlinie (0.02 mm) gezeichnet.
|
||||
*/
|
||||
jointLineStyleId?: string;
|
||||
/** Strichstärke der Schichtfuge in Papier-mm ([110]); fehlt sie, gilt die Standard-Fuge. */
|
||||
jointWeightMm?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1490,16 +1506,13 @@ export type LineStyle = {
|
||||
id: string;
|
||||
name: string;
|
||||
/**
|
||||
* @deprecated Die Strichstärke gehört NICHT mehr in den Linienstil — es gibt nur
|
||||
* „Vollinie/Strich", die tatsächliche Dicke wird per Element-Attribut (bzw.
|
||||
* Ebene/Default) aufgelöst. Das Feld bleibt für die Backward-Compat-Auflösung
|
||||
* erhalten und dient den Renderern noch als Fallback für die Muster-/Fugen-Stärke
|
||||
* (siehe `resolveHatch` → `HatchRender.lineWeight`). Der Linien-Detail-Editor
|
||||
* zeigt es nicht mehr an; neue Linienstile bekommen einen Haarlinien-Default.
|
||||
* Die echte per-Element-Strichstärken-Auflösung (Attribut → Ebene → Default)
|
||||
* folgt separat mit dem By-Layer/By-Object-Refactor — NICHT hier.
|
||||
* @deprecated Nur noch für die Migration alter Dateien gelesen ([110], Format 4): Ein Linienstil
|
||||
* legt nur das Muster (Volllinie, Strich, Punkt, Zickzack …) und die Farbe fest — die Strichstärke
|
||||
* kommt vom Element (`Drawing2D.weightMm`), der Schraffur (`HatchStyle.lineWeight`), der
|
||||
* Schichtfuge (`Layer.jointWeightMm`) bzw. Ebene/Stift. Die Migration trägt das alte Gewicht dort
|
||||
* ein und entfernt es hier; die Renderer werten es nicht mehr aus.
|
||||
*/
|
||||
weight: number;
|
||||
weight?: number;
|
||||
/** Farbe (hex). */
|
||||
color: string;
|
||||
/**
|
||||
|
||||
@@ -121,13 +121,14 @@ describe("generatePlan — Schichtfugen als stilisierbare Linien", () => {
|
||||
p.kind === "line" && p.cls === "layer-joint",
|
||||
);
|
||||
|
||||
it("zieht die innere Fuge als eigene Linie und übernimmt Gewicht/Farbe des LineStyle", () => {
|
||||
it("zieht die innere Fuge als eigene Linie: Farbe/Muster vom LineStyle, Stärke von der Schicht ([110])", () => {
|
||||
const proj = cornerProject();
|
||||
proj.walls = [proj.walls[0]]; // nur W1, zwei Schichten → genau eine innere Fuge
|
||||
proj.wallTypes[0].layers[0].jointLineStyleId = "thin"; // weight 0.13, color #111
|
||||
proj.wallTypes[0].layers[0].jointLineStyleId = "thin"; // color #111
|
||||
proj.wallTypes[0].layers[0].jointWeightMm = 0.13;
|
||||
const joints = jointLines(proj);
|
||||
expect(joints.length).toBe(1);
|
||||
// LAYER_DETAIL_FACTOR["mittel"] == 1 → das LineStyle-Gewicht wirkt direkt.
|
||||
// LAYER_DETAIL_FACTOR["mittel"] == 1 → die Fugen-Stärke der Schicht wirkt direkt.
|
||||
expect(joints[0].weightMm).toBeCloseTo(0.13, 6);
|
||||
expect(joints[0].color).toBe("#111");
|
||||
expect(joints[0].dash ?? null).toBeNull();
|
||||
|
||||
@@ -136,7 +136,8 @@ export function applyDashRuns(runs: HatchRun[], dash: number[] | null): HatchRun
|
||||
|
||||
/**
|
||||
* Schraffur eines Polygons als zusammenhängende Läufe (Modell-Meter): diagonal (eine Schar),
|
||||
* crosshatch (zwei Scharen), insulation (Welle), custom (Motiv je Musterlinie), Random-Untermodus
|
||||
* crosshatch (zwei Scharen), Schicht-Muster über die Dicke (Dämmschlange, Zickzack, Welle, Holzkreuz),
|
||||
* Naturstein, Erdreich, Kies, custom (Motiv je Musterlinie), Random-Untermodus
|
||||
* (gestreute Striche); solid/none sowie Bild/Verlauf liefern keine Linien-Geometrie des Musters.
|
||||
*/
|
||||
export function buildHatchRuns(poly: Vec2[], hatch: HatchRender): HatchRun[] {
|
||||
|
||||
@@ -111,6 +111,12 @@ const PATTERN_CODE: Record<string, number> = {
|
||||
crosshatch: 3,
|
||||
insulation: 4,
|
||||
custom: 5,
|
||||
insulationHard: 6,
|
||||
insulationWave: 7,
|
||||
timber: 8,
|
||||
earth: 9,
|
||||
gravel: 10,
|
||||
stone: 11,
|
||||
};
|
||||
|
||||
/** Ein Hatch-Datensatz (auch Eingabe der Einzel-Bindungen in `glPlanHatch.ts`). */
|
||||
|
||||
@@ -12,7 +12,7 @@ import { selectionHighlightLines, projectToWalls3d, projectToModel3d, pickGeomet
|
||||
import { hexToRgb } from "./toWalls3d/shared";
|
||||
import type { ToolDraft } from "../tools/types";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { getHatch, getLineStyle } from "../model/types";
|
||||
import { getHatch } from "../model/types";
|
||||
import { roofGeometry, roofBaseElevation } from "../geometry/roof";
|
||||
|
||||
const RGB: [number, number, number] = [1, 0.5, 0.1];
|
||||
@@ -1805,7 +1805,7 @@ describe("Schnitt-Schraffur-Orientierung: relativeToWall dreht bei Wand, nicht b
|
||||
const h = getHatch(p, id);
|
||||
return {
|
||||
angle: h.relativeToWall && wallAngleDeg != null ? h.angle - wallAngleDeg : h.angle,
|
||||
lineWeight: (h.lineStyleId ? getLineStyle(p, h.lineStyleId) : null)?.weight ?? 0.13,
|
||||
lineWeight: h.lineWeight ?? 0.13,
|
||||
};
|
||||
};
|
||||
// 2D-Referenz (verbindlich): splitWallLayers ruft resolveHatch(…, 90, …) (Wand
|
||||
@@ -1844,9 +1844,9 @@ describe("Schnitt-Schraffur-Orientierung: relativeToWall dreht bei Wand, nicht b
|
||||
expect(brick.hatch?.angle).toBeCloseTo(resolveHatch(sampleProject, "sia-brick", 90).angle, 6);
|
||||
});
|
||||
|
||||
it("Musterlinien-Stärke kommt aus dem LineStyle des Hatch durch (2D-Parität)", () => {
|
||||
// sia-insulation nutzt lineStyleId "hatch-hair" (0.02 mm). Der 3D-Hatch muss die
|
||||
// resolveHatch-lineWeight (aus dem LineStyle) tragen — für Wand UND Decke gleich.
|
||||
it("Musterlinien-Stärke kommt aus der Schraffur durch (2D-Parität)", () => {
|
||||
// sia-insulation trägt lineWeight 0.02 mm ([110]). Der 3D-Hatch muss die
|
||||
// resolveHatch-lineWeight (aus der Schraffur) tragen — für Wand UND Decke gleich.
|
||||
const expected = resolveHatch(sampleProject, "sia-insulation", 90).lineWeight;
|
||||
expect(wallInsul().hatch?.lineWeight).toBeCloseTo(expected, 6);
|
||||
expect(slabInsul().hatch?.lineWeight).toBeCloseTo(expected, 6);
|
||||
|
||||
@@ -894,7 +894,6 @@ export function createProjectSlice(
|
||||
const lineStyle: LineStyle = {
|
||||
id: `line-${Date.now()}`,
|
||||
name: t("default.lineStyleName"),
|
||||
weight: 0.18,
|
||||
color: "#2b3039",
|
||||
dash: null,
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ describe("Projekt laden ([K4] S4)", () => {
|
||||
st().undo();
|
||||
expect(st().project).toBe(next);
|
||||
// Kern-Dokument = Leseansicht (Speichern aus dem Kern).
|
||||
expect(JSON.parse(serializeProject(st().project))).toEqual({ ...next, formatVersion: 3 });
|
||||
expect(JSON.parse(serializeProject(st().project))).toEqual({ ...next, formatVersion: 4 });
|
||||
});
|
||||
|
||||
it("openProjectFile: Kern liest, migriert und lädt direkt; Verlauf leer; kaputte Datei ändert nichts", () => {
|
||||
@@ -70,7 +70,7 @@ describe("Projekt laden ([K4] S4)", () => {
|
||||
expect(r.ok && r.migratedFrom).toBe(1);
|
||||
expect(st().undoDepth).toBe(0);
|
||||
expect(st().redoDepth).toBe(0);
|
||||
expect(st().project.formatVersion).toBe(3);
|
||||
expect(st().project.formatVersion).toBe(4);
|
||||
expect(st().project.openings?.some((o) => o.id === "TX" && o.kind === "door")).toBe(true);
|
||||
expect("doors" in st().project).toBe(false);
|
||||
// Danach normal weiterarbeiten: ein Schritt, Undo zurück auf den geladenen Stand.
|
||||
@@ -78,6 +78,6 @@ describe("Projekt laden ([K4] S4)", () => {
|
||||
st().setProject(opsMutation((p) => patchItem(p, "walls", p.walls[0].id, { height: 7 })));
|
||||
st().undo();
|
||||
expect(st().project).toEqual(loaded);
|
||||
expect(serializeProject(st().project)).toBe(JSON.stringify({ formatVersion: 3, ...loaded }, null, 2));
|
||||
expect(serializeProject(st().project)).toBe(JSON.stringify({ formatVersion: 4, ...loaded }, null, 2));
|
||||
});
|
||||
});
|
||||
+45
-168
@@ -1,72 +1,48 @@
|
||||
// Live-SVG-Vorschau (Swatch) für Schraffuren und Linienstile — eigenständig.
|
||||
// Live-SVG-Vorschau (Swatch) für Schraffuren und Linienstile.
|
||||
//
|
||||
// Bewusst OHNE Rückgriff auf die Plan-Renderer (generatePlan/toRenderScene):
|
||||
// diese Datei zeichnet die Muster direkt aus den HatchStyle-/LineStyle-Parametern
|
||||
// als SVG nach, damit die Vorschau im Ressourcen-Manager auch dann konsistent
|
||||
// bleibt, während der Plan-Renderer separat umgebaut wird. Die Farbe kommt hier
|
||||
// bewusst NICHT vom (deprecated) HatchStyle.color, sondern über `currentColor`
|
||||
// aus dem umgebenden CSS (var(--ink)) — die echte Vordergrundfarbe stammt im Plan
|
||||
// vom Bauteil/Attribut. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
// Vektor-Schraffuren zeichnet die Vorschau mit DEMSELBEN Kern-Generator wie Plan, Schnitt und Druck
|
||||
// (`buildHatchRuns`, [109]) — die Box wird als Fläche in Modell-Metern (`SWATCH_PX_PER_M`) übergeben,
|
||||
// Schicht-Muster (Dämmschlange, Zickzack …) spannen also über das Band wie im Plan. Bild/Verlauf als
|
||||
// SVG-Füllung. Die Farbe kommt bewusst NICHT vom (deprecated) HatchStyle.color, sondern über
|
||||
// `currentColor` aus dem umgebenden CSS (var(--ink)) — die echte Vordergrundfarbe stammt im Plan vom
|
||||
// Bauteil/Attribut. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { useId } from "react";
|
||||
import type { HatchStyle, LineStyle } from "../model/types";
|
||||
import { dashHasDot } from "../core";
|
||||
import { buildHatchRuns, dashHasDot } from "../core";
|
||||
|
||||
// ── Kleiner deterministischer PRNG (mulberry32) ────────────────────────────
|
||||
// Für „random"-Striche: stabil pro Seed, damit die Vorschau bei gleichem
|
||||
// Maßstab/Winkel nicht bei jedem Render „springt".
|
||||
function mulberry32(seed: number): () => number {
|
||||
let a = seed >>> 0;
|
||||
return () => {
|
||||
a |= 0;
|
||||
a = (a + 0x6d2b79f5) | 0;
|
||||
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
||||
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
}
|
||||
/** Vorschau-Massstab: px je Modell-Meter (128 px ≈ 0.43 m, etwa 1:10 am Bildschirm). */
|
||||
const SWATCH_PX_PER_M = 300;
|
||||
|
||||
/**
|
||||
* Parallele Linienschar über die Box (w×h) unter `angleDeg`, Abstand `spacing`
|
||||
* px senkrecht zur Linienrichtung. Liefert fertige <line>-Elemente, die die Box
|
||||
* komplett überdecken (Clip übernimmt der Aufrufer).
|
||||
* Musterlinien einer Vektor-Schraffur für eine Box `w`×`h` (px) aus dem Kern-Generator. `wallAngleDeg`
|
||||
* dreht wandbezogene Muster wie im Plan (Wand senkrecht = 90).
|
||||
*/
|
||||
function parallelLines(
|
||||
w: number,
|
||||
h: number,
|
||||
angleDeg: number,
|
||||
spacing: number,
|
||||
strokeWidth: number,
|
||||
keyPrefix: string,
|
||||
): React.ReactNode[] {
|
||||
const a = (angleDeg * Math.PI) / 180;
|
||||
const cos = Math.cos(a);
|
||||
const sin = Math.sin(a);
|
||||
// Senkrechte zur Linienrichtung.
|
||||
const px = -sin;
|
||||
const py = cos;
|
||||
const cx = w / 2;
|
||||
const cy = h / 2;
|
||||
const half = Math.hypot(w, h); // Linien lang genug, um die Box zu überdecken.
|
||||
const step = Math.max(spacing, 1.2);
|
||||
const n = Math.ceil(half / step) + 2;
|
||||
const out: React.ReactNode[] = [];
|
||||
for (let k = -n; k <= n; k++) {
|
||||
const mx = cx + k * step * px;
|
||||
const my = cy + k * step * py;
|
||||
out.push(
|
||||
<line
|
||||
key={`${keyPrefix}${k}`}
|
||||
x1={mx - cos * half}
|
||||
y1={my - sin * half}
|
||||
x2={mx + cos * half}
|
||||
y2={my + sin * half}
|
||||
stroke="currentColor"
|
||||
strokeWidth={strokeWidth}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
return out;
|
||||
function vectorRuns(hatch: HatchStyle, w: number, h: number, wallAngleDeg: number | undefined): string[] {
|
||||
const k = SWATCH_PX_PER_M;
|
||||
const poly = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: w / k, y: 0 },
|
||||
{ x: w / k, y: h / k },
|
||||
{ x: 0, y: h / k },
|
||||
];
|
||||
const angle = hatch.relativeToWall && wallAngleDeg != null ? hatch.angle - wallAngleDeg : hatch.angle;
|
||||
const runs = buildHatchRuns(poly, {
|
||||
pattern: hatch.pattern,
|
||||
scale: hatch.scale,
|
||||
angle,
|
||||
color: "#000",
|
||||
lineWeight: hatch.lineWeight ?? 0.13,
|
||||
dash: null,
|
||||
kind: hatch.kind,
|
||||
lines: hatch.lines,
|
||||
seed: hatch.seed,
|
||||
density: hatch.density,
|
||||
lengthMin: hatch.lengthMin,
|
||||
lengthMax: hatch.lengthMax,
|
||||
motif: hatch.motif,
|
||||
});
|
||||
return runs.map((r) => r.map((p, i) => `${i ? "L" : "M"}${(p.x * k).toFixed(1)} ${(h - p.y * k).toFixed(1)}`).join(""));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,14 +52,9 @@ function parallelLines(
|
||||
* Band DASSELBE Muster zeichnet. `uid` macht interne <pattern>-IDs eindeutig
|
||||
* (mehrere Bänder je SVG).
|
||||
*/
|
||||
function hatchInner(hatch: HatchStyle, w: number, h: number, uid: string): React.ReactNode {
|
||||
function hatchInner(hatch: HatchStyle, w: number, h: number, uid: string, wallAngleDeg?: number): React.ReactNode {
|
||||
const patId = `hsp_${uid}`;
|
||||
|
||||
// Grundabstand der Musterlinien (px), über den Maßstab moduliert.
|
||||
const scale = hatch.scale > 0 ? hatch.scale : 1;
|
||||
const spacing = Math.max(3, 8 / Math.sqrt(scale));
|
||||
const angle = hatch.angle || 0;
|
||||
|
||||
let inner: React.ReactNode = null;
|
||||
|
||||
if (hatch.kind === "image") {
|
||||
@@ -172,106 +143,11 @@ function hatchInner(hatch: HatchStyle, w: number, h: number, uid: string): React
|
||||
inner = <rect x={0} y={0} width={w} height={h} fill="currentColor" />;
|
||||
} else if (hatch.pattern === "none") {
|
||||
inner = null;
|
||||
} else if (hatch.lines === "random") {
|
||||
// Zufällig verteilte kurze Striche (deterministisch geseedet). Dichte, Länge
|
||||
// und der explizite Seed spiegeln die Plan-Parameter (HatchStyle) — so ändert
|
||||
// „Neu würfeln"/Dichte/Länge die Vorschau wie im Plan. Rein schematisch (px),
|
||||
// NICHT deckungsgleich mit der Modell-Streuung, aber qualitativ konsistent.
|
||||
const density = hatch.density != null && hatch.density > 0 ? hatch.density : 1;
|
||||
const seed = (Math.round(scale * 1000) + Math.round(angle) + Math.round(hatch.seed ?? 0)) >>> 0;
|
||||
const rnd = mulberry32(seed);
|
||||
const count = Math.min(400, Math.max(4, Math.round((18 * Math.min(2, scale) + 6) * density)));
|
||||
// mm-Papier → Vorschau-px (wie das Dash-Muster im LineSwatch: ·4).
|
||||
const PX_PER_MM = 4;
|
||||
const hasRange =
|
||||
hatch.lengthMin != null && hatch.lengthMax != null &&
|
||||
hatch.lengthMin > 0 && hatch.lengthMax >= hatch.lengthMin;
|
||||
const baseLen = Math.max(3, 6 / Math.sqrt(scale));
|
||||
const out: React.ReactNode[] = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const cx = rnd() * w;
|
||||
const cy = rnd() * h;
|
||||
const ang = rnd() * Math.PI;
|
||||
const lr = rnd();
|
||||
const len = hasRange
|
||||
? (hatch.lengthMin! + lr * (hatch.lengthMax! - hatch.lengthMin!)) * PX_PER_MM
|
||||
: baseLen;
|
||||
const dx = (Math.cos(ang) * len) / 2;
|
||||
const dy = (Math.sin(ang) * len) / 2;
|
||||
out.push(
|
||||
<line
|
||||
key={i}
|
||||
x1={cx - dx}
|
||||
y1={cy - dy}
|
||||
x2={cx + dx}
|
||||
y2={cy + dy}
|
||||
stroke="currentColor"
|
||||
strokeWidth={0.9}
|
||||
strokeLinecap="round"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
inner = out;
|
||||
} else if (hatch.pattern === "crosshatch") {
|
||||
inner = [
|
||||
...parallelLines(w, h, angle, spacing, 0.8, "a"),
|
||||
...parallelLines(w, h, angle + 90, spacing, 0.8, "b"),
|
||||
];
|
||||
} else if (hatch.pattern === "insulation") {
|
||||
// Dämmung: eine gewellte Schar quer über die Box (angenähert als Zickzack).
|
||||
const rows = Math.max(2, Math.round(h / Math.max(6, spacing)));
|
||||
const out: React.ReactNode[] = [];
|
||||
for (let r = 0; r < rows; r++) {
|
||||
const y = ((r + 0.5) / rows) * h;
|
||||
const amp = Math.min(h / rows / 2, 3);
|
||||
const waves = Math.max(2, Math.round(w / 6));
|
||||
let d = `M 0 ${y}`;
|
||||
for (let i = 1; i <= waves; i++) {
|
||||
const x = (i / waves) * w;
|
||||
const yy = y + (i % 2 === 0 ? -amp : amp);
|
||||
d += ` L ${x.toFixed(1)} ${yy.toFixed(1)}`;
|
||||
}
|
||||
out.push(
|
||||
<path key={r} d={d} fill="none" stroke="currentColor" strokeWidth={0.8} />,
|
||||
);
|
||||
}
|
||||
inner = out;
|
||||
} else if (hatch.pattern === "custom" && hatch.motif && hatch.motif.points.length >= 2 && hatch.motif.length > 1e-6) {
|
||||
// Eigenes Motiv: EINE Wiederhollänge als <pattern>-Kachel (analog zur
|
||||
// Bild-Schraffur oben) — motif.x (0..length) läuft entlang der Kachel-
|
||||
// Höhe (wie die Musterlinie bei diagonal/crosshatch), motif.y (Versatz
|
||||
// quer) entlang der Kachelbreite. Bewusst eigenständig tesseliert (KEIN
|
||||
// Import aus glPlanHatch, s. Moduldoc oben) — schematisch/px, wie der
|
||||
// übrige Swatch, nicht deckungsgleich mit dem Plan-Renderer.
|
||||
const PX_PER_MM = 2;
|
||||
const rowSpacing = Math.max(3, 8 / Math.sqrt(scale));
|
||||
const period = Math.max(4, hatch.motif.length * scale * PX_PER_MM);
|
||||
const d = hatch.motif.points
|
||||
.map((p, i) => {
|
||||
const x = (p.y * scale * PX_PER_MM).toFixed(1);
|
||||
const y = (p.x * scale * PX_PER_MM).toFixed(1);
|
||||
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
||||
})
|
||||
.join(" ");
|
||||
inner = (
|
||||
<>
|
||||
<defs>
|
||||
<pattern
|
||||
id={patId}
|
||||
patternUnits="userSpaceOnUse"
|
||||
width={rowSpacing}
|
||||
height={period}
|
||||
patternTransform={`rotate(${angle})`}
|
||||
>
|
||||
<path d={d} fill="none" stroke="currentColor" strokeWidth={0.8} />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect x={0} y={0} width={w} height={h} fill={`url(#${patId})`} />
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
// "diagonal" (Default, auch "custom" ohne gesetztes Motiv): eine parallele Schar.
|
||||
inner = parallelLines(w, h, angle, spacing, 0.8, "d");
|
||||
// Vektor (parallel, Kreuz, Schicht-Muster, Motiv, gestreut): Kern-Generator.
|
||||
inner = vectorRuns(hatch, w, h, wallAngleDeg).map((d, i) => (
|
||||
<path key={i} d={d} fill="none" stroke="currentColor" strokeWidth={0.8} strokeLinejoin="round" />
|
||||
));
|
||||
}
|
||||
|
||||
return inner;
|
||||
@@ -412,7 +288,7 @@ export function WallTypeSwatch({
|
||||
transform={`translate(${b.bx.toFixed(2)},${b.by.toFixed(2)})`}
|
||||
clipPath={`url(#${clipId}_b${i})`}
|
||||
>
|
||||
{b.hatch && hatchInner(b.hatch, b.bw, b.bh, `${rawId}_${i}`)}
|
||||
{b.hatch && hatchInner(b.hatch, b.bw, b.bh, `${rawId}_${i}`, orientation === "wall" ? 90 : undefined)}
|
||||
</g>
|
||||
))}
|
||||
{/* Fugen: dünne Trennlinie an jeder INNEREN Bandgrenze. */}
|
||||
@@ -471,7 +347,8 @@ export function LineSwatch({
|
||||
width?: number;
|
||||
height?: number;
|
||||
}) {
|
||||
const px = Math.max(1, Math.min(6, style.weight * 6));
|
||||
// Linienstile tragen keine Stärke mehr ([110]): Vorschau mit einheitlicher Linie.
|
||||
const px = 1.5;
|
||||
const midY = height / 2;
|
||||
const x0 = 4;
|
||||
const x1 = width - 4;
|
||||
|
||||
@@ -26,6 +26,12 @@ const PATTERN_OPTIONS: { value: HatchPattern; labelKey: string }[] = [
|
||||
{ value: "insulation", labelKey: "pattern.insulation" },
|
||||
{ value: "diagonal", labelKey: "pattern.diagonal" },
|
||||
{ value: "crosshatch", labelKey: "pattern.crosshatch" },
|
||||
{ value: "insulationHard", labelKey: "pattern.insulationHard" },
|
||||
{ value: "insulationWave", labelKey: "pattern.insulationWave" },
|
||||
{ value: "timber", labelKey: "pattern.timber" },
|
||||
{ value: "stone", labelKey: "pattern.stone" },
|
||||
{ value: "earth", labelKey: "pattern.earth" },
|
||||
{ value: "gravel", labelKey: "pattern.gravel" },
|
||||
{ value: "custom", labelKey: "pattern.custom" },
|
||||
];
|
||||
|
||||
@@ -212,6 +218,14 @@ function HatchDetail({
|
||||
options={lineOptions}
|
||||
/>
|
||||
</FieldRow>
|
||||
<FieldRow label={t("resources.col.hatchLineWeight")} hint={t("resources.col.hatchLineWeight.hint")}>
|
||||
<NumberField
|
||||
value={hatch.lineWeight ?? 0.13}
|
||||
onChange={(w) => onPatch({ lineWeight: Math.max(0.01, w) })}
|
||||
step={0.01}
|
||||
min={0.01}
|
||||
/>
|
||||
</FieldRow>
|
||||
{lines === "random" && (
|
||||
<>
|
||||
<FieldRow label={t("resources.field.density")}>
|
||||
@@ -327,8 +341,8 @@ function patToHatches(text: string): Omit<HatchStyle, "id">[] {
|
||||
scale: 1,
|
||||
angle: p.families[0]?.angle ?? 45,
|
||||
color: "#1a1a1a",
|
||||
// Kanonische Volllinie 0.13 (früher "hatch-line", zusammengeführt auf "thin").
|
||||
lineStyleId: "thin",
|
||||
// Volllinie (Muster); die Stärke trägt die Schraffur ([110]).
|
||||
lineWeight: 0.13,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,16 @@ function LayeredStyleDetail({
|
||||
/>
|
||||
)}
|
||||
</FieldRow>
|
||||
{!isInner && (
|
||||
<FieldRow label={t("resources.col.jointWeight")}>
|
||||
<NumberField
|
||||
value={layer.jointWeightMm ?? 0}
|
||||
onChange={(w) => patchLayer(i, { jointWeightMm: w > 0 ? w : undefined })}
|
||||
step={0.01}
|
||||
min={0}
|
||||
/>
|
||||
</FieldRow>
|
||||
)}
|
||||
</div>
|
||||
<DeleteButton
|
||||
onClick={() => removeLayer(i)}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import type { LineStyle, Project } from "../../model/types";
|
||||
import { PEN_WEIGHTS } from "../../model/types";
|
||||
import { parseLin } from "../../io/linParser";
|
||||
import { LineSwatch } from "../hatchPreview";
|
||||
import { segmentsToDash, dashToSegments, presetOfDash, LINE_PRESETS, type LineSegment, type LineSegmentType, type LinePresetKey } from "../../core";
|
||||
@@ -249,11 +248,10 @@ function LineStyleDetail({
|
||||
);
|
||||
}
|
||||
|
||||
/** .lin-Text → id-lose Linienstile (schwarze Haarlinie 0.18 als Default). */
|
||||
/** .lin-Text → id-lose Linienstile (nur Muster; die Stärke trägt das Element, [110]). */
|
||||
function linToStyles(text: string): Omit<LineStyle, "id">[] {
|
||||
return parseLin(text).map((p) => ({
|
||||
name: p.name,
|
||||
weight: 0.18,
|
||||
color: "#1a1a1a",
|
||||
dash: p.dash,
|
||||
}));
|
||||
@@ -278,12 +276,6 @@ export function LinesTab({
|
||||
|
||||
return (
|
||||
<div className="res-tab">
|
||||
{/* Vorschlagswerte für die Strichstärke (Standard-Stiftbreiten in mm). */}
|
||||
<datalist id="pen-weights">
|
||||
{PEN_WEIGHTS.map((w) => (
|
||||
<option key={w} value={w} />
|
||||
))}
|
||||
</datalist>
|
||||
<div className="res-hint">{t("resources.lines.hint")}</div>
|
||||
<div className="res-md">
|
||||
<div className="res-md-list">
|
||||
|
||||
Reference in new issue
Block a user