From 243aa19d25a6b550582c80be4fbbd04cd6c66bb4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 13:36:55 +0000 Subject: [PATCH] =?UTF-8?q?[149]=203D:=20Klick=20auf=20ein=20Gruppenmitgli?= =?UTF-8?q?ed=20w=C3=A4hlt=20die=20Gruppe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pick3dGroup (wie der Klick im Grundriss, Isolation beachtet). Test groupActions.test.ts. --- src/state/groupActions.test.ts | 17 +++++++++++++++++ src/state/groupActions.ts | 24 +++++++++++++++++++++++- src/state/useMouseSelectionHandlers.ts | 7 +++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/state/groupActions.test.ts b/src/state/groupActions.test.ts index 8893b160..dda4ce68 100644 --- a/src/state/groupActions.test.ts +++ b/src/state/groupActions.test.ts @@ -13,6 +13,7 @@ import { expandToGroups, groupSelection, isInsideActiveGroup, + pick3dGroup, transitiveMembership, ungroup, } from "./groupActions"; @@ -203,6 +204,22 @@ describe("[149] Bäume in Gruppen", () => { }); }); +describe("[149] 3D-Klick auf ein Gruppenmitglied", () => { + it("wählt die ganze Gruppe wie im Grundriss; Element ohne Gruppe bzw. ohne Gruppen-Art → null", () => { + const res = groupSelection({ ...EMPTY_MEM, wallIds: ["w1"], treeIds: ["b1"], columnIds: ["c1"] }, []); + const p = applyOps(project([]), res!.ops); + for (const [kind, id] of [["tree", "b1"], ["wall", "w1"], ["column", "c1"]] as const) { + const g = pick3dGroup(p, kind, id, []); + expect(g?.groupIds).toEqual([res!.groupId]); + expect([g!.expanded.wallIds, g!.expanded.treeIds, g!.expanded.columnIds]).toEqual([["w1"], ["b1"], ["c1"]]); + } + expect(pick3dGroup(p, "wall", "w9", [])).toBeNull(); + expect(pick3dGroup(p, "contextObject", "w1", [])).toBeNull(); + // In der Gruppe (Isolation): einzeln. + expect(pick3dGroup(p, "wall", "w1", [res!.groupId])).toBeNull(); + }); +}); + describe("applyGroupDimmingToPlan", () => { const g1: Group = { id: "g1", wallIds: [], drawingIds: ["din"], ceilingIds: [], roomIds: [], stairIds: [], columnIds: [], roofIds: [], openingIds: [], groupIds: [] }; const p = project([g1]); diff --git a/src/state/groupActions.ts b/src/state/groupActions.ts index 4e4ac5cf..a1eb544c 100644 --- a/src/state/groupActions.ts +++ b/src/state/groupActions.ts @@ -11,7 +11,7 @@ import { uniqueId } from "../tools/types"; import type { Primitive } from "../core"; import type { CoreOp } from "../core"; import { addItems, removeItems } from "../core"; -import { transitiveMembership } from "../core"; +import { EMPTY_MEMBERSHIP, expandToGroups, transitiveMembership } from "../core"; import type { GroupMembership, MemberKind } from "../core"; export type { GroupMembership, MemberKind } from "../core"; @@ -36,6 +36,28 @@ export function mergeMembership(a: GroupMembership, b: GroupMembership): GroupMe return out; } +/** 3D-Pick-Art → Gruppen-Art (Kontext-Netze, 2D-Zeichnungen im 3D und Körper sind nicht gruppierbar). */ +const PICK3D_KIND: Partial> = { + wall: "wallIds", + ceiling: "ceilingIds", + opening: "openingIds", + stair: "stairIds", + roof: "roofIds", + column: "columnIds", + tree: "treeIds", +}; + +/** + * [149] 3D-Klick auf ein Element: gehört es zu einer (im Isolations-Kontext `groupPath` sichtbaren) Gruppe, + * die erweiterte Auswahl der ganzen Gruppe (wie der Klick im Grundriss), sonst `null`. + */ +export function pick3dGroup(project: Project, kind: string, id: string, groupPath: string[]): { expanded: GroupMembership; groupIds: string[] } | null { + const k = PICK3D_KIND[kind]; + if (!k) return null; + const r = expandToGroups(project, { ...EMPTY_MEMBERSHIP, [k]: [id] }, groupPath); + return r.groupIds.length > 0 ? r : null; +} + /** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */ const TREE_PICK = "@tree:"; diff --git a/src/state/useMouseSelectionHandlers.ts b/src/state/useMouseSelectionHandlers.ts index 7891d110..6a056e67 100644 --- a/src/state/useMouseSelectionHandlers.ts +++ b/src/state/useMouseSelectionHandlers.ts @@ -24,6 +24,7 @@ import { EMPTY_MEMBERSHIP, expandToGroups, isInsideActiveGroup, + pick3dGroup, type GroupMembership, type MemberKind, } from "./groupActions"; @@ -376,6 +377,12 @@ export function useMouseSelectionHandlers(opts: { setSelection(clearKinds()); return; } + // [149] Gruppenmitglied: die ganze Gruppe wählen (wie der Klick im Grundriss). + const group = additive ? null : pick3dGroup(project, hit.kind, hit.id, groupPath); + if (group) { + setSelection({ ...clearKinds(), ...fromIdLists(group.expanded), groups: group.groupIds }); + return; + } // Öffnung (Fenster/Tür), Treppe, Kontext-Objekt, 2D-Element und Dach ersetzen // die Auswahl exklusiv; nur Wände und Decken unterstützen additive // Mehrfachauswahl (wie bisher; ein 2D-Treffer wählt auch mit Shift nur sich).