[109] [101] Schraffuren: Generator als eigenes Crate (hatchgen), render3d-Live-Schnitt/Druck-SVG/SVG-PlanView zeichnen Schichtmuster mit dem Kern-Generator, Putz/Keramik/Faserzement mit Schraffur (Punktfeld), Standards aktualisieren im Ressourcen-Manager

This commit is contained in:
Claude committed 2026-10-30 05:10:50 +00:00
1 parent 907ff65ce6
commit 23442fe7a2
38 files changed
+1004 -74

No files matched your search

+2
View File
@@ -1594,6 +1594,7 @@ export default function App() {
patchPenSetWeight,
seedStandardPenSet,
loadStandards,
updateStandards,
addCustomPalette,
renameCustomPalette,
deleteCustomPalette,
@@ -2549,6 +2550,7 @@ export default function App() {
onPatchPenSetWeight: patchPenSetWeight,
onSeedStandardPenSet: seedStandardPenSet,
onLoadStandards: loadStandards,
onUpdateStandards: updateStandards,
onAddCustomPalette: addCustomPalette,
onRenameCustomPalette: renameCustomPalette,
onDeleteCustomPalette: deleteCustomPalette,
+1 -1
View File
@@ -57,7 +57,7 @@ export type LoadFileResult =
| { ok: false; error: string };
/** Wurzel-Abfragen des Kerns (`queries.rs::run_root`). */
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch";
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "standardsUpdatePlan" | "standardsUpdateOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch";
/** Abfragen des Kerns (`queries.rs`). */
export type QueryName =
+44
View File
@@ -1244,6 +1244,49 @@ export const de = {
"material.fetchAmbient": "Textur laden",
"material.fetchAmbient.hint": "Lädt die Texturkarten dieses ambientCG-Materials (CC0) herunter.",
"resources.loadStandards": "Standards laden",
"resources.updateStandards": "Standards aktualisieren",
"resources.updateStandards.hint": "Bringt Standard-Einträge (Schraffuren, Baustoffe, Linientypen, Aufbauten mit Standard-id) auf die heutige Definition. Du siehst vorher, was sich ändert, und wählst aus; ein Undo-Schritt.",
"resources.updateStandards.intro": "Diese Standard-Einträge weichen von der heutigen Bibliothek ab. Ob du einen Eintrag selbst angepasst hast, kann Dossier nicht erkennen: umbenannte Einträge sind abgewählt, alle anderen vorgewählt. Name und eigene Zusatzfelder bleiben unverändert.",
"resources.updateStandards.added": "Außerdem werden {n} fehlende Standard-Einträge hinzugefügt.",
"resources.updateStandards.none": "Alle Standard-Einträge sind auf dem heutigen Stand.",
"resources.updateStandards.renamed": "umbenannt",
"resources.updateStandards.all": "Alle überschreiben",
"resources.updateStandards.noneSelected": "Keine",
"resources.updateStandards.apply": "{n} aktualisieren",
"resources.updateStandards.done": "Standards: {n} Einträge aktualisiert",
"resources.updateStandards.col.components": "Baustoffe",
"resources.updateStandards.col.hatches": "Schraffuren",
"resources.updateStandards.col.lineStyles": "Linientypen",
"resources.updateStandards.col.wallTypes": "Wandaufbauten",
"resources.updateStandards.col.ceilingTypes": "Deckenaufbauten",
"resources.updateStandards.col.roofTypes": "Dachaufbauten",
"resources.updateStandards.field.pattern": "Muster",
"resources.updateStandards.field.scale": "Massstab",
"resources.updateStandards.field.angle": "Winkel",
"resources.updateStandards.field.color": "Farbe",
"resources.updateStandards.field.lineWeight": "Strichstärke",
"resources.updateStandards.field.relativeToWall": "Bezug zur Wand",
"resources.updateStandards.field.lineStyleId": "Linientyp",
"resources.updateStandards.field.kind": "Art",
"resources.updateStandards.field.lines": "Linienart",
"resources.updateStandards.field.density": "Dichte",
"resources.updateStandards.field.lengthMin": "Mindestlänge",
"resources.updateStandards.field.lengthMax": "Maximallänge",
"resources.updateStandards.field.seed": "Streuung",
"resources.updateStandards.field.background": "Hintergrund",
"resources.updateStandards.field.hatchId": "Schraffur",
"resources.updateStandards.field.viewHatchId": "Ansichtsschraffur",
"resources.updateStandards.field.joinPriority": "Anschlussvorrang",
"resources.updateStandards.field.fireClass": "Brandklasse",
"resources.updateStandards.field.elevationColor": "Ansichtsfarbe",
"resources.updateStandards.field.standardId": "Standard-id",
"resources.updateStandards.field.lambda": "Lambda",
"resources.updateStandards.field.material": "Textur",
"resources.updateStandards.field.surfacePattern": "Ansichtsmuster",
"resources.updateStandards.field.abbrev": "Kürzel",
"resources.updateStandards.field.dash": "Strichmuster",
"resources.updateStandards.field.zigzag": "Zickzack",
"resources.updateStandards.field.layers": "Schichten",
"resources.loadStandards.hint": "Ergänzt die SIA-400-Standards (Baustoffe mit Schraffur, Ansichtsschraffur, Textur und Kennwerten, Linientypen, Wand-/Decken-/Dachaufbauten). Vorhandene Einträge (gleiche id oder gleicher Name) bleiben unverändert.",
"resources.loadStandards.added": "{list} hinzugefügt",
"resources.loadStandards.none": "Standards: alles schon vorhanden",
@@ -1415,6 +1458,7 @@ export const de = {
"pattern.stone": "Naturstein",
"pattern.earth": "Erdreich",
"pattern.gravel": "Kies",
"pattern.dots": "Punktfeld (Putz)",
"pattern.diagonal": "Diagonal",
"pattern.crosshatch": "Kreuzschraffur",
"pattern.custom": "Eigenes Motiv",
+44
View File
@@ -1237,6 +1237,49 @@ export const en: Record<TranslationKey, string> = {
"material.fetchAmbient": "Load texture",
"material.fetchAmbient.hint": "Downloads the texture maps of this ambientCG material (CC0).",
"resources.loadStandards": "Load standards",
"resources.updateStandards": "Update standards",
"resources.updateStandards.hint": "Brings standard entries (hatches, materials, line types, assemblies with a standard id) up to today's definition. You see what changes first and choose; one undo step.",
"resources.updateStandards.intro": "These standard entries differ from today's library. Dossier cannot tell whether you adjusted an entry yourself: renamed entries are unchecked, all others are checked. Names and your own extra fields stay as they are.",
"resources.updateStandards.added": "{n} missing standard entries will also be added.",
"resources.updateStandards.none": "All standard entries are up to date.",
"resources.updateStandards.renamed": "renamed",
"resources.updateStandards.all": "Overwrite all",
"resources.updateStandards.noneSelected": "None",
"resources.updateStandards.apply": "Update {n}",
"resources.updateStandards.done": "Standards: {n} entries updated",
"resources.updateStandards.col.components": "Materials",
"resources.updateStandards.col.hatches": "Hatches",
"resources.updateStandards.col.lineStyles": "Line types",
"resources.updateStandards.col.wallTypes": "Wall assemblies",
"resources.updateStandards.col.ceilingTypes": "Ceiling assemblies",
"resources.updateStandards.col.roofTypes": "Roof assemblies",
"resources.updateStandards.field.pattern": "Pattern",
"resources.updateStandards.field.scale": "Scale",
"resources.updateStandards.field.angle": "Angle",
"resources.updateStandards.field.color": "Color",
"resources.updateStandards.field.lineWeight": "Line weight",
"resources.updateStandards.field.relativeToWall": "Relative to wall",
"resources.updateStandards.field.lineStyleId": "Line type",
"resources.updateStandards.field.kind": "Kind",
"resources.updateStandards.field.lines": "Line mode",
"resources.updateStandards.field.density": "Density",
"resources.updateStandards.field.lengthMin": "Min length",
"resources.updateStandards.field.lengthMax": "Max length",
"resources.updateStandards.field.seed": "Seed",
"resources.updateStandards.field.background": "Background",
"resources.updateStandards.field.hatchId": "Hatch",
"resources.updateStandards.field.viewHatchId": "View hatch",
"resources.updateStandards.field.joinPriority": "Join priority",
"resources.updateStandards.field.fireClass": "Fire class",
"resources.updateStandards.field.elevationColor": "Elevation color",
"resources.updateStandards.field.standardId": "Standard id",
"resources.updateStandards.field.lambda": "Lambda",
"resources.updateStandards.field.material": "Texture",
"resources.updateStandards.field.surfacePattern": "Surface pattern",
"resources.updateStandards.field.abbrev": "Abbreviation",
"resources.updateStandards.field.dash": "Dash",
"resources.updateStandards.field.zigzag": "Zigzag",
"resources.updateStandards.field.layers": "Layers",
"resources.loadStandards.hint": "Adds the SIA 400 standards (materials with hatch, surface pattern, texture and physical values, line types, wall/ceiling/roof build-ups). Existing entries (same id or same name) stay unchanged.",
"resources.loadStandards.added": "Added {list}",
"resources.loadStandards.none": "Standards: everything already present",
@@ -1406,6 +1449,7 @@ export const en: Record<TranslationKey, string> = {
"pattern.stone": "Natural stone",
"pattern.earth": "Earth",
"pattern.gravel": "Gravel",
"pattern.dots": "Dot field (plaster)",
"pattern.diagonal": "Diagonal",
"pattern.crosshatch": "Crosshatch",
"pattern.custom": "Custom motif",
+32 -1
View File
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import { emptyProject, sampleProject } from "./sampleProject";
import { standardsMergeCounts, standardsMergeOps, withStandards } from "./standards";
import { standardsChangeKey, standardsMergeCounts, standardsMergeOps, standardsUpdateOps, standardsUpdatePlan, withStandards } from "./standards";
import { applyOps } from "../core/ops";
describe("Standard-Bibliothek ([100]–[102])", () => {
it("bringt Baustoffe, Linientypen und Aufbauten in ein neues Projekt", () => {
@@ -36,4 +37,34 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5);
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0 });
});
it("Putz, Keramik und Faserzement haben eine Schraffur", () => {
const p = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
const hatchOf = (name: string) => p.hatches.find((h) => h.id === p.components.find((c) => c.name === name)!.hatchId)!;
expect(hatchOf("Innenputz").pattern).toBe("dots");
expect(hatchOf("Aussenputz").pattern).toBe("dots");
expect(hatchOf("Keramikplatten").pattern).toBe("crosshatch");
expect(hatchOf("Faserzementplatten").pattern).toBe("diagonal");
});
it("„Standards aktualisieren“: alte Definitionen auf heutigen Stand, Auswahl, ein Op-Satz", () => {
const full = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
expect(standardsUpdatePlan(full).changes).toEqual([]);
// Stand 29.10.: EPS mit alter Schraffur, Putz ohne Schraffur, XPS umbenannt
const old = {
...full,
hatches: full.hatches.filter((h) => h.id !== "std-h-putz").map((h) => (h.id === "std-h-eps" ? { ...h, pattern: "insulation" as const } : h.id === "std-h-xps" ? { ...h, name: "Meine XPS", pattern: "diagonal" as const } : h)),
components: full.components.map((c) => (c.id === "std-c-innenputz" ? { ...c, hatchId: "std-h-ohne" } : c)),
};
const plan = standardsUpdatePlan(old);
expect(plan.added).toBe(1);
expect(plan.changes.map((c) => c.id).sort()).toEqual(["std-c-innenputz", "std-h-eps", "std-h-xps"]);
expect(plan.changes.find((c) => c.id === "std-h-xps")!.renamed).toBe(true);
const selected = plan.changes.filter((c) => !c.renamed).map(standardsChangeKey);
const after = applyOps(old, standardsUpdateOps(old, selected));
expect(after.hatches.find((h) => h.id === "std-h-eps")!.pattern).toBe("insulationHard");
expect(after.hatches.find((h) => h.id === "std-h-xps")!.pattern).toBe("diagonal");
expect(after.components.find((c) => c.id === "std-c-innenputz")!.hatchId).toBe("std-h-putz");
expect(standardsUpdatePlan(after).changes.map((c) => c.id)).toEqual(["std-h-xps"]);
});
});
+31
View File
@@ -37,3 +37,34 @@ export function standardsMergeCounts(ops: readonly CoreOp[]): StandardsMergeCoun
}
return out;
}
/** Ein Standard-Eintrag des Projekts, der von der heutigen Bibliothek abweicht („Standards aktualisieren"). */
export interface StandardsChange {
/** Projekt-Liste (`hatches`, `components`, `wallTypes` …). */
collection: string;
id: string;
name: string;
/** Namen der Felder, die sich ändern würden. */
fields: string[];
/** Name weicht vom Standard ab: vermutlich selbst angepasst (im Dialog abgewählt). */
renamed: boolean;
}
export interface StandardsUpdatePlan {
/** Anzahl fehlender Standard-Einträge, die mit angehängt werden. */
added: number;
changes: StandardsChange[];
}
/** Schlüssel eines Eintrags in der Auswahl von {@link standardsUpdateOps}. */
export const standardsChangeKey = (c: Pick<StandardsChange, "collection" | "id">): string => `${c.collection}:${c.id}`;
/** Abweichungen der Standard-Einträge vom heutigen Standard (Regel s. `standards.rs`, „Standards aktualisieren"). */
export function standardsUpdatePlan(project: Project): StandardsUpdatePlan {
return documentFor(project).queryRoot<StandardsUpdatePlan>("standardsUpdatePlan");
}
/** Ops: fehlende Standards anhängen und die gewählten Einträge (`standardsChangeKey`) auf den heutigen Stand bringen. */
export function standardsUpdateOps(project: Project, selected: readonly string[]): CoreOp[] {
return documentFor(project).queryRoot<CoreOp[]>("standardsUpdateOps", JSON.stringify(selected));
}
+2 -1
View File
@@ -1202,7 +1202,8 @@ export type HatchPattern =
| "timber"
| "earth"
| "gravel"
| "stone";
| "stone"
| "dots";
/** Eine wiederverwendbare Schraffur (Hatch Manager). */
export type HatchStyle = {
+1
View File
@@ -117,6 +117,7 @@ const PATTERN_CODE: Record<string, number> = {
earth: 9,
gravel: 10,
stone: 11,
dots: 12,
};
/** Ein Hatch-Datensatz (auch Eingabe der Einzel-Bindungen in `glPlanHatch.ts`). */
+9 -1
View File
@@ -57,7 +57,7 @@ import {
PEN_FALLBACK_COLOR,
PEN_FALLBACK_WEIGHT,
} from "../model/penSets";
import { standardsMergeCounts, standardsMergeOps } from "../model/standards";
import { standardsMergeCounts, standardsMergeOps, standardsUpdateOps } from "../model/standards";
import { reorderByIds } from "../model/reorder";
import { transformMutation } from "../tools/transform";
import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform";
@@ -185,6 +185,8 @@ export interface ProjectSlice {
seedStandardPenSet: () => void;
/** Ergänzt die fehlenden SIA-400-Standards (Baustoffe, Schraffuren, Linientypen, Aufbauten; [100]–[102]). */
loadStandards: () => void;
/** „Standards aktualisieren" ([109]): ergänzt Fehlendes und bringt die gewählten Standard-Einträge (`"<Liste>:<id>"`) auf den heutigen Stand; ein Undo-Schritt. */
updateStandards: (selected: string[]) => void;
// ── Benutzerdefinierte Farbpaletten (s. model/types.ts::CustomPalette) ────
addCustomPalette: () => void;
@@ -1035,6 +1037,12 @@ export function createProjectSlice(
get().notify(parts.length ? t("resources.loadStandards.added", { list: parts.join(", ") }) : t("resources.loadStandards.none"), "info");
},
updateStandards: (selected) => {
const ops = standardsUpdateOps(get().project, selected);
if (ops.length) applyChange(ops);
get().notify(t("resources.updateStandards.done", { n: selected.length }), "info");
},
addCustomPalette: () =>
applyChange(
addItems("customPalettes", [{ id: `palette-${Date.now()}`, name: t("default.customPaletteName"), colors: [] }]),
+2
View File
@@ -114,6 +114,7 @@ export function useProjectActions(
const patchPenSetWeight = useStore((s) => s.patchPenSetWeight);
const seedStandardPenSet = useStore((s) => s.seedStandardPenSet);
const loadStandards = useStore((s) => s.loadStandards);
const updateStandards = useStore((s) => s.updateStandards);
const addCustomPalette = useStore((s) => s.addCustomPalette);
const renameCustomPalette = useStore((s) => s.renameCustomPalette);
const deleteCustomPalette = useStore((s) => s.deleteCustomPalette);
@@ -425,6 +426,7 @@ export function useProjectActions(
patchPenSetWeight,
seedStandardPenSet,
loadStandards,
updateStandards,
addCustomPalette,
renameCustomPalette,
deleteCustomPalette,
+22
View File
@@ -34,6 +34,7 @@ import { EyeIcon } from "./EyeIcon";
import { t } from "../i18n";
import { ComponentsTab } from "./resourceManager/ComponentsTab";
import { HatchesTab } from "./resourceManager/HatchesTab";
import { StandardsUpdateDialog } from "./resourceManager/StandardsUpdateDialog";
import { LinesTab } from "./resourceManager/LinesTab";
import { CeilingStylesTab, RoofStylesTab, WallStylesTab } from "./resourceManager/LayeredStylesTab";
import { DoorStylesTab } from "./resourceManager/DoorStylesTab";
@@ -153,6 +154,8 @@ export interface ResourceManagerHandlers {
onSeedStandardPenSet?: () => void;
/** Ergänzt die fehlenden SIA-400-Standards ([100]–[102], „Standards laden"). */
onLoadStandards?: () => void;
/** „Standards aktualisieren" ([109]): bringt die gewählten Standard-Einträge (`"<Liste>:<id>"`) auf den heutigen Stand. */
onUpdateStandards?: (selected: string[]) => void;
/**
* Farbpaletten (Tab „Paletten"): eigene Paletten verwalten + Sichtbarkeit
* der Bänke im Farbwahl-Popover. Optional wie die Stift-Handler.
@@ -234,6 +237,7 @@ export function ResourceManager({
if (initialTab) setTab(initialTab);
}, [initialTab]);
const [rect, setRect] = useState<WindowRect>(initialRect);
const [updateStandardsOpen, setUpdateStandardsOpen] = useState(false);
// Verschieben über die Kopfzeile: Cursor − linke/obere Kante festhalten und die
// Kante der Cursorbewegung folgen lassen (Pointer-Capture hält die Geste).
@@ -330,6 +334,16 @@ export function ResourceManager({
{t("resources.loadStandards")}
</button>
)}
{handlers.onUpdateStandards && (
<button
className="res-add res-update-standards"
title={t("resources.updateStandards.hint")}
onPointerDown={(e) => e.stopPropagation()}
onClick={() => setUpdateStandardsOpen(true)}
>
{t("resources.updateStandards")}
</button>
)}
{!windowed && (
<button
className="res-close"
@@ -475,6 +489,14 @@ export function ResourceManager({
)}
</div>
{updateStandardsOpen && handlers.onUpdateStandards && (
<StandardsUpdateDialog
project={project}
onApply={(sel) => handlers.onUpdateStandards?.(sel)}
onClose={() => setUpdateStandardsOpen(false)}
/>
)}
{/* Greifer unten rechts (Größe ändern) — im eigenen OS-Fenster übernimmt
das Betriebssystem das Grössenändern, daher windowed ohne Greifer. */}
{!windowed && (
+1
View File
@@ -32,6 +32,7 @@ const PATTERN_OPTIONS: { value: HatchPattern; labelKey: string }[] = [
{ value: "stone", labelKey: "pattern.stone" },
{ value: "earth", labelKey: "pattern.earth" },
{ value: "gravel", labelKey: "pattern.gravel" },
{ value: "dots", labelKey: "pattern.dots" },
{ value: "custom", labelKey: "pattern.custom" },
];
@@ -0,0 +1,124 @@
// „Standards aktualisieren" ([109]): Bestätigungs-Overlay (kein window.confirm — im Tauri-WKWebView stumm).
// Listet die Standard-Einträge des Projekts, die von der heutigen Bibliothek abweichen, mit den betroffenen
// Feldern. Ob ein Eintrag selbst angepasst wurde, lässt sich nicht erkennen: umbenannte Einträge sind
// abgewählt, alle anderen vorgewählt; „Alle überschreiben" wählt alles. Regel: `core/src/standards.rs`.
import { useEffect, useMemo, useState } from "react";
import { createPortal } from "react-dom";
import type { Project } from "../../model/types";
import { standardsChangeKey, standardsUpdatePlan } from "../../model/standards";
import { t } from "../../i18n";
const COLLECTION_ORDER = ["components", "hatches", "lineStyles", "wallTypes", "ceilingTypes", "roofTypes"];
export function StandardsUpdateDialog({
project,
onApply,
onClose,
}: {
project: Project;
onApply: (selected: string[]) => void;
onClose: () => void;
}) {
const plan = useMemo(() => standardsUpdatePlan(project), [project]);
const [selected, setSelected] = useState<Set<string>>(
() => new Set(plan.changes.filter((c) => !c.renamed).map(standardsChangeKey)),
);
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [onClose]);
const toggle = (key: string) =>
setSelected((s) => {
const n = new Set(s);
if (n.has(key)) n.delete(key);
else n.add(key);
return n;
});
const groups = COLLECTION_ORDER.map((col) => ({ col, items: plan.changes.filter((c) => c.collection === col) })).filter((g) => g.items.length > 0);
const nothing = plan.changes.length === 0 && plan.added === 0;
const canApply = selected.size > 0 || plan.added > 0;
return createPortal(
<div className="imp-overlay" onClick={onClose}>
<div className="imp-dialog" role="dialog" aria-modal="true" aria-label={t("resources.updateStandards")} style={{ maxWidth: 560 }} onClick={(e) => e.stopPropagation()}>
<header className="imp-head">
<span className="imp-head-title">{t("resources.updateStandards")}</span>
<button className="imp-close" onClick={onClose} aria-label={t("export.close")}>
×
</button>
</header>
<div className="imp-body" style={{ maxHeight: "60vh", overflow: "auto" }}>
{nothing ? (
<section className="imp-section">
<div className="imp-section-title">{t("resources.updateStandards.none")}</div>
</section>
) : (
<>
<section className="imp-section">
<div className="imp-section-title" style={{ fontWeight: 400 }}>
{t("resources.updateStandards.intro")}
</div>
{plan.added > 0 && (
<div className="imp-section-title" style={{ fontWeight: 400, opacity: 0.8 }}>
{t("resources.updateStandards.added", { n: plan.added })}
</div>
)}
</section>
{groups.map((g) => (
<section className="imp-section" key={g.col}>
<div className="imp-section-title">{t(`resources.updateStandards.col.${g.col}`)}</div>
{g.items.map((c) => {
const key = standardsChangeKey(c);
return (
<label key={key} style={{ display: "flex", gap: 8, alignItems: "baseline", padding: "2px 0", cursor: "pointer" }}>
<input type="checkbox" checked={selected.has(key)} onChange={() => toggle(key)} />
<span>
{c.name}
{c.renamed && <em style={{ opacity: 0.7 }}> ({t("resources.updateStandards.renamed")})</em>}
<span style={{ opacity: 0.6, fontSize: 11 }}> — {c.fields.map((f) => t(`resources.updateStandards.field.${f}`)).join(", ")}</span>
</span>
</label>
);
})}
</section>
))}
</>
)}
</div>
<footer className="imp-foot">
{!nothing && plan.changes.length > 0 && (
<>
<button className="imp-btn" onClick={() => setSelected(new Set(plan.changes.map(standardsChangeKey)))}>
{t("resources.updateStandards.all")}
</button>
<button className="imp-btn" onClick={() => setSelected(new Set())}>
{t("resources.updateStandards.noneSelected")}
</button>
</>
)}
<button className="imp-btn" onClick={onClose}>
{t("export.cancel")}
</button>
{!nothing && (
<button
className="imp-btn primary"
disabled={!canApply}
onClick={() => {
onApply([...selected]);
onClose();
}}
>
{t("resources.updateStandards.apply", { n: selected.size })}
</button>
)}
</footer>
</div>
</div>,
document.body,
);
}
@@ -10,7 +10,7 @@
*/
import { describe, expect, it } from "vitest";
import { polyUsesPattern } from "./primitives";
import { isGeneratedPattern, polyUsesPattern } from "./primitives";
import type { HatchRender } from "../../../plan/generatePlan/shared";
function hatch(over: Partial<HatchRender> = {}): HatchRender {
@@ -43,3 +43,14 @@ describe("polyUsesPattern — gradient", () => {
expect(polyUsesPattern(hatch({ pattern: "none" }))).toBe(false);
});
});
describe("polyUsesPattern — Kern-Generator-Muster ([109])", () => {
it("Schicht-/Streumuster laufen über buildHatchRuns, nicht über <pattern>-Kacheln", () => {
for (const pattern of ["insulation", "insulationHard", "insulationWave", "timber", "earth", "gravel", "stone", "dots"] as const) {
expect(isGeneratedPattern(pattern)).toBe(true);
expect(polyUsesPattern(hatch({ pattern }))).toBe(false);
}
expect(polyUsesPattern(hatch({ pattern: "diagonal" }))).toBe(true);
expect(polyUsesPattern(hatch({ pattern: "crosshatch" }))).toBe(true);
});
});
+22 -35
View File
@@ -8,7 +8,7 @@ import { NO_HATCH } from "../../../core";
import { layoutText, stampBlockLines, wrapPlainText } from "../../../text/renderHtml";
import type { Vec2 } from "../../../model/types";
import { quantizePen } from "../../../export/sceneToPrintSvg";
import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
import { buildHatchRuns, buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
import { dashHasDot } from "../../../core";
import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../core";
import { dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "../../../core";
@@ -19,13 +19,30 @@ const IMG_TILE_VB = 40;
/** Lineare/Kreuz-Muster brauchen ein <pattern>; solid/none nicht. */
export function needsPattern(pattern: HatchRender["pattern"]): boolean {
return (
pattern === "insulation" ||
pattern === "diagonal" ||
pattern === "crosshatch" ||
pattern === "custom"
);
}
/**
* Muster, die der Kern-Generator als Linien/Polylinien erzeugt ([109]: Dämmschlange, Zickzack, Welle, Holzkreuz,
* Naturstein, Erdreich, Kies, Punktfeld) — der SVG-Rückfall zeichnet sie wie GL/Druck-SVG aus
* `buildHatchRuns` (eine Implementierung) statt als `<pattern>`-Kachel.
*/
export function isGeneratedPattern(pattern: HatchRender["pattern"]): boolean {
return (
pattern === "insulation" ||
pattern === "insulationHard" ||
pattern === "insulationWave" ||
pattern === "timber" ||
pattern === "earth" ||
pattern === "gravel" ||
pattern === "stone" ||
pattern === "dots"
);
}
/**
* Ob ein Polygon einen SVG-Fill-Server aus `<defs>` braucht (`<pattern>` ODER
* `<linearGradient>`/`<radialGradient>` — beide lassen sich identisch per
@@ -40,6 +57,7 @@ export function polyUsesPattern(h: HatchRender): boolean {
if (h.kind === "image") return !!h.image;
if (h.kind === "gradient") return !!h.gradient;
if (h.lines === "random") return false;
if (isGeneratedPattern(h.pattern)) return false;
return needsPattern(h.pattern);
}
@@ -122,37 +140,6 @@ export function HatchPattern({
);
}
if (hatch.pattern === "insulation") {
// Weiche Zickzack-/Wellenlinie (SIA-nah). Kachel 14×10 × Maßstab.
const w = 14 * hatch.scale;
const h = 10 * hatch.scale;
const my = 5 * hatch.scale;
const qy1 = -1 * hatch.scale;
const qy2 = 11 * hatch.scale;
const qx1 = 3.5 * hatch.scale;
const qx2 = 7 * hatch.scale;
const qx3 = 10.5 * hatch.scale;
return (
<pattern
id={id}
patternUnits="userSpaceOnUse"
width={w}
height={h}
patternTransform={`rotate(${hatch.angle})`}
>
<path
d={`M0 ${my} Q ${qx1} ${qy1} ${qx2} ${my} Q ${qx3} ${qy2} ${w} ${my}`}
fill="none"
stroke={hatch.color}
strokeWidth={sw}
style={dashStyle(w)}
strokeLinecap={dashCap}
vectorEffect={vfx}
/>
</pattern>
);
}
if (
hatch.pattern === "custom" &&
hatch.motif &&
@@ -570,9 +557,9 @@ export function renderPrimitive(
// Random-Vektor-Schraffur (Kies/Splitt): Grundfüllung + deterministische
// Streu-Striche (im MODELL-Raum erzeugt → toScreen; identischer Seed wie
// GL/PDF) + Umriss. KEIN <pattern> (die Striche werden direkt gezeichnet).
if (p.hatch.kind !== "image" && p.hatch.lines === "random") {
if (p.hatch.kind !== "image" && (p.hatch.lines === "random" || isGeneratedPattern(p.hatch.pattern))) {
const hsw = weight(p.hatch.lineWeight > 0 ? p.hatch.lineWeight : 0.13);
const runs = buildRandomHatchRuns(p.pts, p.hatch);
const runs = p.hatch.lines === "random" ? buildRandomHatchRuns(p.pts, p.hatch) : buildHatchRuns(p.pts, p.hatch);
return (
<g>
<polygon points={pts} fill={p.fill} stroke="none" />