[26][B2] Dach: Innenhöfe (Roof.holes) und Neigung je Kante (Roof.edgePitchDeg), Objekt-Info, Befehl Dachhof

Modell (Rust, ts-rs): Roof.holes (Ringe) und Roof.edgePitchDeg (je Umrisskante, dann Hofkanten;
null = Giebel, negativ = Standard, Feld fehlt = wie bisher). roof.rs: custom_roof rechnet über
weighted_roof (alle Ringe, Überstand je Kante, Hofringe schrumpfen); ungültige Höfe und Pult
fallen auf das bisherige Dach zurück. Dächer ohne die Felder bleiben bitgleich (CLI-SVG/IFC).
Plan: Hof als Loch der Dachfläche, Hofkanten als Traufe. 3D: Gehrung an Graten zwischen
verschieden geneigten Flächen (Dachschichten bleiben geschlossen).
UI: Kantenliste mit Neigung/Giebel im Objekt-Info, Hofliste mit Entfernen, Befehl "Dachhof".

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-29 01:29:15 +00:00
1 parent 775d756a6c
commit 0986a3ac7b
24 files changed
+1341 -41

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
/**
* `roofHoleCommand` — Innenhof per Klicks (≥ 3 Punkte Polygon, 2 Punkte + Enter Rechteck) im ersten
* Dach des aktiven Geschosses, in dem er wirkt; sonst bleibt das Projekt unverändert.
*/
import { describe, expect, it } from "vitest";
import { roofHoleCommand } from "./roofHole";
import type { CommandContext, CommandState, Project, Vec2 } from "../types";
const roof = (id: string, shape: "walm" | "pult", x0: number) => ({
id,
type: "roof" as const,
floorId: "eg",
categoryCode: "31",
outline: [
{ x: x0, y: 0 },
{ x: x0 + 12, y: 0 },
{ x: x0 + 12, y: 8 },
{ x: x0, y: 8 },
],
shape,
pitchDeg: 35,
overhang: 0,
ridgeAxis: "x" as const,
thickness: 0.2,
});
function project(shape: "walm" | "pult" = "walm"): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [],
wallTypes: [],
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
layers: [{ code: "31", name: "Dächer", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [],
context: [],
roofs: [roof("RF1", shape, 0)],
};
}
const ctxOf = (p: Project): CommandContext => ({
project: p,
level: p.drawingLevels[0],
defaultCategoryCode: "31",
activeLineStyleId: "solid",
activeWallTypeId: "aw",
lastPoint: null,
selection: { wallIds: [], drawingId: null },
});
/** Befehl mit Punkten füttern und mit Enter bestätigen; liefert das Ergebnis-Projekt. */
function run(p: Project, pts: Vec2[], confirm = true): Project {
const ctx = ctxOf(p);
let state: CommandState = roofHoleCommand.init();
let commit: ((q: Project) => Project) | undefined;
for (const point of pts) {
const [ns, res] = roofHoleCommand.onInput(state, { kind: "point", point }, ctx);
state = ns;
commit = res.commit ?? commit;
}
if (confirm && !commit) {
const [, res] = roofHoleCommand.onConfirm(state, ctx);
commit = res.commit;
}
return commit ? commit(p) : p;
}
describe("roofHoleCommand", () => {
it("zwei Punkte + Enter ergeben einen rechteckigen Hof", () => {
const p = project();
const q = run(p, [{ x: 4, y: 2 }, { x: 8, y: 6 }]);
expect(q.roofs![0].holes).toEqual([
[
{ x: 4, y: 2 },
{ x: 8, y: 2 },
{ x: 8, y: 6 },
{ x: 4, y: 6 },
],
]);
});
it("drei und mehr Punkte: Klick auf den Startpunkt schliesst das Polygon", () => {
const q = run(project(), [{ x: 3, y: 2 }, { x: 9, y: 2 }, { x: 6, y: 6 }, { x: 3, y: 2 }], false);
expect(q.roofs![0].holes).toHaveLength(1);
expect(q.roofs![0].holes![0]).toHaveLength(3);
});
it("Hof ausserhalb des Dachs oder bei Pultdach: Projekt unverändert", () => {
const p = project();
expect(run(p, [{ x: 20, y: 2 }, { x: 24, y: 6 }]).roofs![0].holes).toBeUndefined();
const pult = project("pult");
expect(run(pult, [{ x: 4, y: 2 }, { x: 8, y: 6 }]).roofs![0].holes).toBeUndefined();
});
it("Hof über den Umriss hinaus wird verworfen", () => {
expect(run(project(), [{ x: 10, y: 2 }, { x: 14, y: 6 }]).roofs![0].holes).toBeUndefined();
});
});
+145
View File
@@ -0,0 +1,145 @@
// Dachhof — Innenhof/Lichthof im Dach als Engine-Befehl: eine Kontur wird per Klicks gezeichnet und
// dem ERSTEN Dach des aktiven Geschosses hinzugefügt, in dem sie wirkt (ganz im Umriss, ohne
// Überschneidung, nicht bei Pultdach — das entscheidet der Rust-Kern, s. `roofHoleWorks`).
//
// Warum Zeichnen statt „aus gewählter Kontur": die Auswahl kennt immer nur ein Objekt, mit dem
// Dach gewählt wäre keine zweite Kontur wählbar; gezeichnet gibt es Fang auf Wände und Umriss,
// und der Ablauf entspricht Deckenloch/Decke. Zwei Punkte + Enter ergeben ein Rechteck.
//
// Schritte:
// 1) „Erster Punkt des Hofs:" → Punkt
// 2) „Nächster Punkt ( Schliessen Zurück ):" → Punkt … Schliessen per Klick auf den Startpunkt,
// Option „Schliessen" oder Enter (≥ 3 Punkte; bei genau 2 Punkten: Rechteck aus den Ecken).
import { addRoofHole, opsMutation, patchItem, pointInOutline, roofHoleWorks } from "../../core";
import type { CoreOp } from "../../core";
import type { Command, CommandContext, CommandResult, CommandState, CmdOption, DraftShape, Project, ToolDraft, Vec2 } from "../types";
const EPS = 1e-6;
const CLOSE_HIT = 0.08; // Modell-Meter: Klick nahe Startpunkt schliesst die Kontur
const dist = (a: Vec2, b: Vec2): number => Math.hypot(b.x - a.x, b.y - a.y);
/** Vier Ecken eines Rechtecks aus zwei Gegenecken. */
function rectCorners(a: Vec2, b: Vec2): Vec2[] {
const x0 = Math.min(a.x, b.x);
const x1 = Math.max(a.x, b.x);
const y0 = Math.min(a.y, b.y);
const y1 = Math.max(a.y, b.y);
return [
{ x: x0, y: y0 },
{ x: x1, y: y0 },
{ x: x1, y: y1 },
{ x: x0, y: y1 },
];
}
interface HoleIdle extends CommandState {
phase: "start";
}
interface HoleDrawing extends CommandState {
phase: "next";
points: Vec2[];
cursor: Vec2 | null;
}
type HoleState = HoleIdle | HoleDrawing;
const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" };
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
/** Vorschau: Kontur (ab 3 Punkten geschlossen) + Gummiband. */
function holeDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
const pts = cursor ? [...points, cursor] : points;
const preview: DraftShape[] = [{ kind: "poly", pts, closed: pts.length >= 3 }];
const draft: ToolDraft = { preview, vertices: points };
const last = points[points.length - 1];
if (cursor && last && dist(last, cursor) >= EPS) draft.hud = { at: cursor, text: `${dist(last, cursor).toFixed(2)} m` };
return draft;
}
/** Aus den Klickpunkten die Hof-Kontur: ≥ 3 Punkte = Polygon, genau 2 = Rechteck. */
function ringOf(points: Vec2[]): Vec2[] | null {
if (points.length >= 3) return points;
if (points.length === 2) {
const [a, b] = points;
if (Math.abs(a.x - b.x) < 0.05 || Math.abs(a.y - b.y) < 0.05) return null;
return rectCorners(a, b);
}
return null;
}
/**
* Hängt den Hof an das erste Dach des aktiven Geschosses, in dem er wirkt. Ohne passendes Dach
* (Hof ausserhalb, schneidet den Umriss, Pultdach) bleibt das Projekt unverändert.
*/
function roofHoleOps(p: Project, points: Vec2[], ctx: CommandContext): CoreOp[] {
const ring = ringOf(points);
if (!ring) return [];
const host = (p.roofs ?? []).find((r) => r.floorId === ctx.level.id && r.outline.length >= 3 && ring.every((pt) => pointInOutline(pt, r.outline)) && roofHoleWorks(r, ring));
if (!host) return [];
return patchItem(p, "roofs", host.id, (r) => ({ ...r, ...addRoofHole(r, ring) }));
}
const idle = (): [CommandState, CommandResult] => [{ phase: "start", lastPoint: null } as HoleIdle, { draft: null, done: true }];
const finish = (points: Vec2[], ctx: CommandContext): [CommandState, CommandResult] => [
{ phase: "start", lastPoint: null } as HoleIdle,
{ draft: null, done: true, commit: opsMutation((p) => roofHoleOps(p, points, ctx)) },
];
export const roofHoleCommand: Command = {
name: "roofhole",
labelKey: "cmd.roofHole.label",
floorOnly: true,
prompt: (s) => ((s as HoleState).phase === "next" ? "cmd.roofHole.next" : "cmd.roofHole.start"),
accepts: (s) => ((s as HoleState).phase === "next" ? ["point", "option"] : ["point"]),
options: (s) => {
const ps = s as HoleState;
if (ps.phase !== "next") return [];
return ps.points.length >= 3 ? [CLOSE, UNDO] : [UNDO];
},
init: (): HoleIdle => ({ phase: "start", lastPoint: null }),
onInput: (state, input, ctx): [CommandState, CommandResult] => {
const s = state as HoleState;
if (input.kind === "option") {
if (s.phase !== "next") return [s, { draft: null }];
if (input.id === "undo") {
const pts = s.points.slice(0, -1);
if (pts.length === 0) return [{ phase: "start", lastPoint: null } as HoleIdle, { draft: null }];
const ns: HoleDrawing = { phase: "next", points: pts, cursor: s.cursor, lastPoint: pts[pts.length - 1] };
return [ns, { draft: holeDraft(pts, s.cursor) }];
}
if (input.id === "close" && s.points.length >= 3) return finish(s.points, ctx);
return [s, { draft: holeDraft(s.points, s.cursor) }];
}
if (input.kind !== "point") return [s, { draft: s.phase === "next" ? holeDraft(s.points, s.cursor) : null }];
const pt = input.point;
if (s.phase !== "next") {
const ns: HoleDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
return [ns, { draft: holeDraft([pt], pt) }];
}
// Klick nahe Startpunkt schliesst die Kontur.
if (s.points.length >= 3 && dist(s.points[0], pt) < CLOSE_HIT) return finish(s.points, ctx);
// Null-Strecke ignorieren.
if (dist(s.points[s.points.length - 1], pt) < EPS) return [s, { draft: holeDraft(s.points, s.cursor) }];
const points = [...s.points, pt];
const ns: HoleDrawing = { phase: "next", points, cursor: pt, lastPoint: pt };
return [ns, { draft: holeDraft(points, pt) }];
},
onMove: (state, point): [CommandState, CommandResult] => {
const s = state as HoleState;
if (s.phase !== "next") return [s, { draft: null }];
const ns: HoleDrawing = { ...s, cursor: point };
return [ns, { draft: holeDraft(s.points, point) }];
},
// Enter/Rechtsklick: ≥ 3 Punkte Polygon, 2 Punkte Rechteck.
onConfirm: (state, ctx): [CommandState, CommandResult] => {
const s = state as HoleState;
if (s.phase === "next" && s.points.length >= 2) return finish(s.points, ctx);
return idle();
},
onCancel: (): [CommandState, CommandResult] => idle(),
};
+4
View File
@@ -18,6 +18,7 @@ import { solidCommand } from "./cmds/solid";
import { solidBoolCommand } from "./cmds/solidbool";
import { voidBoxCommand } from "./cmds/voidbox";
import { ceilingOpeningCommand } from "./cmds/ceilingOpening";
import { roofHoleCommand } from "./cmds/roofHole";
import { roomCommand } from "./cmds/room";
import { rectCommand } from "./cmds/rect";
import { circleCommand } from "./cmds/circle";
@@ -77,6 +78,7 @@ export const COMMANDS: Record<string, Command> = {
solidbool: solidBoolCommand,
voidbox: voidBoxCommand,
ceilingopening: ceilingOpeningCommand,
roofhole: roofHoleCommand,
room: roomCommand,
line: lineCommand,
polyline: polylineCommand,
@@ -159,6 +161,8 @@ export const ALIASES: Record<string, string> = {
body: "solid",
deckenloch: "ceilingopening",
aussparung: "ceilingopening",
dachhof: "roofhole",
lichthof: "roofhole",
rf: "roof",
raum: "room",
rm: "room",
+9
View File
@@ -127,6 +127,15 @@ export {
roofGeometry,
} from "../geometry/roof";
export {
addRoofHole,
removeRoofHole,
roofEdgeList,
roofHoleWorks,
setRoofEdge,
} from "../geometry/roofEdges";
export type { EdgeSpec, RoofEdge } from "../geometry/roofEdges";
export {
SIA_CATEGORIES,
balance,
+29 -5
View File
@@ -23,6 +23,8 @@ export interface RoofPlane {
export interface RoofGeometry {
/** Traufe-Umriss (Grundriss, inkl. Überstand) als geschlossener Ring. */
eaves: Vec2[];
/** Traufringe der Innenhöfe (`Roof.holes`, inkl. Überstand; der Hof schrumpft). */
eavesHoles: Vec2[][];
/** Firstlinie(n) im Grundriss (leer bei Flach/Zelt). */
ridges: [Vec2, Vec2][];
/** Gratlinien (Walm/Zelt: Ecke → First/Spitze). */
@@ -74,7 +76,11 @@ const MANSARD_CODE = { giebel: 0, walm: 1, zelt: 2 } as const;
function encodeRoof(roof: Roof): Float64Array {
const pts = roof.outline;
const buf = new Float64Array(10 + 2 * pts.length);
const holes = roof.holes ?? [];
const edges = roof.edgePitchDeg;
let size = 10 + 2 * pts.length + 1 + 1 + (edges ? edges.length : 0);
for (const h of holes) size += 1 + 2 * h.length;
const buf = new Float64Array(size);
buf[0] = SHAPE_CODE[roof.shape] ?? 0;
buf[1] = roof.pitchDeg;
buf[2] = roof.pitchUpperDeg ?? NaN;
@@ -85,10 +91,22 @@ function encodeRoof(roof: Roof): Float64Array {
buf[7] = roof.overhangGable ?? NaN;
buf[8] = roof.ridgeAxis === "y" ? 1 : 0;
buf[9] = pts.length;
for (let i = 0; i < pts.length; i++) {
buf[10 + 2 * i] = pts[i].x;
buf[11 + 2 * i] = pts[i].y;
let i = 10;
for (const p of pts) {
buf[i++] = p.x;
buf[i++] = p.y;
}
buf[i++] = holes.length;
for (const h of holes) {
buf[i++] = h.length;
for (const p of h) {
buf[i++] = p.x;
buf[i++] = p.y;
}
}
// Neigung je Kante: NaN = Feld fehlt, +∞ = Giebel (null), negativ = Standard.
buf[i++] = edges ? edges.length : NaN;
if (edges) for (const v of edges) buf[i++] = v === null ? Infinity : v;
return buf;
}
@@ -122,7 +140,13 @@ function decodeGeometry(b: Float64Array): RoofGeometry {
const planes = polys().map((pts) => ({ pts }));
const planesEnd = i;
const gables = polys();
const geo: RoofGeometry = { eaves, ridges, hips, breaks, planes, gables, ridgeHeight };
const eavesHoles: Vec2[][] = [];
for (let n = b[i++]; n > 0; n--) {
const ring: Vec2[] = [];
for (let m = b[i++]; m > 0; m--) ring.push(pt());
eavesHoles.push(ring);
}
const geo: RoofGeometry = { eaves, eavesHoles, ridges, hips, breaks, planes, gables, ridgeHeight };
planesFlat.set(geo, b.subarray(planesStart, planesEnd));
return geo;
}
+92
View File
@@ -0,0 +1,92 @@
// Kanten und Höfe eines Dachs ([26]): Liste, Änderung der Kantenneigung, Hof hinzufügen/entfernen.
import { describe, expect, it } from "vitest";
import type { Roof, Vec2 } from "../model/types";
import { addRoofHole, removeRoofHole, roofEdgeList, roofHoleWorks, setRoofEdge } from "./roofEdges";
const rect = (x: number, y: number, w: number, h: number): Vec2[] => [
{ x, y },
{ x: x + w, y },
{ x: x + w, y: y + h },
{ x, y: y + h },
];
const roof = (extra: Partial<Roof> = {}): Roof => ({
id: "R",
type: "roof",
floorId: "eg",
categoryCode: "31",
outline: rect(0, 0, 12, 8),
shape: "walm",
pitchDeg: 35,
overhang: 0,
ridgeAxis: "x",
thickness: 0.2,
...extra,
});
const court = rect(4, 2, 4, 4);
describe("roofEdgeList", () => {
it("Umrisskanten, dann Hofkanten; Standard ohne Feld", () => {
const list = roofEdgeList(roof({ holes: [court] }));
expect(list).toHaveLength(8);
expect(list.map((e) => e.ring)).toEqual([0, 0, 0, 0, 1, 1, 1, 1]);
expect(list[0]).toMatchObject({ index: 0, spec: { kind: "default" }, length: 12 });
expect(list[5].index).toBe(5);
});
it("liest Giebel, Neigung und negativ = Standard; Sattel: Giebelregel zeigt sich als Vorgabe", () => {
const list = roofEdgeList(roof({ edgePitchDeg: [20, null, -1] }));
expect(list[0].spec).toEqual({ kind: "pitch", deg: 20 });
expect(list[1].spec).toEqual({ kind: "gable" });
expect(list[2].spec).toEqual({ kind: "default" });
expect(list[3].spec).toEqual({ kind: "default" });
const sattel = roofEdgeList(roof({ shape: "sattel" }));
expect(sattel.map((e) => e.defaultGable)).toEqual([false, true, false, true]);
expect(roofEdgeList(roof()).every((e) => !e.defaultGable)).toBe(true);
});
});
describe("setRoofEdge", () => {
it("setzt Neigung/Giebel, füllt mit Standard auf, entfernt das Feld wenn alles Standard", () => {
const a = setRoofEdge(roof(), 2, { kind: "pitch", deg: 25 });
expect(a.edgePitchDeg).toEqual([-1, -1, 25]);
const b = setRoofEdge(roof({ ...a }), 0, { kind: "gable" });
expect(b.edgePitchDeg).toEqual([null, -1, 25]);
const c = setRoofEdge(roof({ ...b }), 0, { kind: "default" });
const d = setRoofEdge(roof({ ...c }), 2, { kind: "default" });
expect(d.edgePitchDeg).toBeUndefined();
});
it("begrenzt die Neigung auf 0..89 Grad", () => {
expect(setRoofEdge(roof(), 0, { kind: "pitch", deg: 120 }).edgePitchDeg).toEqual([89]);
expect(setRoofEdge(roof(), 0, { kind: "pitch", deg: -5 }).edgePitchDeg).toEqual([0]);
});
});
describe("Höfe", () => {
it("Hof hinzufügen: Ring bleibt, ungültige (ausserhalb, Pult) wirken nicht", () => {
const r = roof();
expect(roofHoleWorks(r, court)).toBe(true);
expect(roofHoleWorks(r, rect(10, 2, 4, 4))).toBe(false);
expect(roofHoleWorks(roof({ shape: "pult" }), court)).toBe(false);
const p = addRoofHole(r, court);
expect(p.holes).toEqual([court]);
});
it("Hof entfernen nimmt seine Kantenneigungen mit; Indizes der übrigen Höfe rücken nach", () => {
const h2 = rect(1, 1, 1, 1);
const r = roof({ holes: [court, h2], edgePitchDeg: [-1, -1, -1, -1, 10, -1, -1, -1, 50, -1, -1, -1] });
const p = removeRoofHole(r, 0);
expect(p.holes).toEqual([h2]);
expect(p.edgePitchDeg).toEqual([-1, -1, -1, -1, 50]);
const q = removeRoofHole(roof({ ...p }), 0);
expect(q.holes).toBeUndefined();
expect(q.edgePitchDeg).toBeUndefined();
});
it("Hof entfernen ohne Kantenfeld lässt es weg", () => {
const p = removeRoofHole(roof({ holes: [court] }), 0);
expect(p).toEqual({ holes: undefined, edgePitchDeg: undefined });
});
});
+116
View File
@@ -0,0 +1,116 @@
// Kanten und Höfe eines Dachs ([26]): die Kantenliste fürs Objekt-Info (Neigung je Kante, Giebel),
// Änderungen als Teilobjekt (`Partial<Roof>`, für `updateRoof`/`patchItem` — ein Undo-Schritt) und
// die Prüfung, ob ein Hof wirkt. Die Geometrie selbst rechnet der Rust-Kern (`roof.rs`).
//
// Kantennummerierung wie `Roof.edgePitchDeg`: erst die Kanten von `outline` (Kante i = Punkt i →
// i+1), dann die der `holes` Ring für Ring. Eintrag `null` = Giebel, Zahl ≥ 0 = Neigung, negativ
// (oder fehlend) = Standard.
import type { Roof, Vec2 } from "../model/types";
import { roofGeometry } from "./roof";
/** Vorgabe einer Kante. */
export type EdgeSpec = { kind: "default" } | { kind: "gable" } | { kind: "pitch"; deg: number };
/** Eine Kante der Kantenliste (Umriss oder Hof). */
export interface RoofEdge {
/** Index in `edgePitchDeg`. */
index: number;
/** 0 = Umriss, 1.. = Hof (1-basiert). */
ring: number;
/** Index der Kante im eigenen Ring. */
edge: number;
a: Vec2;
b: Vec2;
/** Länge der Kante (Meter). */
length: number;
spec: EdgeSpec;
/** Standard ist hier ein Giebel (Satteldach/Mansard-Satteldach, Kante quer zum First). */
defaultGable: boolean;
}
const MAX_PITCH = 89;
/** Die Vorgabe aus einem Eintrag von `edgePitchDeg`. */
function specOf(v: number | null | undefined): EdgeSpec {
if (v === null) return { kind: "gable" };
if (v === undefined || !Number.isFinite(v) || v < 0) return { kind: "default" };
return { kind: "pitch", deg: v };
}
/** Giebelt der Standard dieser Dachform die Kante a→b (quer zur Firstrichtung)? */
function defaultGableEdge(roof: Roof, a: Vec2, b: Vec2): boolean {
const gabled = roof.shape === "sattel" || (roof.shape === "mansarde" && (roof.mansardType ?? "giebel") === "giebel");
if (!gabled) return false;
const dx = Math.abs(b.x - a.x);
const dy = Math.abs(b.y - a.y);
return roof.ridgeAxis === "y" ? dy < dx : dx < dy;
}
/** Alle Kanten des Dachs (Umriss, dann Höfe) mit ihrer Vorgabe. */
export function roofEdgeList(roof: Roof): RoofEdge[] {
const rings: Vec2[][] = [roof.outline, ...(roof.holes ?? [])];
const out: RoofEdge[] = [];
let index = 0;
rings.forEach((ring, r) => {
ring.forEach((a, edge) => {
const b = ring[(edge + 1) % ring.length];
out.push({
index,
ring: r,
edge,
a,
b,
length: Math.hypot(b.x - a.x, b.y - a.y),
spec: specOf(roof.edgePitchDeg?.[index]),
defaultGable: defaultGableEdge(roof, a, b),
});
index++;
});
});
return out;
}
/** `edgePitchDeg` ohne Standard-Einträge am Ende; alles Standard ⇒ `undefined` (Feld entfällt). */
function normalized(values: (number | null)[]): (number | null)[] | undefined {
const v = values.slice();
while (v.length > 0 && v[v.length - 1] !== null && (v[v.length - 1] as number) < 0) v.pop();
return v.length === 0 ? undefined : v;
}
/** Teilobjekt für `updateRoof`: Kante `index` auf `spec` setzen. */
export function setRoofEdge(roof: Roof, index: number, spec: EdgeSpec): Pick<Roof, "edgePitchDeg"> {
const total = roofEdgeList(roof).length;
const values: (number | null)[] = Array.from({ length: total }, (_, i) => {
const v = roof.edgePitchDeg?.[i];
return v === undefined ? -1 : v;
});
if (index < 0 || index >= total) return { edgePitchDeg: roof.edgePitchDeg };
values[index] = spec.kind === "gable" ? null : spec.kind === "pitch" ? Math.max(0, Math.min(MAX_PITCH, spec.deg)) : -1;
return { edgePitchDeg: normalized(values) };
}
/** Wirkt ein Hof `ring` an diesem Dach? Der Kern verwirft Höfe, die nicht ganz im Umriss liegen, sich
* schneiden oder bei einer Dachform ohne Höfe (Pult) — dann liefert er keinen Hof-Traufring. */
export function roofHoleWorks(roof: Roof, ring: Vec2[]): boolean {
if (ring.length < 3) return false;
const probe: Roof = { ...roof, holes: [...(roof.holes ?? []), ring] };
return roofGeometry(probe, 0).eavesHoles.length === (probe.holes?.length ?? 0);
}
/** Teilobjekt für `updateRoof`: Hof anhängen (seine Kanten folgen mit Standard-Neigung). */
export function addRoofHole(roof: Roof, ring: Vec2[]): Pick<Roof, "holes"> {
return { holes: [...(roof.holes ?? []), ring.map((p) => ({ x: p.x, y: p.y }))] };
}
/** Teilobjekt für `updateRoof`: Hof `k` entfernen samt seinen Kantenneigungen. */
export function removeRoofHole(roof: Roof, k: number): Pick<Roof, "holes" | "edgePitchDeg"> {
const holes = roof.holes ?? [];
if (k < 0 || k >= holes.length) return { holes: roof.holes, edgePitchDeg: roof.edgePitchDeg };
let from = roof.outline.length;
for (let i = 0; i < k; i++) from += holes[i].length;
const to = from + holes[k].length;
const rest = holes.filter((_, i) => i !== k);
const edges = roof.edgePitchDeg ? [...roof.edgePitchDeg.slice(0, from), ...roof.edgePitchDeg.slice(to)] : undefined;
return { holes: rest.length > 0 ? rest : undefined, edgePitchDeg: edges ? normalized(edges) : undefined };
}
+16
View File
@@ -477,6 +477,19 @@ export const de = {
"objinfo.roof.baseElevation": "Traufhöhe (m)",
"objinfo.roof.ridgeHeight": "Firsthöhe",
"objinfo.roof.area": "Grundfläche",
"objinfo.roof.edges": "Kanten (Neigung je Kante)",
"objinfo.roof.edge": "Kante {n}",
"objinfo.roof.edgeCourt": "Hof {c} · Kante {n}",
"objinfo.roof.edgePitch": "Neigung der Kante (Grad); leer = Standard",
"objinfo.roof.edgeGable": "Giebel",
"objinfo.roof.edgeGableHint": "Senkrechte Giebelwand statt geneigter Fläche",
"objinfo.roof.edgeReset": "Auf Standard zurücksetzen",
"objinfo.roof.edgesReset": "Alle Kanten auf Standard",
"objinfo.roof.courts": "Innenhöfe",
"objinfo.roof.courtRow": "Hof {n}: {area} m²",
"objinfo.roof.courtRemove": "Hof entfernen",
"objinfo.roof.courtAdd": "Hof hinzufügen: Befehl „Dachhof“ (Kontur zeichnen)",
"objinfo.roof.courtAddBtn": "Hof zeichnen …",
// ── Stützen-Attribute (Object-Info-Panel) ───────────────────────────────
"objinfo.column.section": "Stütze",
"objinfo.column.profile": "Profil",
@@ -1309,6 +1322,9 @@ export const de = {
"cmd.ceilingOpening.label": "Deckenloch",
"cmd.ceilingOpening.start": "Erste Ecke der Aussparung (in einer Decke):",
"cmd.ceilingOpening.corner": "Gegenecke:",
"cmd.roofHole.label": "Dachhof",
"cmd.roofHole.start": "Erster Punkt des Innenhofs (im Dach):",
"cmd.roofHole.next": "Nächster Punkt (Enter bei 2 Punkten = Rechteck, ab 3 Punkten Polygon):",
"cmd.roof.shape.sattel": "Satteldach",
"cmd.roof.shape.walm": "Walmdach",
"cmd.roof.shape.pult": "Pultdach",
+16
View File
@@ -475,6 +475,19 @@ export const en: Record<TranslationKey, string> = {
"objinfo.roof.baseElevation": "Eaves height (m)",
"objinfo.roof.ridgeHeight": "Ridge height",
"objinfo.roof.area": "Footprint area",
"objinfo.roof.edges": "Edges (pitch per edge)",
"objinfo.roof.edge": "Edge {n}",
"objinfo.roof.edgeCourt": "Court {c} · edge {n}",
"objinfo.roof.edgePitch": "Edge pitch (degrees); empty = default",
"objinfo.roof.edgeGable": "Gable",
"objinfo.roof.edgeGableHint": "Vertical gable wall instead of a sloped surface",
"objinfo.roof.edgeReset": "Reset to default",
"objinfo.roof.edgesReset": "All edges to default",
"objinfo.roof.courts": "Courtyards",
"objinfo.roof.courtRow": "Court {n}: {area} m²",
"objinfo.roof.courtRemove": "Remove courtyard",
"objinfo.roof.courtAdd": "Add a courtyard: command \"Roof court\" (draw the contour)",
"objinfo.roof.courtAddBtn": "Draw courtyard …",
// ── Column attributes (object info panel) ────────────────────────────────
"objinfo.column.section": "Column",
"objinfo.column.profile": "Profile",
@@ -1298,6 +1311,9 @@ export const en: Record<TranslationKey, string> = {
"cmd.ceilingOpening.label": "Slab opening",
"cmd.ceilingOpening.start": "First corner of the opening (inside a slab):",
"cmd.ceilingOpening.corner": "Opposite corner:",
"cmd.roofHole.label": "Roof court",
"cmd.roofHole.start": "First point of the courtyard (inside the roof):",
"cmd.roofHole.next": "Next point (Enter with 2 points = rectangle, 3 or more = polygon):",
"cmd.roof.shape.sattel": "Gable roof",
"cmd.roof.shape.walm": "Hip roof",
"cmd.roof.shape.pult": "Mono-pitch roof",
+18
View File
@@ -2070,6 +2070,24 @@ export type Roof = {
locked?: boolean;
/** Geschlossener Grundriss-Umriss (Meter); Geometrie nutzt die Bounding-Box. */
outline: Array<Vec2>;
/**
* Innenhöfe/Lichthöfe als Ringe (Meter, jeder Ring geschlossen, Drehsinn egal). Das Dach
* ist an dieser Stelle ausgespart (3D, Grundriss, Schnitt, Ansicht, IFC); die Hofkanten sind
* innere Traufen. Wirkt bei Flach/Sattel/Walm/Mansarde/Zelt (Pult ignoriert sie); ein Ring,
* der nicht ganz im Umriss liegt oder sich mit Umriss/anderen Höfen schneidet, macht die
* Höfe wirkungslos (Dach wie ohne). Fehlt ⇒ keine Höfe.
*/
holes?: Array<Array<Vec2>>;
/**
* Neigung je Umrisskante in Grad. Nummerierung: erst die Kanten von `outline` (Kante i =
* Punkt i → i+1, in der gespeicherten Reihenfolge), danach die Kanten der `holes` Ring für
* Ring. Eintrag `null` = Giebel (senkrechte Wand, Kante läuft nicht nach innen), eine Zahl
* ≥ 0 = Neigung dieser Kante (übersteuert `pitchDeg`), eine NEGATIVE Zahl (oder ein fehlender
* Eintrag) = Standard: `pitchDeg`, bei Satteldach/Mansard-Satteldach mit Giebel an den
* Kanten quer zur Firstrichtung. Fehlt das Feld ganz ⇒ alles Standard (wie bisher).
* Wirkt bei Sattel/Walm/Mansarde/Zelt (Flach/Pult ignorieren es).
*/
edgePitchDeg?: Array<number | null>;
/** Dachform. */
shape: RoofShape;
/** Hauptneigung in Grad (0 = flach). */
+130 -12
View File
@@ -36,6 +36,7 @@ import type {
WallReferenceLine,
} from "../model/types";
import { SIA_CATEGORIES, siaLabelFull } from "../core";
import type { EdgeSpec, RoofEdge } from "../core";
import { Dropdown } from "../ui/Dropdown";
import type { DetailLevel } from "../model/viewTypes";
import { ColorHexField } from "../ui/ColorHexField";
@@ -1042,18 +1043,24 @@ export function RoofSection({
{/* Grundriss-Masse (Breite/Tiefe): das Umriss-Rechteck neu bilden, die
untere/linke Ecke (minX/minY) bleibt fix. */}
{numField("objinfo.roof.width", roof.width, 0.1, (v) => {
const w = Math.max(0.2, v);
host.onSetRoofPatch({
outline: rectOutline(roof.minX, roof.minY, w, roof.depth),
});
})}
{numField("objinfo.roof.depth", roof.depth, 0.1, (v) => {
const d = Math.max(0.2, v);
host.onSetRoofPatch({
outline: rectOutline(roof.minX, roof.minY, roof.width, d),
});
})}
{/* 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 &&
roof.edges.length === 4 &&
numField("objinfo.roof.width", roof.width, 0.1, (v) => {
const w = Math.max(0.2, v);
host.onSetRoofPatch({
outline: rectOutline(roof.minX, roof.minY, w, roof.depth),
});
})}
{roof.holes.length === 0 &&
roof.edges.length === 4 &&
numField("objinfo.roof.depth", roof.depth, 0.1, (v) => {
const d = Math.max(0.2, v);
host.onSetRoofPatch({
outline: rectOutline(roof.minX, roof.minY, roof.width, d),
});
})}
{/* Überstand: Traufe (senkrecht zum First) + Ortgang (Giebelseite). */}
{numField("objinfo.roof.overhang", roof.overhang, 0.05, (v) =>
@@ -1075,6 +1082,46 @@ export function RoofSection({
host.onSetRoofPatch({ baseElevation: v }),
)}
{/* 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" && (
<RoofEdgesSection roof={roof} host={host} />
)}
{/* Innenhöfe: Liste mit Entfernen, Hinzufügen über den Befehl „Dachhof“. */}
{roof.shape !== "pult" && (
<>
<div className="objinfo-sep" />
<div className="objinfo-section-label">{t("objinfo.roof.courts")}</div>
{roof.holes.map((h, i) => (
<div className="objinfo-field" key={i}>
<span className="objinfo-flabel objinfo-muted">
{t("objinfo.roof.courtRow", { n: i + 1, area: h.area.toFixed(2) })}
</span>
<button
type="button"
className="objinfo-typebtn"
title={t("objinfo.roof.courtRemove")}
aria-label={t("objinfo.roof.courtRemove")}
onClick={() => host.onRemoveRoofHole(i)}
>
×
</button>
</div>
))}
<div className="objinfo-field">
<button
type="button"
className="objinfo-typebtn"
title={t("objinfo.roof.courtAdd")}
onClick={() => host.onRunCommand("roofhole")}
>
{t("objinfo.roof.courtAddBtn")}
</button>
</div>
</>
)}
<div className="objinfo-sep" />
{/* Abgeleitete Werte (read-only). */}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.roof.ridgeHeight")}</span>
@@ -1088,6 +1135,77 @@ export function RoofSection({
);
}
/** Kantenliste eines Dachs: Neigung je Kante (leer = Standard) + Giebel-Schalter. */
function RoofEdgesSection({
roof,
host,
}: {
roof: RoofInfo;
host: ReturnType<typeof usePanelHost>;
}) {
// Tippen einer Zahl = ein Undo-Schritt je Kante (gleicher coalesceKey, s. Host).
const setEdge = (e: RoofEdge, spec: EdgeSpec) => host.onSetRoofEdge(e.index, spec);
return (
<>
<div className="objinfo-sep" />
<div className="objinfo-section-label">{t("objinfo.roof.edges")}</div>
{roof.edges.map((e) => {
const label =
e.ring === 0
? t("objinfo.roof.edge", { n: e.edge + 1 })
: t("objinfo.roof.edgeCourt", { c: e.ring, n: e.edge + 1 });
const gable = e.spec.kind === "gable";
const placeholder = e.defaultGable ? t("objinfo.roof.edgeGable") : String(roof.pitchDeg);
return (
<div className="objinfo-field objinfo-roof-edge" key={e.index} data-edge={e.index}>
<span className="objinfo-flabel" title={`${e.length.toFixed(2)} m`}>
{label}
</span>
<input
type="number"
className="objinfo-text"
min={0}
max={89}
step={1}
disabled={gable}
placeholder={placeholder}
value={e.spec.kind === "pitch" ? Number(e.spec.deg.toFixed(2)) : ""}
aria-label={`${label}: ${t("objinfo.roof.edgePitch")}`}
title={t("objinfo.roof.edgePitch")}
onChange={(ev) => {
const raw = ev.target.value;
if (raw === "") return setEdge(e, { kind: "default" });
const v = Number(raw);
if (Number.isFinite(v)) setEdge(e, { kind: "pitch", deg: v });
}}
/>
<label className="objinfo-muted" title={t("objinfo.roof.edgeGableHint")}>
<input
type="checkbox"
checked={gable}
aria-label={`${label}: ${t("objinfo.roof.edgeGable")}`}
onChange={(ev) => setEdge(e, ev.target.checked ? { kind: "gable" } : { kind: "default" })}
/>
{t("objinfo.roof.edgeGable")}
</label>
</div>
);
})}
{roof.hasEdgePitch && (
<div className="objinfo-field">
<button
type="button"
className="objinfo-typebtn"
onClick={() => host.onSetRoofPatch({ edgePitchDeg: undefined })}
>
{t("objinfo.roof.edgesReset")}
</button>
</div>
)}
</>
);
}
export function StairSection({
stair,
host,
+1 -1
View File
@@ -355,7 +355,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "ceilingopening", "roof", "extrude", "solid", "solidbool", "sectionline", "viewline", "autodim"];
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "extrude", "solid", "solidbool", "sectionline", "viewline", "autodim"];
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
type ToolsView = "list" | "icons";
+5 -1
View File
@@ -471,7 +471,11 @@ export interface PanelHostValue {
* Immutable Änderung von Dach-Attributen (Form/Neigung/Überstand/Firstrichtung/
* Dicke) — wirkt NUR auf das selektierte Dach.
*/
onSetRoofPatch: (patch: Partial<import("../model/types").Roof>) => void;
onSetRoofPatch: (patch: Partial<import("../model/types").Roof>, coalesceKey?: string) => void;
/** Neigung/Giebel der Dachkante `index` setzen ([26]); Tippen einer Zahl = ein Undo-Schritt je Kante. */
onSetRoofEdge: (index: number, spec: import("../core").EdgeSpec) => void;
/** Innenhof `k` (Index in `Roof.holes`) des gewählten Dachs entfernen, samt seinen Kantenneigungen. */
onRemoveRoofHole: (k: number) => void;
// ── Schnitt-/Ansichtslinie (Object-Info-Panel; nur die selektierte Linie) ──
/**
+17
View File
@@ -170,4 +170,21 @@ describe("generatePlan — Dächer (Dachaufsicht)", () => {
false,
);
});
it("Innenhof ([26]): Traufring des Hofs, Dachfläche mit Loch (Brückenkanten), Firstlinien des Hofs", () => {
const court = [
{ x: 1.5, y: 1 },
{ x: 1.5, y: 3 },
{ x: 3, y: 3 },
{ x: 3, y: 1 },
];
const plain = generatePlan(baseProject([roof("R9", "walm", { overhang: 0 })]), "eg", visible);
const withCourt = generatePlan(baseProject([roof("R9", "walm", { overhang: 0, holes: [court] })]), "eg", visible);
// Umriss 4 Kanten + Hof 4 Kanten.
expect(linesOf(plain.primitives, "roof-eaves").length).toBe(4);
expect(linesOf(withCourt.primitives, "roof-eaves").length).toBe(8);
const poly = withCourt.primitives.find((p) => p.kind === "polygon" && p.roofId === "R9");
expect(poly && poly.kind === "polygon" && poly.pts.length).toBeGreaterThan(4);
expect(poly && poly.kind === "polygon" && (poly.noStrokeEdges ?? []).length).toBeGreaterThan(0);
});
});
+118
View File
@@ -0,0 +1,118 @@
// Dach: Kantenneigung und Innenhöfe ([26]) über Store/Ops — ein Undo-Schritt je Aktion — und die
// Rundreise durch das Projektformat (Rust-Modell ↔ TS: `holes`, `edgePitchDeg` mit `null` = Giebel).
import { beforeEach, describe, expect, it } from "vitest";
import { getState, setState } from "./appStore";
import type { Project, Roof } from "../model/types";
import { addRoofHole, removeRoofHole, roofGeometry, setRoofEdge } from "../core";
import { parseProjectFile, serializeProject } from "../io/projectFormat";
import { sampleProject } from "../model/sampleProject";
const roof: Roof = {
id: "RF1",
type: "roof",
floorId: "eg",
categoryCode: "31",
outline: [
{ x: 0, y: 0 },
{ x: 12, y: 0 },
{ x: 12, y: 8 },
{ x: 0, y: 8 },
],
shape: "walm",
pitchDeg: 35,
overhang: 0,
ridgeAxis: "x",
thickness: 0.2,
};
const court = [
{ x: 4, y: 2 },
{ x: 4, y: 6 },
{ x: 8, y: 6 },
{ x: 8, y: 2 },
];
const baseProject = {
id: "p",
name: "T",
layers: [],
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, baseElevation: 0 }],
walls: [],
drawings2d: [],
roofs: [roof],
} as unknown as Project;
const current = (): Roof => getState().project.roofs![0];
beforeEach(() => {
setState({ project: JSON.parse(JSON.stringify(baseProject)), undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
getState().clearHistory();
});
describe("Kantenneigung über Ops", () => {
it("Kante ändern ist ein Undo-Schritt; Zurück stellt das Feld wieder her", () => {
getState().updateRoof("RF1", setRoofEdge(current(), 0, { kind: "pitch", deg: 20 }));
expect(current().edgePitchDeg).toEqual([20]);
expect(getState().undoDepth).toBe(1);
getState().undo();
expect(current().edgePitchDeg).toBeUndefined();
});
it("Tippen einer Zahl (gleicher Schlüssel) koalesziert zu einem Schritt", () => {
const key = "roof-edge-RF1-1";
getState().updateRoof("RF1", { overhang: 0.1 }); // Koaleszenz-Grenze
getState().clearHistory();
getState().updateRoof("RF1", setRoofEdge(current(), 1, { kind: "pitch", deg: 3 }), key);
getState().updateRoof("RF1", setRoofEdge(current(), 1, { kind: "pitch", deg: 30 }), key);
expect(current().edgePitchDeg).toEqual([-1, 30]);
expect(getState().undoDepth).toBe(1);
getState().undo();
expect(current().edgePitchDeg).toBeUndefined();
});
it("Giebel (null) bleibt im Projekt und ändert die Geometrie", () => {
const before = roofGeometry(current(), 0);
getState().updateRoof("RF1", { edgePitchDeg: [-1, null, -1, null] });
expect(current().edgePitchDeg).toEqual([-1, null, -1, null]);
const after = roofGeometry(current(), 0);
expect(after.gables.length).toBe(2);
expect(before.gables.length).toBe(0);
});
});
describe("Innenhöfe über Ops", () => {
it("Hof hinzufügen und entfernen: je ein Undo-Schritt, Dach spart den Hof aus", () => {
getState().updateRoof("RF1", addRoofHole(current(), court));
expect(current().holes).toEqual([court]);
expect(roofGeometry(current(), 0).eavesHoles).toHaveLength(1);
expect(getState().undoDepth).toBe(1);
getState().updateRoof("RF1", removeRoofHole(current(), 0));
expect(current().holes).toBeUndefined();
expect(getState().undoDepth).toBe(2);
getState().undo();
expect(current().holes).toEqual([court]);
getState().undo();
expect(current().holes).toBeUndefined();
});
});
describe("Projektdatei: Rundreise", () => {
it("holes und edgePitchDeg (mit null) überstehen Schreiben und Lesen", () => {
const withFields: Roof = { ...roof, holes: [court], edgePitchDeg: [20, null, -1, 45, 10, -1, -1, null] };
const p = { ...sampleProject, roofs: [withFields] } as Project;
const r = parseProjectFile(serializeProject(p));
if (!r.ok) throw new Error(r.error);
expect(r.project.roofs![0].holes).toEqual([court]);
expect(r.project.roofs![0].edgePitchDeg).toEqual([20, null, -1, 45, 10, -1, -1, null]);
});
it("ohne die Felder bleiben sie auch nach der Rundreise weg", () => {
const p = { ...sampleProject, roofs: [roof] } as Project;
const text = serializeProject(p);
expect(text).not.toContain("edgePitchDeg");
expect(text).not.toContain("holes");
const r = parseProjectFile(text);
if (!r.ok) throw new Error(r.error);
expect("holes" in r.project.roofs![0]).toBe(false);
expect("edgePitchDeg" in r.project.roofs![0]).toBe(false);
});
});
+11 -1
View File
@@ -58,7 +58,8 @@ import {
wallVerticalExtent,
} from "../model/wall";
import { ceilingArea, outlineBBox } from "../core";
import { roofBBox, roofBaseElevation, roofGeometry } from "../core";
import { roofBBox, roofBaseElevation, roofEdgeList, roofGeometry } from "../core";
import type { RoofEdge } from "../core";
import { openingGapQuad, openingVerticalExtent } from "../core";
import { stairGeometry, stairBBox } from "../core";
@@ -115,6 +116,12 @@ export interface RoofInfo {
/** Untere/linke Ecke der Bounding-Box (fix beim Breite/Tiefe-Resize). */
minX: number;
minY: number;
/** Kanten (Umriss, dann Höfe) mit Neigungsvorgabe ([26], `roofEdgeList`). */
edges: RoofEdge[];
/** Innenhöfe: Fläche (m²) und Punktzahl je Hof, in der Reihenfolge von `Roof.holes`. */
holes: { area: number; points: number }[];
/** Ob `edgePitchDeg` gesetzt ist. */
hasEdgePitch: boolean;
}
/**
@@ -867,6 +874,9 @@ function roofSelection(project: Project, roof: Roof): Selection {
depth: Math.abs(bb.y1 - bb.y0),
minX: bb.x0,
minY: bb.y0,
edges: roofEdgeList(roof),
holes: (roof.holes ?? []).map((h) => ({ area: Math.abs(polygonArea(h)), points: h.length })),
hasEdgePitch: roof.edgePitchDeg !== undefined,
};
return {
kind: "roof",
+15 -3
View File
@@ -8,7 +8,7 @@
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { applyFillMode } from "./fillMode";
import { addItems, fieldOps, opsMutation, patchItem, patchItems, removeItems, setFieldIfChanged } from "../core";
import { addItems, fieldOps, opsMutation, patchItem, patchItems, removeItems, removeRoofHole, setFieldIfChanged, setRoofEdge } from "../core";
import type { CoreOp } from "../core";
import { useMemo, type RefObject } from "react";
import type { DrawingLevel, Layout, Project } from "../model/types";
@@ -929,8 +929,20 @@ export function usePanelHostBase(opts: {
},
onOpenOpeningEditor: (id) => setOpeningEditorId(id),
// ── Dach-Attribute (nur bei selektiertem Dach) ─────────────────────────
onSetRoofPatch: (patch) => {
if (selection?.kind === "roof") updateRoof(selection.id, patch);
onSetRoofPatch: (patch, coalesceKey) => {
if (selection?.kind === "roof") updateRoof(selection.id, patch, coalesceKey);
},
onSetRoofEdge: (index, spec) => {
if (selection?.kind !== "roof") return;
const r = (project.roofs ?? []).find((x) => x.id === selection.id);
if (!r) return;
// Zahl tippen: gleicher Schlüssel je Kante ⇒ ein Undo-Schritt; Giebel-Schalter einzeln.
updateRoof(selection.id, setRoofEdge(r, index, spec), spec.kind === "pitch" ? `roof-edge-${selection.id}-${index}` : undefined);
},
onRemoveRoofHole: (k) => {
if (selection?.kind !== "roof") return;
const r = (project.roofs ?? []).find((x) => x.id === selection.id);
if (r) updateRoof(selection.id, removeRoofHole(r, k));
},
// ── Schnitt-/Ansichtslinie (nur bei selektierter Linie) ────────────────
sectionLine,
+8
View File
@@ -182,6 +182,14 @@ export function CommandIcon({ name }: { name: string }) {
<line x1="8" y1="3" x2="8" y2="9" strokeDasharray="1.5 1.5" />
</svg>
);
case "roofhole":
// Dachhof: Dach-Umriss mit ausgespartem Innenhof.
return (
<svg {...common}>
<polygon points="2,12 3.5,4 12.5,4 14,12" />
<rect x="6" y="6.5" width="4" height="3" strokeDasharray="1.4 1.2" />
</svg>
);
case "ceilingopening":
// Deckenloch: Decken-Rechteck mit ausgespartem Innenrechteck.
return (