// Reicher Fenster-/Tür-Einstellungsdialog (VW „Fenster bearbeiten"-Muster, // Studie docs/design/window-editor-vectorworks-study.md). Drei Zonen: // 1. Kategorie-Sidebar links, // 2. Parameter-Panel Mitte, // 3. Live-2D-Ansicht (Elevation) rechts — direkt aus den aktuellen Werten // gezeichnet (Rahmen/Flügel/Öffnungslinien/Verglasung/Rollladenkasten). // Oben eine Stil-Leiste: Stil wählen · „Als Stil speichern…" · zurücksetzen. // // Der Dialog editiert TYP-Parameter (der referenzierte WindowType/DoorType = // wiederverwendbarer Stil, wirkt auf alle Instanzen) UND INSTANZ-Parameter // (Grösse/Position dieser Öffnung). Bezeichner englisch, UI-Text deutsch. import { useEffect, useState } from "react"; import { t } from "../i18n"; import type { DoorType, FrameDetail, LayerReveal, FrameCornerJoin, Opening, OpeningKind, Project, SashDef, WindowType, } from "../model/types"; import { getDoorType, getWindowType, sashesOfWindowType, glazingPanesOf } from "../model/types"; import { CorePreview, DoorFramePanel, FrameDetailPanel, RebatePanel, RevealPanel, ScopeSwitch } from "./OpeningDetailPanels"; /** P0-Kategorien der Sidebar, je nach Öffnungsart. */ type CatId = | "basis" | "groesse" | "rahmen" | "fluegel" | "sonnenschutz" | "tuerblatt" | "rahmendetail" | "anschlag" | "zarge" | "schichten"; export interface OpeningEditorDialogProps { openingId: string; project: Project; /** Typ-Feld (aktueller Stil) ändern — wirkt auf alle Instanzen des Stils. */ onPatchWindowType: (typeId: string, patch: Partial) => void; onPatchDoorType: (typeId: string, patch: Partial) => void; /** Instanz-Feld dieser Öffnung ändern. */ onPatchOpening: (patch: Partial) => void; /** Öffnung einem anderen Stil zuweisen ("" = keiner). */ onSetOpeningType: (typeId: string) => void; /** Aktuellen Stil als NEUEN benannten Stil ablegen und der Öffnung zuweisen. */ onSaveAsStyle: (name: string) => void; onClose: () => void; } export function OpeningEditorDialog({ openingId, project, onPatchWindowType, onPatchDoorType, onPatchOpening, onSetOpeningType, onSaveAsStyle, onClose, }: OpeningEditorDialogProps) { const opening = (project.openings ?? []).find((o) => o.id === openingId); const isDoor = opening?.kind === "door"; const wt = opening && !isDoor ? getWindowType(project, opening) : undefined; const dt = opening && isDoor ? getDoorType(project, opening) : undefined; const cats: { id: CatId; label: string }[] = isDoor ? [ { id: "basis", label: t("oed.cat.basis") }, { id: "groesse", label: t("oed.cat.groesse") }, { id: "rahmen", label: t("oed.cat.rahmen") }, { id: "zarge", label: t("oed.cat.zarge") }, { id: "rahmendetail", label: t("oed.cat.rahmendetail") }, { id: "anschlag", label: t("oed.cat.anschlag") }, { id: "schichten", label: t("oed.cat.schichten") }, { id: "tuerblatt", label: t("oed.cat.tuerblatt") }, ] : [ { id: "basis", label: t("oed.cat.basis") }, { id: "groesse", label: t("oed.cat.groesse") }, { id: "rahmen", label: t("oed.cat.rahmen") }, { id: "rahmendetail", label: t("oed.cat.rahmendetail") }, { id: "anschlag", label: t("oed.cat.anschlag") }, { id: "schichten", label: t("oed.cat.schichten") }, { id: "fluegel", label: t("oed.cat.fluegel") }, { id: "sonnenschutz", label: t("oed.cat.sonnenschutz") }, ]; const [cat, setCat] = useState("basis"); // [105]/[106]: Detail-Panels wirken auf den Typ (alle Öffnungen) oder nur auf diese Öffnung. const [scope, setScope] = useState<"type" | "opening">(opening?.frameDetail || opening?.layerReveals || opening?.doorFrame || opening?.doorFrameKind ? "opening" : "type"); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onClose]); if (!opening) { // Öffnung verschwand (Undo/Löschen während offen) → Dialog schliesst sich. return null; } const typeList = isDoor ? project.doorTypes ?? [] : project.windowTypes ?? []; const styleName = (isDoor ? dt?.name : wt?.name) ?? t("objinfo.type.none"); const patchWt = (patch: Partial) => { if (wt) onPatchWindowType(wt.id, patch); }; const patchDt = (patch: Partial) => { if (dt) onPatchDoorType(dt.id, patch); }; const ty = isDoor ? dt : wt; const onType = scope === "type" && !!ty; // Werte des gewählten Geltungsbereichs; „nur diese Öffnung" zeigt die Übersteuerung (leer = wie Typ). const frameDetail = onType ? ty?.frameDetail : opening.frameDetail; const setFrameDetail = (v: FrameDetail | undefined) => (onType ? (isDoor ? patchDt({ frameDetail: v }) : patchWt({ frameDetail: v })) : onPatchOpening({ frameDetail: v })); const typeReveals = isDoor ? dt?.layerReveals : wt?.layerReveals ?? (wt?.innerLayerRecess ? [{ layer: -1, mode: "zurueck" as const }] : undefined); const reveals = onType ? typeReveals : opening.layerReveals ?? typeReveals; const setReveals = (v: LayerReveal[] | undefined) => onType ? (isDoor ? patchDt({ layerReveals: v }) : patchWt({ layerReveals: v, innerLayerRecess: undefined })) : onPatchOpening({ layerReveals: v }); const overridden = !!(opening.frameDetail || opening.layerReveals || opening.doorFrame || opening.doorFrameKind); const scopeBar = ( onPatchOpening({ frameDetail: undefined, layerReveals: undefined, doorFrame: undefined, doorFrameKind: undefined })} /> ); return (
e.stopPropagation()} >
{t(isDoor ? "oed.title.door" : "oed.title.window")}
{/* Stil-Leiste: Stil wählen · als Stil speichern · zurücksetzen. */}
{t("oed.style")}
{/* 1. Kategorie-Sidebar. */} {/* 2. Parameter-Panel. */}
{!wt && !dt && (
{t("oed.noStyle")}
)} {cat === "basis" && ( )} {cat === "groesse" && ( )} {cat === "rahmen" && ( )} {cat === "fluegel" && wt && } {cat === "sonnenschutz" && wt && } {cat === "tuerblatt" && dt && } {(cat === "rahmendetail" || cat === "anschlag" || cat === "zarge" || cat === "schichten") && scopeBar} {cat === "rahmendetail" && } {cat === "anschlag" && } {cat === "zarge" && isDoor && ( (onType ? patchDt({ frameKind: k }) : onPatchOpening({ doorFrameKind: k }))} value={onType ? dt?.doorFrame : opening.doorFrame} onChange={(v) => (onType ? patchDt({ doorFrame: v }) : onPatchOpening({ doorFrame: v }))} /> )} {cat === "schichten" && }
{/* 3. Live-Ansicht aus dem Kern: Grundriss, Schnitt, Ansicht. */}
{t("oed.preview")}
); } // ── Parameter-Panels ──────────────────────────────────────────────────────── /** Kleines beschriftetes Zahlenfeld (Meter), lokal gepuffert. */ function NumField({ label, value, step = 0.01, min, onCommit, }: { label: string; value: number; step?: number; min?: number; onCommit: (n: number) => void; }) { const [text, setText] = useState(String(value)); useEffect(() => setText(String(value)), [value]); return ( ); } /** Beschriftetes Dropdown. */ function SelField({ label, value, options, onChange, }: { label: string; value: V; options: { value: V; label: string }[]; onChange: (v: V) => void; }) { return ( ); } const OPENING_KIND_OPTS = (): { value: OpeningKind; label: string }[] => [ { value: "dreh", label: t("oed.kind.dreh") }, { value: "kipp", label: t("oed.kind.kipp") }, { value: "drehkipp", label: t("oed.kind.drehkipp") }, { value: "fest", label: t("oed.kind.fest") }, { value: "schiebe", label: t("oed.kind.schiebe") }, ]; type DoorKind = DoorType["kind"]; const DOOR_KIND_OPTS = (): { value: DoorKind; label: string }[] => [ { value: "dreh", label: t("oed.kind.dreh") }, { value: "schiebe", label: t("oed.kind.schiebe") }, { value: "wandoeffnung", label: t("oed.door.wandoeffnung") }, { value: "hebeschiebe", label: t("oed.door.hebeschiebe") }, { value: "pendel", label: t("oed.door.pendel") }, { value: "tasche", label: t("oed.door.tasche") }, ]; function BasisPanel({ isDoor, wt, dt, patchWt, patchDt, }: { isDoor: boolean; wt?: WindowType; dt?: DoorType; patchWt: (p: Partial) => void; patchDt: (p: Partial) => void; }) { if (isDoor && dt) { return ( patchDt({ kind: v })} /> ); } if (wt) { return ( <> patchWt({ kind: v })} /> patchWt({ glazingPanes: Number(v) as 1 | 2 | 3 })} /> patchWt({ insetFace: v })} /> patchWt({ insetFromFace: n })} /> patchWt({ sillLine: v === "off" ? undefined : { faces: v as "aussen" | "innen" | "beide", view: wt.sillLine?.view ?? "auf" }, }) } /> {wt.sillLine && ( patchWt({ sillLine: { faces: wt.sillLine!.faces, view: v } })} /> )} ); } return null; } function GroessePanel({ opening, isDoor, onPatchOpening, }: { opening: Opening; isDoor: boolean; onPatchOpening: (p: Partial) => void; }) { return ( <> onPatchOpening({ width: n })} /> onPatchOpening({ height: n })} /> {!isDoor && ( onPatchOpening({ sillHeight: n })} /> )} onPatchOpening({ position: n })} /> {/* [G3] Umrissform (Wandausschnitt in Schnitt, Ansicht, 3D, IFC; Grundriss bleibt SIA-Symbol). */} label={t("oed.f.shape")} value={opening.shape ?? "rechteck"} options={OPENING_SHAPE_OPTS()} onChange={(v) => onPatchOpening({ shape: v === "rechteck" ? undefined : v, shapeRise: undefined })} /> {(opening.shape === "segmentbogen" || opening.shape === "spitzbogen" || opening.shape === "schraeg" || opening.shape === "giebel") && ( onPatchOpening({ shapeRise: n })} /> )} {opening.shape && opening.shape !== "rechteck" &&

{t("oed.shapeNote")}

} ); } type OpeningShapeValue = NonNullable; /** Stich ohne Angabe wie im Kern (`opening_shape::outline`). */ function defaultShapeRise(o: Opening): number { const w = o.width; const r = o.shape === "segmentbogen" ? w / 6 : o.shape === "spitzbogen" ? (w * Math.sqrt(3)) / 2 : w / 2; return Math.round(r * 1000) / 1000; } const OPENING_SHAPE_OPTS = (): { value: OpeningShapeValue; label: string }[] => (["rechteck", "rundbogen", "segmentbogen", "spitzbogen", "rund", "schraeg", "giebel"] as const).map((v) => ({ value: v, label: t(`oed.shape.${v}`), })); function RahmenPanel({ isDoor, wt, dt, patchWt, patchDt, }: { isDoor: boolean; wt?: WindowType; dt?: DoorType; patchWt: (p: Partial) => void; patchDt: (p: Partial) => void; }) { if (isDoor && dt) { return ( <> patchDt({ frameThickness: n })} /> patchDt({ frameWidth: n })} /> label={t("oed.f.cornerJoin")} value={dt.frameCornerJoin ?? "vertikal"} options={cornerJoinOptions()} onChange={(v) => patchDt({ frameCornerJoin: v })} /> patchDt({ insetFace: v })} /> patchDt({ insetFromFace: n })} /> patchDt({ rebateDepth: n || undefined })} /> patchDt({ lintelHeight: n || undefined })} /> ); } if (wt) { return ( <> patchWt({ frameThickness: n })} /> patchWt({ frameDepth: n || undefined })} /> patchWt({ frameWidth: n })} /> label={t("oed.f.cornerJoin")} value={wt.frameCornerJoin ?? "vertikal"} options={cornerJoinOptions()} onChange={(v) => patchWt({ frameCornerJoin: v })} /> patchWt({ rebateDepth: n || undefined })} /> patchWt({ lintelHeight: n || undefined })} /> patchWt({ sillBoard: v })} /> ); } return null; } /** Auswahl der Rahmen-Eckverbindung (s. `WindowType.frameCornerJoin`). */ function cornerJoinOptions(): { value: FrameCornerJoin; label: string }[] { return [ { value: "vertikal", label: t("oed.cornerJoin.vertikal") }, { value: "horizontal", label: t("oed.cornerJoin.horizontal") }, { value: "gehrung", label: t("oed.cornerJoin.gehrung") }, ]; } /** Oberlicht-Einteilung ([95]): Anzahl Felder und Öffnungsart des ersten Felds. */ function transomFields(wt: WindowType): { count: number; opening: OpeningKind } { const fields = (wt.transomSashes ?? []).filter((s) => s.kind === "fluegel"); return { count: Math.max(1, fields.length), opening: fields[0]?.opening ?? "fest" }; } /** Gleichmässige Oberlicht-Einteilung: `count` Felder, dazwischen Pfosten; ein festes Feld = keine Liste. */ function transomSashes(count: number, opening: OpeningKind): SashDef[] | undefined { if (count <= 1 && opening === "fest") return undefined; const out: SashDef[] = []; for (let i = 0; i < count; i++) { if (i > 0) out.push({ kind: "pfosten", postWidth: 0.06 }); out.push({ kind: "fluegel", autoWidth: true, opening, hingeSide: i % 2 === 0 ? "left" : "right" }); } return out; } /** Flügeleinteilung: Tabelle mit Flügel/Pfosten, Öffnungsart + Anschlag je Zeile. */ function FluegelPanel({ wt, patchWt, }: { wt: WindowType; patchWt: (p: Partial) => void; }) { const sashes = sashesOfWindowType(wt); const setSashes = (next: SashDef[]) => patchWt({ sashes: next, wingCount: next.filter((s) => s.kind === "fluegel").length || 1 }); const update = (i: number, patch: Partial) => setSashes(sashes.map((s, k) => (k === i ? { ...s, ...patch } : s))); const addSash = (kind: SashDef["kind"]) => setSashes([ ...sashes, kind === "fluegel" ? { kind, autoWidth: true, opening: "dreh", hingeSide: "left" } : { kind, postWidth: 0.06 }, ]); const remove = (i: number) => setSashes(sashes.filter((_, k) => k !== i)); return ( <>
{t("oed.fluegel.hint")}
{/* Oberlicht (festes Feld über einem Kämpfer) + Kämpfer-/Sprossen-Zeilen. */} patchWt({ transomHeight: n || undefined })} /> {(wt.transomHeight ?? 0) > 0 && ( <> patchWt({ transomSashes: transomSashes(Math.max(1, Math.min(6, Math.round(n))), transomFields(wt).opening) })} /> label={t("oed.f.transomOpening")} value={transomFields(wt).opening} options={[ { value: "fest", label: t("oed.kind.fest") }, { value: "kipp", label: t("oed.kind.kipp") }, { value: "dreh", label: t("oed.kind.dreh") }, ]} onChange={(v) => patchWt({ transomSashes: transomSashes(transomFields(wt).count, v) })} /> )} {/* [95] Brüstungsfeld unten (unter einem Riegel), Einteilung wie das Oberlicht. */} patchWt({ bottomPanelHeight: n || undefined })} /> {(wt.bottomPanelHeight ?? 0) > 0 && ( s.kind === "fluegel").length)} step={1} min={1} onCommit={(n) => patchWt({ bottomSashes: transomSashes(Math.max(1, Math.min(6, Math.round(n))), "fest") })} /> )} patchWt({ mullionRows: Math.max(1, Math.round(n)) })} /> patchWt({ mullionCols: Math.max(1, Math.round(n)) })} /> {sashes.map((s, i) => ( ))}
# {t("oed.fluegel.col.kind")} {t("oed.fluegel.col.opening")} {t("oed.fluegel.col.hinge")}
{i + 1} {s.kind === "fluegel" ? ( ) : ( – )} {s.kind === "fluegel" && s.opening !== "fest" ? ( ) : ( – )}
); } function SonnenschutzPanel({ wt, patchWt, }: { wt: WindowType; patchWt: (p: Partial) => void; }) { const sh = wt.shading; const box = sh?.box ?? { width: 0, height: 0.24, depth: 0.2 }; const set = (patch: Partial>) => patchWt({ shading: { create: sh?.create ?? false, kind: sh?.kind ?? "rollladen", box, ...patch, }, }); return ( <> {sh?.create && ( <> set({ kind: v as NonNullable["kind"] }) } /> set({ mount: v })} /> set({ box: { ...box, height: n } })} /> set({ box: { ...box, depth: n } })} /> )} ); } function TuerblattPanel({ dt, patchDt, }: { dt: DoorType; patchDt: (p: Partial) => void; }) { return ( <> patchDt({ leafCount: Number(v) as 1 | 2 })} /> patchDt({ leafStyle: v as DoorType["leafStyle"] })} /> ); }