diff --git a/src/panels/AttributesPanel.tsx b/src/panels/AttributesPanel.tsx index b39bf922..b2613403 100644 --- a/src/panels/AttributesPanel.tsx +++ b/src/panels/AttributesPanel.tsx @@ -41,19 +41,15 @@ const END_MARK_OPTIONS: EndMark[] = ["none", "arrow", "arrowOpen", "dot", "tick" // Element-spezifische Attribut-Abschnitte (Wand/Decke/Öffnung/Treppe/Raum) — // aus ObjectInfoPanel hierher verschoben (Ribbon Phase 3: ObjectInfo trägt nur // noch Bezugspunkt + Masse). -import { - WallSection, - CeilingSection, - RoofSection, - OpeningSection, - StairSection, - RoomSection, - ExtrudedSolidSection, - ColumnSection, - SectionLineSection, - DetailRefSection, - DimRefsSection, -} from "./ObjectInfoPanel"; +import { WallSection } from "./objectInfo/WallSection"; +import { CeilingSection } from "./objectInfo/CeilingSection"; +import { RoofSection } from "./objectInfo/RoofSections"; +import { OpeningSection } from "./objectInfo/OpeningSections"; +import { StairSection } from "./objectInfo/StairSection"; +import { RoomSection } from "./objectInfo/RoomSection"; +import { ExtrudedSolidSection, ColumnSection } from "./objectInfo/SolidSections"; +import { SectionLineSection } from "./objectInfo/SectionLineSection"; +import { DetailRefSection, DimRefsSection } from "./objectInfo/RefSections"; import { SurfacePatternPlacement } from "./SurfacePatternPlacement"; /** UI-Zustand des 3-Optionen-Quellen-Dropdowns (nicht 1:1 das Modell-Feld: diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index 404530f4..b01bd9b6 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -13,81 +13,43 @@ // // Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). Alle sichtbaren // Texte über t(...). +// +// [165] Die Abschnitte (Wand, Decke, Dach, Treppe …) liegen in `objectInfo/`; `AttributesPanel` ruft sie +// von dort, das Panel selbst nur Baum, Messwerte und die gemeinsamen Felder. -import { UValueRow } from "./UValueRow"; import { lengthFromDisplay, lengthToDisplay, unitsForLevel, xToDisplay, yFromDisplay, yToDisplay } from "../tools/displayUnits"; -import { solidProps } from "../engine/truckSolid"; -import type { SolidProps, SolidSpec } from "../engine/truckSolid"; -import { useEffect, useMemo, useRef, useState } from "react"; -import { dormerStatus } from "../analysis/dormerStatus"; -// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) — -// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs) -// (reine UI-Default-Anzeige, kein Re-Export nötig). -const OPENING_LINE_DEFAULT_COLOR = "#1a1a1a"; -const OPENING_LINE_DEFAULT_WEIGHT = 0.02; +import { useMemo, useState } from "react"; import { t } from "../i18n"; -import type { TranslationKey } from "../i18n"; -import { flattenCategories, formatM } from "../model/types"; -import type { - DimRef, - Dormer, - DormerKind, - DrawingLevel, - Project, - RoofShape, - Room, - SiaCategory, - SliceTermination, - StairShape, - Tree, - TreeFoliage, - TreeShape, - TreeStatus, - Vec2, - VerticalAnchor, - WallReferenceLine, -} from "../model/types"; -import { SIA_CATEGORIES, siaLabelFull, surfaceOpeningInfo } from "../core"; -import { ROOM_USAGES, roomBook, usageLabel } from "../core"; -import type { EdgeSpec, RoofEdge } from "../core"; +import { flattenCategories } from "../model/types"; import { Dropdown } from "../ui/Dropdown"; -import type { DetailLevel } from "../model/viewTypes"; -import { ColorHexField } from "../ui/ColorHexField"; import { usePanelHost } from "./host"; -import type { - CeilingInfo, - ColumnInfo, - DetailRefInfo, - ExtrudedSolidInfo, - OpeningInfo, - RoofInfo, - RoomInfo, - StairInfo, - WallInfo, -} from "../state/selectionInfo"; -import type { MeasurementReadout } from "../tools/types"; import { useStore } from "../state/appStore"; -import { patchItem } from "../core"; import { excavationQuantities } from "../core"; import { ContextObjectProps } from "./ContextObjectProps"; import { SunStudySection } from "./SunStudySection"; import { SiteRulesSection } from "./SiteRulesSection"; +import { TreeSection } from "./objectInfo/TreeSection"; +import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks"; +import { DimensionField, RotateField } from "./objectInfo/fields"; // ── Bezugspunkt-Raster ─────────────────────────────────────────────────────── // Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0). // Reihenfolge des Arrays = Lesereihenfolge des Grids (links→rechts, oben→unten). const FRACTIONS = [0, 0.5, 1] as const; + /** Stabiler Schlüssel je Anker (z. B. "0-0.5"), unabhängig von Float-Anzeige. */ function anchorKey(fx: number, fy: number): string { return `${fx}-${fy}`; } + /** Radiant → Grad, normiert auf [0, 360) (für Winkel-Anzeigefelder). */ function toDeg360(rad: number): number { return (((rad * 180) / Math.PI) % 360 + 360) % 360; } + export function ObjectInfoPanel() { const host = usePanelHost(); const sel = host.selection; @@ -406,2442 +368,3 @@ export function ObjectInfoPanel() { ); } - -// ── Raum-Attribut-Abschnitt ────────────────────────────────────────────────── -// Editierbarer Name, SIA-416-Kategorie (5 Blatt-Kategorien), abgeleitete Fläche -// + Umfang (read-only), Referenzgeschoss, sowie ein Button, der den Rich-Text- -// Stempel-Editor öffnet. Alle Werte/Setter über den Host. -export function RoomSection({ - room, - roomId, - host, -}: { - room: RoomInfo; - roomId: string; - host: ReturnType; -}) { - return ( - <> -
-
{t("objinfo.room.section")}
- - {/* Name (editierbar). */} -
- {t("objinfo.room.name")} - host.onSetRoomName(e.target.value)} - title={t("objinfo.room.name")} - /> -
- - {/* SIA-416-Kategorie (5 Blatt-Kategorien). */} -
- {t("objinfo.room.sia")} - host.onSetRoomSia(v as SiaCategory)} - options={SIA_CATEGORIES.map((c) => ({ - value: c, - label: siaLabelFull(c), - }))} - title={t("objinfo.room.sia")} - width={170} - /> -
- - {/* Fläche + Umfang (read-only, abgeleitet). */} -
- {t("objinfo.room.area")} - {room.area.toFixed(2)} m² -
-
- {t("objinfo.room.perimeter")} - {formatM(room.perimeter)} -
- - {/* Referenzgeschoss (read-only). */} -
- {t("objinfo.room.refFloor")} - {room.floorName} -
- - {/* [158] Raumbuch: Nutzung und Oberflächen. */} - - - {/* Stempel bearbeiten (öffnet den Rich-Text-Editor). */} - - - ); -} - -type RoomFinishField = "floorFinish" | "wallFinish" | "ceilingFinish" | "floorBuildUp"; - -/** [158] Nutzung (Nassraum abgeleitet) und Oberflächen Boden/Wand/Decke (Material aus dem Projekt oder - * Freitext; ein eingegebener Material-Name wird als Verweis gespeichert) und Bodenaufbau. */ -function RoomFinishFields({ roomId, host }: { roomId: string; host: ReturnType }) { - const applyChange = useStore((s) => s.applyChange); - const project = host.project; - const room = (project.rooms ?? []).find((r) => r.id === roomId); - if (!room) return null; - const comps = project.components; - const listId = `room-finish-materials-${roomId}`; - const shown = (v: string | undefined) => comps.find((c) => c.id === v)?.name ?? v ?? ""; - const set = (field: RoomFinishField | "usage", value: string | undefined) => - applyChange((p: Project) => patchItem(p, "rooms", roomId, { [field]: value } as Partial), `room:${roomId}:${field}`); - const setFinish = (field: RoomFinishField, text: string) => { - const v = text.trim(); - if (!v) return set(field, undefined); - const comp = field === "floorBuildUp" ? undefined : comps.find((c) => c.name.trim() === v); - set(field, comp ? comp.id : text); - }; - // Nassraum wie im Kern (Nutzung, sonst Name), für [156] „Nassräume" im Grundriss. - const wet = roomBook(project).rows.find((r) => r.id === roomId)?.wet ?? false; - const finishInput = (field: RoomFinishField, label: TranslationKey) => ( -
- {t(label)} - setFinish(field, e.target.value)} - title={t(label)} - /> -
- ); - return ( - <> -
- {t("objinfo.room.usage")} - set("usage", v || undefined)} - options={[{ value: "", label: t("objinfo.room.usageNone") }, ...ROOM_USAGES.map((u) => ({ value: u, label: usageLabel(u) }))]} - title={t("objinfo.room.usage")} - width={170} - /> -
- {wet && ( -
- {t("objinfo.room.wet")} - ✓ -
- )} -
{t("objinfo.room.finishes")}
- - {comps.map((c) => ( - - {finishInput("floorFinish", "objinfo.room.floorFinish")} - {finishInput("wallFinish", "objinfo.room.wallFinish")} - {finishInput("ceilingFinish", "objinfo.room.ceilingFinish")} - {finishInput("floorBuildUp", "objinfo.room.buildUp")} - - ); -} - -// ── Schnitt-/Ansichtslinien-Abschnitt (Object-Info; nur die gewählte Linie) ── -// Name (editierbar), Blickrichtung umkehren (directionSign-Flip), Endpunkt- -// Koordinaten (editierbar) + Schnitt-Tiefe; Löschen setzt linePoints zurück -// (die Ebene bleibt bestehen). Eine Schnittlinie ist KEIN Projekt-Bauteil, -// darum kommt sie über `host.sectionLine` (nicht über `selection`). -export function SectionLineSection({ - level, - host, -}: { - level: DrawingLevel; - host: ReturnType; -}) { - const line = level.linePoints; - const kindLabel = - level.kind === "elevation" - ? t("objinfo.sectionLine.kind.elevation") - : t("objinfo.sectionLine.kind.section"); - const patchPoint = (which: 0 | 1, axis: "x" | "y", value: number) => { - if (!line) return; - const next: [Vec2, Vec2] = [{ ...line[0] }, { ...line[1] }]; - next[which] = { ...next[which], [axis]: value }; - host.onSetSectionLinePatch({ linePoints: next }); - }; - const coordField = (labelKey: TranslationKey, value: number, on: (v: number) => void) => ( -
- {t(labelKey)} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) on(v); - }} - title={t(labelKey)} - /> -
- ); - return ( - <> -
-
- {t("objinfo.sectionLine.section")} · {kindLabel} -
- - {/* Name (editierbar). */} -
- {t("objinfo.sectionLine.name")} - host.onSetSectionLinePatch({ name: e.target.value })} - title={t("objinfo.sectionLine.name")} - /> -
- - {/* Blickrichtung umkehren (directionSign-Flip). */} - - - {/* 3D-Live-Schnitt an diese Linie binden (nur mit gesetzter Linie sinnvoll): - der Viewport clippt dann vertikal entlang dieser Ebene. */} - {line && ( -
- {t("objinfo.sectionLine.cut3d")} - host.onToggleSection3dCut(level.id)} - title={t("objinfo.sectionLine.cut3d")} - /> -
- )} - - {/* Endpunkt-Koordinaten (nur wenn eine Linie gesetzt ist). */} - {line && ( - <> - {coordField("objinfo.sectionLine.startX", line[0].x, (v) => patchPoint(0, "x", v))} - {coordField("objinfo.sectionLine.startY", line[0].y, (v) => patchPoint(0, "y", v))} - {coordField("objinfo.sectionLine.endX", line[1].x, (v) => patchPoint(1, "x", v))} - {coordField("objinfo.sectionLine.endY", line[1].y, (v) => patchPoint(1, "y", v))} - - )} - - {/* Schnitt-Tiefe (leer = unbegrenzt). */} -
- {t("objinfo.sectionLine.depth")} - { - const raw = e.target.value.trim(); - if (raw === "") { - host.onSetSectionLinePatch({ depth: undefined }); - return; - } - const v = Number(raw); - if (Number.isFinite(v) && v > 0) host.onSetSectionLinePatch({ depth: v }); - }} - title={t("objinfo.sectionLine.depth")} - /> -
- - {/* Verdeckte Kanten (gestrichelt) — Default aus (blasses Liniengewirr). */} -
- {t("objinfo.sectionLine.hiddenLines")} - host.onSetSectionLinePatch({ hiddenLines: e.target.checked })} - title={t("objinfo.sectionLine.hiddenLines")} - /> -
- - {/* Automatische Höhenkoten (Geschosse + oberste Kante). */} -
- {t("objinfo.sectionLine.levelMarks")} - host.onSetSectionLinePatch({ levelMarks: e.target.checked ? undefined : false })} - title={t("objinfo.sectionLine.levelMarks")} - /> -
- - {/* Grundriss-Unterlage: ein Geschoss ausgerichtet unter dem Schnitt/der Ansicht. */} - {line && ( -
- {t("objinfo.sectionLine.planUnderlay")} - host.onSetSectionLinePatch({ planUnderlayId: v || undefined })} - options={[ - { value: "", label: t("objinfo.sectionLine.planUnderlay.none") }, - ...host.project.drawingLevels - .filter((l) => l.kind === "floor") - .map((l) => ({ value: l.id, label: l.name })), - ]} - title={t("objinfo.sectionLine.planUnderlay")} - width={150} - /> -
- )} - - {/* Löschen: linePoints zurücksetzen (die Ebene bleibt bestehen). */} - - - ); -} - -// ── Assoziative Bemassung ([38]) ──────────────────────────────────────────── -// Je Punkt: frei, angehängt (Merkmal + Element) oder Bezug verloren; „Bemassung lösen" entfernt alle. -export function DimRefsSection({ - refs, - drawingId, - host, -}: { - refs: (DimRef | null)[]; - drawingId: string; - host: ReturnType; -}) { - const lost = refs.some((r) => r?.lost); - return ( - <> -
-
{t("objinfo.dimRefs.section")}
- {refs.map((r, i) => ( -
- {t("objinfo.dimRefs.point", { n: i + 1 })} - - {!r - ? t("objinfo.dimRefs.free") - : r.lost - ? t("objinfo.dimRefs.lost", { id: r.id }) - : `${t(`objinfo.dimRefs.feature.${r.feature}` as TranslationKey)} · ${r.id}${r.id2 ? ` / ${r.id2}` : ""}`} - -
- ))} - {lost &&
{t("objinfo.dimRefs.lostHint")}
} -
- -
- - ); -} - -// ── Detail-/Schnitt-Verweis-Attribut-Abschnitt ────────────────────────────── -// Bezeichner (obere Zeile) + Blattverknüpfung (Dropdown der Project.layouts, -// „kein Verweis" löst sie); ohne Verknüpfung zusätzlich ein manueller -// Blattname-Platzhalter (untere Zeile, s. `DetailRefInfo`-Kommentar). -export function DetailRefSection({ - detailRef, - drawingId, - host, -}: { - detailRef: DetailRefInfo; - drawingId: string; - host: ReturnType; -}) { - return ( - <> -
-
{t("objinfo.detailRef.section")}
- -
- {t("objinfo.detailRef.label")} - host.onSetDetailRefLabel(drawingId, e.target.value)} - title={t("objinfo.detailRef.label")} - /> -
- -
- {t("objinfo.detailRef.sheet")} - host.onSetDetailRefSheetLayout(drawingId, v === "" ? undefined : v)} - options={[ - { value: "", label: t("objinfo.detailRef.sheet.none") }, - ...detailRef.availableLayouts.map((l) => ({ value: l.id, label: l.name })), - ]} - title={t("objinfo.detailRef.sheet")} - width={130} - /> -
- - {!detailRef.sheetLayoutId && ( -
- {t("objinfo.detailRef.sheetLabel")} - host.onSetDetailRefSheetLabel(drawingId, e.target.value)} - title={t("objinfo.detailRef.sheetLabel")} - /> -
- )} - - ); -} - -/** Volumen/Oberfläche/Schwerpunkt aus truck (asynchron, aus dem tessellierten B-Rep). */ -function SolidPropsRows({ spec }: { spec: SolidSpec | null }) { - const [props, setProps] = useState(null); - const key = JSON.stringify(spec); - useEffect(() => { - let alive = true; - setProps(null); - if (!spec) return; - solidProps(spec).then( - (p) => alive && setProps(p), - () => alive && setProps(null), - ); - return () => { - alive = false; - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [key]); - if (!props) return null; - const f = (v: number, d = 2) => v.toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d }); - return ( - <> -
- {t("objinfo.extrudedSolid.volume")} - {f(props.volume)} m³ -
-
- {t("objinfo.extrudedSolid.surface")} - {f(props.area)} m² -
-
- {t("objinfo.extrudedSolid.centroid")} - - {f(props.centroid[0])} / {f(props.centroid[1])} / {f(props.centroid[2])} - -
- {!props.closed &&
{t("objinfo.extrudedSolid.notClosed")}
} - - ); -} - -// ── Extrusions-Attribut-Abschnitt (truck-Integration) ─────────────────────── -// Höhe editierbar (löst Re-Extrusion aus); Grundfläche + Geschoss read-only. -export function ExtrudedSolidSection({ - solid, - host, -}: { - solid: ExtrudedSolidInfo; - host: ReturnType; -}) { - return ( - <> -
-
{t("objinfo.extrudedSolid.section")}
- - {/* Höhe (editierbar, > 0) — löst eine Re-Extrusion (truck-WASM) aus. */} -
- {t("objinfo.extrudedSolid.height")} - { - const v = Number(e.target.value); - if (Number.isFinite(v) && v > 0) host.onSetExtrudedSolidHeight(v); - }} - title={t("objinfo.extrudedSolid.height")} - /> -
- - - - {/* Abstand über Geschoss-UK (Brüstungs-/Durchbruchshöhe). */} -
- {t("objinfo.extrudedSolid.baseOffset")} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) host.onSetExtrudedSolidBaseOffset(v); - }} - title={t("objinfo.extrudedSolid.baseOffset")} - /> -
- - {/* Abzugskörper: zieht sich von Wänden/Decken/Stützen ab (Grundriss, Schnitt, 3D, STEP). */} - {solid.canSubtract && ( -
- {t("objinfo.extrudedSolid.subtract")} - host.onSetExtrudedSolidSubtract(e.target.checked)} - title={t("objinfo.extrudedSolid.subtractHint")} - /> -
- )} - - {solid.brepLabel && ( -
- {t("objinfo.extrudedSolid.brep")} - {solid.brepLabel} -
- )} - - {/* Eckenradius (editierbar, ≥ 0): echte Kreisbögen an den Ecken der Aussenkontur. */} - {!solid.brepLabel && ( -
- {t("objinfo.extrudedSolid.cornerRadius")} - { - const v = Number(e.target.value); - if (Number.isFinite(v) && v >= 0) host.onSetExtrudedSolidCornerRadius(v); - }} - title={t("objinfo.extrudedSolid.cornerRadius")} - /> -
- )} - - {/* Fase (editierbar, ≥ 0): gerade Abschrägung der Ecken der Aussenkontur. */} - {!solid.brepLabel && ( -
- {t("objinfo.extrudedSolid.chamfer")} - { - const v = Number(e.target.value); - if (Number.isFinite(v) && v >= 0) host.onSetExtrudedSolidChamfer(v); - }} - title={t("objinfo.extrudedSolid.chamfer")} - /> -
- )} - - {/* Verjüngung (editierbar, 0..1) — löst eine Re-Extrusion (truck-WASM) aus. */} - {!solid.brepLabel && ( -
- {t("objinfo.extrudedSolid.taper")} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) host.onSetExtrudedSolidTaper(v); - }} - title={t("objinfo.extrudedSolid.taper")} - /> -
- )} - - {/* Grundfläche (read-only, abgeleitet). */} -
- {t("objinfo.extrudedSolid.area")} - {solid.area.toFixed(2)} m² -
- - {/* Geschoss (read-only). */} -
- {t("objinfo.extrudedSolid.floor")} - {solid.floorName} -
- - ); -} - -// ── Stützen-Attribut-Abschnitt (Tragwerk) ─────────────────────────────────── -// Profil (Rechteck/Kreis) + Masse, Höhe, Drehung editierbar; Geschoss + UK/OK -// read-only. -export function ColumnSection({ - column, - host, -}: { - column: ColumnInfo; - host: ReturnType; -}) { - return ( - <> -
-
{t("objinfo.column.section")}
- - {/* Profil-Dropdown (Rechteck/Kreis). */} -
- {t("objinfo.column.profile")} - host.onSetColumnProfileKind(v as "rect" | "round")} - options={[ - { value: "rect", label: t("objinfo.column.profile.rect") }, - { value: "round", label: t("objinfo.column.profile.round") }, - ]} - title={t("objinfo.column.profile")} - width={130} - /> -
- - {/* Editierbare Masse je Profil. */} - {column.profile.kind === "round" ? ( - host.onSetColumnRadius(v)} - /> - ) : ( - <> - host.onSetColumnWidth(v)} - /> - host.onSetColumnDepth(v)} - /> - - )} - - host.onSetColumnHeight(v)} - /> - - {/* Drehung (Grad). */} -
- {t("objinfo.column.rotation")} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) host.onSetColumnRotation(v); - }} - title={t("objinfo.column.rotation")} - /> -
- - {/* Geschoss (read-only). */} -
- {t("objinfo.column.floor")} - {column.floorName} -
- - ); -} - -// ── Treppen-Attribut-Abschnitt ─────────────────────────────────────────────── -// Grundform (gerade/L/Wendel), Laufbreite, Stufenanzahl, Steighöhe (+ abgeleitete -// Steigungshöhe/Auftrittstiefe), Laufrichtung; Referenzgeschoss + UK/OK read-only. -/** Rechteck-Umriss (CCW) aus unterer/linker Ecke + Breite/Tiefe (für Dach-Resize). */ -function rectOutline(x0: number, y0: number, w: number, d: number) { - return [ - { x: x0, y: y0 }, - { x: x0 + w, y: y0 }, - { x: x0 + w, y: y0 + d }, - { x: x0, y: y0 + d }, - ]; -} - -/** Gauben ([G5]) des Dachs: Art, Masse, Neigung, Aufbau je Gaube; Hinzufügen über den Befehl „Gaube". */ -function DormersSection({ roof, host }: { roof: RoofInfo; host: ReturnType }) { - const dormers = roof.dormers ?? []; - const status = useMemo(() => dormerStatus(host.project), [host.project]); - const patch = (i: number, p: Partial) => - host.onSetRoofPatch({ dormers: dormers.map((d, k) => (k === i ? { ...d, ...p } : d)) }, `dormer-${i}`); - const num = (labelKey: TranslationKey, value: number, step: number, apply: (v: number) => void) => ( -
- {t(labelKey)} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) apply(v); - }} - title={t(labelKey)} - /> -
- ); - return ( - <> -
-
{t("objinfo.dormer.section")}
- {dormers.map((d, i) => ( -
- {(() => { - const st = status.find((s) => s.dormerId === d.id); - if (!st || !(st.clamped || st.invalid)) return null; - return ( -
- {st.invalid ? t("objinfo.dormer.invalid") : t("objinfo.dormer.clamped", { height: st.effectiveHeight.toFixed(2) })} -
- ); - })()} -
- {t("objinfo.dormer.kind")} - patch(i, { kind: v as DormerKind })} - options={[ - { value: "schlepp", label: t("objinfo.dormer.kind.schlepp") }, - { value: "sattel", label: t("objinfo.dormer.kind.sattel") }, - { value: "flach", label: t("objinfo.dormer.kind.flach") }, - { value: "walm", label: t("objinfo.dormer.kind.walm") }, - ]} - title={t("objinfo.dormer.kind")} - width={130} - /> - -
- {num("objinfo.dormer.width", d.width, 0.1, (v) => patch(i, { width: Math.max(0.8, v) }))} - {num("objinfo.dormer.frontHeight", d.frontHeight, 0.05, (v) => patch(i, { frontHeight: Math.max(0.5, v) }))} - {d.kind !== "flach" && - num("objinfo.dormer.pitch", d.pitchDeg ?? (d.kind === "schlepp" ? 15 : 40), 1, (v) => - patch(i, { pitchDeg: Math.max(0, Math.min(75, v)), depth: undefined }), - )} - {d.kind === "schlepp" && - num("objinfo.dormer.depth", d.depth ?? 0, 0.1, (v) => patch(i, { depth: v > 0.1 ? v : undefined }))} - {num("objinfo.dormer.overhang", d.overhang ?? 0.15, 0.05, (v) => patch(i, { overhang: Math.max(0, v) }))} -
- {t("objinfo.dormer.wallType")} - patch(i, { wallTypeId: v || undefined })} - options={[ - { value: "", label: t("objinfo.dormer.wallType.default") }, - ...host.project.wallTypes.map((wt) => ({ value: wt.id, label: wt.name })), - ]} - title={t("objinfo.dormer.wallType")} - width={130} - /> -
-
- {t("objinfo.dormer.roofType")} - patch(i, { roofTypeId: v || undefined })} - options={[ - { value: "", label: t("objinfo.dormer.roofType.host") }, - ...(host.project.roofTypes ?? []).map((rt) => ({ value: rt.id, label: rt.name })), - ]} - title={t("objinfo.dormer.roofType")} - width={130} - /> -
-
- ))} -
- -
- - ); -} - -/** Dach-Abschnitt: Form, Neigung(en), Überstand, Firstrichtung, Dicke. */ -export function RoofSection({ - roof, - host, -}: { - roof: RoofInfo; - host: ReturnType; -}) { - const numField = ( - labelKey: TranslationKey, - value: number, - step: number, - apply: (v: number) => void, - ) => ( -
- {t(labelKey)} - { - const v = Number(e.target.value); - if (Number.isFinite(v)) apply(v); - }} - title={t(labelKey)} - /> -
- ); - return ( - <> -
-
{t("objinfo.roof.section")}
- - {/* Dachform. */} -
- {t("objinfo.roof.shape")} - host.onSetRoofPatch({ shape: v as RoofShape })} - options={[ - { value: "flach", label: t("objinfo.roof.shape.flach") }, - { value: "pult", label: t("objinfo.roof.shape.pult") }, - { value: "sattel", label: t("objinfo.roof.shape.sattel") }, - { value: "walm", label: t("objinfo.roof.shape.walm") }, - { value: "mansarde", label: t("objinfo.roof.shape.mansarde") }, - { value: "zelt", label: t("objinfo.roof.shape.zelt") }, - ]} - title={t("objinfo.roof.shape")} - width={130} - /> -
- - {/* Dachtyp (mehrschichtiger Aufbau) — leer = einschichtig (Dicke unten). */} -
- {t("objinfo.roof.type")} - host.onSetRoofPatch({ roofTypeId: v || undefined })} - options={[ - { value: "", label: t("objinfo.roof.type.single") }, - ...(host.project.roofTypes ?? []).map((rt) => ({ value: rt.id, label: rt.name })), - ]} - title={t("objinfo.roof.type")} - width={130} - /> -
- - - {/* Firstrichtung (X/Y) — nur bei Formen mit First relevant. */} - {roof.shape !== "flach" && roof.shape !== "zelt" && ( -
- {t("objinfo.roof.ridgeAxis")} - host.onSetRoofPatch({ ridgeAxis: v as "x" | "y" })} - options={[ - { value: "x", label: t("objinfo.roof.ridgeAxis.x") }, - { value: "y", label: t("objinfo.roof.ridgeAxis.y") }, - ]} - title={t("objinfo.roof.ridgeAxis")} - width={130} - /> -
- )} - - {/* 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)) }), - )} - {roof.shape === "mansarde" && - numField("objinfo.roof.pitchUpper", roof.pitchUpperDeg ?? roof.pitchDeg / 2, 1, (v) => - host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }), - )} - {/* Mansarde-Untertyp (Giebel/Walm/Zelt) + Knicklage. */} - {roof.shape === "mansarde" && ( -
- {t("objinfo.roof.mansardType")} - - host.onSetRoofPatch({ mansardType: v as "giebel" | "walm" | "zelt" }) - } - options={[ - { value: "giebel", label: t("objinfo.roof.mansard.giebel") }, - { value: "walm", label: t("objinfo.roof.mansard.walm") }, - { value: "zelt", label: t("objinfo.roof.mansard.zelt") }, - ]} - title={t("objinfo.roof.mansardType")} - width={130} - /> -
- )} - {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 }), - )} - - {roof.shape === "sattel" && - numField("objinfo.roof.halfHip", (roof.halfHipRatio ?? 0) * 100, 5, (v) => - host.onSetRoofPatch({ halfHipRatio: Math.max(0, Math.min(90, v)) / 100 }), - )} - - {/* 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 && - 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) => - host.onSetRoofPatch({ overhang: Math.max(0, v) }), - )} - {roof.shape !== "flach" && - roof.shape !== "zelt" && - numField( - "objinfo.roof.overhangGable", - roof.overhangGable ?? roof.overhang, - 0.05, - (v) => host.onSetRoofPatch({ overhangGable: Math.max(0, v) }), - )} - {numField("objinfo.roof.thickness", roof.thickness, 0.02, (v) => - host.onSetRoofPatch({ thickness: Math.max(0.01, v) }), - )} - {/* 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 }), - )} - - {/* 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" && ( - - )} - {/* Innenhöfe: Liste mit Entfernen, Hinzufügen über den Befehl „Dachhof“. */} - - {roof.shape !== "pult" && ( - <> -
-
{t("objinfo.roof.courts")}
- {roof.holes.map((h, i) => ( -
- - {t("objinfo.roof.courtRow", { n: i + 1, area: h.area.toFixed(2) })} - - -
- ))} -
- -
- - )} -
- - {/* Abgeleitete Werte (read-only). */} -
- {t("objinfo.roof.ridgeHeight")} - {formatM(roof.ridgeHeight)} -
-
- {t("objinfo.roof.area")} - {roof.footprintArea.toFixed(2)} m² -
- - ); -} - -/** Kantenliste eines Dachs: Neigung je Kante (leer = Standard) + Giebel-Schalter. */ -function RoofEdgesSection({ - roof, - host, -}: { - roof: RoofInfo; - host: ReturnType; -}) { - // Tippen einer Zahl = ein Undo-Schritt je Kante (gleicher coalesceKey, s. Host). - const setEdge = (e: RoofEdge, spec: EdgeSpec) => host.onSetRoofEdge(e.index, spec); - return ( - <> -
-
{t("objinfo.roof.edges")}
- {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 ( -
- - {label} - - { - 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 }); - }} - /> - -
- ); - })} - {roof.hasEdgePitch && ( -
- -
- )} - - ); -} - -/** - * [151] Läufe und Podest einer Podesttreppe (L, U, gerade mit Podest): Lauflängen, Steigungen im ersten - * Lauf, Drehsinn (L/U), Treppenauge, Mittellauf und Versatz (U), Podesttiefe (U, gerade mit Podest). - */ -function StairFlightFields({ stair, host }: { stair: StairInfo; host: ReturnType }) { - const isU = stair.shape === "U"; - const turn = stair.turn ?? 1; - return ( - <> - v > 0.1 && host.onSetStairPatch({ runLength: v })} - /> - v > 0.1 && host.onSetStairPatch({ run2Length: v })} - /> - host.onSetStairPatch({ run1Steps: v >= 1 ? Math.round(v) : undefined })} - /> - {stair.shape !== "straightLanding" && ( -
- {t("objinfo.stair.turn")} -
- - -
-
- )} - {stair.shape !== "L" && ( - v > 0.1 && host.onSetStairPatch({ landingLength: v })} - /> - )} - {isU && ( - <> - v >= 0 && host.onSetStairPatch({ gap: v })} - /> - host.onSetStairPatch({ midSteps: v >= 1 ? Math.round(v) : undefined })} - /> - {(stair.midSteps ?? 0) >= 1 && ( - host.onSetStairPatch({ midOffset: v !== 0 ? v : undefined })} - /> - )} - host.onSetStairPatch({ run2Offset: v !== 0 ? v : undefined })} - /> - - )} - - ); -} - -export function StairSection({ - stair, - host, -}: { - stair: StairInfo; - host: ReturnType; -}) { - return ( - <> -
-
{t("objinfo.stair.section")}
- - {/* Treppentyp (Bibliothek) — treibt u. a. die 3D-Tragart (massiv/offen). */} -
- {t("objinfo.stair.type")} - host.onSetStairType(v)} - options={[ - { value: "", label: t("objinfo.type.none") }, - ...(host.project.stairTypes ?? []).map((st) => ({ - value: st.id, - label: st.name, - })), - ]} - title={t("objinfo.stair.type")} - width={130} - /> -
- - {/* Grundform-Dropdown. */} -
- {t("objinfo.stair.shape")} - host.onSetStairShape(v as StairShape)} - options={[ - { value: "straight", label: t("objinfo.stair.shape.straight") }, - { value: "L", label: t("objinfo.stair.shape.L") }, - { value: "U", label: t("objinfo.stair.shape.U") }, - { value: "straightLanding", label: t("objinfo.stair.shape.straightLanding") }, - { value: "spiral", label: t("objinfo.stair.shape.spiral") }, - ]} - title={t("objinfo.stair.shape")} - width={130} - /> -
- - {/* Referenzpunkt der Laufbreite (links/mitte/rechts). */} -
- {t("objinfo.stair.referenz")} - host.onSetStairReferenz(v as "links" | "mitte" | "rechts")} - options={[ - { value: "links", label: t("objinfo.stair.referenz.links") }, - { value: "mitte", label: t("objinfo.stair.referenz.mitte") }, - { value: "rechts", label: t("objinfo.stair.referenz.rechts") }, - ]} - title={t("objinfo.stair.referenz")} - width={130} - /> -
- - {/* Laufrichtung (aufwärts/abwärts). */} -
- {t("objinfo.stair.direction")} -
- - -
-
- - {/* Pfeil-Darstellung (offener Winkel- oder gefüllter SIA-Vollpfeil). */} -
- {t("objinfo.stair.arrow")} -
- - -
-
- - {/* Editierbare Maße. */} - host.onSetStairWidth(v)} - /> - {stair.shape === "spiral" && ( - host.onSetStairColumn(v)} - /> - )} - {stair.shape !== "spiral" && stair.shape !== "straight" && } - host.onSetStairSteps(v)} - /> - host.onSetStairRise(v)} - /> - - {/* Abgeleitete Werte (read-only). */} -
- {t("objinfo.stair.riser")} - {formatM(stair.riserHeight)} -
-
- {t("objinfo.stair.tread")} - {formatM(stair.treadDepth)} -
- {stair.concreteVolume !== undefined && ( -
- {t("objinfo.stair.concreteVolume")} - {stair.concreteVolume.toFixed(2)} m³ -
- )} - {stair.soffitArea !== undefined && ( -
- {t("objinfo.stair.soffitArea")} - {stair.soffitArea.toFixed(2)} m² -
- )} - - {/* Referenzgeschoss (read-only). */} -
- {t("objinfo.stair.refFloor")} - {stair.floorName} -
- -
- - {/* UK/OK (read-only). */} -
- {t("objinfo.stair.bottom")} - {formatM(stair.zBottom)} -
-
- {t("objinfo.stair.top")} - {formatM(stair.zTop)} -
- - ); -} - -// ── Öffnungs-Attribut-Abschnitt ────────────────────────────────────────────── -// Art (Fenster/Tür), Wirts-Wand, Position/Breite/Höhe/Brüstung, bei Türen -// zusätzlich Anschlag/Aufschlag/Richtung/Winkel; UK/OK read-only. -export function OpeningSection({ - opening, - host, -}: { - opening: OpeningInfo; - host: ReturnType; -}) { - const isDoor = opening.kind === "door"; - if (opening.hostRoofId || opening.hostCeilingId) { - return ; - } - return ( - <> -
-
{t("objinfo.opening.section")}
- - {/* Tür-/Fenstertyp (Bibliothek) — je nach Art aus doorTypes bzw. windowTypes. - Der ⚙-Knopf öffnet den reichen Fenster-/Tür-Einstellungsdialog. */} -
- {t("objinfo.opening.type")} - host.onSetOpeningType(v)} - options={[ - { value: "", label: t("objinfo.type.none") }, - ...(isDoor - ? host.project.doorTypes ?? [] - : host.project.windowTypes ?? [] - ).map((ty) => ({ value: ty.id, label: ty.name })), - ]} - title={t("objinfo.opening.type")} - width={106} - /> - -
- - {/* Art (Fenster/Tür) — read-only: die Gattung wird beim Platzieren mit dem - jeweiligen Werkzeug festgelegt und NICHT nachträglich umgeschaltet - (ein Fenster in eine Tür zu verwandeln ergibt keinen sinnvollen Bauteil). */} -
- {t("objinfo.opening.kind")} - - {t(isDoor ? "objinfo.opening.kind.door" : "objinfo.opening.kind.window")} - -
- - {/* Wirts-Wand (read-only Anzeige des Geschosses/Wand-Bezugs). */} -
- {t("objinfo.opening.hostWall")} - {opening.hostWallName} -
- - {/* Editierbare Maße. */} - host.onSetOpeningPosition(v)} - /> - {/* [144] Gegenstück: Abstand des zweiten Pfostens vom Wandende (nur gerade Wand). */} - {opening.wallLength != null && ( - host.onSetOpeningPosition(opening.wallLength! - v - opening.width)} - /> - )} - host.onSetOpeningWidth(v)} - /> - host.onSetOpeningHeight(v)} - /> - {!isDoor && ( - <> - host.onSetOpeningSill(v)} - /> - {/* Fenster-spezifisch: Flügelanzahl (1–4). */} - host.onSetOpeningWingCount(Math.max(1, Math.min(4, Math.round(v))))} - /> - {/* Grundriss-Linien je Kategorie: Rahmen (Blendrahmen+Stulp), Fenster - (Flügelrahmen/Sprossen), Sims (Auf-/Untersicht, nur wenn der - Fenstertyp sie aktiviert hat — s. WindowType.sillLine). */} - - - - - - )} - - {/* Tür-spezifisch: Typ / Sturzlinien / Anschlag / Aufschlagseite / Richtung / Winkel. */} - {isDoor && ( - <> - {/* Tür-Typ (normal / Wandöffnung). */} -
- {t("objinfo.opening.doorType")} - host.onSetOpeningDoorType(v as "normal" | "wandoeffnung")} - options={[ - { value: "normal", label: t("objinfo.opening.doorType.normal") }, - { value: "wandoeffnung", label: t("objinfo.opening.doorType.wandoeffnung") }, - ]} - title={t("objinfo.opening.doorType")} - width={130} - /> -
- {/* Sturzlinien-Darstellung (keine/innen/aussen/beide). */} -
- {t("objinfo.opening.lintelLines")} - host.onSetOpeningLintelLines(v as "keine" | "innen" | "aussen" | "beide")} - options={[ - { value: "keine", label: t("objinfo.opening.lintelLines.keine") }, - { value: "innen", label: t("objinfo.opening.lintelLines.innen") }, - { value: "aussen", label: t("objinfo.opening.lintelLines.aussen") }, - { value: "beide", label: t("objinfo.opening.lintelLines.beide") }, - ]} - title={t("objinfo.opening.lintelLines")} - width={130} - /> -
-
- {t("objinfo.opening.hinge")} - host.onSetOpeningHinge(v as "start" | "end")} - options={[ - { value: "start", label: t("objinfo.opening.hinge.start") }, - { value: "end", label: t("objinfo.opening.hinge.end") }, - ]} - title={t("objinfo.opening.hinge")} - width={130} - /> -
-
- {t("objinfo.opening.swing")} - host.onSetOpeningSwing(v as "left" | "right")} - options={[ - { value: "left", label: t("objinfo.opening.swing.left") }, - { value: "right", label: t("objinfo.opening.swing.right") }, - ]} - title={t("objinfo.opening.swing")} - width={130} - /> -
-
- {t("objinfo.opening.dir")} - host.onSetOpeningDir(v as "in" | "out")} - options={[ - { value: "in", label: t("objinfo.opening.dir.in") }, - { value: "out", label: t("objinfo.opening.dir.out") }, - ]} - title={t("objinfo.opening.dir")} - width={130} - /> -
- host.onSetOpeningSwingAngle(v)} - /> - - )} - - {/* Detailstufe-Übersteuerung — fehlt sie ("" = Ansicht), gilt die - ansichtsweite Detailstufe (Grundriss-Kopfzeile). Wirkt auf dasselbe - grob/mittel/fein-Symbol wie die Ansichts-Detailstufe (Türblatt-Bogen, - Rahmen/Glaslinien), nur PRO ELEMENT statt für den ganzen Plan. */} -
- {t("objinfo.opening.detailLevel")} - - host.onSetOpeningDetailLevel(v === "" ? undefined : (v as DetailLevel)) - } - options={[ - { value: "", label: t("objinfo.detailLevel.view") }, - { value: "grob", label: t("topbar.detail.grob") }, - { value: "mittel", label: t("topbar.detail.mittel") }, - { value: "fein", label: t("topbar.detail.fein") }, - ]} - title={t("objinfo.opening.detailLevel")} - width={130} - /> -
- -
- - {/* UK/OK (read-only, aus der Wand-UK + Brüstung/Höhe abgeleitet). */} -
- {t("objinfo.opening.bottom")} - {formatM(opening.zBottom)} -
-
- {t("objinfo.opening.top")} - {formatM(opening.zTop)} -
- - ); -} - -// ── Dach-/Deckenfenster ([103]) ───────────────────────────────────────────── -// Wirt (Dach/Decke + Geschoss), Breite quer und Höhe im Gefälle (in der Fläche gemessen), Lage des -// Mittelpunkts im Grundriss, Drehung nur auf waagrechten Flächen; UK/OK und Neigung aus dem Kern. -function SurfaceOpeningSection({ - opening, - host, -}: { - opening: OpeningInfo; - host: ReturnType; -}) { - const info = surfaceOpeningInfo(host.project, opening.id); - const roof = !!opening.hostRoofId; - const hp = opening.hostPoint ?? { x: 0, y: 0 }; - return ( - <> -
-
{t("objinfo.opening.section")}
-
- {t("objinfo.opening.type")} - host.onSetOpeningType(v)} - options={[ - { value: "", label: t("objinfo.type.none") }, - ...(host.project.windowTypes ?? []).map((ty) => ({ value: ty.id, label: ty.name })), - ]} - title={t("objinfo.opening.type")} - width={106} - /> - -
-
- {t(roof ? "objinfo.opening.hostRoof" : "objinfo.opening.hostCeiling")} - {info?.hostName ?? "–"} -
- host.onSetOpeningWidth(v)} /> - host.onSetOpeningHeight(v)} /> - host.onSetOpeningHost?.({ hostPoint: { x, y: hp.y } })} /> - host.onSetOpeningHost?.({ hostPoint: { x: hp.x, y } })} /> - {!roof && ( - host.onSetOpeningHost?.({ hostAngle: a })} - /> - )} - {info && ( - <> -
-
- {t("objinfo.opening.slope")} - {info.slopeDeg.toFixed(1)}° -
-
- {t("objinfo.opening.bottom")} - {formatM(info.zBottom)} -
-
- {t("objinfo.opening.top")} - {formatM(info.zTop)} -
- - )} - - ); -} - -// ── Decken-Attribut-Abschnitt ──────────────────────────────────────────────── -// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss + -// OK-Bindung, Fläche. Alle Werte/Setter über den Host. -/** Aussenbauteil / tragend ([97]/[98]): wirken auf Bauteil-/Öffnungslisten und das IFC-Pset. */ -function BuildingFlags({ isExternal, loadBearing, host }: { isExternal: boolean; loadBearing: boolean; host: ReturnType }) { - return ( - <> -
- {t("objinfo.isExternal")} - host.onSetBuildingFlags({ isExternal: e.target.checked })} /> -
-
- {t("objinfo.loadBearing")} - host.onSetBuildingFlags({ loadBearing: e.target.checked })} /> -
- - ); -} - -export function CeilingSection({ - ceiling, - host, -}: { - ceiling: CeilingInfo; - host: ReturnType; -}) { - const isSingle = ceiling.singleLayer; - const multiPresets = ceiling.ceilingTypes.filter((ct) => ct.layerCount > 1); - - function chooseSingle() { - if (isSingle) return; - host.onSetCeilingThickness(ceiling.thickness); - } - function chooseMulti() { - if (!isSingle) return; - const first = multiPresets[0]; - if (first) host.onSetCeilingType(first.id); - } - - return ( - <> -
-
{t("objinfo.ceiling.section")}
- - - {/* Aufbau-Typ-Segment. */} -
- {t("objinfo.ceiling.buildup")} -
- - -
-
- - {/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */} - {isSingle ? ( - host.onSetCeilingThickness(v)} - /> - ) : ( -
- {t("objinfo.ceiling.preset")} - host.onSetCeilingType(id)} - options={ceiling.ceilingTypes.map((ct) => ({ - value: ct.id, - label: ct.label, - title: ct.name, - }))} - title={t("objinfo.ceiling.preset")} - width={150} - /> -
- )} - - {/* Referenzgeschoss (read-only Anzeige). */} -
- {t("objinfo.ceiling.refFloor")} - {ceiling.floorName} -
- - - {/* Fläche + Volumen (read-only). */} -
- {t("objinfo.ceiling.area")} - {ceiling.area.toFixed(2)} m² -
-
- {t("objinfo.volume")} - {ceiling.volume.toFixed(2)} m³ -
- - {/* Aussparungen (Treppenauge/Schacht) — Liste mit Entfernen je Loch. - Anlegen über den Befehl „Deckenloch" (BIM-Ribbon). */} - {ceiling.openings.length > 0 && ( - <> -
- {t("objinfo.ceiling.openings")} - {ceiling.openings.length} -
- {ceiling.openings.map((o, i) => ( -
- - {`${i + 1}: ${o.width.toFixed(2)} × ${o.depth.toFixed(2)} m`} - - -
- ))} - - )} - -
- - {/* OK der Decke: an Geschoss gebunden ODER eigene Höhe. */} - host.onSetCeilingTop(a)} - /> - - {/* UK der Decke: an Geschoss gebunden ODER eigene Höhe; ohne Override - bleibt es beim heutigen Verhalten UK = OK − Dicke. */} - host.onSetCeilingBottom?.(a)} - /> -
- {t("objinfo.ceiling.height")} - {formatM(ceiling.zTop - ceiling.zBottom)} -
- - ); -} - -// ── Wand-Attribut-Abschnitt ────────────────────────────────────────────────── -// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss + -// Oberverknüpfung, UK/OK je Modus-Umschalter. Alle Werte/Setter über den Host. -export function WallSection({ - wall, - host, -}: { - wall: WallInfo; - host: ReturnType; -}) { - // Aufbau-Typ-Segment: einschichtig vs. mehrschichtig. Aus dem Modell - // abgeleitet (singleLayer); der Umschalter auf „mehrschichtig" wählt einen - // mehrschichtigen Wandtyp-Preset (erster mit >1 Schicht), auf „einschichtig" - // setzt er die Dicke des aktuellen Aufbaus als einschichtige Wand. - const isSingle = wall.singleLayer; - - const multiPresets = wall.wallTypes.filter((wt) => wt.layerCount > 1); - - function chooseSingle() { - if (isSingle) return; - // Auf einschichtig wechseln: aktuelle Gesamtdicke als Einzelschicht setzen. - host.onSetWallThickness(wall.thickness); - } - function chooseMulti() { - if (!isSingle) return; - const first = multiPresets[0]; - if (first) host.onSetWallType(first.id); - } - - return ( - <> -
-
{t("objinfo.wall.section")}
- - {/* Referenzlinie (wo die Achse über die Dicke liegt) — außen/mitte/innen ODER - bei mehrschichtigen Wänden eine SCHICHTTRENNLINIE (Fuge). Ein Fugenwert - wird als "off:" kodiert und übersteuert die benannte Linie. */} -
- {t("objinfo.wall.refLine")} - { - if (v.startsWith("off:")) host.onSetWallReferenceOffset(Number(v.slice(4))); - else host.onSetWallReferenceLine(v as WallReferenceLine); - }} - options={[ - { value: "left", label: t("objinfo.wall.refLine.left") }, - { value: "center", label: t("objinfo.wall.refLine.center") }, - { value: "right", label: t("objinfo.wall.refLine.right") }, - ...wall.layerBoundaries.map((b) => ({ - value: `off:${b.offset.toFixed(4)}`, - label: `${t("objinfo.wall.refLine.joint")} ${b.label}`, - })), - ]} - title={t("objinfo.wall.refLine")} - width={120} - /> -
- - {/* Terminierung am Deckenanschluss (Zuschnitt, NICHT Priorität): ob die Wand - an der Decke endet oder oberhalb wieder auftaucht. Default "both". */} -
- {t("objinfo.wall.sliceTermination")} - host.onSetWallSliceTermination(v as SliceTermination)} - options={[ - { value: "both", label: t("objinfo.wall.sliceTermination.both") }, - { value: "below", label: t("objinfo.wall.sliceTermination.below") }, - { value: "above", label: t("objinfo.wall.sliceTermination.above") }, - ]} - title={t("objinfo.wall.sliceTermination")} - width={120} - /> -
- - {/* An Dach anschliessen ([G2]): automatisch endet die Wand an der Dach-Unterkante, "Ja" - verlängert sie bis unter das Dach, "Nein" lässt die Dächer die Wand nicht schneiden. */} -
- {t("objinfo.wall.roofAttach")} - host.onSetWallRoofAttach(v as "auto" | "on" | "off")} - options={[ - { value: "auto", label: t("objinfo.wall.roofAttach.auto") }, - { value: "on", label: t("objinfo.wall.roofAttach.on") }, - { value: "off", label: t("objinfo.wall.roofAttach.off") }, - ]} - title={t("objinfo.wall.roofAttach.tip")} - width={120} - /> -
- - - {/* Aufbau-Typ-Segment. */} -
- {t("objinfo.wall.buildup")} -
- - -
-
- - {/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */} - {isSingle ? ( - host.onSetWallThickness(v)} - /> - ) : ( -
- {t("objinfo.wall.preset")} - host.onSetWallType(id)} - options={wall.wallTypes.map((wt) => ({ - value: wt.id, - label: wt.label, - title: wt.name, - }))} - title={t("objinfo.wall.preset")} - width={150} - /> -
- )} - - {/* Referenzgeschoss (read-only Anzeige). */} -
- {t("objinfo.wall.refFloor")} - {wall.floorName} -
- - - {/* Länge + Volumen (read-only). Volumen ist NETTO — Fenster/Türen - abgezogen; der Titel zeigt zusätzlich das Bruttovolumen. */} -
- {t("objinfo.wall.length")} - {formatM(wall.length)} -
-
- {t("objinfo.volume")} - 0 - ? `${t("objinfo.wall.volumeGross")}: ${wall.grossVolume.toFixed(2)} m³ − ${wall.openingVolume.toFixed(2)} m³` - : undefined - } - > - {wall.netVolume.toFixed(2)} m³ - -
- - {/* Verknüpfung zum oberen Geschoss: OK an nächstes Geschoss binden. */} - - -
- - {/* OK & UK getrennt: je „an Geschoss gebunden" ODER „eigene Höhe". OK - (oben) steht oben, UK (unten) darunter — räumlich passend (Nutzer). */} - host.onSetWallTop(a)} - /> - host.onSetWallBottom(a)} - /> - - {/* Höhe = OK − UK (abgeleitet, read-only). */} -
- {t("objinfo.wall.height")} - {formatM(wall.zTop - wall.zBottom)} -
- - ); -} - -// ── UK/OK-Zeile: Modus-Umschalter (Geschoss/eigene Höhe) + Feld ────────────── -// „Geschoss gebunden" → Geschoss-Dropdown; „eigene Höhe" → absolutes Z-Feld. -// `null`-Anchor (undefined im Modell) = Geschoss-Default; zeigt „eigene Höhe" -// mit dem aufgelösten Default-Z als Ausgangswert NICHT — Default ist -// „an Geschoss gebunden" (Geschoss-Default-Verhalten). -function VerticalAnchorRow({ - label, - anchor, - defaultZ, - floors, - defaultFloorId, - onChange, -}: { - label: string; - anchor?: VerticalAnchor; - defaultZ: number; - floors: { id: string; name: string }[]; - defaultFloorId: string; - onChange: (a: VerticalAnchor | null) => void; -}) { - const mode: "floor" | "custom" = anchor?.mode === "custom" ? "custom" : "floor"; - - function setMode(next: "floor" | "custom") { - if (next === mode) return; - if (next === "custom") { - onChange({ mode: "custom", z: defaultZ }); - } else { - // Zurück auf Geschoss-Bindung: bei vorhandenem expliziten Geschoss dieses, - // sonst Default-Geschoss → entspricht dem Geschoss-Default-Verhalten. - onChange({ mode: "floor", floorId: defaultFloorId }); - } - } - - return ( -
-
- {label} -
- - -
-
- {/* Unterzeile in normaler Label-/Wert-Struktur: Label links, Control in - der Wert-Spalte (Nutzer-Wunsch — vorher hing das Control ohne Label - im Einzug der linken Spalte). */} - {mode === "floor" ? ( -
- {t("objinfo.anchor.refFloor")} - onChange({ mode: "floor", floorId: id })} - options={floors.map((f) => ({ value: f.id, label: f.name }))} - title={t("objinfo.anchor.refFloor")} - width={150} - /> -
- ) : ( - onChange({ mode: "custom", z })} - /> - )} -
- ); -} - -// ── Editierbares Maßfeld ───────────────────────────────────────────────────── -// Kontrolliert über den vom Host gelieferten Wert, hält aber während des -// Tippens einen lokalen Entwurf. Commit auf blur/Enter; Escape verwirft. -// Nach erfolgreichem Resize liefert der Host eine neue bbox → neuer `value` → -// das Feld zeigt automatisch die aktualisierte Größe. `min` erlaubt negative -// Werte (z. B. absolute Z-Höhen unter 0). -// ── Baum ([149]) ───────────────────────────────────────────────────────────── -// Lage (Stammmitte), Masse, Form, Bestand, Laub/Nadel und Art des ersten gewählten Baums; jede Änderung -// ein Undo-Schritt (Kern prüft die Op). Bei mehreren gewählten Bäumen wirken Form/Bestand/Laub auf alle. -const TREE_SHAPES: TreeShape[] = ["round", "oval", "columnar", "conical"]; -const TREE_STATUS: TreeStatus[] = ["existing", "new", "remove"]; -const TREE_FOLIAGE: TreeFoliage[] = ["deciduous", "conifer"]; - -export function TreeSection({ ids }: { ids: readonly string[] }) { - const host = usePanelHost(); - const applyChange = useStore((s) => s.applyChange); - const trees = (host.project.trees ?? []).filter((x) => ids.includes(x.id)); - const tree = trees[0]; - if (!tree) return
{t("objinfo.empty")}
; - const locked = !!tree.locked; - const set = (patch: Partial, all = false) => - applyChange((p) => (all ? trees : [tree]).filter((x) => !x.locked).flatMap((x) => patchItem(p, "trees", x.id, patch))); - const level = host.project.drawingLevels.find((l) => l.id === tree.floorId); - return ( -
-
- {trees.length > 1 ? t("objinfo.tree.many", { n: trees.length }) : t("objinfo.kind.tree")} -
-
{t("objinfo.tree.section")}
- -
- {t("objinfo.tree.showLabel")} - set({ showLabel: e.target.checked }, true)} - title={t("objinfo.tree.showLabelHint")} - data-testid="tree-show-label" - /> -
-
- {t("objinfo.tree.status")} - set({ status: v as TreeStatus }, true)} - options={TREE_STATUS.map((v) => ({ value: v, label: t(`objinfo.tree.status.${v}` as TranslationKey) }))} - title={t("objinfo.tree.status")} - width={130} - /> -
-
- {t("objinfo.tree.shape")} - set({ shape: v as TreeShape }, true)} - options={TREE_SHAPES.map((v) => ({ value: v, label: t(`objinfo.tree.shape.${v}` as TranslationKey) }))} - title={t("objinfo.tree.shape")} - width={130} - /> -
-
- {t("objinfo.tree.foliage")} - set({ foliage: v as TreeFoliage }, true)} - options={TREE_FOLIAGE.map((v) => ({ value: v, label: t(`objinfo.tree.foliage.${v}` as TranslationKey) }))} - title={t("objinfo.tree.foliage")} - width={130} - /> -
- set({ height: v, crownBase: Math.min(tree.crownBase, 0.9 * v) })} /> - set({ crownDiameter: v })} /> - set({ crownBase: Math.min(v, 0.9 * tree.height) })} /> - set({ trunkDiameter: v })} /> - set({ position: { x: v, y: tree.position.y } })} /> - set({ position: { x: tree.position.x, y: v } })} /> -
- {t("objinfo.column.floor")} - {level?.name ?? tree.floorId} -
- {locked &&
{t("objinfo.tree.locked")}
} -
- ); -} - -function DimensionField({ - label, - value, - onCommit, - min = 0, - unit = "m", - step = 0.01, - digits = 3, -}: { - label: string; - value: number; - onCommit: (v: number) => void; - min?: number; - unit?: string; - step?: number; - /** Nachkommastellen der Anzeige (Papier-mm: 1). */ - digits?: number; -}) { - // Entwurf als String, damit Zwischenzustände (leer, „1.") tippbar sind. - // `null` = kein aktiver Entwurf → zeige den Host-Wert. - const [draft, setDraft] = useState(null); - // Enter committet und nimmt danach den Fokus — das `blur` im selben Handler sieht noch den alten - // Entwurf (State noch nicht neu gerendert) und committete ein zweites Mal (X/Y: doppelte Verschiebung). - const pending = useRef(null); - pending.current = draft; - - const shown = draft ?? (Object.is(Number(value.toFixed(digits)), -0) ? 0 : value).toFixed(digits); - - function commit() { - const d = pending.current; - if (d === null) return; - pending.current = null; - const v = Number(d); - setDraft(null); - if (isFinite(v) && v >= min) onCommit(v); - } - - return ( - - ); -} - -/** Farbe + Strichstärke (mm) einer Linien-Kategorie, mit "System"-Fallback- - * Anzeige (Override `undefined` ⇒ zeigt `fallbackColor`/`fallbackWeight`, - * Ändern setzt sofort einen expliziten Override). */ -function LineStyleRow({ - label, - value, - fallbackColor, - fallbackWeight, - onChange, -}: { - label: string; - value: { color?: string; weight?: number } | undefined; - fallbackColor: string; - fallbackWeight: number; - onChange: (v: { color?: string; weight?: number } | undefined) => void; -}) { - return ( -
- {label} - onChange({ ...value, color })} - /> - { - const w = Number(e.target.value); - if (isFinite(w) && w >= 0) onChange({ ...value, weight: w }); - }} - title={t("objinfo.lineWeight")} - /> - mm -
- ); -} - -// ── Dreh-Feld (Delta-Winkel in Grad) ───────────────────────────────────────── -// Anders als DimensionField zeigt dieses Feld KEINEN persistenten Host-Wert — -// eine „aktuelle Rotation" gibt es für die Selektion generell nicht (Wand ist -// nur eine Achse, Drawing2D/Extrusion tragen keinen Rotationswinkel). Das Feld -// ist daher ein Delta: Eingabe = Drehung ab jetzt, danach zeigt es wieder „0". -function RotateField({ onCommit }: { onCommit: (deg: number) => void }) { - const [draft, setDraft] = useState(null); - const shown = draft ?? "0"; - - function commit() { - if (draft === null) return; - const v = Number(draft); - setDraft(null); - if (isFinite(v) && v !== 0) onCommit(v); - } - - return ( - - ); -} - -// ── Mess-Werkzeug-Abschnitt ─────────────────────────────────────────────────── -// Zeigt die Live-Messwerte (letztes Segment, aufsummierte Länge, umschlossene -// Fläche, Richtung). Fläche nur, sobald der Zug ≥ 3 Ecken hat. -function MeasurementSection({ m }: { m: MeasurementReadout }) { - return ( -
-
{t("objinfo.measure.title")}
-
- {t("objinfo.measure.segment")} - {m.segment.toFixed(3)} m - {t("objinfo.measure.total")} - {m.total.toFixed(3)} m - {t("objinfo.measure.angle")} - {m.angle.toFixed(1)}° - {m.area != null && ( - <> - {t("objinfo.measure.area")} - {m.area.toFixed(2)} m² - - )} -
-
{t("objinfo.measure.hint")}
-
- ); -} - -/** [137] Schlagschatten der Ansicht angeklickt: Schalter der aktiven Ansicht (DrawingLevel.shadows, Undo). */ -function ViewShadowsInfo() { - const level = useStore((s) => s.project.drawingLevels.find((l) => l.id === s.activeLevelId)); - const applyChange = useStore((s) => s.applyChange); - return ( -
-
- {t("objinfo.kind.viewShadows")} -
-
{t("elevation.shadows.hint")}
- {level && ( - - )} -
- ); -} diff --git a/src/panels/README.md b/src/panels/README.md index 55215032..b15a395b 100644 --- a/src/panels/README.md +++ b/src/panels/README.md @@ -20,6 +20,7 @@ Kern; hier stehen Eingabe und Darstellung. Zustand über den Store (`src/state`) | Datei | Inhalt | |---|---| | `ToolsPanel.tsx`, `AttributesPanel.tsx`, `ObjectInfoPanel.tsx` | Werkzeug-Palette, Attribute, Objekt-Info der Auswahl (`ContextObjectProps.tsx`, `UValueRow.tsx`, `SurfacePatternPlacement.tsx` sind Teile davon) | +| `objectInfo/*.tsx` | Abschnitte je Element-Art (`WallSection`, `CeilingSection`, `RoofSections`, `OpeningSections`, `StairSection`, `RoomSection`, `SolidSections`, `SectionLineSection`, `RefSections`, `TreeSection`), gemeinsame Felder (`fields.tsx`) und Info-Blöcke (`InfoBlocks.tsx`); `AttributesPanel` und `ObjectInfoPanel` rufen sie (`[165]`) | | `DrawingLevelsPanel.tsx`, `LayersPanel.tsx`, `ElementTreePanel.tsx` | Zeichnungsebenen, Ebenen, Baum Geschoss → Bauteilklasse → Element | | `LayoutsPanel.tsx`, `PublishSection.tsx`, `ViewSnapshotsPanel.tsx` | Layouts als Baum, Publikationssätze (`[79]`), gespeicherte Ansichten | | `RoomBalancePanel.tsx` | Flächenbilanz mit den Abschnitten `AreaTableSection.tsx`, `KennzahlenSection.tsx`, `ProgramCompareSection.tsx`, `ElementScheduleSection.tsx`, `OpeningScheduleSection.tsx`, `RoomBookSection.tsx`; Stempel-Editor `RoomStampEditor.tsx` | diff --git a/src/panels/objectInfo/CeilingSection.tsx b/src/panels/objectInfo/CeilingSection.tsx new file mode 100644 index 00000000..f9d6ae13 --- /dev/null +++ b/src/panels/objectInfo/CeilingSection.tsx @@ -0,0 +1,156 @@ +// Abschnitt „Decke" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Aufbau, Höhenlage, Öffnungen. +// Gerufen von `AttributesPanel`. + +import type { CeilingInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import { UValueRow } from "../UValueRow"; +import { formatM } from "../../model/types"; +import { BuildingFlags, DimensionField, VerticalAnchorRow } from "./fields"; + +export function CeilingSection({ + ceiling, + host, +}: { + ceiling: CeilingInfo; + host: ReturnType; +}) { + const isSingle = ceiling.singleLayer; + const multiPresets = ceiling.ceilingTypes.filter((ct) => ct.layerCount > 1); + + function chooseSingle() { + if (isSingle) return; + host.onSetCeilingThickness(ceiling.thickness); + } + function chooseMulti() { + if (!isSingle) return; + const first = multiPresets[0]; + if (first) host.onSetCeilingType(first.id); + } + + return ( + <> +
+
{t("objinfo.ceiling.section")}
+ + + {/* Aufbau-Typ-Segment. */} +
+ {t("objinfo.ceiling.buildup")} +
+ + +
+
+ + {/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */} + {isSingle ? ( + host.onSetCeilingThickness(v)} + /> + ) : ( +
+ {t("objinfo.ceiling.preset")} + host.onSetCeilingType(id)} + options={ceiling.ceilingTypes.map((ct) => ({ + value: ct.id, + label: ct.label, + title: ct.name, + }))} + title={t("objinfo.ceiling.preset")} + width={150} + /> +
+ )} + + {/* Referenzgeschoss (read-only Anzeige). */} +
+ {t("objinfo.ceiling.refFloor")} + {ceiling.floorName} +
+ + + {/* Fläche + Volumen (read-only). */} +
+ {t("objinfo.ceiling.area")} + {ceiling.area.toFixed(2)} m² +
+
+ {t("objinfo.volume")} + {ceiling.volume.toFixed(2)} m³ +
+ + {/* Aussparungen (Treppenauge/Schacht) — Liste mit Entfernen je Loch. + Anlegen über den Befehl „Deckenloch" (BIM-Ribbon). */} + {ceiling.openings.length > 0 && ( + <> +
+ {t("objinfo.ceiling.openings")} + {ceiling.openings.length} +
+ {ceiling.openings.map((o, i) => ( +
+ + {`${i + 1}: ${o.width.toFixed(2)} × ${o.depth.toFixed(2)} m`} + + +
+ ))} + + )} + +
+ + {/* OK der Decke: an Geschoss gebunden ODER eigene Höhe. */} + host.onSetCeilingTop(a)} + /> + + {/* UK der Decke: an Geschoss gebunden ODER eigene Höhe; ohne Override + bleibt es beim heutigen Verhalten UK = OK − Dicke. */} + host.onSetCeilingBottom?.(a)} + /> +
+ {t("objinfo.ceiling.height")} + {formatM(ceiling.zTop - ceiling.zBottom)} +
+ + ); +} diff --git a/src/panels/objectInfo/InfoBlocks.tsx b/src/panels/objectInfo/InfoBlocks.tsx new file mode 100644 index 00000000..84b6c0aa --- /dev/null +++ b/src/panels/objectInfo/InfoBlocks.tsx @@ -0,0 +1,59 @@ +// Kleine Info-Blöcke der Objekt-Info ([165] aus `ObjectInfoPanel.tsx`): Messwert-Anzeige und Hinweis zu den +// Schlagschatten der Ansicht. Gerufen von `ObjectInfoPanel`. + +import type { MeasurementReadout } from "../../tools/types"; +import { t } from "../../i18n"; +import { useStore } from "../../state/appStore"; +import { patchItem } from "../../core"; + +// ── Mess-Werkzeug-Abschnitt ─────────────────────────────────────────────────── +// Zeigt die Live-Messwerte (letztes Segment, aufsummierte Länge, umschlossene +// Fläche, Richtung). Fläche nur, sobald der Zug ≥ 3 Ecken hat. +export function MeasurementSection({ m }: { m: MeasurementReadout }) { + return ( +
+
{t("objinfo.measure.title")}
+
+ {t("objinfo.measure.segment")} + {m.segment.toFixed(3)} m + {t("objinfo.measure.total")} + {m.total.toFixed(3)} m + {t("objinfo.measure.angle")} + {m.angle.toFixed(1)}° + {m.area != null && ( + <> + {t("objinfo.measure.area")} + {m.area.toFixed(2)} m² + + )} +
+
{t("objinfo.measure.hint")}
+
+ ); +} + + +/** [137] Schlagschatten der Ansicht angeklickt: Schalter der aktiven Ansicht (DrawingLevel.shadows, Undo). */ +export function ViewShadowsInfo() { + const level = useStore((s) => s.project.drawingLevels.find((l) => l.id === s.activeLevelId)); + const applyChange = useStore((s) => s.applyChange); + return ( +
+
+ {t("objinfo.kind.viewShadows")} +
+
{t("elevation.shadows.hint")}
+ {level && ( + + )} +
+ ); +} diff --git a/src/panels/objectInfo/OpeningSections.tsx b/src/panels/objectInfo/OpeningSections.tsx new file mode 100644 index 00000000..9200f0b5 --- /dev/null +++ b/src/panels/objectInfo/OpeningSections.tsx @@ -0,0 +1,394 @@ +// Abschnitte „Öffnung" und „Flächenöffnung" der Attribute ([165] aus `ObjectInfoPanel.tsx`) samt der +// Linien-Übersteuerung der Öffnung. Gerufen von `AttributesPanel`. + +import type { OpeningInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import type { DetailLevel } from "../../model/viewTypes"; +import { formatM } from "../../model/types"; +import { surfaceOpeningInfo } from "../../core"; +import { ColorHexField } from "../../ui/ColorHexField"; +import { DimensionField } from "./fields"; + +// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) — +// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs) +// (reine UI-Default-Anzeige, kein Re-Export nötig). +const OPENING_LINE_DEFAULT_COLOR = "#1a1a1a"; + +const OPENING_LINE_DEFAULT_WEIGHT = 0.02; + + +// ── Öffnungs-Attribut-Abschnitt ────────────────────────────────────────────── +// Art (Fenster/Tür), Wirts-Wand, Position/Breite/Höhe/Brüstung, bei Türen +// zusätzlich Anschlag/Aufschlag/Richtung/Winkel; UK/OK read-only. +export function OpeningSection({ + opening, + host, +}: { + opening: OpeningInfo; + host: ReturnType; +}) { + const isDoor = opening.kind === "door"; + if (opening.hostRoofId || opening.hostCeilingId) { + return ; + } + return ( + <> +
+
{t("objinfo.opening.section")}
+ + {/* Tür-/Fenstertyp (Bibliothek) — je nach Art aus doorTypes bzw. windowTypes. + Der ⚙-Knopf öffnet den reichen Fenster-/Tür-Einstellungsdialog. */} +
+ {t("objinfo.opening.type")} + host.onSetOpeningType(v)} + options={[ + { value: "", label: t("objinfo.type.none") }, + ...(isDoor + ? host.project.doorTypes ?? [] + : host.project.windowTypes ?? [] + ).map((ty) => ({ value: ty.id, label: ty.name })), + ]} + title={t("objinfo.opening.type")} + width={106} + /> + +
+ + {/* Art (Fenster/Tür) — read-only: die Gattung wird beim Platzieren mit dem + jeweiligen Werkzeug festgelegt und NICHT nachträglich umgeschaltet + (ein Fenster in eine Tür zu verwandeln ergibt keinen sinnvollen Bauteil). */} +
+ {t("objinfo.opening.kind")} + + {t(isDoor ? "objinfo.opening.kind.door" : "objinfo.opening.kind.window")} + +
+ + {/* Wirts-Wand (read-only Anzeige des Geschosses/Wand-Bezugs). */} +
+ {t("objinfo.opening.hostWall")} + {opening.hostWallName} +
+ + {/* Editierbare Maße. */} + host.onSetOpeningPosition(v)} + /> + {/* [144] Gegenstück: Abstand des zweiten Pfostens vom Wandende (nur gerade Wand). */} + {opening.wallLength != null && ( + host.onSetOpeningPosition(opening.wallLength! - v - opening.width)} + /> + )} + host.onSetOpeningWidth(v)} + /> + host.onSetOpeningHeight(v)} + /> + {!isDoor && ( + <> + host.onSetOpeningSill(v)} + /> + {/* Fenster-spezifisch: Flügelanzahl (1–4). */} + host.onSetOpeningWingCount(Math.max(1, Math.min(4, Math.round(v))))} + /> + {/* Grundriss-Linien je Kategorie: Rahmen (Blendrahmen+Stulp), Fenster + (Flügelrahmen/Sprossen), Sims (Auf-/Untersicht, nur wenn der + Fenstertyp sie aktiviert hat — s. WindowType.sillLine). */} + + + + + + )} + + {/* Tür-spezifisch: Typ / Sturzlinien / Anschlag / Aufschlagseite / Richtung / Winkel. */} + {isDoor && ( + <> + {/* Tür-Typ (normal / Wandöffnung). */} +
+ {t("objinfo.opening.doorType")} + host.onSetOpeningDoorType(v as "normal" | "wandoeffnung")} + options={[ + { value: "normal", label: t("objinfo.opening.doorType.normal") }, + { value: "wandoeffnung", label: t("objinfo.opening.doorType.wandoeffnung") }, + ]} + title={t("objinfo.opening.doorType")} + width={130} + /> +
+ {/* Sturzlinien-Darstellung (keine/innen/aussen/beide). */} +
+ {t("objinfo.opening.lintelLines")} + host.onSetOpeningLintelLines(v as "keine" | "innen" | "aussen" | "beide")} + options={[ + { value: "keine", label: t("objinfo.opening.lintelLines.keine") }, + { value: "innen", label: t("objinfo.opening.lintelLines.innen") }, + { value: "aussen", label: t("objinfo.opening.lintelLines.aussen") }, + { value: "beide", label: t("objinfo.opening.lintelLines.beide") }, + ]} + title={t("objinfo.opening.lintelLines")} + width={130} + /> +
+
+ {t("objinfo.opening.hinge")} + host.onSetOpeningHinge(v as "start" | "end")} + options={[ + { value: "start", label: t("objinfo.opening.hinge.start") }, + { value: "end", label: t("objinfo.opening.hinge.end") }, + ]} + title={t("objinfo.opening.hinge")} + width={130} + /> +
+
+ {t("objinfo.opening.swing")} + host.onSetOpeningSwing(v as "left" | "right")} + options={[ + { value: "left", label: t("objinfo.opening.swing.left") }, + { value: "right", label: t("objinfo.opening.swing.right") }, + ]} + title={t("objinfo.opening.swing")} + width={130} + /> +
+
+ {t("objinfo.opening.dir")} + host.onSetOpeningDir(v as "in" | "out")} + options={[ + { value: "in", label: t("objinfo.opening.dir.in") }, + { value: "out", label: t("objinfo.opening.dir.out") }, + ]} + title={t("objinfo.opening.dir")} + width={130} + /> +
+ host.onSetOpeningSwingAngle(v)} + /> + + )} + + {/* Detailstufe-Übersteuerung — fehlt sie ("" = Ansicht), gilt die + ansichtsweite Detailstufe (Grundriss-Kopfzeile). Wirkt auf dasselbe + grob/mittel/fein-Symbol wie die Ansichts-Detailstufe (Türblatt-Bogen, + Rahmen/Glaslinien), nur PRO ELEMENT statt für den ganzen Plan. */} +
+ {t("objinfo.opening.detailLevel")} + + host.onSetOpeningDetailLevel(v === "" ? undefined : (v as DetailLevel)) + } + options={[ + { value: "", label: t("objinfo.detailLevel.view") }, + { value: "grob", label: t("topbar.detail.grob") }, + { value: "mittel", label: t("topbar.detail.mittel") }, + { value: "fein", label: t("topbar.detail.fein") }, + ]} + title={t("objinfo.opening.detailLevel")} + width={130} + /> +
+ +
+ + {/* UK/OK (read-only, aus der Wand-UK + Brüstung/Höhe abgeleitet). */} +
+ {t("objinfo.opening.bottom")} + {formatM(opening.zBottom)} +
+
+ {t("objinfo.opening.top")} + {formatM(opening.zTop)} +
+ + ); +} + + +// ── Dach-/Deckenfenster ([103]) ───────────────────────────────────────────── +// Wirt (Dach/Decke + Geschoss), Breite quer und Höhe im Gefälle (in der Fläche gemessen), Lage des +// Mittelpunkts im Grundriss, Drehung nur auf waagrechten Flächen; UK/OK und Neigung aus dem Kern. +function SurfaceOpeningSection({ + opening, + host, +}: { + opening: OpeningInfo; + host: ReturnType; +}) { + const info = surfaceOpeningInfo(host.project, opening.id); + const roof = !!opening.hostRoofId; + const hp = opening.hostPoint ?? { x: 0, y: 0 }; + return ( + <> +
+
{t("objinfo.opening.section")}
+
+ {t("objinfo.opening.type")} + host.onSetOpeningType(v)} + options={[ + { value: "", label: t("objinfo.type.none") }, + ...(host.project.windowTypes ?? []).map((ty) => ({ value: ty.id, label: ty.name })), + ]} + title={t("objinfo.opening.type")} + width={106} + /> + +
+
+ {t(roof ? "objinfo.opening.hostRoof" : "objinfo.opening.hostCeiling")} + {info?.hostName ?? "–"} +
+ host.onSetOpeningWidth(v)} /> + host.onSetOpeningHeight(v)} /> + host.onSetOpeningHost?.({ hostPoint: { x, y: hp.y } })} /> + host.onSetOpeningHost?.({ hostPoint: { x: hp.x, y } })} /> + {!roof && ( + host.onSetOpeningHost?.({ hostAngle: a })} + /> + )} + {info && ( + <> +
+
+ {t("objinfo.opening.slope")} + {info.slopeDeg.toFixed(1)}° +
+
+ {t("objinfo.opening.bottom")} + {formatM(info.zBottom)} +
+
+ {t("objinfo.opening.top")} + {formatM(info.zTop)} +
+ + )} + + ); +} + + +/** Farbe + Strichstärke (mm) einer Linien-Kategorie, mit "System"-Fallback- + * Anzeige (Override `undefined` ⇒ zeigt `fallbackColor`/`fallbackWeight`, + * Ändern setzt sofort einen expliziten Override). */ +function LineStyleRow({ + label, + value, + fallbackColor, + fallbackWeight, + onChange, +}: { + label: string; + value: { color?: string; weight?: number } | undefined; + fallbackColor: string; + fallbackWeight: number; + onChange: (v: { color?: string; weight?: number } | undefined) => void; +}) { + return ( +
+ {label} + onChange({ ...value, color })} + /> + { + const w = Number(e.target.value); + if (isFinite(w) && w >= 0) onChange({ ...value, weight: w }); + }} + title={t("objinfo.lineWeight")} + /> + mm +
+ ); +} diff --git a/src/panels/objectInfo/RefSections.tsx b/src/panels/objectInfo/RefSections.tsx new file mode 100644 index 00000000..16fb10fd --- /dev/null +++ b/src/panels/objectInfo/RefSections.tsx @@ -0,0 +1,108 @@ +// Abschnitte für Bemassungs-Bezüge und Detail-Verweise der Attribute ([165] aus `ObjectInfoPanel.tsx`). +// Gerufen von `AttributesPanel`. + +import type { DimRef } from "../../model/types"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import type { TranslationKey } from "../../i18n"; +import type { DetailRefInfo } from "../../state/selectionInfo"; +import { Dropdown } from "../../ui/Dropdown"; + +// ── Assoziative Bemassung ([38]) ──────────────────────────────────────────── +// Je Punkt: frei, angehängt (Merkmal + Element) oder Bezug verloren; „Bemassung lösen" entfernt alle. +export function DimRefsSection({ + refs, + drawingId, + host, +}: { + refs: (DimRef | null)[]; + drawingId: string; + host: ReturnType; +}) { + const lost = refs.some((r) => r?.lost); + return ( + <> +
+
{t("objinfo.dimRefs.section")}
+ {refs.map((r, i) => ( +
+ {t("objinfo.dimRefs.point", { n: i + 1 })} + + {!r + ? t("objinfo.dimRefs.free") + : r.lost + ? t("objinfo.dimRefs.lost", { id: r.id }) + : `${t(`objinfo.dimRefs.feature.${r.feature}` as TranslationKey)} · ${r.id}${r.id2 ? ` / ${r.id2}` : ""}`} + +
+ ))} + {lost &&
{t("objinfo.dimRefs.lostHint")}
} +
+ +
+ + ); +} + + +// ── Detail-/Schnitt-Verweis-Attribut-Abschnitt ────────────────────────────── +// Bezeichner (obere Zeile) + Blattverknüpfung (Dropdown der Project.layouts, +// „kein Verweis" löst sie); ohne Verknüpfung zusätzlich ein manueller +// Blattname-Platzhalter (untere Zeile, s. `DetailRefInfo`-Kommentar). +export function DetailRefSection({ + detailRef, + drawingId, + host, +}: { + detailRef: DetailRefInfo; + drawingId: string; + host: ReturnType; +}) { + return ( + <> +
+
{t("objinfo.detailRef.section")}
+ +
+ {t("objinfo.detailRef.label")} + host.onSetDetailRefLabel(drawingId, e.target.value)} + title={t("objinfo.detailRef.label")} + /> +
+ +
+ {t("objinfo.detailRef.sheet")} + host.onSetDetailRefSheetLayout(drawingId, v === "" ? undefined : v)} + options={[ + { value: "", label: t("objinfo.detailRef.sheet.none") }, + ...detailRef.availableLayouts.map((l) => ({ value: l.id, label: l.name })), + ]} + title={t("objinfo.detailRef.sheet")} + width={130} + /> +
+ + {!detailRef.sheetLayoutId && ( +
+ {t("objinfo.detailRef.sheetLabel")} + host.onSetDetailRefSheetLabel(drawingId, e.target.value)} + title={t("objinfo.detailRef.sheetLabel")} + /> +
+ )} + + ); +} diff --git a/src/panels/objectInfo/RoofSections.tsx b/src/panels/objectInfo/RoofSections.tsx new file mode 100644 index 00000000..2a97adbf --- /dev/null +++ b/src/panels/objectInfo/RoofSections.tsx @@ -0,0 +1,427 @@ +// Abschnitte „Dach" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Dachform, Gauben und Dachränder. +// Gerufen von `AttributesPanel`. + +import type { RoofInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { useMemo } from "react"; +import { dormerStatus } from "../../analysis/dormerStatus"; +import type { Dormer, DormerKind, RoofShape } from "../../model/types"; +import type { TranslationKey } from "../../i18n"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import { UValueRow } from "../UValueRow"; +import { formatM } from "../../model/types"; +import type { RoofEdge, EdgeSpec } from "../../core"; + +// ── Treppen-Attribut-Abschnitt ─────────────────────────────────────────────── +// Grundform (gerade/L/Wendel), Laufbreite, Stufenanzahl, Steighöhe (+ abgeleitete +// Steigungshöhe/Auftrittstiefe), Laufrichtung; Referenzgeschoss + UK/OK read-only. +/** Rechteck-Umriss (CCW) aus unterer/linker Ecke + Breite/Tiefe (für Dach-Resize). */ +function rectOutline(x0: number, y0: number, w: number, d: number) { + return [ + { x: x0, y: y0 }, + { x: x0 + w, y: y0 }, + { x: x0 + w, y: y0 + d }, + { x: x0, y: y0 + d }, + ]; +} + + +/** Gauben ([G5]) des Dachs: Art, Masse, Neigung, Aufbau je Gaube; Hinzufügen über den Befehl „Gaube". */ +function DormersSection({ roof, host }: { roof: RoofInfo; host: ReturnType }) { + const dormers = roof.dormers ?? []; + const status = useMemo(() => dormerStatus(host.project), [host.project]); + const patch = (i: number, p: Partial) => + host.onSetRoofPatch({ dormers: dormers.map((d, k) => (k === i ? { ...d, ...p } : d)) }, `dormer-${i}`); + const num = (labelKey: TranslationKey, value: number, step: number, apply: (v: number) => void) => ( +
+ {t(labelKey)} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) apply(v); + }} + title={t(labelKey)} + /> +
+ ); + return ( + <> +
+
{t("objinfo.dormer.section")}
+ {dormers.map((d, i) => ( +
+ {(() => { + const st = status.find((s) => s.dormerId === d.id); + if (!st || !(st.clamped || st.invalid)) return null; + return ( +
+ {st.invalid ? t("objinfo.dormer.invalid") : t("objinfo.dormer.clamped", { height: st.effectiveHeight.toFixed(2) })} +
+ ); + })()} +
+ {t("objinfo.dormer.kind")} + patch(i, { kind: v as DormerKind })} + options={[ + { value: "schlepp", label: t("objinfo.dormer.kind.schlepp") }, + { value: "sattel", label: t("objinfo.dormer.kind.sattel") }, + { value: "flach", label: t("objinfo.dormer.kind.flach") }, + { value: "walm", label: t("objinfo.dormer.kind.walm") }, + ]} + title={t("objinfo.dormer.kind")} + width={130} + /> + +
+ {num("objinfo.dormer.width", d.width, 0.1, (v) => patch(i, { width: Math.max(0.8, v) }))} + {num("objinfo.dormer.frontHeight", d.frontHeight, 0.05, (v) => patch(i, { frontHeight: Math.max(0.5, v) }))} + {d.kind !== "flach" && + num("objinfo.dormer.pitch", d.pitchDeg ?? (d.kind === "schlepp" ? 15 : 40), 1, (v) => + patch(i, { pitchDeg: Math.max(0, Math.min(75, v)), depth: undefined }), + )} + {d.kind === "schlepp" && + num("objinfo.dormer.depth", d.depth ?? 0, 0.1, (v) => patch(i, { depth: v > 0.1 ? v : undefined }))} + {num("objinfo.dormer.overhang", d.overhang ?? 0.15, 0.05, (v) => patch(i, { overhang: Math.max(0, v) }))} +
+ {t("objinfo.dormer.wallType")} + patch(i, { wallTypeId: v || undefined })} + options={[ + { value: "", label: t("objinfo.dormer.wallType.default") }, + ...host.project.wallTypes.map((wt) => ({ value: wt.id, label: wt.name })), + ]} + title={t("objinfo.dormer.wallType")} + width={130} + /> +
+
+ {t("objinfo.dormer.roofType")} + patch(i, { roofTypeId: v || undefined })} + options={[ + { value: "", label: t("objinfo.dormer.roofType.host") }, + ...(host.project.roofTypes ?? []).map((rt) => ({ value: rt.id, label: rt.name })), + ]} + title={t("objinfo.dormer.roofType")} + width={130} + /> +
+
+ ))} +
+ +
+ + ); +} + + +/** Dach-Abschnitt: Form, Neigung(en), Überstand, Firstrichtung, Dicke. */ +export function RoofSection({ + roof, + host, +}: { + roof: RoofInfo; + host: ReturnType; +}) { + const numField = ( + labelKey: TranslationKey, + value: number, + step: number, + apply: (v: number) => void, + ) => ( +
+ {t(labelKey)} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) apply(v); + }} + title={t(labelKey)} + /> +
+ ); + return ( + <> +
+
{t("objinfo.roof.section")}
+ + {/* Dachform. */} +
+ {t("objinfo.roof.shape")} + host.onSetRoofPatch({ shape: v as RoofShape })} + options={[ + { value: "flach", label: t("objinfo.roof.shape.flach") }, + { value: "pult", label: t("objinfo.roof.shape.pult") }, + { value: "sattel", label: t("objinfo.roof.shape.sattel") }, + { value: "walm", label: t("objinfo.roof.shape.walm") }, + { value: "mansarde", label: t("objinfo.roof.shape.mansarde") }, + { value: "zelt", label: t("objinfo.roof.shape.zelt") }, + ]} + title={t("objinfo.roof.shape")} + width={130} + /> +
+ + {/* Dachtyp (mehrschichtiger Aufbau) — leer = einschichtig (Dicke unten). */} +
+ {t("objinfo.roof.type")} + host.onSetRoofPatch({ roofTypeId: v || undefined })} + options={[ + { value: "", label: t("objinfo.roof.type.single") }, + ...(host.project.roofTypes ?? []).map((rt) => ({ value: rt.id, label: rt.name })), + ]} + title={t("objinfo.roof.type")} + width={130} + /> +
+ + + {/* Firstrichtung (X/Y) — nur bei Formen mit First relevant. */} + {roof.shape !== "flach" && roof.shape !== "zelt" && ( +
+ {t("objinfo.roof.ridgeAxis")} + host.onSetRoofPatch({ ridgeAxis: v as "x" | "y" })} + options={[ + { value: "x", label: t("objinfo.roof.ridgeAxis.x") }, + { value: "y", label: t("objinfo.roof.ridgeAxis.y") }, + ]} + title={t("objinfo.roof.ridgeAxis")} + width={130} + /> +
+ )} + + {/* 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)) }), + )} + {roof.shape === "mansarde" && + numField("objinfo.roof.pitchUpper", roof.pitchUpperDeg ?? roof.pitchDeg / 2, 1, (v) => + host.onSetRoofPatch({ pitchUpperDeg: Math.max(0, Math.min(85, v)) }), + )} + {/* Mansarde-Untertyp (Giebel/Walm/Zelt) + Knicklage. */} + {roof.shape === "mansarde" && ( +
+ {t("objinfo.roof.mansardType")} + + host.onSetRoofPatch({ mansardType: v as "giebel" | "walm" | "zelt" }) + } + options={[ + { value: "giebel", label: t("objinfo.roof.mansard.giebel") }, + { value: "walm", label: t("objinfo.roof.mansard.walm") }, + { value: "zelt", label: t("objinfo.roof.mansard.zelt") }, + ]} + title={t("objinfo.roof.mansardType")} + width={130} + /> +
+ )} + {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 }), + )} + + {roof.shape === "sattel" && + numField("objinfo.roof.halfHip", (roof.halfHipRatio ?? 0) * 100, 5, (v) => + host.onSetRoofPatch({ halfHipRatio: Math.max(0, Math.min(90, v)) / 100 }), + )} + + {/* 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 && + 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) => + host.onSetRoofPatch({ overhang: Math.max(0, v) }), + )} + {roof.shape !== "flach" && + roof.shape !== "zelt" && + numField( + "objinfo.roof.overhangGable", + roof.overhangGable ?? roof.overhang, + 0.05, + (v) => host.onSetRoofPatch({ overhangGable: Math.max(0, v) }), + )} + {numField("objinfo.roof.thickness", roof.thickness, 0.02, (v) => + host.onSetRoofPatch({ thickness: Math.max(0.01, v) }), + )} + {/* 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 }), + )} + + {/* 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" && ( + + )} + {/* Innenhöfe: Liste mit Entfernen, Hinzufügen über den Befehl „Dachhof“. */} + + {roof.shape !== "pult" && ( + <> +
+
{t("objinfo.roof.courts")}
+ {roof.holes.map((h, i) => ( +
+ + {t("objinfo.roof.courtRow", { n: i + 1, area: h.area.toFixed(2) })} + + +
+ ))} +
+ +
+ + )} +
+ + {/* Abgeleitete Werte (read-only). */} +
+ {t("objinfo.roof.ridgeHeight")} + {formatM(roof.ridgeHeight)} +
+
+ {t("objinfo.roof.area")} + {roof.footprintArea.toFixed(2)} m² +
+ + ); +} + + +/** Kantenliste eines Dachs: Neigung je Kante (leer = Standard) + Giebel-Schalter. */ +function RoofEdgesSection({ + roof, + host, +}: { + roof: RoofInfo; + host: ReturnType; +}) { + // Tippen einer Zahl = ein Undo-Schritt je Kante (gleicher coalesceKey, s. Host). + const setEdge = (e: RoofEdge, spec: EdgeSpec) => host.onSetRoofEdge(e.index, spec); + return ( + <> +
+
{t("objinfo.roof.edges")}
+ {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 ( +
+ + {label} + + { + 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 }); + }} + /> + +
+ ); + })} + {roof.hasEdgePitch && ( +
+ +
+ )} + + ); +} diff --git a/src/panels/objectInfo/RoomSection.tsx b/src/panels/objectInfo/RoomSection.tsx new file mode 100644 index 00000000..b1c72115 --- /dev/null +++ b/src/panels/objectInfo/RoomSection.tsx @@ -0,0 +1,158 @@ +// Abschnitt „Raum" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Name, Nutzung, SIA-Kategorie, Fläche, +// Stempel und die Oberflächen-Felder. Gerufen von `AttributesPanel`. + +import type { RoomInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import type { SiaCategory, Project, Room } from "../../model/types"; +import { SIA_CATEGORIES, siaLabelFull, patchItem, roomBook, ROOM_USAGES, usageLabel } from "../../core"; +import { formatM } from "../../model/types"; +import { useStore } from "../../state/appStore"; +import type { TranslationKey } from "../../i18n"; + +// ── Raum-Attribut-Abschnitt ────────────────────────────────────────────────── +// Editierbarer Name, SIA-416-Kategorie (5 Blatt-Kategorien), abgeleitete Fläche +// + Umfang (read-only), Referenzgeschoss, sowie ein Button, der den Rich-Text- +// Stempel-Editor öffnet. Alle Werte/Setter über den Host. +export function RoomSection({ + room, + roomId, + host, +}: { + room: RoomInfo; + roomId: string; + host: ReturnType; +}) { + return ( + <> +
+
{t("objinfo.room.section")}
+ + {/* Name (editierbar). */} +
+ {t("objinfo.room.name")} + host.onSetRoomName(e.target.value)} + title={t("objinfo.room.name")} + /> +
+ + {/* SIA-416-Kategorie (5 Blatt-Kategorien). */} +
+ {t("objinfo.room.sia")} + host.onSetRoomSia(v as SiaCategory)} + options={SIA_CATEGORIES.map((c) => ({ + value: c, + label: siaLabelFull(c), + }))} + title={t("objinfo.room.sia")} + width={170} + /> +
+ + {/* Fläche + Umfang (read-only, abgeleitet). */} +
+ {t("objinfo.room.area")} + {room.area.toFixed(2)} m² +
+
+ {t("objinfo.room.perimeter")} + {formatM(room.perimeter)} +
+ + {/* Referenzgeschoss (read-only). */} +
+ {t("objinfo.room.refFloor")} + {room.floorName} +
+ + {/* [158] Raumbuch: Nutzung und Oberflächen. */} + + + {/* Stempel bearbeiten (öffnet den Rich-Text-Editor). */} + + + ); +} + + +type RoomFinishField = "floorFinish" | "wallFinish" | "ceilingFinish" | "floorBuildUp"; + + +/** [158] Nutzung (Nassraum abgeleitet) und Oberflächen Boden/Wand/Decke (Material aus dem Projekt oder + * Freitext; ein eingegebener Material-Name wird als Verweis gespeichert) und Bodenaufbau. */ +function RoomFinishFields({ roomId, host }: { roomId: string; host: ReturnType }) { + const applyChange = useStore((s) => s.applyChange); + const project = host.project; + const room = (project.rooms ?? []).find((r) => r.id === roomId); + if (!room) return null; + const comps = project.components; + const listId = `room-finish-materials-${roomId}`; + const shown = (v: string | undefined) => comps.find((c) => c.id === v)?.name ?? v ?? ""; + const set = (field: RoomFinishField | "usage", value: string | undefined) => + applyChange((p: Project) => patchItem(p, "rooms", roomId, { [field]: value } as Partial), `room:${roomId}:${field}`); + const setFinish = (field: RoomFinishField, text: string) => { + const v = text.trim(); + if (!v) return set(field, undefined); + const comp = field === "floorBuildUp" ? undefined : comps.find((c) => c.name.trim() === v); + set(field, comp ? comp.id : text); + }; + // Nassraum wie im Kern (Nutzung, sonst Name), für [156] „Nassräume" im Grundriss. + const wet = roomBook(project).rows.find((r) => r.id === roomId)?.wet ?? false; + const finishInput = (field: RoomFinishField, label: TranslationKey) => ( +
+ {t(label)} + setFinish(field, e.target.value)} + title={t(label)} + /> +
+ ); + return ( + <> +
+ {t("objinfo.room.usage")} + set("usage", v || undefined)} + options={[{ value: "", label: t("objinfo.room.usageNone") }, ...ROOM_USAGES.map((u) => ({ value: u, label: usageLabel(u) }))]} + title={t("objinfo.room.usage")} + width={170} + /> +
+ {wet && ( +
+ {t("objinfo.room.wet")} + ✓ +
+ )} +
{t("objinfo.room.finishes")}
+ + {comps.map((c) => ( + + {finishInput("floorFinish", "objinfo.room.floorFinish")} + {finishInput("wallFinish", "objinfo.room.wallFinish")} + {finishInput("ceilingFinish", "objinfo.room.ceilingFinish")} + {finishInput("floorBuildUp", "objinfo.room.buildUp")} + + ); +} diff --git a/src/panels/objectInfo/SectionLineSection.tsx b/src/panels/objectInfo/SectionLineSection.tsx new file mode 100644 index 00000000..74f6cd94 --- /dev/null +++ b/src/panels/objectInfo/SectionLineSection.tsx @@ -0,0 +1,175 @@ +// Abschnitt „Schnitt-/Ansichtslinie" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Name, Art, Tiefe, +// Umkehren, Höhenmarken, Plan-Unterlage. Gerufen von `AttributesPanel`. + +import type { DrawingLevel, Vec2 } from "../../model/types"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import type { TranslationKey } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; + +// ── Schnitt-/Ansichtslinien-Abschnitt (Object-Info; nur die gewählte Linie) ── +// Name (editierbar), Blickrichtung umkehren (directionSign-Flip), Endpunkt- +// Koordinaten (editierbar) + Schnitt-Tiefe; Löschen setzt linePoints zurück +// (die Ebene bleibt bestehen). Eine Schnittlinie ist KEIN Projekt-Bauteil, +// darum kommt sie über `host.sectionLine` (nicht über `selection`). +export function SectionLineSection({ + level, + host, +}: { + level: DrawingLevel; + host: ReturnType; +}) { + const line = level.linePoints; + const kindLabel = + level.kind === "elevation" + ? t("objinfo.sectionLine.kind.elevation") + : t("objinfo.sectionLine.kind.section"); + const patchPoint = (which: 0 | 1, axis: "x" | "y", value: number) => { + if (!line) return; + const next: [Vec2, Vec2] = [{ ...line[0] }, { ...line[1] }]; + next[which] = { ...next[which], [axis]: value }; + host.onSetSectionLinePatch({ linePoints: next }); + }; + const coordField = (labelKey: TranslationKey, value: number, on: (v: number) => void) => ( +
+ {t(labelKey)} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) on(v); + }} + title={t(labelKey)} + /> +
+ ); + return ( + <> +
+
+ {t("objinfo.sectionLine.section")} · {kindLabel} +
+ + {/* Name (editierbar). */} +
+ {t("objinfo.sectionLine.name")} + host.onSetSectionLinePatch({ name: e.target.value })} + title={t("objinfo.sectionLine.name")} + /> +
+ + {/* Blickrichtung umkehren (directionSign-Flip). */} + + + {/* 3D-Live-Schnitt an diese Linie binden (nur mit gesetzter Linie sinnvoll): + der Viewport clippt dann vertikal entlang dieser Ebene. */} + {line && ( +
+ {t("objinfo.sectionLine.cut3d")} + host.onToggleSection3dCut(level.id)} + title={t("objinfo.sectionLine.cut3d")} + /> +
+ )} + + {/* Endpunkt-Koordinaten (nur wenn eine Linie gesetzt ist). */} + {line && ( + <> + {coordField("objinfo.sectionLine.startX", line[0].x, (v) => patchPoint(0, "x", v))} + {coordField("objinfo.sectionLine.startY", line[0].y, (v) => patchPoint(0, "y", v))} + {coordField("objinfo.sectionLine.endX", line[1].x, (v) => patchPoint(1, "x", v))} + {coordField("objinfo.sectionLine.endY", line[1].y, (v) => patchPoint(1, "y", v))} + + )} + + {/* Schnitt-Tiefe (leer = unbegrenzt). */} +
+ {t("objinfo.sectionLine.depth")} + { + const raw = e.target.value.trim(); + if (raw === "") { + host.onSetSectionLinePatch({ depth: undefined }); + return; + } + const v = Number(raw); + if (Number.isFinite(v) && v > 0) host.onSetSectionLinePatch({ depth: v }); + }} + title={t("objinfo.sectionLine.depth")} + /> +
+ + {/* Verdeckte Kanten (gestrichelt) — Default aus (blasses Liniengewirr). */} +
+ {t("objinfo.sectionLine.hiddenLines")} + host.onSetSectionLinePatch({ hiddenLines: e.target.checked })} + title={t("objinfo.sectionLine.hiddenLines")} + /> +
+ + {/* Automatische Höhenkoten (Geschosse + oberste Kante). */} +
+ {t("objinfo.sectionLine.levelMarks")} + host.onSetSectionLinePatch({ levelMarks: e.target.checked ? undefined : false })} + title={t("objinfo.sectionLine.levelMarks")} + /> +
+ + {/* Grundriss-Unterlage: ein Geschoss ausgerichtet unter dem Schnitt/der Ansicht. */} + {line && ( +
+ {t("objinfo.sectionLine.planUnderlay")} + host.onSetSectionLinePatch({ planUnderlayId: v || undefined })} + options={[ + { value: "", label: t("objinfo.sectionLine.planUnderlay.none") }, + ...host.project.drawingLevels + .filter((l) => l.kind === "floor") + .map((l) => ({ value: l.id, label: l.name })), + ]} + title={t("objinfo.sectionLine.planUnderlay")} + width={150} + /> +
+ )} + + {/* Löschen: linePoints zurücksetzen (die Ebene bleibt bestehen). */} + + + ); +} diff --git a/src/panels/objectInfo/SolidSections.tsx b/src/panels/objectInfo/SolidSections.tsx new file mode 100644 index 00000000..03fb6fa6 --- /dev/null +++ b/src/panels/objectInfo/SolidSections.tsx @@ -0,0 +1,278 @@ +// Abschnitte „Extrudierter Körper" und „Stütze" der Attribute ([165] aus `ObjectInfoPanel.tsx`), dazu die +// Kennwert-Zeilen des Körpers (truck). Gerufen von `AttributesPanel`. + +import type { SolidSpec, SolidProps } from "../../engine/truckSolid"; +import { useState, useEffect } from "react"; +import { solidProps } from "../../engine/truckSolid"; +import { t } from "../../i18n"; +import type { ExtrudedSolidInfo, ColumnInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { Dropdown } from "../../ui/Dropdown"; +import { DimensionField } from "./fields"; + +/** Volumen/Oberfläche/Schwerpunkt aus truck (asynchron, aus dem tessellierten B-Rep). */ +function SolidPropsRows({ spec }: { spec: SolidSpec | null }) { + const [props, setProps] = useState(null); + const key = JSON.stringify(spec); + useEffect(() => { + let alive = true; + setProps(null); + if (!spec) return; + solidProps(spec).then( + (p) => alive && setProps(p), + () => alive && setProps(null), + ); + return () => { + alive = false; + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [key]); + if (!props) return null; + const f = (v: number, d = 2) => v.toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d }); + return ( + <> +
+ {t("objinfo.extrudedSolid.volume")} + {f(props.volume)} m³ +
+
+ {t("objinfo.extrudedSolid.surface")} + {f(props.area)} m² +
+
+ {t("objinfo.extrudedSolid.centroid")} + + {f(props.centroid[0])} / {f(props.centroid[1])} / {f(props.centroid[2])} + +
+ {!props.closed &&
{t("objinfo.extrudedSolid.notClosed")}
} + + ); +} + + +// ── Extrusions-Attribut-Abschnitt (truck-Integration) ─────────────────────── +// Höhe editierbar (löst Re-Extrusion aus); Grundfläche + Geschoss read-only. +export function ExtrudedSolidSection({ + solid, + host, +}: { + solid: ExtrudedSolidInfo; + host: ReturnType; +}) { + return ( + <> +
+
{t("objinfo.extrudedSolid.section")}
+ + {/* Höhe (editierbar, > 0) — löst eine Re-Extrusion (truck-WASM) aus. */} +
+ {t("objinfo.extrudedSolid.height")} + { + const v = Number(e.target.value); + if (Number.isFinite(v) && v > 0) host.onSetExtrudedSolidHeight(v); + }} + title={t("objinfo.extrudedSolid.height")} + /> +
+ + + + {/* Abstand über Geschoss-UK (Brüstungs-/Durchbruchshöhe). */} +
+ {t("objinfo.extrudedSolid.baseOffset")} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) host.onSetExtrudedSolidBaseOffset(v); + }} + title={t("objinfo.extrudedSolid.baseOffset")} + /> +
+ + {/* Abzugskörper: zieht sich von Wänden/Decken/Stützen ab (Grundriss, Schnitt, 3D, STEP). */} + {solid.canSubtract && ( +
+ {t("objinfo.extrudedSolid.subtract")} + host.onSetExtrudedSolidSubtract(e.target.checked)} + title={t("objinfo.extrudedSolid.subtractHint")} + /> +
+ )} + + {solid.brepLabel && ( +
+ {t("objinfo.extrudedSolid.brep")} + {solid.brepLabel} +
+ )} + + {/* Eckenradius (editierbar, ≥ 0): echte Kreisbögen an den Ecken der Aussenkontur. */} + {!solid.brepLabel && ( +
+ {t("objinfo.extrudedSolid.cornerRadius")} + { + const v = Number(e.target.value); + if (Number.isFinite(v) && v >= 0) host.onSetExtrudedSolidCornerRadius(v); + }} + title={t("objinfo.extrudedSolid.cornerRadius")} + /> +
+ )} + + {/* Fase (editierbar, ≥ 0): gerade Abschrägung der Ecken der Aussenkontur. */} + {!solid.brepLabel && ( +
+ {t("objinfo.extrudedSolid.chamfer")} + { + const v = Number(e.target.value); + if (Number.isFinite(v) && v >= 0) host.onSetExtrudedSolidChamfer(v); + }} + title={t("objinfo.extrudedSolid.chamfer")} + /> +
+ )} + + {/* Verjüngung (editierbar, 0..1) — löst eine Re-Extrusion (truck-WASM) aus. */} + {!solid.brepLabel && ( +
+ {t("objinfo.extrudedSolid.taper")} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) host.onSetExtrudedSolidTaper(v); + }} + title={t("objinfo.extrudedSolid.taper")} + /> +
+ )} + + {/* Grundfläche (read-only, abgeleitet). */} +
+ {t("objinfo.extrudedSolid.area")} + {solid.area.toFixed(2)} m² +
+ + {/* Geschoss (read-only). */} +
+ {t("objinfo.extrudedSolid.floor")} + {solid.floorName} +
+ + ); +} + + +// ── Stützen-Attribut-Abschnitt (Tragwerk) ─────────────────────────────────── +// Profil (Rechteck/Kreis) + Masse, Höhe, Drehung editierbar; Geschoss + UK/OK +// read-only. +export function ColumnSection({ + column, + host, +}: { + column: ColumnInfo; + host: ReturnType; +}) { + return ( + <> +
+
{t("objinfo.column.section")}
+ + {/* Profil-Dropdown (Rechteck/Kreis). */} +
+ {t("objinfo.column.profile")} + host.onSetColumnProfileKind(v as "rect" | "round")} + options={[ + { value: "rect", label: t("objinfo.column.profile.rect") }, + { value: "round", label: t("objinfo.column.profile.round") }, + ]} + title={t("objinfo.column.profile")} + width={130} + /> +
+ + {/* Editierbare Masse je Profil. */} + {column.profile.kind === "round" ? ( + host.onSetColumnRadius(v)} + /> + ) : ( + <> + host.onSetColumnWidth(v)} + /> + host.onSetColumnDepth(v)} + /> + + )} + + host.onSetColumnHeight(v)} + /> + + {/* Drehung (Grad). */} +
+ {t("objinfo.column.rotation")} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) host.onSetColumnRotation(v); + }} + title={t("objinfo.column.rotation")} + /> +
+ + {/* Geschoss (read-only). */} +
+ {t("objinfo.column.floor")} + {column.floorName} +
+ + ); +} diff --git a/src/panels/objectInfo/StairSection.tsx b/src/panels/objectInfo/StairSection.tsx new file mode 100644 index 00000000..e3535c2e --- /dev/null +++ b/src/panels/objectInfo/StairSection.tsx @@ -0,0 +1,267 @@ +// Abschnitt „Treppe" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Treppenform und Läufe. +// Gerufen von `AttributesPanel`. + +import type { StairInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import type { StairShape } from "../../model/types"; +import { formatM } from "../../model/types"; +import { DimensionField } from "./fields"; + +/** + * [151] Läufe und Podest einer Podesttreppe (L, U, gerade mit Podest): Lauflängen, Steigungen im ersten + * Lauf, Drehsinn (L/U), Treppenauge, Mittellauf und Versatz (U), Podesttiefe (U, gerade mit Podest). + */ +function StairFlightFields({ stair, host }: { stair: StairInfo; host: ReturnType }) { + const isU = stair.shape === "U"; + const turn = stair.turn ?? 1; + return ( + <> + v > 0.1 && host.onSetStairPatch({ runLength: v })} + /> + v > 0.1 && host.onSetStairPatch({ run2Length: v })} + /> + host.onSetStairPatch({ run1Steps: v >= 1 ? Math.round(v) : undefined })} + /> + {stair.shape !== "straightLanding" && ( +
+ {t("objinfo.stair.turn")} +
+ + +
+
+ )} + {stair.shape !== "L" && ( + v > 0.1 && host.onSetStairPatch({ landingLength: v })} + /> + )} + {isU && ( + <> + v >= 0 && host.onSetStairPatch({ gap: v })} + /> + host.onSetStairPatch({ midSteps: v >= 1 ? Math.round(v) : undefined })} + /> + {(stair.midSteps ?? 0) >= 1 && ( + host.onSetStairPatch({ midOffset: v !== 0 ? v : undefined })} + /> + )} + host.onSetStairPatch({ run2Offset: v !== 0 ? v : undefined })} + /> + + )} + + ); +} + + +export function StairSection({ + stair, + host, +}: { + stair: StairInfo; + host: ReturnType; +}) { + return ( + <> +
+
{t("objinfo.stair.section")}
+ + {/* Treppentyp (Bibliothek) — treibt u. a. die 3D-Tragart (massiv/offen). */} +
+ {t("objinfo.stair.type")} + host.onSetStairType(v)} + options={[ + { value: "", label: t("objinfo.type.none") }, + ...(host.project.stairTypes ?? []).map((st) => ({ + value: st.id, + label: st.name, + })), + ]} + title={t("objinfo.stair.type")} + width={130} + /> +
+ + {/* Grundform-Dropdown. */} +
+ {t("objinfo.stair.shape")} + host.onSetStairShape(v as StairShape)} + options={[ + { value: "straight", label: t("objinfo.stair.shape.straight") }, + { value: "L", label: t("objinfo.stair.shape.L") }, + { value: "U", label: t("objinfo.stair.shape.U") }, + { value: "straightLanding", label: t("objinfo.stair.shape.straightLanding") }, + { value: "spiral", label: t("objinfo.stair.shape.spiral") }, + ]} + title={t("objinfo.stair.shape")} + width={130} + /> +
+ + {/* Referenzpunkt der Laufbreite (links/mitte/rechts). */} +
+ {t("objinfo.stair.referenz")} + host.onSetStairReferenz(v as "links" | "mitte" | "rechts")} + options={[ + { value: "links", label: t("objinfo.stair.referenz.links") }, + { value: "mitte", label: t("objinfo.stair.referenz.mitte") }, + { value: "rechts", label: t("objinfo.stair.referenz.rechts") }, + ]} + title={t("objinfo.stair.referenz")} + width={130} + /> +
+ + {/* Laufrichtung (aufwärts/abwärts). */} +
+ {t("objinfo.stair.direction")} +
+ + +
+
+ + {/* Pfeil-Darstellung (offener Winkel- oder gefüllter SIA-Vollpfeil). */} +
+ {t("objinfo.stair.arrow")} +
+ + +
+
+ + {/* Editierbare Maße. */} + host.onSetStairWidth(v)} + /> + {stair.shape === "spiral" && ( + host.onSetStairColumn(v)} + /> + )} + {stair.shape !== "spiral" && stair.shape !== "straight" && } + host.onSetStairSteps(v)} + /> + host.onSetStairRise(v)} + /> + + {/* Abgeleitete Werte (read-only). */} +
+ {t("objinfo.stair.riser")} + {formatM(stair.riserHeight)} +
+
+ {t("objinfo.stair.tread")} + {formatM(stair.treadDepth)} +
+ {stair.concreteVolume !== undefined && ( +
+ {t("objinfo.stair.concreteVolume")} + {stair.concreteVolume.toFixed(2)} m³ +
+ )} + {stair.soffitArea !== undefined && ( +
+ {t("objinfo.stair.soffitArea")} + {stair.soffitArea.toFixed(2)} m² +
+ )} + + {/* Referenzgeschoss (read-only). */} +
+ {t("objinfo.stair.refFloor")} + {stair.floorName} +
+ +
+ + {/* UK/OK (read-only). */} +
+ {t("objinfo.stair.bottom")} + {formatM(stair.zBottom)} +
+
+ {t("objinfo.stair.top")} + {formatM(stair.zTop)} +
+ + ); +} diff --git a/src/panels/objectInfo/TreeSection.tsx b/src/panels/objectInfo/TreeSection.tsx new file mode 100644 index 00000000..591192c6 --- /dev/null +++ b/src/panels/objectInfo/TreeSection.tsx @@ -0,0 +1,117 @@ +// Abschnitt „Baum" der Objekt-Info ([165] aus `ObjectInfoPanel.tsx`) samt den Auswahllisten für Form, Status +// und Laub. Gerufen von `ObjectInfoPanel`. + +import type { TreeShape, TreeStatus, TreeFoliage, Tree } from "../../model/types"; +import { usePanelHost } from "../host"; +import { useStore } from "../../state/appStore"; +import { t } from "../../i18n"; +import { patchItem } from "../../core"; +import { Dropdown } from "../../ui/Dropdown"; +import type { TranslationKey } from "../../i18n"; +import { DimensionField } from "./fields"; + +// ── Editierbares Maßfeld ───────────────────────────────────────────────────── +// Kontrolliert über den vom Host gelieferten Wert, hält aber während des +// Tippens einen lokalen Entwurf. Commit auf blur/Enter; Escape verwirft. +// Nach erfolgreichem Resize liefert der Host eine neue bbox → neuer `value` → +// das Feld zeigt automatisch die aktualisierte Größe. `min` erlaubt negative +// Werte (z. B. absolute Z-Höhen unter 0). +// ── Baum ([149]) ───────────────────────────────────────────────────────────── +// Lage (Stammmitte), Masse, Form, Bestand, Laub/Nadel und Art des ersten gewählten Baums; jede Änderung +// ein Undo-Schritt (Kern prüft die Op). Bei mehreren gewählten Bäumen wirken Form/Bestand/Laub auf alle. +const TREE_SHAPES: TreeShape[] = ["round", "oval", "columnar", "conical"]; + +const TREE_STATUS: TreeStatus[] = ["existing", "new", "remove"]; + +const TREE_FOLIAGE: TreeFoliage[] = ["deciduous", "conifer"]; + + +export function TreeSection({ ids }: { ids: readonly string[] }) { + const host = usePanelHost(); + const applyChange = useStore((s) => s.applyChange); + const trees = (host.project.trees ?? []).filter((x) => ids.includes(x.id)); + const tree = trees[0]; + if (!tree) return
{t("objinfo.empty")}
; + const locked = !!tree.locked; + const set = (patch: Partial, all = false) => + applyChange((p) => (all ? trees : [tree]).filter((x) => !x.locked).flatMap((x) => patchItem(p, "trees", x.id, patch))); + const level = host.project.drawingLevels.find((l) => l.id === tree.floorId); + return ( +
+
+ {trees.length > 1 ? t("objinfo.tree.many", { n: trees.length }) : t("objinfo.kind.tree")} +
+
{t("objinfo.tree.section")}
+ +
+ {t("objinfo.tree.showLabel")} + set({ showLabel: e.target.checked }, true)} + title={t("objinfo.tree.showLabelHint")} + data-testid="tree-show-label" + /> +
+
+ {t("objinfo.tree.status")} + set({ status: v as TreeStatus }, true)} + options={TREE_STATUS.map((v) => ({ value: v, label: t(`objinfo.tree.status.${v}` as TranslationKey) }))} + title={t("objinfo.tree.status")} + width={130} + /> +
+
+ {t("objinfo.tree.shape")} + set({ shape: v as TreeShape }, true)} + options={TREE_SHAPES.map((v) => ({ value: v, label: t(`objinfo.tree.shape.${v}` as TranslationKey) }))} + title={t("objinfo.tree.shape")} + width={130} + /> +
+
+ {t("objinfo.tree.foliage")} + set({ foliage: v as TreeFoliage }, true)} + options={TREE_FOLIAGE.map((v) => ({ value: v, label: t(`objinfo.tree.foliage.${v}` as TranslationKey) }))} + title={t("objinfo.tree.foliage")} + width={130} + /> +
+ set({ height: v, crownBase: Math.min(tree.crownBase, 0.9 * v) })} /> + set({ crownDiameter: v })} /> + set({ crownBase: Math.min(v, 0.9 * tree.height) })} /> + set({ trunkDiameter: v })} /> + set({ position: { x: v, y: tree.position.y } })} /> + set({ position: { x: tree.position.x, y: v } })} /> +
+ {t("objinfo.column.floor")} + {level?.name ?? tree.floorId} +
+ {locked &&
{t("objinfo.tree.locked")}
} +
+ ); +} diff --git a/src/panels/objectInfo/WallSection.tsx b/src/panels/objectInfo/WallSection.tsx new file mode 100644 index 00000000..32e47240 --- /dev/null +++ b/src/panels/objectInfo/WallSection.tsx @@ -0,0 +1,235 @@ +// Abschnitt „Wand" der Attribute ([165] aus `ObjectInfoPanel.tsx`): Referenzlinie, Aufbau, Geschoss, Unter- +// und Oberkante. Gerufen von `AttributesPanel`. + +import type { WallInfo } from "../../state/selectionInfo"; +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import { Dropdown } from "../../ui/Dropdown"; +import type { WallReferenceLine, SliceTermination } from "../../model/types"; +import { UValueRow } from "../UValueRow"; +import { formatM } from "../../model/types"; +import { BuildingFlags, DimensionField, VerticalAnchorRow } from "./fields"; + +// ── Wand-Attribut-Abschnitt ────────────────────────────────────────────────── +// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss + +// Oberverknüpfung, UK/OK je Modus-Umschalter. Alle Werte/Setter über den Host. +export function WallSection({ + wall, + host, +}: { + wall: WallInfo; + host: ReturnType; +}) { + // Aufbau-Typ-Segment: einschichtig vs. mehrschichtig. Aus dem Modell + // abgeleitet (singleLayer); der Umschalter auf „mehrschichtig" wählt einen + // mehrschichtigen Wandtyp-Preset (erster mit >1 Schicht), auf „einschichtig" + // setzt er die Dicke des aktuellen Aufbaus als einschichtige Wand. + const isSingle = wall.singleLayer; + + const multiPresets = wall.wallTypes.filter((wt) => wt.layerCount > 1); + + function chooseSingle() { + if (isSingle) return; + // Auf einschichtig wechseln: aktuelle Gesamtdicke als Einzelschicht setzen. + host.onSetWallThickness(wall.thickness); + } + function chooseMulti() { + if (!isSingle) return; + const first = multiPresets[0]; + if (first) host.onSetWallType(first.id); + } + + return ( + <> +
+
{t("objinfo.wall.section")}
+ + {/* Referenzlinie (wo die Achse über die Dicke liegt) — außen/mitte/innen ODER + bei mehrschichtigen Wänden eine SCHICHTTRENNLINIE (Fuge). Ein Fugenwert + wird als "off:" kodiert und übersteuert die benannte Linie. */} +
+ {t("objinfo.wall.refLine")} + { + if (v.startsWith("off:")) host.onSetWallReferenceOffset(Number(v.slice(4))); + else host.onSetWallReferenceLine(v as WallReferenceLine); + }} + options={[ + { value: "left", label: t("objinfo.wall.refLine.left") }, + { value: "center", label: t("objinfo.wall.refLine.center") }, + { value: "right", label: t("objinfo.wall.refLine.right") }, + ...wall.layerBoundaries.map((b) => ({ + value: `off:${b.offset.toFixed(4)}`, + label: `${t("objinfo.wall.refLine.joint")} ${b.label}`, + })), + ]} + title={t("objinfo.wall.refLine")} + width={120} + /> +
+ + {/* Terminierung am Deckenanschluss (Zuschnitt, NICHT Priorität): ob die Wand + an der Decke endet oder oberhalb wieder auftaucht. Default "both". */} +
+ {t("objinfo.wall.sliceTermination")} + host.onSetWallSliceTermination(v as SliceTermination)} + options={[ + { value: "both", label: t("objinfo.wall.sliceTermination.both") }, + { value: "below", label: t("objinfo.wall.sliceTermination.below") }, + { value: "above", label: t("objinfo.wall.sliceTermination.above") }, + ]} + title={t("objinfo.wall.sliceTermination")} + width={120} + /> +
+ + {/* An Dach anschliessen ([G2]): automatisch endet die Wand an der Dach-Unterkante, "Ja" + verlängert sie bis unter das Dach, "Nein" lässt die Dächer die Wand nicht schneiden. */} +
+ {t("objinfo.wall.roofAttach")} + host.onSetWallRoofAttach(v as "auto" | "on" | "off")} + options={[ + { value: "auto", label: t("objinfo.wall.roofAttach.auto") }, + { value: "on", label: t("objinfo.wall.roofAttach.on") }, + { value: "off", label: t("objinfo.wall.roofAttach.off") }, + ]} + title={t("objinfo.wall.roofAttach.tip")} + width={120} + /> +
+ + + {/* Aufbau-Typ-Segment. */} +
+ {t("objinfo.wall.buildup")} +
+ + +
+
+ + {/* Einschichtig → Dicke-Zahlfeld. Mehrschichtig → Preset-Dropdown. */} + {isSingle ? ( + host.onSetWallThickness(v)} + /> + ) : ( +
+ {t("objinfo.wall.preset")} + host.onSetWallType(id)} + options={wall.wallTypes.map((wt) => ({ + value: wt.id, + label: wt.label, + title: wt.name, + }))} + title={t("objinfo.wall.preset")} + width={150} + /> +
+ )} + + {/* Referenzgeschoss (read-only Anzeige). */} +
+ {t("objinfo.wall.refFloor")} + {wall.floorName} +
+ + + {/* Länge + Volumen (read-only). Volumen ist NETTO — Fenster/Türen + abgezogen; der Titel zeigt zusätzlich das Bruttovolumen. */} +
+ {t("objinfo.wall.length")} + {formatM(wall.length)} +
+
+ {t("objinfo.volume")} + 0 + ? `${t("objinfo.wall.volumeGross")}: ${wall.grossVolume.toFixed(2)} m³ − ${wall.openingVolume.toFixed(2)} m³` + : undefined + } + > + {wall.netVolume.toFixed(2)} m³ + +
+ + {/* Verknüpfung zum oberen Geschoss: OK an nächstes Geschoss binden. */} + + +
+ + {/* OK & UK getrennt: je „an Geschoss gebunden" ODER „eigene Höhe". OK + (oben) steht oben, UK (unten) darunter — räumlich passend (Nutzer). */} + host.onSetWallTop(a)} + /> + host.onSetWallBottom(a)} + /> + + {/* Höhe = OK − UK (abgeleitet, read-only). */} +
+ {t("objinfo.wall.height")} + {formatM(wall.zTop - wall.zBottom)} +
+ + ); +} diff --git a/src/panels/objectInfo/fields.tsx b/src/panels/objectInfo/fields.tsx new file mode 100644 index 00000000..75d6bf49 --- /dev/null +++ b/src/panels/objectInfo/fields.tsx @@ -0,0 +1,215 @@ +// Gemeinsame Eingabefelder der Objekt-Info ([165] aus `ObjectInfoPanel.tsx`): Mass-Feld mit Anzeige-Einheit, +// Drehfeld, Zeile für den vertikalen Anker und die Bauteil-Schalter (aussen, tragend). Gerufen von den +// Abschnitten in diesem Ordner und von `ObjectInfoPanel.tsx`. + +import { usePanelHost } from "../host"; +import { t } from "../../i18n"; +import type { VerticalAnchor } from "../../model/types"; +import { Dropdown } from "../../ui/Dropdown"; +import { useState, useRef } from "react"; + +// ── Decken-Attribut-Abschnitt ──────────────────────────────────────────────── +// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss + +// OK-Bindung, Fläche. Alle Werte/Setter über den Host. +/** Aussenbauteil / tragend ([97]/[98]): wirken auf Bauteil-/Öffnungslisten und das IFC-Pset. */ +export function BuildingFlags({ isExternal, loadBearing, host }: { isExternal: boolean; loadBearing: boolean; host: ReturnType }) { + return ( + <> +
+ {t("objinfo.isExternal")} + host.onSetBuildingFlags({ isExternal: e.target.checked })} /> +
+
+ {t("objinfo.loadBearing")} + host.onSetBuildingFlags({ loadBearing: e.target.checked })} /> +
+ + ); +} + + +// ── UK/OK-Zeile: Modus-Umschalter (Geschoss/eigene Höhe) + Feld ────────────── +// „Geschoss gebunden" → Geschoss-Dropdown; „eigene Höhe" → absolutes Z-Feld. +// `null`-Anchor (undefined im Modell) = Geschoss-Default; zeigt „eigene Höhe" +// mit dem aufgelösten Default-Z als Ausgangswert NICHT — Default ist +// „an Geschoss gebunden" (Geschoss-Default-Verhalten). +export function VerticalAnchorRow({ + label, + anchor, + defaultZ, + floors, + defaultFloorId, + onChange, +}: { + label: string; + anchor?: VerticalAnchor; + defaultZ: number; + floors: { id: string; name: string }[]; + defaultFloorId: string; + onChange: (a: VerticalAnchor | null) => void; +}) { + const mode: "floor" | "custom" = anchor?.mode === "custom" ? "custom" : "floor"; + + function setMode(next: "floor" | "custom") { + if (next === mode) return; + if (next === "custom") { + onChange({ mode: "custom", z: defaultZ }); + } else { + // Zurück auf Geschoss-Bindung: bei vorhandenem expliziten Geschoss dieses, + // sonst Default-Geschoss → entspricht dem Geschoss-Default-Verhalten. + onChange({ mode: "floor", floorId: defaultFloorId }); + } + } + + return ( +
+
+ {label} +
+ + +
+
+ {/* Unterzeile in normaler Label-/Wert-Struktur: Label links, Control in + der Wert-Spalte (Nutzer-Wunsch — vorher hing das Control ohne Label + im Einzug der linken Spalte). */} + {mode === "floor" ? ( +
+ {t("objinfo.anchor.refFloor")} + onChange({ mode: "floor", floorId: id })} + options={floors.map((f) => ({ value: f.id, label: f.name }))} + title={t("objinfo.anchor.refFloor")} + width={150} + /> +
+ ) : ( + onChange({ mode: "custom", z })} + /> + )} +
+ ); +} + + +export function DimensionField({ + label, + value, + onCommit, + min = 0, + unit = "m", + step = 0.01, + digits = 3, +}: { + label: string; + value: number; + onCommit: (v: number) => void; + min?: number; + unit?: string; + step?: number; + /** Nachkommastellen der Anzeige (Papier-mm: 1). */ + digits?: number; +}) { + // Entwurf als String, damit Zwischenzustände (leer, „1.") tippbar sind. + // `null` = kein aktiver Entwurf → zeige den Host-Wert. + const [draft, setDraft] = useState(null); + // Enter committet und nimmt danach den Fokus — das `blur` im selben Handler sieht noch den alten + // Entwurf (State noch nicht neu gerendert) und committete ein zweites Mal (X/Y: doppelte Verschiebung). + const pending = useRef(null); + pending.current = draft; + + const shown = draft ?? (Object.is(Number(value.toFixed(digits)), -0) ? 0 : value).toFixed(digits); + + function commit() { + const d = pending.current; + if (d === null) return; + pending.current = null; + const v = Number(d); + setDraft(null); + if (isFinite(v) && v >= min) onCommit(v); + } + + return ( + + ); +} + + +// ── Dreh-Feld (Delta-Winkel in Grad) ───────────────────────────────────────── +// Anders als DimensionField zeigt dieses Feld KEINEN persistenten Host-Wert — +// eine „aktuelle Rotation" gibt es für die Selektion generell nicht (Wand ist +// nur eine Achse, Drawing2D/Extrusion tragen keinen Rotationswinkel). Das Feld +// ist daher ein Delta: Eingabe = Drehung ab jetzt, danach zeigt es wieder „0". +export function RotateField({ onCommit }: { onCommit: (deg: number) => void }) { + const [draft, setDraft] = useState(null); + const shown = draft ?? "0"; + + function commit() { + if (draft === null) return; + const v = Number(draft); + setDraft(null); + if (isFinite(v) && v !== 0) onCommit(v); + } + + return ( + + ); +}