[195b] Objekteinstellungen: Setzen für alle bei Referenzlinie, Öffnungs-Feldern und -Editor, Treppe, Raum, Stütze, Körper; gemischte Werte; Dach-Kanten/Gauben nur bei einem Dach
This commit is contained in:
16 files changed
+382
-114
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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"),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user