Merge [274] Umbau je Schicht (mit [271]-Rest zusammengeführt)

Konflikte inhaltlich gelöst, beide Funktionsumfänge bleiben: Sanierung je Schicht ([274]) und Ersatzstücke in
Schnitt/Ansicht, Projektionslinien in Umbau-Farbe, 2D/Möbel, Bäume = Umbau-Status, Bäume verdeckt ([271]/[149]).

- renovation.rs: resolve_filter (mit [272]-Grau) nimmt die sanierten Wände (build_up::look) auf; beide
  Testmodule (renovation_tests2, renovation_layers_tests); fehlende Felder `ghost` ergänzt (Stand vorher
  kompilierte nicht).
- Schnitt (query.rs) und Ansicht (elevation): gefiltertes Projekt über Resolved::project bzw. without_hidden +
  swap_build_ups; `orig` (Quelle der Ersatzstücke) = Projekt mit allem, aber mit den gezeigten Aufbauten.
- CutRules::with_renovation: Projektionslinien ([271]) plus Farbe je Schicht ([274]); Projektionslinien sanierter
  Wände in der Farbe der äussersten Schicht (Resolved::faces).
- axo/queries: Bearbeitungsvariante ([272]) und Resolved::project ([274]).
- Beispiel :umbau vereint Südwand W1 + Schnitt C mit Möbeln, Bäumen und Ansicht West; CSS beide Blöcke.
- TODO/ARCHITEKTUR/RELEASE-NOTES: Sätze beider Seiten, veraltete Offen-Punkte von [271] gestrichen, ID-Zähler 274.
  Bild doc/review-274/06-nach-merge.png.
This commit is contained in:
Claude committed 2026-11-17 18:58:59 +00:00
commit b3bb92522f
37 files changed
+2033 -53

No files matched your search

+2
View File
@@ -184,6 +184,8 @@ export type QueryName =
| "kennzahlen"
| "areaTable"
| "renovationFilters"
| "renovationPair"
| "renovationPairs"
| "designOptionInfo"
| "designOptionCompare"
| "costEstimate"
+6
View File
@@ -130,6 +130,12 @@ export {
renovationFilterShows, renovationStyleOf, idsByRenovationStatus, renovationCounts, phaseUsage,
} from "../model/renovation";
export type { RenovationFilterEntry, RenovationCollection } from "../model/renovation";
// [274] Sanierung je Schicht: Typ-Paar Bestand → Sanierungstyp
export {
wallBuildUp, buildUpKey, parseBuildUpKey, setBuildUpOps, commonBuildUp, renovateAllOfTypeOps, createRenovationTypeOps, setTypePairOps,
renovationPair, renovationPairs,
} from "../model/renovation";
export type { RenovationBuildUp, RenovationPair, RenovationPairLayer, RenovationStripPiece, RenovationPairsInfo } from "../model/renovation";
export { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
// [272] Varianten: Sätze, Kombinationen, Zuweisen/Kopieren/Übernehmen (Regeln im Kern `design_options.rs`, Sichtbarkeit `renovation.rs`)
export {
+31
View File
@@ -4754,6 +4754,37 @@ export const de = {
"renovation.panel.phases.deleteMessageUnused": "Etappe „{name}“ löschen?",
"renovation.panel.phases.delete": "Löschen",
"renovation.panel.colors": "Umbau-Farben in den Ressourcen …",
"renovation.buildUp": "Neuer Aufbau (Sanierung)",
"renovation.buildUp.none": "keiner",
"renovation.buildUp.type": "wie Typ: {name}",
"renovation.buildUp.typeMissing": "wie Typ (kein Sanierungstyp)",
"renovation.buildUp.other": "Typ {name}",
"renovation.buildUp.hint": "Neuer Aufbau nur bei Status Bestand; Abbruch und Neu je Schicht nach dem Typ-Paar.",
"renovation.strip.old": "Alt",
"renovation.strip.new": "Neu",
"renovation.strip.result": "Ergebnis",
"renovation.panel.sanierung.title": "Sanierung",
"renovation.panel.sanierung.count": "Sanierte Bauteile: {n}",
"renovation.panel.sanierung.empty": "Noch kein Sanierungstyp. Wandtyp wählen und „Sanierungstyp anlegen …“.",
"renovation.panel.sanierung.walls": "{r} von {n} Wänden saniert",
"renovation.panel.sanierung.renovateAll": "Alle Wände vom Typ sanieren",
"renovation.panel.sanierung.create": "Sanierungstyp anlegen …",
"renovation.panel.sanierung.createFor": "Bestandstyp",
"renovation.panel.sanierung.newName": "{name} saniert",
"renovation.panel.sanierung.edit": "Zuordnung bearbeiten",
"renovation.panel.sanierung.target": "Sanierungstyp",
"renovation.panel.sanierung.side": "Bezugsseite",
"renovation.panel.sanierung.side.inside": "innen (Aussendämmung)",
"renovation.panel.sanierung.side.outside": "aussen (Innendämmung)",
"renovation.panel.sanierung.oldLayers": "Bestandstyp (alt)",
"renovation.panel.sanierung.newLayers": "Sanierungstyp (neu)",
"renovation.panel.sanierung.reset": "Automatisch zuordnen",
"renovation.panel.sanierung.remove": "Sanierungstyp entfernen",
"renovation.panel.sanierung.editLayers": "Schichten in den Ressourcen …",
"renovation.fate.auto": "automatisch",
"renovation.fate.kept": "Bestand",
"renovation.fate.demolish": "Abbruch",
"renovation.fate.new": "Neu",
"resources.tab.renovation": "Umbau",
"file.newFromUmbauSample": "Neu aus Vorlage: Beispiel Umbau",
"menu.native.newFromUmbauSample": "Beispiel Umbau",
+31
View File
@@ -4740,6 +4740,37 @@ export const en: Record<TranslationKey, string> = {
"renovation.panel.phases.deleteMessageUnused": "Delete phase “{name}”?",
"renovation.panel.phases.delete": "Delete",
"renovation.panel.colors": "Renovation colors in the resources …",
"renovation.buildUp": "New build-up (refurbishment)",
"renovation.buildUp.none": "none",
"renovation.buildUp.type": "as type: {name}",
"renovation.buildUp.typeMissing": "as type (no refurbishment type)",
"renovation.buildUp.other": "Type {name}",
"renovation.buildUp.hint": "New build-up only for status existing; demolition and new per layer from the type pair.",
"renovation.strip.old": "Old",
"renovation.strip.new": "New",
"renovation.strip.result": "Result",
"renovation.panel.sanierung.title": "Refurbishment",
"renovation.panel.sanierung.count": "Refurbished elements: {n}",
"renovation.panel.sanierung.empty": "No refurbishment type yet. Pick a wall type and “Create refurbishment type …”.",
"renovation.panel.sanierung.walls": "{r} of {n} walls refurbished",
"renovation.panel.sanierung.renovateAll": "Refurbish all walls of this type",
"renovation.panel.sanierung.create": "Create refurbishment type …",
"renovation.panel.sanierung.createFor": "Existing type",
"renovation.panel.sanierung.newName": "{name} refurbished",
"renovation.panel.sanierung.edit": "Edit layer mapping",
"renovation.panel.sanierung.target": "Refurbishment type",
"renovation.panel.sanierung.side": "Reference side",
"renovation.panel.sanierung.side.inside": "inside (external insulation)",
"renovation.panel.sanierung.side.outside": "outside (internal insulation)",
"renovation.panel.sanierung.oldLayers": "Existing type (old)",
"renovation.panel.sanierung.newLayers": "Refurbishment type (new)",
"renovation.panel.sanierung.reset": "Map automatically",
"renovation.panel.sanierung.remove": "Remove refurbishment type",
"renovation.panel.sanierung.editLayers": "Layers in the resources …",
"renovation.fate.auto": "automatic",
"renovation.fate.kept": "Existing",
"renovation.fate.demolish": "Demolish",
"renovation.fate.new": "New",
"resources.tab.renovation": "Renovation",
"file.newFromUmbauSample": "New From Template: Renovation Example",
"menu.native.newFromUmbauSample": "Renovation Example",
+162 -4
View File
@@ -3,8 +3,8 @@
import type { CoreOp } from "../core/ops";
import { documentFor } from "../core/document";
import { patchItems, setField } from "../core/opsBuild";
import type { Project, Renovation, RenovationPhase, RenovationShow, RenovationStatus, Tree, TreeStatus } from "./types";
import { addItems, patchItem, patchItems, setField } from "../core/opsBuild";
import type { LayerRenovation, Project, Renovation, RenovationPhase, RenovationShow, RenovationSide, RenovationStatus, 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;
@@ -76,7 +76,7 @@ export function setRenovationOps(project: Project, ids: Iterable<string>, status
const old = (e as { renovation?: Renovation }).renovation;
const st = status ?? renovationStatus(old);
const ph = phase === undefined ? old?.phase : phase ?? undefined;
const next = renovationForNew(st, ph);
const next = keepRenovated(renovationForNew(st, ph), old);
const { renovation: _drop, ...rest } = e as { renovation?: Renovation } & Record<string, unknown>;
void _drop;
return (next ? { ...rest, renovation: next } : rest) as unknown as typeof e;
@@ -88,6 +88,15 @@ export function setRenovationOps(project: Project, ids: Iterable<string>, status
return ops;
}
/** [274] Sanierung (`renovated`, `newTypeId`) beim Setzen von Status/Etappe behalten. */
function keepRenovated(next: Renovation | undefined, old: Renovation | undefined): Renovation | undefined {
if (!old?.renovated && !old?.newTypeId) return next;
const r: Renovation = { ...(next ?? { status: "existing" }) };
if (old.renovated) r.renovated = true;
if (old.newTypeId) r.newTypeId = old.newTypeId;
return r;
}
/** Element-Ids der Auswahl, die einen Umbau-Status tragen können. */
export function renovatableIds(project: Project, ids: Iterable<string>): string[] {
const set = new Set(ids);
@@ -141,7 +150,7 @@ export function setPhasesOps(project: Project, phases: readonly RenovationPhase[
},
(e) => {
const r = (e as { renovation?: Renovation }).renovation!;
const next = renovationForNew(renovationStatus(r), null);
const next = keepRenovated(renovationForNew(renovationStatus(r), null), r);
const { renovation: _drop, ...rest } = e as { renovation?: Renovation } & Record<string, unknown>;
void _drop;
return (next ? { ...rest, renovation: next } : rest) as unknown as typeof e;
@@ -250,3 +259,152 @@ export function phaseUsage(project: Project, phaseId: string): number {
}
return n;
}
// ── [274] Sanierung je Schicht: Typ-Paar Bestand → Sanierungstyp (Regeln im Kern `renovation::build_up`) ────────────
/** Neuer Aufbau einer Wand: keiner, der Sanierungstyp ihres Wandtyps oder ein anderer Wandtyp (Ausnahme). */
export type RenovationBuildUp = { kind: "none" } | { kind: "type" } | { kind: "other"; typeId: string };
/** Neuer Aufbau einer Wand aus ihren Umbau-Angaben. */
export function wallBuildUp(r: Renovation | undefined | null): RenovationBuildUp {
if (r?.newTypeId) return { kind: "other", typeId: r.newTypeId };
return r?.renovated ? { kind: "type" } : { kind: "none" };
}
/** Schlüssel eines Aufbaus für Auswahllisten (`""` keiner, `"type"` wie Typ, sonst die Typ-Id mit Präfix). */
export function buildUpKey(b: RenovationBuildUp): string {
return b.kind === "none" ? "" : b.kind === "type" ? "type" : `t:${b.typeId}`;
}
/** Gegenstück zu {@link buildUpKey}. */
export function parseBuildUpKey(k: string): RenovationBuildUp {
if (k === "type") return { kind: "type" };
if (k.startsWith("t:") && k.length > 2) return { kind: "other", typeId: k.slice(2) };
return { kind: "none" };
}
function withBuildUp(r: Renovation | undefined, b: RenovationBuildUp): Renovation | undefined {
const base: Renovation = { ...(r ?? { status: "existing" }) };
delete base.renovated;
delete base.newTypeId;
if (b.kind === "type") base.renovated = true;
if (b.kind === "other") {
base.renovated = true;
base.newTypeId = b.typeId;
}
const plain = base.status === "existing" && !base.phase && !base.renovated;
return plain ? undefined : base;
}
/** Ops: neuer Aufbau für die Wände `ids` (ein Undo-Schritt); Status/Etappe bleiben. */
export function setBuildUpOps(project: Project, ids: Iterable<string>, b: RenovationBuildUp): CoreOp[] {
const set = new Set(ids);
return patchItems(project, "walls", set, (w) => {
const next = withBuildUp(w.renovation, b);
const { renovation: _drop, ...rest } = w;
void _drop;
return next ? { ...rest, renovation: next } : rest;
});
}
/** Gemeinsamer Aufbau-Schlüssel ({@link buildUpKey}) der Wände `ids`: `"mixed"` bei verschiedenen, `null` ohne Wände. */
export function commonBuildUp(project: Project, ids: Iterable<string>): string | null {
const set = new Set(ids);
let out: string | null = null;
for (const w of project.walls) {
if (!set.has(w.id)) continue;
const k = buildUpKey(wallBuildUp(w.renovation));
if (out === null) out = k;
else if (out !== k) return "mixed";
}
return out;
}
/** Ops: alle Wände des Bestandstyps `typeId` sanieren (Sanierungstyp des Typs; ein Undo-Schritt). */
export function renovateAllOfTypeOps(project: Project, typeId: string): CoreOp[] {
const ids = project.walls.filter((w) => w.wallTypeId === typeId && renovationStatus(w.renovation) === "existing").map((w) => w.id);
return setBuildUpOps(project, ids, { kind: "type" });
}
/** Nächste freie Wandtyp-Id mit Präfix. */
function freeTypeId(project: Project, base: string): string {
const used = new Set(project.wallTypes.map((t) => t.id));
let i = 1;
while (used.has(`${base}-${i}`)) i++;
return `${base}-${i}`;
}
/**
* Ops: „Sanierungstyp anlegen …“ — Kopie des Bestandstyps `typeId` als neuer Wandtyp `name` (zum Anpassen der Schichten)
* und als Sanierungstyp des Bestandstyps eingetragen. Liefert die Ops und die neue Id.
*/
export function createRenovationTypeOps(project: Project, typeId: string, name: string): { ops: CoreOp[]; id: string } {
const src = project.wallTypes.find((t) => t.id === typeId);
if (!src) return { ops: [], id: "" };
const id = freeTypeId(project, `${typeId}-saniert`);
const copy: WallType = { id, name, layers: src.layers.map((l) => ({ ...l })) };
return { ops: [...addItems("wallTypes", [copy]), ...setTypePairOps(project, typeId, { target: id, old: null, new: null })], id };
}
/** Ops: Typ-Paar am Bestandstyp ändern (Sanierungstyp, Bezugsseite, manuelle Zuordnung; `null` entfernt). */
export function setTypePairOps(
project: Project,
typeId: string,
patch: { target?: string | null; side?: RenovationSide | null; old?: LayerRenovation[] | null; new?: LayerRenovation[] | null },
): CoreOp[] {
return patchItem(project, "wallTypes", typeId, (t) => {
const next: WallType = { ...t };
const put = <K extends keyof WallType>(k: K, v: WallType[K] | null | undefined) => {
if (v === undefined) return;
if (v === null || (Array.isArray(v) && v.every((x) => x === "auto"))) delete next[k];
else next[k] = v;
};
put("renovationTarget", patch.target);
put("renovationSide", patch.side === "inside" ? null : patch.side);
put("renovationOld", patch.old);
put("renovationNew", patch.new);
return next;
});
}
/** Schicht eines Typ-Paars (Kern-Abfrage `renovationPair`). */
export interface RenovationPairLayer {
componentId: string;
name: string;
color: string;
thickness: number;
fate: "kept" | "demolish" | "new";
}
/** Teilstück eines Ergebnis-Streifens. */
export interface RenovationStripPiece {
thickness: number;
kind: "kept" | "demolish" | "new" | "newOverDemolish";
fill: string;
}
export interface RenovationPair {
type: string;
target: string;
side: RenovationSide;
old: RenovationPairLayer[];
new: RenovationPairLayer[];
oldStrip: RenovationStripPiece[];
newStrip: RenovationStripPiece[];
result: RenovationStripPiece[];
walls: number;
renovated: number;
}
/** Typ-Paar Bestandstyp → Sanierungstyp (`target` fehlt = eingetragener); `null` ohne gültiges Paar. */
export function renovationPair(project: Project, typeId: string, target?: string): RenovationPair | null {
return documentFor(project).query<RenovationPair | null>("renovationPair", [], JSON.stringify({ type: typeId, target: target ?? "" }));
}
export interface RenovationPairsInfo {
pairs: { type: string; name: string; target: string; targetName: string | null; walls: number; renovated: number }[];
renovated: number;
}
/** Alle Typ-Paare mit Zählern (Umbau-Panel „Sanierung“). */
export function renovationPairs(project: Project): RenovationPairsInfo {
return documentFor(project).query<RenovationPairsInfo>("renovationPairs");
}
+102
View File
@@ -0,0 +1,102 @@
// [274] Sanierung je Schicht: Ops (neuer Aufbau je Wand, alle Wände eines Typs, Sanierungstyp anlegen, Typ-Paar),
// gemeinsamer Wert bei Mehrfachauswahl, Kern-Abfragen am Umbau-Beispiel (Typ-Paar, Zähler, Grundriss je Filter).
import { describe, expect, it } from "vitest";
import { applyOps } from "../core/ops";
import {
buildUpKey,
commonBuildUp,
createRenovationTypeOps,
parseBuildUpKey,
renovateAllOfTypeOps,
renovationPair,
renovationPairs,
setBuildUpOps,
setPhasesOps,
setRenovationOps,
setTypePairOps,
wallBuildUp,
} from "./renovation";
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
import { generatePlan } from "../plan/generatePlan";
import { computeAreaTable } from "../analysis/areaTable";
import type { Project } from "./types";
const ALL = new Set(["20", "21", "30", "31", "40", "60"]);
function plan(p: Project, filter: string) {
const q = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter } : l)) };
return generatePlan(q, "eg", ALL).primitives;
}
describe("[274] Sanierung je Schicht", () => {
it("Aufbau-Schlüssel: keiner, wie Typ, anderer Typ", () => {
expect(wallBuildUp(undefined)).toEqual({ kind: "none" });
expect(wallBuildUp({ status: "existing", renovated: true })).toEqual({ kind: "type" });
expect(wallBuildUp({ status: "existing", renovated: true, newTypeId: "x" })).toEqual({ kind: "other", typeId: "x" });
for (const k of ["", "type", "t:abc"]) expect(buildUpKey(parseBuildUpKey(k))).toBe(k);
expect(parseBuildUpKey("t:")).toEqual({ kind: "none" });
});
it("Neuer Aufbau für mehrere Wände in einem Schritt; Status/Etappe ändern behält die Sanierung", () => {
const p = buildUmbauSampleProject();
const ops = setBuildUpOps(p, ["W2", "W3"], { kind: "other", typeId: "aw-saniert" });
expect(ops).toHaveLength(2);
const q = applyOps(p, ops);
expect(q.walls.find((w) => w.id === "W2")?.renovation).toEqual({ status: "existing", renovated: true, newTypeId: "aw-saniert" });
expect(commonBuildUp(q, ["W2", "W3"])).toBe("t:aw-saniert");
expect(commonBuildUp(q, ["W1", "W2"])).toBe("mixed");
expect(commonBuildUp(q, ["O1"])).toBeNull();
// Status setzen: Sanierung bleibt.
const r = applyOps(q, setRenovationOps(q, ["W2"], "existing", "etappe-2"));
expect(r.walls.find((w) => w.id === "W2")?.renovation).toEqual({ status: "existing", phase: "etappe-2", renovated: true, newTypeId: "aw-saniert" });
// Etappe löschen: Sanierung bleibt.
const s = applyOps(p, setPhasesOps(p, [{ id: "etappe-2", name: "Etappe 2" }]));
expect(s.walls.find((w) => w.id === "W1")?.renovation).toEqual({ status: "existing", renovated: true });
// Keiner: Feld weg (Bestand ohne Etappe).
const t = applyOps(q, setBuildUpOps(q, ["W2"], { kind: "none" }));
expect(t.walls.find((w) => w.id === "W2")).not.toHaveProperty("renovation");
});
it("Sanierungstyp anlegen, alle Wände vom Typ sanieren, Typ-Paar mit Zuordnung", () => {
const p = buildUmbauSampleProject();
const { ops, id } = createRenovationTypeOps(p, "aw", "Aussenwand saniert");
const q = applyOps(p, ops);
expect(q.wallTypes.find((t) => t.id === "aw")?.renovationTarget).toBe(id);
expect(q.wallTypes.find((t) => t.id === id)?.layers).toEqual(p.wallTypes.find((t) => t.id === "aw")?.layers);
// Alle Bestandswände vom Typ „aw“ (W2, W3, W4 auf EG; W5–W8 auf OG; nicht die neuen W10–W12) in einem Schritt.
const r = applyOps(q, renovateAllOfTypeOps(q, "aw"));
const renovated = r.walls.filter((w) => w.renovation?.renovated).map((w) => w.id).sort();
expect(renovated).toEqual(["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8"]);
// Gleiche Schichten: alles Bestand (nichts abgebrochen, nichts neu).
const pr = renovationPair(r, "aw");
expect(pr?.old.every((l) => l.fate === "kept")).toBe(true);
// Manuelle Zuordnung am Typ-Paar: die Dämmung wird ersetzt.
const s = applyOps(r, setTypePairOps(r, "aw", { old: ["auto", "demolish"] }));
expect(renovationPair(s, "aw")?.old.map((l) => l.fate)).toEqual(["kept", "demolish", "kept", "kept"]);
expect(renovationPair(s, "aw")?.new.map((l) => l.fate)).toEqual(["kept", "new", "kept", "kept"]);
// Alles „automatisch“: Feld weg.
const u = applyOps(s, setTypePairOps(s, "aw", { old: ["auto", "auto"] }));
expect(u.wallTypes.find((t) => t.id === "aw")).not.toHaveProperty("renovationOld");
expect(renovationPairs(u).pairs.map((x) => x.type).sort()).toEqual(["aw", "aw-bestand"]);
});
it("Beispiel Umbau: Typ-Paar der Südwand, Zähler, Grundriss und GF je Filter", () => {
const p = buildUmbauSampleProject();
const pr = renovationPair(p, "aw-bestand");
expect(pr?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "kept"]);
expect(pr?.new.map((l) => l.fate)).toEqual(["new", "new", "kept"]);
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");
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).
const unsaniert = applyOps(p, setBuildUpOps(p, ["W1"], { kind: "none" }));
const gf = (q: Project) => computeAreaTable(q, JSON.stringify({ renovation: "endzustand", renovationPhase: "etappe-1" })).total.gf;
expect(gf(p) - gf(unsaniert)).toBeGreaterThan(0.25);
const gfB = (q: Project) => computeAreaTable(q, "bestand").total.gf;
expect(gfB(p)).toBeCloseTo(gfB(unsaniert), 9);
});
});
+33 -2
View File
@@ -8,9 +8,12 @@
// Möbel (Objekte der Bibliothek) und Bäume tragen den Umbau-Status ebenfalls: ein Sofa bleibt (Bestand), ein Tisch wird
// entfernt (Abbruch, Etappe 1), ein neues Sofa kommt in den Anbau (Etappe 2); ein Baum wird gefällt (Bäume: `status` = Umbau-Status),
// ein neuer wird gepflanzt.
// [274] Sanierung je Schicht: die Südwand W1 ist eine Aussenwand „Beton 20 + Dämmung 10 + Aussenputz“ (Bestandstyp
// „aw-bestand“) mit dem Sanierungstyp „aw-saniert“ (Beton bleibt, Dämmung und Putz werden abgebrochen, neue Dämmung 20 +
// neuer Putz), saniert in Etappe 1: Kern bleibt an seiner Stelle, die Fassade rückt 10 cm nach aussen.
// Nur Modellfelder, keine Kern-Befehle: das Modul ist ohne geladenen Kern auswertbar.
import type { Ceiling, Drawing2D, DrawingLevel, Opening, Project, Renovation, Room, Tree, Wall } from "./types";
import type { Ceiling, Drawing2D, DrawingLevel, Opening, Project, Renovation, Room, Tree, Wall, WallType } from "./types";
import { sampleProject } from "./sampleProject";
const E1: Renovation = { status: "new", phase: "etappe-1" };
@@ -46,8 +49,35 @@ export function buildUmbauSampleProject(): Project {
{ id: "schnitt-b", name: "Schnitt B", kind: "section", visible: true, locked: false, linePoints: [{ x: 1.4, y: -1 }, { x: 1.4, y: 8 }], directionSign: -1 },
// Ansicht West (Blick nach Osten): das neue Fenster O3 in der Bestandswand W4 mit seinem Abbruch-Stück, der Anbau dahinter.
{ id: "ansicht-west", name: "Ansicht West", kind: "elevation", visible: true, locked: false, linePoints: [{ x: -2, y: 8 }, { x: -2, y: -1 }], directionSign: 1 },
// [274] Schnitt durch die sanierte Südwand W1 (zwischen Tür und Fenster) und den Anbau.
{ id: "schnitt-c", name: "Schnitt C", kind: "section", visible: true, locked: false, linePoints: [{ x: 2, y: -1 }, { x: 2, y: 8 }], directionSign: -1 },
];
const walls: Wall[] = base.walls.map((w) =>
w.id === "W9" ? { ...w, renovation: D1 } : w.id === "W1" ? { ...w, wallTypeId: "aw-bestand", renovation: { status: "existing", phase: "etappe-1", renovated: true } } : w,
);
// [274] Typ-Paar Bestand → Sanierung (aussen → innen).
const wallTypes: WallType[] = [
...base.wallTypes,
{
id: "aw-bestand",
name: "Aussenwand Beton 20 + Dämmung 10 (Bestand)",
layers: [
{ componentId: "render-ext", thickness: 0.02 },
{ componentId: "insulation", thickness: 0.1 },
{ componentId: "concrete", thickness: 0.2 },
],
renovationTarget: "aw-saniert",
},
{
id: "aw-saniert",
name: "Aussenwand Beton 20 + Dämmung 20 (saniert)",
layers: [
{ componentId: "render-ext", thickness: 0.02 },
{ componentId: "insulation", thickness: 0.2 },
{ componentId: "concrete", thickness: 0.2 },
],
},
];
const walls: Wall[] = base.walls.map((w) => (w.id === "W9" ? { ...w, renovation: D1 } : w));
walls.push(wall("W10", 0, 4, 0, 7), wall("W11", 0, 7, 3, 7), wall("W12", 3, 7, 3, 4));
const openings: Opening[] = (base.openings ?? []).map((o) => (o.id === "O2" ? { ...o, renovation: D1 } : o));
openings.push(
@@ -86,6 +116,7 @@ export function buildUmbauSampleProject(): Project {
id: "beispiel-umbau",
name: "Beispiel Umbau",
drawingLevels: levels,
wallTypes,
walls,
openings,
ceilings,
+37 -1
View File
@@ -1981,6 +1981,9 @@ export type LayerFunction =
| "cladding"
| "air";
/** [274] Zuordnung einer Schicht im Typ-Paar Bestand → Sanierung (manuell statt automatisch). */
export type LayerRenovation = "auto" | "existing" | "demolish" | "new";
/**
* Schichteinzug einer Wandschicht an der Öffnung ([106]): Regel für alle Seiten, je Seite
* übersteuerbar. `layer` zählt ab aussen (0 = äusserste Schicht); negativ ab innen (−1 = innerste),
@@ -3415,6 +3418,15 @@ export type Renovation = {
* Fehlt ⇒ erste Etappe.
*/
phase?: string;
/**
* [274] Saniert: die Wand bekommt den Sanierungstyp ihres Wandtyps (`WallType.renovationTarget`) als neuen
* Aufbau; der bisherige Aufbau ist der Bestand. Wirkt nur beim Status Bestand; Etappe der Sanierung = `phase`.
*/
renovated?: boolean;
/**
* [274] Ausnahme: anderer neuer Aufbau als der Sanierungstyp des Wandtyps (Wandtyp-Id); setzt „saniert“ voraus.
*/
newTypeId?: string;
};
/** [271] Ein Umbaufilter (wie Archicads „Renovation Filter“): Darstellung je Status. */
@@ -3441,6 +3453,11 @@ export type RenovationSettings = {
/** [271] Darstellung eines Status im Umbaufilter. */
export type RenovationShow = "show" | "hide" | "override";
/**
* [274] Bezugsseite einer Sanierung (bleibt stehen, von ihr her werden die Schichten verglichen).
*/
export type RenovationSide = "inside" | "outside";
/**
* [271] Umbau-Status eines Bauteils (Archicad „Renovation Status“; SIA 400: Bestand schwarz/grau, Abbruch gelb,
* Neu rot).
@@ -4751,7 +4768,26 @@ export type Wall = {
export type WallReferenceLine = "left" | "center" | "right";
/** Ein Wandtyp = geordneter Schichtaufbau (außen → innen). */
export type WallType = { id: string; name: string; layers: Array<Layer> };
export type WallType = {
id: string;
name: string;
layers: Array<Layer>;
/**
* [274] Sanierungstyp (Wandtyp-Id): neuer Aufbau aller als „saniert“ markierten Wände dieses (Bestands-)Typs.
*/
renovationTarget?: string;
/** [274] Bezugsseite der Sanierung (fehlt ⇒ innen). */
renovationSide?: RenovationSide;
/**
* [274] Manuelle Zuordnung je Schicht dieses Bestandstyps (Bestand/Abbruch, fehlt/„auto“ = automatisch); gilt
* für das Paar mit `renovationTarget`.
*/
renovationOld?: Array<LayerRenovation>;
/**
* [274] Manuelle Zuordnung je Schicht des Sanierungstyps (Bestand/Neu, fehlt/„auto“ = automatisch).
*/
renovationNew?: Array<LayerRenovation>;
};
/** Rollladen-/Sonnenschutzkasten über der Öffnung (P0-Minimalfassung). */
export type WindowShading = {
+4
View File
@@ -23,6 +23,7 @@ import {
import type { Project, RenovationShow, RenovationStatus } from "../model/types";
import { ConfirmDialog } from "../ui/ConfirmDialog";
import { usePanelHostAction } from "./host";
import { RenovationSanierung } from "./RenovationSanierung";
const MIXED = "__mixed";
@@ -238,6 +239,9 @@ export function RenovationPanel() {
</div>
</div>
{/* [274] Sanierung je Schicht: Typ-Paare Bestand → Sanierungstyp */}
<RenovationSanierung project={project} />
{/* Etappen */}
<div className="reno-block">
<div className="reno-head">{t("renovation.phases.title")}</div>
+175
View File
@@ -0,0 +1,175 @@
// [274] Umbau-Panel, Abschnitt „Sanierung“: Typ-Paare Bestandstyp → Sanierungstyp mit Zählern, „Alle Wände vom Typ
// sanieren“ (ein Undo-Schritt), „Sanierungstyp anlegen …“ (Kopie des Bestandstyps) und der Typ-Paar-Editor: Alt und Neu
// nebeneinander, Zuordnung je Schicht (automatisch oder manuell), Bezugsseite, Ergebnis-Streifen mit SIA-Farben.
// Die Regeln (Zuordnung, Teilstücke) rechnet der Kern (`renovation::build_up`); gespeichert wird am Bestandstyp.
import { useState } from "react";
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { useStore } from "../state/appStore";
import {
createRenovationTypeOps,
renovateAllOfTypeOps,
renovationPair,
renovationPairs,
setTypePairOps,
} from "../core";
import type { LayerRenovation, Project, RenovationSide } from "../model/types";
import { RenovationStrip } from "../ui/RenovationStrip";
import { usePanelHostAction } from "./host";
function PairEditor({ project, typeId }: { project: Project; typeId: string }) {
const applyChange = useStore((s) => s.applyChange);
const openResources = usePanelHostAction("onOpenResources");
const wt = project.wallTypes.find((x) => x.id === typeId);
const pair = renovationPair(project, typeId);
if (!wt || !pair) return null;
const oldOv = wt.renovationOld ?? [];
const newOv = wt.renovationNew ?? [];
const setOv = (which: "old" | "new", i: number, v: LayerRenovation) => {
const n = which === "old" ? wt.layers.length : (project.wallTypes.find((x) => x.id === pair.target)?.layers.length ?? 0);
const cur = [...(which === "old" ? oldOv : newOv)];
while (cur.length < n) cur.push("auto");
cur[i] = v;
applyChange((p) => setTypePairOps(p, typeId, which === "old" ? { old: cur } : { new: cur }));
};
const layerRow = (which: "old" | "new", l: (typeof pair.old)[number], i: number) => {
const ov = (which === "old" ? oldOv : newOv)[i] ?? "auto";
const choices: LayerRenovation[] = which === "old" ? ["auto", "existing", "demolish"] : ["auto", "existing", "new"];
return (
<div className="reno-pair-layer" key={i} data-testid={`reno-pair-${which}-layer`} data-fate={l.fate}>
<span className="reno-swatch" style={{ background: l.color }} aria-hidden="true" />
<span className="reno-pair-name" title={l.name}>
{l.name}
</span>
<span className="reno-pair-cm">{(l.thickness * 100).toFixed(1)}</span>
<select
value={ov}
data-testid={`reno-pair-${which}-fate`}
aria-label={l.name}
className={`reno-fate is-${l.fate}`}
onChange={(e) => setOv(which, i, e.target.value as LayerRenovation)}
>
{choices.map((c) => (
<option key={c} value={c}>
{c === "auto" ? `${t("renovation.fate.auto")} (${t(`renovation.fate.${l.fate}` as TranslationKey)})` : t(`renovation.fate.${c === "existing" ? "kept" : c}` as TranslationKey)}
</option>
))}
</select>
</div>
);
};
return (
<div className="reno-pair-editor" data-testid="reno-pair-editor">
<label className="reno-field">
<span>{t("renovation.panel.sanierung.target")}</span>
<select value={pair.target} data-testid="reno-pair-target" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { target: e.target.value, old: null, new: null }))}>
{project.wallTypes
.filter((x) => x.id !== typeId)
.map((x) => (
<option key={x.id} value={x.id}>
{x.name}
</option>
))}
</select>
</label>
<label className="reno-field">
<span>{t("renovation.panel.sanierung.side")}</span>
<select value={pair.side} data-testid="reno-pair-side" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { side: e.target.value as RenovationSide }))}>
<option value="inside">{t("renovation.panel.sanierung.side.inside")}</option>
<option value="outside">{t("renovation.panel.sanierung.side.outside")}</option>
</select>
</label>
<div className="reno-pair-cols">
<div className="reno-pair-col">
<div className="reno-head sub">{t("renovation.panel.sanierung.oldLayers")}</div>
{pair.old.map((l, i) => layerRow("old", l, i))}
</div>
<div className="reno-pair-col">
<div className="reno-head sub">{t("renovation.panel.sanierung.newLayers")}</div>
{pair.new.map((l, i) => layerRow("new", l, i))}
</div>
</div>
<RenovationStrip pair={pair} width={170} />
<div className="reno-select-by">
<button type="button" className="reno-link-btn" data-testid="reno-pair-reset" onClick={() => applyChange((p) => setTypePairOps(p, typeId, { old: null, new: null }))}>
{t("renovation.panel.sanierung.reset")}
</button>
<button type="button" className="reno-link-btn" onClick={() => openResources("wallStyles")}>
{t("renovation.panel.sanierung.editLayers")}
</button>
<button type="button" className="reno-link-btn" data-testid="reno-pair-remove" onClick={() => applyChange((p) => setTypePairOps(p, typeId, { target: null, old: null, new: null, side: null }))}>
{t("renovation.panel.sanierung.remove")}
</button>
</div>
</div>
);
}
export function RenovationSanierung({ project }: { project: Project }) {
const applyChange = useStore((s) => s.applyChange);
const info = renovationPairs(project);
const [open, setOpen] = useState<string | null>(null);
const targets = new Set(info.pairs.map((x) => x.target));
const candidates = project.wallTypes.filter((x) => !x.renovationTarget && !targets.has(x.id));
const [pick, setPick] = useState("");
const pickId = candidates.some((x) => x.id === pick) ? pick : (candidates[0]?.id ?? "");
return (
<div className="reno-block" data-testid="reno-sanierung">
<div className="reno-head">{t("renovation.panel.sanierung.title")}</div>
<div className="reno-hint" data-testid="reno-sanierung-count">
{t("renovation.panel.sanierung.count", { n: String(info.renovated) })}
</div>
{info.pairs.length === 0 && <div className="reno-hint">{t("renovation.panel.sanierung.empty")}</div>}
{info.pairs.map((pr) => (
<div className="reno-pair" key={pr.type} data-testid="reno-pair">
<div className="reno-pair-title">
<span>{pr.name}</span>
<span aria-hidden="true">→</span>
<span>{pr.targetName ?? pr.target}</span>
</div>
<div className="reno-hint">{t("renovation.panel.sanierung.walls", { r: String(pr.renovated), n: String(pr.walls) })}</div>
<div className="reno-select-by">
<button
type="button"
className="reno-link-btn"
data-testid="reno-pair-renovate-all"
disabled={pr.walls === 0 || pr.renovated === pr.walls}
onClick={() => applyChange((p) => renovateAllOfTypeOps(p, pr.type))}
>
{t("renovation.panel.sanierung.renovateAll")}
</button>
<button type="button" className="reno-link-btn" data-testid="reno-pair-edit" aria-expanded={open === pr.type} onClick={() => setOpen(open === pr.type ? null : pr.type)}>
{t("renovation.panel.sanierung.edit")}
</button>
</div>
{open === pr.type && <PairEditor project={project} typeId={pr.type} />}
</div>
))}
{candidates.length > 0 && (
<div className="reno-field reno-create">
<select value={pickId} aria-label={t("renovation.panel.sanierung.createFor")} data-testid="reno-create-type" onChange={(e) => setPick(e.target.value)}>
{candidates.map((x) => (
<option key={x.id} value={x.id}>
{x.name}
</option>
))}
</select>
<button
type="button"
className="reno-add-btn"
data-testid="reno-create"
onClick={() => {
const src = project.wallTypes.find((x) => x.id === pickId);
if (!src) return;
applyChange((p) => createRenovationTypeOps(p, pickId, t("renovation.panel.sanierung.newName", { name: src.name })).ops);
setOpen(pickId);
}}
>
{t("renovation.panel.sanierung.create")}
</button>
</div>
)}
</div>
);
}
+60 -2
View File
@@ -4,8 +4,9 @@
import { memo } from "react";
import { t } from "../../i18n";
import type { RenovationStatus } from "../../model/types";
import { RENOVATION_STATUSES } from "../../core";
import { useStore } from "../../state/appStore";
import { RENOVATION_STATUSES, commonBuildUp, parseBuildUpKey, renovationPair, setBuildUpOps } from "../../core";
import { getState, useStore } from "../../state/appStore";
import { RenovationStrip } from "../../ui/RenovationStrip";
import { useRenovationSelection } from "../../state/renovationHook";
import { Dropdown } from "../../ui/Dropdown";
@@ -44,6 +45,7 @@ export const RenovationField = memo(function RenovationField() {
width={150}
/>
</div>
<BuildUpField />
{phases.length > 0 && (
<div className="objinfo-field" data-testid="objinfo-renovation-phase">
<span className="objinfo-flabel">{t("renovation.phase")}</span>
@@ -62,3 +64,59 @@ export const RenovationField = memo(function RenovationField() {
</>
);
});
const NO_TYPES: readonly { id: string; name: string; renovationTarget?: string }[] = [];
/**
* [274] „Neuer Aufbau (Sanierung)“ der gewählten Wände: keiner, wie Typ (Sanierungstyp des Wandtyps) oder ein anderer
* Wandtyp (Ausnahme). Mehrfachauswahl in einem Undo-Schritt; bei gemeinsamem Wandtyp der Streifen Alt/Neu/Ergebnis.
*/
const BuildUpField = memo(function BuildUpField() {
const types = useStore((s) => s.project.wallTypes) ?? NO_TYPES;
const applyChange = useStore((s) => s.applyChange);
const wallIds = useStore((s) => s.selection.walls);
// Gemeinsamer Aufbau und gemeinsamer Wandtyp als Text: rendert nur bei echter Änderung neu.
const key = useStore((s) => {
const set = new Set(s.selection.walls);
const ts = new Set(s.project.walls.filter((w) => set.has(w.id)).map((w) => w.wallTypeId));
return JSON.stringify([commonBuildUp(s.project, s.selection.walls), ts.size === 1 ? [...ts][0] : null]);
});
const [common, typeId] = JSON.parse(key) as [string | null, string | null];
if (common === null || wallIds.length === 0) return null;
const own = typeId ? types.find((x) => x.id === typeId) : undefined;
const ownTarget = own?.renovationTarget ? types.find((x) => x.id === own.renovationTarget) : undefined;
const options = [
...(common === "mixed" ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
{ value: "", label: t("renovation.buildUp.none") },
{ value: "type", label: ownTarget ? t("renovation.buildUp.type", { name: ownTarget.name }) : t("renovation.buildUp.typeMissing") },
...types.filter((x) => x.id !== typeId).map((x) => ({ value: `t:${x.id}`, label: t("renovation.buildUp.other", { name: x.name }) })),
];
const value = common === "mixed" ? MIXED : common;
const b = parseBuildUpKey(value === MIXED ? "" : value);
const target = b.kind === "other" ? b.typeId : b.kind === "type" ? ownTarget?.id : undefined;
const pair = typeId && target ? renovationPair(getState().project, typeId, target) : null;
return (
<>
<div className="objinfo-field" data-testid="objinfo-renovation-buildup">
<span className="objinfo-flabel" title={t("renovation.buildUp.hint")}>
{t("renovation.buildUp")}
</span>
<Dropdown
value={value}
onChange={(v) => {
if (v === MIXED) return;
applyChange((p) => setBuildUpOps(p, wallIds, parseBuildUpKey(v)));
}}
options={options}
title={t("renovation.buildUp")}
width={150}
/>
</div>
{pair && (
<div className="objinfo-field reno-strip-field" data-testid="objinfo-renovation-strip">
<RenovationStrip pair={pair} width={140} />
</div>
)}
</>
);
});
+3 -2
View File
@@ -65,8 +65,8 @@ declare global {
planFillColors: () => Record<string, number>;
/** [272] Öffnungs-Ids im Grundriss der aktiven Ebene (alle Klassen, 1:100). */
planOpeningIds: () => string[];
/** [271] Umbau: Filter und Etappe der aktiven Ebene, Zeichen-Status, Status je Wand. */
renovation: () => { filter: string | null; phase: string | null; draw: string; walls: Record<string, string> };
/** [271] Umbau: Filter und Etappe der aktiven Ebene, Zeichen-Status, Status je Wand; [274] neuer Aufbau je Wand („type“ = Sanierungstyp, sonst Typ-Id, leer = keiner). */
renovation: () => { filter: string | null; phase: string | null; draw: string; walls: Record<string, string>; buildUp: Record<string, string> };
/** [272] Varianten: Kombination der aktiven Ebene, Zeichen-Variante, Variante je Element (`set/option`, leer = Hauptmodell), Sätze. */
designOptions: () => { level: Record<string, string>; combination: string | null; combinations: string[]; draw: string | null; elements: Record<string, string>; sets: string[] };
/** [272] Grundriss der aktiven Ebene wie auf dem Bildschirm (mit Bearbeitungsvariante): Wände und grau gezeichnete Wände (ids); dazu derselbe Grundriss für den Druck. */
@@ -230,6 +230,7 @@ export function installTestHooks(): void {
phase: l?.renovationPhase ?? null,
draw: s.drawRenovation.status,
walls: Object.fromEntries(s.project.walls.map((w) => [w.id, w.renovation?.status ?? "existing"])),
buildUp: Object.fromEntries(s.project.walls.map((w) => [w.id, w.renovation?.newTypeId ?? (w.renovation?.renovated ? "type" : "")])),
};
},
context: () =>
+114
View File
@@ -10266,3 +10266,117 @@ body {
.sb-toggle.sb-design-editing .material-symbols-outlined {
font-size: 14px;
}
/* [274] Sanierung je Schicht: Streifen Alt/Neu/Ergebnis, Typ-Paare und Typ-Paar-Editor im Umbau-Panel. */
.reno-strip {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 10px;
color: var(--ink-2);
}
.reno-strip-row {
display: grid;
grid-template-columns: 48px auto 1fr;
align-items: center;
gap: 6px;
}
.reno-strip-label {
font-size: 10px;
}
.reno-strip-bar {
display: inline-flex;
height: 10px;
}
.reno-strip-piece {
display: inline-block;
height: 10px;
box-sizing: border-box;
border: 1px solid rgba(0, 0, 0, 0.5);
border-right-width: 0;
}
.reno-strip-piece:last-child {
border-right-width: 1px;
}
.reno-strip-cm {
font-variant-numeric: tabular-nums;
color: var(--muted);
}
.reno-strip-field {
display: block;
}
.reno-pair {
display: flex;
flex-direction: column;
gap: 3px;
padding: 4px 0;
border-top: 1px solid var(--line, rgba(0, 0, 0, 0.08));
}
.reno-pair-title {
display: flex;
gap: 4px;
font-size: 12px;
font-weight: 600;
}
.reno-pair-editor {
display: flex;
flex-direction: column;
gap: 6px;
padding: 6px;
border-radius: 4px;
background: var(--panel-2, rgba(0, 0, 0, 0.03));
}
.reno-pair-cols {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
}
.reno-pair-col {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.reno-pair-layer {
display: grid;
grid-template-columns: 12px minmax(0, 1fr) auto;
align-items: center;
column-gap: 4px;
font-size: 11px;
}
.reno-pair-layer .reno-swatch {
width: 10px;
height: 10px;
}
.reno-pair-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.reno-pair-cm {
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.reno-pair-layer select {
grid-column: 2 / 4;
font-size: 11px;
min-width: 0;
}
.reno-fate.is-demolish {
box-shadow: inset 3px 0 0 #ffd800;
}
.reno-fate.is-new {
box-shadow: inset 3px 0 0 #e3001b;
}
.reno-fate.is-kept {
box-shadow: inset 3px 0 0 #a6a6a6;
}
.reno-create {
display: flex;
gap: 4px;
align-items: center;
}
.reno-create select {
min-width: 0;
flex: 1 1 auto;
}
+51
View File
@@ -0,0 +1,51 @@
// [274] Vorschau-Streifen einer Sanierung: Alt, Neu und Ergebnis (Umbauplan) mit SIA-Farben, aussen links → innen rechts,
// massstäblich zueinander (gleiche Meter je Pixel). Die Teilstücke rechnet der Kern (`renovationPair`).
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import type { RenovationPair, RenovationStripPiece } from "../core";
function Bar({ pieces, scale, demolishFill }: { pieces: RenovationStripPiece[]; scale: number; demolishFill: string }) {
return (
<span className="reno-strip-bar">
{pieces.map((q, i) => (
<span
key={i}
className={`reno-strip-piece is-${q.kind}`}
data-kind={q.kind}
style={{
width: `${Math.max(1, q.thickness * scale)}px`,
background: q.fill,
// Neu über Abbruch: Abbruch als gestrichelte Kontur über der Neu-Füllung.
outline: q.kind === "newOverDemolish" ? `1px dashed ${demolishFill}` : undefined,
outlineOffset: q.kind === "newOverDemolish" ? "-2px" : undefined,
borderStyle: q.kind === "demolish" ? "dashed" : "solid",
}}
title={`${t(`renovation.fate.${q.kind === "newOverDemolish" ? "new" : q.kind}` as TranslationKey)} ${(q.thickness * 100).toFixed(1)} cm`}
/>
))}
</span>
);
}
/** Streifen Alt/Neu/Ergebnis eines Typ-Paars; `width` = Pixel für den dicksten Aufbau. */
export function RenovationStrip({ pair, width = 150 }: { pair: RenovationPair; width?: number }) {
const sum = (v: RenovationStripPiece[]) => v.reduce((a, q) => a + q.thickness, 0);
const max = Math.max(sum(pair.oldStrip), sum(pair.newStrip), sum(pair.result), 1e-6);
const scale = width / max;
const demolishFill = pair.result.find((q) => q.kind === "demolish")?.fill ?? pair.oldStrip.find((q) => q.kind === "demolish")?.fill ?? "#ffd800";
const row = (label: string, pieces: RenovationStripPiece[], id: string) => (
<div className="reno-strip-row" data-testid={`reno-strip-${id}`}>
<span className="reno-strip-label">{label}</span>
<Bar pieces={pieces} scale={scale} demolishFill={demolishFill} />
<span className="reno-strip-cm">{(sum(pieces) * 100).toFixed(1)} cm</span>
</div>
);
return (
<div className="reno-strip" data-testid="reno-strip">
{row(t("renovation.strip.old"), pair.oldStrip, "old")}
{row(t("renovation.strip.new"), pair.newStrip, "new")}
{row(t("renovation.strip.result"), pair.result, "result")}
</div>
);
}