// Dock-Panel „Objekte" ([253]) — Palette der Standard-Objektbibliothek 2D: Gruppen (Sanitär, Küche, Tische, …) // mit Vorschau-Symbol je Objekt. Klick wählt das Objekt und startet den Befehl `libobj` (Einfügepunkt klicken, // R = drehen, M = spiegeln). Der Katalog kommt aus dem Rust-Kern; die Vorschau zeichnet der Kern (grob). import { useMemo } from "react"; import { t } from "../i18n"; import type { TranslationKey } from "../i18n"; import { usePanelHostAction } from "./host"; import { setActiveLibObject } from "../commands/cmds/libobj"; import { libCatalog, libDefaultParams, libGeometry, libGeometryToPolys, libGroups, polysBounds, type LibObjectDef, } from "../model/furnitureLib"; const SIZE = 44; /** Vorschau: Linien des Objekts (grob) als kleines SVG, Plan-y nach oben. */ function Preview({ def }: { def: LibObjectDef }) { const polys = useMemo( () => libGeometryToPolys(libGeometry(def.id, libDefaultParams(def), "grob", 1), (p) => ({ x: p.x, y: -p.y })), [def], ); const b = polysBounds(polys); if (!b) return ; const w = Math.max(b.maxX - b.minX, 1e-3); const h = Math.max(b.maxY - b.minY, 1e-3); const pad = 3; const k = (SIZE - 2 * pad) / Math.max(w, h); const tx = (x: number) => pad + (x - b.minX) * k + ((SIZE - 2 * pad) - w * k) / 2; const ty = (y: number) => pad + (y - b.minY) * k + ((SIZE - 2 * pad) - h * k) / 2; return ( ); } export function ObjectLibraryPanel() { const onRunCommand = usePanelHostAction("onRunCommand"); const catalog = useMemo(() => libCatalog(), []); const groups = useMemo(() => libGroups(), []); const place = (def: LibObjectDef) => { setActiveLibObject(def.id, libDefaultParams(def)); onRunCommand("libobj"); }; if (catalog.objects.length === 0) { return
{t("lib.empty")}
; } return (
{t("lib.hint")}
{groups.map((g) => (
{t(`lib.g.${g}` as TranslationKey)}
{catalog.objects .filter((o) => o.group === g) .map((o) => { const name = t(`lib.o.${o.id.replace(/^lib:/, "")}` as TranslationKey); return ( ); })}
))}
); } /** Tab-Symbol: Stuhl in der Draufsicht. */ export function ObjectLibraryTabIcon() { return ( ); }