// Inhalts-Panel „Objekt-Info" (Vectorworks-Stil) — kompakte Sicht auf die // aktuelle Auswahl: ein 3×3-Bezugspunkt-„Würfel", die X/Y-Koordinaten des // gewählten Bezugspunkts (read-only) sowie editierbare Maße Breite×Höhe. // // Bei Auswahl GENAU EINER Wand zeigt das Panel zusätzlich einen Wand-Abschnitt // (Referenzlinie, Aufbau-Typ/Dicke/Preset, Referenzgeschoss + UK/OK) — analog // Vectorworks. Die Referenzlinie sitzt rechts oben im Kopf. // // Alle Daten/Handler kommen über usePanelHost (kein Prop-Drilling, kein // Modellzugriff). Der gewählte Bezugspunkt (fx,fy ∈ {0,0.5,1}) ist lokaler // State und wird als Anker an onResizeSelection durchgereicht: Beim Ändern // der Maße bleibt genau dieser Punkt fix. // // Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). Alle sichtbaren // Texte über t(...). // // [165] Die Abschnitte (Wand, Decke, Dach, Treppe …) liegen in `objectInfo/`. [189] Sie erscheinen hier als // einklappbare Gruppen (`objectInfo/InfoGroups.tsx`; Zuordnung in `objectInfo/groups.ts`) — das Attribute-Panel // zeigt nur noch Gestaltung. Das Panel selbst hält Baum, Messwerte und die gemeinsamen Felder. import { useSelectionInfo } from "../state/useSelectionInfo"; import { lengthFromDisplay, lengthToDisplay, unitsForLevel, xToDisplay, yFromDisplay, yToDisplay } from "../tools/displayUnits"; import { useMemo, useState } from "react"; import { t } from "../i18n"; import { flattenCategories } from "../model/types"; import { Dropdown } from "../ui/Dropdown"; import { usePanelHost } from "./host"; import { useStore } from "../state/appStore"; import { excavationQuantities } from "../core"; import { ContextObjectProps } from "./ContextObjectProps"; import { SunStudySection } from "./SunStudySection"; import { SiteRulesSection } from "./SiteRulesSection"; import { TreeSection } from "./objectInfo/TreeSection"; import { CameraSection } from "./objectInfo/CameraSection"; import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks"; import { DimensionField, RotateField } from "./objectInfo/fields"; import { elementDimensions } from "./objectInfo/elementDims"; import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups"; // ── 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 storeProject = useStore((st) => st.project); const sel = useSelectionInfo(); // Gewählter Bezugspunkt — Default Mitte (Vectorworks-Standardanker beim // Skalieren). Bleibt erhalten, solange das Panel montiert ist. const [anchor, setAnchor] = useState<{ fx: number; fy: number }>({ fx: 0.5, fy: 0.5, }); // ── Mess-Werkzeug: Live-Messwerte (Länge/Fläche/Winkel) ───────────────────── // Werden angezeigt, sobald gemessen wird — unabhängig von einer Selektion // (das Mess-Werkzeug erzeugt kein Element). Hat Vorrang vor dem Leerzustand. const m = host.measurement; // [137] Lage-Darstellung angeklickt (Schattenfläche / Baurechtslinie): Einstellungen der Quelle. const site = useStore((s) => s.selection.site); const treeSel = useStore((s) => s.selection.trees); const cameraSel = useStore((s) => s.selection.cameras); const ctxObj = sel?.kind === "contextObject" ? (storeProject.context ?? []).find((o) => o.id === sel.id) : undefined; const quantities = useMemo( () => (ctxObj?.type === "excavation" ? excavationQuantities(storeProject) : []), [ctxObj?.type, storeProject], ); // ── Leerzustand ─────────────────────────────────────────────────────────── // [149] Baum gewählt: eigene Felder (Lage, Masse, Form, Bestand). if (sel === null && treeSel.length > 0) return ; // [213] Kamera gewählt: Standpunkt, Ziel, Bildwinkel, Projektion, Sonne und „Kamera öffnen". if (sel === null && cameraSel.length > 0) return ; if (sel === null && site[0] === "viewShadows") return ; if (sel === null && site.length > 0) { const sun = site[0] === "sunStudy"; return (
{t(sun ? "objinfo.kind.sunStudy" : "objinfo.kind.siteRules")}
{t(sun ? "objinfo.sunStudy.hint" : "objinfo.siteRules.hint")}
{sun ? : }
); } if (sel === null) { const groups = hasInfoGroups(null, undefined, host); return (
{m ? : !groups &&
{t("objinfo.empty")}
}
); } const { bbox } = sel; const elementDims = elementDimensions(sel); const width = bbox.maxX - bbox.minX; const height = bbox.maxY - bbox.minY; // X/Y des gewählten Bezugspunkts (Modell-Meter). Editierbar: Commit // verschiebt die Selektion so, dass der gewählte Bezugspunkt auf die // eingegebene Koordinate wandert (Delta = neu − aktuell → generischer Move // über den Host). Bei Öffnungen (wandgebunden, kein freier 2D-Punkt) ist der // Host-Aufruf ein No-op — das Feld zeigt danach wieder den unveränderten // Wert (wie bei Breite/Höhe oben). const px = bbox.minX + anchor.fx * width; const py = bbox.minY + anchor.fy * height; // Auf einem Layout-Blatt zeigt und liest das Panel Papier-mm mit y nach unten ([93]). const u = unitsForLevel(storeProject.drawingLevels.find((z) => z.id === sel.floorId)); const len = (m: number): number => lengthToDisplay(u, m); const unlen = (v: number): number => lengthFromDisplay(u, v); const lenProps = { unit: u.suffix, digits: u.digits }; // Rohe Drawing2D-Geometrie der Selektion (nur bei kind==="drawing2d") — für // die Linien-Länge/Kreis-Radius-Felder unten; die Selection-Sicht trägt // keine Geometrieform, daher direkter (Lese-)Zugriff aufs Projekt. const rawDrawing = sel.kind === "drawing2d" ? storeProject.drawings2d.find((d) => d.id === sel.id) : undefined; const drawingShape = rawDrawing?.geom.shape; // ── Maß-Commit ────────────────────────────────────────────────────────────── // Liest beide aktuellen Maße aus den Feldern und skaliert um den aktiven // Anker. Negative/ungültige Werte werden ignoriert (kein Resize). function commitSize(nextWidth: number, nextHeight: number) { if (!isFinite(nextWidth) || !isFinite(nextHeight)) return; if (nextWidth < 0 || nextHeight < 0) return; host.onResizeSelection(nextWidth, nextHeight, anchor); } return (
{m && } {/* Kopfzeile: Typ + editierbare Klasse (Grafik-Kategorie) + Zeichnungsebene (VW-Muster „Klasse"/„Ebene"). */}
{t(`objinfo.kind.${sel.kind}`)}
{sel.categoryCode !== "" && (
{t("objinfo.category")} host.onSetSelectionCategory(v)} options={flattenCategories(storeProject.layers).map((c) => ({ value: c.code, label: `${c.code} ${c.name}`, }))} title={t("objinfo.category")} width={150} />
)} {sel.floorId != null && (
{t("objinfo.level")} host.onSetSelectionLevel(v)} options={storeProject.drawingLevels // Geschosse + die aktuelle Ebene (2D-Zeichnungen können auch auf // Schnitt-/Zeichnungs-Ebenen liegen — die darf nicht verschwinden). .filter((z) => z.kind === "floor" || z.id === sel.floorId) .map((z) => ({ value: z.id, label: z.name }))} title={t("objinfo.level")} width={150} />
)}
{( <> {/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte rechts daneben (Nutzer-Wunsch). */}
{t("objinfo.refpoint")}
{FRACTIONS.map((fy) => FRACTIONS.map((fx) => { const active = anchor.fx === fx && anchor.fy === fy; return ( ); }), )}
{/* X / Y des gewählten Bezugspunkts (editierbar) + Z (read-only) + ein Dreh-Feld, als Spalte. */}
host.onMoveSelectionBy(unlen(nx) - px, 0)} /> host.onMoveSelectionBy(0, yFromDisplay(u, ny) - py)} /> {/* Z ehrlich: Das Modell ist 2D pro Ebene; es gibt keine Z am Element. Daher „—" statt einer gefakten 0, mit kurzem Hinweis im Titel. */}
{t("objinfo.z")} —
{/* Drehen: Delta-Winkel (Grad) um den gewählten Bezugspunkt — kein persistenter Zustand, das Feld zeigt nach dem Commit wieder „0". */} host.onRotateSelectionAround(px, py, deg)} />
{/* Maße (editierbar) — Commit auf blur/Enter skaliert um den Anker. */}
{t("objinfo.dimensions")}
{elementDims ? ( // [204a] Wand: Länge/Dicke/Höhe, Öffnung: Breite/Höhe/Brüstung (nur Anzeige). elementDims.map((d) => (
{t(d.label)} {len(d.value).toFixed(u.digits)} {u.suffix}
)) ) : ( <> commitSize(unlen(w), height)} /> commitSize(width, unlen(h))} /> )} {/* Formspezifische Zusatzfelder (nur wenn das Modell den Wert direkt hergibt — andere Formen bleiben ohne Zusatzfeld, s. Dateikopf). */} {drawingShape === "line" && rawDrawing?.geom.shape === "line" && ( <> host.onSetDrawingLineLength(unlen(v))} /> host.onSetDrawingLineAngle(v)} /> )} {drawingShape === "text" && rawDrawing?.geom.shape === "text" && ( host.onSetDrawingTextPaperHeight(v)} /> )} {sel.kind === "drawing2d" && sel.area !== undefined && (
{t("objinfo.drawing.area")} {sel.area.toFixed(2)} m²
)} {drawingShape === "circle" && ( host.onSetDrawingCircleRadius(unlen(v))} /> )} {drawingShape === "arc" && rawDrawing?.geom.shape === "arc" && ( <> host.onSetDrawingArcRadius(unlen(v))} /> host.onSetDrawingArcStartAngle(v)} /> host.onSetDrawingArcEndAngle(v)} /> )} )} {/* Gelände-/Umgebungs-Element (Netzkörper, Gelände, Höhenlinien …): Art, Herkunft (nur Auskunft, [181]), Einstellungen und reale LV95-Koordinate des Bbox-Mittelpunkts — direkt sichtbar, ob/wohin georeferenziert importiert wurde (Nutzer-Wunsch zum Prüfen). */} {sel.contextObject && ( <>
{t("objinfo.contextObject.section")}
{t("objinfo.contextObject.type")} {t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}
{sel.contextObject.source && (
{t("objinfo.contextObject.source")} {sel.contextObject.source}
)} {ctxObj && (
)} {sel.contextObject.lv95Center ? ( <>
{t("objinfo.contextObject.lv95E")} {sel.contextObject.lv95Center.e.toFixed(1)}
{t("objinfo.contextObject.lv95N")} {sel.contextObject.lv95Center.n.toFixed(1)}
) : (
{t("objinfo.contextObject.noAnchor")}
)} )} {/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */}
); }