Merge [218] Raumstempel im Objekteinstellungsfenster, Schrift wählbar

This commit is contained in:
Claude committed 2026-11-12 21:14:57 +00:00
commit 9a51dd7b71
49 files changed
+1073 -763

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
// [218] Doppelklick auf einen Raumstempel öffnet die Objekteinstellungen mit fokussiertem Abschnitt „Raumstempel"
// (Taste T dagegen mit dem ersten Abschnitt der Auswahl).
import { beforeEach, describe, expect, it } from "vitest";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { getInfoGroupState, resetInfoGroupsForTest } from "../panels/objectInfo/infoGroupState";
import { getSettingsArea } from "../panels/objectSettings/areaState";
import { getState, setState } from "./appStore";
import { openObjectSettings } from "./objectSettings";
import { EMPTY_SELECTION } from "./selection";
describe("openObjectSettings [218]", () => {
let revealed: (string | null)[] = [];
const deps = { activeTool: "select", revealObjectSettings: (g: string | null) => void revealed.push(g) };
beforeEach(() => {
revealed = [];
resetInfoGroupsForTest();
getState().loadProject(buildComplexSampleProject());
});
it("Raum gewählt: T zeigt den Abschnitt „Raum“, der Doppelklick auf den Stempel „Raumstempel“", () => {
setState({ selection: { ...EMPTY_SELECTION, rooms: [getState().project.rooms![0].id] } });
expect(openObjectSettings(deps)).toBe(true);
expect(revealed).toEqual(["room"]);
expect(openObjectSettings(deps, "roomStamp")).toBe(true);
expect(revealed).toEqual(["room", "roomStamp"]);
expect(getInfoGroupState().focus?.id).toBe("roomStamp");
expect(getSettingsArea()).toBe("object");
});
it("ein Abschnitt, den die Auswahl nicht hat, wird nicht erzwungen", () => {
setState({ selection: { ...EMPTY_SELECTION, walls: [getState().project.walls[0].id] } });
openObjectSettings(deps, "roomStamp");
expect(revealed).toEqual(["wall"]);
});
});
+7 -3
View File
@@ -4,7 +4,7 @@
// und fokussiert; ohne Auswahl die Voreinstellung des aktiven Werkzeugs (Wand/Decke: Typ des neuen Bauteils), sonst
// nichts. Die Zuordnung Auswahl → Abschnitt ist rein (`panels/objectInfo/groups.ts::objectSettingsTarget`).
import { objectSettingsTarget, type InfoGroupId } from "../panels/objectInfo/groups";
import { infoGroups, objectSettingsTarget, type InfoGroupId } from "../panels/objectInfo/groups";
import { setSettingsArea } from "../panels/objectSettings/areaState";
import { expandAndFocusInfoGroup } from "../panels/objectInfo/infoGroupState";
import { getState } from "./appStore";
@@ -17,8 +17,11 @@ export interface ObjectSettingsDeps {
revealObjectSettings: (group: InfoGroupId | null) => void;
}
/** Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. */
export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
/**
* Öffnet die Einstellungen; `false`, wenn es nichts zu öffnen gibt. `group` wählt den Abschnitt (statt des ersten der
* Auswahl), z. B. „roomStamp" beim Doppelklick auf einen Raumstempel ([218]); er muss zur Auswahl gehören.
*/
export function openObjectSettings(deps: ObjectSettingsDeps, group?: InfoGroupId): boolean {
const { project, selection } = getState();
const sel = selectionInfoFor(project, selection);
let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined));
@@ -27,6 +30,7 @@ export function openObjectSettings(deps: ObjectSettingsDeps): boolean {
target = { group: selection.sectionLines.length > 0 ? "sectionLine" : null };
}
if (!target) return false;
if (group && sel && infoGroups({ sel, isGrid: false, sectionLine: false, newComponentTool: false }).includes(group)) target = { group };
setSettingsArea("object");
if (target.group) expandAndFocusInfoGroup(target.group);
deps.revealObjectSettings(target.group);
+1 -2
View File
@@ -45,7 +45,7 @@ function targetIds(collection: MultiCollection, id: string): string[] {
const ROOF_OWN_KEYS: ReadonlySet<string> = new Set(["outline", "holes", "outlineBulge", "holesBulge", "edgePitchDeg", "dormers"]);
export function buildElementAttributesHost(c: FlatHostOpts) {
const { applyChange, onOpenStampEditor, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
const { applyChange, onToggleSection3dCut, openResources, patchLevel, project, section3dCutId, sectionLine, selection, patchDoorType, patchWindowType, saveOpeningStyle, setCeilingThickness, setWallThickness, slideOpening, updateCeiling, updateOpening, updateRoof, updateRoom, updateStair, updateWall } = c;
/** Wie {@link patchAll}, aber mit Änderungsfunktion je Element (z. B. Stützen-Profil). */
function mapAll<K extends MultiCollection>(collection: K, id: string, fn: (e: EntityOf<(typeof PROJECT_LIST)[K]>) => EntityOf<(typeof PROJECT_LIST)[K]>, coalesceKey?: string): void {
const ids = targetIds(collection, id);
@@ -308,7 +308,6 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
onSetRoomSia: (category) => {
if (selection?.kind === "room") patchAll("rooms", selection.id, { siaCategory: category });
},
onEditRoomStamp: (roomId) => onOpenStampEditor(roomId),
// ── Extrusions-Attribute (truck-Integration; nur bei selektiertem Körper) ──
onSetExtrudedSolidHeight: (height) => {
if (selection?.kind !== "extrudedSolid" || !(height > 0)) return;
-1
View File
@@ -48,7 +48,6 @@ export type PanelHostOpts = {
onToggleSection3dCut: (id: string) => void;
openLayerSettings: (code: string, x: number, y: number) => void;
openSettings: () => void;
onOpenStampEditor: (roomId: string) => void;
openResources: (tab?: ResourceTabId) => void;
dxfInputRef: RefObject<HTMLInputElement | null>;
planViewRef: RefObject<PlanViewHandle | null>;
-8
View File
@@ -499,11 +499,6 @@ export interface ProjectSlice {
roomId: string,
doc: import("../model/types").RichTextDoc,
) => void;
/** Setzt den strukturierten Raum-Stempel (Feldmodell). */
setRoomStamp: (
roomId: string,
stamp: import("../model/types").RoomStamp,
) => void;
}
/**
@@ -1415,9 +1410,6 @@ export function createProjectSlice(
setRoomStampDoc: (roomId, doc) =>
applyChange((p) => mapRoom(p, roomId, (r) => ({ ...r, stampDoc: doc }))),
setRoomStamp: (roomId, stamp) =>
applyChange((p) => mapRoom(p, roomId, (r) => ({ ...r, stamp }))),
};
}
+17
View File
@@ -0,0 +1,17 @@
// [218] Raumstempel mehrerer Räume in EINEM Undo-Schritt ändern (Abschnitt „Raumstempel" der Objekteinstellungen).
// Fehlt einem Raum der Stempel, beginnt die Änderung beim Standard-Stempel des Raums. Gleicher `key` (Tippen,
// Regler) fasst aufeinanderfolgende Änderungen zu einem Schritt zusammen.
import { patchItems } from "../core";
import { defaultRoomStamp } from "../model/roomStamp";
import type { Project, Room, RoomStamp } from "../model/types";
import { getState } from "./appStore";
export function editRoomStamps(ids: readonly string[], fn: (stamp: RoomStamp) => RoomStamp, key: string): void {
getState().applyChange((p: Project) => patchItems(p, "rooms", [...ids], (r) => ({ ...r, stamp: fn(r.stamp ?? defaultRoomStamp(r)) }) as Room), key);
}
/** Räume, die eine Änderung trifft: bei Mehrfachauswahl alle gewählten (wenn `roomId` dazugehört), sonst nur `roomId`. */
export function stampTargetIds(selected: readonly string[], roomId: string): string[] {
return selected.length > 1 && selected.includes(roomId) ? [...selected] : [roomId];
}
+21
View File
@@ -79,6 +79,10 @@ declare global {
stairHole: (stairId: string, ceilingId: string) => { start: { x: number; y: number }; center: { x: number; y: number } | null; hole0: { x: number; y: number } | null; lines: number };
/** [203] Grundriss der aktiven Ebene wie in der Ansicht (Geschoss-Überlagerung nach Zeichnungsebenen-Modus): Raumstempel je Geschoss (gesamt/gedimmt) und Zahl der Achs-Beschriftungen `axis`. */
planStamps: (axis: string) => { floors: Record<string, { n: number; greyed: number }>; axis: number };
/** [218] Stempel des Raums `roomId` im Grundriss der aktiven Ebene (wie angezeigt): Lage, Schrift der Namenszeile und Zusatzzeilen; `null` ohne Stempel. */
roomStamp: (roomId: string) => { at: { x: number; y: number }; basePt: number; name: { sizePt?: number; font?: string; bold?: boolean }; extra: { text: string; marks?: { sizePt?: number; font?: string; italic?: boolean } }[] } | null;
/** [218] Räume der aktiven Ebene mit Mittelpunkt des Umrisses (Modell-m). */
roomCenters: () => { id: string; name: string; x: number; y: number }[];
/** [205] Pausfolie des Reiters (Store) und ihr Plan für die aktive Ebene: Zahl der Primitive, Linienfarben, Zahl mit Auswahl-Ids, Ausmass. */
trace: () => { trace: unknown; n: number; colors: string[]; withIds: number; bounds: { minX: number; minY: number; maxX: number; maxY: number } | null; probe: { x: number; y: number } | null };
};
@@ -229,6 +233,23 @@ export function installTestHooks(): void {
}
return { floors, axis: n };
},
roomStamp: (roomId) => {
const s = getState();
const p = s.project;
const mode = s.displayModes[BUILTIN_PANEL_IDS.drawingLevels] ?? "all";
const display = (id: string) => itemDisplay(mode, id === s.activeLevelId, p.drawingLevels.find((l) => l.id === id)?.visible ?? false);
const plan = materializeGreyed(materializeUnderlay(generateVisibleLevelsPlan(p, s.activeLevelId, collectVisibleCodes(p.layers), undefined, s.detail, false, false, display, s.scaleDenominator)), true);
for (const q of plan.primitives) {
if (q.kind !== "text" || q.roomId !== roomId) continue;
const m = q.doc.paragraphs[0]?.runs[0]?.marks ?? {};
return { at: q.at, basePt: q.basePt, name: { sizePt: m.sizePt, font: m.font, bold: m.bold }, extra: (q.extraLines ?? []).map((l) => ({ text: l.text, marks: l.marks })) };
}
return null;
},
roomCenters: () => {
const s = getState();
return (s.project.rooms ?? []).filter((r) => r.floorId === s.activeLevelId && r.boundary.length >= 3).map((r) => ({ id: r.id, name: r.name, x: r.boundary.reduce((a, v) => a + v.x, 0) / r.boundary.length, y: r.boundary.reduce((a, v) => a + v.y, 0) / r.boundary.length }));
},
trace: () => {
const s = getState();
const level = s.project.drawingLevels.find((l) => l.id === s.activeLevelId);
+8 -6
View File
@@ -58,22 +58,24 @@ export function useMouseSelectionHandlers(opts: {
selectionState: Pick<ReturnType<typeof useSelectionState>, "selection" | "setSelection" | "groupPath">;
contextMenuState: Pick<
ReturnType<typeof useContextMenuState>,
"setMenu" | "setStampEditorRoomId" | "editTextId" | "setEditTextId" | "setEditTextMinHeightM"
"setMenu" | "editTextId" | "setEditTextId" | "setEditTextMinHeightM"
>;
/** [218] Fenster Objekteinstellungen mit dem Abschnitt „Raumstempel" öffnen (Doppelklick auf einen Stempel). */
openRoomStampSettings: () => void;
}) {
// [121] Das Projekt liest jeder Handler beim Aufruf aus dem Store (App abonniert es nicht mehr).
const { setProject, activeLevelId, visibleCodes, categoryDisplay, floorDisplay, selectionState, contextMenuState } = opts;
const { selection, setSelection, groupPath } = selectionState;
const { setMenu, setStampEditorRoomId, editTextId, setEditTextId, setEditTextMinHeightM } = contextMenuState;
const { setMenu, editTextId, setEditTextId, setEditTextMinHeightM } = contextMenuState;
// ── Maus-Schema: Auswahl + Kontextmenü aus Grundriss / 3D ─────────────────
// Links-Klick im Grundriss: genau eine Wand wählen (Menge ersetzen) bzw.
// Leerraum → Auswahl löschen.
// Doppelklick auf einen Raum-Stempel: den Raum wählen + den Stempel-Editor
// öffnen (Rich-Text-Popup).
// Doppelklick auf einen Raum-Stempel: den Raum wählen + die Objekteinstellungen mit dem Abschnitt „Raumstempel"
// öffnen ([218], kein Dialog im Fenster mehr). Gehört der Raum schon zur Auswahl, bleibt sie (Mehrfachwerte).
const onOpenStampEditor = (roomId: string) => {
setSelection({ ...clearKinds(), rooms: [roomId] });
setStampEditorRoomId(roomId);
if (!getState().selection.rooms.includes(roomId)) setSelection({ ...clearKinds(), rooms: [roomId] });
opts.openRoomStampSettings();
};
// Doppelklick auf ein Text-2D-Element: selektieren + Inhalts-Editor öffnen.
const onEditDrawingText = (drawingId: string) => {
-2
View File
@@ -398,7 +398,6 @@ export function useProjectActions(
const moveRoomEdge = useStore((s) => s.moveRoomEdge);
const moveRoomStamp = useStore((s) => s.moveRoomStamp);
const setRoomStampDoc = useStore((s) => s.setRoomStampDoc);
const setRoomStamp = useStore((s) => s.setRoomStamp);
return {
toggleLevelVisible,
@@ -523,6 +522,5 @@ export function useProjectActions(
moveRoomEdge,
moveRoomStamp,
setRoomStampDoc,
setRoomStamp,
};
}