From d926f950782e884d81db7555ab258d3ee5aae8a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 20:27:59 +0000 Subject: [PATCH] =?UTF-8?q?[189]=20Attribute=20nur=20Gestaltung,=20Bauteil?= =?UTF-8?q?-Felder=20in=20einklappbaren=20Gruppen=20der=20Objekt-Info;=20T?= =?UTF-8?q?aste=20T=20=C3=B6ffnet=20Objekteinstellungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 +- e2e/objectSettings.spec.ts | 104 ++++++++++ src/App.tsx | 12 ++ src/i18n/de.ts | 9 +- src/i18n/en.ts | 9 +- src/native/appMenu.ts | 6 + src/panels/AttributesPanel.tsx | 184 ++---------------- src/panels/ObjectInfoPanel.tsx | 18 +- src/panels/README.md | 2 +- src/panels/objectInfo/GridSection.tsx | 119 +++++++++++ src/panels/objectInfo/InfoGroup.tsx | 35 ++++ src/panels/objectInfo/InfoGroups.tsx | 66 +++++++ src/panels/objectInfo/NewComponentSection.tsx | 24 +++ src/panels/objectInfo/groups.test.ts | 75 +++++++ src/panels/objectInfo/groups.ts | 115 +++++++++++ src/panels/objectInfo/infoGroupState.ts | 73 +++++++ src/state/README.md | 1 + src/state/keyboardShortcuts.ts | 5 +- src/state/objectSettings.ts | 41 ++++ src/state/useKeyboardShortcuts.ts | 27 +++ src/state/useNativeMenu.ts | 3 + src/styles.css | 62 +++++- 22 files changed, 791 insertions(+), 201 deletions(-) create mode 100644 e2e/objectSettings.spec.ts create mode 100644 src/panels/objectInfo/GridSection.tsx create mode 100644 src/panels/objectInfo/InfoGroup.tsx create mode 100644 src/panels/objectInfo/InfoGroups.tsx create mode 100644 src/panels/objectInfo/NewComponentSection.tsx create mode 100644 src/panels/objectInfo/groups.test.ts create mode 100644 src/panels/objectInfo/groups.ts create mode 100644 src/panels/objectInfo/infoGroupState.ts create mode 100644 src/state/objectSettings.ts diff --git a/TODO.md b/TODO.md index 08d524f5..7e366cb9 100644 --- a/TODO.md +++ b/TODO.md @@ -85,7 +85,6 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* gedämpft (render3d hat nur `set_ghost` für die Hülle); natives Mac-3D-Fenster bekommt nur den Ebenen-Baum, nicht den Darstellungsmodus; Datei-Exporte (OBJ/glTF/IFC/STEP) bleiben vollständig; kein e2e (3D-Pick headless unzuverlässig); nicht in der Tauri-App/auf dem Mac geprüft. · M -- ○ **[189]** Panels neu ordnen + Einstellungsdialog (12.11., Maintainer): Attribute-Panel unten links nur Gestaltung (Stift, Füllung, Linienstil, Schraffur); BIM-/Bauteil-Infos (Typ, Schichten, Masse, Kennwerte, IFC/Psets, Material …) in die Objekt-Info. Taste T bei Auswahl öffnet direkt den Einstellungsdialog des Objekts (wie Archicad Cmd+T), v. a. für Fenster/Türen, deren Einstellungen heute nur über das Attribute-Panel erreichbar sind. · M - ○ **[187]** Griffe im Schnitt/in der Ansicht (12.11., Maintainer): angewählte Elemente haben dort kaum Fasspunkte (Decken, Gelände, Dächer …). Wie Archicad: Decke OK/UK (Höhe/Dicke), Wand OK (Höhe), Öffnung Brüstung/Sturz, Dach Traufe/First bzw. Neigung, Treppe An-/Austritt, Gelände-Profilpunkte (falls Modell es erlaubt); ein Undo-Schritt je Zug, Fang + Tab-Eingabe wie im Grundriss. · L - ○ **[186]** Schatten (12.11., Maintainer): (1) 3D-Schatten stellenweise unscharf (Shadow-Map-Auflösung/Frustum zu gross, Filter) → Frustum auf Gebäude fitten bzw. Kaskaden, schärferer PCF; (2) Grundriss-Schatten fehlt unmittelbar am Haus (Lücke zwischen Fassade und Schatten; vermutlich Werfer ab ±0.00 statt ab Wandfuss/Gelände) → Schatten beginnt an der Fassade. Opus. · M - ◐ **[185]** Navigation wie Archicad (12.11., Wunsch Maintainer). Umgesetzt (12.11.): Geschosswechsel im Grundriss @@ -736,3 +735,4 @@ exakte Durchdringung, [61] Zuordnung per Hand, [63] Profil je Kante, [70] Fläch halbe Handlaufbreite, IFC-Basismenge `CrossSectionArea`, Objekt-Info (Profil + Masse). Ohne Angabe Rundrohr wie bisher (Netze bit-gleich). Offen: Profil am Treppentyp (nur am Element), Profil nur für Handlauf/Pfosten, Stäbe der Absturzsicherung bleiben rund; in der App nicht geklickt +- **[189]** Panels neu ordnen + Einstellungsdialog (12.11.): Attribute-Panel nur noch Gestaltung (Stift, Linienenden, Bemassungs-Darstellung, Füllung); Typ/Aufbau/Masse/Raum/Dach/Treppe/Verweise, Achsraster, Schnittlinie und „Neues Bauteil" (Wandtyp des Werkzeugs) in der Objekt-Info als einklappbare Gruppen (`panels/objectInfo/groups.ts`, `InfoGroup.tsx`; Zustand in localStorage); die doppelte Maß-Anzeige (Ausdehnung X/Y) im Attribute-Panel entfällt. Taste T (rebindbar, `objectSettings`): Fenster/Tür → Öffnungs-Dialog, sonst Abschnitt der Objekt-Info aufgeklappt und fokussiert, ohne Auswahl bei Wand-/Decken-Werkzeug „Neues Bauteil"; macOS-Menü „Bearbeiten > Objekteinstellungen…" ohne Kürzel (ein nacktes T würde das Tippen abfangen). Wand/Decke/Dach/Treppe haben keinen eigenen Typ-Dialog (nur Objekt-Info). Offen: Menüpunkt in der Browser-Menüleiste; nicht in der Tauri-App geprüft. 12.11. diff --git a/e2e/objectSettings.spec.ts b/e2e/objectSettings.spec.ts new file mode 100644 index 00000000..05a4a700 --- /dev/null +++ b/e2e/objectSettings.spec.ts @@ -0,0 +1,104 @@ +// [189] Attribute-Panel = nur Gestaltung, Bauteil-/BIM-Felder in der Objekt-Info; Taste T öffnet die +// Einstellungen des gewählten Objekts (Fenster/Tür: Dialog, sonst Abschnitt der Objekt-Info). +// Mit DOSSIER_SHOTS= entstehen Screenshots für die Abnahme. +import { blurFocus, elementRows, expect, openSample, openTab, startNewProject, test } from "./app"; +import type { Page } from "@playwright/test"; + +test.use({ deviceScaleFactor: 2 }); + +async function selectW1(page: Page): Promise { + await openTab(page, "Elemente"); + await elementRows(page).filter({ hasText: "W1" }).click(); + await expect(page.getByText("Auswahl: 1 Wand")).toBeVisible(); + await openTab(page, "Objekt-Info"); +} + +test("Wand gewählt: Attribute ohne Aufbau/Typ-Felder, Objekt-Info mit Wand-Abschnitt ([189])", async ({ page }) => { + await startNewProject(page); + await openSample(page); + await selectW1(page); + + const attr = page.locator(".attr-panel"); + const info = page.locator(".objinfo-panel"); + // Gestaltung bleibt im Attribute-Panel. + await expect(attr.getByText("Strichstärke (mm)", { exact: true })).toBeVisible(); + await expect(attr.getByText("Hintergrund", { exact: true })).toBeVisible(); + // Bauteil-Felder sind dort weg … + await expect(attr.locator(".objinfo-wall-anchor")).toHaveCount(0); + await expect(attr.getByText("Volumen")).toHaveCount(0); + await expect(attr.getByText("Aufbau", { exact: false })).toHaveCount(0); + await expect(attr.getByText("Maße", { exact: true })).toHaveCount(0); + // … und in der Objekt-Info als einklappbarer Abschnitt. + const group = info.locator('[data-group="wall"]'); + await expect(group.locator(".objinfo-wall-anchor").first()).toBeVisible(); + await expect(group.getByText("Volumen")).toBeVisible(); + + // Einklappen blendet den Inhalt aus, Aufklappen holt ihn zurück. + const head = group.locator(".objinfo-group-head"); + await head.click(); + await expect(head).toHaveAttribute("aria-expanded", "false"); + await expect(group.getByText("Volumen")).toHaveCount(0); + await head.click(); + await expect(group.getByText("Volumen")).toBeVisible(); + + const shots = process.env.DOSSIER_SHOTS; + if (shots) { + await head.evaluate((el) => el.scrollIntoView({ block: "start" })); + await info.screenshot({ path: `${shots}/objekt-info-wand.png` }); + await attr.screenshot({ path: `${shots}/attribute-wand.png` }); + } +}); + +test("Taste T: Fenster gewählt → Einstellungsdialog ([189])", async ({ page }) => { + await startNewProject(page); + await openSample(page); + await openTab(page, "Elemente"); + await elementRows(page).filter({ hasText: /Fenster/ }).first().click(); + await blurFocus(page); + await expect(page.locator(".oed-dialog")).toHaveCount(0); + await page.keyboard.press("t"); + await expect(page.locator(".oed-dialog")).toBeVisible(); +}); + +test("Taste T: Wand gewählt → Wand-Abschnitt der Objekt-Info fokussiert und aufgeklappt ([189])", async ({ page }) => { + await startNewProject(page); + await openSample(page); + await selectW1(page); + const head = page.locator('[data-group="wall"] .objinfo-group-head'); + await head.click(); // zuklappen + await expect(head).toHaveAttribute("aria-expanded", "false"); + await blurFocus(page); + await page.keyboard.press("t"); + await expect(head).toHaveAttribute("aria-expanded", "true"); + await expect(head).toBeFocused(); + await expect(page.locator(".oed-dialog")).toHaveCount(0); +}); + +test("Taste T ohne Auswahl bei Wand-Werkzeug: Typ des neuen Bauteils in der Objekt-Info ([189])", async ({ page }) => { + await startNewProject(page); + await openSample(page); + await openTab(page, "Objekt-Info"); + await blurFocus(page); + await page.keyboard.press("6"); + await blurFocus(page); // der Befehl holt den Fokus in die Befehlszeile + await page.keyboard.press("t"); + await expect(page.locator('[data-group="newComponent"] .objinfo-group-head')).toBeFocused(); + await expect(page.locator(".attr-panel").getByText("Neues Bauteil")).toHaveCount(0); +}); + +test("Taste T: in Textfeldern wirkungslos, ohne Auswahl und Werkzeug nichts ([189])", async ({ page }) => { + await startNewProject(page); + await openSample(page); + await openTab(page, "Elemente"); + await elementRows(page).filter({ hasText: /Fenster/ }).first().click(); + // Tippen im Befehlsfeld darf den Dialog nicht öffnen. + await page.locator(".cmdline-input").fill("t"); + await page.locator(".cmdline-input").press("t"); + await expect(page.locator(".oed-dialog")).toHaveCount(0); + // Auswahl leeren: T tut nichts. + await page.locator(".cmdline-input").fill(""); + await blurFocus(page); + await page.keyboard.press("Escape"); + await page.keyboard.press("t"); + await expect(page.locator(".oed-dialog")).toHaveCount(0); +}); diff --git a/src/App.tsx b/src/App.tsx index 27211cb6..a9089584 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -59,9 +59,11 @@ import { useProjectActions } from "./state/useProjectActions"; import { useCommandEngineHost } from "./state/useCommandEngineHost"; import { TRANSFORM_COMMANDS, useToolInput } from "./state/useToolInput"; import { useSelectionCommands } from "./state/useSelectionCommands"; +import { openObjectSettings } from "./state/objectSettings"; import { useActiveToolKeys, useElementClipboardShortcut, + useObjectSettingsShortcut, useUndoRedoShortcut, } from "./state/useKeyboardShortcuts"; import { useProjectFileActions } from "./state/useProjectFileActions"; @@ -494,8 +496,18 @@ export default function App() { pa, }); + // [189] Taste T / Menü „Objekteinstellungen…": Öffnungs-Dialog bzw. Objekt-Info (state/objectSettings.ts). + const openSettingsOfObject = () => + openObjectSettings({ + activeTool, + openOpeningEditor: setOpeningEditorId, + revealObjectInfo: () => setLayout((l) => revealPanel(l, "object-info")), + }); + useObjectSettingsShortcut(shortcutOverrides, engineRef, openSettingsOfObject); + // Native macOS-Menüleiste → state/useNativeMenu.ts. useNativeMenu({ + onObjectSettings: openSettingsOfObject, files, notify, undo, diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 5d5a76e1..5dc52c09 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -147,6 +147,7 @@ export const de = { "menu.native.move": "Bewegen", "menu.native.mirror": "Spiegeln", "menu.native.rotate": "Drehen", + "menu.native.objectSettings": "Objekteinstellungen…", "menu.native.view": "Ansicht", "menu.native.window": "Fenster", "menu.native.panels": "Panels", @@ -432,11 +433,6 @@ export const de = { "attr.source.layer": "Nach Ebene", "attr.source.object": "Nach Bauteil", "attr.source.custom": "eigener Wert", - "attr.size": "Maße", - "attr.width": "Breite", - "attr.height": "Höhe", - "attr.extentX": "Ausdehnung X", - "attr.extentY": "Ausdehnung Y", // Objekt-Info-Palette (ObjectInfoPanel) "objinfo.title": "Objekt-Info", @@ -931,6 +927,8 @@ export const de = { "objinfo.room.editStamp": "Stempel bearbeiten …", // ── Extrusions-Attribute (truck-Integration, Object-Info-Panel) ───────── "objinfo.sectionLine.section": "Schnittlinie", + "objinfo.dimText.section": "Masszahl", + "objinfo.group.toggle": "Abschnitt ein-/ausklappen", "objinfo.detailRef.section": "Detail-/Schnitt-Verweis", "objinfo.dimRefs.section": "Assoziative Bemassung", "objinfo.dimRefs.point": "Punkt {n}", @@ -3073,6 +3071,7 @@ export const de = { "shortcut.floorDown": "Geschoss tiefer", "shortcut.floorUp": "Geschoss höher", "shortcut.showSelection3d": "Auswahl in 3D zeigen (ohne Auswahl: alles)", + "shortcut.objectSettings": "Einstellungen des gewählten Objekts öffnen (ohne Auswahl: Werkzeug-Voreinstellung)", "shortcut.hideSelection3d": "Auswahl im 3D ausblenden", "settings.section.update": "Update", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index fc5f74a6..59211b7f 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -145,6 +145,7 @@ export const en: Record = { "menu.native.move": "Move", "menu.native.mirror": "Mirror", "menu.native.rotate": "Rotate", + "menu.native.objectSettings": "Object Settings…", "menu.native.view": "View", "menu.native.window": "Window", "menu.native.panels": "Panels", @@ -430,11 +431,6 @@ export const en: Record = { "attr.source.layer": "By layer", "attr.source.object": "By component", "attr.source.custom": "Custom", - "attr.size": "Size", - "attr.width": "Width", - "attr.height": "Height", - "attr.extentX": "Extent X", - "attr.extentY": "Extent Y", // Objekt-Info-Palette (ObjectInfoPanel) "objinfo.title": "Object Info", @@ -927,6 +923,8 @@ export const en: Record = { "objinfo.room.editStamp": "Edit stamp …", // ── Extruded solid attributes (truck integration, object info panel) ──── "objinfo.sectionLine.section": "Section line", + "objinfo.dimText.section": "Dimension text", + "objinfo.group.toggle": "Expand/collapse section", "objinfo.detailRef.section": "Detail/section reference", "objinfo.dimRefs.section": "Associative dimension", "objinfo.dimRefs.point": "Point {n}", @@ -3060,6 +3058,7 @@ export const en: Record = { "shortcut.floorDown": "Story down", "shortcut.floorUp": "Story up", "shortcut.showSelection3d": "Show selection in 3D (no selection: everything)", + "shortcut.objectSettings": "Open settings of the selected object (no selection: tool defaults)", "shortcut.hideSelection3d": "Hide selection in 3D", "settings.section.update": "Update", diff --git a/src/native/appMenu.ts b/src/native/appMenu.ts index 5c7f3345..04114c73 100644 --- a/src/native/appMenu.ts +++ b/src/native/appMenu.ts @@ -51,6 +51,8 @@ export interface NativeAppMenuHandlers { onMove: () => void; onMirror: () => void; onRotate: () => void; + /** [189] Einstellungen des gewählten Objekts (Taste T; als Menüpunkt ohne Kürzel, ein nacktes „T" würde das Tippen in Textfeldern abfangen). */ + onObjectSettings?: () => void; onViewType: (v: ViewType) => void; onView3d: (v: View3d) => void; @@ -287,6 +289,10 @@ export function useNativeAppMenu( text: t("menu.native.rotate"), action: () => handlersRef.current.onRotate(), }), + await MenuItem.new({ + text: t("menu.native.objectSettings"), + action: () => handlersRef.current.onObjectSettings?.(), + }), await PredefinedMenuItem.new({ item: "Separator" }), await MenuItem.new({ text: t("menu.native.clashCheck"), diff --git a/src/panels/AttributesPanel.tsx b/src/panels/AttributesPanel.tsx index effec472..a4908c8f 100644 --- a/src/panels/AttributesPanel.tsx +++ b/src/panels/AttributesPanel.tsx @@ -3,6 +3,10 @@ // ersten selektierten Elements und erlaubt das direkte Bearbeiten (Farbe, // Strichstärke, Füllschraffur). // +// [189] NUR Gestaltung: Stift, Linienenden, Bemassungs-Darstellung, Füllung. Alles Bauteil-/BIM-Bezogene (Typ, +// Aufbau, Masse, Raumdaten, Dach-/Treppen-Parameter, Achsraster, Schnittlinie …) liegt in der Objekt-Info +// (`ObjectInfoPanel`, Abschnitte in `objectInfo/`); welcher Abschnitt wohin gehört, hält `objectInfo/groups.ts`. +// // Vordergrund/Hintergrund/Strichstärke/Schraffur tragen je einen 3-Optionen- // Quellen-Dropdown: „Nach Ebene" (die LayerCategory erzwingt den Wert), „Nach // Bauteil" (erbt vom Component-Manager, heutiges Default-Verhalten) oder @@ -25,10 +29,9 @@ import { Fragment } from "react"; import { useSelectionInfo } from "../state/useSelectionInfo"; import { useStore } from "../state/appStore"; +import { attrGroups } from "./objectInfo/groups"; import type { ReactNode } from "react"; import { t } from "../i18n"; -import { formatM, wallTypeLabel } from "../model/types"; -import { fmtLength, unitsForLevel } from "../tools/displayUnits"; import { PEN_WEIGHTS } from "../model/types"; import type { AttributeSource } from "../model/types"; import { usePanelHost } from "./host"; @@ -40,20 +43,6 @@ import type { EndMark } from "../model/types"; /** Auswahl der Linienenden (Reihenfolge = Anzeige im Dropdown). */ const END_MARK_OPTIONS: EndMark[] = ["none", "arrow", "arrowOpen", "dot", "tick", "square"]; -// 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 } 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, DimTextSection } from "./objectInfo/RefSections"; -import { SurfacePatternPlacement } from "./SurfacePatternPlacement"; - /** UI-Zustand des 3-Optionen-Quellen-Dropdowns (nicht 1:1 das Modell-Feld: * „custom" ist abgeleitet aus „ist ein expliziter Wert gesetzt?", nicht * selbst gespeichert). */ @@ -79,54 +68,16 @@ export function AttributesPanel() { const project = useStore((s) => s.project); const sel = useSelectionInfo(); - // Wandtyp-/Deckentyp-Wahl für das NEUE Bauteil (was gezeichnet wird) — früher - // in der Werkzeug-Sidebar (ToolsPanel), seit deren Entfernung hier. Erscheint - // nur bei aktivem Wand-/Decken-Werkzeug (unabhängig von einer Auswahl); Wand und - // Decke teilen sich denselben Aufbau-Typ (WallType) + Host-State. - const drawingComponent = - host.activeTool === "wall" || host.activeTool === "ceiling"; - const typeSection = drawingComponent ? ( - <> -
{t("attr.newComponent")}
-
- - {t(host.activeTool === "wall" ? "tool.wallType" : "tool.ceilingType")} - - - host.onActiveWallTypeId(v)} - options={project.wallTypes.map((wt) => ({ - value: wt.id, - label: wallTypeLabel(wt, project.components), - title: wt.name, - }))} - /> - -
- - ) : null; - - // Leerzustand: der Typ-Picker (falls ein Bauteil-Werkzeug aktiv ist), sonst ein - // kompakter Hinweis. + // Leerzustand: Hinweis. (Typ des neuen Bauteils und Schnittlinie liegen seit [189] in der Objekt-Info.) if (sel === null) { - // Schnitt-/Ansichtslinie ist kein Projekt-Bauteil (kein `selection`) — sie - // kommt über host.sectionLine und wird hier im „Leerzustand" bearbeitet. return (
- {typeSection} - {host.sectionLine && } - {!typeSection && !host.sectionLine && ( -
{t("attr.empty")}
- )} +
{t("attr.empty")}
); } const isDrawing = sel.kind === "drawing2d"; - const sheetUnits = unitsForLevel(project.drawingLevels.find((z) => z.id === sel.floorId)); - const sizeText = (m: number): string => (sheetUnits.perMeter === 1 ? formatM(m) : `${fmtLength(sheetUnits, m).replace(/mm$/, "")} mm`); // Strichstärke: Wand/Decke/Stütze/Drawing2D tragen einen eigenen Override // (`strokeWeight`/`weightMm`) + Quellen-Dropdown; andere Elementarten erben // stets aus der Kategorie (kein Setter im Kontrakt → nicht editierbar). @@ -262,14 +213,10 @@ export function AttributesPanel() { ? project.lineStyles.find((l) => l.id === drawing.lineStyleId) : undefined; - const bboxW = sel.bbox.maxX - sel.bbox.minX; - const bboxH = sel.bbox.maxY - sel.bbox.minY; - const isModelElement = !!(sel.wall || sel.ceiling || sel.roof || sel.stair || sel.room); + const groups = attrGroups({ sel, openEnds: openEndsShape, isDimension: drawing?.geom.shape === "dimension" }); return (
- {/* Typ-Picker für das neue Bauteil (nur bei aktivem Wand-/Decken-Werkzeug). */} - {typeSection} {/* EIN durchgehendes Grid über alle Sektionen — dieselben zwei Spalten (Label | Wert) für Stift/Füllung/Maße, damit die Wertfelder überall bündig in EINER Spalte stehen. Sektion-Balken spannen beide Spalten. */} @@ -451,7 +398,7 @@ export function AttributesPanel() { Nur bei OFFENEN 2D-Formen und beim Text mit Hinweislinie — geschlossene Formen haben keine Enden. Grösse in Papier-mm (massstabsunabhängig, wie die Bemassungswerte). */} - {openEndsShape && ( + {groups.includes("ends") && ( <>
{t("attr.ends.section")}
{( @@ -499,83 +446,7 @@ export function AttributesPanel() { (Modellmass, s. `model/dimension.ts`); leer/0 fällt auf den Standard zurück. Die Masszahl selbst wird direkt im Plan am eigenen Griff verschoben (rastet nahe der Standardlage ein). */} - {drawing?.geom.shape === "grid" && (() => { - const fmtAxis = (v: number) => (Math.round(v * 100) / 100).toString(); - const geom = drawing.geom as Extract; - const here = geom.levels?.includes(drawing.levelId) && geom.levels.length === 1; - return ( - <> -
{t("attr.grid.section")}
- {t("attr.grid.bubbles")} - - - - {t("attr.grid.extend")} - - { const v = Number(e.target.value); if (Number.isFinite(v) && v >= 0) host.onSetGridProps(drawing.id, { extend: v }); }} /> - - {t("attr.grid.bubbleMm")} - - { const v = Number(e.target.value); if (Number.isFinite(v) && v >= 2) host.onSetGridProps(drawing.id, { bubbleMm: v }); }} /> - - {t("attr.grid.show3d")} - - host.onSetGridProps(drawing.id, { show3d: e.target.checked })} /> - - {(["a", "b"] as const).map((list) => - geom[list].map((ax, i) => ( - - {t(geom.radial ? (list === "a" ? "attr.grid.ray" : "attr.grid.ring") : "attr.grid.axis", { pos: fmtAxis(ax.pos) })} - - host.onSetGridProps(drawing.id, { [list]: geom[list].map((x, k) => (k === i ? { ...x, label: e.target.value } : x)) })} - /> - - - - )), - )} - {t("attr.grid.levels")} - - - - - ); - })()} - - {drawing?.geom.shape === "dimension" && ( + {groups.includes("dimension") && drawing?.geom.shape === "dimension" && ( <>
{t("attr.dim.section")}
{/* Abstände/Grössen in PAPIER-mm (massstabsunabhängig, wie die @@ -618,7 +489,7 @@ export function AttributesPanel() { also massstabsunabhängig. Leer gelassen (0) = Standard: Mass- und Hilfslinie erben die Elementstärke, der Massstrich wird doppelt so dick gezeichnet. */} - {drawing?.geom.shape === "dimension" && + {groups.includes("dimension") && drawing?.geom.shape === "dimension" && ( [ ["lineWeightMm", "attr.dim.lineWeight"], @@ -657,7 +528,7 @@ export function AttributesPanel() { Nach Bauteil (erbt vom Component-Manager, Default) / eigener Wert. Eine Layout-Annotation kennt keine Füllung (nur Umriss) — Sektion entfällt komplett statt drei bedeutungslose Dropdowns zu zeigen. */} - {( + {groups.includes("fill") && ( <>
{t("attr.fill")}
@@ -838,38 +709,7 @@ export function AttributesPanel() { )} )} - - {/* ── Masse (informativ, aus der bbox) — auf einem Layout-Blatt in Papier-mm ([93]). */} - {/* Bauteile: die bbox ist der GRUNDRISS-Umriss (X/Y), keine Höhe — als - „Ausdehnung X/Y" beschriften (Nutzer-Report: Fenster zeigte „Höhe - 0.34 m" = Wanddicke). Öffnungen tragen Breite/Höhe im eigenen - Abschnitt, dort entfällt die bbox ganz. */} - {!sel.opening && ( - <> -
{t("attr.size")}
- {t(isModelElement ? "attr.extentX" : "attr.width")} - {sizeText(bboxW)} - {t(isModelElement ? "attr.extentY" : "attr.height")} - {sizeText(bboxH)} - - )}
- - {/* Element-spezifische Abschnitte (aus ObjectInfo hierher verschoben) — - nur der jeweils passende erscheint. Nutzen weiter die `objinfo-*`- - Darstellung + die Host-Handler. */} - {sel.wall && } - {sel.ceiling && } - {sel.roof && } - {(sel.wall || sel.roof) && } - {sel.opening && } - {sel.stair && } - {sel.room && } - {sel.extrudedSolid && } - {sel.column && } - {sel.detailRef && } - {sel.dimRefs && } - {sel.dimTextMoved && } ); } diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index d567cb7e..f503a8e6 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -14,8 +14,9 @@ // 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. +// [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"; @@ -32,6 +33,7 @@ import { SiteRulesSection } from "./SiteRulesSection"; import { TreeSection } from "./objectInfo/TreeSection"; import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks"; import { DimensionField, RotateField } from "./objectInfo/fields"; +import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups"; // ── Bezugspunkt-Raster ─────────────────────────────────────────────────────── // Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0). @@ -94,9 +96,11 @@ export function ObjectInfoPanel() { ); } if (sel === null) { + const groups = hasInfoGroups(null, undefined, host); return (
- {m ? :
{t("objinfo.empty")}
} + {m ? : !groups &&
{t("objinfo.empty")}
} +
); } @@ -141,8 +145,7 @@ export function ObjectInfoPanel() {
{m && } {/* Kopfzeile: Typ + editierbare Klasse (Grafik-Kategorie) + Zeichnungsebene - (VW-Muster „Klasse"/„Ebene"). Die element-spezifischen Attribut- - Abschnitte (Wand/Decke/Öffnung/Treppe/Raum) liegen im Attribute-Panel. */} + (VW-Muster „Klasse"/„Ebene"). */}
{t(`objinfo.kind.${sel.kind}`)}
@@ -370,9 +373,8 @@ export function ObjectInfoPanel() { )} )} - {/* Die element-spezifischen Abschnitte (Wand/Decke/Öffnung/Treppe/Raum) - werden jetzt im Attribute-Panel gerendert (AttributesPanel importiert - die exportierten *Section-Komponenten). */} + {/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */} +
); } diff --git a/src/panels/README.md b/src/panels/README.md index 97e588a2..16bec02d 100644 --- a/src/panels/README.md +++ b/src/panels/README.md @@ -20,7 +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]`) | +| `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`); `ObjectInfoPanel` zeigt sie als einklappbare Gruppen (`InfoGroups.tsx`, `InfoGroup.tsx`, Zustand `infoGroupState.ts`); `groups.ts` hält die Zuordnung (Attribute = nur Gestaltung, Objekt-Info = Bauteil/BIM) und das Ziel der Taste T (`[189]`) | | `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/GridSection.tsx b/src/panels/objectInfo/GridSection.tsx new file mode 100644 index 00000000..4b72a0c5 --- /dev/null +++ b/src/panels/objectInfo/GridSection.tsx @@ -0,0 +1,119 @@ +// Abschnitt „Achsraster" der Objekt-Info ([189], früher im Attribute-Panel): Blasen, Verlängerung, Achsnamen, +// 3D-Anzeige und Geschoss-Gültigkeit eines gewählten Rasters. + +import { Fragment, type ReactNode } from "react"; +import { t } from "../../i18n"; +import type { Drawing2D } from "../../model/types"; +import type { usePanelHost } from "../host"; + +type GridGeom = Extract; +type Bubble = "start" | "end" | "both"; + +const numProps = { className: "objinfo-text", style: { width: 72 }, type: "number" } as const; + +export function GridSection({ drawing, host }: { drawing: Drawing2D; host: ReturnType }) { + if (drawing.geom.shape !== "grid") return null; + const geom: GridGeom = drawing.geom; + const fmtAxis = (v: number) => (Math.round(v * 100) / 100).toString(); + const here = geom.levels?.includes(drawing.levelId) && geom.levels.length === 1; + const set = (patch: Parameters[1]) => host.onSetGridProps(drawing.id, patch); + const row = (label: string, control: ReactNode, testId?: string) => ( +
+ {label} + {control} +
+ ); + return ( + <> +
+
{t("attr.grid.section")}
+ {row( + t("attr.grid.bubbles"), + , + )} + {row( + t("attr.grid.extend"), + { + const v = Number(e.target.value); + if (Number.isFinite(v) && v >= 0) set({ extend: v }); + }} + />, + )} + {row( + t("attr.grid.bubbleMm"), + { + const v = Number(e.target.value); + if (Number.isFinite(v) && v >= 2) set({ bubbleMm: v }); + }} + />, + )} + {row( + t("attr.grid.show3d"), + set({ show3d: e.target.checked })} />, + )} + {(["a", "b"] as const).map((list) => + geom[list].map((ax, i) => ( + + {row( + t(geom.radial ? (list === "a" ? "attr.grid.ray" : "attr.grid.ring") : "attr.grid.axis", { pos: fmtAxis(ax.pos) }), + + set({ [list]: geom[list].map((x, k) => (k === i ? { ...x, label: e.target.value } : x)) })} + /> + + , + "grid-axis-row", + )} + + )), + )} + {row( + t("attr.grid.levels"), + , + )} + + ); +} diff --git a/src/panels/objectInfo/InfoGroup.tsx b/src/panels/objectInfo/InfoGroup.tsx new file mode 100644 index 00000000..f1115e27 --- /dev/null +++ b/src/panels/objectInfo/InfoGroup.tsx @@ -0,0 +1,35 @@ +// [189] Einklappbarer Abschnitt der Objekt-Info: Kopfzeile (Knopf mit Pfeil) und Inhalt. Die Abschnitts- +// Komponenten (`WallSection` …) bringen ihre eigene Kopf-Trennlinie mit; die erste blendet das CSS im Rumpf aus. + +import { useEffect, useRef, useSyncExternalStore, type ReactNode } from "react"; +import { t } from "../../i18n"; +import { INFO_GROUP_TITLE, type InfoGroupId } from "./groups"; +import { clearInfoGroupFocus, getInfoGroupState, subscribeInfoGroups, toggleInfoGroup } from "./infoGroupState"; + +export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) { + const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState); + const open = !st.collapsed.has(id); + const head = useRef(null); + useEffect(() => { + if (st.focus?.id !== id) return; + head.current?.scrollIntoView?.({ block: "nearest" }); + head.current?.focus(); + clearInfoGroupFocus(); + }, [st.focus, id]); + return ( +
+ + {open &&
{children}
} +
+ ); +} diff --git a/src/panels/objectInfo/InfoGroups.tsx b/src/panels/objectInfo/InfoGroups.tsx new file mode 100644 index 00000000..c04b85fb --- /dev/null +++ b/src/panels/objectInfo/InfoGroups.tsx @@ -0,0 +1,66 @@ +// [189] Die einklappbaren Bauteil-/BIM-Abschnitte der Objekt-Info (früher im Attribute-Panel): welche es für die +// Auswahl gibt, bestimmt `groups.ts`; hier werden sie gerendert. Gerufen von `ObjectInfoPanel`. + +import type { ReactNode } from "react"; +import type { Drawing2D } from "../../model/types"; +import type { SelectionInfo } from "../../state/selectionInfo"; +import type { usePanelHost } from "../host"; +import { SurfacePatternPlacement } from "../SurfacePatternPlacement"; +import { CeilingSection } from "./CeilingSection"; +import { GridSection } from "./GridSection"; +import { InfoGroup } from "./InfoGroup"; +import { NewComponentSection } from "./NewComponentSection"; +import { OpeningSection } from "./OpeningSections"; +import { DetailRefSection, DimRefsSection, DimTextSection } from "./RefSections"; +import { RoofSection } from "./RoofSections"; +import { RoomSection } from "./RoomSection"; +import { SectionLineSection } from "./SectionLineSection"; +import { ColumnSection, ExtrudedSolidSection } from "./SolidSections"; +import { StairSection } from "./StairSection"; +import { WallSection } from "./WallSection"; +import { infoGroups, type InfoGroupId } from "./groups"; + +type Host = ReturnType; + +function groupIds(sel: SelectionInfo | null, drawing: Drawing2D | undefined, host: Host): InfoGroupId[] { + return infoGroups({ + sel, + isGrid: drawing?.geom.shape === "grid", + sectionLine: !!host.sectionLine, + newComponentTool: host.activeTool === "wall" || host.activeTool === "ceiling", + }); +} + +/** Ob für diese Auswahl mindestens ein Abschnitt erscheint. */ +export function hasInfoGroups(sel: SelectionInfo | null, drawing: Drawing2D | undefined, host: Host): boolean { + return groupIds(sel, drawing, host).length > 0; +} + +export function InfoGroups({ sel, drawing, host }: { sel: SelectionInfo | null; drawing: Drawing2D | undefined; host: Host }) { + const body = (id: InfoGroupId): ReactNode => { + switch (id) { + case "newComponent": return ; + case "sectionLine": return host.sectionLine ? : null; + case "wall": return sel?.wall ? : null; + case "ceiling": return sel?.ceiling ? : null; + case "roof": return sel?.roof ? : null; + case "surfacePattern": return sel ? : null; + case "opening": return sel?.opening ? : null; + case "stair": return sel?.stair ? : null; + case "room": return sel?.room ? : null; + case "extrudedSolid": return sel?.extrudedSolid ? : null; + case "column": return sel?.column ? : null; + case "detailRef": return sel?.detailRef ? : null; + case "dimRefs": return sel?.dimRefs ? : null; + case "dimText": return sel ? : null; + case "grid": return drawing ? : null; + } + }; + return ( + <> + {groupIds(sel, drawing, host).map((id) => ( + {body(id)} + ))} + + ); +} diff --git a/src/panels/objectInfo/NewComponentSection.tsx b/src/panels/objectInfo/NewComponentSection.tsx new file mode 100644 index 00000000..a6b088d7 --- /dev/null +++ b/src/panels/objectInfo/NewComponentSection.tsx @@ -0,0 +1,24 @@ +// Abschnitt „Neues Bauteil" der Objekt-Info ([189], früher im Attribute-Panel): Aufbau-Typ für die nächste +// Wand bzw. Decke, solange das Wand-/Decken-Werkzeug aktiv ist. Wand und Decke teilen sich denselben Typ. + +import { t } from "../../i18n"; +import { wallTypeLabel } from "../../model/types"; +import { useStore } from "../../state/appStore"; +import { Dropdown } from "../../ui/Dropdown"; +import type { usePanelHost } from "../host"; + +export function NewComponentSection({ host }: { host: ReturnType }) { + const wallTypes = useStore((s) => s.project.wallTypes); + const components = useStore((s) => s.project.components); + return ( +
+ {t(host.activeTool === "wall" ? "tool.wallType" : "tool.ceilingType")} + host.onActiveWallTypeId(v)} + options={wallTypes.map((wt) => ({ value: wt.id, label: wallTypeLabel(wt, components), title: wt.name }))} + /> +
+ ); +} diff --git a/src/panels/objectInfo/groups.test.ts b/src/panels/objectInfo/groups.test.ts new file mode 100644 index 00000000..a77a548f --- /dev/null +++ b/src/panels/objectInfo/groups.test.ts @@ -0,0 +1,75 @@ +// [189] Zuordnung der Panels: Attribute zeigen nur Gestaltung, alles Bauteil-/BIM-Bezogene gehört in die Objekt-Info; +// Taste T öffnet für Fenster/Türen den Öffnungs-Dialog, sonst den passenden Abschnitt der Objekt-Info. + +import { describe, expect, it } from "vitest"; +import { buildComplexSampleProject } from "../../model/sampleProjectComplex"; +import { deriveSelection } from "../../state/selectionInfo"; +import { attrGroups, infoGroups, objectSettingsTarget, INFO_GROUP_TITLE, type InfoGroupId } from "./groups"; + +const p = buildComplexSampleProject(); +const ctx = { isGrid: false, sectionLine: false, newComponentTool: false }; + +describe("Panel-Zuordnung [189]", () => { + it("Wand: Gestaltung in Attribute, Typ/Aufbau/Ansichtsschraffur in der Objekt-Info", () => { + const sel = deriveSelection(p, { walls: [p.walls[0].id] }); + expect(sel?.wall).toBeTruthy(); + expect(attrGroups({ sel, openEnds: false, isDimension: false })).toEqual(["stroke", "fill"]); + expect(infoGroups({ sel, ...ctx })).toEqual(["wall", "surfacePattern"]); + }); + + it("Fenster/Tür: nur die Objekt-Info trägt den Öffnungs-Abschnitt", () => { + const sel = deriveSelection(p, { openings: [p.openings![0].id] }); + expect(infoGroups({ sel, ...ctx })).toEqual(["opening"]); + }); + + it("Decke, Raum, Treppe, Dach: je ein eigener Abschnitt der Objekt-Info", () => { + const cases: [string, Partial[1]>, InfoGroupId][] = [ + ["Decke", { ceilings: [p.ceilings?.[0].id] }, "ceiling"], + ["Raum", { rooms: [p.rooms?.[0].id] }, "room"], + ["Treppe", { stairs: [p.stairs?.[0]?.id] }, "stair"], + ["Dach", { roofs: [p.roofs?.[0]?.id] }, "roof"], + ] as never; + for (const [name, selection, group] of cases) { + const sel = deriveSelection(p, selection); + if (!sel) continue; // Beispielprojekt ohne dieses Element + expect(infoGroups({ sel, ...ctx }), name).toContain(group); + } + }); + + it("Attribute: ohne Auswahl nichts; Linienenden/Bemassung nur wo sie gelten", () => { + expect(attrGroups({ sel: null, openEnds: true, isDimension: true })).toEqual([]); + const sel = deriveSelection(p, { walls: [p.walls[0].id] }); + expect(attrGroups({ sel, openEnds: true, isDimension: false })).toEqual(["stroke", "ends", "fill"]); + expect(attrGroups({ sel, openEnds: false, isDimension: true })).toEqual(["stroke", "dimension", "fill"]); + }); + + it("Werkzeug-Voreinstellung und Schnittlinie stehen ohne Auswahl in der Objekt-Info", () => { + expect(infoGroups({ sel: null, isGrid: false, sectionLine: false, newComponentTool: true })).toEqual(["newComponent"]); + expect(infoGroups({ sel: null, isGrid: false, sectionLine: true, newComponentTool: false })).toEqual(["sectionLine"]); + expect(infoGroups({ sel: null, ...ctx })).toEqual([]); + }); + + it("jede Gruppe hat einen Titel", () => { + const all: InfoGroupId[] = ["newComponent", "sectionLine", "wall", "ceiling", "roof", "surfacePattern", "opening", "stair", "room", "extrudedSolid", "column", "detailRef", "dimRefs", "dimText", "grid"]; + for (const g of all) expect(INFO_GROUP_TITLE[g]).toBeTruthy(); + }); +}); + +describe("Taste T: Ziel [189]", () => { + it("Fenster/Tür öffnet den Öffnungs-Dialog", () => { + const sel = deriveSelection(p, { openings: [p.openings![0].id] }); + expect(objectSettingsTarget(sel, "select")).toEqual({ kind: "opening", id: p.openings![0].id }); + }); + + it("Wand öffnet den Wand-Abschnitt der Objekt-Info", () => { + const sel = deriveSelection(p, { walls: [p.walls[0].id] }); + expect(objectSettingsTarget(sel, "select")).toEqual({ kind: "info", group: "wall" }); + }); + + it("ohne Auswahl: Wand-/Decken-Werkzeug → Typ des neuen Bauteils, sonst nichts", () => { + expect(objectSettingsTarget(null, "wall")).toEqual({ kind: "info", group: "newComponent" }); + expect(objectSettingsTarget(null, "ceiling")).toEqual({ kind: "info", group: "newComponent" }); + expect(objectSettingsTarget(null, "select")).toBeNull(); + expect(objectSettingsTarget(null, "line")).toBeNull(); + }); +}); diff --git a/src/panels/objectInfo/groups.ts b/src/panels/objectInfo/groups.ts new file mode 100644 index 00000000..55787da4 --- /dev/null +++ b/src/panels/objectInfo/groups.ts @@ -0,0 +1,115 @@ +// [189] Zuordnung der Panels: welche Abschnitte zeigt „Attribute" (nur Gestaltung: Stift, Linienenden, +// Bemassungs-Darstellung, Füllung) und welche die Objekt-Info (alles Bauteil-/BIM-bezogene: Typ, Aufbau, Masse, +// Raumdaten, Dach-/Treppen-Parameter, Verweise, Achsraster …). Rein, ohne React — der Test +// `groups.test.ts` hält die Aufteilung fest, `ObjectInfoPanel` und `AttributesPanel` richten sich danach. + +import type { TranslationKey } from "../../i18n"; +import type { SelectionInfo } from "../../state/selectionInfo"; + +/** Einklappbare Abschnitte der Objekt-Info (Reihenfolge = Anzeige). */ +export type InfoGroupId = + | "newComponent" + | "sectionLine" + | "wall" + | "ceiling" + | "roof" + | "surfacePattern" + | "opening" + | "stair" + | "room" + | "extrudedSolid" + | "column" + | "detailRef" + | "dimRefs" + | "dimText" + | "grid"; + +export const INFO_GROUP_TITLE: Record = { + newComponent: "attr.newComponent", + sectionLine: "objinfo.sectionLine.section", + wall: "objinfo.wall.section", + ceiling: "objinfo.ceiling.section", + roof: "objinfo.roof.section", + surfacePattern: "objinfo.surfacePattern", + opening: "objinfo.opening.section", + stair: "objinfo.stair.section", + room: "objinfo.room.section", + extrudedSolid: "objinfo.extrudedSolid.section", + column: "objinfo.column.section", + detailRef: "objinfo.detailRef.section", + dimRefs: "objinfo.dimRefs.section", + dimText: "objinfo.dimText.section", + grid: "attr.grid.section", +}; + +export interface InfoGroupContext { + sel: SelectionInfo | null; + /** Gewählte 2D-Form ist ein Achsraster. */ + isGrid: boolean; + /** Eine Schnitt-/Ansichtslinie ist gewählt (kein Projekt-Bauteil, daher nicht in `sel`). */ + sectionLine: boolean; + /** Wand- oder Decken-Werkzeug aktiv: Typ für das NEUE Bauteil wählen. */ + newComponentTool: boolean; +} + +/** Abschnitte der Objekt-Info für die aktuelle Auswahl, in Anzeige-Reihenfolge. */ +export function infoGroups(c: InfoGroupContext): InfoGroupId[] { + const out: InfoGroupId[] = []; + const { sel } = c; + if (c.newComponentTool) out.push("newComponent"); + if (!sel) { + if (c.sectionLine) out.push("sectionLine"); + return out; + } + if (sel.wall) out.push("wall"); + if (sel.ceiling) out.push("ceiling"); + if (sel.roof) out.push("roof"); + if (sel.wall || sel.roof) out.push("surfacePattern"); + if (sel.opening) out.push("opening"); + if (sel.stair) out.push("stair"); + if (sel.room) out.push("room"); + if (sel.extrudedSolid) out.push("extrudedSolid"); + if (sel.column) out.push("column"); + if (sel.detailRef) out.push("detailRef"); + if (sel.dimRefs) out.push("dimRefs"); + if (sel.dimTextMoved) out.push("dimText"); + if (c.isGrid) out.push("grid"); + return out; +} + +/** Abschnitte des Attribute-Panels: nur Gestaltung. */ +export type AttrGroupId = "stroke" | "ends" | "dimension" | "fill"; + +export interface AttrGroupContext { + sel: SelectionInfo | null; + /** Offene 2D-Form (oder Text mit Hinweislinie): trägt Linienenden. */ + openEnds: boolean; + /** Gewählte 2D-Form ist eine Masskette. */ + isDimension: boolean; +} + +export function attrGroups(c: AttrGroupContext): AttrGroupId[] { + if (!c.sel) return []; + const out: AttrGroupId[] = ["stroke"]; + if (c.openEnds) out.push("ends"); + if (c.isDimension) out.push("dimension"); + out.push("fill"); + return out; +} + +/** + * Ziel der Taste T ([189], wie Archicad Cmd+T): Fenster/Tür → Öffnungs-Dialog; sonst der Abschnitt der + * Objekt-Info (fokussiert und aufgeklappt, `group: null` = nur das Panel); ohne Auswahl die Voreinstellung des + * aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst nichts. + */ +export type ObjectSettingsTarget = + | { kind: "opening"; id: string } + | { kind: "info"; group: InfoGroupId | null } + | null; + +export function objectSettingsTarget(sel: SelectionInfo | null, activeTool: string, isGrid = false): ObjectSettingsTarget { + if (!sel) return activeTool === "wall" || activeTool === "ceiling" ? { kind: "info", group: "newComponent" } : null; + if (sel.opening) return { kind: "opening", id: sel.id }; + const first = infoGroups({ sel, isGrid, sectionLine: false, newComponentTool: false })[0]; + return { kind: "info", group: first ?? null }; +} diff --git a/src/panels/objectInfo/infoGroupState.ts b/src/panels/objectInfo/infoGroupState.ts new file mode 100644 index 00000000..d27a7ae1 --- /dev/null +++ b/src/panels/objectInfo/infoGroupState.ts @@ -0,0 +1,73 @@ +// [189] Zustand der einklappbaren Abschnitte der Objekt-Info: welche Abschnitte zugeklappt sind (je Viewer in +// localStorage) und die Anfrage „diesen Abschnitt aufklappen und fokussieren" (Taste T). Ausserhalb von React +// lesbar, damit der Tastendruck (`state/objectSettings.ts`) den Abschnitt auch öffnen kann, bevor das Panel +// montiert ist. + +import type { InfoGroupId } from "./groups"; + +interface GroupState { + collapsed: ReadonlySet; + /** Offene Fokus-Anfrage; die Gruppe löscht sie, sobald sie fokussiert hat. */ + focus: { id: InfoGroupId } | null; +} + +const KEY = "dossier.objinfo.collapsed"; + +function load(): ReadonlySet { + try { + const raw = window.localStorage.getItem(KEY); + const arr: unknown = raw ? JSON.parse(raw) : []; + return new Set(Array.isArray(arr) ? arr.filter((x): x is string => typeof x === "string") : []); + } catch { + return new Set(); + } +} + +function save(c: ReadonlySet): void { + try { + window.localStorage.setItem(KEY, JSON.stringify([...c])); + } catch { + // Bestes Bemühen (Quota/privates Fenster). + } +} + +let state: GroupState = { collapsed: load(), focus: null }; +const listeners = new Set<() => void>(); + +function set(next: GroupState): void { + state = next; + for (const l of [...listeners]) l(); +} + +export function subscribeInfoGroups(l: () => void): () => void { + listeners.add(l); + return () => listeners.delete(l); +} + +export function getInfoGroupState(): GroupState { + return state; +} + +export function toggleInfoGroup(id: InfoGroupId): void { + const c = new Set(state.collapsed); + if (!c.delete(id)) c.add(id); + save(c); + set({ ...state, collapsed: c }); +} + +/** Klappt den Abschnitt auf und bittet ihn, den Fokus zu nehmen (sobald er sichtbar ist). */ +export function expandAndFocusInfoGroup(id: InfoGroupId): void { + const c = new Set(state.collapsed); + c.delete(id); + save(c); + set({ collapsed: c, focus: { id } }); +} + +export function clearInfoGroupFocus(): void { + if (state.focus) set({ ...state, focus: null }); +} + +/** Nur für Tests. */ +export function resetInfoGroupsForTest(): void { + state = { collapsed: new Set(), focus: null }; +} diff --git a/src/state/README.md b/src/state/README.md index 41b44e4b..9d8bcedd 100644 --- a/src/state/README.md +++ b/src/state/README.md @@ -48,6 +48,7 @@ in `ProjectSync`. | `useDormerNotice.ts` | Gauben-Hinweis (in `ProjectSync`, abonniert nur Dächer und Projekt-Id) | | `useMouseSelectionHandlers.ts` | Auswahl und Kontextmenü aus Grundriss und 3D | | `useKeyboardShortcuts.ts`, `keyboardShortcuts.ts`, `commandKeys.ts` | Tastenkürzel, Esc/Enter laufender Befehle | +| `objectSettings.ts` | Taste T / Menü „Objekteinstellungen…" ([189]): Öffnungs-Dialog oder Abschnitt der Objekt-Info | | `useDisplayResolvers.ts` | sichtbar, gedimmt, gesperrt je Ebene und Kategorie | | `useTextTarget.ts`, `useSectionLineState.ts`, `useStatusBarInfo.ts` | Text-Ziel der Formatierleiste; Schnittlinie, 3D-Live-Schnitt; Status-Leiste (je mit schmalen Selektoren) | | `usePanelHostBase.ts`, `panelHost/` | Host-Wert für die Panels: Zusammenbau aus Teil-Bauern je Bereich (`toolsHost`, `selectionStyleHost`, `elementAttributesHost`, `siteHost`, `viewSnapshotsHost` + `viewState`, `layoutsHost`); `stableHost.ts` hält die Identität fest (Handler als Trampoline), solange sich kein Wert-Feld ändert. Projekt und Objekt-Info kommen beim Bau aus dem Store; die Fassung hinter den Trampolinen wird bei geändertem Projekt/Auswahl erst beim Aufruf neu gebaut | diff --git a/src/state/keyboardShortcuts.ts b/src/state/keyboardShortcuts.ts index 30f9d4fa..cc8745e7 100644 --- a/src/state/keyboardShortcuts.ts +++ b/src/state/keyboardShortcuts.ts @@ -52,7 +52,8 @@ export type ShortcutId = | "floorDown" | "floorUp" | "showSelection3d" - | "hideSelection3d"; + | "hideSelection3d" + | "objectSettings"; export type ShortcutCategory = | "general" @@ -214,6 +215,8 @@ export const SHORTCUT_DEFS: ShortcutDef[] = [ { id: "floorUp", category: "navigation", labelKey: "shortcut.floorUp", defaultCombo: "mod+6" }, { id: "showSelection3d", category: "navigation", labelKey: "shortcut.showSelection3d", defaultCombo: "mod+3" }, { id: "hideSelection3d", category: "navigation", labelKey: "shortcut.hideSelection3d", defaultCombo: "mod+4" }, + // [189] Einstellungsdialog des gewählten Objekts (Archicad Cmd+T), hier schlicht „t". + { id: "objectSettings", category: "edit", labelKey: "shortcut.objectSettings", defaultCombo: "t", bareKeyOnly: true }, ]; const DEFS_BY_ID = new Map(SHORTCUT_DEFS.map((d) => [d.id, d])); diff --git a/src/state/objectSettings.ts b/src/state/objectSettings.ts new file mode 100644 index 00000000..ecb2914f --- /dev/null +++ b/src/state/objectSettings.ts @@ -0,0 +1,41 @@ +// [189] Taste T (wie Archicad Cmd+T): Einstellungen des gewählten Objekts öffnen. Fenster/Tür → der Öffnungs- +// Dialog; alles andere → die Objekt-Info (Panel zeigen, passenden Abschnitt aufklappen und fokussieren); +// ohne Auswahl die Voreinstellung des aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst nichts. +// Die Zuordnung Auswahl → Ziel ist rein (`panels/objectInfo/groups.ts::objectSettingsTarget`). + +import { objectSettingsTarget } from "../panels/objectInfo/groups"; +import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState"; +import { getState } from "./appStore"; +import { selectionInfoFor } from "./useSelectionInfo"; + +export interface ObjectSettingsDeps { + /** Aktives Werkzeug (React-State der App). */ + activeTool: string; + openOpeningEditor: (openingId: string) => void; + /** Objekt-Info-Panel sichtbar machen (Dock-Tab, schwebendes Fenster …). */ + revealObjectInfo: () => void; +} + +/** Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. */ +export function openObjectSettings(deps: ObjectSettingsDeps): boolean { + const { project, selection } = getState(); + const sel = selectionInfoFor(project, selection); + let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined)); + // Baum, Lage-Darstellung und Schnittlinie sind keine `SelectionInfo`, haben aber ihre Felder in der Objekt-Info. + if (!target && (selection.trees.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) { + target = { kind: "info", group: selection.sectionLines.length > 0 ? "sectionLine" : null }; + } + if (!target) return false; + if (target.kind === "opening") { + deps.openOpeningEditor(target.id); + return true; + } + if (target.group) expandAndFocusInfoGroup(target.group); + deps.revealObjectInfo(); + return true; +} + +function isGridDrawing(id: string | undefined): boolean { + if (!id) return false; + return getState().project.drawings2d.find((d) => d.id === id)?.geom.shape === "grid"; +} diff --git a/src/state/useKeyboardShortcuts.ts b/src/state/useKeyboardShortcuts.ts index f379ad1a..a1a8f7cc 100644 --- a/src/state/useKeyboardShortcuts.ts +++ b/src/state/useKeyboardShortcuts.ts @@ -672,3 +672,30 @@ export function useViewNavigationShortcuts(overrides: ShortcutOverrides): void { return () => window.removeEventListener("keydown", onKey); }, [overrides]); } + +/** + * [189] Taste T (rebindbar, `objectSettings`): Einstellungen des gewählten Objekts öffnen (`state/objectSettings.ts`). + * Nicht in Textfeldern/Auswahllisten und nicht, wenn ein laufender Befehl diese Taste als Option-Kürzel belegt. + * `run` liefert `true`, wenn es etwas zu öffnen gab (dann wird die Taste verbraucht). + */ +export function useObjectSettingsShortcut( + overrides: ShortcutOverrides, + engineRef: RefObject, + run: () => boolean, +): void { + const runRef = useRef(run); + runRef.current = run; + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (e.defaultPrevented || isEditableTarget(e) || (e.target as HTMLElement | null)?.tagName === "SELECT") return; + if (!matchesShortcut(e, "objectSettings", overrides)) return; + // Ein laufender Befehl behält seine Option-Kürzel (U/I/O/P …); sonst gilt T auch mitten im Zeichnen. + const eng = engineRef.current; + const k = e.key.toLowerCase(); + if (eng?.isActive() && eng.view().options.some((o) => o.key?.toLowerCase() === k)) return; + if (runRef.current()) e.preventDefault(); + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [overrides, engineRef]); +} diff --git a/src/state/useNativeMenu.ts b/src/state/useNativeMenu.ts index a612be2e..beece89c 100644 --- a/src/state/useNativeMenu.ts +++ b/src/state/useNativeMenu.ts @@ -52,6 +52,8 @@ export function useNativeMenu(opts: { openSettings: () => void; openLayerSettings: (code: string, x: number, y: number) => void; activeCategoryCode: string; + /** [189] Objekteinstellungen (Taste T): Öffnungs-Dialog bzw. Objekt-Info. */ + onObjectSettings: () => boolean; }) { const { notify, @@ -154,6 +156,7 @@ export function useNativeMenu(opts: { onMove: () => onRunCommand("move"), onMirror: () => onRunCommand("mirror"), onRotate: () => onRunCommand("rotate"), + onObjectSettings: () => void opts.onObjectSettings(), onViewType: setViewType, onView3d: setView3d, onReferenceLines: setReferenceLines, diff --git a/src/styles.css b/src/styles.css index 32f53cf0..41eac3ff 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5187,7 +5187,8 @@ body { `.attr-panel` — denselben sauberen Look wie das obere Attribut-Grid: Sektion- Balken, Zeilentrenner, einheitliche Label-Spalte, linksbündig füllende Felder. Das eigenständige ObjectInfo-Panel (Bezugspunkt/Masse) bleibt unberührt. */ -.attr-panel .objinfo-section-label { +.attr-panel .objinfo-section-label, +.objinfo-group-body .objinfo-section-label { color: var(--label); font-weight: 700; text-transform: uppercase; @@ -5199,18 +5200,21 @@ body { border-radius: 3px; } /* Sektion-Balken trennen bereits → die dünnen Extra-Striche entfallen. */ -.attr-panel .objinfo-sep { +.attr-panel .objinfo-sep, +.objinfo-group-body .objinfo-sep { display: none; } /* Zeile: Label-Spalte | Wert/Control, mit dezentem Zeilentrenner (wie .attr-*). */ -.attr-panel .objinfo-field { +.attr-panel .objinfo-field, +.objinfo-group-body .objinfo-field { display: flex; align-items: center; gap: 6px; padding: 2px 2px 2px 2px; border-bottom: 1px solid var(--line); } -.attr-panel .objinfo-flabel { +.attr-panel .objinfo-flabel, +.objinfo-group-body .objinfo-flabel { flex: 0 0 104px; width: 104px; white-space: nowrap; @@ -5220,25 +5224,67 @@ body { color: var(--label); } /* Werte/Controls füllen die Zelle linksbündig (statt rechtsbündig). */ -.attr-panel .objinfo-fval { +.attr-panel .objinfo-fval, +.objinfo-group-body .objinfo-fval { flex: 1 1 auto; text-align: left; } -.attr-panel .objinfo-input { +.attr-panel .objinfo-input, +.objinfo-group-body .objinfo-input { text-align: left; } -.attr-panel .objinfo-field .tb-dd-trigger { +.attr-panel .objinfo-field .tb-dd-trigger, +.objinfo-group-body .objinfo-field .tb-dd-trigger { flex: 1 1 auto; min-width: 0; justify-content: space-between; } /* Segment-Umschalter + verschachtelte Felder füllen ebenfalls die Wert-Spalte. */ .attr-panel .objinfo-segment, -.attr-panel .objinfo-subfield { +.objinfo-group-body .objinfo-segment, +.attr-panel .objinfo-subfield, +.objinfo-group-body .objinfo-subfield { flex: 1 1 auto; min-width: 0; } +/* [189] Einklappbare Gruppen der Objekt-Info: Kopfzeile als Knopf; Trennlinie und Titel, die jede + Abschnitts-Komponente selbst mitbringt, entfallen im Rumpf der Gruppe (der Kopf ersetzt sie). */ +.objinfo-group { + margin-top: 4px; +} +.objinfo-group-head { + display: flex; + align-items: center; + gap: 6px; + width: 100%; + margin: 0; + padding: 3px 6px; + border: 0; + border-radius: 3px; + background: var(--panel-2); + color: var(--label); + font: inherit; + font-weight: 700; + font-size: 10px; + letter-spacing: 0.05em; + text-transform: uppercase; + text-align: left; + cursor: pointer; +} +.objinfo-group-head:hover { + background: var(--accent-dim); +} +.objinfo-group-chev { + flex: 0 0 auto; + width: 10px; + color: var(--muted); +} +.objinfo-group-body > .objinfo-sep:first-child, +.objinfo-group-body > .objinfo-sep:first-child + .objinfo-section-label { + display: none; +} + /* ── Wand-Abschnitt (Object-Info) ─────────────────────────────────────── */ /* Referenzlinie-Dropdown rechts oben im Kopf. */ .objinfo-head-ref {