[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

+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 = {