[149] Bäume: Auswahlrechteck, Gruppen, Art-Beschriftung im Plan, Schatten nicht doppelt

Bäume im Fenster/Kreuzen; Group.treeIds (Rust-Modell, optional) samt Mitgliedschaft im Kern; Feld
Tree.showLabel (Art-Name rechts neben dem Stamm, Tusche, Schrift wie die Stempel-Zusatzzeile); Kreis der
Baum-Ebene am Ort eines Baum-Objekts wirft keinen zweiten Schatten.
This commit is contained in:
Claude committed 2026-11-06 22:26:25 +00:00
1 parent aaf0092f89
commit ae10667a6f
19 files changed
+203 -11

No files matched your search

+2
View File
@@ -1808,6 +1808,8 @@ export const de = {
"objinfo.tree.section": "Baum",
"objinfo.tree.species": "Art",
"objinfo.tree.speciesHint": "z. B. Quercus robur",
"objinfo.tree.showLabel": "Beschriftung zeigen",
"objinfo.tree.showLabelHint": "Art-Name im Grundriss neben dem Stamm",
"objinfo.tree.status": "Bestand",
"objinfo.tree.status.existing": "bestehend",
"objinfo.tree.status.new": "neu",
+2
View File
@@ -1797,6 +1797,8 @@ export const en: Record<TranslationKey, string> = {
"objinfo.tree.section": "Tree",
"objinfo.tree.species": "Species",
"objinfo.tree.speciesHint": "e.g. Quercus robur",
"objinfo.tree.showLabel": "Show label",
"objinfo.tree.showLabelHint": "Species name next to the trunk in plan",
"objinfo.tree.status": "Status",
"objinfo.tree.status.existing": "existing",
"objinfo.tree.status.new": "new",
+3
View File
@@ -16,6 +16,8 @@ export interface GroupMembership {
columnIds: string[];
roofIds: string[];
openingIds: string[];
/** [149] Bäume. */
treeIds: string[];
}
export type MemberKind = keyof GroupMembership;
@@ -29,6 +31,7 @@ export const EMPTY_MEMBERSHIP: GroupMembership = {
columnIds: [],
roofIds: [],
openingIds: [],
treeIds: [],
};
/** Letzte transitive Mitgliedschaft (Projekt + Gruppe): Klick-/Rahmen-Filter fragen je Element. */
+4
View File
@@ -1399,6 +1399,8 @@ export type Group = {
columnIds: Array<string>;
roofIds: Array<string>;
openingIds: Array<string>;
/** [149] Bäume (fehlt in älteren Dateien). */
treeIds?: Array<string>;
/** Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes). */
groupIds: Array<string>;
};
@@ -3284,6 +3286,8 @@ export type Tree = {
foliage: TreeFoliage;
/** Optionaler Art-Name (z. B. „Quercus robur"), erscheint als Beschriftung im Grundriss. */
species?: string;
/** [149] Art-Name als Beschriftung im Grundriss zeigen (nahe am Stamm; Vorgabe aus). */
showLabel?: boolean;
/** Höhenversatz des Fusses gegenüber Gelände bzw. Geschoss-UK (m, Vorgabe 0). */
baseOffset?: number;
/**
+11
View File
@@ -2436,6 +2436,17 @@ export function TreeSection({ ids }: { ids: readonly string[] }) {
}}
/>
</label>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.showLabel")}</span>
<input
type="checkbox"
checked={tree.showLabel === true}
disabled={locked}
onChange={(e) => set({ showLabel: e.target.checked }, true)}
title={t("objinfo.tree.showLabelHint")}
data-testid="tree-show-label"
/>
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.status")}</span>
<Dropdown
+1 -1
View File
@@ -191,7 +191,7 @@ export class PlanPickIndex {
* Rahmen-Auswahl über Polygone mit Id im Feld `field` (CAD-Konvention): `crossing` = ein Band
* berührt das Rechteck, sonst liegen alle Bänder ganz darin. Ids in Auftreten-Reihenfolge.
*/
marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId", rect: ModelRect, crossing: boolean): string[] {
marquee(field: "wallId" | "ceilingId" | "roomId" | "stairId" | "columnId" | "roofId" | "contextObjectId", rect: ModelRect, crossing: boolean): string[] {
const r = Float64Array.of(rect.minX, rect.minY, rect.maxX, rect.maxY);
return splitIds(core().pick_marquee_polygons(this.ix(), KIND[field], r, crossing));
}
+19
View File
@@ -32,6 +32,7 @@ const EMPTY_MEM = {
columnIds: [] as string[],
roofIds: [] as string[],
openingIds: [] as string[],
treeIds: [] as string[],
};
function project(groups: Group[]): Project {
@@ -184,6 +185,24 @@ describe("applyGroupDimming", () => {
});
});
describe("[149] Bäume in Gruppen", () => {
it("gruppieren, erweitern, auflösen und dimmen", () => {
const res = groupSelection({ ...EMPTY_MEM, wallIds: ["w1"], treeIds: ["b1", "b2"] }, []);
expect(res).not.toBeNull();
const p = applyOps(project([]), res!.ops);
expect(p.groups![0].treeIds).toEqual(["b1", "b2"]);
// Gruppe ohne Bäume schreibt kein leeres Feld (ältere Dateien bleiben gleich).
expect(groupSelection({ ...EMPTY_MEM, wallIds: ["w1", "w2"] }, [])!.ops.length).toBe(1);
const { expanded, groupIds } = expandToGroups(p, { ...EMPTY_MEM, treeIds: ["b2"] }, []);
expect([expanded.wallIds, expanded.treeIds, groupIds]).toEqual([["w1"], ["b1", "b2"], [res!.groupId]]);
expect(ungroup(p, res!.groupId)!.members.treeIds).toEqual(["b1", "b2"]);
const inside = { kind: "polygon", pts: [], contextObjectId: "@tree:b1" } as unknown as Primitive;
const outside = { kind: "polygon", pts: [], contextObjectId: "@tree:b9" } as unknown as Primitive;
const out = applyGroupDimming([inside, outside], p, [res!.groupId]);
expect([out[0].greyed, out[1].greyed]).toEqual([undefined, true]);
});
});
describe("applyGroupDimmingToPlan", () => {
const g1: Group = { id: "g1", wallIds: [], drawingIds: ["din"], ceilingIds: [], roomIds: [], stairIds: [], columnIds: [], roofIds: [], openingIds: [], groupIds: [] };
const p = project([g1]);
+13
View File
@@ -26,6 +26,7 @@ const KEYS: MemberKind[] = [
"columnIds",
"roofIds",
"openingIds",
"treeIds",
];
/** Vereinigung je Art (erste Vorkommen in Reihenfolge) — für Auswahl-Mengen in der Hülle. */
@@ -35,6 +36,9 @@ export function mergeMembership(a: GroupMembership, b: GroupMembership): GroupMe
return out;
}
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
const TREE_PICK = "@tree:";
/** Primitiv-ID-Feld → zugehörige `MemberKind` (Reihenfolge irrelevant). */
const ID_FIELD_TO_KIND: [string, MemberKind][] = [
["wallId", "wallIds"],
@@ -73,6 +77,7 @@ export function applyGroupDimming(
columnIds: new Set(mem.columnIds),
roofIds: new Set(mem.roofIds),
openingIds: new Set(mem.openingIds),
treeIds: new Set(mem.treeIds),
};
return primitives.map((p) => {
const rec = p as unknown as Record<string, unknown>;
@@ -84,6 +89,12 @@ export function applyGroupDimming(
hasId = true;
if (sets[kind].has(v)) inside = true;
}
// [149] Bäume tragen ihre id als `contextObjectId = "@tree:<id>"`.
const ctx = rec.contextObjectId;
if (typeof ctx === "string" && ctx.startsWith(TREE_PICK)) {
hasId = true;
if (sets.treeIds.has(ctx.slice(TREE_PICK.length))) inside = true;
}
return hasId && !inside ? { ...p, greyed: true } : p;
});
}
@@ -135,6 +146,7 @@ export function groupSelection(
columnIds: sel.columnIds,
roofIds: sel.roofIds,
openingIds: sel.openingIds,
...(sel.treeIds.length ? { treeIds: sel.treeIds } : {}),
groupIds: [...selectedGroupIds],
};
return { ops: addItems("groups", [g]), groupId: id };
@@ -164,6 +176,7 @@ export function ungroup(
columnIds: g.columnIds,
roofIds: g.roofIds,
openingIds: g.openingIds,
treeIds: g.treeIds ?? [],
},
subGroupIds: g.groupIds,
};
+4
View File
@@ -34,6 +34,8 @@ export function isLocked(project: Project, kind: MemberKind, id: string): boolea
return !!(project.roofs ?? []).find((r) => r.id === id)?.locked;
case "openingIds":
return !!(project.openings ?? []).find((o) => o.id === id)?.locked;
case "treeIds":
return !!(project.trees ?? []).find((t) => t.id === id)?.locked;
}
}
@@ -56,6 +58,8 @@ export function lockOps(project: Project, kind: MemberKind, id: string, locked:
return patchItem(project, "roofs", id, { locked });
case "openingIds":
return patchItem(project, "openings", id, { locked });
case "treeIds":
return patchItem(project, "trees", id, { locked });
}
}
+1
View File
@@ -228,5 +228,6 @@ export function toMembership(sel: Selection): GroupMembership {
columnIds: sel.columns,
roofIds: sel.roofs,
openingIds: sel.openings,
treeIds: sel.trees,
};
}
+4
View File
@@ -38,6 +38,7 @@ function selHit(sel: PlanSelection): { kind: MemberKind; id: string } | null {
if (sel.roomId) return { kind: "roomIds", id: sel.roomId };
if (sel.columnId) return { kind: "columnIds", id: sel.columnId };
if (sel.roofId) return { kind: "roofIds", id: sel.roofId };
if (sel.treeId) return { kind: "treeIds", id: sel.treeId };
return null;
}
@@ -314,6 +315,7 @@ export function useMouseSelectionHandlers(opts: {
columnIds: [],
roofIds: [],
openingIds: [],
treeIds: sel.treeIds ?? [],
};
// Gruppen-Isolation: ausserhalb der aktiven Gruppe getroffene Elemente
// sind gesperrt (werden ignoriert), wie beim Einzelklick.
@@ -329,6 +331,7 @@ export function useMouseSelectionHandlers(opts: {
columnIds: [],
roofIds: [],
openingIds: [],
treeIds: raw.treeIds.filter((id) => isInsideActiveGroup(project, "treeIds", id, groupPath)),
};
// Gruppen-Erweiterung: jedes getroffene Element, das zu einer sichtbaren
// Gruppe gehört, zieht deren ganze (transitive) Mitgliedschaft nach.
@@ -344,6 +347,7 @@ export function useMouseSelectionHandlers(opts: {
ceilings: expanded.ceilingIds,
stairs: expanded.stairIds,
rooms: expanded.roomIds,
trees: expanded.treeIds,
groups: groupIds,
});
};
+7
View File
@@ -336,6 +336,8 @@ export interface MarqueeSelection {
ceilingIds: string[];
roomIds: string[];
stairIds: string[];
/** [149] Getroffene Bäume (Kronenfläche, gleiche Konvention). */
treeIds?: string[];
/**
* Zieh-Richtung: `false` = links→rechts (positiv Δx) → nur VOLLSTÄNDIG
* eingeschlossene Wände; `true` = rechts→links (negativ Δx) → auch berührte/
@@ -2619,6 +2621,11 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
ceilingIds: getPick().marquee("ceilingId", rect, crossing),
roomIds: getPick().marquee("roomId", rect, crossing),
stairIds: getPick().marquee("stairId", rect, crossing),
// [149] Bäume: Kronen-Pickfläche (`contextObjectId = "@tree:<id>"`).
treeIds: getPick()
.marquee("contextObjectId", rect, crossing)
.filter((id) => id.startsWith(TREE_PICK))
.map((id) => id.slice(TREE_PICK.length)),
crossing,
});
}