[271][272][215] Exporte und Rendering folgen Umbaufilter und Variantenkombination der Ansicht
Gemeinsame Ansicht export/exportView.ts (Umbaufilter, Etappe, Kombination der aktiven Ebene) als EIN Weg in IFC, OBJ/STL/glTF, STEP, Blender-Paket und Cycles-Szene (Text der Kern-Abfragen, renovation::view_from_text). Cycles-Szene: Ausgeblendetes fehlt, Umbau-Farben nur auf Wunsch (renovationColors, cycles_scene_styled); Explosionsaxonometrie bekommt die Umbau-Farben, Pick/Explosion folgten dem Filter schon. App: Export-Dialog und Rendering-Dialog zeigen die Ansicht und lassen Hauptvarianten/kein Filter wählen; Häkchen Umbau-Farben im Bild. CLI: --renovation/--phase auch für ifc, obj, stl, glb, gltf, step, render, blend; render --engine cycles --renovation-colors. Tests: Kern export_view_tests.rs, vitest exportView/exportViewState/render, e2e exportView271; Bilder doc/review-272/07-09.
This commit is contained in:
32 files changed
+695
-42
No files matched your search
+19
-11
@@ -26,6 +26,8 @@
|
||||
// model3d, kennzahlen, dxf, ifc, obj …); `designoptions` vergleicht die gespeicherten Kombinationen
|
||||
// (--all: alle Kombinationen der Sätze) [272]
|
||||
// --combination "Studie 1" gespeicherte benannte Kombination (Name oder id), für alle Ausgaben [272]
|
||||
// Exporte und Rendering (ifc, obj, stl, glb, gltf, step, render, blend) folgen --renovation/--phase ebenso: Ausgeblendetes fehlt;
|
||||
// render --engine cycles: --renovation-colors malt die Umbau-Farben ins Bild (Vorgabe: Materialfarben) [271]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// --snapshot <Name|id> übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207]
|
||||
// dossier-cli <projekt.obp> axo [--view southeast|southwest|northeast|northwest|iso|…] [--projection iso|military|military30]
|
||||
@@ -150,6 +152,7 @@ import {
|
||||
viewportLevelPlan,
|
||||
generateAxoPlan,
|
||||
renovationFilterList,
|
||||
exportViewFields,
|
||||
parseCombination,
|
||||
designOptionSets,
|
||||
designOptionCombinations,
|
||||
@@ -202,7 +205,7 @@ import {
|
||||
runCyclesRender,
|
||||
CyclesMissingError,
|
||||
} from "../core";
|
||||
import type { BlenderHost, CyclesHost, Filter3d, Project, RenderMode, RenderPackage, RenderViewPreset, TextureLoader, ViewTemplate } from "../core";
|
||||
import type { BlenderHost, CyclesHost, ExportView, Filter3d, Project, RenderMode, RenderPackage, RenderViewPreset, TextureLoader, ViewTemplate } from "../core";
|
||||
import { serveStdio } from "./mcp";
|
||||
import { startBridge } from "./mcpBridge";
|
||||
|
||||
@@ -406,6 +409,11 @@ function renovationFlags(project: Project, args: Args): { renovation: string; re
|
||||
return { renovation: hit.id, renovationPhase: p.id };
|
||||
}
|
||||
|
||||
/** [271][272] Ansicht für Exporte und Rendering aus `--renovation`/`--phase` (die Kombination gilt schon über `--options`/`--combination`); ohne Flag `undefined`. */
|
||||
function exportViewFlags(project: Project, args: Args): ExportView | undefined {
|
||||
return renovationFlags(project, args) ?? undefined;
|
||||
}
|
||||
|
||||
/** `--sketch` ([67]): die Ebene im Skizzenstil (wie `DrawingLevel.sketch`); sonst das Projekt unverändert. */
|
||||
function withSketch(project: Project, levelId: string, args: Args): Project {
|
||||
if (!args.flags.has("sketch")) return project;
|
||||
@@ -881,7 +889,7 @@ async function buildCliPackage(project: Project, args: Args, mode: RenderMode):
|
||||
await loadFileio();
|
||||
const pkg = await buildRenderPackage(
|
||||
project,
|
||||
{ mode, width, height, samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto", backfilled: !args.flags.has("excavation") },
|
||||
{ mode, width, height, samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto", backfilled: !args.flags.has("excavation"), view: exportViewFlags(project, args) },
|
||||
localTextureLoader(),
|
||||
);
|
||||
if (pkg.missingTextures.length > 0) process.stderr.write(`Hinweis: ${pkg.missingTextures.length} Bildkarten nicht lesbar (Material erscheint einfarbig)\n`);
|
||||
@@ -962,7 +970,7 @@ async function runCyclesRenderCli(project: Project, args: Args): Promise<number>
|
||||
if (look !== "filmic" && look !== "standard") return fail("--look: filmic|standard");
|
||||
const pkg = await buildCyclesPackage(
|
||||
project,
|
||||
{ width, height, samples, denoise: !args.flags.has("no-denoise"), whenMs: when.getTime(), camera: choice ? choice.camera : { preset: view }, backfilled: !args.flags.has("excavation"), context: !args.flags.has("no-context"), exposureEv },
|
||||
{ width, height, samples, denoise: !args.flags.has("no-denoise"), whenMs: when.getTime(), camera: choice ? choice.camera : { preset: view }, backfilled: !args.flags.has("excavation"), context: !args.flags.has("no-context"), exposureEv, ...exportViewFields(exportViewFlags(project, args)), ...(args.flags.has("renovation-colors") ? { renovationColors: true } : {}) },
|
||||
localTextureLoader(),
|
||||
);
|
||||
if (pkg.info.meshes === 0) return fail("render: Das Modell enthält keine 3D-Geometrie");
|
||||
@@ -1305,7 +1313,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
case "ifc":
|
||||
await loadFileio();
|
||||
// --ebkph: eBKP-H-Hauptgruppen je Bauteilart; --ebenen: Ebene (categoryCode) des Modells als Klassifikation.
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen"), context: args.flags.has("kontext"), schema: ifcSchemaFlag(args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen"), context: args.flags.has("kontext"), schema: ifcSchemaFlag(args), view: exportViewFlags(project, args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
return 0;
|
||||
case "obj":
|
||||
await loadFileio();
|
||||
@@ -1314,26 +1322,26 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
{
|
||||
const target = args.flags.get("out") ?? `${exportProjectName(project) || "projekt"}.obj`;
|
||||
if (target === "-" || args.flags.has("no-mtl")) {
|
||||
out(args, exportObj(project), `${exportProjectName(project) || "projekt"}.obj`);
|
||||
out(args, exportObj(project, { view: exportViewFlags(project, args) }), `${exportProjectName(project) || "projekt"}.obj`);
|
||||
} else {
|
||||
const mtlPath = target.replace(/\.obj$/i, "") + ".mtl";
|
||||
out(args, exportObj(project, {}, basename(mtlPath)), target);
|
||||
writeFileSync(mtlPath, exportMtl(project));
|
||||
out(args, exportObj(project, { view: exportViewFlags(project, args) }, basename(mtlPath)), target);
|
||||
writeFileSync(mtlPath, exportMtl(project, { view: exportViewFlags(project, args) }));
|
||||
process.stderr.write(`geschrieben: ${mtlPath}\n`);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case "stl":
|
||||
await loadFileio();
|
||||
out(args, exportStl(project), `${exportProjectName(project) || "projekt"}.stl`);
|
||||
out(args, exportStl(project, { view: exportViewFlags(project, args) }), `${exportProjectName(project) || "projekt"}.stl`);
|
||||
return 0;
|
||||
case "glb":
|
||||
await loadFileio();
|
||||
out(args, exportGlb(project, { byLevel: !args.flags.has("flat") }), `${exportProjectName(project) || "projekt"}.glb`);
|
||||
out(args, exportGlb(project, { byLevel: !args.flags.has("flat"), view: exportViewFlags(project, args) }), `${exportProjectName(project) || "projekt"}.glb`);
|
||||
return 0;
|
||||
case "gltf":
|
||||
await loadFileio();
|
||||
out(args, exportGltf(project, { byLevel: !args.flags.has("flat") }), `${exportProjectName(project) || "projekt"}.gltf`);
|
||||
out(args, exportGltf(project, { byLevel: !args.flags.has("flat"), view: exportViewFlags(project, args) }), `${exportProjectName(project) || "projekt"}.gltf`);
|
||||
return 0;
|
||||
case "kennzahlen": {
|
||||
// --sia416 / --ivhb: Flächentabelle bzw. IVHB-Kennziffern [70]; --format json|csv|svg|pdf (Default json).
|
||||
@@ -1488,7 +1496,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
return 0;
|
||||
}
|
||||
case "step": {
|
||||
const r = await exportProjectStep(project, project.name || "projekt");
|
||||
const r = await exportProjectStep(project, project.name || "projekt", exportViewFlags(project, args));
|
||||
if (r.skipped.length) process.stderr.write(`${r.skipped.length} Körper übersprungen/ungeschnitten.\n`);
|
||||
out(args, r.text, `${exportProjectName(project) || "projekt"}.stp`);
|
||||
return 0;
|
||||
|
||||
@@ -240,6 +240,30 @@ echo "Finished Rendering."
|
||||
expect(xml).toContain("textures/");
|
||||
}, 120_000);
|
||||
|
||||
// [271][272] Die Szene folgt `--renovation`/`--phase`/`--options`/`--combination`; Umbau-Farben nur mit `--renovation-colors`.
|
||||
it("Szene ohne Ausgeblendetes, Kombination und Umbau-Farben auf Wunsch", async () => {
|
||||
const sceneXml = () => readFileSync(join(dir, "fake-cycles-scene.xml"), "utf8");
|
||||
const meshes = (xml: string) => (xml.match(/<mesh /g) ?? []).length;
|
||||
const base = (extra: string[]) => run([":umbau", "render", "--engine", "cycles", "--cycles", fakeCycles, "--out", join(dir, "ren.png"), "--samples", "8", "--size", "8x4", "--no-context", ...extra]);
|
||||
expect((await quiet(() => base([]))).result).toBe(0);
|
||||
const ganz = sceneXml();
|
||||
expect((await quiet(() => base(["--renovation", "bestand"]))).result).toBe(0);
|
||||
const bestand = sceneXml();
|
||||
expect(meshes(bestand)).toBeLessThan(meshes(ganz));
|
||||
expect(bestand).not.toContain("Umbau-");
|
||||
expect((await quiet(() => base(["--renovation", "umbauplan"]))).result).toBe(0);
|
||||
expect(sceneXml()).not.toContain("Umbau-");
|
||||
expect((await quiet(() => base(["--renovation", "umbauplan", "--renovation-colors"]))).result).toBe(0);
|
||||
expect(sceneXml()).toContain("Umbau-ffd800");
|
||||
const vb = (extra: string[]) => run([":varianten", "render", "--engine", "cycles", "--cycles", fakeCycles, "--out", join(dir, "var.png"), "--samples", "8", "--size", "8x4", "--no-context", ...extra]);
|
||||
expect((await quiet(() => vb([]))).result).toBe(0);
|
||||
const studie1 = sceneXml();
|
||||
expect((await quiet(() => vb(["--combination", "Studie 2 Satteldach/Bandfenster"]))).result).toBe(0);
|
||||
expect(sceneXml()).not.toBe(studie1);
|
||||
expect((await quiet(() => vb(["--options", "Dachform=B"]))).result).toBe(0);
|
||||
expect(sceneXml()).not.toBe(studie1);
|
||||
}, 240_000);
|
||||
|
||||
it("Programm aus DOSSIER_CYCLES; fehlt es: Hinweis und Exit-Code 3", async () => {
|
||||
const png = join(dir, "cy2.png");
|
||||
const old = process.env.DOSSIER_CYCLES;
|
||||
@@ -303,4 +327,21 @@ describe.skipIf(!realCycles || !existsSync(realCycles))("dossier-cli render --en
|
||||
expect(sum / (raw.length - 180)).toBeGreaterThan(40);
|
||||
expect(max - min).toBeGreaterThan(80);
|
||||
}, 240_000);
|
||||
|
||||
// [271][272] Ansicht: Umbau „Endzustand“ und Variantenkombination „Studie 2“ rendern (klein, 4 Samples).
|
||||
it(":umbau im Endzustand und :varianten Studie 2 geben ein PNG", async () => {
|
||||
const err = vi.spyOn(process.stderr, "write").mockImplementation(() => true);
|
||||
try {
|
||||
for (const [name, extra] of [
|
||||
[":umbau", ["--renovation", "endzustand"]],
|
||||
[":varianten", ["--combination", "Studie 2 Satteldach/Bandfenster"]],
|
||||
] as const) {
|
||||
const png = join(dir, `echt-${name.slice(1)}.png`);
|
||||
expect(await run([name, "render", "--engine", "cycles", "--out", png, "--samples", "4", "--size", "160x90", "--cpu", ...extra])).toBe(0);
|
||||
expect(Array.from(readFileSync(png).subarray(1, 4))).toEqual([80, 78, 71]);
|
||||
}
|
||||
} finally {
|
||||
err.mockRestore();
|
||||
}
|
||||
}, 360_000);
|
||||
});
|
||||
@@ -15,6 +15,9 @@ export { projectToWorldCoords } from "../model/geoRebase";
|
||||
export { exportScheduleCsv } from "../export/exportSchedule";
|
||||
export { exportObj, exportMtl, exportStl, exportGlb, exportGltf } from "../export/exportMesh";
|
||||
export { exportProjectStep } from "../export/exportStep";
|
||||
// [271][272] Ansicht eines Exports/Renderings (Umbaufilter, Etappe, Variantenkombination der aktiven Ebene).
|
||||
export { levelExportView, hasExportView, exportViewText, exportViewFields, exportViewLabels } from "../export/exportView";
|
||||
export type { ExportView } from "../export/exportView";
|
||||
export { planToSvgString } from "../export/planToSvgString";
|
||||
export { setWasmBytesProvider } from "../engine/wasmSource";
|
||||
export { initCore } from "../engine/coreWasm";
|
||||
|
||||
@@ -24,6 +24,7 @@ import type { Camera, ComponentMaterial, LayoutOrientation, LayoutPaperFormat, P
|
||||
import { projectLatLon, sunPosition } from "../analysis/sun";
|
||||
import { sheetSizeMm } from "../model/layoutModel";
|
||||
import { exportGlb } from "./exportMesh";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { TERRAIN_GRASS_MATERIAL, terrainComponentMaterial, terrainMeshes } from "../materials/terrainMaterial";
|
||||
|
||||
/** Kamera in Modell-Koordinaten (gleiche Form wie `ViewCamera` der 3D-Ansicht, `viewport/cameraBridge.ts`). */
|
||||
@@ -100,6 +101,8 @@ export interface RenderOptions {
|
||||
* die 3D-Ansicht im Modell bleibt unberührt (Klasse „07 Baugrube").
|
||||
*/
|
||||
backfilled?: boolean;
|
||||
/** [271][272] Ansicht der Szene: Umbaufilter und Variantenkombination (Ausgeblendetes fehlt; ohne Angabe Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** Eintrag der Materialtabelle in `scene.json`. */
|
||||
@@ -361,7 +364,7 @@ function componentMaterials(project: Project): Map<string, ComponentMaterial> {
|
||||
* Kamera, Sonne. Verlangt das geladene Format-Modul (`await loadFileio()`) und den Kern.
|
||||
*/
|
||||
export async function buildRenderPackage(project: Project, opts: RenderOptions, loadTexture?: TextureLoader): Promise<RenderPackage> {
|
||||
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true }), project);
|
||||
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true, view: opts.view }), project);
|
||||
const files: RenderPackage["files"] = [{ path: "model.glb", bytes: glb }];
|
||||
const materials = glbMaterials(glb);
|
||||
const comp = componentMaterials(project);
|
||||
|
||||
@@ -37,6 +37,12 @@ export interface CyclesSceneOptions {
|
||||
ground?: boolean;
|
||||
/** Bild-URLs, die geladen werden können (`undefined` = alle). */
|
||||
textures?: string[];
|
||||
/** [271][272] Umbaufilter und Variantenkombination der Ansicht (Ausgeblendetes fehlt; ohne Angabe Hauptvarianten). */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
designOptions?: Record<string, string>;
|
||||
/** [271] Umbau-Farben im Bild (nur mit Filter, der Farben vorsieht; Standard: Materialfarben). */
|
||||
renovationColors?: boolean;
|
||||
}
|
||||
|
||||
/** Antwort des Kerns. */
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { fileio } from "../engine/fileioWasm";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
/** IFC-Schema der Ausgabe: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0, TC1). */
|
||||
@@ -34,6 +36,8 @@ export interface IfcExportOptions {
|
||||
* (IfcBuildingElementProxy „Kontext"), am IfcSite. Ohne Angabe nicht: Fachplaner wollen meist nur das Gebäude.
|
||||
*/
|
||||
context?: boolean;
|
||||
/** [271][272] Ansicht der Ausgabe: Umbaufilter und Variantenkombination (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export::ifc_guid`). */
|
||||
@@ -79,7 +83,7 @@ export function exportIfcSpf(project: Project, options: IfcExportOptions = {}):
|
||||
const now = Date.now();
|
||||
const iso = new Date(now).toISOString().replace(/\.\d+Z$/, "");
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0, options.context ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, iso));
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, exportViewText(options.view, { iso })));
|
||||
const m = fileio();
|
||||
const text = m.export_ifc_flat(buf, strings);
|
||||
if (text.length === 0) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import type { Project } from "../model/types";
|
||||
import { fileio } from "../engine/fileioWasm";
|
||||
import { documentFor } from "../core/document";
|
||||
import { decodeExportFlat } from "./exportIfc";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
|
||||
/** Was in die Szene kommt. Alles standardmässig an (vollständiges 3D-Modell). */
|
||||
export interface MeshOptions {
|
||||
@@ -21,12 +23,14 @@ export interface MeshOptions {
|
||||
context?: boolean;
|
||||
/** [227] Baugruben weglassen: Gelände ohne Aushub (hinterfüllt, bis an die Fassade geschlossen). Standard: nein. */
|
||||
backfilled?: boolean;
|
||||
/** [271][272] Ansicht der Ausgabe: Umbaufilter und Variantenkombination (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** Ruft eine Rust-Bindung; leeres Ergebnis (kaputter Puffer) wird zum Fehler mit dem Grund. */
|
||||
function write<T extends string | Uint8Array>(project: Project, opts: MeshOptions, byLevel: boolean, run: (m: ReturnType<typeof fileio>, buf: Float64Array, strings: string) => T): T {
|
||||
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0, opts.backfilled ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args));
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args, exportViewText(opts.view)));
|
||||
const m = fileio();
|
||||
const out = run(m, buf, strings);
|
||||
if (out.length === 0) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import { exportProjectName, isAnonymous, neutralizeStepText } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
import { documentFor } from "../core/document";
|
||||
import { exportStepSolids } from "../engine/truckSolid";
|
||||
import type { SolidSpec } from "../engine/truckSolid";
|
||||
@@ -28,8 +30,8 @@ export { wallProfile, wallSpec } from "../plan/wallSpec";
|
||||
const VOID_FALLBACK = new WeakMap<SolidSpec, SolidSpec>();
|
||||
|
||||
/** Alle Bauteile des Projekts als B-Rep-Spezifikationen (Rust-Kern, `solid_specs.rs::project_solid_specs`; kein truck-WASM). */
|
||||
export function projectSolidSpecs(project: Project): SolidSpec[] {
|
||||
const r = documentFor(project).query<{ specs: SolidSpec[]; fallbacks: [number, SolidSpec][] }>("projectSolidSpecs", []);
|
||||
export function projectSolidSpecs(project: Project, view?: ExportView): SolidSpec[] {
|
||||
const r = documentFor(project).query<{ specs: SolidSpec[]; fallbacks: [number, SolidSpec][] }>("projectSolidSpecs", [], exportViewText(view));
|
||||
for (const [i, base] of r.fallbacks) VOID_FALLBACK.set(r.specs[i], base);
|
||||
return r.specs;
|
||||
}
|
||||
@@ -47,8 +49,9 @@ export interface StepExportResult {
|
||||
* Exportiert das Projekt als STEP-Text. Körper, die truck nicht bauen kann (entartete
|
||||
* Profile …), werden einzeln übersprungen statt den ganzen Export zu verwerfen.
|
||||
*/
|
||||
export async function exportProjectStep(project: Project, fileName = ""): Promise<StepExportResult> {
|
||||
const specs = projectSolidSpecs(project);
|
||||
/** [271][272] `view`: Umbaufilter und Variantenkombination der Ansicht (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
export async function exportProjectStep(project: Project, fileName = "", view?: ExportView): Promise<StepExportResult> {
|
||||
const specs = projectSolidSpecs(project, view);
|
||||
const good: SolidSpec[] = [];
|
||||
const skipped: StepExportResult["skipped"] = [];
|
||||
// Erst alle zusammen versuchen (Normalfall); nur bei Fehler einzeln prüfen.
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// [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-ffd800");
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
// [271][272] Ansicht eines Exports: Umbaufilter, Etappe und Variantenkombination, die ein Export bzw. Rendering übernimmt.
|
||||
// EIN Ort für IFC, glTF/OBJ/STL, Blender-Paket und Cycles-Szene — der Kern wertet sie über den Text der Abfrage aus
|
||||
// (`renovation::view_from_text`: `{"renovation", "renovationPhase", "designOptions"}`; ohne Angabe Hauptvarianten, kein Filter).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { combinationLabel, combinationNameFor, combinationSuffix, resolveCombination, storedChoice } from "../model/designOptions";
|
||||
|
||||
export interface ExportView {
|
||||
/** Umbaufilter (Id oder Name; eingebaut `bestand`, `abbruch`, `neubau`, `umbauplan`, `endzustand`). */
|
||||
renovation?: string;
|
||||
/** Etappe („bis n“). */
|
||||
renovationPhase?: string;
|
||||
/** Variantenkombination (Satz-Id → Varianten-Id); fehlende Sätze gelten als Hauptvariante. */
|
||||
designOptions?: Record<string, string>;
|
||||
}
|
||||
|
||||
/** Ansicht der Ebene `levelId` (Umbaufilter und Kombination, wie sie das 3D-Fenster dieser Ebene zeigt); ohne Ebene leer. */
|
||||
export function levelExportView(project: Project, levelId: string | null | undefined): ExportView {
|
||||
const level = project.drawingLevels.find((l) => l.id === levelId);
|
||||
if (!level) return {};
|
||||
const view: ExportView = {};
|
||||
if (level.renovationFilter) {
|
||||
view.renovation = level.renovationFilter;
|
||||
if (level.renovationPhase) view.renovationPhase = level.renovationPhase;
|
||||
}
|
||||
const choice = storedChoice(project, level);
|
||||
if (choice && Object.keys(choice).length > 0) view.designOptions = { ...choice };
|
||||
return view;
|
||||
}
|
||||
|
||||
/** Wirkt die Ansicht (Filter oder gewählte Kombination)? */
|
||||
export function hasExportView(view: ExportView | null | undefined): boolean {
|
||||
return !!view && (!!view.renovation || !!view.designOptions);
|
||||
}
|
||||
|
||||
/** Der Text der Kern-Abfragen (JSON); leer, wenn die Ansicht nichts ändert. `extra` kommt dazu (z. B. `iso` beim IFC). */
|
||||
export function exportViewText(view: ExportView | null | undefined, extra: Record<string, unknown> = {}): string {
|
||||
const body: Record<string, unknown> = { ...extra };
|
||||
if (view?.renovation) {
|
||||
body.renovation = view.renovation;
|
||||
if (view.renovationPhase) body.renovationPhase = view.renovationPhase;
|
||||
}
|
||||
if (view?.designOptions && Object.keys(view.designOptions).length > 0) body.designOptions = view.designOptions;
|
||||
return Object.keys(body).length > 0 ? JSON.stringify(body) : "";
|
||||
}
|
||||
|
||||
/** Felder einer Ansicht für die Optionen der Cycles-Szene (JSON an den Kern). */
|
||||
export function exportViewFields(view: ExportView | null | undefined): Record<string, unknown> {
|
||||
const text = exportViewText(view);
|
||||
return text ? (JSON.parse(text) as Record<string, unknown>) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Lesbare Fassung für Dialoge: Filter-Anzeigename (über `filterName`, mit Etappe) und Kombination (Name einer gespeicherten
|
||||
* Kombination, sonst „Satz Variante, …“ der Abweichungen von der Hauptvariante); `null` = nicht gesetzt.
|
||||
*/
|
||||
export function exportViewLabels(project: Project, view: ExportView, filterName: (id: string) => string): { renovation: string | null; combination: string | null } {
|
||||
const phase = view.renovationPhase ? (project.renovation?.phases?.find((p) => p.id === view.renovationPhase)?.name ?? view.renovationPhase) : "";
|
||||
const full = view.designOptions ? resolveCombination(project, view.designOptions) : null;
|
||||
return {
|
||||
renovation: view.renovation ? filterName(view.renovation) + (phase ? ` (${phase})` : "") : null,
|
||||
combination: full ? (combinationNameFor(project, full) ?? (combinationSuffix(project, full) || combinationLabel(project, full))) || null : null,
|
||||
};
|
||||
}
|
||||
@@ -2913,6 +2913,12 @@ export const de = {
|
||||
"exportSave.fmt.glb": "glTF 2.0 (GLB, 3D-Modell)",
|
||||
"mesh.export.failed": "Mesh-Export fehlgeschlagen",
|
||||
"exportSave.fmt.step": "STEP (B-Rep, truck)",
|
||||
"exportSave.view": "Ansicht",
|
||||
"exportSave.view.use": "Umbaufilter und Variante der aktiven Ansicht übernehmen",
|
||||
"exportSave.view.renovation": "Umbau: {name}",
|
||||
"exportSave.view.combination": "Variante: {name}",
|
||||
"exportSave.view.off": "Alle Elemente, Hauptvarianten (ohne Umbaufilter).",
|
||||
"exportSave.view.none": "Alle Elemente, Hauptvarianten: die aktive Ansicht hat weder Umbaufilter noch gewählte Variantenkombination.",
|
||||
"step.export.failed": "STEP-Export fehlgeschlagen",
|
||||
"ifc.export.failed": "IFC-Export fehlgeschlagen",
|
||||
"step.export.skipped": "{n} Körper konnten nicht exportiert werden",
|
||||
@@ -4141,6 +4147,14 @@ export const de = {
|
||||
"render.quality.final": "Final (1536 Samples)",
|
||||
"render.backfilled": "Baugrube ausblenden (hinterfüllt)",
|
||||
"render.backfilled.hint": "Das Gelände im Bild ist ohne Aushub gerechnet und reicht bis an die Fassade. Das 3D im Modell bleibt unverändert (Klasse «07 Baugrube»).",
|
||||
"render.view": "Ansicht",
|
||||
"render.view.use": "Umbaufilter und Variante der aktiven Ansicht übernehmen",
|
||||
"render.view.none": "Alle Elemente, Hauptvarianten: die aktive Ansicht hat weder Umbaufilter noch gewählte Variantenkombination.",
|
||||
"render.view.off": "Alle Elemente, Hauptvarianten (ohne Umbaufilter).",
|
||||
"render.view.renovation": "Umbau: {name}",
|
||||
"render.view.combination": "Variante: {name}",
|
||||
"render.view.colors": "Umbau-Farben im Bild",
|
||||
"render.view.colorsHint": "Bestand grau, Abbruch gelb, Neu rot (SIA 400). Vorgabe aus: Materialfarben. Wirkt nur mit einem Umbaufilter, der Farben vorsieht (z. B. Umbauplan), und nur beim eingebauten Cycles.",
|
||||
"render.time": "Datum und Uhrzeit der Sonne",
|
||||
"render.sun": "Sonne: Azimut {az}°, Höhe {el}°",
|
||||
"render.sun.night": "Die Sonne steht dann unter dem Horizont; gerendert wird bei Dämmerung (Sonnenhöhe 1°).",
|
||||
|
||||
@@ -2861,6 +2861,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"file.exportObj": "Export OBJ (3D mesh)",
|
||||
"file.exportStl": "Export STL (3D mesh)",
|
||||
"exportSave.fmt.step": "STEP (B-rep, truck)",
|
||||
"exportSave.view": "View",
|
||||
"exportSave.view.use": "Apply the renovation filter and option of the active view",
|
||||
"exportSave.view.renovation": "Renovation: {name}",
|
||||
"exportSave.view.combination": "Option: {name}",
|
||||
"exportSave.view.off": "All elements, primary options (no renovation filter).",
|
||||
"exportSave.view.none": "All elements, primary options: the active view has neither a renovation filter nor a chosen option combination.",
|
||||
"step.export.failed": "STEP export failed",
|
||||
"ifc.export.failed": "IFC export failed",
|
||||
"step.export.skipped": "{n} solids could not be exported",
|
||||
@@ -4127,6 +4133,14 @@ export const en: Record<TranslationKey, string> = {
|
||||
"render.quality.final": "Final (1536 samples)",
|
||||
"render.backfilled": "Hide excavation (backfilled)",
|
||||
"render.backfilled.hint": "The terrain in the image is computed without the excavation and reaches the facade. The 3D model itself is unchanged (class \"07 Baugrube\").",
|
||||
"render.view": "View",
|
||||
"render.view.use": "Apply the renovation filter and option of the active view",
|
||||
"render.view.none": "All elements, primary options: the active view has neither a renovation filter nor a chosen option combination.",
|
||||
"render.view.off": "All elements, primary options (no renovation filter).",
|
||||
"render.view.renovation": "Renovation: {name}",
|
||||
"render.view.combination": "Option: {name}",
|
||||
"render.view.colors": "Renovation colors in the image",
|
||||
"render.view.colorsHint": "Existing grey, demolition yellow, new red (SIA 400). Default off: material colors. Only effective with a renovation filter that uses colors (e.g. Renovation plan), and only with the built-in Cycles.",
|
||||
"render.time": "Date and time of the sun",
|
||||
"render.sun": "Sun: azimuth {az}°, elevation {el}°",
|
||||
"render.sun.night": "The sun is below the horizon then; the image is rendered at twilight (sun elevation 1°).",
|
||||
|
||||
@@ -12,7 +12,9 @@ import {
|
||||
type Codec,
|
||||
type CyclesPackage,
|
||||
type CyclesSceneOptions,
|
||||
type ExportView,
|
||||
type RenderCameraSpec,
|
||||
exportViewFields,
|
||||
} from "../core";
|
||||
import type { Project } from "../model/types";
|
||||
import { pakoCodec } from "../export/zlibCodec";
|
||||
@@ -108,6 +110,10 @@ export interface CyclesRequest {
|
||||
exposureEv?: number;
|
||||
/** Belichtungskorrektur in EV beim Tonwert, auf die automatische Belichtung (0 = keine). */
|
||||
extraEv?: number;
|
||||
/** [271][272] Ansicht der Szene (Umbaufilter, Etappe, Variantenkombination); fehlt sie, gilt kein Filter und die Hauptvarianten. */
|
||||
view?: ExportView;
|
||||
/** [271] Umbau-Farben im Bild (Vorgabe aus: Materialfarben). */
|
||||
renovationColors?: boolean;
|
||||
}
|
||||
|
||||
export interface CyclesHooks {
|
||||
@@ -181,6 +187,8 @@ export async function renderWithCycles(project: Project, req: CyclesRequest, hoo
|
||||
backfilled: req.backfilled,
|
||||
context: req.context,
|
||||
exposureEv: req.exposureEv,
|
||||
...exportViewFields(req.view),
|
||||
...(req.renovationColors ? { renovationColors: true } : {}),
|
||||
});
|
||||
if (pkg.info.meshes === 0) throw new CyclesRenderError("empty", 0, "");
|
||||
if (pkg.missingTextures.length > 0) hooks.onMissingTextures?.(pkg.missingTextures.length);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// [271][272] Ansicht für Export-/Rendering-Dialog: Umbaufilter (mit Anzeigename) und Variantenkombination der aktiven Ebene.
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { getState, setState } from "./appStore";
|
||||
import { activeExportView } from "./exportViewState";
|
||||
import { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
import { buildVariantenSampleProject } from "../model/sampleProjectVarianten";
|
||||
import { hasExportView } from "../core";
|
||||
|
||||
beforeEach(() => {
|
||||
setState({ project: buildVariantenSampleProject(), activeLevelId: "eg" });
|
||||
});
|
||||
|
||||
describe("activeExportView", () => {
|
||||
it("ohne Filter und Wahl: leer, die Dialoge zeigen Hauptvarianten", () => {
|
||||
const v = activeExportView();
|
||||
expect(hasExportView(v.view)).toBe(false);
|
||||
expect(v.labels).toEqual({ renovation: null, combination: null });
|
||||
});
|
||||
|
||||
it("Kombination der aktiven Ebene mit Namen", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
setState({ project: { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, designOptionCombination: "studie-2" } : l)) } });
|
||||
const v = activeExportView();
|
||||
expect(v.view.designOptions).toEqual({ dachform: "b", fassade: "b" });
|
||||
expect(v.labels.combination).toBe("Studie 2 Satteldach/Bandfenster");
|
||||
// Andere Ebene: eigene Ansicht (hier ohne Wahl).
|
||||
getState().setActiveLevelId("og");
|
||||
expect(hasExportView(activeExportView().view)).toBe(false);
|
||||
});
|
||||
|
||||
it("Umbaufilter der aktiven Ebene mit Anzeigename und Etappe", () => {
|
||||
const p = buildUmbauSampleProject();
|
||||
const phase = p.renovation?.phases?.[0];
|
||||
setState({ project: { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: "endzustand", renovationPhase: phase?.id } : l)) } });
|
||||
const v = activeExportView();
|
||||
expect(v.view).toEqual({ renovation: "endzustand", renovationPhase: phase?.id });
|
||||
expect(v.labels.renovation).toContain("Endzustand");
|
||||
expect(v.labels.renovation).toContain(phase!.name);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
// [271][272] Ansicht für Exporte und Rendering aus dem Zustand der App: Umbaufilter, Etappe und Variantenkombination der
|
||||
// aktiven Ebene (wie das 3D-Fenster sie zeigt), dazu die lesbare Fassung für Dialoge. Die Rechnung selbst: `export/exportView.ts`.
|
||||
|
||||
import { exportViewLabels, levelExportView, type ExportView } from "../core";
|
||||
import { getState } from "./appStore";
|
||||
import { renovationFilterLabel } from "./renovationHook";
|
||||
|
||||
export interface ActiveExportView {
|
||||
view: ExportView;
|
||||
labels: { renovation: string | null; combination: string | null };
|
||||
}
|
||||
|
||||
/** Ansicht der aktiven Ebene (`activeLevelId`) des aktuellen Projekts. */
|
||||
export function activeExportView(): ActiveExportView {
|
||||
const st = getState();
|
||||
const view = levelExportView(st.project, st.activeLevelId);
|
||||
const own = st.project.renovation?.filters ?? [];
|
||||
return { view, labels: exportViewLabels(st.project, view, (id) => renovationFilterLabel(id, own)) };
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import { exportProjectName } from "../export/competitionIdentity";
|
||||
import { confirmAnonymousExport, setAnonymityProjectFileName } from "./anonymityGate";
|
||||
import { exportScheduleCsv } from "../export/exportSchedule";
|
||||
import { exportIfcSpf, type IfcExportOptions } from "../export/exportIfc";
|
||||
import type { ExportView } from "../export/exportView";
|
||||
import { loadFileio } from "../engine/fileioWasm";
|
||||
import { exportProjectStep } from "../export/exportStep";
|
||||
import { exportGlb, exportMtl, exportObj, exportStl } from "../export/exportMesh";
|
||||
@@ -749,13 +750,14 @@ export function useProjectFileActions(
|
||||
// Führt den gewählten Direkt-Export (CSV/IFC/OBJ/STL) mit dem im Dialog
|
||||
// gewählten Dateinamen aus. Erzeugung aus dem jeweiligen reinen Kern, Download
|
||||
// über den robusten Helfer.
|
||||
const runExport = (format: ExportSaveFormat, filename: string, ifcOptions?: IfcExportOptions) => {
|
||||
const runExport = (format: ExportSaveFormat, filename: string, ifcOptions?: IfcExportOptions, view?: ExportView) => {
|
||||
// [208] Anonyme Abgabe: Freitext vorher prüfen (Dialog), erst dann schreiben.
|
||||
void confirmAnonymousExport(getState().project, [filename]).then((ok) => {
|
||||
if (ok) runExportChecked(format, filename, ifcOptions);
|
||||
if (ok) runExportChecked(format, filename, ifcOptions, view);
|
||||
});
|
||||
};
|
||||
const runExportChecked = (format: ExportSaveFormat, filename: string, ifcOptions?: IfcExportOptions) => {
|
||||
// [271][272] `view`: Umbaufilter und Variantenkombination der aktiven Ansicht (3D-Formate); fehlt sie, gelten Hauptvarianten und alles.
|
||||
const runExportChecked = (format: ExportSaveFormat, filename: string, ifcOptions?: IfcExportOptions, view?: ExportView) => {
|
||||
const project = getState().project;
|
||||
switch (format) {
|
||||
case "csv":
|
||||
@@ -764,7 +766,7 @@ export function useProjectFileActions(
|
||||
case "ifc":
|
||||
// IFC schreibt Rust (Format-Modul pkgFileIo, wird beim ersten Export nachgeladen).
|
||||
void loadFileio()
|
||||
.then(() => downloadTextFile(exportIfcSpf(project, ifcOptions), filename))
|
||||
.then(() => downloadTextFile(exportIfcSpf(project, { ...ifcOptions, view }), filename))
|
||||
.catch((e) => notify(`${t("ifc.export.failed")}: ${e instanceof Error ? e.message : String(e)}`, "error"));
|
||||
break;
|
||||
case "obj":
|
||||
@@ -773,17 +775,17 @@ export function useProjectFileActions(
|
||||
// OBJ/STL/glTF schreibt Rust (Format-Modul pkgFileIo, wird beim ersten Export nachgeladen).
|
||||
void loadFileio()
|
||||
.then(() => {
|
||||
if (format === "glb") void saveBinaryFile(exportGlb(project), filename, "model/gltf-binary");
|
||||
if (format === "glb") void saveBinaryFile(exportGlb(project, { view }), filename, "model/gltf-binary");
|
||||
// [201] OBJ mit MTL (Farben) als zweite Datei gleichen Namens; STL kennt keine Farben.
|
||||
else if (format === "obj") void saveTextWithCompanion((mtlName) => ({ main: exportObj(project, {}, mtlName), companion: exportMtl(project) }), filename, "mtl");
|
||||
else downloadTextFile(exportStl(project), filename);
|
||||
else if (format === "obj") void saveTextWithCompanion((mtlName) => ({ main: exportObj(project, { view }, mtlName), companion: exportMtl(project, { view }) }), filename, "mtl");
|
||||
else downloadTextFile(exportStl(project, { view }), filename);
|
||||
})
|
||||
.catch((e) => notify(`${t("mesh.export.failed")}: ${e instanceof Error ? e.message : String(e)}`, "error"));
|
||||
break;
|
||||
case "step":
|
||||
// B-Rep via truck-WASM (asynchron): Körper, die truck nicht bauen kann, werden
|
||||
// übersprungen — der Export bleibt trotzdem erhalten, Hinweis per Meldung.
|
||||
void exportProjectStep(project, filename.replace(/\.[^.]+$/, ""))
|
||||
void exportProjectStep(project, filename.replace(/\.[^.]+$/, ""), view)
|
||||
.then((r) => {
|
||||
downloadTextFile(r.text, filename);
|
||||
if (r.skipped.length > 0) {
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
// Raumstempel-Editor und der Drop-Rahmen — in derselben Reihenfolge wie zuvor. Gerendert von
|
||||
// `App.tsx` nach der Status-Leiste; Zustand und Handler kommen aus den Hooks der App.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import type { DrawingLevel } from "../model/types";
|
||||
import { lineEndsOf, setFieldIfChanged } from "../core";
|
||||
import { getState, useStore, type RootState } from "../state/appStore";
|
||||
import { setAiAccessEnabled } from "../state/aiAccess";
|
||||
import { activeExportView } from "../state/exportViewState";
|
||||
import { reconcileLayout } from "../state/layoutSlice";
|
||||
import type { useCommandEngineHost } from "../state/useCommandEngineHost";
|
||||
import type { useDialogState } from "../state/useDialogState";
|
||||
@@ -136,6 +138,8 @@ export function AppDialogs(props: {
|
||||
const needsProject = resourcesOpen || !!importState || settingsOpen;
|
||||
const subscribed = useStore((s) => (needsProject ? s.project : null));
|
||||
const project = subscribed ?? getState().project;
|
||||
// [271][272] Ansicht der aktiven Ebene für den Export-Dialog (beim Öffnen gelesen, der Dialog ist modal).
|
||||
const exportView = useMemo(() => (exportSaveFormat ? activeExportView() : null), [exportSaveFormat]);
|
||||
// [193] Höhe eines Netzpunkts (Rechtsklick auf den Griff): Overlay-Eingabe statt window.prompt.
|
||||
const meshHeightPrompt = useStore((s) => s.meshHeightPrompt);
|
||||
const meshPromptZ = useStore((s) => {
|
||||
@@ -255,8 +259,10 @@ export function AppDialogs(props: {
|
||||
<ExportSaveDialog
|
||||
initialFormat={exportSaveFormat}
|
||||
baseName={projectFileName()}
|
||||
onSave={(fmt, filename, ifcOptions) => {
|
||||
runExport(fmt, filename, ifcOptions);
|
||||
view={exportView?.view}
|
||||
viewLabels={exportView?.labels}
|
||||
onSave={(fmt, filename, ifcOptions, view) => {
|
||||
runExport(fmt, filename, ifcOptions, view);
|
||||
setExportSaveFormat(null);
|
||||
}}
|
||||
onClose={() => setExportSaveFormat(null)}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { t } from "../i18n";
|
||||
import { useModalFocus } from "./modalFocus";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
import type { IfcExportOptions, IfcSchema } from "../export/exportIfc";
|
||||
import { hasExportView, type ExportView } from "../export/exportView";
|
||||
|
||||
/** Direkt-herunterladbare Exportformate (mit Datei-Endung). */
|
||||
export type ExportSaveFormat = "csv" | "ifc" | "obj" | "stl" | "glb" | "step";
|
||||
@@ -31,8 +32,15 @@ export interface ExportSaveDialogProps {
|
||||
initialFormat: ExportSaveFormat;
|
||||
/** Basis-Dateiname OHNE Endung (i. d. R. Projektname). */
|
||||
baseName: string;
|
||||
/** `ifc`: Klassifikations-Optionen (nur bei Format IFC gesetzt). */
|
||||
onSave: (format: ExportSaveFormat, filename: string, ifc?: IfcExportOptions) => void;
|
||||
/** [271][272] Ansicht der aktiven Ebene (Umbaufilter, Etappe, Variantenkombination); fehlt oder leer = Hauptvarianten, alles. */
|
||||
view?: ExportView;
|
||||
/** Lesbare Fassung von `view` (Filtername mit Etappe, Kombination) für die Anzeige. */
|
||||
viewLabels?: { renovation: string | null; combination: string | null };
|
||||
/**
|
||||
* `ifc`: Klassifikations-Optionen (nur bei Format IFC gesetzt). `view`: die Ansicht, die der Export übernimmt
|
||||
* (nur bei den 3D-Formaten und wenn gewählt; sonst nicht gesetzt = Hauptvarianten, kein Filter).
|
||||
*/
|
||||
onSave: (format: ExportSaveFormat, filename: string, ifc?: IfcExportOptions, view?: ExportView) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
@@ -46,6 +54,8 @@ function withExt(base: string, ext: string): string {
|
||||
export function ExportSaveDialog({
|
||||
initialFormat,
|
||||
baseName,
|
||||
view,
|
||||
viewLabels,
|
||||
onSave,
|
||||
onClose,
|
||||
}: ExportSaveDialogProps) {
|
||||
@@ -69,7 +79,11 @@ export function ExportSaveDialog({
|
||||
const [context, setContext] = useState(false);
|
||||
// IFC-Schema: IFC4 (Standard) oder IFC2x3 für ältere Fachplaner-Programme.
|
||||
const [schema, setSchema] = useState<IfcSchema>("IFC4");
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes, context } : undefined);
|
||||
// [271][272] Die Ansicht der aktiven Ebene gilt für alle 3D-Formate (IFC, OBJ, STL, glTF, STEP); die Bauteilliste (CSV) nicht.
|
||||
const viewApplies = format !== "csv";
|
||||
const viewActive = hasExportView(view);
|
||||
const [useView, setUseView] = useState(true);
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes, context } : undefined, viewApplies && viewActive && useView ? view : undefined);
|
||||
|
||||
return (
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
@@ -137,6 +151,29 @@ export function ExportSaveDialog({
|
||||
</section>
|
||||
)}
|
||||
|
||||
{viewApplies && (
|
||||
<section className="imp-section" data-testid="export-view">
|
||||
<div className="imp-section-title">{t("exportSave.view")}</div>
|
||||
{viewActive ? (
|
||||
<>
|
||||
<label className="imp-check">
|
||||
<input type="checkbox" data-testid="export-view-use" checked={useView} onChange={(e) => setUseView(e.target.checked)} />
|
||||
<span>{t("exportSave.view.use")}</span>
|
||||
</label>
|
||||
<div className="imp-note" data-testid="export-view-summary">
|
||||
{useView
|
||||
? [viewLabels?.renovation ? t("exportSave.view.renovation", { name: viewLabels.renovation }) : "", viewLabels?.combination ? t("exportSave.view.combination", { name: viewLabels.combination }) : ""].filter(Boolean).join(" · ")
|
||||
: t("exportSave.view.off")}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="imp-note" data-testid="export-view-summary">
|
||||
{t("exportSave.view.none")}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="imp-section">
|
||||
<div className="imp-section-title">{t("exportSave.filename")}</div>
|
||||
<input
|
||||
|
||||
+40
-2
@@ -24,6 +24,7 @@ import {
|
||||
type RenderCameraChoice,
|
||||
type RenderCameraSpec,
|
||||
exportProjectName,
|
||||
hasExportView,
|
||||
} from "../core";
|
||||
import { getState } from "../state/appStore";
|
||||
import { setRenderDialogOpener } from "../state/renderDialogHook";
|
||||
@@ -46,6 +47,7 @@ import {
|
||||
import { saveBinaryFile } from "../native/saveFile";
|
||||
import { runWithAnonymityGate } from "../state/anonymityGate";
|
||||
import { defaultTargetLayout, placeImageOnLayout } from "../state/layoutImageActions";
|
||||
import { activeExportView, type ActiveExportView } from "../state/exportViewState";
|
||||
import { PreviewBadge } from "./PreviewBadge";
|
||||
|
||||
type SizeId = "sd" | "hd" | "uhd" | "a4" | "a3" | "a2" | "custom";
|
||||
@@ -83,6 +85,10 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
const [cameras, setCameras] = useState<RenderCameraChoice[]>([]);
|
||||
// [227] Baugrube im Bild ausblenden (Gelände hinterfüllt); das 3D im Modell bleibt wie es ist.
|
||||
const [backfilled, setBackfilled] = useState(true);
|
||||
// [271][272] Ansicht der aktiven 3D-Ansicht (Umbaufilter, Variantenkombination); übernehmen oder Hauptvarianten/alles.
|
||||
const [view, setView] = useState<ActiveExportView>({ view: {}, labels: { renovation: null, combination: null } });
|
||||
const [useView, setUseView] = useState(true);
|
||||
const [renoColors, setRenoColors] = useState(false);
|
||||
// [215] Renderer: eingebautes Cycles oder Blender; `cyclesOk` undefined, bis die Suche nach dem mitgelieferten Programm fertig ist.
|
||||
const [engine, setEngine] = useState<RenderEngine>("blender");
|
||||
const [cyclesOk, setCyclesOk] = useState<boolean | undefined>(undefined);
|
||||
@@ -116,6 +122,9 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
const st = getState();
|
||||
setWhen(toInputValue(defaultRenderTime(st.project)));
|
||||
setCamera(currentRenderCamera());
|
||||
setView(activeExportView());
|
||||
setUseView(true);
|
||||
setRenoColors(false);
|
||||
setCameraKey("live");
|
||||
setCameras(projectRenderCameras(st.project));
|
||||
setPath(getBlenderPath());
|
||||
@@ -200,7 +209,9 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
// Sonnenzeit der Kamera übernehmen (änderbar).
|
||||
if (choice.sunWhen) setWhen(toInputValue(choice.sunWhen));
|
||||
};
|
||||
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera, backfilled });
|
||||
const viewActive = hasExportView(view.view);
|
||||
const appliedView = viewActive && useView ? view.view : undefined;
|
||||
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera, backfilled, view: appliedView });
|
||||
const stageText = (e: { stage: string; done: number; total: number }) =>
|
||||
e.stage === "render"
|
||||
? t("render.stage.render", { done: e.done, total: e.total })
|
||||
@@ -287,7 +298,7 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
try {
|
||||
const res = await renderWithCycles(
|
||||
st.project,
|
||||
{ width: dims.width, height: dims.height, samples, denoise, when: date!, camera, backfilled, context, extraEv: exposureEv },
|
||||
{ width: dims.width, height: dims.height, samples, denoise, when: date!, camera, backfilled, context, extraEv: exposureEv, view: appliedView, renovationColors: renoColors && !!appliedView?.renovation },
|
||||
{
|
||||
signal: ac.signal,
|
||||
onMissingTextures: (n) => st.notify(t("render.missingTextures", { n }), "warning"),
|
||||
@@ -559,6 +570,33 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
</label>
|
||||
<div className="imp-note">{t("render.backfilled.hint")}</div>
|
||||
</section>
|
||||
<section className="imp-section" data-testid="render-view">
|
||||
<div className="imp-section-title">{t("render.view")}</div>
|
||||
{viewActive ? (
|
||||
<>
|
||||
<label className="imp-field-label">
|
||||
<input type="checkbox" data-testid="render-view-use" checked={useView} disabled={busy} onChange={(e) => setUseView(e.target.checked)} /> {t("render.view.use")}
|
||||
</label>
|
||||
<div className="imp-note" data-testid="render-view-summary">
|
||||
{useView
|
||||
? [view.labels.renovation ? t("render.view.renovation", { name: view.labels.renovation }) : "", view.labels.combination ? t("render.view.combination", { name: view.labels.combination }) : ""].filter(Boolean).join(" · ")
|
||||
: t("render.view.off")}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="imp-note" data-testid="render-view-summary">
|
||||
{t("render.view.none")}
|
||||
</div>
|
||||
)}
|
||||
{useCycles && viewActive && useView && !!view.view.renovation && (
|
||||
<>
|
||||
<label className="imp-field-label" style={{ display: "block", marginTop: 4 }}>
|
||||
<input type="checkbox" data-testid="render-reno-colors" checked={renoColors} disabled={busy} onChange={(e) => setRenoColors(e.target.checked)} /> {t("render.view.colors")}
|
||||
</label>
|
||||
<div className="imp-note">{t("render.view.colorsHint")}</div>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
{useCycles && (
|
||||
<section className="imp-section" data-testid="render-cycles-options">
|
||||
<label className="imp-field-label">
|
||||
|
||||
Reference in new issue
Block a user