[149] 3D: Klick auf ein Gruppenmitglied wählt die Gruppe
pick3dGroup (wie der Klick im Grundriss, Isolation beachtet). Test groupActions.test.ts.
This commit is contained in:
3 files changed
+47
-1
No files matched your search
@@ -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]);
|
||||
|
||||
@@ -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<Record<string, MemberKind>> = {
|
||||
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:";
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in new issue
Block a user