[195b] Objekteinstellungen: alle Dach-Felder bei Mehrfachauswahl für alle Dächer, gemischte Werte
This commit is contained in:
6 files changed
+92
-28
No files matched your search
@@ -156,6 +156,7 @@ export function RoofSection({
|
||||
value: number,
|
||||
step: number,
|
||||
apply: (v: number) => void,
|
||||
mixedKey?: keyof NonNullable<typeof multi>,
|
||||
) => (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t(labelKey)}</span>
|
||||
@@ -170,6 +171,7 @@ export function RoofSection({
|
||||
}}
|
||||
title={t(labelKey)}
|
||||
/>
|
||||
{mixedKey && <MixedMark on={multi?.[mixedKey].mixed} what={mixedKey} />}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
@@ -194,6 +196,7 @@ export function RoofSection({
|
||||
title={t("objinfo.roof.shape")}
|
||||
width={130}
|
||||
/>
|
||||
<MixedMark on={multi?.shape.mixed} what="shape" />
|
||||
</div>
|
||||
|
||||
{/* Dachtyp (mehrschichtiger Aufbau) — leer = einschichtig (Dicke unten). */}
|
||||
@@ -227,18 +230,18 @@ export function RoofSection({
|
||||
title={t("objinfo.roof.ridgeAxis")}
|
||||
width={130}
|
||||
/>
|
||||
<MixedMark on={multi?.ridgeAxis.mixed} what="ridgeAxis" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Neigung(en) — Flachdach hat keine. */}
|
||||
{roof.shape !== "flach" &&
|
||||
numField("objinfo.roof.pitch", roof.pitchDeg, 1, (v) =>
|
||||
host.onSetRoofPatch({ pitchDeg: Math.max(0, Math.min(85, v)) }),
|
||||
host.onSetRoofPatch({ pitchDeg: Math.max(0, Math.min(85, v)) }), "pitchDeg",
|
||||
)}
|
||||
{roof.shape !== "flach" && <MixedMark on={multi?.pitchDeg.mixed} what="pitch" />}
|
||||
{roof.shape === "mansarde" &&
|
||||
numField("objinfo.roof.pitchUpper", roof.pitchUpperDeg ?? roof.pitchDeg / 2, 1, (v) =>
|
||||
host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }),
|
||||
host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }), "pitchUpperDeg",
|
||||
)}
|
||||
{/* Mansarde-Untertyp (Giebel/Walm/Zelt) + Knicklage. */}
|
||||
{roof.shape === "mansarde" && (
|
||||
@@ -257,23 +260,25 @@ export function RoofSection({
|
||||
title={t("objinfo.roof.mansardType")}
|
||||
width={130}
|
||||
/>
|
||||
<MixedMark on={multi?.mansardType.mixed} what="mansardType" />
|
||||
</div>
|
||||
)}
|
||||
{roof.shape === "mansarde" &&
|
||||
numField("objinfo.roof.mansardKnee", (roof.mansardKneeRatio ?? 0.4) * 100, 1, (v) =>
|
||||
host.onSetRoofPatch({ mansardKneeRatio: Math.max(5, Math.min(49, v)) / 100 }),
|
||||
host.onSetRoofPatch({ mansardKneeRatio: Math.max(5, Math.min(49, v)) / 100 }), "mansardKneeRatio",
|
||||
)}
|
||||
|
||||
{roof.shape === "sattel" &&
|
||||
numField("objinfo.roof.halfHip", (roof.halfHipRatio ?? 0) * 100, 5, (v) =>
|
||||
host.onSetRoofPatch({ halfHipRatio: Math.max(0, Math.min(90, v)) / 100 }),
|
||||
host.onSetRoofPatch({ halfHipRatio: Math.max(0, Math.min(90, v)) / 100 }), "halfHipRatio",
|
||||
)}
|
||||
|
||||
{/* Grundriss-Masse (Breite/Tiefe): das Umriss-Rechteck neu bilden, die
|
||||
untere/linke Ecke (minX/minY) bleibt fix. */}
|
||||
{/* Mit Innenhöfen oder Kanten ausserhalb eines Vierecks würde das Rechteck die Höfe/Kantenneigungen
|
||||
zerstören — dort entfallen Breite/Tiefe. */}
|
||||
{roof.holes.length === 0 &&
|
||||
{!multi &&
|
||||
roof.holes.length === 0 &&
|
||||
roof.edges.length === 4 &&
|
||||
numField("objinfo.roof.width", roof.width, 0.1, (v) => {
|
||||
const w = Math.max(0.2, v);
|
||||
@@ -281,7 +286,8 @@ export function RoofSection({
|
||||
outline: rectOutline(roof.minX, roof.minY, w, roof.depth),
|
||||
});
|
||||
})}
|
||||
{roof.holes.length === 0 &&
|
||||
{!multi &&
|
||||
roof.holes.length === 0 &&
|
||||
roof.edges.length === 4 &&
|
||||
numField("objinfo.roof.depth", roof.depth, 0.1, (v) => {
|
||||
const d = Math.max(0.2, v);
|
||||
@@ -292,7 +298,7 @@ export function RoofSection({
|
||||
|
||||
{/* Überstand: Traufe (senkrecht zum First) + Ortgang (Giebelseite). */}
|
||||
{numField("objinfo.roof.overhang", roof.overhang, 0.05, (v) =>
|
||||
host.onSetRoofPatch({ overhang: Math.max(0, v) }),
|
||||
host.onSetRoofPatch({ overhang: Math.max(0, v) }), "overhang",
|
||||
)}
|
||||
{roof.shape !== "flach" &&
|
||||
roof.shape !== "zelt" &&
|
||||
@@ -300,17 +306,17 @@ export function RoofSection({
|
||||
"objinfo.roof.overhangGable",
|
||||
roof.overhangGable ?? roof.overhang,
|
||||
0.05,
|
||||
(v) => host.onSetRoofPatch({ overhangGable: Math.max(0, v) }),
|
||||
(v) => host.onSetRoofPatch({ overhangGable: Math.max(0, v) }), "overhangGable",
|
||||
)}
|
||||
{/* Attika ([148]): Brüstung am Rand des Flachdachs; Höhe 0 = keine. */}
|
||||
{roof.shape === "flach" && (
|
||||
<>
|
||||
{numField("objinfo.roof.parapetHeight", roof.parapetHeight ?? 0, 0.05, (v) =>
|
||||
host.onSetRoofPatch({ parapetHeight: v > 0 ? v : undefined }),
|
||||
host.onSetRoofPatch({ parapetHeight: v > 0 ? v : undefined }), "parapetHeight",
|
||||
)}
|
||||
{(roof.parapetHeight ?? 0) > 0 &&
|
||||
numField("objinfo.roof.parapetWidth", roof.parapetWidth ?? 0.2, 0.01, (v) =>
|
||||
host.onSetRoofPatch({ parapetWidth: Math.max(0.02, v) }),
|
||||
host.onSetRoofPatch({ parapetWidth: Math.max(0.02, v) }), "parapetWidth",
|
||||
)}
|
||||
{(roof.parapetHeight ?? 0) > 0 && (
|
||||
<div className="objinfo-field">
|
||||
@@ -325,16 +331,17 @@ export function RoofSection({
|
||||
title={t("objinfo.roof.parapetMaterial")}
|
||||
width={130}
|
||||
/>
|
||||
<MixedMark on={multi?.parapetComponentId.mixed} what="parapetComponent" />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{numField("objinfo.roof.thickness", roof.thickness, 0.02, (v) =>
|
||||
host.onSetRoofPatch({ thickness: Math.max(0.01, v) }),
|
||||
host.onSetRoofPatch({ thickness: Math.max(0.01, v) }), "thickness",
|
||||
)}
|
||||
{/* Traufhöhe (absolutes Z) — z. B. für einen Kniestock übers Geschoss anheben. */}
|
||||
{numField("objinfo.roof.baseElevation", roof.baseElevation, 0.1, (v) =>
|
||||
host.onSetRoofPatch({ baseElevation: v }),
|
||||
host.onSetRoofPatch({ baseElevation: v }), "baseElevation",
|
||||
)}
|
||||
|
||||
{/* Kanten: Neigung je Kante (leer = Standard) und Giebel ([26]). Wirkt bei Sattel/Walm/
|
||||
|
||||
@@ -84,6 +84,10 @@ describe("Mehrfachwerte Decke, Dach, Öffnung, Höhen [195b]", () => {
|
||||
const v = selectionRoofValues(q, mergeSelection(EMPTY_SELECTION, { roofs: [a, b] }));
|
||||
expect(v.pitchDeg.mixed).toBe(true);
|
||||
expect(v.roofTypeId.mixed).toBe(true);
|
||||
const q2 = { ...q, roofs: q.roofs.map((r) => (r.id === a ? { ...r, overhang: 0.3, thickness: 0.2 } : r.id === b ? { ...r, overhang: 0.5, thickness: 0.2 } : r)) };
|
||||
const v2 = selectionRoofValues(q2, mergeSelection(EMPTY_SELECTION, { roofs: [a, b] }));
|
||||
expect(v2.overhang.mixed).toBe(true);
|
||||
expect(v2.thickness).toEqual({ value: 0.2, mixed: false });
|
||||
const one = selectionRoofValues(q, mergeSelection(EMPTY_SELECTION, { roofs: [a] }));
|
||||
expect(one.pitchDeg).toEqual({ value: 20, mixed: false });
|
||||
});
|
||||
|
||||
@@ -124,22 +124,53 @@ export function selectionCeilingValues(project: Project, sel: Selection): Select
|
||||
return { typeId: commonValue(types), thickness: commonValue(thick), bottom: commonValue(b), top: commonValue(t) };
|
||||
}
|
||||
|
||||
/** [195b] Typ und Neigung der gewählten Dächer. */
|
||||
/** [195b] Dach-Felder der gewählten Dächer (alle ausser Umriss, Kanten, Gauben und Höfen, die je Dach eigen sind). */
|
||||
export interface SelectionRoofValues {
|
||||
roofTypeId: Common<string>;
|
||||
pitchDeg: Common<number>;
|
||||
shape: Common<string>;
|
||||
ridgeAxis: Common<string>;
|
||||
pitchUpperDeg: Common<number>;
|
||||
mansardType: Common<string>;
|
||||
mansardKneeRatio: Common<number>;
|
||||
halfHipRatio: Common<number>;
|
||||
overhang: Common<number>;
|
||||
overhangGable: Common<number>;
|
||||
parapetHeight: Common<number>;
|
||||
parapetWidth: Common<number>;
|
||||
parapetComponentId: Common<string>;
|
||||
thickness: Common<number>;
|
||||
baseElevation: Common<number>;
|
||||
}
|
||||
|
||||
export function selectionRoofValues(project: Project, sel: Selection): SelectionRoofValues {
|
||||
const types: string[] = [];
|
||||
const pitch: number[] = [];
|
||||
const v = {
|
||||
roofTypeId: [] as string[], pitchDeg: [] as number[], shape: [] as string[], ridgeAxis: [] as string[],
|
||||
pitchUpperDeg: [] as number[], mansardType: [] as string[], mansardKneeRatio: [] as number[], halfHipRatio: [] as number[],
|
||||
overhang: [] as number[], overhangGable: [] as number[], parapetHeight: [] as number[], parapetWidth: [] as number[],
|
||||
parapetComponentId: [] as string[], thickness: [] as number[], baseElevation: [] as number[],
|
||||
};
|
||||
for (const id of sel.roofs.slice(0, MAX_COMPARED)) {
|
||||
const r = deriveSelection(project, { roofs: [id] })?.roof;
|
||||
if (!r) continue;
|
||||
types.push(r.roofTypeId ?? "");
|
||||
pitch.push(r.pitchDeg);
|
||||
v.roofTypeId.push(r.roofTypeId ?? "");
|
||||
v.pitchDeg.push(r.pitchDeg);
|
||||
v.shape.push(r.shape);
|
||||
v.ridgeAxis.push(r.ridgeAxis);
|
||||
// Vorgaben wie in der Anzeige (RoofSection), damit „gleich angezeigt" auch „gleich" heisst.
|
||||
v.pitchUpperDeg.push(r.pitchUpperDeg ?? r.pitchDeg / 2);
|
||||
v.mansardType.push(r.mansardType ?? "giebel");
|
||||
v.mansardKneeRatio.push(r.mansardKneeRatio ?? 0.4);
|
||||
v.halfHipRatio.push(r.halfHipRatio ?? 0);
|
||||
v.overhang.push(r.overhang);
|
||||
v.overhangGable.push(r.overhangGable ?? r.overhang);
|
||||
v.parapetHeight.push(r.parapetHeight ?? 0);
|
||||
v.parapetWidth.push(r.parapetWidth ?? 0.2);
|
||||
v.parapetComponentId.push(r.parapetComponentId ?? "");
|
||||
v.thickness.push(r.thickness);
|
||||
v.baseElevation.push(r.baseElevation);
|
||||
}
|
||||
return { roofTypeId: commonValue(types), pitchDeg: commonValue(pitch) };
|
||||
return Object.fromEntries(Object.entries(v).map(([k, a]) => [k, commonValue(a as (string | number)[])])) as unknown as SelectionRoofValues;
|
||||
}
|
||||
|
||||
/** [195b] Breite, Höhe, Brüstung und Typ der gewählten Öffnungen. */
|
||||
|
||||
@@ -79,17 +79,35 @@ describe("Mehrfachauswahl setzt alle gewählten Elemente in einem Schritt [195b]
|
||||
expect(getState().undoDepth).toBe(depth);
|
||||
});
|
||||
|
||||
it("Dächer: Neigung für alle; andere Felder nur für das erste", () => {
|
||||
it("Dächer: Neigung, Dicke, Traufhöhe, Überstand für alle in EINEM Undo-Schritt; Gauben/Kanten nur das erste", () => {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
const [a, b] = getState().project.roofs!;
|
||||
setState({ selection: { ...EMPTY_SELECTION, roofs: [a.id, b.id] } });
|
||||
const host = hostFor("roof", a.id);
|
||||
(host.onSetRoofPatch as (p: object) => void)({ pitchDeg: 33 });
|
||||
const patch = host.onSetRoofPatch as (p: object, k?: string) => void;
|
||||
patch({ pitchDeg: 33 });
|
||||
expect(getState().project.roofs!.find((r) => r.id === b.id)!.pitchDeg).toBe(33);
|
||||
(host.onSetRoofPatch as (p: object) => void)({ overhang: 0.77 });
|
||||
const depth = getState().undoDepth;
|
||||
patch({ overhang: 0.77 });
|
||||
patch({ thickness: 0.31 });
|
||||
patch({ baseElevation: 4.2 });
|
||||
const r2 = getState().project.roofs!;
|
||||
expect(r2.find((r) => r.id === a.id)!.overhang).toBe(0.77);
|
||||
expect(r2.find((r) => r.id === b.id)!.overhang).not.toBe(0.77);
|
||||
for (const id of [a.id, b.id]) {
|
||||
const r = r2.find((x) => x.id === id)!;
|
||||
expect(r.overhang).toBe(0.77);
|
||||
expect(r.thickness).toBe(0.31);
|
||||
expect(r.baseElevation).toBe(4.2);
|
||||
}
|
||||
expect(getState().undoDepth).toBe(depth + 3);
|
||||
getState().undo();
|
||||
getState().undo();
|
||||
getState().undo();
|
||||
expect(getState().project.roofs!.find((r) => r.id === b.id)!.overhang).toBe(b.overhang);
|
||||
// dachspezifisch: nur das erste Dach
|
||||
patch({ edgePitchDeg: [20, 20, 20, 20] });
|
||||
const r3 = getState().project.roofs!;
|
||||
expect(r3.find((r) => r.id === a.id)!.edgePitchDeg).toEqual([20, 20, 20, 20]);
|
||||
expect(r3.find((r) => r.id === b.id)!.edgePitchDeg).toEqual(b.edgePitchDeg);
|
||||
});
|
||||
|
||||
it("Wände: Unterkante und Dicke für alle", () => {
|
||||
|
||||
@@ -37,8 +37,12 @@ function targetIds(collection: MultiCollection, id: string): string[] {
|
||||
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). */
|
||||
const ROOF_MULTI_KEYS: ReadonlySet<string> = new Set(["roofTypeId", "pitchDeg"]);
|
||||
/**
|
||||
* Dach-Felder, die je Dach eigen sind und bei Mehrfachauswahl nur das erste Dach treffen: Umriss samt Höfen/Bögen,
|
||||
* Kantenneigungen (Indizes) und Gauben. Alle anderen Felder (Typ, Neigung, Dicke, Traufhöhe, Überstände, Attika …)
|
||||
* gelten für alle gewählten Dächer.
|
||||
*/
|
||||
const ROOF_OWN_KEYS: ReadonlySet<string> = new Set(["outline", "holes", "outlineBulge", "holesBulge", "edgePitchDeg", "dormers"]);
|
||||
|
||||
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;
|
||||
@@ -225,7 +229,7 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
// ── Dach-Attribute (nur bei selektiertem Dach) ─────────────────────────
|
||||
onSetRoofPatch: (patch, coalesceKey) => {
|
||||
if (selection?.kind !== "roof") return;
|
||||
const multi = Object.keys(patch).every((k) => ROOF_MULTI_KEYS.has(k));
|
||||
const multi = !Object.keys(patch).some((k) => ROOF_OWN_KEYS.has(k));
|
||||
if (multi) patchAll("roofs", selection.id, patch, coalesceKey);
|
||||
else updateRoof(selection.id, patch, coalesceKey);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user