Files
DOSSIER/src/export/exportView.test.ts
T
Claude e33b840739 [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).
2026-11-17 20:21:52 +00:00

103 lines
5.4 KiB
TypeScript

// [271][272] Ansicht eines Exports: Umbaufilter und Variantenkombination der aktiven Ebene gelten für IFC, OBJ/STL/glTF,
// STEP-Spezifikationen und die Cycles-Szene; ohne Ansicht Hauptvarianten und alles (wie bisher).
import { describe, expect, it } from "vitest";
import "../engine/fileioWasm.setup";
import { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
import { buildVariantenSampleProject } from "../model/sampleProjectVarianten";
import { exportIfcSpf } from "./exportIfc";
import { exportObj } from "./exportMesh";
import { projectSolidSpecs } from "./exportStep";
import { cyclesSceneInfo } from "./cyclesRender";
import { exportViewFields, exportViewLabels, exportViewText, hasExportView, levelExportView } from "./exportView";
import type { Project } from "../model/types";
const count = (text: string, word: string): number => text.split(word).length - 1;
/** Das Projekt mit Umbaufilter an der Ebene „eg“. */
function withFilter(p: Project, filter: string, phase?: string): Project {
return { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter, ...(phase ? { renovationPhase: phase } : {}) } : l)) };
}
describe("Ansicht der Ebene", () => {
it("liest Umbaufilter, Etappe und Kombination der Ebene", () => {
const u = withFilter(buildUmbauSampleProject(), "endzustand", "etappe-1");
expect(levelExportView(u, "eg")).toEqual({ renovation: "endzustand", renovationPhase: "etappe-1" });
expect(levelExportView(u, "gibt-es-nicht")).toEqual({});
expect(levelExportView(u, null)).toEqual({});
const v = buildVariantenSampleProject();
const lv = { ...v, drawingLevels: v.drawingLevels.map((l) => (l.id === "eg" ? { ...l, designOptionCombination: "studie-2" } : l)) };
// Benannte Kombination wird zur vollständigen Wahl aufgelöst.
expect(levelExportView(lv, "eg").designOptions).toEqual({ dachform: "b", fassade: "b" });
expect(hasExportView(levelExportView(lv, "eg"))).toBe(true);
expect(hasExportView(levelExportView(v, "eg"))).toBe(false);
});
it("Text für den Kern: leer ohne Wirkung, sonst JSON; Beschriftung", () => {
expect(exportViewText(undefined)).toBe("");
expect(exportViewText({})).toBe("");
expect(exportViewText({}, { iso: "2026-01-01T00:00:00" })).toBe('{"iso":"2026-01-01T00:00:00"}');
expect(JSON.parse(exportViewText({ renovation: "endzustand", renovationPhase: "e1", designOptions: { a: "b" } }, { iso: "x" }))).toEqual({
iso: "x",
renovation: "endzustand",
renovationPhase: "e1",
designOptions: { a: "b" },
});
expect(exportViewFields(undefined)).toEqual({});
expect(exportViewFields({ renovation: "bestand" })).toEqual({ renovation: "bestand" });
const v = buildVariantenSampleProject();
const labels = exportViewLabels(v, { designOptions: { dachform: "b", fassade: "b" } }, (id) => id);
expect(labels.combination).toBe("Studie 2 Satteldach/Bandfenster");
expect(labels.renovation).toBeNull();
const u = buildUmbauSampleProject();
const first = u.renovation?.phases?.[0];
expect(exportViewLabels(u, { renovation: "endzustand", renovationPhase: first?.id }, () => "Endzustand").renovation).toBe(`Endzustand (${first?.name})`);
});
});
describe("Exporte folgen der Ansicht", () => {
it("IFC: Endzustand ohne Abbruch, andere Kombination andere Bauteile", () => {
const u = buildUmbauSampleProject();
const ganz = exportIfcSpf(u);
const endzustand = exportIfcSpf(u, { view: { renovation: "endzustand" } });
expect(count(endzustand, "IFCWALL(")).toBeLessThan(count(ganz, "IFCWALL("));
// Ohne Ansicht wie bisher (Hauptvarianten, kein Filter).
expect(exportIfcSpf(u, { view: {} }).length).toBe(ganz.length);
const v = buildVariantenSampleProject();
const a = exportIfcSpf(v);
const b = exportIfcSpf(v, { view: { designOptions: { dachform: "b", fassade: "b" } } });
expect(count(a, "IFCROOF(")).not.toBe(count(b, "IFCROOF(") + 1000); // beide lesbar
expect(a).not.toBe(b);
expect(count(b, "IFCWINDOW(")).toBeGreaterThan(0);
});
it("OBJ und STEP-Körper: gleiche Ansicht, gleiche Auswahl", () => {
const u = buildUmbauSampleProject();
const objs = (view?: Parameters<typeof exportObj>[1]) => count(exportObj(u, view), "\no ");
expect(objs({ view: { renovation: "endzustand" } })).toBeLessThan(objs());
const specs = projectSolidSpecs(u).length;
expect(projectSolidSpecs(u, { renovation: "endzustand" }).length).toBeLessThan(specs);
});
it("Cycles-Szene: ohne Ausgeblendetes, Kombination, Umbau-Farben nur auf Wunsch", () => {
const u = buildUmbauSampleProject();
const base = { width: 64, height: 36, samples: 1, context: false };
const alle = cyclesSceneInfo(u, base);
const end = cyclesSceneInfo(u, { ...base, ...exportViewFields({ renovation: "endzustand" }) });
expect(end.triangles).toBeLessThan(alle.triangles);
const plan = { ...base, renovation: "umbauplan" };
expect(cyclesSceneInfo(u, plan).xml).not.toContain("Umbau-");
const farbig = cyclesSceneInfo(u, { ...plan, renovationColors: true });
expect(farbig.xml).toContain("Umbau-e8c35a");
expect(farbig.triangles).toBe(cyclesSceneInfo(u, plan).triangles);
const v = buildVariantenSampleProject();
const a = cyclesSceneInfo(v, base);
const b = cyclesSceneInfo(v, { ...base, designOptions: { dachform: "b", fassade: "b" } });
expect(b.triangles).not.toBe(a.triangles);
});
});