[275] Umbau: Farbe oder Stift je Status, gedämpfte Vorgabe, eigene Farben je Etappe

Wunsch Maintainer 17.11.: Umbau-Farben nicht mehr hart, Farbe oder Stift wählbar,
weniger leuchtendes Gelb und Rot.

Vorgabe (renovation::default_style, eine Stelle für Plan, Schnitt, Ansicht, Axo,
3D, Cycles-Umbaufarben, Panel): Abbruch #e8c35a statt #ffd800, Neu #c8524a mit
Linie #9e3a33 statt #e3001b/#c00016, Bestand #a6a6a6 unverändert. Begründung im
Bild (doc/review-275/01, 01b, 02): Ocker bleibt auf weissem Papier klar gelb und
neben dem Grau unterscheidbar, hat aber mehr Kontrast als das Signalgelb
(Leuchtdichte ~0.58 statt ~0.70); das Ziegelrot ist ruhig, die Wand-Füllung
deutlich gegen den grauen Bestand. Richtwerte unverändert übernommen. Eine
eigene Abbruch-Linie (dunkles Ocker #ad8a2c) wurde ausprobiert: Möbel und Baum
„zu fällen“ werden kräftiger, aber die Wandkontur wird ocker statt schwarz
gestrichelt und verschwimmt mit der Füllung — darum Linie weiter „wie ohne
Filter“ (dünnes Abbruch-Strichwerk bleibt blass, offen in TODO).

Modell (Rust, gen:types): RenovationStyle.fillPen/linePen (ColorPen-Id; Farbe
aus dem aktiven Stiftsatz beim Lesen, nicht eingebacken: ein S/W-Stiftsatz
färbt den Umbauplan um; Stift ohne Eintrag ⇒ freie Farbe/Vorgabe),
RenovationPhase.styles (eigene Farben der Etappe über der Projektfarbe).
Kern: renovation::style/phase_style/apply_own, View.phase_styles; View::treat
nimmt die Etappen-Farbe, solange das Element seinen eigenen Status zeigt (im
Stand einer späteren Etappe ist es Bestand), Ersatzstücke nach der Etappe ihrer
Öffnung, Sanierung je Schicht über treat; colors() (Tusche behält Farben) und
key() mit Etappen-Farben. Abfrage renovationStyles (Vorgabe, Projekt, Etappen
aufgelöst) — TS rechnet keine Farben mehr (DEFAULT_RENOVATION_STYLES entfernt,
renovationStyleOf fragt den Kern). project_refs prüft die Stifte.

Oberfläche: gemeinsamer Editor ui/RenovationStyleEditor.tsx mit dem
PenColorField der App (Frei/Stift), gestrichelt, Zurücksetzen je Status — im
Umbau-Panel (Abschnitt „Darstellung“, Knopf „SIA-Vorgabe“; je Etappe ein
Farbmuster-Knopf mit eigenem Editor und „Farben des Projekts verwenden“) und
im Ressourcen-Tab „Umbau“ (ersetzt die input type=color). Ops
setRenovationStylesOps/setPhaseStylesOps/patchRenovationStyles (Farbe und
Stift schliessen sich aus). Statusleisten-Punkt in der Projektfarbe
(useRenovationSwatches, hört nur auf Umbau/Stiftsätze). CSS-Muster über
--reno-*. Beispiel :umbau: Etappe 2 (Anbau) Neu gedämpft blau #5b84b1.

Geprüft: Kern cargo test --release (1913 + robustness 14) und --features web
robustness_web (3) grün, neu renovation_style_tests (6); WASM build:core
--no-opt; tsc; vitest gesamt 3640 grün (neu model/renovationStyles.test.ts),
Goldens ohne Änderung (kein Golden mit Umbau-Farben); e2e renovation271,
renovationPanel271, renovation274, renderCount (43 Renders je Wand-Änderung,
unverändert) und neu renovationStyles275 grün (Port 5196). Angesehen: CLI-SVG
--hatch Grundriss EG 1:50 und Schnitt C vorher/nachher, Etappe 2 blau,
Panel hell/dunkel im Browser-Build (Chromium/Linux).
Nicht geprüft: Tauri/Mac, 3D-Fenster (render3d) und Cycles-Bild mit den neuen
Farben (nur über Tests), Ressourcen-Tab nur per tsc (nicht angesehen).
This commit is contained in:
Claude committed 2026-11-17 20:21:52 +00:00
1 parent 05ffb7906f
commit e33b840739
40 files changed
+956 -144

No files matched your search

+5 -5
View File
@@ -54,13 +54,13 @@ describe("[271] Umbau", () => {
const p = buildUmbauSampleProject();
expect(renovationFilterList(p).map((f) => f.id)).toEqual(["bestand", "abbruch", "neubau", "umbauplan", "endzustand"]);
// Ohne Filter keine Umbau-Farben; Umbauplan grau, gelb und rot.
expect(fills(p)).not.toContain("#e3001b");
expect(fills(p)).not.toContain("#c8524a");
const u = fills(p, "umbauplan");
for (const c of ["#a6a6a6", "#ffd800", "#e3001b"]) expect(u).toContain(c);
for (const c of ["#a6a6a6", "#e8c35a", "#c8524a"]) expect(u).toContain(c);
// Neubau: kein Gelb (Abbruch weg), Rot da.
const n = fills(p, "neubau");
expect(n).not.toContain("#ffd800");
expect(n).toContain("#e3001b");
expect(n).not.toContain("#e8c35a");
expect(n).toContain("#c8524a");
// Kennzahlen: der Anbau zählt nur im Endzustand.
const b = computeKennzahlen(p, "bestand");
const e = computeKennzahlen(p, "endzustand");
@@ -81,7 +81,7 @@ describe("[271] Umbau", () => {
// ── Panel „Umbau“ ──
it("Panel: Vorschau je Filter stimmt mit dem Grundriss des Kerns überein (Override = Farbe da, Hide/Show = keine)", () => {
const p = buildUmbauSampleProject();
const colour = { existing: "#a6a6a6", demolish: "#ffd800", new: "#e3001b" } as const;
const colour = { existing: "#a6a6a6", demolish: "#e8c35a", new: "#c8524a" } as const;
for (const f of renovationFilterList(p)) {
const shows = renovationFilterShows(p, f.id)!;
const got = fills(p, f.id);
+74 -12
View File
@@ -4,7 +4,7 @@
import type { CoreOp } from "../core/ops";
import { documentFor } from "../core/document";
import { addItems, patchItem, patchItems, setField } from "../core/opsBuild";
import type { LayerRenovation, Project, Renovation, RenovationPhase, RenovationShow, RenovationSide, RenovationStatus, Tree, TreeStatus, WallType } from "./types";
import type { LayerRenovation, Project, Renovation, RenovationPhase, RenovationShow, RenovationSide, RenovationStatus, RenovationStyle, RenovationStyles, Tree, TreeStatus, WallType } from "./types";
/** Eingebaute Umbaufilter (Ids; Namen über `t("renovation.filter.<id>")`). */
export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"] as const;
@@ -26,12 +26,75 @@ export type RenovationCollection = (typeof RENOVATION_COLLECTIONS)[number];
const TREE_STATUS_OF: Record<RenovationStatus, TreeStatus> = { existing: "existing", demolish: "remove", new: "new" };
export const treeRenovationStatus = (t: Tree): RenovationStatus => (t.status === "remove" ? "demolish" : t.status === "new" ? "new" : "existing");
/** SIA-400-Vorgabe der Umbau-Farben (gleich wie `renovation::default_style` im Kern). */
export const DEFAULT_RENOVATION_STYLES: Record<RenovationStatus, { fill: string; line?: string; dashed: boolean }> = {
existing: { fill: "#a6a6a6", dashed: false },
demolish: { fill: "#ffd800", dashed: true },
new: { fill: "#e3001b", line: "#c00016", dashed: false },
};
/** Aufgelöste Umbau-Farbe eines Status (Stift schon in Farbe übersetzt). */
export interface RenovationStyleView {
fill: string;
line?: string;
dashed: boolean;
}
export type RenovationStyleSet = Record<RenovationStatus, RenovationStyleView>;
/** [275] Umbau-Farben, wie der Kern sie auflöst: SIA-Vorgabe, Projekt, Etappen mit eigenen Farben (Id → je Status). */
export interface ResolvedRenovationStyles {
defaults: RenovationStyleSet;
project: RenovationStyleSet;
phases: Record<string, RenovationStyleSet>;
}
type RawStyle = { fill: string; line: string | null; dashed: boolean };
const cleanSet = (x: Record<RenovationStatus, RawStyle>): RenovationStyleSet =>
Object.fromEntries(RENOVATION_STATUSES.map((s) => [s, { fill: x[s].fill, ...(x[s].line ? { line: x[s].line } : {}), dashed: x[s].dashed }])) as RenovationStyleSet;
/**
* [275] Umbau-Farben des Projekts (Kern-Abfrage `renovationStyles`, `renovation::style`/`phase_style`): eine Wahrheit
* für Plan und Muster der Oberfläche — Stifte (aktiver Stiftsatz) und Etappen-Farben sind schon aufgelöst.
*/
export function resolvedRenovationStyles(project: Project): ResolvedRenovationStyles {
const raw = documentFor(project).query<{ defaults: Record<RenovationStatus, RawStyle>; project: Record<RenovationStatus, RawStyle>; phases: Record<string, Record<RenovationStatus, RawStyle>> }>("renovationStyles");
return {
defaults: cleanSet(raw.defaults),
project: cleanSet(raw.project),
phases: Object.fromEntries(Object.entries(raw.phases ?? {}).map(([k, v]) => [k, cleanSet(v)])),
};
}
/**
* [275] Eine Umbau-Farbe ändern (`patch`; `null` = zurück auf die Vorgabe): fehlende Felder gelten als „wie Vorgabe“,
* Farbe und Stift schliessen sich aus (wer eine freie Farbe setzt, löst den Stift und umgekehrt). `undefined` = leer.
*/
export function patchRenovationStyles(styles: RenovationStyles | undefined, status: RenovationStatus, patch: Partial<RenovationStyle> | null): RenovationStyles | undefined {
const next: RenovationStyles = { ...(styles ?? {}) };
if (patch === null) delete next[status];
else {
const merged: RenovationStyle = { ...(next[status] ?? {}), ...patch };
if ("fill" in patch && patch.fill !== undefined) delete merged.fillPen;
if ("fillPen" in patch && patch.fillPen !== undefined) delete merged.fill;
if ("line" in patch && patch.line !== undefined) delete merged.linePen;
if ("linePen" in patch && patch.linePen !== undefined) delete merged.line;
for (const k of Object.keys(merged) as (keyof RenovationStyle)[]) if (merged[k] === undefined) delete merged[k];
if (Object.keys(merged).length) next[status] = merged;
else delete next[status];
}
return Object.keys(next).length ? next : undefined;
}
/** [275] Ops: Umbau-Farben des Projekts ersetzen (`undefined` = SIA-Vorgabe). */
export function setRenovationStylesOps(project: Project, styles: RenovationStyles | undefined): CoreOp[] {
const next = { ...(project.renovation ?? {}) };
if (styles) next.styles = styles;
else delete next.styles;
return [setField("renovation", Object.keys(next).length ? next : undefined)];
}
/** [275] Ops: eigene Umbau-Farben einer Etappe ersetzen (`undefined` = Farben des Projekts). */
export function setPhaseStylesOps(project: Project, phaseId: string, styles: RenovationStyles | undefined): CoreOp[] {
const phases = renovationPhases(project).map((ph) => {
if (ph.id !== phaseId) return ph;
const { styles: _drop, ...rest } = ph;
void _drop;
return styles ? { ...rest, styles } : rest;
});
return setPhasesOps(project, phases);
}
export interface RenovationFilterEntry {
id: string;
@@ -187,11 +250,10 @@ export function renovationFilterShows(project: Project, id: string): Record<Reno
return BUILTIN_FILTER_SHOWS[id] ?? null;
}
/** Umbau-Farbe eines Status (Projekt-Vorgabe über SIA-400-Vorgabe). */
export function renovationStyleOf(project: Project, status: RenovationStatus): { fill: string; line?: string; dashed: boolean } {
const d = DEFAULT_RENOVATION_STYLES[status];
const o = project.renovation?.styles?.[status];
return { fill: o?.fill ?? d.fill, line: o?.line ?? d.line, dashed: o?.dashed ?? d.dashed };
/** Umbau-Farbe eines Status (Etappe `phaseId` mit eigenen Farben, sonst Projekt, sonst SIA-Vorgabe; Kern löst auf). */
export function renovationStyleOf(project: Project, status: RenovationStatus, phaseId?: string | null): RenovationStyleView {
const r = resolvedRenovationStyles(project);
return (phaseId ? r.phases[phaseId]?.[status] : undefined) ?? r.project[status];
}
/** Möbel und Symbole (Objekte der Bibliothek, Blöcke): nehmen ohne Angabe als Bestand am Umbaufilter teil. */
+1 -1
View File
@@ -89,7 +89,7 @@ describe("[274] Sanierung je Schicht", () => {
expect(pr?.result.map((q) => q.kind)).toEqual(["new", "new", "newOverDemolish", "newOverDemolish", "kept"]);
expect(renovationPairs(p).renovated).toBe(1);
// Grundriss: Abbruch gelb, Umbauplan mit gelber gestrichelter Kontur über Rot.
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#ffd800");
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#e8c35a");
expect(dashedYellow(plan(p, "umbauplan"))).toBe(true);
expect(dashedYellow(plan(p, "endzustand"))).toBe(false);
// GF im Endzustand: die Südwand ist 10 cm dicker als ohne Sanierung (die Aussenkante rückt nach aussen).
+80
View File
@@ -0,0 +1,80 @@
// [275] Umbau-Farben: gedämpfte Vorgabe, Farbe ODER Stift (aktiver Stiftsatz), eigene Farben je Etappe — Auflösung im Kern
// (`renovationStyles`), Ops der Oberfläche, und dass der Grundriss genau die Farben der Muster zeigt.
import { describe, expect, it } from "vitest";
import { applyOps } from "../core/ops";
import { generatePlan } from "../plan/generatePlan";
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
import { patchRenovationStyles, renovationStyleOf, resolvedRenovationStyles, setPhaseStylesOps, setRenovationStylesOps } from "./renovation";
import type { Project } from "./types";
const ALL = new Set(["20", "21", "30", "31", "40", "60"]);
function fills(p: Project, filter: string): string[] {
const q = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter } : l)) };
return generatePlan(q, "eg", ALL).primitives.flatMap((x) => (x.kind === "polygon" ? [x.fill] : []));
}
describe("[275] Umbau-Farben", () => {
it("Vorgabe gedämpft: Ocker-Gelb, Ziegelrot, Grau", () => {
const r = resolvedRenovationStyles(buildUmbauSampleProject());
expect(r.defaults.demolish).toEqual({ fill: "#e8c35a", dashed: true });
expect(r.defaults.new).toEqual({ fill: "#c8524a", line: "#9e3a33", dashed: false });
expect(r.defaults.existing.fill).toBe("#a6a6a6");
});
it("Farbe und Stift schliessen sich aus; leer = Vorgabe", () => {
let s = patchRenovationStyles(undefined, "new", { fill: "#123456" });
expect(s).toEqual({ new: { fill: "#123456" } });
s = patchRenovationStyles(s, "new", { fillPen: "3" });
expect(s).toEqual({ new: { fillPen: "3" } });
s = patchRenovationStyles(s, "new", { line: "#000000" });
s = patchRenovationStyles(s, "new", { linePen: "4" });
expect(s).toEqual({ new: { fillPen: "3", linePen: "4" } });
s = patchRenovationStyles(s, "demolish", { dashed: false });
expect(patchRenovationStyles(patchRenovationStyles(s, "new", null), "demolish", null)).toBeUndefined();
});
it("Stift: Farbe aus dem aktiven Stiftsatz, ein S/W-Satz färbt den Umbauplan um", () => {
const base = buildUmbauSampleProject();
const withPens: Project = {
...base,
pens: [...(base.pens ?? []), { id: "u1", name: "Umbau Neu" }],
penSets: [
{ id: "farbe", name: "Farbe", pens: { u1: { color: "#3366cc", weight: 0.25 } } },
{ id: "sw", name: "S/W", pens: { u1: { color: "#999999", weight: 0.25 } } },
],
activePenSetId: "farbe",
};
const p = applyOps(withPens, setRenovationStylesOps(withPens, { new: { fillPen: "u1" } }));
expect(renovationStyleOf(p, "new").fill).toBe("#3366cc");
expect(fills(p, "umbauplan")).toContain("#3366cc");
const sw = { ...p, activePenSetId: "sw" };
expect(renovationStyleOf(sw, "new").fill).toBe("#999999");
expect(fills(sw, "umbauplan")).toContain("#999999");
expect(fills(sw, "umbauplan")).not.toContain("#3366cc");
// SIA-Vorgabe zurück.
const back = applyOps(p, setRenovationStylesOps(p, undefined));
expect(back.renovation?.styles).toBeUndefined();
expect(renovationStyleOf(back, "new").fill).toBe("#c8524a");
});
it("Etappe mit eigener Farbe: Neu der Etappe 2 im Beispiel in eigener Farbe, Projektfarbe bleibt", () => {
const p0 = buildUmbauSampleProject();
const e2 = p0.renovation!.phases![1];
// Das Beispiel zeigt Etappe 2 schon in eigener Farbe.
expect(e2.styles?.new).toBeTruthy();
const own = renovationStyleOf(p0, "new", e2.id).fill;
expect(own).not.toBe(renovationStyleOf(p0, "new").fill);
expect(fills(p0, "umbauplan")).toContain(own);
// Zurück auf die Projektfarben: nur die Etappe ändert sich (Name, Reihenfolge, Elemente bleiben).
const p1 = applyOps(p0, setPhaseStylesOps(p0, e2.id, undefined));
expect(p1.renovation!.phases![1]).toEqual({ id: e2.id, name: e2.name });
expect(resolvedRenovationStyles(p1).phases[e2.id]).toBeUndefined();
expect(fills(p1, "umbauplan")).not.toContain(own);
expect(p1.walls.map((w) => w.renovation)).toEqual(p0.walls.map((w) => w.renovation));
// Neue eigene Farbe für Abbruch der Etappe.
const p2 = applyOps(p1, setPhaseStylesOps(p1, e2.id, { demolish: { fill: "#7a5c99" } }));
expect(resolvedRenovationStyles(p2).phases[e2.id].demolish.fill).toBe("#7a5c99");
expect(resolvedRenovationStyles(p2).phases[e2.id].new.fill).toBe("#c8524a");
});
});
+3 -1
View File
@@ -126,7 +126,9 @@ export function buildUmbauSampleProject(): Project {
renovation: {
phases: [
{ id: "etappe-1", name: "Etappe 1" },
{ id: "etappe-2", name: "Etappe 2" },
// [275] Etappe 2 (Anbau) mit eigener Farbe: Neues gedämpft blau statt rot, damit die zwei Etappen im Umbauplan
// auseinanderzuhalten sind.
{ id: "etappe-2", name: "Etappe 2", styles: { new: { fill: "#5b84b1", line: "#3e6390" } } },
],
},
};
+20 -2
View File
@@ -3439,7 +3439,15 @@ export type RenovationFilter = {
};
/** [271] Eine Bau-Etappe (Reihenfolge = Reihenfolge der Liste). */
export type RenovationPhase = { id: string; name: string };
export type RenovationPhase = {
id: string;
name: string;
/**
* [275] Eigene Umbau-Farben der Etappe (Neu/Abbruch dieser Etappe, z. B. Neubau Etappe 2 blau); fehlende Felder
* ⇒ die Farben des Projekts (`RenovationSettings.styles`), dann die SIA-Vorgabe.
*/
styles?: RenovationStyles;
};
/** [271] Umbau-Einstellungen des Projekts. */
export type RenovationSettings = {
@@ -3466,8 +3474,18 @@ export type RenovationStatus = "existing" | "demolish" | "new";
/**
* [271] Umbau-Farbe eines Status: Füllung der Schnittflächen, Linienfarbe, gestrichelt. Fehlende Felder ⇒ SIA-Vorgabe.
* [275] Statt einer freien Farbe ein Stift (`ColorPen.id`): seine Farbe aus dem aktiven Stiftsatz geht der freien
* Farbe vor (ein S/W-Plot-Stiftsatz färbt so auch die Umbau-Farben um; Stift ohne Eintrag ⇒ freie Farbe/Vorgabe).
*/
export type RenovationStyle = { fill?: string; line?: string; dashed?: boolean };
export type RenovationStyle = {
fill?: string;
/** [275] Stift der Füllung. */
fillPen?: string;
line?: string;
/** [275] Stift der Linien. */
linePen?: string;
dashed?: boolean;
};
/** [271] Umbau-Farben je Status (fehlt ⇒ SIA-400-Vorgabe, `renovation::default_style`). */
export type RenovationStyles = { existing?: RenovationStyle; demolish?: RenovationStyle; new?: RenovationStyle };