Merge branch 'worktree-agent-a5d8662de762593ef' into claude/practical-noether-1hb2s1

# Conflicts:
#	TODO.md
This commit is contained in:
Claude committed 2026-11-12 00:39:39 +00:00
commit e0e9dfe214
22 files changed
+317 -75

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
// [196] Auge einer Zeichnungsebene: schaltet nur die eigene; in „Nur aktive"/„Alle anzeigen" werden die Flags vorher
// auf das eingefroren, was der Modus zeigt (sonst erschienen beim Umschalten auf „Ausgewählte" alle Geschosse).
import { beforeEach, describe, expect, it } from "vitest";
import { getState, setState } from "./appStore";
import { sampleProject } from "../model/sampleProject";
import { frozenLevelFlags, hiddenFloorIds, itemDisplay } from "../panels/displayMode";
beforeEach(() => {
setState({ project: sampleProject });
getState().clearHistory();
});
const flags = () => Object.fromEntries(getState().project.drawingLevels.map((l) => [l.id, l.visible]));
describe("Auge der Zeichnungsebenen [196]", () => {
it("frozenLevelFlags: nur in all_force/active, sonst null", () => {
const lv = getState().project.drawingLevels;
expect(frozenLevelFlags("all", lv, "eg")).toBeNull();
expect(frozenLevelFlags("grey", lv, "eg")).toBeNull();
const act = frozenLevelFlags("active", lv, "eg")!;
expect(act.eg).toBe(true);
expect(Object.entries(act).filter(([, v]) => v).map(([k]) => k)).toEqual(["eg"]);
expect(Object.values(frozenLevelFlags("all_force", lv, "eg")!).every(Boolean)).toBe(true);
});
it("Klick auf das Auge einer Ansicht in „Nur aktive“ ändert nur diese Ebene (ein Undo-Schritt)", () => {
const lv = getState().project.drawingLevels;
const view = lv.find((l) => l.kind === "elevation")!;
const frozen = frozenLevelFlags("active", lv, "eg")!;
const wasOn = frozen[view.id];
getState().toggleLevelVisible(view.id, frozen);
const after = flags();
// Geschosse nach dem eingefrorenen Modus (nur EG an), die Ansicht umgeschaltet.
for (const l of lv) expect(after[l.id]).toBe(l.id === view.id ? !wasOn : frozen[l.id]);
expect(hiddenFloorIds(getState().project.drawingLevels, (id) => itemDisplay("all", id === "eg", after[id])).sort()).toEqual(lv.filter((l) => l.kind === "floor" && l.id !== "eg").map((l) => l.id).sort());
getState().undo();
expect(flags()).toEqual(Object.fromEntries(lv.map((l) => [l.id, l.visible])));
});
it("ohne frozen: nur die eine Ebene", () => {
const before = flags();
getState().toggleLevelVisible("og");
expect(flags()).toEqual({ ...before, og: !before.og });
});
it("hiddenFloorIds: nur Geschosse mit Auge aus", () => {
const levels = [{ id: "a", kind: "floor" }, { id: "b", kind: "floor" }, { id: "s", kind: "section" }];
expect(hiddenFloorIds(levels, (id) => ({ render: id === "a" }))).toEqual(["b"]);
});
});
+7 -3
View File
@@ -119,7 +119,7 @@ export interface ProjectSlice {
openProjectFile: (text: string) => LoadFileResult;
// ── Zeichnungsebenen (Levels/Geschosse) ──────────────────────────────────
toggleLevelVisible: (id: string) => void;
toggleLevelVisible: (id: string, frozen?: Record<string, boolean>) => void;
patchActiveFloor: (patch: Partial<DrawingLevel>) => void;
addFloor: () => void;
addDrawing: () => void;
@@ -676,8 +676,12 @@ export function createProjectSlice(
},
// ── Zeichnungsebenen ───────────────────────────────────────────────────
toggleLevelVisible: (id) =>
applyChange((p) => patchItem(p, "drawingLevels", id, (z) => ({ ...z, visible: !z.visible }))),
// [196] `frozen`: Flags aller Ebenen, wie der Modus sie gerade zeigt — nur die angeklickte wird umgeschaltet.
toggleLevelVisible: (id, frozen) =>
applyChange((p) => {
const flag = (z: DrawingLevel) => frozen?.[z.id] ?? z.visible;
return patchItems(p, "drawingLevels", (z) => z.id === id || flag(z) !== z.visible, (z) => ({ ...z, visible: z.id === id ? !flag(z) : flag(z) }));
}),
patchActiveFloor: (patch) => {
const activeLevelId = get().activeLevelId;
+2 -2
View File
@@ -50,10 +50,10 @@ export function stepActiveFloor(dir: 1 | -1): void {
/**
* [185] Cmd/Ctrl+3 „Auswahl in 3D zeigen": mit Auswahl zeigt der 3D-Reiter nur diese (Titel „3D · Auswahl"), ohne
* Auswahl wieder alles; wechselt in den 3D-Reiter bzw. öffnet ihn, die Kamera passt sich ein.
* Auswahl wieder alles; wechselt in den 3D-Reiter bzw. öffnet ihn, die Kamera bleibt stehen (Einpassen nur Cmd/Ctrl+Shift+F).
*/
export function showSelectionIn3d(): void {
setView3dFilter(showSelection3d(getView3dFilter(), selectionIds3d(getState().selection)));
setView3dFilter(showSelection3d(selectionIds3d(getState().selection)));
switchViewType("perspektive");
}
+13 -3
View File
@@ -9,6 +9,8 @@ import { ceilingThickness } from "../model/types";
import { computeSection, generatePlan, verticalExtents, generateSectionPlan, pickGeometry, projectToModel3d } from "../core";
import { getViewStateBridge } from "./viewTabs";
import { getView3dFilter, toFilter3d } from "./view3dFilter";
import { BUILTIN_PANEL_IDS } from "../panels/builtinPanels";
import { hiddenFloorIds, itemDisplay } from "../panels/displayMode";
declare global {
interface Window {
@@ -59,7 +61,7 @@ declare global {
/** [195] Strichstärke-Override der Wände (id → mm), nur gesetzte. */
wallWeights: () => Record<string, number>;
/** [185] 3D-Element-Filter (Store) und die Wand-ids des 3D-Modells bzw. der Pick-Geometrie mit ihm. */
view3d: () => { only: string[] | null; hidden: string[]; walls: string[]; pickWalls: string[] };
view3d: () => { only: string[] | null; hidden: string[]; walls: string[]; pickWalls: string[]; floors: string[]; pickOpenings: { id: string; host: string }[] };
};
}
}
@@ -153,14 +155,22 @@ export function installTestHooks(): void {
},
view3d: () => {
const f = getView3dFilter();
const p = getState().project;
const hide = toFilter3d(f, []);
const s = getState();
const p = s.project;
const mode = s.displayModes[BUILTIN_PANEL_IDS.drawingLevels] ?? "all";
const hide = toFilter3d(f, [], hiddenFloorIds(p.drawingLevels, (id) => itemDisplay(mode, id === s.activeLevelId, p.drawingLevels.find((l) => l.id === id)?.visible ?? false)));
const uniq = (ids: string[]) => [...new Set(ids)].sort();
return {
only: f.only,
hidden: f.hidden,
walls: uniq(projectToModel3d(p, { hide }).walls.map((w) => w.wallId)),
pickWalls: uniq(pickGeometry(p, 0, hide).walls.map((w) => w.wallId)),
pickOpenings: (() => {
const g = pickGeometry(p, 0, hide);
const ids = uniq([...g.openings.map((o) => o.openingId), ...g.openingMeshes.map((o) => o.openingId)]);
return ids.map((id) => ({ id, host: p.openings?.find((o) => o.id === id)?.hostWallId || p.openings?.find((o) => o.id === id)?.hostRoofId || p.openings?.find((o) => o.id === id)?.hostCeilingId || "" }));
})(),
floors: uniq(projectToModel3d(p, { hide }).walls.map((w) => p.walls.find((x) => x.id === w.wallId)?.floorId ?? "")),
};
},
layerView: () => {
+8 -11
View File
@@ -24,34 +24,31 @@ describe("3D-Element-Filter [185]", () => {
expect(selectionIds3d(sel)).toEqual(["w1", "w2", "o1"]);
});
it("Cmd+3 mit Auswahl: nur diese, Ausgeblendetes vergessen, Kamera einpassen; ohne Auswahl: alles", () => {
const hidden = hideSelection3d(NO_VIEW3D_FILTER, ["x"]);
const a = showSelection3d(hidden, ["w1", "w1", "o1"]);
it("Cmd+3 mit Auswahl: nur diese, Ausgeblendetes vergessen, Kamera bleibt; ohne Auswahl: alles", () => {
const a = showSelection3d(["w1", "w1", "o1"]);
expect(a).toMatchObject({ only: ["w1", "o1"], hidden: [] });
expect(isSelectionMode(a)).toBe(true);
expect(a.fitSeq).toBe(hidden.fitSeq + 1);
const b = showSelection3d(a, []);
const b = showSelection3d([]);
expect(b).toMatchObject({ only: null, hidden: [] });
expect(isSelectionMode(b)).toBe(false);
expect(b.fitSeq).toBe(a.fitSeq + 1);
});
it("Cmd+4: blendet zusätzlich aus, im Auswahl-Modus auch; ohne ids unverändert", () => {
const a = hideSelection3d(NO_VIEW3D_FILTER, ["w1"]);
expect(a).toMatchObject({ only: null, hidden: ["w1"], fitSeq: 0 });
expect(a).toMatchObject({ only: null, hidden: ["w1"], });
expect(hideSelection3d(a, ["w1"])).toBe(a);
expect(hideSelection3d(a, [])).toBe(a);
const b = hideSelection3d(showSelection3d(a, ["w2", "w3"]), ["w3"]);
const b = hideSelection3d(showSelection3d(["w2", "w3"]), ["w3"]);
expect(b).toMatchObject({ only: ["w2", "w3"], hidden: ["w3"] });
});
it("toFilter3d: Klassen plus Element-Auswahl für den Kern", () => {
expect(toFilter3d(NO_VIEW3D_FILTER, ["31"])).toEqual({ hide: ["31"], only: null, hideIds: [] });
expect(toFilter3d(showSelection3d(NO_VIEW3D_FILTER, ["w1"]), [])).toEqual({ hide: [], only: ["w1"], hideIds: [] });
expect(toFilter3d(NO_VIEW3D_FILTER, ["31"])).toEqual({ hide: ["31"], only: null, hideIds: [], hideFloors: [] });
expect(toFilter3d(showSelection3d(["w1"]), [])).toEqual({ hide: [], only: ["w1"], hideIds: [], hideFloors: [] });
});
it("Store: setzen und beim Projektwechsel zurücksetzen", () => {
setView3dFilter(showSelection3d(NO_VIEW3D_FILTER, ["w1"]));
setView3dFilter(showSelection3d(["w1"]));
expect(isSelectionMode(getView3dFilter())).toBe(true);
resetView3dFilter();
expect(getView3dFilter()).toBe(NO_VIEW3D_FILTER);
+8 -10
View File
@@ -16,11 +16,9 @@ export interface View3dFilter {
only: string[] | null;
/** Temporär ausgeblendete Element-ids. */
hidden: string[];
/** Zählt die Anfragen „Kamera auf das Gezeigte einpassen" (der 3D-Viewport passt bei jeder Änderung ein). */
fitSeq: number;
}
export const NO_VIEW3D_FILTER: View3dFilter = Object.freeze({ only: null, hidden: [], fitSeq: 0 }) as View3dFilter;
export const NO_VIEW3D_FILTER: View3dFilter = Object.freeze({ only: null, hidden: [] }) as View3dFilter;
/** Element-Arten, die im 3D vorkommen (Räume, Schnittlinien, Lage-Darstellung und Gruppen nicht). */
const KINDS_3D: readonly SelectionKind[] = ["walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "drawings"];
@@ -36,11 +34,11 @@ export function isSelectionMode(f: View3dFilter): boolean {
}
/**
* Cmd/Ctrl+3: mit Auswahl nur diese zeigen (ausgeblendete werden vergessen), ohne Auswahl alles zeigen. Beide Male
* passt der 3D-Viewport die Kamera ein.
* Cmd/Ctrl+3: mit Auswahl nur diese zeigen (ausgeblendete werden vergessen), ohne Auswahl alles zeigen. Die Kamera
* bleibt stehen (Einpassen nur mit Cmd/Ctrl+Shift+F).
*/
export function showSelection3d(f: View3dFilter, ids: readonly string[]): View3dFilter {
return ids.length ? { only: [...new Set(ids)], hidden: [], fitSeq: f.fitSeq + 1 } : { only: null, hidden: [], fitSeq: f.fitSeq + 1 };
export function showSelection3d(ids: readonly string[]): View3dFilter {
return ids.length ? { only: [...new Set(ids)], hidden: [] } : { only: null, hidden: [] };
}
/** Cmd/Ctrl+4: die Elemente `ids` zusätzlich ausblenden (Kamera bleibt). Ohne ids unverändert. */
@@ -50,9 +48,9 @@ export function hideSelection3d(f: View3dFilter, ids: readonly string[]): View3d
return hidden.length === f.hidden.length ? f : { ...f, hidden };
}
/** Filter für die 3D-Abfragen: Klassen-Codes `hide` plus Element-Auswahl (Kern `ClassFilter::from_text`). */
export function toFilter3d(f: View3dFilter, hide: readonly string[]): Filter3d {
return { hide, only: f.only, hideIds: f.hidden };
/** Filter für die 3D-Abfragen: Klassen-Codes `hide`, Geschosse mit ausgeschaltetem Auge ([196]) plus Element-Auswahl (Kern `ClassFilter::from_text`). */
export function toFilter3d(f: View3dFilter, hide: readonly string[], hideFloors: readonly string[] = []): Filter3d {
return { hide, only: f.only, hideIds: f.hidden, hideFloors };
}
// ── Store ───────────────────────────────────────────────────────────────────