Merge [195b] Mehrfachauswahl restliche Setter

This commit is contained in:
Claude committed 2026-11-12 04:08:03 +00:00
commit 57c475b5e0
16 files changed
+382 -117

No files matched your search

+1 -4
View File
@@ -87,10 +87,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
nicht in der Tauri-App/auf dem Mac geprüft. · M
- ◐ **[193]** Anwählen/Bearbeiten von Gelände & Co. (12.11., Maintainer, PRIO; Stand 11.11.): **erledigt** — Cmd+A nimmt Gelände, Höhenlinien, Baugrube, Netze, Bilder mit (sichtbare, nicht gesperrte Klasse; reine Funktion `state/selectAll.ts`) und die Schattenfläche der Sonnenstudie (`site: sunStudy`); Entf löscht sie in einem Undo-Schritt (Schatten: blendet `sunStudy.show` aus). Die „nicht lösch-/anwählbare Schraffur" war der Schatten der Sonnenstudie (abgeleitet aus den Geschossen, die Cmd+A nicht erfasst, Loch = Treppenöffnung); er war schon anwählbar ([137]), aber Entf tat nichts. Verschieben/Kopieren/Drehen/Spiegeln für Kontext-Elemente (Kern `cmd_transform.rs`, `contextIds`; Baugrube, Höhenlinien, Netze, Bild); Objekt-Info: Höhenversatz für Gelände/Netz/Höhenlinien/Baugrube und Höhe je Höhenlinie (`state/contextHeight.ts`, TS-Hilfe, später in den Kern). Baugrube war im Grundriss schon anwählbar (Kern-Pick) und hat Eckgriffe (`useGripEditing`); e2e `selectAllContext.spec.ts`. **Update 11.11. (Rest):** Höhen-Helfer nach Rust (`cmd_context.rs`: `contextOffset`/`contourZ`, TS-Fassung `contextHeight.ts` gelöscht; Store `offsetContextHeight`/`setContourHeight`); Maus-Ziehen im Plan für gewählte Kontext-Elemente (Baugrube, Höhenlinien, Netze, Bild: Vorschau und Ops aus dem Kern-Transform, Fang auf den ersten Punkt, ein Undo-Schritt, `moveContextBy`); Höhenlinien-Punkte als Griffe (`contourGrip`/`contourInsert` in `grips.rs`, Einfüge-Rauten wie [26], ein Undo-Schritt je Zug; ab 600 Punkten keine Griffe, ab 100 keine Rauten); Entf und Cmd+A auf den Ansichts-Schlagschatten (`viewShadows`) blenden `shadows` der Ansicht aus. e2e `contextDrag.spec.ts`. **Offen:** Gelände-Netz zuschneiden/Punkte editieren; Höhenlinien-Punkt löschen (Kontextmenü); Aufräumen eingefügter Punkte beim Zurückziehen. · M
- ◐ **[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 als Ops-Strom, 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). **12.11. Ops-Strom:** das Hauptfenster schickt die vom Kern-Dokument angenommenen Ops (Commit/Griff/Befehl/Import/Undo/Redo, `ProjectDocument.onChange`) mit laufender Nummer `seq`; das Fenster führt sie ohne Verlauf nach (`applyRemote` = `doc_apply` + `applyOps`, kein Rust nötig). Rückfall Feld-Differenz + Vollabgleich bei Laden/Neu, grossem Verlaufsschritt ohne Ops; Lücke in `seq` oder abgelehnte Ops → Fenster fordert den ganzen Stand an. Messung Grossgebäude (1832 Wände, Linux-Container): Sync einer Wandänderung 0.4 ms statt 56 ms. 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); 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
- ○ **[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
- ◐ **[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. **12.11. Ops-Strom:** das Hauptfenster schickt die vom Kern-Dokument angenommenen Ops (Commit/Griff/Befehl/Import/Undo/Redo, `ProjectDocument.onChange`) mit laufender Nummer `seq`; das Fenster führt sie ohne Verlauf nach (`applyRemote` = `doc_apply` + `applyOps`, kein Rust nötig). Rückfall Feld-Differenz + Vollabgleich bei Laden/Neu, grossem Verlaufsschritt ohne Ops; Lücke in `seq` oder abgelehnte Ops → Fenster fordert den ganzen Stand an. Messung Grossgebäude (1832 Wände, Linux-Container): Sync einer Wandänderung 0.4 ms statt 56 ms. Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`. **Stand 12.11. (3):** Mehrfachauswahl setzt jetzt auch Referenzlinie/Fugen-Versatz/Terminierung/Dachanschluss/Aussen+tragend (Wand, Decke), alle Öffnungs-Felder (nur Öffnungen GLEICHER Art Fenster/Tür; Position und Dach-/Deckenfenster-Lage bewusst nur das erste), den Fenster-/Türeditor (`onPatchOpening`, Typ-Zuweisung; ein Undo-Schritt), Treppe, Raum (SIA, Nutzung, Oberflächen; der Name bleibt je Raum eigen, Feld gesperrt), Stütze und Körper (`patchAll`/`mapAll`, `targetIds` im `elementAttributesHost`); `deriveSelection` führt auch bei mehreren Treppen/Räumen/Körpern/Stützen mit dem ersten Element; „gemischt“ für Referenzlinie, Treppe (Typ/Form/Breite/Stufen/Steighöhe), Öffnungs-Anschlag/Aufschlag/Richtung/Flügel, Raum-SIA, Höhe von Stütze/Körper. Dach-Kanten, Gauben und Innenhöfe sind dachspezifisch: nur bei EINEM Dach angeboten. Tests `native/objectSettingsSync.test.ts`, `objectSettingsWindow.render.test.ts`, `state/mixedValues.test.ts`, `panelHost/elementAttributesHost.test.ts`, `objectInfo/OpeningEditor.render.test.ts`. **Offen:** NICHT auf macOS gebaut/getestet (nur vitest/tsc im Linux-Container; Capability `object-settings` ergänzt, kein Rust); kein Messwert (Live-Mass) im Fenster; Gelände/Baugrube haben keinen Setter im Objekt-Info (nichts umgestellt); Dach-Felder ausser Typ/Neigung (Dicke, Traufhöhe …) setzen bei Mehrfachauswahl weiter nur das erste Dach. · 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
Textfelder/Masszahlen/Beschriftungen (mehrzeilig, Umbruch, fett/kursiv, Ausrichtung) über denselben Glyphen-Pass
+2
View File
@@ -491,6 +491,8 @@ export interface PanelHostValue {
onSetOpeningSashLine: (v: { color?: string; weight?: number } | undefined) => void;
/** Übersteuert Farbe/Strichstärke der Auf-/Untersicht-Andeutung (Sims). */
onSetOpeningSillLineStyle: (v: { color?: string; weight?: number } | undefined) => void;
/** Öffnungs-Editor: Instanz-Felder der gewählten Öffnung(en) gleicher Art (Position nur das erste Element). */
onPatchOpening: (patch: Partial<import("../model/types").Opening>) => void;
/** Weist der Öffnung einen Tür-/Fenstertyp (Bibliothek) zu; "" löst die Zuweisung. */
onSetOpeningType: (typeId: string) => void;
/**
@@ -34,4 +34,19 @@ describe("Objekteinstellungen: Öffnung [195b]", () => {
setState({ selection: { ...EMPTY_SELECTION, openings: [a.id] } });
expect(render()).not.toContain('data-mixed="width"');
});
it("zwei Treppen mit abweichender Breite: Treppen-Abschnitt mit „gemischt“; zwei Dächer ohne Gauben-/Kantenabschnitt", () => {
const p = buildComplexSampleProject();
const [a, b] = p.stairs!;
getState().loadProject({ ...p, stairs: p.stairs!.map((x) => (x.id === a.id ? { ...x, width: 1 } : x.id === b.id ? { ...x, width: 1.3 } : x)) });
setState({ selection: { ...EMPTY_SELECTION, stairs: [a.id, b.id] } });
expect(render()).toContain('data-mixed="width"');
const [r1, r2] = getState().project.roofs!;
setState({ selection: { ...EMPTY_SELECTION, roofs: [r1.id] } });
const single = render();
setState({ selection: { ...EMPTY_SELECTION, roofs: [r1.id, r2.id] } });
const multi = render();
expect(multi).not.toContain("objinfo-dormer");
expect(multi.length).toBeLessThan(single.length);
});
});
+4 -3
View File
@@ -45,15 +45,16 @@ type CatId =
/** 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);
// [195b] Mehrfachauswahl: Instanz-Felder und Typ-Zuweisung gelten für alle gewählten Öffnungen gleicher Art
// (Host-Handler, ein Undo-Schritt); Typ-Felder wirken ohnehin auf alle Öffnungen des Stils.
return (
<OpeningEditor
openingId={openingId}
project={project}
onPatchWindowType={host.onPatchWindowType}
onPatchDoorType={host.onPatchDoorType}
onPatchOpening={(patch) => updateOpening(openingId, patch)}
onSetOpeningType={(typeId) => updateOpening(openingId, { typeId: typeId || undefined })}
onPatchOpening={host.onPatchOpening}
onSetOpeningType={host.onSetOpeningType}
onSaveAsStyle={(name) => host.onSaveOpeningStyle(openingId, name)}
/>
);
@@ -138,6 +138,7 @@ export function OpeningSection({
min={1}
onCommit={(v) => host.onSetOpeningWingCount(Math.max(1, Math.min(4, Math.round(v))))}
/>
<MixedMark on={multi?.wingCount.mixed} what="wingCount" />
{/* Grundriss-Linien je Kategorie: Rahmen (Blendrahmen+Stulp), Fenster
(Flügelrahmen/Sprossen), Sims (Auf-/Untersicht, nur wenn der
Fenstertyp sie aktiviert hat — s. WindowType.sillLine). */}
@@ -249,6 +250,7 @@ export function OpeningSection({
title={t("objinfo.opening.hinge")}
width={130}
/>
<MixedMark on={multi?.hinge.mixed} what="hinge" />
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.opening.swing")}</span>
@@ -262,6 +264,7 @@ export function OpeningSection({
title={t("objinfo.opening.swing")}
width={130}
/>
<MixedMark on={multi?.swing.mixed} what="swing" />
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.opening.dir")}</span>
@@ -275,6 +278,7 @@ export function OpeningSection({
title={t("objinfo.opening.dir")}
width={130}
/>
<MixedMark on={multi?.openingDir.mixed} what="openingDir" />
</div>
<DimensionField
label={t("objinfo.opening.swingAngle")}
+5 -3
View File
@@ -339,12 +339,14 @@ export function RoofSection({
{/* Kanten: Neigung je Kante (leer = Standard) und Giebel ([26]). Wirkt bei Sattel/Walm/
Mansarde/Zelt; Flach und Pult ignorieren sie. */}
{roof.shape !== "flach" && roof.shape !== "pult" && (
{/* [195b] Kanten, Gauben und Innenhöfe gehören zu genau einem Dach (Indizes/Ids sind dachspezifisch): bei
Mehrfachauswahl nicht angeboten (`multi`), die Host-Setter wirken dort ohnehin nur auf das erste Dach. */}
{!multi && roof.shape !== "flach" && roof.shape !== "pult" && (
<RoofEdgesSection roof={roof} host={host} />
)}
{/* Innenhöfe: Liste mit Entfernen, Hinzufügen über den Befehl „Dachhof“. */}
<DormersSection roof={roof} host={host} />
{roof.shape !== "pult" && (
{!multi && <DormersSection roof={roof} host={host} />}
{!multi && roof.shape !== "pult" && (
<>
<div className="objinfo-sep" />
<div className="objinfo-section-label">{t("objinfo.roof.courts")}</div>
+15 -3
View File
@@ -6,10 +6,13 @@ import { usePanelHost } from "../host";
import { t } from "../../i18n";
import { Dropdown } from "../../ui/Dropdown";
import type { SiaCategory, Project, Room } from "../../model/types";
import { SIA_CATEGORIES, siaLabelFull, patchItem, roomBook, ROOM_USAGES, usageLabel } from "../../core";
import { SIA_CATEGORIES, siaLabelFull, patchItems, roomBook, ROOM_USAGES, usageLabel } from "../../core";
import { formatM } from "../../model/types";
import { useStore } from "../../state/appStore";
import type { TranslationKey } from "../../i18n";
import { selectionRoomValues } from "../../state/mixedValues";
import { MixedMark } from "./fields";
import { useMulti } from "./useMulti";
// ── Raum-Attribut-Abschnitt ──────────────────────────────────────────────────
// Editierbarer Name, SIA-416-Kategorie (5 Blatt-Kategorien), abgeleitete Fläche
@@ -24,6 +27,9 @@ export function RoomSection({
roomId: string;
host: ReturnType<typeof usePanelHost>;
}) {
// [195b] Mehrfachauswahl: SIA-Kategorie und Oberflächen gelten für alle gewählten Räume; der Name bleibt je Raum
// eigen (Feld gesperrt).
const multi = useMulti("rooms", selectionRoomValues);
return (
<>
<div className="objinfo-sep" />
@@ -36,6 +42,7 @@ export function RoomSection({
type="text"
className="objinfo-text"
value={room.name}
disabled={multi != null}
onChange={(e) => host.onSetRoomName(e.target.value)}
title={t("objinfo.room.name")}
/>
@@ -54,6 +61,7 @@ export function RoomSection({
title={t("objinfo.room.sia")}
width={170}
/>
<MixedMark on={multi?.siaCategory.mixed} what="sia" />
</div>
{/* Fläche + Umfang (read-only, abgeleitet). */}
@@ -96,14 +104,18 @@ type RoomFinishField = "floorFinish" | "wallFinish" | "ceilingFinish" | "floorBu
function RoomFinishFields({ roomId }: { roomId: string }) {
const storeProject = useStore((st) => st.project);
const applyChange = useStore((s) => s.applyChange);
const selectedRooms = useStore((s) => s.selection.rooms);
const project = storeProject;
const room = (project.rooms ?? []).find((r) => r.id === roomId);
if (!room) return null;
const comps = project.components;
const listId = `room-finish-materials-${roomId}`;
const shown = (v: string | undefined) => comps.find((c) => c.id === v)?.name ?? v ?? "";
const set = (field: RoomFinishField | "usage", value: string | undefined) =>
applyChange((p: Project) => patchItem(p, "rooms", roomId, { [field]: value } as Partial<Room>), `room:${roomId}:${field}`);
// [195b] Mehrfachauswahl: Nutzung und Oberflächen gelten für alle gewählten Räume (ein Undo-Schritt).
const set = (field: RoomFinishField | "usage", value: string | undefined) => {
const ids = selectedRooms.length > 1 && selectedRooms.includes(roomId) ? [...selectedRooms] : [roomId];
applyChange((p: Project) => patchItems(p, "rooms", ids, (r) => ({ ...r, [field]: value }) as Room), `room:${roomId}:${field}`);
};
const setFinish = (field: RoomFinishField, text: string) => {
const v = text.trim();
if (!v) return set(field, undefined);
+9 -1
View File
@@ -6,7 +6,9 @@ import type { ExtrudedSolidInfo, ColumnInfo, SolidProps } from "../../state/sele
import { usePanelHost } from "../host";
import { useStore } from "../../state/appStore";
import { Dropdown } from "../../ui/Dropdown";
import { DimensionField } from "./fields";
import { selectionColumnValues, selectionSolidValues } from "../../state/mixedValues";
import { DimensionField, MixedMark } from "./fields";
import { useMulti } from "./useMulti";
/** Volumen/Oberfläche/Schwerpunkt aus dem Kern-Netz des Körpers (Manifold, dasselbe Netz wie im 3D). */
function SolidPropsRows({ props }: { props: SolidProps | null }) {
@@ -44,6 +46,8 @@ export function ExtrudedSolidSection({
host: ReturnType<typeof usePanelHost>;
}) {
const components = useStore((st) => st.project.components);
// [195b] Mehrfachauswahl: Höhe und die übrigen Setter gelten für alle gewählten Körper.
const multi = useMulti("solids", selectionSolidValues);
return (
<>
<div className="objinfo-sep" />
@@ -64,6 +68,7 @@ export function ExtrudedSolidSection({
}}
title={t("objinfo.extrudedSolid.height")}
/>
<MixedMark on={multi?.height.mixed} what="height" />
</div>
<SolidPropsRows props={solid.props} />
@@ -205,6 +210,8 @@ export function ColumnSection({
column: ColumnInfo;
host: ReturnType<typeof usePanelHost>;
}) {
// [195b] Mehrfachauswahl: Profil, Masse, Höhe und Drehung gelten für alle gewählten Stützen.
const multi = useMulti("columns", selectionColumnValues);
return (
<>
<div className="objinfo-sep" />
@@ -252,6 +259,7 @@ export function ColumnSection({
value={column.height}
onCommit={(v) => host.onSetColumnHeight(v)}
/>
<MixedMark on={multi?.height.mixed} what="height" />
{/* Drehung (Grad). */}
<div className="objinfo-field">
+10 -1
View File
@@ -8,7 +8,9 @@ import { t } from "../../i18n";
import { Dropdown } from "../../ui/Dropdown";
import type { StairShape } from "../../model/types";
import { formatM } from "../../model/types";
import { DimensionField } from "./fields";
import { selectionStairValues } from "../../state/mixedValues";
import { DimensionField, MixedMark } from "./fields";
import { useMulti } from "./useMulti";
/**
* [151] Läufe und Podest einer Podesttreppe (L, U, gerade mit Podest): Lauflängen, Steigungen im ersten
@@ -135,6 +137,8 @@ export function StairSection({
host: ReturnType<typeof usePanelHost>;
}) {
const storeProject = useStore((st) => st.project);
// [195b] Mehrfachauswahl: abweichende Werte als „gemischt" kennzeichnen; Änderungen gelten für alle gewählten Treppen.
const multi = useMulti("stairs", selectionStairValues);
return (
<>
<div className="objinfo-sep" />
@@ -156,6 +160,7 @@ export function StairSection({
title={t("objinfo.stair.type")}
width={130}
/>
<MixedMark on={multi?.typeId.mixed} what="stairType" />
</div>
{/* Grundform-Dropdown. */}
@@ -174,6 +179,7 @@ export function StairSection({
title={t("objinfo.stair.shape")}
width={130}
/>
<MixedMark on={multi?.shape.mixed} what="stairShape" />
</div>
{/* Referenzpunkt der Laufbreite (links/mitte/rechts). */}
@@ -240,6 +246,7 @@ export function StairSection({
value={stair.width}
onCommit={(v) => host.onSetStairWidth(v)}
/>
<MixedMark on={multi?.width.mixed} what="width" />
{stair.shape === "spiral" && (
<DimensionField
label={t("objinfo.stair.column")}
@@ -254,11 +261,13 @@ export function StairSection({
value={stair.stepCount}
onCommit={(v) => host.onSetStairSteps(v)}
/>
<MixedMark on={multi?.stepCount.mixed} what="stepCount" />
<DimensionField
label={t("objinfo.stair.rise")}
value={stair.totalRise}
onCommit={(v) => host.onSetStairRise(v)}
/>
<MixedMark on={multi?.totalRise.mixed} what="totalRise" />
<DimensionField
label={t("objinfo.stair.baseOffset")}
value={stair.baseOffset ?? 0}
+1
View File
@@ -79,6 +79,7 @@ export function WallSection({
title={t("objinfo.wall.refLine")}
width={120}
/>
{mixedMark(multi?.referenceLine.mixed, "referenceLine")}
</div>
{/* Terminierung am Deckenanschluss (Zuschnitt, NICHT Priorität): ob die Wand
+1 -1
View File
@@ -6,7 +6,7 @@ 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 {
export function useMulti<T>(kind: "walls" | "ceilings" | "roofs" | "openings" | "stairs" | "rooms" | "columns" | "solids", 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).
+32 -1
View File
@@ -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, selectionCeilingValues, selectionOpeningValues, selectionRoofValues, selectionWallHeights } from "./mixedValues";
import { commonValue, selectionAppearance, selectionWallValues, selectedCount, selectionCeilingValues, selectionOpeningValues, selectionRoofValues, selectionWallHeights, selectionStairValues, selectionRoomValues, selectionColumnValues, selectionSolidValues } from "./mixedValues";
import { EMPTY_SELECTION, mergeSelection } from "./selection";
describe("commonValue [195]", () => {
@@ -104,3 +104,34 @@ describe("Mehrfachwerte Decke, Dach, Öffnung, Höhen [195b]", () => {
expect(v.bottom.mixed).toBe(true);
});
});
describe("Mehrfachwerte Treppe, Raum, Stütze, Körper [195b]", () => {
const p = buildComplexSampleProject();
it("Treppe: Breite gleich → Wert, abweichend → gemischt", () => {
const [a, b] = p.stairs!;
const sel = mergeSelection(EMPTY_SELECTION, { stairs: [a.id, b.id] });
const same = { ...p, stairs: p.stairs!.map((s) => (s.id === b.id ? { ...s, width: a.width } : s)) };
expect(selectionStairValues(same, sel).width.mixed).toBe(false);
const diff = { ...p, stairs: p.stairs!.map((s) => (s.id === b.id ? { ...s, width: a.width + 0.2 } : s)) };
expect(selectionStairValues(diff, sel).width.mixed).toBe(true);
});
it("Raum: SIA-Kategorie", () => {
const [a, b] = p.rooms!;
const sel = mergeSelection(EMPTY_SELECTION, { rooms: [a.id, b.id] });
const same = { ...p, rooms: p.rooms!.map((r) => (r.id === b.id ? { ...r, siaCategory: a.siaCategory } : r)) };
expect(selectionRoomValues(same, sel).siaCategory.mixed).toBe(false);
const other = a.siaCategory === "NNF" ? ("VF" as const) : ("NNF" as const);
const diff = { ...p, rooms: p.rooms!.map((r) => (r.id === b.id ? { ...r, siaCategory: other } : r)) };
expect(selectionRoomValues(diff, sel).siaCategory.mixed).toBe(true);
});
it("Stütze und Körper: Höhe", () => {
const [c1, c2] = p.columns!;
const csel = mergeSelection(EMPTY_SELECTION, { columns: [c1.id, c2.id] });
const cdiff = { ...p, columns: p.columns!.map((c) => (c.id === c2.id ? { ...c, height: c1.height + 1 } : c)) };
expect(selectionColumnValues(cdiff, csel).height.mixed).toBe(true);
const [e1, e2] = p.extrudedSolids!;
const ssel = mergeSelection(EMPTY_SELECTION, { solids: [e1.id, e2.id] });
const same = { ...p, extrudedSolids: p.extrudedSolids!.map((e) => (e.id === e2.id ? { ...e, height: e1.height } : e)) };
expect(selectionSolidValues(same, ssel).height.mixed).toBe(false);
});
});
+92 -2
View File
@@ -60,18 +60,22 @@ export function selectionAppearance(project: Project, sel: Selection): Selection
export interface SelectionWallValues {
wallTypeId: Common<string>;
thickness: Common<number>;
/** Referenzlinie samt freiem Fugen-Versatz. */
referenceLine: Common<string>;
}
export function selectionWallValues(project: Project, sel: Selection): SelectionWallValues {
const types: string[] = [];
const thick: number[] = [];
const refs: string[] = [];
for (const id of sel.walls.slice(0, MAX_COMPARED)) {
const wall = deriveSelection(project, { walls: [id] })?.wall;
if (!wall) continue;
types.push(wall.wallTypeId);
thick.push(wall.thickness);
refs.push(`${wall.referenceLine}|${wall.referenceOffset ?? ""}`);
}
return { wallTypeId: commonValue(types), thickness: commonValue(thick) };
return { wallTypeId: commonValue(types), thickness: commonValue(thick), referenceLine: commonValue(refs) };
}
/** Schlüssel einer Höhenangabe (Anker + aufgelöstes Z), damit gleiche Lagen als gleich gelten. */
@@ -144,6 +148,11 @@ export interface SelectionOpeningValues {
height: Common<number>;
sillHeight: Common<number>;
typeId: Common<string>;
/** Tür: Anschlag, Aufschlag, Richtung; Fenster: Flügelzahl. */
hinge: Common<string>;
swing: Common<string>;
openingDir: Common<string>;
wingCount: Common<number>;
}
export function selectionOpeningValues(project: Project, sel: Selection): SelectionOpeningValues {
@@ -151,6 +160,10 @@ export function selectionOpeningValues(project: Project, sel: Selection): Select
const h: number[] = [];
const s: number[] = [];
const ty: string[] = [];
const hinge: string[] = [];
const swing: string[] = [];
const dir: string[] = [];
const wings: number[] = [];
for (const id of sel.openings.slice(0, MAX_COMPARED)) {
const o = deriveSelection(project, { openings: [id] })?.opening;
if (!o) continue;
@@ -158,6 +171,83 @@ export function selectionOpeningValues(project: Project, sel: Selection): Select
h.push(o.height);
s.push(o.sillHeight);
ty.push(o.typeId ?? "");
hinge.push(o.hinge ?? "");
swing.push(o.swing ?? "");
dir.push(o.openingDir ?? "");
wings.push(o.wingCount ?? 1);
}
return { width: commonValue(w), height: commonValue(h), sillHeight: commonValue(s), typeId: commonValue(ty) };
return {
width: commonValue(w),
height: commonValue(h),
sillHeight: commonValue(s),
typeId: commonValue(ty),
hinge: commonValue(hinge),
swing: commonValue(swing),
openingDir: commonValue(dir),
wingCount: commonValue(wings),
};
}
/** [195b] Form, Breite, Stufenzahl, Steighöhe und Typ der gewählten Treppen. */
export interface SelectionStairValues {
shape: Common<string>;
width: Common<number>;
stepCount: Common<number>;
totalRise: Common<number>;
typeId: Common<string>;
}
export function selectionStairValues(project: Project, sel: Selection): SelectionStairValues {
const shape: string[] = [];
const width: number[] = [];
const steps: number[] = [];
const rise: number[] = [];
const ty: string[] = [];
for (const id of sel.stairs.slice(0, MAX_COMPARED)) {
const st = deriveSelection(project, { stairs: [id] })?.stair;
if (!st) continue;
shape.push(st.shape);
width.push(st.width);
steps.push(st.stepCount);
rise.push(st.totalRise);
ty.push(st.typeId ?? "");
}
return { shape: commonValue(shape), width: commonValue(width), stepCount: commonValue(steps), totalRise: commonValue(rise), typeId: commonValue(ty) };
}
/** [195b] SIA-Kategorie der gewählten Räume (der Name bleibt je Raum eigen und wird nicht für alle gesetzt). */
export interface SelectionRoomValues {
siaCategory: Common<string>;
}
export function selectionRoomValues(project: Project, sel: Selection): SelectionRoomValues {
const sia: string[] = [];
for (const id of sel.rooms.slice(0, MAX_COMPARED)) {
const r = deriveSelection(project, { rooms: [id] })?.room;
if (r) sia.push(r.siaCategory);
}
return { siaCategory: commonValue(sia) };
}
/** [195b] Höhe der gewählten Stützen bzw. Körper (Extrusionshöhe). */
export interface SelectionHeightValue {
height: Common<number>;
}
export function selectionColumnValues(project: Project, sel: Selection): SelectionHeightValue {
const h: number[] = [];
for (const id of sel.columns.slice(0, MAX_COMPARED)) {
const c = deriveSelection(project, { columns: [id] })?.column;
if (c) h.push(c.height);
}
return { height: commonValue(h) };
}
export function selectionSolidValues(project: Project, sel: Selection): SelectionHeightValue {
const h: number[] = [];
for (const id of sel.solids.slice(0, MAX_COMPARED)) {
const c = deriveSelection(project, { solids: [id] })?.extrudedSolid;
if (c) h.push(c.height);
}
return { height: commonValue(h) };
}
@@ -36,6 +36,9 @@ function hostFor(kind: string, id: string): Host {
updateCeiling: s.updateCeiling,
updateOpening: s.updateOpening,
updateRoof: s.updateRoof,
project: s.project,
updateStair: s.updateStair,
updateRoom: s.updateRoom,
setWallThickness: s.setWallThickness,
setCeilingThickness: s.setCeilingThickness,
selection: { kind, id },
@@ -45,7 +48,7 @@ function hostFor(kind: string, id: string): 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!;
const [a, b] = getState().project.openings!.filter((o) => o.kind === "window");
setState({ selection: { ...EMPTY_SELECTION, openings: [a.id, b.id] } });
const host = hostFor("opening", a.id);
const depth = getState().undoDepth;
@@ -100,4 +103,79 @@ describe("Mehrfachauswahl setzt alle gewählten Elemente in einem Schritt [195b]
(host.onSetWallThickness as (x: number) => void)(0.29);
expect(getState().undoDepth).toBe(depth + 1);
});
it("Öffnungen: Zusatzfelder und Editor-Patch nur für Öffnungen GLEICHER Art", () => {
getState().loadProject(buildComplexSampleProject());
const os = getState().project.openings!;
const doors = os.filter((o) => o.kind === "door");
const win = os.find((o) => o.kind === "window")!;
setState({ selection: { ...EMPTY_SELECTION, openings: [doors[0].id, doors[1].id, win.id] } });
const host = hostFor("opening", doors[0].id);
const depth = getState().undoDepth;
(host.onSetOpeningHinge as (x: string) => void)("end");
const after = getState().project.openings!;
expect(after.find((o) => o.id === doors[1].id)!.hinge).toBe("end");
expect(after.find((o) => o.id === win.id)!.hinge).toBe(os.find((o) => o.id === win.id)!.hinge);
expect(getState().undoDepth).toBe(depth + 1);
// Editor: Instanz-Patch für alle Türen, die Position nur für das erste Element.
(host.onPatchOpening as (x: object) => void)({ frameDetail: undefined, shape: "bogen" });
expect(getState().project.openings!.find((o) => o.id === doors[1].id)!.shape).toBe("bogen");
expect(getState().project.openings!.find((o) => o.id === win.id)!.shape).not.toBe("bogen");
expect(getState().undoDepth).toBe(depth + 2);
});
it("Wände: Referenzlinie für alle in einem Schritt", () => {
getState().loadProject(buildComplexSampleProject());
const [a, b] = getState().project.walls;
setState({ selection: { ...EMPTY_SELECTION, walls: [a.id, b.id] } });
const host = hostFor("wall", a.id);
const depth = getState().undoDepth;
(host.onSetWallReferenceLine as (x: string) => void)("right");
expect(getState().project.walls.find((w) => w.id === b.id)!.referenceLine).toBe("right");
expect(getState().undoDepth).toBe(depth + 1);
});
it("Treppen, Räume, Stützen, Körper: Setter wirken auf alle, Raumname nur auf das erste", () => {
getState().loadProject(buildComplexSampleProject());
const p = getState().project;
const [s1, s2] = p.stairs!;
setState({ selection: { ...EMPTY_SELECTION, stairs: [s1.id, s2.id] } });
let depth = getState().undoDepth;
(hostFor("stair", s1.id).onSetStairWidth as (x: number) => void)(1.37);
expect(getState().project.stairs!.find((s) => s.id === s2.id)!.width).toBe(1.37);
expect(getState().undoDepth).toBe(depth + 1);
const [r1, r2] = p.rooms!;
setState({ selection: { ...EMPTY_SELECTION, rooms: [r1.id, r2.id] } });
depth = getState().undoDepth;
const sia = r1.siaCategory === "NNF" ? "VF" : "NNF";
(hostFor("room", r1.id).onSetRoomSia as (x: string) => void)(sia);
expect(getState().project.rooms!.find((r) => r.id === r2.id)!.siaCategory).toBe(sia);
expect(getState().undoDepth).toBe(depth + 1);
(hostFor("room", r1.id).onSetRoomName as (x: string) => void)("Eigenname");
expect(getState().project.rooms!.find((r) => r.id === r2.id)!.name).not.toBe("Eigenname");
const [c1, c2] = p.columns!;
setState({ selection: { ...EMPTY_SELECTION, columns: [c1.id, c2.id] } });
depth = getState().undoDepth;
(hostFor("column", c1.id).onSetColumnHeight as (x: number) => void)(3.3);
expect(getState().project.columns!.find((c) => c.id === c2.id)!.height).toBe(3.3);
expect(getState().undoDepth).toBe(depth + 1);
const [e1, e2] = p.extrudedSolids!;
setState({ selection: { ...EMPTY_SELECTION, solids: [e1.id, e2.id] } });
depth = getState().undoDepth;
(hostFor("extrudedSolid", e1.id).onSetExtrudedSolidHeight as (x: number) => void)(2.2);
expect(getState().project.extrudedSolids!.find((e) => e.id === e2.id)!.height).toBe(2.2);
expect(getState().undoDepth).toBe(depth + 1);
});
it("Dach: Kanten bleiben beim ersten Dach", () => {
getState().loadProject(buildComplexSampleProject());
const [a, b] = getState().project.roofs!;
setState({ selection: { ...EMPTY_SELECTION, roofs: [a.id, b.id] } });
const before = JSON.stringify(b);
(hostFor("roof", a.id).onSetRoofEdge as (i: number, s: object) => void)(0, { kind: "pitch", pitchDeg: 51 });
expect(JSON.stringify(getState().project.roofs!.find((r) => r.id === b.id))).toBe(before);
});
});
+107 -93
View File
@@ -3,19 +3,38 @@
// Handler wirkt nur bei passender Auswahl (`selection.kind`) und schreibt über die Projekt-Aktionen
// bzw. `applyChange`.
import { patchItem, patchItems, removeRoofHole, setRoofEdge } from "../../core";
import { patchItems, removeRoofHole, setRoofEdge } from "../../core";
import type { EntityOf } from "../../core";
import { getState } from "../appStore";
import type { FlatHostOpts, HostPart } from "./types";
type MultiCollection = "walls" | "ceilings" | "roofs" | "openings";
/** Auswahl-Arten mit Mehrfach-Setzen (Schlüssel in `Selection`). */
type MultiCollection = "walls" | "ceilings" | "roofs" | "openings" | "stairs" | "rooms" | "columns" | "solids";
/** Projekt-Liste zur Auswahl-Art (Körper heissen im Modell `extrudedSolids`). */
const PROJECT_LIST = {
walls: "walls",
ceilings: "ceilings",
roofs: "roofs",
openings: "openings",
stairs: "stairs",
rooms: "rooms",
columns: "columns",
solids: "extrudedSolids",
} as const;
/**
* [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.
* zu setzen), sonst nur das Objekt der Objekt-Info. Öffnungen: nur die GLEICHER Art (Fenster/Tür) wie `id` —
* Typ, Flügel, Anschlag u. a. gelten nur dort.
*/
function targetIds(collection: MultiCollection, id: string): string[] {
const ids = getState().selection[collection];
return ids.length > 1 && ids.includes(id) ? [...ids] : [id];
if (!(ids.length > 1 && ids.includes(id))) return [id];
if (collection !== "openings") return [...ids];
const openings = getState().project.openings ?? [];
const kind = openings.find((o) => o.id === id)?.kind;
return ids.filter((x) => openings.find((o) => o.id === x)?.kind === kind);
}
/** Dach-Felder, die bei Mehrfachauswahl für alle gewählten Dächer gelten (Rest: nur das erste). */
@@ -23,51 +42,56 @@ const ROOF_MULTI_KEYS: ReadonlySet<string> = new Set(["roofTypeId", "pitchDeg"])
export function buildElementAttributesHost(c: FlatHostOpts) {
const { applyChange, onOpenStampEditor, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
/** Wie {@link patchAll}, aber mit Änderungsfunktion je Element (z. B. Stützen-Profil). */
function mapAll<K extends MultiCollection>(collection: K, id: string, fn: (e: EntityOf<(typeof PROJECT_LIST)[K]>) => EntityOf<(typeof PROJECT_LIST)[K]>, coalesceKey?: string): void {
const ids = targetIds(collection, id);
applyChange((p) => patchItems(p, PROJECT_LIST[collection], ids, fn), coalesceKey);
}
/** Patch auf alle Ziele (s. {@link targetIds}); ein Element: wie bisher über die Einzel-Aktion. */
function patchAll<K extends MultiCollection>(collection: K, id: string, patch: Record<string, unknown>, 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);
if (ids.length > 1) mapAll(collection, id, (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);
else if (collection === "openings") updateOpening(id, patch);
else if (collection === "stairs") updateStair(id, patch);
else if (collection === "rooms") updateRoom(id, patch);
else mapAll(collection, id, (e) => ({ ...(e as object), ...patch }) as typeof e, coalesceKey);
}
return {
// ── Wand-Attribute (nur bei selektierter Wand) ─────────────────────────
onSetWallReferenceLine: (ref) => {
if (selection?.kind === "wall")
// Benannte Linie gewählt ⇒ freien Fugen-Versatz löschen (er übersteuert sonst).
updateWall(selection.id, { referenceLine: ref, referenceOffset: undefined });
patchAll("walls", selection.id, { referenceLine: ref, referenceOffset: undefined });
},
onSetWallReferenceOffset: (offset) => {
if (selection?.kind === "wall")
updateWall(selection.id, { referenceOffset: offset ?? undefined });
if (selection?.kind === "wall") patchAll("walls", selection.id, { referenceOffset: offset ?? undefined });
},
onSetSurfacePatternPlacement: (patch) => {
if (selection?.kind === "wall") updateWall(selection.id, patch, "surface-pattern");
else if (selection?.kind === "roof") updateRoof(selection.id, patch, "surface-pattern");
if (selection?.kind === "wall") patchAll("walls", selection.id, patch, "surface-pattern");
else if (selection?.kind === "roof") patchAll("roofs", selection.id, patch, "surface-pattern");
},
onSetWallSliceTermination: (termination) => {
if (selection?.kind === "wall")
// "both" ist der Default ⇒ als undefined speichern (Alt-Projekt-Parität).
updateWall(selection.id, {
sliceTermination: termination === "both" ? undefined : termination,
});
patchAll("walls", selection.id, { sliceTermination: termination === "both" ? undefined : termination });
},
onSetWallRoofAttach: (attach) => {
if (selection?.kind === "wall")
// "auto" ist der Default ⇒ als undefined speichern.
updateWall(selection.id, { roofAttach: attach === "auto" ? undefined : attach === "on" });
patchAll("walls", selection.id, { roofAttach: attach === "auto" ? undefined : attach === "on" });
},
onSetBuildingFlags: (flags) => {
const patch: { isExternal?: boolean; loadBearing?: boolean } = {};
if (flags.isExternal !== undefined) patch.isExternal = flags.isExternal || undefined;
if (flags.loadBearing !== undefined) patch.loadBearing = flags.loadBearing || undefined;
if (selection?.kind === "wall") updateWall(selection.id, patch);
else if (selection?.kind === "ceiling") updateCeiling(selection.id, patch);
if (selection?.kind === "wall") patchAll("walls", selection.id, patch);
else if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, patch);
},
onSetCeilingEdgeAtOutline: (edgeAtOutline) => {
if (selection?.kind === "ceiling") updateCeiling(selection.id, { edgeAtOutline: edgeAtOutline || undefined });
if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { edgeAtOutline: edgeAtOutline || undefined });
},
onSetWallType: (wallTypeId) => {
// [195b] Mehrfachauswahl: alle gewählten Wände bekommen den Typ (ein Undo-Schritt).
@@ -137,53 +161,61 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
},
onSetOpeningSwingAngle: (swingAngle) => {
if (selection?.kind === "opening" && swingAngle > 0)
updateOpening(selection.id, { swingAngle });
patchAll("openings", selection.id, { swingAngle });
},
onSetOpeningHinge: (hinge) => {
if (selection?.kind === "opening") updateOpening(selection.id, { hinge });
if (selection?.kind === "opening") patchAll("openings", selection.id, { hinge });
},
onSetOpeningSwing: (swing) => {
if (selection?.kind === "opening") updateOpening(selection.id, { swing });
if (selection?.kind === "opening") patchAll("openings", selection.id, { swing });
},
onSetOpeningDir: (openingDir) => {
if (selection?.kind === "opening") updateOpening(selection.id, { openingDir });
if (selection?.kind === "opening") patchAll("openings", selection.id, { openingDir });
},
onSetOpeningWingCount: (wingCount) => {
if (selection?.kind === "opening")
updateOpening(selection.id, { wingCount: Math.max(1, Math.min(4, Math.round(wingCount))) });
patchAll("openings", selection.id, { wingCount: Math.max(1, Math.min(4, Math.round(wingCount))) });
},
onSetOpeningDoorType: (doorType) => {
if (selection?.kind === "opening") updateOpening(selection.id, { doorType });
if (selection?.kind === "opening") patchAll("openings", selection.id, { doorType });
},
onSetOpeningLintelLines: (lintelLines) => {
if (selection?.kind === "opening") updateOpening(selection.id, { lintelLines });
if (selection?.kind === "opening") patchAll("openings", selection.id, { lintelLines });
},
onSetOpeningDisplay: (patch) => {
if (selection?.kind === "opening") updateOpening(selection.id, patch);
if (selection?.kind === "opening") patchAll("openings", selection.id, patch);
},
// Lage eines Dach-/Deckenfensters ist elementspezifisch (Punkt/Winkel in der Wirtsfläche) ⇒ bewusst nur das erste Element.
onSetOpeningHost: (patch) => {
if (selection?.kind === "opening") updateOpening(selection.id, patch);
},
onSetOpeningDetailLevel: (detailLevel) => {
if (selection?.kind === "opening") updateOpening(selection.id, { detailLevel });
if (selection?.kind === "opening") patchAll("openings", selection.id, { detailLevel });
},
onSetOpeningFrameLine: (v) => {
if (selection?.kind === "opening") updateOpening(selection.id, { frameLine: v });
if (selection?.kind === "opening") patchAll("openings", selection.id, { frameLine: v });
},
onSetOpeningFrameViewLine: (v) => {
if (selection?.kind === "opening") updateOpening(selection.id, { frameViewLine: v });
if (selection?.kind === "opening") patchAll("openings", selection.id, { frameViewLine: v });
},
onSetOpeningSashLine: (v) => {
if (selection?.kind === "opening") updateOpening(selection.id, { sashLine: v });
if (selection?.kind === "opening") patchAll("openings", selection.id, { sashLine: v });
},
onSetOpeningSillLineStyle: (v) => {
if (selection?.kind === "opening") updateOpening(selection.id, { sillLineStyle: v });
if (selection?.kind === "opening") patchAll("openings", selection.id, { sillLineStyle: v });
},
// Typ-Zuweisung (Bibliothek): Tür-/Fenstertyp per typeId; leerer String löst
// die Zuweisung wieder (Inline-Verhalten).
onSetOpeningType: (typeId) => {
if (selection?.kind === "opening") patchAll("openings", selection.id, { typeId: typeId || undefined });
},
// Öffnungs-Editor (Fenster-/Türeditor): Instanz-Felder gelten für alle gewählten Öffnungen gleicher Art; die Position
// ist je Öffnung verschieden (Kern klemmt an der Wand) ⇒ nur das erste Element.
onPatchOpening: (patch) => {
if (selection?.kind !== "opening") return;
if ("position" in patch) updateOpening(selection.id, patch);
else patchAll("openings", selection.id, patch);
},
onEditOpeningType: (kind) => {
openResources(kind === "door" ? "doorStyles" : "windowStyles");
},
@@ -197,6 +229,9 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
if (multi) patchAll("roofs", selection.id, patch, coalesceKey);
else updateRoof(selection.id, patch, coalesceKey);
},
// Kanten (Index in den Umriss), Höfe und Gauben gehören zu GENAU EINEM Dach (Indizes/Ids sind dachspezifisch,
// andere Dächer haben andere Umrisse): bewusst nur das erste Element; die Abschnitte erscheinen deshalb bei
// Mehrfachauswahl nicht (`RoofSections`, `useMulti`).
onSetRoofEdge: (index, spec) => {
if (selection?.kind !== "roof") return;
const r = (project.roofs ?? []).find((x) => x.id === selection.id);
@@ -222,149 +257,128 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
onToggleSection3dCut,
// ── Treppen-Attribute (nur bei selektierter Treppe) ────────────────────
onSetStairShape: (shape) => {
if (selection?.kind === "stair") updateStair(selection.id, { shape });
if (selection?.kind === "stair") patchAll("stairs", selection.id, { shape });
},
onSetStairWidth: (width) => {
if (selection?.kind === "stair" && width > 0)
updateStair(selection.id, { width });
patchAll("stairs", selection.id, { width });
},
onSetStairSteps: (stepCount) => {
if (selection?.kind === "stair" && stepCount >= 2)
updateStair(selection.id, { stepCount: Math.round(stepCount) });
patchAll("stairs", selection.id, { stepCount: Math.round(stepCount) });
},
onSetStairRise: (totalRise) => {
if (selection?.kind === "stair" && totalRise > 0)
updateStair(selection.id, { totalRise });
patchAll("stairs", selection.id, { totalRise });
},
onSetStairBaseOffset: (baseOffset) => {
if (selection?.kind === "stair" && Number.isFinite(baseOffset)) updateStair(selection.id, { baseOffset });
if (selection?.kind === "stair" && Number.isFinite(baseOffset)) patchAll("stairs", selection.id, { baseOffset });
},
onSetStairUp: (up) => {
if (selection?.kind === "stair") updateStair(selection.id, { up });
if (selection?.kind === "stair") patchAll("stairs", selection.id, { up });
},
onSetStairArrowStyle: (arrowStyle) => {
if (selection?.kind === "stair") updateStair(selection.id, { arrowStyle });
if (selection?.kind === "stair") patchAll("stairs", selection.id, { arrowStyle });
},
onSetStairColumn: (radius) => {
if (selection?.kind === "stair")
updateStair(selection.id, { centerColumn: radius > 0 ? radius : undefined });
patchAll("stairs", selection.id, { centerColumn: radius > 0 ? radius : undefined });
},
onSetStairReferenz: (referenz) => {
if (selection?.kind === "stair") updateStair(selection.id, { referenz });
if (selection?.kind === "stair") patchAll("stairs", selection.id, { referenz });
},
onSetStairPatch: (patch) => {
if (selection?.kind === "stair") updateStair(selection.id, patch);
if (selection?.kind === "stair") patchAll("stairs", selection.id, patch);
},
// Typ-Zuweisung (Bibliothek): Treppentyp per typeId; leerer String löst die
// Zuweisung (Inline-Verhalten). Treibt u. a. die 3D-Tragart (massiv/offen).
onSetStairType: (typeId) => {
if (selection?.kind === "stair")
updateStair(selection.id, { typeId: typeId || undefined });
patchAll("stairs", selection.id, { typeId: typeId || undefined });
},
// ── Raum-Attribute (nur bei selektiertem Raum) ─────────────────────────
onSetRoomName: (name) => {
// Raumnamen sind je Raum verschieden ⇒ bewusst nur das erste Element (das Feld ist bei Mehrfachauswahl gesperrt).
if (selection?.kind === "room") updateRoom(selection.id, { name });
},
onSetRoomSia: (category) => {
if (selection?.kind === "room") updateRoom(selection.id, { siaCategory: category });
if (selection?.kind === "room") patchAll("rooms", selection.id, { siaCategory: category });
},
onEditRoomStamp: (roomId) => onOpenStampEditor(roomId),
// ── Extrusions-Attribute (truck-Integration; nur bei selektiertem Körper) ──
onSetExtrudedSolidHeight: (height) => {
if (selection?.kind !== "extrudedSolid" || !(height > 0)) return;
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { height }));
patchAll("solids", selection.id, { height });
},
onSetExtrudedSolidTaper: (taper) => {
if (selection?.kind !== "extrudedSolid") return;
const clamped = Math.min(1, Math.max(0, taper));
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { taper: clamped }));
patchAll("solids", selection.id, { taper: clamped });
},
onSetExtrudedSolidCornerRadius: (radius) => {
if (selection?.kind !== "extrudedSolid") return;
const r = Math.max(0, radius);
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { cornerRadius: r > 0 ? r : undefined }));
patchAll("solids", selection.id, { cornerRadius: r > 0 ? r : undefined });
},
onSetExtrudedSolidChamfer: (chamfer) => {
if (selection?.kind !== "extrudedSolid") return;
const c = Math.max(0, chamfer);
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { chamfer: c > 0 ? c : undefined }));
patchAll("solids", selection.id, { chamfer: c > 0 ? c : undefined });
},
onSetExtrudedSolidSubtract: (subtract) => {
if (selection?.kind !== "extrudedSolid") return;
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { operation: subtract ? ("subtract" as const) : undefined }));
patchAll("solids", selection.id, { operation: subtract ? ("subtract" as const) : undefined });
},
onSetExtrudedSolidBaseOffset: (offset) => {
if (selection?.kind !== "extrudedSolid" || !Number.isFinite(offset)) return;
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { baseOffset: Math.abs(offset) > 1e-9 ? offset : undefined }));
patchAll("solids", selection.id, { baseOffset: Math.abs(offset) > 1e-9 ? offset : undefined });
},
onSetExtrudedSolidComponent: (componentId) => {
if (selection?.kind !== "extrudedSolid") return;
const id = selection.id;
applyChange((p) => patchItem(p, "extrudedSolids", id, { componentId: componentId || undefined }));
patchAll("solids", selection.id, { componentId: componentId || undefined });
},
// ── Stützen-Attribute (Tragwerk; nur bei selektierter Stütze) ──────────
onSetColumnProfileKind: (kind) => {
if (selection?.kind !== "column") return;
const id = selection.id;
applyChange((p) =>
patchItem(p, "columns", id, (c) => {
if (kind === c.profile.kind) return c;
// Profil-Typ wechseln: sinnvolles Mass aus dem bisherigen ableiten.
if (kind === "round") {
const r =
c.profile.kind === "rect"
? Math.max(c.profile.width, c.profile.depth) / 2
: c.profile.radius;
return { ...c, profile: { kind: "round" as const, radius: r } };
}
const side = c.profile.kind === "round" ? c.profile.radius * 2 : 0.3;
return { ...c, profile: { kind: "rect" as const, width: side, depth: side } };
}),
);
mapAll("columns", selection.id, (c) => {
if (kind === c.profile.kind) return c;
// Profil-Typ wechseln: sinnvolles Mass aus dem bisherigen ableiten.
if (kind === "round") {
const r =
c.profile.kind === "rect"
? Math.max(c.profile.width, c.profile.depth) / 2
: c.profile.radius;
return { ...c, profile: { kind: "round" as const, radius: r } };
}
const side = c.profile.kind === "round" ? c.profile.radius * 2 : 0.3;
return { ...c, profile: { kind: "rect" as const, width: side, depth: side } };
});
},
onSetColumnWidth: (width) => {
if (selection?.kind !== "column" || !(width > 0)) return;
const id = selection.id;
applyChange((p) =>
patchItem(p, "columns", id, (c) =>
c.profile.kind === "rect" ? { ...c, profile: { ...c.profile, width } } : c,
),
mapAll("columns", selection.id, (c) =>
c.profile.kind === "rect" ? { ...c, profile: { ...c.profile, width } } : c,
);
},
onSetColumnDepth: (depth) => {
if (selection?.kind !== "column" || !(depth > 0)) return;
const id = selection.id;
applyChange((p) =>
patchItem(p, "columns", id, (c) =>
c.profile.kind === "rect" ? { ...c, profile: { ...c.profile, depth } } : c,
),
mapAll("columns", selection.id, (c) =>
c.profile.kind === "rect" ? { ...c, profile: { ...c.profile, depth } } : c,
);
},
onSetColumnRadius: (radius) => {
if (selection?.kind !== "column" || !(radius > 0)) return;
const id = selection.id;
applyChange((p) =>
patchItem(p, "columns", id, (c) =>
c.profile.kind === "round" ? { ...c, profile: { ...c.profile, radius } } : c,
),
mapAll("columns", selection.id, (c) =>
c.profile.kind === "round" ? { ...c, profile: { ...c.profile, radius } } : c,
);
},
onSetColumnHeight: (height) => {
if (selection?.kind !== "column" || !(height > 0)) return;
const id = selection.id;
applyChange((p) => patchItem(p, "columns", id, { height }));
patchAll("columns", selection.id, { height });
},
onSetColumnRotation: (deg) => {
if (selection?.kind !== "column" || !Number.isFinite(deg)) return;
const id = selection.id;
const rotation = (deg * Math.PI) / 180;
applyChange((p) => patchItem(p, "columns", id, { rotation }));
patchAll("columns", selection.id, { rotation: (deg * Math.PI) / 180 });
},
} satisfies HostPart;
}
+5 -4
View File
@@ -610,10 +610,11 @@ export function deriveSelection(project: Project, selection: Partial<Selection>)
// 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"),
// Ebenso Treppen, Räume, Körper und Stützen.
stairId: sel.stairs[0] ?? null,
roomId: sel.rooms[0] ?? null,
extrudedSolidId: sel.solids[0] ?? null,
columnId: sel.columns[0] ?? null,
roofId: sel.roofs[0] ?? null,
contextObjectId: single(sel, "contextObjects"),
};