[105][106] Merge: Fenster/Türen tief einstellbar (Rahmen je Seite, Flügel, Profile, Zargenarten, Schichteinzug je Schicht/Seite, Vorschau) – IDs 103/104→105/106

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-30 01:06:15 +00:00
commit 2eab3b73af
26 files changed
+3099 -85

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import { sampleProject } from "../model/sampleProject";
import type { Project } from "../model/types";
import { openingPreviewProject, openingPreviewSvgs } from "./openingPreview";
describe("openingPreview ([105]/[106])", () => {
it("baut ein Vorschau-Projekt mit nur der Öffnung", () => {
const mini = openingPreviewProject(sampleProject, "D1");
expect(mini?.walls).toHaveLength(1);
expect(mini?.openings?.map((o) => o.id)).toEqual(["D1"]);
expect(openingPreviewProject(sampleProject, "fehlt")).toBeNull();
});
it("liefert Grundriss, Schnitt und Ansicht als SVG; Schichteinzug ändert den Grundriss", async () => {
const svgs = await openingPreviewSvgs(sampleProject, "D1");
expect(svgs?.plan).toContain("<svg");
expect(svgs?.section).toContain("<polygon");
expect(svgs?.elevation).toContain("<polygon");
const withReveal: Project = {
...sampleProject,
openings: sampleProject.openings!.map((o) => (o.id === "D1" ? { ...o, layerReveals: [{ layer: -1, mode: "zurueck", amount: 0.05 }] } : o)),
};
const other = await openingPreviewSvgs(withReveal, "D1");
expect(other?.plan).not.toEqual(svgs?.plan);
});
});
+58
View File
@@ -0,0 +1,58 @@
// Live-Vorschau einer Öffnung für den Fenster-/Tür-Dialog ([105]/[106]): Der Kern baut ein kleines
// Projekt (Abfrage `openingPreview`, `src-tauri/core/src/opening_preview.rs`: Wirtswand mit nur dieser
// Öffnung, Schnitt quer durch die Mitte, Ansicht von aussen); Grundriss, Schnitt und Ansicht rechnen die
// gewöhnlichen Kern-Fassaden, als SVG-Text (`planToSvgString`).
import type { DetailLevel, Project } from "../model/types";
import { documentFor } from "../core/document";
import { generatePlan } from "./generatePlan";
import { computeSection, generateSectionPlan } from "./toSection";
import { generateElevationPlan } from "./toElevation";
import { planToSvgString } from "../export/planToSvgString";
export interface OpeningPreviewSvgs {
plan: string;
section: string | null;
elevation: string | null;
}
/** Vorschau-Projekt (oder `null`, wenn Öffnung/Wand fehlen). */
export function openingPreviewProject(project: Project, openingId: string): Project | null {
return documentFor(project).query<Project | null>("openingPreview", [], openingId);
}
/** Grundriss (Detailgrad `detail`), Schnitt und Ansicht der Öffnung als SVG-Text, Massstab 1:`scale`. */
export async function openingPreviewSvgs(project: Project, openingId: string, detail: DetailLevel = "fein", scale = 20): Promise<OpeningPreviewSvgs | null> {
const mini = openingPreviewProject(project, openingId);
if (!mini) return null;
const codes = new Set<string>(["", ...collectCodes(mini)]);
const opts = { scaleDenominator: scale, marginM: 0.15 };
const plan = planToSvgString(generatePlan(mini, "preview-floor", codes, undefined, detail, false, false, false, scale), opts);
const secLevel = mini.drawingLevels.find((l) => l.id === "preview-section");
const elevLevel = mini.drawingLevels.find((l) => l.id === "preview-elevation");
let section: string | null = null;
if (secLevel) {
const out = await computeSection(mini, secLevel);
if (out) section = planToSvgString(generateSectionPlan(out, false, { visibleCodes: codes, openings: true }), opts);
}
let elevation: string | null = null;
if (elevLevel) {
const p = generateElevationPlan(mini, elevLevel, { visibleCodes: codes });
if (p) elevation = planToSvgString(p, opts);
}
return { plan, section, elevation };
}
function collectCodes(p: Project): string[] {
const out: string[] = [];
for (const w of p.walls) out.push(w.categoryCode);
for (const o of p.openings ?? []) out.push(o.categoryCode);
const walk = (cats: Project["layers"]) => {
for (const c of cats) {
out.push(c.code);
walk((c as { children?: Project["layers"] }).children ?? []);
}
};
walk(p.layers);
return out;
}