diff --git a/TODO.md b/TODO.md index 4608fd9d..c4a9b858 100644 --- a/TODO.md +++ b/TODO.md @@ -90,7 +90,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* - ◐ **[198]** T-Stoss: gleiche Schichten verschmelzen (12.11.). Ursache: jede Wand zeichnete ihre Umriss-/Fugenlinie einzeln, am T-Stoss blieb ein Stück Wandumriss der Durchgangswand unter dem Innenputz des Abzweigs (Putz an Putz). Jetzt streicht `plan/seams.rs` nach dem Zeichnen alle Linien/Polygonkanten, die zwei Flächen gleichen Stils (Füllung + Schraffur ohne Ursprung) VERSCHIEDENER Bauteile trennen (Probe beidseits, Linie muss auf dem Rand beider Flächen liegen); Teilstücke werden zu Linien `wall-outline`/`section-joint`. Grundriss (`walls.rs`, Bänder + schwarze Sammelfläche ab 1:100), Schnitt (`section/primitives.rs`, feine Fugen; schwere Schnittkante unberührt) — Bildschirm, Druck, SVG gleich (gleiche Primitive). Materialwechsel und Fugen eigener Schichten einer Wand bleiben. Tests `plan/wall_merge_tests.rs` (T, Ecke, Kreuzung, Gegenprobe, Materialwechsel), `section/tests.rs`; Goldens nachgeführt. Offen: Flächen werden nicht per Boolean vereinigt (Schraffur-Phase je Wand; verschieden orientierte Schraffur gilt als anderer Stil, Linie bleibt); durchlaufende, nicht verbundene Wand durch Wand (Überlappung) unberührt; Ansicht nicht angesehen; nicht in der Tauri-App/auf dem Mac. · M - ○ **[197]** Cmd+3/4 Nachbesserung (12.11., Maintainer): (1) Kamera bleibt bei Cmd+3/Cmd+4 exakt stehen (kein Einpassen; Einpassen nur mit Cmd+Shift+F); (2) Dachfenster/Deckenöffnungen bleiben bei „nur Auswahl“ (eine Wand) sichtbar → Öffnungen nur mit sichtbarem Wirt (Wand, Dach, Decke) oder selbst gewählt (`model3d::ElementSelection`). e2e. · S - ○ **[196]** (12.11., Maintainer, PRIO) (1) Raster-Bodenschraffur in Gebäudeform (mit Loch an der Wendeltreppe) im EG-Grundriss lässt sich weder anwählen noch löschen — Vermutung: Ansichtsschraffur der Decke des darunterliegenden Geschosses (UG-Decke von oben) bzw. Bodenbelag; klären (Musterhaus komplex EG), Pick wählt das Quell-Element (auch wenn es zu einem anderen Geschoss gehört), Entf löscht es bzw. Hinweis. (2) Zeichnungsebenen-Panel: Auge/„sichtbar“ bei einer Ansicht blendet bei den Grundrissen alle Geschosse ein → Auge schaltet nur die eigene Ebene. (3) Auge eines Geschosses aus → Geschoss fehlt auch im 3D (heute zeigt 3D immer alle Geschosse; Filter wie Klassen [180] im 3D-Cache-Ausgang). e2e für alles. · S -- ◐ **[195b]** Objekteinstellungen als ECHTES Nebenfenster (Wunsch Maintainer, 12.11.). **Stand 12.11.:** Unter Tauri öffnet T (bzw. Menü) das native Fenster `object-settings` (`native/objectSettingsWindow.ts`, Fensterseite `ObjectSettingsWindowApp.tsx`, Protokoll `objectSettingsSync.ts`); Browser/Electron behalten das schwebende Panel. Architektur (schlankste ohne Doppelspur): das Fenster lädt denselben Store als SPIEGEL (Projekt-Leseansicht als Feld-Differenz `projectDelta` + Laden ins eigene Kern-Dokument, Auswahl, aktive Ebene, Wert-Felder des Panel-Hosts, Fokus-Abschnitt von T) und rendert unverändert `ObjectSettingsPanel`; Store-Änderungen dort rechnen ihre Ops auf dem Spiegel und gehen über `state/changeSink.ts` ans Hauptfenster (`applyChange`, Undo je Änderung, `coalesceKey` bleibt), Host-Handler per Proxy (`remoteHost`) ebenso; Cmd+Z/Shift+Cmd+Z im Fenster wirken auf den Verlauf des Hauptfensters, Meldungen erscheinen dort. Auswahlwechsel und Undo im Hauptfenster kommen als Sync (30 ms gebündelt, nur bei offenem Fenster, ohne React-Abo in `App`). Mehrfachwerte: Schraffur (Attribute) und Wandtyp/Dicke („gemischt“), Wandtyp gilt für alle gewählten Wände (ein Schritt). Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`. **Offen:** NICHT auf macOS gebaut/getestet (nur vitest/tsc im Linux-Container; Capability `object-settings` ergänzt, kein Rust); jede Projektänderung lädt das Projekt im Fenster ganz ins Kern-Dokument (bei grossen Projekten ggf. Ops-Strom statt Feld-Differenz); kein Messwert (Live-Mass) im Fenster; Mehrfachwerte für weitere Felder (Decke/Dach/Öffnung, Höhen) und Setzen für alle bei weiteren Handlern; OpeningEditorDialog in den Bereich „Objekt“ übernehmen. · L +- ◐ **[195b]** Objekteinstellungen als ECHTES Nebenfenster (Wunsch Maintainer, 12.11.). **Stand 12.11.:** Unter Tauri öffnet T (bzw. Menü) das native Fenster `object-settings` (`native/objectSettingsWindow.ts`, Fensterseite `ObjectSettingsWindowApp.tsx`, Protokoll `objectSettingsSync.ts`); Browser/Electron behalten das schwebende Panel. Architektur (schlankste ohne Doppelspur): das Fenster lädt denselben Store als SPIEGEL (Projekt-Leseansicht als Feld-Differenz `projectDelta` + Laden ins eigene Kern-Dokument, Auswahl, aktive Ebene, Wert-Felder des Panel-Hosts, Fokus-Abschnitt von T) und rendert unverändert `ObjectSettingsPanel`; Store-Änderungen dort rechnen ihre Ops auf dem Spiegel und gehen über `state/changeSink.ts` ans Hauptfenster (`applyChange`, Undo je Änderung, `coalesceKey` bleibt), Host-Handler per Proxy (`remoteHost`) ebenso; Cmd+Z/Shift+Cmd+Z im Fenster wirken auf den Verlauf des Hauptfensters, Meldungen erscheinen dort. Auswahlwechsel und Undo im Hauptfenster kommen als Sync (30 ms gebündelt, nur bei offenem Fenster, ohne React-Abo in `App`). Mehrfachwerte: Schraffur (Attribute) und Wandtyp/Dicke („gemischt“), Wandtyp gilt für alle gewählten Wände (ein Schritt). **Stand 12.11. (2):** „gemischt“ auch für Decke (Typ/Dicke/UK/OK), Dach (Typ/Neigung), Öffnung (Typ/Breite/Höhe/Brüstung) und Wand-UK/OK (`mixedValues.ts`, Marke `MixedMark`); die Setter dafür (`elementAttributesHost`, `patchAll`) ändern alle gewählten Elemente gleicher Art in EINEM Undo-Schritt (Dicken per `groupChanges`; Dach nur Typ/Neigung), ein nicht angefasstes gemischtes Feld bleibt unverändert; `deriveSelection` führt bei mehreren Decken/Öffnungen/Dächern mit dem ersten Element (vorher: keine Info, also kein Abschnitt). `OpeningEditorDialog` ist weg: der Editor ist der Abschnitt „Fenster-/Türeditor“ im Bereich „Objekt“ (`panels/objectInfo/OpeningEditor.tsx`, ⚙ klappt ihn auf; Host-Handler `onPatchWindowType/DoorType/onSaveOpeningStyle`; „Als Stil speichern“ mit Eingabezeile statt `window.prompt`); `setOpeningEditorId`/Dialog-State entfernt. Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`. **Offen:** NICHT auf macOS gebaut/getestet (nur vitest/tsc im Linux-Container; Capability `object-settings` ergänzt, kein Rust); jede Projektänderung lädt das Projekt im Fenster ganz ins Kern-Dokument (bei grossen Projekten ggf. Ops-Strom statt Feld-Differenz); kein Messwert (Live-Mass) im Fenster; weitere Handler setzen bei Mehrfachauswahl noch nur das erste Element (Referenzlinie, Raum, Treppe, Öffnungs-Zusatzfelder, Dach-Kanten/Gauben). · L - ○ **[195]** Objekt-Einstellungsfenster (12.11., Maintainer): T öffnet ein EIGENES Fenster (macOS-Nebenfenster wie Einstellungen/Ressourcen über die Sync-Brücke, Browser: verschiebbares Fenster), für ALLE Bauteile (Wand, Decke, Dach, Treppe, Stütze, Öffnung, Raum, Körper, Gelände/Baugrube, 2D, Bemassung), mit Abschnitten Objektspezifisch (Typ/Aufbau/Masse/Parameter) + Darstellung (Stift, Füllung, Schraffur, Linienstil, Modelldarstellung). Mehrfachauswahl gleicher Art, live mit Undo je Änderung; dieselben Abschnitts-Komponenten wie Objekt-Info (keine Doppelspur). Ersetzt den bisherigen Öffnungs-Dialog bei T. · L - ◐ **[194]** Texte exakt synchron beim Zoomen (12.11., Maintainer Mac: Texte immer leicht verzögert; Nachfolger [145]). 12.11.: Die native Fläche zeichnet die Plan-Texte selbst im selben Frame wie die Linien: Raumstempel und waagrechte diff --git a/src/App.tsx b/src/App.tsx index e7cf956c..204b05c4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -147,7 +147,7 @@ export default function App() { // State, siehe state/useDialogState.ts. const dialogs = useDialogState(); const { - resourcesOpen, setResourcesOpen, setResourcesTab, setOpeningEditorId, activeLayoutId, setActiveLayoutId, + resourcesOpen, setResourcesOpen, setResourcesTab, activeLayoutId, setActiveLayoutId, setImportState, exportOpen, setExportOpen, setExportDxfOpen, setSettingsOpen, setExportSaveFormat, setDropActive, } = dialogs; @@ -680,7 +680,7 @@ export default function App() { selectedViewSnapshotId, setSelectedViewSnapshotId, }, - dialogState: { setActiveLayoutId, setOpeningEditorId }, + dialogState: { setActiveLayoutId }, contextMenuState: { setMenu }, }); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index b1227dba..cd5dd110 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -623,9 +623,10 @@ export const de = { "objinfo.ceiling.anchorCustom": "Eigene", // ── Öffnungs-Attribute (Object-Info-Panel) ────────────────────────────── "objinfo.opening.section": "Öffnung", + "objinfo.openingEditor.section": "Fenster-/Türeditor", "objinfo.opening.type": "Typ", "objinfo.opening.editType": "Einstellungen …", - // Fenster-/Tür-Einstellungsdialog (OpeningEditorDialog). + // Fenster-/Tür-Einstellungsdialog (OpeningEditor). "oed.title.window": "Fenster-Einstellungen", "oed.title.door": "Tür-Einstellungen", "oed.style": "Stil", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 0f9b7dfc..fdfd09ce 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -622,9 +622,10 @@ export const en: Record = { "objinfo.ceiling.anchorCustom": "Custom", // ── Opening attributes (object info panel) ────────────────────────────── "objinfo.opening.section": "Opening", + "objinfo.openingEditor.section": "Window/door editor", "objinfo.opening.type": "Type", "objinfo.opening.editType": "Settings …", - // Window/door settings dialog (OpeningEditorDialog). + // Window/door settings dialog (OpeningEditor). "oed.title.window": "Window settings", "oed.title.door": "Door settings", "oed.style": "Style", diff --git a/src/panels/host.ts b/src/panels/host.ts index d461a9cf..011ba45d 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -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) => void; + onPatchDoorType: (typeId: string, patch: Partial) => 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. diff --git a/src/panels/objectInfo/CeilingSection.tsx b/src/panels/objectInfo/CeilingSection.tsx index e9802f3f..43fa0099 100644 --- a/src/panels/objectInfo/CeilingSection.tsx +++ b/src/panels/objectInfo/CeilingSection.tsx @@ -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; }) { 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 ? ( - host.onSetCeilingThickness(v)} - /> + <> + host.onSetCeilingThickness(v)} + /> + + ) : (
{t("objinfo.ceiling.preset")} @@ -80,6 +87,7 @@ export function CeilingSection({ title={t("objinfo.ceiling.preset")} width={150} /> +
)} @@ -149,6 +157,7 @@ export function CeilingSection({ defaultFloorId={ceiling.floorId} onChange={(a) => host.onSetCeilingTop(a)} /> + {/* 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)} /> +
{t("objinfo.ceiling.height")} {formatM(ceiling.zTop - ceiling.zBottom)} diff --git a/src/panels/objectInfo/InfoGroups.tsx b/src/panels/objectInfo/InfoGroups.tsx index c04b85fb..8dbe7a9f 100644 --- a/src/panels/objectInfo/InfoGroups.tsx +++ b/src/panels/objectInfo/InfoGroups.tsx @@ -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 ? : null; case "surfacePattern": return sel ? : null; case "opening": return sel?.opening ? : null; + case "openingEditor": return sel?.opening ? : null; case "stair": return sel?.stair ? : null; case "room": return sel?.room ? : null; case "extrudedSolid": return sel?.extrudedSolid ? : null; diff --git a/src/panels/objectInfo/OpeningEditor.render.test.ts b/src/panels/objectInfo/OpeningEditor.render.test.ts new file mode 100644 index 00000000..0a51e417 --- /dev/null +++ b/src/panels/objectInfo/OpeningEditor.render.test.ts @@ -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"'); + }); +}); diff --git a/src/ui/OpeningEditorDialog.tsx b/src/panels/objectInfo/OpeningEditor.tsx similarity index 91% rename from src/ui/OpeningEditorDialog.tsx rename to src/panels/objectInfo/OpeningEditor.tsx index 6ed6c49d..2a21c37f 100644 --- a/src/ui/OpeningEditorDialog.tsx +++ b/src/panels/objectInfo/OpeningEditor.tsx @@ -1,5 +1,6 @@ -// Reicher Fenster-/Tür-Einstellungsdialog (VW „Fenster bearbeiten"-Muster, -// Studie docs/design/window-editor-vectorworks-study.md). Drei Zonen: +// 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 @@ -11,7 +12,7 @@ // (Grösse/Position dieser Öffnung). Bezeichner englisch, UI-Text deutsch. import { useEffect, useState } from "react"; -import { t } from "../i18n"; +import { t } from "../../i18n"; import type { DoorType, FrameDetail, @@ -22,9 +23,11 @@ import type { Project, SashDef, WindowType, -} from "../model/types"; -import { getDoorType, getWindowType, sashesOfWindowType, glazingPanesOf } from "../model/types"; -import { CorePreview, DoorFramePanel, FrameDetailPanel, RebatePanel, RevealPanel, ScopeSwitch } from "./OpeningDetailPanels"; +} 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 = @@ -39,7 +42,24 @@ type CatId = | "zarge" | "schichten"; -export interface OpeningEditorDialogProps { +/** 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 }) { + const project = useStore((st) => st.project); + const updateOpening = useStore((st) => st.updateOpening); + return ( + 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. */ @@ -51,10 +71,9 @@ export interface OpeningEditorDialogProps { onSetOpeningType: (typeId: string) => void; /** Aktuellen Stil als NEUEN benannten Stil ablegen und der Öffnung zuweisen. */ onSaveAsStyle: (name: string) => void; - onClose: () => void; } -export function OpeningEditorDialog({ +export function OpeningEditor({ openingId, project, onPatchWindowType, @@ -62,8 +81,7 @@ export function OpeningEditorDialog({ onPatchOpening, onSetOpeningType, onSaveAsStyle, - onClose, -}: OpeningEditorDialogProps) { +}: OpeningEditorProps) { const opening = (project.openings ?? []).find((o) => o.id === openingId); const isDoor = opening?.kind === "door"; const wt = opening && !isDoor ? getWindowType(project, opening) : undefined; @@ -94,16 +112,11 @@ export function OpeningEditorDialog({ // [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]); + // Name für „Als Stil speichern" (null = Eingabe zu); `window.prompt` ist im Tauri-WKWebView stumm. + const [newStyleName, setNewStyleName] = useState(null); if (!opening) { - // Öffnung verschwand (Undo/Löschen während offen) → Dialog schliesst sich. + // Öffnung verschwand (Undo/Löschen während offen) → nichts zu zeigen. return null; } @@ -137,23 +150,7 @@ export function OpeningEditorDialog({ ); return ( -
-
e.stopPropagation()} - > -
- - {t(isDoor ? "oed.title.door" : "oed.title.window")} - - -
- +
{/* Stil-Leiste: Stil wählen · als Stil speichern · zurücksetzen. */}
{t("oed.style")} @@ -174,17 +171,31 @@ export function OpeningEditorDialog({ type="button" className="oed-btn" title={t("oed.saveStyle.hint")} - onClick={() => { - const name = window.prompt( - t("oed.saveStyle.prompt"), - `${styleName} ${t("oed.saveStyle.copySuffix")}`, - ); - if (name && name.trim()) onSaveAsStyle(name.trim()); - }} + onClick={() => setNewStyleName(newStyleName === null ? `${styleName} ${t("oed.saveStyle.copySuffix")}` : null)} > {t("oed.saveStyle")}
+ {newStyleName !== null && ( +
{ + e.preventDefault(); + if (newStyleName.trim()) onSaveAsStyle(newStyleName.trim()); + setNewStyleName(null); + }} + > + setNewStyleName(e.target.value)} + /> + +
+ )}
{/* 1. Kategorie-Sidebar. */} @@ -244,13 +255,6 @@ export function OpeningEditorDialog({
- -
- -
-
); } diff --git a/src/panels/objectInfo/OpeningSections.tsx b/src/panels/objectInfo/OpeningSections.tsx index 63d99d02..4407f262 100644 --- a/src/panels/objectInfo/OpeningSections.tsx +++ b/src/panels/objectInfo/OpeningSections.tsx @@ -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; }) { 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 ; @@ -57,12 +69,13 @@ export function OpeningSection({ title={t("objinfo.opening.type")} width={106} /> + @@ -103,11 +116,13 @@ export function OpeningSection({ value={opening.width} onCommit={(v) => host.onSetOpeningWidth(v)} /> + host.onSetOpeningHeight(v)} /> + {!isDoor && ( <> host.onSetOpeningSill(v)} /> + {/* Fenster-spezifisch: Flügelanzahl (1–4). */} host.onOpenOpeningEditor(opening.id)} + onClick={openEditor} > ⚙ diff --git a/src/panels/objectInfo/RoofSections.tsx b/src/panels/objectInfo/RoofSections.tsx index d6cf89ba..7833e83f 100644 --- a/src/panels/objectInfo/RoofSections.tsx +++ b/src/panels/objectInfo/RoofSections.tsx @@ -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; }) { 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} /> +
@@ -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" && } {roof.shape === "mansarde" && numField("objinfo.roof.pitchUpper", roof.pitchUpperDeg ?? roof.pitchDeg / 2, 1, (v) => host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }), diff --git a/src/panels/objectInfo/WallSection.tsx b/src/panels/objectInfo/WallSection.tsx index 3a6fe70d..cf2c1490 100644 --- a/src/panels/objectInfo/WallSection.tsx +++ b/src/panels/objectInfo/WallSection.tsx @@ -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; }) { 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 ? {t("objsettings.mixed")} : 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) => ; // 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")} host.onSetWallBottom(a)} /> + {mixedMark(heights?.bottom.mixed, "bottom")} {/* Höhe = OK − UK (abgeleitet, read-only). */}
diff --git a/src/panels/objectInfo/fields.tsx b/src/panels/objectInfo/fields.tsx index 75d6bf49..92f1ef6b 100644 --- a/src/panels/objectInfo/fields.tsx +++ b/src/panels/objectInfo/fields.tsx @@ -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 ? {t("objsettings.mixed")} : null; +} + // ── Decken-Attribut-Abschnitt ──────────────────────────────────────────────── // Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss + // OK-Bindung, Fläche. Alle Werte/Setter über den Host. diff --git a/src/panels/objectInfo/groups.test.ts b/src/panels/objectInfo/groups.test.ts index d428941f..79a257e7 100644 --- a/src/panels/objectInfo/groups.test.ts +++ b/src/panels/objectInfo/groups.test.ts @@ -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(); }); }); diff --git a/src/panels/objectInfo/groups.ts b/src/panels/objectInfo/groups.ts index f8c530a8..5bec4429 100644 --- a/src/panels/objectInfo/groups.ts +++ b/src/panels/objectInfo/groups.ts @@ -15,6 +15,7 @@ export type InfoGroupId = | "roof" | "surfacePattern" | "opening" + | "openingEditor" | "stair" | "room" | "extrudedSolid" @@ -32,6 +33,7 @@ export const INFO_GROUP_TITLE: Record = { 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"); diff --git a/src/panels/objectInfo/useMulti.ts b/src/panels/objectInfo/useMulti.ts new file mode 100644 index 00000000..26779916 --- /dev/null +++ b/src/panels/objectInfo/useMulti.ts @@ -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(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]); +} diff --git a/src/state/mixedValues.test.ts b/src/state/mixedValues.test.ts index 53970130..fc57fbae 100644 --- a/src/state/mixedValues.test.ts +++ b/src/state/mixedValues.test.ts @@ -1,7 +1,7 @@ // [195] Mehrfach-Werte: gleiche Werte → ein Wert, abweichende → leer (gemischt). import { describe, expect, it } from "vitest"; import { buildComplexSampleProject } from "../model/sampleProjectComplex"; -import { commonValue, selectionAppearance, selectionWallValues, selectedCount } from "./mixedValues"; +import { commonValue, selectionAppearance, selectionWallValues, selectedCount, selectionCeilingValues, selectionOpeningValues, selectionRoofValues, selectionWallHeights } from "./mixedValues"; import { EMPTY_SELECTION, mergeSelection } from "./selection"; describe("commonValue [195]", () => { @@ -60,3 +60,47 @@ describe("Mehrfachwerte Füllung/Typ/Masse [195b]", () => { expect(selectionAppearance(changed, sel).hatch.mixed).toBe(true); }); }); + + +describe("Mehrfachwerte Decke, Dach, Öffnung, Höhen [195b]", () => { + const p = buildComplexSampleProject(); + + it("Decken: gleiche Werte → ein Wert, abweichende Oberkante → gemischt", () => { + const [a, b] = p.ceilings!.slice(0, 2).map((c) => c.id); + const same = selectionCeilingValues(p, mergeSelection(EMPTY_SELECTION, { ceilings: [a, a] })); + expect(same.thickness.mixed).toBe(false); + expect(same.top.mixed).toBe(false); + const q = { + ...p, + ceilings: p.ceilings!.map((c) => (c.id === b ? { ...c, top: { mode: "custom" as const, z: 17.5 } } : c)), + }; + const mixed = selectionCeilingValues(q, mergeSelection(EMPTY_SELECTION, { ceilings: [a, b] })); + expect(mixed.top).toEqual({ value: undefined, mixed: true }); + }); + + it("Dächer: abweichende Neigung/Typ → gemischt", () => { + const [a, b] = p.roofs!.slice(0, 2).map((r) => r.id); + const q = { ...p, roofs: p.roofs!.map((r) => (r.id === a ? { ...r, pitchDeg: 20, roofTypeId: undefined } : r.id === b ? { ...r, pitchDeg: 35, roofTypeId: "x" } : r)) }; + const v = selectionRoofValues(q, mergeSelection(EMPTY_SELECTION, { roofs: [a, b] })); + expect(v.pitchDeg.mixed).toBe(true); + expect(v.roofTypeId.mixed).toBe(true); + const one = selectionRoofValues(q, mergeSelection(EMPTY_SELECTION, { roofs: [a] })); + expect(one.pitchDeg).toEqual({ value: 20, mixed: false }); + }); + + it("Öffnungen: abweichende Breite → gemischt, gleiche Höhe → Wert", () => { + const [a, b] = p.openings!.slice(0, 2).map((o) => o.id); + const q = { ...p, openings: p.openings!.map((o) => (o.id === a ? { ...o, width: 1, height: 2, sillHeight: 0.9 } : o.id === b ? { ...o, width: 1.5, height: 2, sillHeight: 0.9 } : o)) }; + const v = selectionOpeningValues(q, mergeSelection(EMPTY_SELECTION, { openings: [a, b] })); + expect(v.width.mixed).toBe(true); + expect(v.height).toEqual({ value: 2, mixed: false }); + expect(v.sillHeight).toEqual({ value: 0.9, mixed: false }); + }); + + it("Wand-Höhen: abweichende Unterkante → gemischt", () => { + const [a, b] = p.walls.slice(0, 2).map((w) => w.id); + const q = { ...p, walls: p.walls.map((w) => (w.id === b ? { ...w, bottom: { mode: "custom" as const, z: 0.37 } } : w)) }; + const v = selectionWallHeights(q, mergeSelection(EMPTY_SELECTION, { walls: [a, b] })); + expect(v.bottom.mixed).toBe(true); + }); +}); diff --git a/src/state/mixedValues.ts b/src/state/mixedValues.ts index 10b10ff2..76f8642c 100644 --- a/src/state/mixedValues.ts +++ b/src/state/mixedValues.ts @@ -73,3 +73,91 @@ export function selectionWallValues(project: Project, sel: Selection): Selection } return { wallTypeId: commonValue(types), thickness: commonValue(thick) }; } + +/** Schlüssel einer Höhenangabe (Anker + aufgelöstes Z), damit gleiche Lagen als gleich gelten. */ +function heightKey(anchor: unknown, z: number): string { + return `${JSON.stringify(anchor ?? null)}|${Math.round(z * 1e6)}`; +} + +/** [195b] Unter-/Oberkante der gewählten Wände. */ +export interface SelectionHeights { + bottom: Common; + top: Common; +} + +/** Wandtyp/Dicke und Höhen: eine Abfrage je Wand. */ +export function selectionWallHeights(project: Project, sel: Selection): SelectionHeights { + const b: string[] = []; + const t: string[] = []; + for (const id of sel.walls.slice(0, MAX_COMPARED)) { + const w = deriveSelection(project, { walls: [id] })?.wall; + if (!w) continue; + b.push(heightKey(w.bottom, w.zBottom)); + t.push(heightKey(w.top, w.zTop)); + } + return { bottom: commonValue(b), top: commonValue(t) }; +} + +/** [195b] Typ, Dicke und Höhen der gewählten Decken. */ +export interface SelectionCeilingValues extends SelectionHeights { + typeId: Common; + thickness: Common; +} + +export function selectionCeilingValues(project: Project, sel: Selection): SelectionCeilingValues { + const types: string[] = []; + const thick: number[] = []; + const b: string[] = []; + const t: string[] = []; + for (const id of sel.ceilings.slice(0, MAX_COMPARED)) { + const c = deriveSelection(project, { ceilings: [id] })?.ceiling; + if (!c) continue; + types.push(c.typeId); + thick.push(c.thickness); + b.push(heightKey(c.bottom, c.zBottom)); + t.push(heightKey(c.top, c.zTop)); + } + return { typeId: commonValue(types), thickness: commonValue(thick), bottom: commonValue(b), top: commonValue(t) }; +} + +/** [195b] Typ und Neigung der gewählten Dächer. */ +export interface SelectionRoofValues { + roofTypeId: Common; + pitchDeg: Common; +} + +export function selectionRoofValues(project: Project, sel: Selection): SelectionRoofValues { + const types: string[] = []; + const pitch: number[] = []; + for (const id of sel.roofs.slice(0, MAX_COMPARED)) { + const r = deriveSelection(project, { roofs: [id] })?.roof; + if (!r) continue; + types.push(r.roofTypeId ?? ""); + pitch.push(r.pitchDeg); + } + return { roofTypeId: commonValue(types), pitchDeg: commonValue(pitch) }; +} + +/** [195b] Breite, Höhe, Brüstung und Typ der gewählten Öffnungen. */ +export interface SelectionOpeningValues { + width: Common; + height: Common; + sillHeight: Common; + typeId: Common; +} + +export function selectionOpeningValues(project: Project, sel: Selection): SelectionOpeningValues { + const w: number[] = []; + const h: number[] = []; + const s: number[] = []; + const ty: string[] = []; + for (const id of sel.openings.slice(0, MAX_COMPARED)) { + const o = deriveSelection(project, { openings: [id] })?.opening; + if (!o) continue; + w.push(o.width); + h.push(o.height); + s.push(o.sillHeight); + ty.push(o.typeId ?? ""); + } + return { width: commonValue(w), height: commonValue(h), sillHeight: commonValue(s), typeId: commonValue(ty) }; +} diff --git a/src/state/panelHost/elementAttributesHost.test.ts b/src/state/panelHost/elementAttributesHost.test.ts index 63cba138..63d7e13a 100644 --- a/src/state/panelHost/elementAttributesHost.test.ts +++ b/src/state/panelHost/elementAttributesHost.test.ts @@ -26,3 +26,78 @@ describe("onSetWallType [195b]", () => { expect(getState().undoDepth).toBe(depth + 1); }); }); + +type Host = Record void>; +function hostFor(kind: string, id: string): Host { + const s = getState(); + return buildElementAttributesHost({ + applyChange: s.applyChange, + updateWall: s.updateWall, + updateCeiling: s.updateCeiling, + updateOpening: s.updateOpening, + updateRoof: s.updateRoof, + setWallThickness: s.setWallThickness, + setCeilingThickness: s.setCeilingThickness, + selection: { kind, id }, + } as unknown as FlatHostOpts) as unknown as Host; +} + +describe("Mehrfachauswahl setzt alle gewählten Elemente in einem Schritt [195b]", () => { + it("Öffnungen: Breite und Brüstung gelten für alle, je ein Undo-Schritt", () => { + getState().loadProject(buildComplexSampleProject()); + const [a, b] = getState().project.openings!; + setState({ selection: { ...EMPTY_SELECTION, openings: [a.id, b.id] } }); + const host = hostFor("opening", a.id); + const depth = getState().undoDepth; + (host.onSetOpeningWidth as (w: number) => void)(1.234); + const os = getState().project.openings!; + expect(os.find((o) => o.id === a.id)!.width).toBe(1.234); + expect(os.find((o) => o.id === b.id)!.width).toBe(1.234); + expect(getState().undoDepth).toBe(depth + 1); + (host.onSetOpeningSill as (w: number) => void)(0.77); + expect(getState().project.openings!.find((o) => o.id === b.id)!.sillHeight).toBe(0.77); + expect(getState().undoDepth).toBe(depth + 2); + }); + + it("Decken: Oberkante und Dicke für alle, je ein Undo-Schritt", () => { + getState().loadProject(buildComplexSampleProject()); + const [a, b] = getState().project.ceilings!; + setState({ selection: { ...EMPTY_SELECTION, ceilings: [a.id, b.id] } }); + const host = hostFor("ceiling", a.id); + let depth = getState().undoDepth; + (host.onSetCeilingTop as (x: unknown) => void)({ mode: "custom", z: 9.5 }); + const cs = getState().project.ceilings!; + expect(cs.find((c) => c.id === b.id)!.top).toEqual({ mode: "custom", z: 9.5 }); + expect(getState().undoDepth).toBe(depth + 1); + depth = getState().undoDepth; + (host.onSetCeilingThickness as (x: number) => void)(0.31); + expect(getState().undoDepth).toBe(depth + 1); + getState().undo(); + expect(getState().undoDepth).toBe(depth); + }); + + it("Dächer: Neigung für alle; andere Felder nur für das erste", () => { + getState().loadProject(buildComplexSampleProject()); + const [a, b] = getState().project.roofs!; + setState({ selection: { ...EMPTY_SELECTION, roofs: [a.id, b.id] } }); + const host = hostFor("roof", a.id); + (host.onSetRoofPatch as (p: object) => void)({ pitchDeg: 33 }); + expect(getState().project.roofs!.find((r) => r.id === b.id)!.pitchDeg).toBe(33); + (host.onSetRoofPatch as (p: object) => void)({ overhang: 0.77 }); + const r2 = getState().project.roofs!; + expect(r2.find((r) => r.id === a.id)!.overhang).toBe(0.77); + expect(r2.find((r) => r.id === b.id)!.overhang).not.toBe(0.77); + }); + + it("Wände: Unterkante und Dicke für alle", () => { + getState().loadProject(buildComplexSampleProject()); + const [a, b] = getState().project.walls; + setState({ selection: { ...EMPTY_SELECTION, walls: [a.id, b.id] } }); + const host = hostFor("wall", a.id); + (host.onSetWallBottom as (x: unknown) => void)({ mode: "custom", z: 0.2 }); + expect(getState().project.walls.find((w) => w.id === b.id)!.bottom).toEqual({ mode: "custom", z: 0.2 }); + const depth = getState().undoDepth; + (host.onSetWallThickness as (x: number) => void)(0.29); + expect(getState().undoDepth).toBe(depth + 1); + }); +}); diff --git a/src/state/panelHost/elementAttributesHost.ts b/src/state/panelHost/elementAttributesHost.ts index 45411fe8..6b1ae3a1 100644 --- a/src/state/panelHost/elementAttributesHost.ts +++ b/src/state/panelHost/elementAttributesHost.ts @@ -7,8 +7,31 @@ import { patchItem, patchItems, removeRoofHole, setRoofEdge } from "../../core"; import { getState } from "../appStore"; import type { FlatHostOpts, HostPart } from "./types"; +type MultiCollection = "walls" | "ceilings" | "roofs" | "openings"; + +/** + * [195b] Ziele einer Änderung: bei Mehrfachauswahl gleicher Art alle gewählten Elemente (in einem Undo-Schritt + * zu setzen), sonst nur das Objekt der Objekt-Info. + */ +function targetIds(collection: MultiCollection, id: string): string[] { + const ids = getState().selection[collection]; + return ids.length > 1 && ids.includes(id) ? [...ids] : [id]; +} + +/** Dach-Felder, die bei Mehrfachauswahl für alle gewählten Dächer gelten (Rest: nur das erste). */ +const ROOF_MULTI_KEYS: ReadonlySet = new Set(["roofTypeId", "pitchDeg"]); + export function buildElementAttributesHost(c: FlatHostOpts) { - const { applyChange, onOpenStampEditor, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, setCeilingThickness, setOpeningEditorId, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c; + const { applyChange, onOpenStampEditor, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c; + /** Patch auf alle Ziele (s. {@link targetIds}); ein Element: wie bisher über die Einzel-Aktion. */ + function patchAll(collection: K, id: string, patch: Record, coalesceKey?: string): void { + const ids = targetIds(collection, id); + if (ids.length > 1) applyChange((p) => patchItems(p, collection, ids, (e) => ({ ...(e as object), ...patch }) as typeof e), coalesceKey); + else if (collection === "walls") updateWall(id, patch, coalesceKey); + else if (collection === "ceilings") updateCeiling(id, patch); + else if (collection === "roofs") updateRoof(id, patch, coalesceKey); + else updateOpening(id, patch); + } return { // ── Wand-Attribute (nur bei selektierter Wand) ───────────────────────── onSetWallReferenceLine: (ref) => { @@ -47,32 +70,30 @@ export function buildElementAttributesHost(c: FlatHostOpts) { if (selection?.kind === "ceiling") updateCeiling(selection.id, { edgeAtOutline: edgeAtOutline || undefined }); }, onSetWallType: (wallTypeId) => { - if (selection?.kind !== "wall") return; // [195b] Mehrfachauswahl: alle gewählten Wände bekommen den Typ (ein Undo-Schritt). - const ids = getState().selection.walls; - if (ids.length > 1) applyChange((p) => patchItems(p, "walls", ids, (w) => ({ ...w, wallTypeId }))); - else updateWall(selection.id, { wallTypeId }); + if (selection?.kind === "wall") patchAll("walls", selection.id, { wallTypeId }); }, onSetWallThickness: (thickness) => { - if (selection?.kind === "wall") - setWallThickness(selection.id, thickness); + if (selection?.kind !== "wall") return; + const ids = targetIds("walls", selection.id); + if (ids.length === 1) setWallThickness(selection.id, thickness); + else getState().groupChanges(() => ids.forEach((id) => setWallThickness(id, thickness))); }, onSetWallBottom: (anchor) => { - if (selection?.kind === "wall") - updateWall(selection.id, { bottom: anchor ?? undefined }); + if (selection?.kind === "wall") patchAll("walls", selection.id, { bottom: anchor ?? undefined }); }, onSetWallTop: (anchor) => { - if (selection?.kind === "wall") - updateWall(selection.id, { top: anchor ?? undefined }); + if (selection?.kind === "wall") patchAll("walls", selection.id, { top: anchor ?? undefined }); }, // ── Decken-Attribute (nur bei selektierter Decke) ────────────────────── onSetCeilingType: (ceilingTypeId) => { - if (selection?.kind === "ceiling") - updateCeiling(selection.id, { ceilingTypeId, thickness: undefined }); + if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { ceilingTypeId, thickness: undefined }); }, onSetCeilingThickness: (thickness) => { - if (selection?.kind === "ceiling") - setCeilingThickness(selection.id, thickness); + if (selection?.kind !== "ceiling") return; + const ids = targetIds("ceilings", selection.id); + if (ids.length === 1) setCeilingThickness(selection.id, thickness); + else getState().groupChanges(() => ids.forEach((id) => setCeilingThickness(id, thickness))); }, onRemoveCeilingOpening: (index) => { if (selection?.kind !== "ceiling") return; @@ -83,12 +104,10 @@ export function buildElementAttributesHost(c: FlatHostOpts) { }); }, onSetCeilingTop: (anchor) => { - if (selection?.kind === "ceiling") - updateCeiling(selection.id, { top: anchor ?? undefined }); + if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { top: anchor ?? undefined }); }, onSetCeilingBottom: (anchor) => { - if (selection?.kind === "ceiling") - updateCeiling(selection.id, { bottom: anchor ?? undefined }); + if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { bottom: anchor ?? undefined }); }, // ── Öffnungs-Attribute (nur bei selektierter Öffnung) ────────────────── onSetOpeningKind: (kind) => { @@ -101,16 +120,13 @@ export function buildElementAttributesHost(c: FlatHostOpts) { ); }, onSetOpeningWidth: (width) => { - if (selection?.kind === "opening" && width > 0) - updateOpening(selection.id, { width }); + if (selection?.kind === "opening" && width > 0) patchAll("openings", selection.id, { width }); }, onSetOpeningHeight: (height) => { - if (selection?.kind === "opening" && height > 0) - updateOpening(selection.id, { height }); + if (selection?.kind === "opening" && height > 0) patchAll("openings", selection.id, { height }); }, onSetOpeningSill: (sillHeight) => { - if (selection?.kind === "opening" && sillHeight >= 0) - updateOpening(selection.id, { sillHeight }); + if (selection?.kind === "opening" && sillHeight >= 0) patchAll("openings", selection.id, { sillHeight }); }, onSetOpeningPosition: (position) => { if (selection?.kind !== "opening" || !Number.isFinite(position)) return; @@ -166,16 +182,20 @@ export function buildElementAttributesHost(c: FlatHostOpts) { // Typ-Zuweisung (Bibliothek): Tür-/Fenstertyp per typeId; leerer String löst // die Zuweisung wieder (Inline-Verhalten). onSetOpeningType: (typeId) => { - if (selection?.kind === "opening") - updateOpening(selection.id, { typeId: typeId || undefined }); + if (selection?.kind === "opening") patchAll("openings", selection.id, { typeId: typeId || undefined }); }, onEditOpeningType: (kind) => { openResources(kind === "door" ? "doorStyles" : "windowStyles"); }, - onOpenOpeningEditor: (id) => setOpeningEditorId(id), + onPatchWindowType: patchWindowType, + onPatchDoorType: patchDoorType, + onSaveOpeningStyle: saveOpeningStyle, // ── Dach-Attribute (nur bei selektiertem Dach) ───────────────────────── onSetRoofPatch: (patch, coalesceKey) => { - if (selection?.kind === "roof") updateRoof(selection.id, patch, coalesceKey); + if (selection?.kind !== "roof") return; + const multi = Object.keys(patch).every((k) => ROOF_MULTI_KEYS.has(k)); + if (multi) patchAll("roofs", selection.id, patch, coalesceKey); + else updateRoof(selection.id, patch, coalesceKey); }, onSetRoofEdge: (index, spec) => { if (selection?.kind !== "roof") return; diff --git a/src/state/panelHost/types.ts b/src/state/panelHost/types.ts index 75665636..0a9a2322 100644 --- a/src/state/panelHost/types.ts +++ b/src/state/panelHost/types.ts @@ -106,6 +106,9 @@ export type PanelHostOpts = { | "updateWall" | "setWallThickness" | "updateOpening" + | "patchWindowType" + | "patchDoorType" + | "saveOpeningStyle" | "slideOpening" | "updateCeiling" | "setCeilingThickness" @@ -137,7 +140,7 @@ export type PanelHostOpts = { | "selectedViewSnapshotId" | "setSelectedViewSnapshotId" >; - dialogState: Pick, "setActiveLayoutId" | "setOpeningEditorId">; + dialogState: Pick, "setActiveLayoutId">; contextMenuState: Pick, "setMenu">; }; diff --git a/src/state/projectSlice.ts b/src/state/projectSlice.ts index 2d939372..882eafb6 100644 --- a/src/state/projectSlice.ts +++ b/src/state/projectSlice.ts @@ -1281,7 +1281,7 @@ export function createProjectSlice( op: "wallThickness", id: wallId, thickness, - newId: `wt-${Date.now()}`, + newId: uniqueId("wt"), newName: t("default.wallTypeSingle", { thickness: thickness.toFixed(2) }), }), @@ -1337,7 +1337,7 @@ export function createProjectSlice( op: "ceilingThickness", id: ceilingId, thickness, - newId: `ct-${Date.now()}`, + newId: uniqueId("ct"), newName: t("default.ceilingTypeSingle", { thickness: thickness.toFixed(2) }), }), @@ -1350,7 +1350,7 @@ export function createProjectSlice( b: from, // Griffhöhe vor dem Zug: Dach, Treppe, Gelände zählen den Zug relativ index, // Höhenlinie `contourLine` free: !!free, - newId: `ct-${Date.now()}`, + newId: uniqueId("ct"), newName: t("default.ceilingTypeSingle", { thickness: "{t}" }), // {t} setzt der Kern ein }), diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 4f20c952..366fb0d7 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -605,13 +605,16 @@ export function deriveSelection(project: Project, selection: Partial) const args = { wallIds: sel.walls, drawingId: single(sel, "drawings"), - ceilingId: single(sel, "ceilings"), - openingId: single(sel, "openings"), + // [195b] Decken, Öffnungen und Dächer: bei Mehrfachauswahl führt das erste Element die Anzeige; die + // Setter des Panel-Hosts (`elementAttributesHost`) wirken auf alle gewählten, die Abschnitte kennzeichnen + // abweichende Werte („gemischt", `mixedValues.ts`). + ceilingId: sel.ceilings[0] ?? null, + openingId: sel.openings[0] ?? null, stairId: single(sel, "stairs"), roomId: single(sel, "rooms"), extrudedSolidId: single(sel, "solids"), columnId: single(sel, "columns"), - roofId: single(sel, "roofs"), + roofId: sel.roofs[0] ?? null, contextObjectId: single(sel, "contextObjects"), }; // Das Element sucht der Kern über den Positions-Index des Dokuments (keine lineare Suche). diff --git a/src/state/useDialogState.ts b/src/state/useDialogState.ts index 9c4e42d0..f2615b6e 100644 --- a/src/state/useDialogState.ts +++ b/src/state/useDialogState.ts @@ -22,9 +22,6 @@ export function useDialogState() { // Angeforderter Start-Tab des Ressourcen-Fensters (z. B. „doorStyles", wenn man // von einer gewählten Tür in den Typeditor springt). const [resourcesTab, setResourcesTab] = useState("components"); - // Offener Fenster-/Tür-Einstellungsdialog (⚙ der OpeningSection) — ID der - // editierten Öffnung, oder null wenn geschlossen. - const [openingEditorId, setOpeningEditorId] = useState(null); // Aktives Layout-Blatt im HAUPT-Viewport (DOSSIER A3, Phase 2b): Id des offenen // Layouts oder null (= normale Modell-Ansicht). Transienter UI-State; das @@ -65,8 +62,6 @@ export function useDialogState() { setResourcesOpen, resourcesTab, setResourcesTab, - openingEditorId, - setOpeningEditorId, activeLayoutId, setActiveLayoutId, importState, diff --git a/src/styles.css b/src/styles.css index a475f43a..c184b3bc 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5800,7 +5800,7 @@ body { border-color: var(--ctx-danger); } -/* ── Fenster-/Tür-Einstellungsdialog (OpeningEditorDialog) ────────────────── +/* ── Fenster-/Tür-Einstellungsdialog (OpeningEditor, Abschnitt der Objekt-Info) ────────────────── Drei Zonen (Sidebar · Panel · Ansicht) unter einer Stil-Leiste. Nutzt sonst die imp-*-Klassen (Overlay/Head/Foot). */ .oed-dialog { @@ -5814,6 +5814,30 @@ body { box-shadow: var(--shadow-3); overflow: hidden; } +/* Eingebettet im Objekteinstellungs-Fenster: schmal, Sidebar als Reihe über dem Parameter-Panel. */ +.oed-dialog.oed-embedded { + width: auto; + max-height: none; + border: 0; + border-radius: 0; + box-shadow: none; + background: transparent; +} +.oed-embedded .oed-main { + grid-template-columns: 1fr; + min-height: 0; + overflow: visible; +} +.oed-embedded .oed-sidebar { + flex-direction: row; + flex-wrap: wrap; + width: auto; + border-right: 0; +} +.oed-embedded .oed-stylebar { + padding: 6px 0; + flex-wrap: wrap; +} .oed-stylebar { display: flex; align-items: center; diff --git a/src/ui/AppDialogs.tsx b/src/ui/AppDialogs.tsx index 6cb8225f..a88d9c4b 100644 --- a/src/ui/AppDialogs.tsx +++ b/src/ui/AppDialogs.tsx @@ -28,7 +28,6 @@ import { ExportSaveDialog } from "./ExportSaveDialog"; import { IfcImportDialog, IfcImportReportDialog } from "./IfcImportDialog"; import { ImportDialog } from "./ImportDialog"; import { LockConflictDialog } from "./LockConflictDialog"; -import { OpeningEditorDialog } from "./OpeningEditorDialog"; import { PresentationDialogHost } from "./PresentationDialog"; import { PromptDialog } from "./PromptDialog"; import { RecoverAutosaveDialog } from "./RecoverAutosaveDialog"; @@ -96,8 +95,6 @@ export function AppDialogs(props: { resourcesOpen, setResourcesOpen, resourcesTab, - openingEditorId, - setOpeningEditorId, setActiveLayoutId, importState, setImportState, @@ -131,10 +128,10 @@ export function AppDialogs(props: { const { pendingIfc, setPendingIfc, ifcReport, setIfcReport, runIfcImport } = props.modelImport; const { themeMode, setThemeMode, offline, onOfflineChange, aiAccess, setScaleLineWeights, setLineEnds } = props.settings; const { exportContentMeters, onExportPdf, onExportSvg, onExportDxf } = props.planExport; - const { patchWindowType, patchDoorType, updateOpening, saveOpeningStyle, setRoomStamp, setRoomStampDoc } = props.pa; + const { setRoomStamp, setRoomStampDoc } = props.pa; // Das Projekt nur abonnieren, solange ein Dialog offen ist, der es zeigt ([121]): sonst rendert eine Op // am Modell hier nichts. `App` reicht es nicht mehr durch. - const needsProject = resourcesOpen || openingEditorId != null || !!importState || settingsOpen; + const needsProject = resourcesOpen || !!importState || settingsOpen; const subscribed = useStore((s) => (needsProject ? s.project : null)); const project = subscribed ?? getState().project; return ( @@ -153,20 +150,6 @@ export function AppDialogs(props: { /> )} - {/* Reicher Fenster-/Tür-Einstellungsdialog (⚙ der OpeningSection). */} - {openingEditorId != null && ( - updateOpening(openingEditorId, patch)} - onSetOpeningType={(typeId) => updateOpening(openingEditorId, { typeId: typeId || undefined })} - onSaveAsStyle={(name) => saveOpeningStyle(openingEditorId, name)} - onClose={() => setOpeningEditorId(null)} - /> - )} - diff --git a/src/ui/ElevationPreview.tsx b/src/ui/ElevationPreview.tsx index 73c3d8f1..3c556a93 100644 --- a/src/ui/ElevationPreview.tsx +++ b/src/ui/ElevationPreview.tsx @@ -1,7 +1,7 @@ // Frontal-Ansicht (Elevation, SVG) eines Fensters/einer Tür: Rahmen, Flügel/ // Pfosten (mit Öffnungslinien je Flügel), Verglasungshinweis und Rollladen- // kasten. Rein aus den Modellwerten gezeichnet — kein Renderer-Roundtrip, -// deterministisch. Ursprünglich Teil von {@link OpeningEditorDialog} (dort +// deterministisch. Ursprünglich Teil von `OpeningEditor` (dort // mit einer echten Öffnungs-Instanz gefüttert); hierher extrahiert, damit // auch die Typ-Bibliothek (ResourceManager, ohne konkrete Instanz — s. // `WindowStylesTab`/`DoorStylesTab`) dieselbe Vorschau zeigen kann. Braucht diff --git a/src/ui/README.md b/src/ui/README.md index fef230d7..e67d0409 100644 --- a/src/ui/README.md +++ b/src/ui/README.md @@ -39,7 +39,7 @@ liegen in `src/panels`, Befehle in `src/commands`. |---|---| | `LayoutSheet.tsx`, `layoutSheetMath.ts`, `LayoutCreateDialogs.tsx`, `SheetTableHud.tsx` | Layout-Blatt im Haupt-Viewport, Treffer- und Resize-Rechnung der Viewports, Erstell-Dialoge, Eigenschaften einer Blatt-Tabelle | | `TextEditorDialog.tsx`, `RoomStampEditorHost.tsx` | Rich-Text-Editor, Stempel-Editor eines Raums | -| `OpeningEditorDialog.tsx`, `OpeningDetailPanels.tsx`, `ElevationPreview.tsx` | Fenster-/Tür-Dialog, Detail-Panels, Ansichtsvorschau | +| `OpeningDetailPanels.tsx`, `ElevationPreview.tsx` | Detail-Panels des Fenster-/Türeditors (der Editor selbst: `panels/objectInfo/OpeningEditor.tsx`), Ansichtsvorschau | ## Unterordner