Files
DOSSIER/src/panels/ObjectInfoPanel.tsx
T
Claude fb0c932b53 [271] Umbaufilter: Status Bestand/Abbruch/Neu mit Etappen, Filter wie Archicad in Grundriss, Schnitt, Ansicht, Axo, 3D, Kennzahlen, DXF und IFC
Modell (Rust, gen:types): `renovation: {status, phase?}` an Wand, Öffnung (ohne eigenen Status
folgt sie der Wand), Decke, Dach, Treppe, Stütze, Körper und Raum (Raum nur Sichtbarkeit und
Flächen, keine Farbe); `Project.renovation` (Etappen, Farben, eigene Filter, KNOWN_KEYS);
`renovationFilter`/`renovationPhase` an DrawingLevel, ViewTemplate und ViewSnapshot — der Filter
gehört zur Ebene wie die Modelldarstellung [173], damit je Reiter, Ausschnitt und Vorlage.

Kern `renovation.rs` als ein Ort für „sichtbar/wie gezeichnet im Filter“: Vorgaben Bestand,
Abbruch, Neubau, Umbauplan, Endzustand; SIA-400-Farben (Bestand grau, Abbruch gelb gestrichelt,
Neu rot), anpassbar; Etappe „bis n“; neue Öffnung in Bestandswand = Abbruch-Stück, zugemauerte
Öffnung = Ausfachung (die Wand schliesst, wo die Öffnung ausgeblendet ist, wie bei der Regel
„Ausblenden“). Angebunden: Grundriss (Ctx.hidden, Farben je Element-Bereich, nur Schnittflächen
gefüllt, Symbole in Linienfarbe), Schnitt (without_elements + CutRules::with_renovation), Ansicht,
Vektor-Axo, 3D (model3dParts mit Filter, 3D-Fenster nimmt den Filter der aktiven Ebene),
Kennzahlen/Flächen (Text = Zustand), DXF (Layer <Klasse>_Abbruch/_Neu), IFC (Status im
Pset_*Common, Etappe in Dossier_Umbau). Tusche behält die Umbau-Farben (extras::KeepColors).
Neue Bauteile der Zeichenbefehle tragen den Zeichen-Status (commands::stamp_renovation).

Bedienung: Objekt-Info/Objekteinstellungen „Umbau“ und „Etappe“ (Mehrfachauswahl, ein
Undo-Schritt), Statusleiste „Umbau: …“ mit Zeichen-Status und Umbaufilter der Ansicht (im
Überlauf „⋯“ mit der Pausfolie), Befehl `umbau` (B/A/N; getippte Options-Kürzel mit Enter),
Ressourcen-Tab „Umbau“ (Etappen, Farben), Flächenbilanz „Zustand“, Vorlage „Beispiel Umbau“
(CLI :umbau), CLI --renovation/--phase für plan, section, elevation, axo, model3d, kennzahlen.

Tests: Kern renovation_tests.rs (20: Vorgaben, Etappen, Öffnungen in Bestandswand, Grundriss,
Schnitt, Ansicht, Kennzahlen, DXF, IFC, 3D, Tusche, Zeichen-Status, Unsinn), Robustheit (Plan,
Schnitt, Ansicht, Kennzahlen, 3D mit Filter), vitest model/renovation.test.ts und
commands/cmds/renovation.test.ts, e2e renovation271.spec.ts (2× grün). Goldens unverändert.
Bilder doc/review-271 (CLI-SVG --hatch in Chromium, App). Nur im Linux-Container geprüft, nicht
in der Tauri-App/auf dem Mac (Prüfschritt RELEASE-1.0 13.37). Offen: TODO [271].
2026-11-17 11:44:28 +00:00

415 lines
19 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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 { LibObjectSection } from "./objectInfo/LibObjectSection";
import { elementDimensions } from "./objectInfo/elementDims";
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup";
import { RenovationField } from "./objectInfo/RenovationField";
// ── 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;
}
/**
* `showPlacement` = false: ohne Bezugspunkt/Lage und Masse (Breite/Höhe/Drehen) — so zeigt sie das Fenster
* Objekteinstellungen ([218], Wunsch Maintainer: Platzierung und Masse gehören nur ins Objekt-Info-Panel).
*/
export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: boolean } = {}) {
const host = usePanelHost();
const storeProject = useStore((st) => st.project);
// [121] Abschnitts-Rahmen ohne eigene Komponente (kein Render je Abschnitt bei Inhaltsänderung).
const gst = useInfoGroupState();
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 <TreeSection ids={treeSel} />;
// [213] Kamera gewählt: Standpunkt, Ziel, Bildwinkel, Projektion, Sonne und „Kamera öffnen".
if (sel === null && cameraSel.length > 0) return <CameraSection ids={cameraSel} />;
if (sel === null && site[0] === "viewShadows") return <ViewShadowsInfo />;
if (sel === null && site.length > 0) {
const sun = site[0] === "sunStudy";
return (
<div className="objinfo-panel">
<div className="objinfo-head">
<span className="objinfo-kind">{t(sun ? "objinfo.kind.sunStudy" : "objinfo.kind.siteRules")}</span>
</div>
<div className="objinfo-muted objinfo-site-hint">{t(sun ? "objinfo.sunStudy.hint" : "objinfo.siteRules.hint")}</div>
<div className="site-panel objinfo-site">{sun ? <SunStudySection /> : <SiteRulesSection />}</div>
</div>
);
}
if (sel === null) {
const groups = hasInfoGroups(null, undefined, host);
return (
<div className="objinfo-panel">
{m ? <MeasurementSection m={m} /> : !groups && <div className="objinfo-empty">{t("objinfo.empty")}</div>}
<InfoGroups sel={null} drawing={undefined} host={host} />
</div>
);
}
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 (
<div className="objinfo-panel">
{m && <MeasurementSection m={m} />}
{/* Kopfzeile: Typ + editierbare Klasse (Grafik-Kategorie) + Zeichnungsebene
(VW-Muster „Klasse"/„Ebene"). */}
<div className="objinfo-head">
<span className="objinfo-kind">{t(`objinfo.kind.${sel.kind}`)}</span>
</div>
{sel.categoryCode !== "" && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.category")}</span>
<Dropdown
value={sel.categoryCode}
onChange={(v) => host.onSetSelectionCategory(v)}
options={flattenCategories(storeProject.layers).map((c) => ({
value: c.code,
label: `${c.code} ${c.name}`,
}))}
title={t("objinfo.category")}
width={150}
/>
</div>
)}
{sel.floorId != null && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.level")}</span>
<Dropdown
value={sel.floorId}
onChange={(v) => 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}
/>
</div>
)}
{/* [271] Umbau: Status und Etappe der Auswahl (Mehrfachauswahl in einem Undo-Schritt). */}
<RenovationField />
{showPlacement && (
<>
{infoGroupFrame(gst, "refpoint", <>
{/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte
rechts daneben (Nutzer-Wunsch). */}
<div className="objinfo-refrow">
<div className="objinfo-cube" role="group" aria-label={t("objinfo.refpoint")}>
{FRACTIONS.map((fy) =>
FRACTIONS.map((fx) => {
const active = anchor.fx === fx && anchor.fy === fy;
return (
<button
key={anchorKey(fx, fy)}
type="button"
className={"objinfo-anchor" + (active ? " active" : "")}
title={t("objinfo.setRefpoint")}
aria-pressed={active}
onClick={() => setAnchor({ fx, fy })}
>
<span className="objinfo-dot" />
</button>
);
}),
)}
</div>
{/* X / Y des gewählten Bezugspunkts (editierbar) + Z (read-only) + ein
Dreh-Feld, als Spalte. */}
<div className="objinfo-xyzcol">
<DimensionField
label={t("objinfo.x")}
value={xToDisplay(u, px)}
min={-Infinity}
{...lenProps}
onCommit={(nx) => host.onMoveSelectionBy(unlen(nx) - px, 0)}
/>
<DimensionField
label={t("objinfo.y")}
value={yToDisplay(u, py)}
min={-Infinity}
{...lenProps}
onCommit={(ny) => 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. */}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.z")}</span>
<span className="objinfo-fval objinfo-muted" title={t("objinfo.zHint")}>
—
</span>
</div>
{/* Drehen: Delta-Winkel (Grad) um den gewählten Bezugspunkt — kein
persistenter Zustand, das Feld zeigt nach dem Commit wieder „0". */}
<RotateField onCommit={(deg) => host.onRotateSelectionAround(px, py, deg)} />
</div>
</div>
</>)}
{infoGroupFrame(gst, "dimensions", <>
{/* Maße (editierbar) — Commit auf blur/Enter skaliert um den Anker. */}
{elementDims ? (
// [204a] Wand: Länge/Dicke/Höhe, Öffnung: Breite/Höhe/Brüstung (nur Anzeige).
elementDims.map((d) => (
<div className="objinfo-field" key={d.label} data-testid="objinfo-dim">
<span className="objinfo-flabel">{t(d.label)}</span>
<span className="objinfo-fval">{len(d.value).toFixed(u.digits)} {u.suffix}</span>
</div>
))
) : rawDrawing?.geom.shape === "libobj" ? (
// [253] Bibliotheks-Objekt: Masse und Parameter generisch aus dem Katalog.
<LibObjectSection drawing={rawDrawing} geom={rawDrawing.geom} />
) : (
<>
<DimensionField
label={t("objinfo.width")}
value={len(width)}
{...lenProps}
onCommit={(w) => commitSize(unlen(w), height)}
/>
<DimensionField
label={t("objinfo.height")}
value={len(height)}
{...lenProps}
onCommit={(h) => 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" && (
<>
<DimensionField
label={t("objinfo.drawing.length")}
value={len(Math.hypot(width, height))}
{...lenProps}
onCommit={(v) => host.onSetDrawingLineLength(unlen(v))}
/>
<DimensionField
label={t("objinfo.drawing.angle")}
value={toDeg360(
Math.atan2(
rawDrawing.geom.b.y - rawDrawing.geom.a.y,
rawDrawing.geom.b.x - rawDrawing.geom.a.x,
),
)}
min={-Infinity}
step={1}
unit="°"
onCommit={(v) => host.onSetDrawingLineAngle(v)}
/>
</>
)}
{drawingShape === "text" && rawDrawing?.geom.shape === "text" && (
<DimensionField
label={t("objinfo.drawing.paperHeight")}
value={rawDrawing.geom.paperHeight ?? 0}
min={0}
step={0.5}
unit="mm"
onCommit={(v) => host.onSetDrawingTextPaperHeight(v)}
/>
)}
{sel.kind === "drawing2d" && sel.area !== undefined && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.drawing.area")}</span>
<span className="objinfo-fval">{sel.area.toFixed(2)} m²</span>
</div>
)}
{drawingShape === "circle" && (
<DimensionField
label={t("objinfo.drawing.radius")}
value={len(width / 2)}
{...lenProps}
onCommit={(v) => host.onSetDrawingCircleRadius(unlen(v))}
/>
)}
{drawingShape === "arc" && rawDrawing?.geom.shape === "arc" && (
<>
<DimensionField
label={t("objinfo.drawing.radius")}
value={len(rawDrawing.geom.r)}
{...lenProps}
onCommit={(v) => host.onSetDrawingArcRadius(unlen(v))}
/>
<DimensionField
label={t("objinfo.drawing.startAngle")}
value={toDeg360(rawDrawing.geom.a0)}
min={-Infinity}
step={1}
unit="°"
onCommit={(v) => host.onSetDrawingArcStartAngle(v)}
/>
<DimensionField
label={t("objinfo.drawing.endAngle")}
value={toDeg360(rawDrawing.geom.a1)}
min={-Infinity}
step={1}
unit="°"
onCommit={(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 && (
<>
{infoGroupFrame(gst, "contextProps", <>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.contextObject.type")}</span>
<span className="objinfo-fval">{t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}</span>
</div>
{ctxObj && (
<div className="site-panel objinfo-site">
<ContextObjectProps obj={ctxObj} quantities={quantities} />
</div>
)}
</>)}
{/* [239] Herkunft und LV95 stehen in eigener Gruppe (Standard zugeklappt: nur Auskunft). */}
{infoGroupFrame(gst, "georef", <>
{sel.contextObject.source && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.contextObject.source")}</span>
<span className="objinfo-fval" data-testid="context-source">{sel.contextObject.source}</span>
</div>
)}
{sel.contextObject.lv95Center ? (
<>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.contextObject.lv95E")}</span>
<span className="objinfo-fval">{sel.contextObject.lv95Center.e.toFixed(1)}</span>
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.contextObject.lv95N")}</span>
<span className="objinfo-fval">{sel.contextObject.lv95Center.n.toFixed(1)}</span>
</div>
</>
) : (
<div className="objinfo-field">
<span className="objinfo-fval objinfo-muted">{t("objinfo.contextObject.noAnchor")}</span>
</div>
)}
</>)}
</>
)}
{/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */}
<InfoGroups sel={sel} drawing={rawDrawing} host={host} />
</div>
);
}