[195b] Objekteinstellungen: gemischte Werte und Setzen für alle bei Decke, Dach, Öffnung, Höhen; Öffnungs-Editor als Abschnitt statt Dialog
This commit is contained in:
28 files changed
+479
-148
No files matched your search
+5
-6
@@ -498,12 +498,11 @@ export interface PanelHostValue {
|
||||
* (Discoverability: von der gewählten Öffnung in den Typeditor springen).
|
||||
*/
|
||||
onEditOpeningType: (kind: "door" | "window") => void;
|
||||
/**
|
||||
* Öffnet den reichen Fenster-/Tür-Einstellungsdialog für DIESE Öffnung
|
||||
* (Kategorie-Sidebar, Live-2D-Vorschau, Flügeleinteilung, „Als Stil speichern").
|
||||
* Ist der Primärort für Öffnungs-Parameter; das ⚙ der OpeningSection ruft ihn.
|
||||
*/
|
||||
onOpenOpeningEditor: (openingId: string) => void;
|
||||
/** Fenster-/Türeditor ([195b], Abschnitt der Objekt-Info): Typ-Felder des Stils ändern (wirkt auf alle Öffnungen des Stils). */
|
||||
onPatchWindowType: (typeId: string, patch: Partial<import("../model/types").WindowType>) => void;
|
||||
onPatchDoorType: (typeId: string, patch: Partial<import("../model/types").DoorType>) => void;
|
||||
/** „Als Stil speichern": Stil der Öffnung als neuen benannten Stil ablegen und zuweisen. */
|
||||
onSaveOpeningStyle: (openingId: string, name: string) => void;
|
||||
/**
|
||||
* Immutable Änderung von Dach-Attributen (Form/Neigung/Überstand/Firstrichtung/
|
||||
* Dicke) — wirkt NUR auf das selektierte Dach.
|
||||
|
||||
@@ -8,7 +8,9 @@ import { t } from "../../i18n";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { UValueRow } from "../UValueRow";
|
||||
import { formatM } from "../../model/types";
|
||||
import { BuildingFlags, DimensionField, VerticalAnchorRow } from "./fields";
|
||||
import { selectionCeilingValues } from "../../state/mixedValues";
|
||||
import { BuildingFlags, DimensionField, MixedMark, VerticalAnchorRow } from "./fields";
|
||||
import { useMulti } from "./useMulti";
|
||||
|
||||
export function CeilingSection({
|
||||
ceiling,
|
||||
@@ -18,6 +20,8 @@ export function CeilingSection({
|
||||
host: ReturnType<typeof usePanelHost>;
|
||||
}) {
|
||||
const storeProject = useStore((st) => st.project);
|
||||
// [195b] Mehrfachauswahl: abweichende Werte als „gemischt" kennzeichnen.
|
||||
const multi = useMulti("ceilings", selectionCeilingValues);
|
||||
const isSingle = ceiling.singleLayer;
|
||||
const multiPresets = ceiling.ceilingTypes.filter((ct) => ct.layerCount > 1);
|
||||
|
||||
@@ -61,11 +65,14 @@ export function CeilingSection({
|
||||
|
||||
{/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */}
|
||||
{isSingle ? (
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.thickness")}
|
||||
value={ceiling.thickness}
|
||||
onCommit={(v) => host.onSetCeilingThickness(v)}
|
||||
/>
|
||||
<>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.thickness")}
|
||||
value={ceiling.thickness}
|
||||
onCommit={(v) => host.onSetCeilingThickness(v)}
|
||||
/>
|
||||
<MixedMark on={multi?.thickness.mixed} what="thickness" />
|
||||
</>
|
||||
) : (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.ceiling.preset")}</span>
|
||||
@@ -80,6 +87,7 @@ export function CeilingSection({
|
||||
title={t("objinfo.ceiling.preset")}
|
||||
width={150}
|
||||
/>
|
||||
<MixedMark on={multi?.typeId.mixed} what="ceilingType" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -149,6 +157,7 @@ export function CeilingSection({
|
||||
defaultFloorId={ceiling.floorId}
|
||||
onChange={(a) => host.onSetCeilingTop(a)}
|
||||
/>
|
||||
<MixedMark on={multi?.top.mixed} what="top" />
|
||||
|
||||
{/* UK der Decke: an Geschoss gebunden ODER eigene Höhe; ohne Override
|
||||
bleibt es beim heutigen Verhalten UK = OK − Dicke. */}
|
||||
@@ -160,6 +169,7 @@ export function CeilingSection({
|
||||
defaultFloorId={ceiling.floorId}
|
||||
onChange={(a) => host.onSetCeilingBottom?.(a)}
|
||||
/>
|
||||
<MixedMark on={multi?.bottom.mixed} what="bottom" />
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.ceiling.height")}</span>
|
||||
<span className="objinfo-fval">{formatM(ceiling.zTop - ceiling.zBottom)}</span>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { CeilingSection } from "./CeilingSection";
|
||||
import { GridSection } from "./GridSection";
|
||||
import { InfoGroup } from "./InfoGroup";
|
||||
import { NewComponentSection } from "./NewComponentSection";
|
||||
import { OpeningEditorSection } from "./OpeningEditor";
|
||||
import { OpeningSection } from "./OpeningSections";
|
||||
import { DetailRefSection, DimRefsSection, DimTextSection } from "./RefSections";
|
||||
import { RoofSection } from "./RoofSections";
|
||||
@@ -46,6 +47,7 @@ export function InfoGroups({ sel, drawing, host }: { sel: SelectionInfo | null;
|
||||
case "roof": return sel?.roof ? <RoofSection roof={sel.roof} host={host} /> : null;
|
||||
case "surfacePattern": return sel ? <SurfacePatternPlacement kind={sel.wall ? "wall" : "roof"} id={sel.id} host={host} /> : null;
|
||||
case "opening": return sel?.opening ? <OpeningSection opening={sel.opening} host={host} /> : null;
|
||||
case "openingEditor": return sel?.opening ? <OpeningEditorSection openingId={sel.opening.id} host={host} /> : null;
|
||||
case "stair": return sel?.stair ? <StairSection stair={sel.stair} host={host} /> : null;
|
||||
case "room": return sel?.room ? <RoomSection room={sel.room} roomId={sel.id} host={host} /> : null;
|
||||
case "extrudedSolid": return sel?.extrudedSolid ? <ExtrudedSolidSection solid={sel.extrudedSolid} host={host} /> : null;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// [195b] Der Fenster-/Türeditor ist Abschnitt des Bereichs „Objekt" (früher modaler Dialog) und die Abschnitte
|
||||
// zeigen „gemischt" bei abweichenden Werten der Mehrfachauswahl. Ohne DOM: Server-Render des Panels.
|
||||
import { createElement } from "react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildComplexSampleProject } from "../../model/sampleProjectComplex";
|
||||
import { getState, setState } from "../../state/appStore";
|
||||
import { EMPTY_SELECTION } from "../../state/selection";
|
||||
import { PanelHostProvider } from "../host";
|
||||
import type { PanelHost } from "../types";
|
||||
import { ObjectSettingsPanel } from "../objectSettings/ObjectSettingsPanel";
|
||||
|
||||
const host = { activeTool: "select", sectionLine: null, displayMode: { mode: "all", setMode: () => {} } } as unknown as PanelHost;
|
||||
const render = () => renderToString(createElement(PanelHostProvider, { value: host }, createElement(ObjectSettingsPanel)));
|
||||
|
||||
describe("Objekteinstellungen: Öffnung [195b]", () => {
|
||||
it("Wandöffnung gewählt: Abschnitt „Fenster-/Türeditor“ mit dem Editor im Bereich Objekt", () => {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
const o = getState().project.openings!.find((x) => !x.hostRoofId && !x.hostCeilingId)!;
|
||||
setState({ selection: { ...EMPTY_SELECTION, openings: [o.id] } });
|
||||
const html = render();
|
||||
expect(html).toContain('data-group="openingEditor"');
|
||||
expect(html).toContain('data-testid="opening-editor"');
|
||||
expect(html).not.toContain("imp-overlay");
|
||||
});
|
||||
|
||||
it("zwei Öffnungen mit abweichender Breite: „gemischt“ am Breitenfeld", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
const [a, b] = p.openings!.filter((x) => !x.hostRoofId && !x.hostCeilingId);
|
||||
const q = { ...p, openings: p.openings!.map((x) => (x.id === a.id ? { ...x, width: 1 } : x.id === b.id ? { ...x, width: 1.4 } : x)) };
|
||||
getState().loadProject(q);
|
||||
setState({ selection: { ...EMPTY_SELECTION, openings: [a.id, b.id] } });
|
||||
expect(render()).toContain('data-mixed="width"');
|
||||
setState({ selection: { ...EMPTY_SELECTION, openings: [a.id] } });
|
||||
expect(render()).not.toContain('data-mixed="width"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,932 @@
|
||||
// Reicher Fenster-/Tür-Editor (VW „Fenster bearbeiten"-Muster, Studie docs/design/window-editor-vectorworks-study.md),
|
||||
// [195b] als Abschnitt „Fenster-/Türeditor" im Bereich „Objekt" des Objekteinstellungs-Fensters (früher modaler
|
||||
// Dialog `OpeningEditorDialog`). 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 { useStore } from "../../state/appStore";
|
||||
import type { usePanelHost } from "../host";
|
||||
import { getDoorType, getWindowType, sashesOfWindowType, glazingPanesOf } from "../../model/types";
|
||||
import { CorePreview, DoorFramePanel, FrameDetailPanel, RebatePanel, RevealPanel, ScopeSwitch } from "../../ui/OpeningDetailPanels";
|
||||
|
||||
/** P0-Kategorien der Sidebar, je nach Öffnungsart. */
|
||||
type CatId =
|
||||
| "basis"
|
||||
| "groesse"
|
||||
| "rahmen"
|
||||
| "fluegel"
|
||||
| "sonnenschutz"
|
||||
| "tuerblatt"
|
||||
| "rahmendetail"
|
||||
| "anschlag"
|
||||
| "zarge"
|
||||
| "schichten";
|
||||
|
||||
/** Abschnitt „Fenster-/Türeditor" der Objekt-Info: Projekt aus dem Store, Änderungen über die Host-Handler. */
|
||||
export function OpeningEditorSection({ openingId, host }: { openingId: string; host: ReturnType<typeof usePanelHost> }) {
|
||||
const project = useStore((st) => st.project);
|
||||
const updateOpening = useStore((st) => st.updateOpening);
|
||||
return (
|
||||
<OpeningEditor
|
||||
openingId={openingId}
|
||||
project={project}
|
||||
onPatchWindowType={host.onPatchWindowType}
|
||||
onPatchDoorType={host.onPatchDoorType}
|
||||
onPatchOpening={(patch) => updateOpening(openingId, patch)}
|
||||
onSetOpeningType={(typeId) => updateOpening(openingId, { typeId: typeId || undefined })}
|
||||
onSaveAsStyle={(name) => host.onSaveOpeningStyle(openingId, name)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export interface OpeningEditorProps {
|
||||
openingId: string;
|
||||
project: Project;
|
||||
/** Typ-Feld (aktueller Stil) ändern — wirkt auf alle Instanzen des Stils. */
|
||||
onPatchWindowType: (typeId: string, patch: Partial<WindowType>) => void;
|
||||
onPatchDoorType: (typeId: string, patch: Partial<DoorType>) => void;
|
||||
/** Instanz-Feld dieser Öffnung ändern. */
|
||||
onPatchOpening: (patch: Partial<Opening>) => 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;
|
||||
}
|
||||
|
||||
export function OpeningEditor({
|
||||
openingId,
|
||||
project,
|
||||
onPatchWindowType,
|
||||
onPatchDoorType,
|
||||
onPatchOpening,
|
||||
onSetOpeningType,
|
||||
onSaveAsStyle,
|
||||
}: OpeningEditorProps) {
|
||||
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<CatId>("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");
|
||||
|
||||
// Name für „Als Stil speichern" (null = Eingabe zu); `window.prompt` ist im Tauri-WKWebView stumm.
|
||||
const [newStyleName, setNewStyleName] = useState<string | null>(null);
|
||||
|
||||
if (!opening) {
|
||||
// Öffnung verschwand (Undo/Löschen während offen) → nichts zu zeigen.
|
||||
return null;
|
||||
}
|
||||
|
||||
const typeList = isDoor ? project.doorTypes ?? [] : project.windowTypes ?? [];
|
||||
const styleName =
|
||||
(isDoor ? dt?.name : wt?.name) ?? t("objinfo.type.none");
|
||||
|
||||
const patchWt = (patch: Partial<WindowType>) => {
|
||||
if (wt) onPatchWindowType(wt.id, patch);
|
||||
};
|
||||
const patchDt = (patch: Partial<DoorType>) => {
|
||||
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 = (
|
||||
<ScopeSwitch
|
||||
scope={onType ? "type" : "opening"}
|
||||
onScope={setScope}
|
||||
overridden={overridden}
|
||||
onReset={() => onPatchOpening({ frameDetail: undefined, layerReveals: undefined, doorFrame: undefined, doorFrameKind: undefined })}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="oed-dialog oed-embedded" role="group" aria-label={t(isDoor ? "oed.title.door" : "oed.title.window")} data-testid="opening-editor">
|
||||
{/* Stil-Leiste: Stil wählen · als Stil speichern · zurücksetzen. */}
|
||||
<div className="oed-stylebar">
|
||||
<span className="oed-style-label">{t("oed.style")}</span>
|
||||
<select
|
||||
className="oed-select oed-style-select"
|
||||
value={opening.typeId ?? ""}
|
||||
onChange={(e) => onSetOpeningType(e.target.value)}
|
||||
>
|
||||
<option value="">{t("objinfo.type.none")}</option>
|
||||
{typeList.map((ty) => (
|
||||
<option key={ty.id} value={ty.id}>
|
||||
{ty.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="oed-stylebar-spacer" />
|
||||
<button
|
||||
type="button"
|
||||
className="oed-btn"
|
||||
title={t("oed.saveStyle.hint")}
|
||||
onClick={() => setNewStyleName(newStyleName === null ? `${styleName} ${t("oed.saveStyle.copySuffix")}` : null)}
|
||||
>
|
||||
{t("oed.saveStyle")}
|
||||
</button>
|
||||
</div>
|
||||
{newStyleName !== null && (
|
||||
<form
|
||||
className="oed-stylebar"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (newStyleName.trim()) onSaveAsStyle(newStyleName.trim());
|
||||
setNewStyleName(null);
|
||||
}}
|
||||
>
|
||||
<input
|
||||
className="oed-input"
|
||||
aria-label={t("oed.saveStyle.prompt")}
|
||||
placeholder={t("oed.saveStyle.prompt")}
|
||||
value={newStyleName}
|
||||
autoFocus
|
||||
onChange={(e) => setNewStyleName(e.target.value)}
|
||||
/>
|
||||
<button type="submit" className="oed-btn">{t("oed.saveStyle")}</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<div className="oed-main">
|
||||
{/* 1. Kategorie-Sidebar. */}
|
||||
<nav className="oed-sidebar" aria-label={t("oed.categories")}>
|
||||
{cats.map((c) => (
|
||||
<button
|
||||
key={c.id}
|
||||
type="button"
|
||||
className={`oed-cat${cat === c.id ? " active" : ""}`}
|
||||
onClick={() => setCat(c.id)}
|
||||
>
|
||||
{c.label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* 2. Parameter-Panel. */}
|
||||
<div className="oed-panel">
|
||||
{!wt && !dt && (
|
||||
<div className="oed-hint oed-hint-warn">{t("oed.noStyle")}</div>
|
||||
)}
|
||||
{cat === "basis" && (
|
||||
<BasisPanel
|
||||
isDoor={isDoor}
|
||||
wt={wt}
|
||||
dt={dt}
|
||||
patchWt={patchWt}
|
||||
patchDt={patchDt}
|
||||
/>
|
||||
)}
|
||||
{cat === "groesse" && (
|
||||
<GroessePanel opening={opening} isDoor={isDoor} onPatchOpening={onPatchOpening} />
|
||||
)}
|
||||
{cat === "rahmen" && (
|
||||
<RahmenPanel isDoor={isDoor} wt={wt} dt={dt} patchWt={patchWt} patchDt={patchDt} />
|
||||
)}
|
||||
{cat === "fluegel" && wt && <FluegelPanel wt={wt} patchWt={patchWt} />}
|
||||
{cat === "sonnenschutz" && wt && <SonnenschutzPanel wt={wt} patchWt={patchWt} />}
|
||||
{cat === "tuerblatt" && dt && <TuerblattPanel dt={dt} patchDt={patchDt} />}
|
||||
{(cat === "rahmendetail" || cat === "anschlag" || cat === "zarge" || cat === "schichten") && scopeBar}
|
||||
{cat === "rahmendetail" && <FrameDetailPanel value={frameDetail} onChange={setFrameDetail} isDoor={isDoor} />}
|
||||
{cat === "anschlag" && <RebatePanel value={frameDetail} onChange={setFrameDetail} isDoor={isDoor} />}
|
||||
{cat === "zarge" && isDoor && (
|
||||
<DoorFramePanel
|
||||
kind={onType ? dt?.frameKind : opening.doorFrameKind}
|
||||
onKind={(k) => (onType ? patchDt({ frameKind: k }) : onPatchOpening({ doorFrameKind: k }))}
|
||||
value={onType ? dt?.doorFrame : opening.doorFrame}
|
||||
onChange={(v) => (onType ? patchDt({ doorFrame: v }) : onPatchOpening({ doorFrame: v }))}
|
||||
/>
|
||||
)}
|
||||
{cat === "schichten" && <RevealPanel project={project} opening={opening} value={reveals} onChange={setReveals} />}
|
||||
</div>
|
||||
|
||||
{/* 3. Live-Ansicht aus dem Kern: Grundriss, Schnitt, Ansicht. */}
|
||||
<div className="oed-preview">
|
||||
<div className="oed-preview-title">{t("oed.preview")}</div>
|
||||
<CorePreview project={project} openingId={opening.id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ── 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 (
|
||||
<label className="oed-field">
|
||||
<span className="oed-flabel">{label}</span>
|
||||
<input
|
||||
className="oed-input"
|
||||
type="number"
|
||||
step={step}
|
||||
min={min}
|
||||
inputMode="decimal"
|
||||
value={text}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value);
|
||||
const n = Number(e.target.value);
|
||||
if (Number.isFinite(n)) onCommit(n);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
/** Beschriftetes Dropdown. */
|
||||
function SelField<V extends string>({
|
||||
label,
|
||||
value,
|
||||
options,
|
||||
onChange,
|
||||
}: {
|
||||
label: string;
|
||||
value: V;
|
||||
options: { value: V; label: string }[];
|
||||
onChange: (v: V) => void;
|
||||
}) {
|
||||
return (
|
||||
<label className="oed-field">
|
||||
<span className="oed-flabel">{label}</span>
|
||||
<select
|
||||
className="oed-select"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value as V)}
|
||||
>
|
||||
{options.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
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<WindowType>) => void;
|
||||
patchDt: (p: Partial<DoorType>) => void;
|
||||
}) {
|
||||
if (isDoor && dt) {
|
||||
return (
|
||||
<SelField
|
||||
label={t("oed.f.kind")}
|
||||
value={dt.kind}
|
||||
options={DOOR_KIND_OPTS()}
|
||||
onChange={(v) => patchDt({ kind: v })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (wt) {
|
||||
return (
|
||||
<>
|
||||
<SelField
|
||||
label={t("oed.f.kind")}
|
||||
value={wt.kind}
|
||||
options={OPENING_KIND_OPTS()}
|
||||
onChange={(v) => patchWt({ kind: v })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.f.glazing")}
|
||||
value={String(glazingPanesOf(wt)) as "1" | "2" | "3"}
|
||||
options={[
|
||||
{ value: "1", label: t("oed.glazing.1") },
|
||||
{ value: "2", label: t("oed.glazing.2") },
|
||||
{ value: "3", label: t("oed.glazing.3") },
|
||||
]}
|
||||
onChange={(v) => patchWt({ glazingPanes: Number(v) as 1 | 2 | 3 })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.f.insetFace")}
|
||||
value={wt.insetFace ?? "aussen"}
|
||||
options={[
|
||||
{ value: "aussen", label: t("oed.insetFace.aussen") },
|
||||
{ value: "innen", label: t("oed.insetFace.innen") },
|
||||
{ value: "mitte", label: t("oed.insetFace.mitte") },
|
||||
]}
|
||||
onChange={(v) => patchWt({ insetFace: v })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.insetFromFace")}
|
||||
value={wt.insetFromFace ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ insetFromFace: n })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.f.sillLineFaces")}
|
||||
value={wt.sillLine?.faces ?? "off"}
|
||||
options={[
|
||||
{ value: "off", label: t("oed.sillLine.off") },
|
||||
{ value: "aussen", label: t("oed.insetFace.aussen") },
|
||||
{ value: "innen", label: t("oed.insetFace.innen") },
|
||||
{ value: "beide", label: t("oed.sillLine.beide") },
|
||||
]}
|
||||
onChange={(v) =>
|
||||
patchWt({
|
||||
sillLine:
|
||||
v === "off"
|
||||
? undefined
|
||||
: { faces: v as "aussen" | "innen" | "beide", view: wt.sillLine?.view ?? "auf" },
|
||||
})
|
||||
}
|
||||
/>
|
||||
{wt.sillLine && (
|
||||
<SelField
|
||||
label={t("oed.f.sillLineView")}
|
||||
value={wt.sillLine.view}
|
||||
options={[
|
||||
{ value: "auf", label: t("oed.sillLine.auf") },
|
||||
{ value: "unter", label: t("oed.sillLine.unter") },
|
||||
]}
|
||||
onChange={(v) => patchWt({ sillLine: { faces: wt.sillLine!.faces, view: v } })}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function GroessePanel({
|
||||
opening,
|
||||
isDoor,
|
||||
onPatchOpening,
|
||||
}: {
|
||||
opening: Opening;
|
||||
isDoor: boolean;
|
||||
onPatchOpening: (p: Partial<Opening>) => void;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<NumField
|
||||
label={t("oed.f.width")}
|
||||
value={opening.width}
|
||||
min={0.1}
|
||||
onCommit={(n) => onPatchOpening({ width: n })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.height")}
|
||||
value={opening.height}
|
||||
min={0.1}
|
||||
onCommit={(n) => onPatchOpening({ height: n })}
|
||||
/>
|
||||
{!isDoor && (
|
||||
<NumField
|
||||
label={t("oed.f.sillHeight")}
|
||||
value={opening.sillHeight}
|
||||
min={0}
|
||||
onCommit={(n) => onPatchOpening({ sillHeight: n })}
|
||||
/>
|
||||
)}
|
||||
<NumField
|
||||
label={t("oed.f.position")}
|
||||
value={opening.position}
|
||||
min={0}
|
||||
onCommit={(n) => onPatchOpening({ position: n })}
|
||||
/>
|
||||
{/* [G3] Umrissform (Wandausschnitt in Schnitt, Ansicht, 3D, IFC; Grundriss bleibt SIA-Symbol). */}
|
||||
<SelField<OpeningShapeValue>
|
||||
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") && (
|
||||
<NumField
|
||||
label={t("oed.f.shapeRise")}
|
||||
value={opening.shapeRise ?? defaultShapeRise(opening)}
|
||||
onCommit={(n) => onPatchOpening({ shapeRise: n })}
|
||||
/>
|
||||
)}
|
||||
{opening.shape && opening.shape !== "rechteck" && <p className="oed-hint">{t("oed.shapeNote")}</p>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
type OpeningShapeValue = NonNullable<Opening["shape"]>;
|
||||
|
||||
/** 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<WindowType>) => void;
|
||||
patchDt: (p: Partial<DoorType>) => void;
|
||||
}) {
|
||||
if (isDoor && dt) {
|
||||
return (
|
||||
<>
|
||||
<NumField
|
||||
label={t("oed.f.frameThickness")}
|
||||
value={dt.frameThickness}
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ frameThickness: n })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.frameWidth")}
|
||||
value={dt.frameWidth ?? 0.06}
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ frameWidth: n })}
|
||||
/>
|
||||
<SelField<FrameCornerJoin>
|
||||
label={t("oed.f.cornerJoin")}
|
||||
value={dt.frameCornerJoin ?? "vertikal"}
|
||||
options={cornerJoinOptions()}
|
||||
onChange={(v) => patchDt({ frameCornerJoin: v })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.f.insetFace")}
|
||||
value={dt.insetFace ?? "aussen"}
|
||||
options={[
|
||||
{ value: "aussen", label: t("oed.insetFace.aussen") },
|
||||
{ value: "innen", label: t("oed.insetFace.innen") },
|
||||
{ value: "mitte", label: t("oed.insetFace.mitte") },
|
||||
]}
|
||||
onChange={(v) => patchDt({ insetFace: v })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.insetFromFace")}
|
||||
value={dt.insetFromFace ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ insetFromFace: n })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.rebateDepth")}
|
||||
value={dt.rebateDepth ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ rebateDepth: n || undefined })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.lintelHeight")}
|
||||
value={dt.lintelHeight ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ lintelHeight: n || undefined })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (wt) {
|
||||
return (
|
||||
<>
|
||||
<NumField
|
||||
label={t("oed.f.frameThickness")}
|
||||
value={wt.frameThickness}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ frameThickness: n })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.frameDepth")}
|
||||
value={wt.frameDepth ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ frameDepth: n || undefined })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.frameWidth")}
|
||||
value={wt.frameWidth ?? 0.06}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ frameWidth: n })}
|
||||
/>
|
||||
<SelField<FrameCornerJoin>
|
||||
label={t("oed.f.cornerJoin")}
|
||||
value={wt.frameCornerJoin ?? "vertikal"}
|
||||
options={cornerJoinOptions()}
|
||||
onChange={(v) => patchWt({ frameCornerJoin: v })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.rebateDepth")}
|
||||
value={wt.rebateDepth ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ rebateDepth: n || undefined })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.lintelHeight")}
|
||||
value={wt.lintelHeight ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ lintelHeight: n || undefined })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.f.sillBoard")}
|
||||
value={wt.sillBoard ?? "aussen"}
|
||||
options={[
|
||||
{ value: "keine", label: t("resources.sillBoard.keine") },
|
||||
{ value: "aussen", label: t("resources.sillBoard.aussen") },
|
||||
{ value: "innen", label: t("resources.sillBoard.innen") },
|
||||
{ value: "beide", label: t("resources.sillBoard.beide") },
|
||||
]}
|
||||
onChange={(v) => 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<WindowType>) => 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<SashDef>) =>
|
||||
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 (
|
||||
<>
|
||||
<div className="oed-hint">{t("oed.fluegel.hint")}</div>
|
||||
{/* Oberlicht (festes Feld über einem Kämpfer) + Kämpfer-/Sprossen-Zeilen. */}
|
||||
<NumField
|
||||
label={t("oed.f.transomHeight")}
|
||||
value={wt.transomHeight ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ transomHeight: n || undefined })}
|
||||
/>
|
||||
{(wt.transomHeight ?? 0) > 0 && (
|
||||
<>
|
||||
<NumField
|
||||
label={t("oed.f.transomFields")}
|
||||
value={transomFields(wt).count}
|
||||
step={1}
|
||||
min={1}
|
||||
onCommit={(n) => patchWt({ transomSashes: transomSashes(Math.max(1, Math.min(6, Math.round(n))), transomFields(wt).opening) })}
|
||||
/>
|
||||
<SelField<OpeningKind>
|
||||
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. */}
|
||||
<NumField
|
||||
label={t("oed.f.bottomPanelHeight")}
|
||||
value={wt.bottomPanelHeight ?? 0}
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ bottomPanelHeight: n || undefined })}
|
||||
/>
|
||||
{(wt.bottomPanelHeight ?? 0) > 0 && (
|
||||
<NumField
|
||||
label={t("oed.f.bottomPanelFields")}
|
||||
value={Math.max(1, (wt.bottomSashes ?? []).filter((s) => s.kind === "fluegel").length)}
|
||||
step={1}
|
||||
min={1}
|
||||
onCommit={(n) => patchWt({ bottomSashes: transomSashes(Math.max(1, Math.min(6, Math.round(n))), "fest") })}
|
||||
/>
|
||||
)}
|
||||
<NumField
|
||||
label={t("oed.f.mullionRows")}
|
||||
value={wt.mullionRows ?? 1}
|
||||
step={1}
|
||||
min={1}
|
||||
onCommit={(n) => patchWt({ mullionRows: Math.max(1, Math.round(n)) })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.f.mullionCols")}
|
||||
value={wt.mullionCols ?? 1}
|
||||
step={1}
|
||||
min={1}
|
||||
onCommit={(n) => patchWt({ mullionCols: Math.max(1, Math.round(n)) })}
|
||||
/>
|
||||
<table className="oed-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{t("oed.fluegel.col.kind")}</th>
|
||||
<th>{t("oed.fluegel.col.opening")}</th>
|
||||
<th>{t("oed.fluegel.col.hinge")}</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{sashes.map((s, i) => (
|
||||
<tr key={i}>
|
||||
<td className="oed-td-num">{i + 1}</td>
|
||||
<td>
|
||||
<select
|
||||
className="oed-select oed-select-sm"
|
||||
value={s.kind}
|
||||
onChange={(e) =>
|
||||
update(i, { kind: e.target.value as SashDef["kind"] })
|
||||
}
|
||||
>
|
||||
<option value="fluegel">{t("oed.fluegel.type.fluegel")}</option>
|
||||
<option value="pfosten">{t("oed.fluegel.type.pfosten")}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{s.kind === "fluegel" ? (
|
||||
<select
|
||||
className="oed-select oed-select-sm"
|
||||
value={s.opening ?? "dreh"}
|
||||
onChange={(e) =>
|
||||
update(i, { opening: e.target.value as OpeningKind })
|
||||
}
|
||||
>
|
||||
{OPENING_KIND_OPTS().map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<span className="oed-td-dash">–</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{s.kind === "fluegel" && s.opening !== "fest" ? (
|
||||
<select
|
||||
className="oed-select oed-select-sm"
|
||||
value={s.hingeSide ?? "left"}
|
||||
onChange={(e) =>
|
||||
update(i, { hingeSide: e.target.value as "left" | "right" })
|
||||
}
|
||||
>
|
||||
<option value="left">{t("oed.hinge.left")}</option>
|
||||
<option value="right">{t("oed.hinge.right")}</option>
|
||||
</select>
|
||||
) : (
|
||||
<span className="oed-td-dash">–</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="oed-rowbtn"
|
||||
title={t("oed.fluegel.remove")}
|
||||
onClick={() => remove(i)}
|
||||
disabled={sashes.length <= 1}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<div className="oed-rowactions">
|
||||
<button type="button" className="oed-btn" onClick={() => addSash("fluegel")}>
|
||||
+ {t("oed.fluegel.type.fluegel")}
|
||||
</button>
|
||||
<button type="button" className="oed-btn" onClick={() => addSash("pfosten")}>
|
||||
+ {t("oed.fluegel.type.pfosten")}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function SonnenschutzPanel({
|
||||
wt,
|
||||
patchWt,
|
||||
}: {
|
||||
wt: WindowType;
|
||||
patchWt: (p: Partial<WindowType>) => void;
|
||||
}) {
|
||||
const sh = wt.shading;
|
||||
const box = sh?.box ?? { width: 0, height: 0.24, depth: 0.2 };
|
||||
const set = (patch: Partial<NonNullable<WindowType["shading"]>>) =>
|
||||
patchWt({
|
||||
shading: {
|
||||
create: sh?.create ?? false,
|
||||
kind: sh?.kind ?? "rollladen",
|
||||
box,
|
||||
...patch,
|
||||
},
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<label className="oed-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={sh?.create ?? false}
|
||||
onChange={(e) => set({ create: e.target.checked })}
|
||||
/>
|
||||
<span>{t("oed.shading.create")}</span>
|
||||
</label>
|
||||
{sh?.create && (
|
||||
<>
|
||||
<SelField
|
||||
label={t("oed.shading.kind")}
|
||||
value={sh.kind}
|
||||
options={[
|
||||
{ value: "rollladen", label: t("oed.shading.rollladen") },
|
||||
{ value: "raffstore", label: t("oed.shading.raffstore") },
|
||||
{ value: "markise", label: t("oed.shading.markise") },
|
||||
]}
|
||||
onChange={(v) =>
|
||||
set({ kind: v as NonNullable<WindowType["shading"]>["kind"] })
|
||||
}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.shading.mount")}
|
||||
value={sh.mount ?? "vorgesetzt"}
|
||||
options={[
|
||||
{ value: "vorgesetzt", label: t("oed.shading.vorgesetzt") },
|
||||
{ value: "sturz", label: t("oed.shading.sturz") },
|
||||
]}
|
||||
onChange={(v) => set({ mount: v })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.shading.boxHeight")}
|
||||
value={box.height}
|
||||
min={0}
|
||||
onCommit={(n) => set({ box: { ...box, height: n } })}
|
||||
/>
|
||||
<NumField
|
||||
label={t("oed.shading.boxDepth")}
|
||||
value={box.depth}
|
||||
min={0}
|
||||
onCommit={(n) => set({ box: { ...box, depth: n } })}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TuerblattPanel({
|
||||
dt,
|
||||
patchDt,
|
||||
}: {
|
||||
dt: DoorType;
|
||||
patchDt: (p: Partial<DoorType>) => void;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<SelField
|
||||
label={t("oed.door.leafCount")}
|
||||
value={String(dt.leafCount) as "1" | "2"}
|
||||
options={[
|
||||
{ value: "1", label: t("oed.door.leaf1") },
|
||||
{ value: "2", label: t("oed.door.leaf2") },
|
||||
]}
|
||||
onChange={(v) => patchDt({ leafCount: Number(v) as 1 | 2 })}
|
||||
/>
|
||||
<SelField
|
||||
label={t("oed.door.leafStyle")}
|
||||
value={dt.leafStyle}
|
||||
options={[
|
||||
{ value: "glatt", label: t("oed.door.glatt") },
|
||||
{ value: "kassette", label: t("oed.door.kassette") },
|
||||
{ value: "glas", label: t("oed.door.glas") },
|
||||
]}
|
||||
onChange={(v) => patchDt({ leafStyle: v as DoorType["leafStyle"] })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,17 @@ import type { DetailLevel } from "../../model/viewTypes";
|
||||
import { formatM } from "../../model/types";
|
||||
import { surfaceOpeningInfo } from "../../core";
|
||||
import { ColorHexField } from "../../ui/ColorHexField";
|
||||
import { DimensionField } from "./fields";
|
||||
import { selectionOpeningValues } from "../../state/mixedValues";
|
||||
import { DimensionField, MixedMark } from "./fields";
|
||||
import { useMulti } from "./useMulti";
|
||||
import { expandAndFocusInfoGroup } from "./infoGroupState";
|
||||
import { setSettingsArea } from "../objectSettings/areaState";
|
||||
|
||||
/** ⚙: den Abschnitt „Fenster-/Türeditor" im Bereich „Objekt" aufklappen und fokussieren. */
|
||||
function openEditor(): void {
|
||||
setSettingsArea("object");
|
||||
expandAndFocusInfoGroup("openingEditor");
|
||||
}
|
||||
|
||||
// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) —
|
||||
// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs)
|
||||
@@ -31,6 +41,8 @@ export function OpeningSection({
|
||||
host: ReturnType<typeof usePanelHost>;
|
||||
}) {
|
||||
const storeProject = useStore((st) => st.project);
|
||||
// [195b] Mehrfachauswahl: abweichende Werte als „gemischt" kennzeichnen.
|
||||
const multi = useMulti("openings", selectionOpeningValues);
|
||||
const isDoor = opening.kind === "door";
|
||||
if (opening.hostRoofId || opening.hostCeilingId) {
|
||||
return <SurfaceOpeningSection opening={opening} host={host} />;
|
||||
@@ -57,12 +69,13 @@ export function OpeningSection({
|
||||
title={t("objinfo.opening.type")}
|
||||
width={106}
|
||||
/>
|
||||
<MixedMark on={multi?.typeId.mixed} what="openingType" />
|
||||
<button
|
||||
type="button"
|
||||
className="objinfo-typebtn"
|
||||
title={t("objinfo.opening.editType")}
|
||||
aria-label={t("objinfo.opening.editType")}
|
||||
onClick={() => host.onOpenOpeningEditor(opening.id)}
|
||||
onClick={openEditor}
|
||||
>
|
||||
⚙
|
||||
</button>
|
||||
@@ -103,11 +116,13 @@ export function OpeningSection({
|
||||
value={opening.width}
|
||||
onCommit={(v) => host.onSetOpeningWidth(v)}
|
||||
/>
|
||||
<MixedMark on={multi?.width.mixed} what="width" />
|
||||
<DimensionField
|
||||
label={t("objinfo.opening.height")}
|
||||
value={opening.height}
|
||||
onCommit={(v) => host.onSetOpeningHeight(v)}
|
||||
/>
|
||||
<MixedMark on={multi?.height.mixed} what="height" />
|
||||
{!isDoor && (
|
||||
<>
|
||||
<DimensionField
|
||||
@@ -115,6 +130,7 @@ export function OpeningSection({
|
||||
value={opening.sillHeight}
|
||||
onCommit={(v) => host.onSetOpeningSill(v)}
|
||||
/>
|
||||
<MixedMark on={multi?.sillHeight.mixed} what="sill" />
|
||||
{/* Fenster-spezifisch: Flügelanzahl (1–4). */}
|
||||
<DimensionField
|
||||
label={t("objinfo.opening.wingCount")}
|
||||
@@ -342,7 +358,7 @@ function SurfaceOpeningSection({
|
||||
className="objinfo-typebtn"
|
||||
title={t("objinfo.opening.editType")}
|
||||
aria-label={t("objinfo.opening.editType")}
|
||||
onClick={() => host.onOpenOpeningEditor(opening.id)}
|
||||
onClick={openEditor}
|
||||
>
|
||||
⚙
|
||||
</button>
|
||||
|
||||
@@ -13,6 +13,9 @@ import { Dropdown } from "../../ui/Dropdown";
|
||||
import { UValueRow } from "../UValueRow";
|
||||
import { formatM } from "../../model/types";
|
||||
import type { RoofEdge, EdgeSpec } from "../../core";
|
||||
import { selectionRoofValues } from "../../state/mixedValues";
|
||||
import { MixedMark } from "./fields";
|
||||
import { useMulti } from "./useMulti";
|
||||
|
||||
// ── Treppen-Attribut-Abschnitt ───────────────────────────────────────────────
|
||||
// Grundform (gerade/L/Wendel), Laufbreite, Stufenanzahl, Steighöhe (+ abgeleitete
|
||||
@@ -146,6 +149,8 @@ export function RoofSection({
|
||||
host: ReturnType<typeof usePanelHost>;
|
||||
}) {
|
||||
const storeProject = useStore((st) => st.project);
|
||||
// [195b] Mehrfachauswahl: abweichender Typ/abweichende Neigung als „gemischt" kennzeichnen.
|
||||
const multi = useMulti("roofs", selectionRoofValues);
|
||||
const numField = (
|
||||
labelKey: TranslationKey,
|
||||
value: number,
|
||||
@@ -204,6 +209,7 @@ export function RoofSection({
|
||||
title={t("objinfo.roof.type")}
|
||||
width={130}
|
||||
/>
|
||||
<MixedMark on={multi?.roofTypeId.mixed} what="roofType" />
|
||||
</div>
|
||||
<UValueRow project={storeProject} kind="roof" typeId={roof.roofTypeId} />
|
||||
|
||||
@@ -229,6 +235,7 @@ export function RoofSection({
|
||||
numField("objinfo.roof.pitch", roof.pitchDeg, 1, (v) =>
|
||||
host.onSetRoofPatch({ pitchDeg: Math.max(0, Math.min(85, v)) }),
|
||||
)}
|
||||
{roof.shape !== "flach" && <MixedMark on={multi?.pitchDeg.mixed} what="pitch" />}
|
||||
{roof.shape === "mansarde" &&
|
||||
numField("objinfo.roof.pitchUpper", roof.pitchUpperDeg ?? roof.pitchDeg / 2, 1, (v) =>
|
||||
host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Abschnitt „Wand" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Referenzlinie, Aufbau, Geschoss, Unter-
|
||||
// und Oberkante. Gerufen von `AttributesPanel`.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import { selectionWallValues } from "../../state/mixedValues";
|
||||
import { selectionWallHeights, selectionWallValues } from "../../state/mixedValues";
|
||||
import type { WallInfo } from "../../state/selectionInfo";
|
||||
import { usePanelHost } from "../host";
|
||||
import { t } from "../../i18n";
|
||||
@@ -11,7 +10,8 @@ import { Dropdown } from "../../ui/Dropdown";
|
||||
import type { WallReferenceLine, SliceTermination } from "../../model/types";
|
||||
import { UValueRow } from "../UValueRow";
|
||||
import { formatM } from "../../model/types";
|
||||
import { BuildingFlags, DimensionField, VerticalAnchorRow } from "./fields";
|
||||
import { BuildingFlags, DimensionField, MixedMark, VerticalAnchorRow } from "./fields";
|
||||
import { useMulti } from "./useMulti";
|
||||
|
||||
// ── Wand-Attribut-Abschnitt ──────────────────────────────────────────────────
|
||||
// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss +
|
||||
@@ -24,14 +24,10 @@ export function WallSection({
|
||||
host: ReturnType<typeof usePanelHost>;
|
||||
}) {
|
||||
const storeProject = useStore((st) => st.project);
|
||||
const selection = useStore((st) => st.selection);
|
||||
// [195b] Mehrfachauswahl: abweichender Typ/abweichende Dicke als „gemischt" kennzeichnen.
|
||||
const multi = useMemo(
|
||||
() => (selection.walls.length > 1 ? selectionWallValues(storeProject, selection) : null),
|
||||
[storeProject, selection],
|
||||
);
|
||||
const mixedMark = (on: boolean | undefined, what: string) =>
|
||||
on ? <span className="attr-mixed" data-mixed={what}>{t("objsettings.mixed")}</span> : null;
|
||||
// [195b] Mehrfachauswahl: abweichender Typ/Dicke/Höhe als „gemischt" kennzeichnen.
|
||||
const multi = useMulti("walls", selectionWallValues);
|
||||
const heights = useMulti("walls", selectionWallHeights);
|
||||
const mixedMark = (on: boolean | undefined, what: string) => <MixedMark on={on} what={what} />;
|
||||
// Aufbau-Typ-Segment: einschichtig vs. mehrschichtig. Aus dem Modell
|
||||
// abgeleitet (singleLayer); der Umschalter auf „mehrschichtig" wählt einen
|
||||
// mehrschichtigen Wandtyp-Preset (erster mit >1 Schicht), auf „einschichtig"
|
||||
@@ -232,6 +228,7 @@ export function WallSection({
|
||||
defaultFloorId={wall.floorAbove?.id ?? wall.floorId}
|
||||
onChange={(a) => host.onSetWallTop(a)}
|
||||
/>
|
||||
{mixedMark(heights?.top.mixed, "top")}
|
||||
<VerticalAnchorRow
|
||||
label={t("objinfo.wall.bottom")}
|
||||
anchor={wall.bottom}
|
||||
@@ -240,6 +237,7 @@ export function WallSection({
|
||||
defaultFloorId={wall.floorId}
|
||||
onChange={(a) => host.onSetWallBottom(a)}
|
||||
/>
|
||||
{mixedMark(heights?.bottom.mixed, "bottom")}
|
||||
|
||||
{/* Höhe = OK − UK (abgeleitet, read-only). */}
|
||||
<div className="objinfo-field">
|
||||
|
||||
@@ -8,6 +8,11 @@ import type { VerticalAnchor } from "../../model/types";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { useState, useRef } from "react";
|
||||
|
||||
/** [195b] Kennzeichnung „gemischt": Die gewählten Elemente haben für dieses Feld verschiedene Werte. */
|
||||
export function MixedMark({ on, what }: { on: boolean | undefined; what: string }) {
|
||||
return on ? <span className="attr-mixed" data-mixed={what}>{t("objsettings.mixed")}</span> : null;
|
||||
}
|
||||
|
||||
// ── Decken-Attribut-Abschnitt ────────────────────────────────────────────────
|
||||
// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss +
|
||||
// OK-Bindung, Fläche. Alle Werte/Setter über den Host.
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("Panel-Zuordnung [189]", () => {
|
||||
|
||||
it("Fenster/Tür: nur die Objekt-Info trägt den Öffnungs-Abschnitt", () => {
|
||||
const sel = deriveSelection(p, { openings: [p.openings![0].id] });
|
||||
expect(infoGroups({ sel, ...ctx })).toEqual(["opening"]);
|
||||
expect(infoGroups({ sel, ...ctx })).toEqual(["opening", "openingEditor"]);
|
||||
});
|
||||
|
||||
it("Decke, Raum, Treppe, Dach: je ein eigener Abschnitt der Objekt-Info", () => {
|
||||
@@ -50,7 +50,7 @@ describe("Panel-Zuordnung [189]", () => {
|
||||
});
|
||||
|
||||
it("jede Gruppe hat einen Titel", () => {
|
||||
const all: InfoGroupId[] = ["newComponent", "sectionLine", "wall", "ceiling", "roof", "surfacePattern", "opening", "stair", "room", "extrudedSolid", "column", "detailRef", "dimRefs", "dimText", "grid"];
|
||||
const all: InfoGroupId[] = ["newComponent", "sectionLine", "wall", "ceiling", "roof", "surfacePattern", "opening", "openingEditor", "stair", "room", "extrudedSolid", "column", "detailRef", "dimRefs", "dimText", "grid"];
|
||||
for (const g of all) expect(INFO_GROUP_TITLE[g]).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@ export type InfoGroupId =
|
||||
| "roof"
|
||||
| "surfacePattern"
|
||||
| "opening"
|
||||
| "openingEditor"
|
||||
| "stair"
|
||||
| "room"
|
||||
| "extrudedSolid"
|
||||
@@ -32,6 +33,7 @@ export const INFO_GROUP_TITLE: Record<InfoGroupId, TranslationKey> = {
|
||||
roof: "objinfo.roof.section",
|
||||
surfacePattern: "objinfo.surfacePattern",
|
||||
opening: "objinfo.opening.section",
|
||||
openingEditor: "objinfo.openingEditor.section",
|
||||
stair: "objinfo.stair.section",
|
||||
room: "objinfo.room.section",
|
||||
extrudedSolid: "objinfo.extrudedSolid.section",
|
||||
@@ -65,7 +67,7 @@ export function infoGroups(c: InfoGroupContext): InfoGroupId[] {
|
||||
if (sel.ceiling) out.push("ceiling");
|
||||
if (sel.roof) out.push("roof");
|
||||
if (sel.wall || sel.roof) out.push("surfacePattern");
|
||||
if (sel.opening) out.push("opening");
|
||||
if (sel.opening) out.push("opening", "openingEditor");
|
||||
if (sel.stair) out.push("stair");
|
||||
if (sel.room) out.push("room");
|
||||
if (sel.extrudedSolid) out.push("extrudedSolid");
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// [195b] Gemeinsame Werte bei Mehrfachauswahl gleicher Art für die Abschnitte der Objekt-Info: `null` bei einem
|
||||
// einzelnen Element, sonst das Ergebnis der Abfrage aus `state/mixedValues.ts` (je Wert gleich oder „gemischt").
|
||||
|
||||
import { useMemo } from "react";
|
||||
import type { Project } from "../../model/types";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { Selection } from "../../state/selection";
|
||||
|
||||
export function useMulti<T>(kind: "walls" | "ceilings" | "roofs" | "openings", compute: (p: Project, sel: Selection) => T): T | null {
|
||||
const project = useStore((s) => s.project);
|
||||
const selection = useStore((s) => s.selection);
|
||||
// `compute` ist je Aufrufstelle eine Modul-Funktion (stabil).
|
||||
return useMemo(() => (selection[kind].length > 1 ? compute(project, selection) : null), [project, selection, kind, compute]);
|
||||
}
|
||||
Reference in new issue
Block a user