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

This commit is contained in:
Claude committed 2026-11-06 21:56:23 +00:00
commit 0a29dc4d64
51 files changed
+1869 -38

No files matched your search

+3
View File
@@ -698,6 +698,8 @@ export default function App() {
const colids = new Set(notLocked("columnIds", selection.columns));
const rfids = new Set(notLocked("roofIds", selection.roofs));
const ctxids = new Set(selection.contextObjects);
// [149] Bäume (gesperrte bleiben).
const treeids = new Set(selection.trees.filter((id) => !(project.trees ?? []).find((t) => t.id === id)?.locked));
setProject(
opsMutation((p) => [
...removeItems(p, "drawings2d", dids),
@@ -711,6 +713,7 @@ export default function App() {
// Öffnungen: eigene Auswahl löschen UND alle, deren Wirt (Wand, Dach, Decke [103]) entfällt.
...removeItems(p, "openings", (o) => oids.has(o.id) || wids.has(o.hostWallId) || (!!o.hostRoofId && rfids.has(o.hostRoofId)) || (!!o.hostCeilingId && cids.has(o.hostCeilingId))),
...removeItems(p, "context", ctxids),
...removeItems(p, "trees", treeids),
]),
);
};
+102
View File
@@ -0,0 +1,102 @@
/**
* [149] Werkzeug „Baum": Klick setzt einen Baum (Ebene 13, Vorgaben, Optionen), Zahl = Kronendurchmesser,
* mehrere Bäume nacheinander; „Kreise in Bäume umwandeln" ersetzt die Kreise der Baum-Ebene.
*/
import { describe, it, expect, beforeEach } from "vitest";
import { circlesToTreesCommand, treeCommand, treeDefaults } from "./tree";
import type { CommandContext, Project } from "../types";
function project(): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [],
wallTypes: [],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
],
layers: [
{ code: "13", name: "Bäume", color: "#0a0a0a", lw: 0.13, visible: true, locked: false },
{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false },
],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [
{ id: "k1", type: "drawing2d", levelId: "eg", categoryCode: "13", geom: { shape: "circle", center: { x: 3, y: 4 }, r: 2.5 } },
{ id: "k2", type: "drawing2d", levelId: "eg", categoryCode: "20", geom: { shape: "circle", center: { x: 0, y: 0 }, r: 1 } },
],
context: [],
};
}
function makeCtx(p: Project, drawingIds: string[] = []): CommandContext {
return {
project: p,
level: p.drawingLevels[0],
defaultCategoryCode: "20",
activeLineStyleId: "solid",
activeWallTypeId: "aw",
lastPoint: null,
selection: { wallIds: [], drawingId: null, drawingIds },
};
}
describe("treeCommand", () => {
beforeEach(() => {
Object.assign(treeDefaults, { shape: "round", status: "existing", foliage: "deciduous", crownDiameter: 5, height: 10 });
});
it("Klick setzt einen Baum auf der Baum-Ebene; der Befehl bleibt für den nächsten", () => {
const p = project();
const ctx = makeCtx(p);
let st = treeCommand.init();
// Zahl = Kronendurchmesser, Optionen wechseln Bestand und Laub/Nadel (Nadel → Kegel).
[st] = treeCommand.onInput(st, { kind: "number", value: 7 }, ctx);
[st] = treeCommand.onInput(st, { kind: "option", id: "status" }, ctx);
[st] = treeCommand.onInput(st, { kind: "option", id: "foliage" }, ctx);
const [st2, r] = treeCommand.onInput(st, { kind: "point", point: { x: 4, y: 2 } }, ctx);
expect(r.done).toBeFalsy();
expect(r.commit).toBeDefined();
const next = r.commit!(p);
expect(next.trees?.length).toBe(1);
const t = next.trees![0];
expect(t).toMatchObject({
type: "tree",
floorId: "eg",
categoryCode: "13",
position: { x: 4, y: 2 },
crownDiameter: 7,
height: 10,
status: "new",
foliage: "conifer",
shape: "conical",
});
// Zweiter Klick: zweiter Baum mit eigener id.
const [, r2] = treeCommand.onInput(st2, { kind: "point", point: { x: 10, y: 2 } }, makeCtx(next));
const n2 = r2.commit!(next);
expect(n2.trees?.length).toBe(2);
expect(n2.trees![1].id).not.toBe(t.id);
// Vorschau: Kronenkreis am Cursor.
const [, mv] = treeCommand.onMove!(st2, { x: 1, y: 1 }, null, ctx);
expect(mv.draft?.preview?.length).toBeGreaterThan(0);
});
it("Kreise in Bäume umwandeln: nur Kreise der Baum-Ebene, Kreise entfallen", () => {
const p = project();
const r = circlesToTreesCommand.autoRun!(makeCtx(p));
const next = r.commit!(p);
expect(next.drawings2d.map((d) => d.id)).toEqual(["k2"]);
expect(next.trees?.length).toBe(1);
expect(next.trees![0]).toMatchObject({ position: { x: 3, y: 4 }, crownDiameter: 5, categoryCode: "13" });
// Mit Auswahl: genau die gewählten Kreise.
const n2 = circlesToTreesCommand.autoRun!(makeCtx(p, ["k2"])).commit!(p);
expect(n2.drawings2d.map((d) => d.id)).toEqual(["k1"]);
expect(n2.trees![0].crownDiameter).toBe(2);
});
});
+128
View File
@@ -0,0 +1,128 @@
// [149] Baum als Engine-Befehl. Ablauf: „Baum setzen:" → Klick setzt die Stammmitte → nächster Baum
// (der Befehl bleibt aktiv, Esc/Enter beendet). Optionen (Klick wechselt): Form, Bestand, Laub/Nadel.
// Eine getippte Zahl setzt den Kronendurchmesser (bleibt über Aufrufe, wie das Leitmass der Stütze).
// Höhe, Kronenansatz, Stamm und Art danach in der Objekt-Info.
//
// Die Ops baut der Kern (`cmd_create.rs`, Befehl „tree"): Ebene „13" (Bäume), falls vorhanden, sonst
// die aktive; aktives Geschoss.
//
// Bezeichner englisch, sichtbarer Text via t().
import type { Command, CommandContext, CommandResult, CommandState, CmdOption, Vec2 } from "../types";
import type { TreeFoliage, TreeShape, TreeStatus } from "../../model/types";
import { createMutation, createPreview, xy } from "../createCore";
import { t, type TranslationKey } from "../../i18n";
const SHAPES: TreeShape[] = ["round", "oval", "columnar", "conical"];
const STATUS: TreeStatus[] = ["existing", "new", "remove"];
const FOLIAGE: TreeFoliage[] = ["deciduous", "conifer"];
/** Vorgaben des Werkzeugs (modulweit, leben über Befehls-Instanzen hinweg). */
export const treeDefaults: {
shape: TreeShape;
status: TreeStatus;
foliage: TreeFoliage;
crownDiameter: number;
height: number;
trunkDiameter: number;
crownBase: number;
} = {
shape: "round",
status: "existing",
foliage: "deciduous",
crownDiameter: 5,
height: 10,
trunkDiameter: 0.3,
crownBase: 2.5,
};
const next = <T>(list: readonly T[], v: T): T => list[(list.indexOf(v) + 1) % list.length];
/** Anfrage an den Kern (Werkzeug-Vorgaben). */
export const treeReq = () => ({ cmd: "tree", ...treeDefaults });
const appendTree = (at: Vec2, ctx: CommandContext) => createMutation(ctx, { ...treeReq(), at: xy(at) });
interface TreeState extends CommandState {
phase: "place" | "done";
}
const finish = (): [CommandState, CommandResult] => [{ phase: "done", lastPoint: null } as TreeState, { draft: null, done: true }];
function previewAt(pt: Vec2, ctx: CommandContext): CommandResult {
return {
draft: {
preview: createPreview(ctx, treeReq(), [pt]).shapes,
vertices: [],
hud: { at: pt, text: `Ø${treeDefaults.crownDiameter.toFixed(1)} m · ${treeDefaults.height.toFixed(1)} m` },
},
};
}
export const treeCommand: Command = {
name: "tree",
labelKey: "cmd.tree.label",
prompt: () => "cmd.tree.place",
accepts: () => ["point", "number", "option"],
options: (): CmdOption[] => [
{ id: "shape", labelKey: "cmd.tree.shape", value: t(`objinfo.tree.shape.${treeDefaults.shape}` as TranslationKey) },
{ id: "status", labelKey: "cmd.tree.status", value: t(`objinfo.tree.status.${treeDefaults.status}` as TranslationKey) },
{ id: "foliage", labelKey: "cmd.tree.foliage", value: t(`objinfo.tree.foliage.${treeDefaults.foliage}` as TranslationKey) },
],
floorOnly: true,
init: (): TreeState => ({ phase: "place", lastPoint: null }),
onInput: (state, input, ctx): [CommandState, CommandResult] => {
const s = state as TreeState;
if (s.phase === "done") return finish();
if (input.kind === "number") {
const v = Math.abs(input.value);
if (v > 0.1 && Number.isFinite(v)) treeDefaults.crownDiameter = v;
return [s, { draft: null }];
}
if (input.kind === "option") {
if (input.id === "shape") treeDefaults.shape = next(SHAPES, treeDefaults.shape);
if (input.id === "status") treeDefaults.status = next(STATUS, treeDefaults.status);
if (input.id === "foliage") {
treeDefaults.foliage = next(FOLIAGE, treeDefaults.foliage);
// Nadelbaum meist kegelförmig, Laubbaum rund (Form bleibt danach frei wählbar).
treeDefaults.shape = treeDefaults.foliage === "conifer" ? "conical" : "round";
}
return [s, { draft: null }];
}
if (input.kind === "point") {
// Mehrere Bäume nacheinander: der Befehl bleibt in der Setz-Phase.
return [s, { draft: null, commit: appendTree(input.point, ctx) }];
}
return [s, { draft: null }];
},
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
const s = state as TreeState;
if (s.phase !== "place") return [s, { draft: null }];
return [s, previewAt(point, ctx)];
},
onConfirm: (): [CommandState, CommandResult] => finish(),
onCancel: (): [CommandState, CommandResult] => finish(),
};
/** [149] „Kreise in Bäume umwandeln": gewählte Kreise, sonst alle Kreise der Baum-Ebene im aktiven Geschoss. */
export const circlesToTreesCommand: Command = {
name: "circlestotrees",
labelKey: "cmd.circlestotrees.label",
prompt: () => "cmd.circlestotrees.label",
accepts: () => [],
options: () => [],
floorOnly: true,
init: (): CommandState => ({ phase: "idle", lastPoint: null }),
autoRun: (ctx: CommandContext): CommandResult => {
const ids = ctx.selection.drawingIds?.length ? ctx.selection.drawingIds : ctx.selection.drawingId ? [ctx.selection.drawingId] : [];
return { draft: null, done: true, commit: createMutation(ctx, { cmd: "circlesToTrees", ids }) };
},
onInput: (): [CommandState, CommandResult] => finish(),
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
onConfirm: (): [CommandState, CommandResult] => finish(),
onCancel: (): [CommandState, CommandResult] => finish(),
};
+5
View File
@@ -13,6 +13,7 @@ import { ceilingCommand } from "./cmds/ceiling";
import { openingCommand, fensterCommand, tuerCommand } from "./cmds/opening";
import { stairCommand } from "./cmds/stair";
import { columnCommand } from "./cmds/column";
import { circlesToTreesCommand, treeCommand } from "./cmds/tree";
import { roofCommand } from "./cmds/roof";
import { solidCommand } from "./cmds/solid";
import { solidBoolCommand } from "./cmds/solidbool";
@@ -82,6 +83,8 @@ export const COMMANDS: Record<string, Command> = {
tuer: tuerCommand,
stair: stairCommand,
column: columnCommand,
tree: treeCommand,
circlestotrees: circlesToTreesCommand,
roof: roofCommand,
solid: solidCommand,
solidbool: solidBoolCommand,
@@ -170,6 +173,8 @@ export const ALIASES: Record<string, string> = {
tp: "stair",
stuetze: "column",
stütze: "column",
baum: "tree",
kreiseinbaeume: "circlestotrees",
dach: "roof",
koerper: "solid",
durchbruch: "voidbox",
+2
View File
@@ -86,6 +86,8 @@ export interface CommandSelection {
roomIds?: string[];
/** Gewählte Öffnungen ([144]): Wandöffnungen gleiten beim Verschieben entlang ihrer Wand. */
openingIds?: string[];
/** [149] Gewählte Bäume (Verschieben/Kopieren/Spiegeln/Drehen: Stammmitte). */
treeIds?: string[];
}
/** Live-Kontext, den ein Befehl bei jedem Schritt erhält (analog ToolContext). */
+1
View File
@@ -163,6 +163,7 @@ export {
DRAWING_PICK_TOLERANCE,
type PickContextMesh,
type PickColumnMesh,
type PickTreeMesh,
type PickSolidMesh,
type PickOpeningMesh,
type PickStairMesh,
+13 -1
View File
@@ -28,6 +28,7 @@ import type {
Roof,
Room,
Stair,
Tree,
Wall,
} from "../model/types";
import { uniqueStamp } from "../tools/types";
@@ -45,6 +46,8 @@ export interface ElementSelectionIds {
roomIds: string[];
extrudedSolidIds: string[];
columnIds: string[];
/** [149] Bäume (optional: ältere Aufrufer kennen sie nicht). */
treeIds?: string[];
}
/** Tiefe Kopie der gewählten Elemente über alle Bauteil-Arten hinweg. */
@@ -58,6 +61,8 @@ export interface ElementClipboard {
rooms: Room[];
extrudedSolids: ExtrudedSolid[];
columns: Column[];
/** [149] Bäume (optional: Zwischenablagen älterer Fenster haben sie nicht). */
trees?: Tree[];
}
const EMPTY_CLIPBOARD: ElementClipboard = {
@@ -83,7 +88,8 @@ export function isClipboardEmpty(c: ElementClipboard): boolean {
c.stairs.length === 0 &&
c.rooms.length === 0 &&
c.extrudedSolids.length === 0 &&
c.columns.length === 0
c.columns.length === 0 &&
(c.trees?.length ?? 0) === 0
);
}
@@ -122,6 +128,8 @@ export function collectElementClipboard(
const extrudedSolids = (project.extrudedSolids ?? []).filter((s) => extrudedSolidIds.has(s.id));
const columnIds = new Set(sel.columnIds);
const columns = (project.columns ?? []).filter((c) => columnIds.has(c.id));
const treeIds = new Set(sel.treeIds ?? []);
const trees = (project.trees ?? []).filter((t) => treeIds.has(t.id));
const clip: ElementClipboard = {
walls: walls.map((w) => structuredClone(w)),
@@ -133,6 +141,7 @@ export function collectElementClipboard(
rooms: rooms.map((r) => structuredClone(r)),
extrudedSolids: extrudedSolids.map((s) => structuredClone(s)),
columns: columns.map((c) => structuredClone(c)),
trees: trees.map((t) => structuredClone(t)),
};
return isClipboardEmpty(clip) ? null : clip;
}
@@ -148,6 +157,7 @@ export interface PastedIds {
roomIds: string[];
extrudedSolidIds: string[];
columnIds: string[];
treeIds: string[];
}
/** Projekt-Liste → Feld in {@link PastedIds}. */
@@ -161,6 +171,7 @@ const PASTED_KEY: Record<string, keyof PastedIds> = {
rooms: "roomIds",
extrudedSolids: "extrudedSolidIds",
columns: "columnIds",
trees: "treeIds",
};
/**
@@ -185,6 +196,7 @@ export function pasteElementClipboard(
roomIds: [],
extrudedSolidIds: [],
columnIds: [],
treeIds: [],
};
for (const op of ops) {
const key = op.kind === "add" ? PASTED_KEY[op.collection] : undefined;
+29
View File
@@ -1797,6 +1797,35 @@ export const de = {
"cmd.opening.dir": "Richtung",
"cmd.opening.sillField": "Brüstung",
"cmd.opening.swingField": "Winkel",
"cmd.tree.label": "Baum",
"cmd.tree.place": "Baum setzen (Zahl = Kronendurchmesser):",
"cmd.tree.shape": "Form",
"cmd.tree.status": "Bestand",
"cmd.tree.foliage": "Laub/Nadel",
"cmd.circlestotrees.label": "Kreise in Bäume umwandeln",
"objinfo.kind.tree": "Baum",
"objinfo.tree.many": "{n} Bäume",
"objinfo.tree.section": "Baum",
"objinfo.tree.species": "Art",
"objinfo.tree.speciesHint": "z. B. Quercus robur",
"objinfo.tree.status": "Bestand",
"objinfo.tree.status.existing": "bestehend",
"objinfo.tree.status.new": "neu",
"objinfo.tree.status.remove": "zu fällen",
"objinfo.tree.shape": "Form",
"objinfo.tree.shape.round": "rund",
"objinfo.tree.shape.oval": "oval",
"objinfo.tree.shape.columnar": "säulenförmig",
"objinfo.tree.shape.conical": "kegelförmig",
"objinfo.tree.foliage": "Laub/Nadel",
"objinfo.tree.foliage.deciduous": "Laubbaum",
"objinfo.tree.foliage.conifer": "Nadelbaum",
"objinfo.tree.height": "Höhe",
"objinfo.tree.crownDiameter": "Kronen-Ø",
"objinfo.tree.crownBase": "Kronenansatz",
"objinfo.tree.trunkDiameter": "Stamm-Ø",
"objinfo.tree.locked": "Gesperrt — Werte nicht änderbar.",
"pick.kind.tree": "Baum",
"cmd.column.label": "Stütze",
"cmd.column.place": "Stütze setzen:",
"cmd.column.profile": "Profil",
+29
View File
@@ -1786,6 +1786,35 @@ export const en: Record<TranslationKey, string> = {
"cmd.opening.dir": "Direction",
"cmd.opening.sillField": "Sill",
"cmd.opening.swingField": "Angle",
"cmd.tree.label": "Tree",
"cmd.tree.place": "Place tree (number = crown diameter):",
"cmd.tree.shape": "Shape",
"cmd.tree.status": "Status",
"cmd.tree.foliage": "Foliage",
"cmd.circlestotrees.label": "Convert circles to trees",
"objinfo.kind.tree": "Tree",
"objinfo.tree.many": "{n} trees",
"objinfo.tree.section": "Tree",
"objinfo.tree.species": "Species",
"objinfo.tree.speciesHint": "e.g. Quercus robur",
"objinfo.tree.status": "Status",
"objinfo.tree.status.existing": "existing",
"objinfo.tree.status.new": "new",
"objinfo.tree.status.remove": "to be felled",
"objinfo.tree.shape": "Shape",
"objinfo.tree.shape.round": "round",
"objinfo.tree.shape.oval": "oval",
"objinfo.tree.shape.columnar": "columnar",
"objinfo.tree.shape.conical": "conical",
"objinfo.tree.foliage": "Foliage",
"objinfo.tree.foliage.deciduous": "deciduous",
"objinfo.tree.foliage.conifer": "conifer",
"objinfo.tree.height": "Height",
"objinfo.tree.crownDiameter": "Crown Ø",
"objinfo.tree.crownBase": "Crown base",
"objinfo.tree.trunkDiameter": "Trunk Ø",
"objinfo.tree.locked": "Locked — values cannot be changed.",
"pick.kind.tree": "Tree",
"cmd.column.label": "Column",
"cmd.column.place": "Place column:",
"cmd.column.profile": "Profile",
+61
View File
@@ -2474,6 +2474,11 @@ export type Project = {
* Projekte/Tests ohne `columns` gültig bleiben (Default: leer behandeln).
*/
columns?: Array<Column>;
/**
* Bäume ([149]) — eigene Objekte mit Stamm, Krone und Höhe, siehe {@link Tree}. Optional, damit
* bestehende Projekte ohne `trees` gültig bleiben (Default: leer behandeln).
*/
trees?: Array<Tree>;
/**
* Gruppen (Vectorworks-artig: Cmd+G fasst die Auswahl zu einer Einheit
* zusammen; Doppelklick betritt die Gruppe zum Bearbeiten, alles andere
@@ -3246,6 +3251,62 @@ export type TextStylePreset = {
marks: Marks;
};
/**
* Ein Baum ([149]) — eigenes Objekt der Umgebung mit Stamm, Krone und Höhe. Grundriss/Situation
* (Kronenkreis mit Planzeichen, Stamm), Schnitt/Ansicht (Silhouette nach Form), 3D (Stamm-Zylinder +
* Krone), Schatten (Sonnenstudie), IFC (IfcGeographicElement). Fuss auf dem Gelände an `position`
* (sonst auf der Geschoss-UK) plus `baseOffset`.
*/
export type Tree = {
id: string;
type: "tree";
/** Zugehörige Zeichnungsebene (Geschoss), auf der der Baum im Grundriss erscheint. */
floorId: string;
/** Grafik-Kategorie (Ebene), Vorgabe "13" (Bäume). */
categoryCode: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Stammmitte im Grundriss (Meter). */
position: Vec2;
/** Stammdurchmesser (m, > 0). */
trunkDiameter: number;
/** Kronendurchmesser (m, > 0). */
crownDiameter: number;
/** Höhe des Kronenansatzes über dem Fuss (m, ≥ 0, < `height`). */
crownBase: number;
/** Gesamthöhe über dem Fuss (m, > 0). */
height: number;
/** Kronenform. */
shape: TreeShape;
/** Bestehend / neu / zu fällen. */
status: TreeStatus;
/** Laub- oder Nadelbaum. */
foliage: TreeFoliage;
/** Optionaler Art-Name (z. B. „Quercus robur"), erscheint als Beschriftung im Grundriss. */
species?: string;
/** Höhenversatz des Fusses gegenüber Gelände bzw. Geschoss-UK (m, Vorgabe 0). */
baseOffset?: number;
/**
* Optionale Übersteuerung der Strichfarbe; sonst gilt die Kategorie-Farbe bzw. die Bestandsfarbe.
*/
color?: string;
};
/** Laub- oder Nadelbaum ([149]) — Planzeichen der Krone (Laub: Wellenkranz, Nadel: Zacken). */
export type TreeFoliage = "deciduous" | "conifer";
/**
* Kronenform eines Baums ([149]): Grundform der Silhouette (Schnitt/Ansicht), des 3D-Körpers und
* des Schattenwerfers.
*/
export type TreeShape = "round" | "oval" | "columnar" | "conical";
/**
* Bestand eines Baums ([149]) nach Plankonvention: bestehend (schwarz), neu (rot/Planung),
* zu fällen (gelb bzw. durchgekreuzt).
*/
export type TreeStatus = "existing" | "new" | "remove";
export type Vec2 = { x: number; y: number };
/**
+93
View File
@@ -37,6 +37,10 @@ import type {
SiaCategory,
SliceTermination,
StairShape,
Tree,
TreeFoliage,
TreeShape,
TreeStatus,
Vec2,
VerticalAnchor,
WallReferenceLine,
@@ -99,6 +103,7 @@ export function ObjectInfoPanel() {
// [137] Lage-Darstellung angeklickt (Schattenfläche / Baurechtslinie): Einstellungen der Quelle.
const site = useStore((s) => s.selection.site);
const treeSel = useStore((s) => s.selection.trees);
const ctxObj = sel?.kind === "contextObject" ? (host.project.context ?? []).find((o) => o.id === sel.id) : undefined;
const quantities = useMemo(
() => (ctxObj?.type === "excavation" ? excavationQuantities(host.project) : []),
@@ -106,6 +111,8 @@ export function ObjectInfoPanel() {
);
// ── Leerzustand ───────────────────────────────────────────────────────────
// [149] Baum gewählt: eigene Felder (Lage, Masse, Form, Bestand).
if (sel === null && treeSel.length > 0) return <TreeSection ids={treeSel} />;
if (sel === null && site[0] === "viewShadows") return <ViewShadowsInfo />;
if (sel === null && site.length > 0) {
const sun = site[0] === "sunStudy";
@@ -2388,6 +2395,92 @@ function VerticalAnchorRow({
// Nach erfolgreichem Resize liefert der Host eine neue bbox → neuer `value` →
// das Feld zeigt automatisch die aktualisierte Größe. `min` erlaubt negative
// Werte (z. B. absolute Z-Höhen unter 0).
// ── Baum ([149]) ─────────────────────────────────────────────────────────────
// Lage (Stammmitte), Masse, Form, Bestand, Laub/Nadel und Art des ersten gewählten Baums; jede Änderung
// ein Undo-Schritt (Kern prüft die Op). Bei mehreren gewählten Bäumen wirken Form/Bestand/Laub auf alle.
const TREE_SHAPES: TreeShape[] = ["round", "oval", "columnar", "conical"];
const TREE_STATUS: TreeStatus[] = ["existing", "new", "remove"];
const TREE_FOLIAGE: TreeFoliage[] = ["deciduous", "conifer"];
export function TreeSection({ ids }: { ids: readonly string[] }) {
const host = usePanelHost();
const applyChange = useStore((s) => s.applyChange);
const trees = (host.project.trees ?? []).filter((x) => ids.includes(x.id));
const tree = trees[0];
if (!tree) return <div className="objinfo-panel"><div className="objinfo-empty">{t("objinfo.empty")}</div></div>;
const locked = !!tree.locked;
const set = (patch: Partial<Tree>, all = false) =>
applyChange((p) => (all ? trees : [tree]).filter((x) => !x.locked).flatMap((x) => patchItem(p, "trees", x.id, patch)));
const level = host.project.drawingLevels.find((l) => l.id === tree.floorId);
return (
<div className="objinfo-panel objinfo-tree">
<div className="objinfo-head">
<span className="objinfo-kind">{trees.length > 1 ? t("objinfo.tree.many", { n: trees.length }) : t("objinfo.kind.tree")}</span>
</div>
<div className="objinfo-section-label">{t("objinfo.tree.section")}</div>
<label className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.species")}</span>
<input
className="objinfo-text"
type="text"
defaultValue={tree.species ?? ""}
key={`sp-${tree.id}-${tree.species ?? ""}`}
disabled={locked}
placeholder={t("objinfo.tree.speciesHint")}
onBlur={(e) => {
const v = e.target.value.trim();
if (v !== (tree.species ?? "")) set({ species: v || undefined });
}}
onKeyDown={(e) => {
if (e.key === "Enter") (e.target as HTMLInputElement).blur();
}}
/>
</label>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.status")}</span>
<Dropdown
value={tree.status}
onChange={(v) => set({ status: v as TreeStatus }, true)}
options={TREE_STATUS.map((v) => ({ value: v, label: t(`objinfo.tree.status.${v}` as TranslationKey) }))}
title={t("objinfo.tree.status")}
width={130}
/>
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.shape")}</span>
<Dropdown
value={tree.shape}
onChange={(v) => set({ shape: v as TreeShape }, true)}
options={TREE_SHAPES.map((v) => ({ value: v, label: t(`objinfo.tree.shape.${v}` as TranslationKey) }))}
title={t("objinfo.tree.shape")}
width={130}
/>
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.tree.foliage")}</span>
<Dropdown
value={tree.foliage}
onChange={(v) => set({ foliage: v as TreeFoliage }, true)}
options={TREE_FOLIAGE.map((v) => ({ value: v, label: t(`objinfo.tree.foliage.${v}` as TranslationKey) }))}
title={t("objinfo.tree.foliage")}
width={130}
/>
</div>
<DimensionField label={t("objinfo.tree.height")} value={tree.height} min={0.5} onCommit={(v) => set({ height: v, crownBase: Math.min(tree.crownBase, 0.9 * v) })} />
<DimensionField label={t("objinfo.tree.crownDiameter")} value={tree.crownDiameter} min={0.2} onCommit={(v) => set({ crownDiameter: v })} />
<DimensionField label={t("objinfo.tree.crownBase")} value={tree.crownBase} onCommit={(v) => set({ crownBase: Math.min(v, 0.9 * tree.height) })} />
<DimensionField label={t("objinfo.tree.trunkDiameter")} value={tree.trunkDiameter} min={0.02} onCommit={(v) => set({ trunkDiameter: v })} />
<DimensionField label="X" value={tree.position.x} min={-Infinity} onCommit={(v) => set({ position: { x: v, y: tree.position.y } })} />
<DimensionField label="Y" value={tree.position.y} min={-Infinity} onCommit={(v) => set({ position: { x: tree.position.x, y: v } })} />
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.column.floor")}</span>
<span className="objinfo-fval">{level?.name ?? tree.floorId}</span>
</div>
{locked && <div className="objinfo-muted">{t("objinfo.tree.locked")}</div>}
</div>
);
}
function DimensionField({
label,
value,
+1 -1
View File
@@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
type ToolsView = "list" | "icons";
+2 -1
View File
@@ -8,7 +8,7 @@ import { flattenCategories } from "../model/types";
/** Art eines auswählbaren Objekts an einer Klickstelle (Reihenfolge = Standard-Priorität). */
export type PickKind =
| "section" | "opening" | "wall" | "column" | "drawing" | "solid"
| "ceiling" | "stair" | "room" | "roof" | "site" | "context";
| "tree" | "ceiling" | "stair" | "room" | "roof" | "site" | "context";
type WithCategory = { id: string; categoryCode?: string };
@@ -25,6 +25,7 @@ function collection(project: Project, kind: PickKind): readonly WithCategory[] {
case "column": return p.columns ?? [];
case "context": return p.context ?? [];
case "solid": return p.extrudedSolids ?? [];
case "tree": return p.trees ?? [];
case "section":
case "site": return [];
}
+6
View File
@@ -104,6 +104,12 @@ export interface PickColumnMesh {
columnId: string;
}
/** [149] Baum für den Raycast: WORLD-Dreiecke von Stamm und Krone (x, Höhe, y). */
export interface PickTreeMesh {
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
treeId: string;
}
/**
* [137] Freier Körper (`extrudedSolids`, Loft/Rotation/Abzug/B-Rep) für den Raycast: WORLD-Dreiecke
* (x, Höhe, y). Der Kern liefert das Prisma über dem Umriss; sobald das truck-Netz geladen ist, ersetzt
+6 -2
View File
@@ -44,7 +44,7 @@ import type { Project, Vec2 } from "../model/types";
import type { DetailLevel } from "../model/viewTypes";
import { documentFor } from "../core/document";
import { coreEpoch } from "../engine/coreWasm";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh } from "./pickTypes";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh, PickTreeMesh } from "./pickTypes";
import {
type RMesh,
type RModel3d,
@@ -334,6 +334,8 @@ export function pickGeometry(
drawings: PickDrawingSeg[];
stairMeshes: PickStairMesh[];
drawingMeshes: PickDrawingMesh[];
/** [149] Bäume (Stamm + Krone). */
trees: PickTreeMesh[];
} {
const g = documentFor(project).query("pickGeometry", [explodeGap(explode)]) as ReturnType<typeof pickGeometry>;
// [137] Freie Körper: das geladene truck-Netz (Loft, Rotation, Verjüngung, Rundung) statt der Prisma-Näherung des Kerns.
@@ -389,8 +391,10 @@ export function selectionHighlightLines(
/** [137] Stützen und freie Körper (Prisma-Umriss). */
columnIds: string[] = [],
solidIds: string[] = [],
/** [149] Bäume (Kronen-Zylinder vom Fuss bis zur Spitze). */
treeIds: string[] = [],
): Float32Array {
const sel = { walls: wallIds, ceilings: ceilingIds, openings: openingIds, stairs: stairIds, roofs: roofIds, context: contextObjectIds, columns: columnIds, solids: solidIds };
const sel = { walls: wallIds, ceilings: ceilingIds, openings: openingIds, stairs: stairIds, roofs: roofIds, context: contextObjectIds, columns: columnIds, solids: solidIds, trees: treeIds };
if (Object.values(sel).every((l) => l.length === 0)) return new Float32Array(0);
// Gerechnet im Kern (`highlight3d.rs`); Antwort f32-LE.
const b = documentFor(project).queryBin("selectionHighlight", [], JSON.stringify({ ...sel, rgb, explode: explodeGap(explode) }));
+1
View File
@@ -85,6 +85,7 @@ describe("Selection", () => {
stairIds: [],
roomIds: [],
openingIds: [],
treeIds: [],
});
expect(toTransformSelection(s)).toEqual(c);
});
+9 -1
View File
@@ -37,6 +37,8 @@ export interface Selection {
* bzw. `"siteRules"` (Baurechtslinie) — die Objekt-Info zeigt die Einstellungen der Quelle.
*/
site: string[];
/** [149] Bäume (`Project.trees`). */
trees: string[];
/**
* Gewählte Gruppen — rein informativ (Bounding-Box, Doppelklick-Ziel); die
* Mitglieder stehen zusätzlich in den übrigen Arten (s. `groupActions.ts`).
@@ -60,6 +62,7 @@ export const SELECTION_KINDS: readonly SelectionKind[] = [
"contextObjects",
"sectionLines",
"site",
"trees",
"groups",
];
@@ -138,6 +141,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
stairIds: sel.stairs,
roomIds: sel.rooms,
openingIds: sel.openings,
treeIds: sel.trees,
};
}
@@ -157,7 +161,8 @@ export function hasTransformable(sel: Selection): boolean {
sel.roofs.length > 0 ||
sel.stairs.length > 0 ||
sel.rooms.length > 0 ||
sel.openings.length > 0
sel.openings.length > 0 ||
sel.trees.length > 0
);
}
@@ -175,6 +180,8 @@ export interface SelectionIdLists {
contextObjectIds: string[];
sectionLineIds: string[];
groupIds: string[];
/** [149] Bäume (nicht gruppierbar; Zwischenablage, Nachauswahl). */
treeIds?: string[];
}
const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
@@ -190,6 +197,7 @@ const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
["contextObjects", "contextObjectIds"],
["sectionLines", "sectionLineIds"],
["groups", "groupIds"],
["trees", "treeIds"],
];
/** Auswahl → `…Ids`-Listen (passt strukturell auf `GroupMembership` und `BcfSelection`). */
+25
View File
@@ -37,6 +37,8 @@ import type { BodyTarget } from "../views/plan/PlanView";
import type { CommandLineHandle } from "../ui/CommandLine";
import type { CommandEngine } from "../commands/engine";
import { single } from "./selection";
import { getState as storeState } from "./appStore";
import { patchItem } from "../core";
import type { Selection } from "./selection";
export interface GripEditFieldsState {
@@ -162,6 +164,13 @@ export function useGripEditing(opts: {
} = opts;
const selectedOpeningId = single(selection, "openings");
const selectedStairId = single(selection, "stairs");
// [149] Baum: Griff in der Stammmitte (verschieben) und am Kronenrand (Kronendurchmesser).
const selectedTreeId = single(selection, "trees");
const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined;
const treeGrips = (tr: NonNullable<typeof selectedTree>): Vec2[] => [
tr.position,
{ x: tr.position.x + tr.crownDiameter / 2, y: tr.position.y },
];
const selectedRoomId = single(selection, "rooms");
const selectedCeilingId = single(selection, "ceilings");
const selectedDrawingId = single(selection, "drawings");
@@ -293,6 +302,11 @@ export function useGripEditing(opts: {
gripOwnerRange.push([0, 0]);
return [stairMoveHandle(st)];
}
if (selectedTree && modelEditable && !selectedTree.locked) {
const pts = treeGrips(selectedTree);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
return pts;
}
// [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt).
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
const pts = excavationGripPoints(selectedExcavation);
@@ -833,6 +847,17 @@ export function useGripEditing(opts: {
if (st) moveStairBy(st.id, sub(pt, stairMoveHandle(st)));
return;
}
// [149] Baum: Stammmitte bzw. Kronenrand live, ein Undo-Schritt je Zug (gleicher coalesceKey).
if (selectedTree) {
const tr = selectedTree;
if (tr.locked) return;
const patch =
index === 0
? { position: { x: pt.x, y: pt.y } }
: { crownDiameter: Math.max(0.2, 2 * Math.hypot(pt.x - tr.position.x, pt.y - tr.position.y)) };
storeState().applyChange((p) => patchItem(p, "trees", tr.id, patch), `treeGrip:${tr.id}:${index}`);
return;
}
// [68] Baugrube: Sohlen-Griff sofort (Höhe), Ecken als Vorschau bis zum Setzen.
if (selectedExcavation && !selectedCeilingId && !selectedRoomId) {
if (index >= selectedExcavation.outline.length) moveExcavationGrip(selectedExcavation.id, index, pt);
+12 -2
View File
@@ -207,6 +207,7 @@ export function useMouseSelectionHandlers(opts: {
roof: "roofs",
context: "contextObjects",
site: "site",
tree: "trees",
} as const satisfies Record<string, SelectionKind>;
type Kind = keyof typeof channels;
const target: { kind: Kind; id: string } | null = sel.sectionLineId
@@ -225,7 +226,9 @@ export function useMouseSelectionHandlers(opts: {
? { kind: "room", id: sel.roomId }
: sel.extrudedSolidId
? { kind: "solid", id: sel.extrudedSolidId }
: sel.columnId
: sel.treeId
? { kind: "tree", id: sel.treeId }
: sel.columnId
? { kind: "column", id: sel.columnId }
: sel.roofId
? { kind: "roof", id: sel.roofId }
@@ -289,7 +292,9 @@ export function useMouseSelectionHandlers(opts: {
? ["contextObjects", sel.contextObjectId]
: sel.siteId
? ["site", sel.siteId]
: null;
: sel.treeId
? ["trees", sel.treeId]
: null;
setSelection({ ...clearKinds(), groups: [], ...(one ? { [one[0]]: [one[1]] } : {}) });
};
// Links-Drag (Marquee) im Grundriss: die getroffene Wand-MENGE übernehmen
@@ -387,6 +392,11 @@ export function useMouseSelectionHandlers(opts: {
setSelection({ ...clearKinds(), columns: [hit.id] });
return;
}
// [149] Baum: Objekt-Info wie im Grundriss.
if (hit.kind === "tree") {
setSelection({ ...clearKinds(), trees: [hit.id] });
return;
}
// [137] Freier Körper (Loft, Rotation, Extrusion): Objekt-Info wie im Grundriss.
if (hit.kind === "solid") {
setSelection({ ...clearKinds(), solids: [hit.id] });
+5 -1
View File
@@ -53,6 +53,8 @@ export interface TransformSelection {
roomIds?: string[];
/** Gewählte Öffnungen ([144]): nur Verschieben, entlang der Wirtswand (Kern `slide_opening`). */
openingIds?: string[];
/** [149] Gewählte Bäume (Stammmitte wird transformiert). */
treeIds?: string[];
}
/** Auswahl (Befehlskontext) → TransformSelection (gleiche Form, alle Elementarten). */
@@ -68,6 +70,7 @@ export function toTransformSel(sel: CommandSelection): TransformSelection {
stairIds: sel.stairIds,
roomIds: sel.roomIds,
openingIds: sel.openingIds,
treeIds: sel.treeIds,
};
}
@@ -87,7 +90,8 @@ export function hasTransformSelection(sel: CommandSelection, op?: string): boole
(sel.ceilingIds?.length ?? 0) > 0 ||
(sel.roofIds?.length ?? 0) > 0 ||
(sel.stairIds?.length ?? 0) > 0 ||
(sel.roomIds?.length ?? 0) > 0
(sel.roomIds?.length ?? 0) > 0 ||
(sel.treeIds?.length ?? 0) > 0
);
}
+18
View File
@@ -175,6 +175,24 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
<line x1="12.5" y1="9.5" x2="12.5" y2="13.5" />
</svg>
);
case "tree":
// [149] Baum: Krone (Kreis) mit Stamm.
return (
<svg {...common}>
<circle cx="8" cy="6.5" r="4.5" />
<line x1="8" y1="11" x2="8" y2="14" />
</svg>
);
case "circlestotrees":
// [149] Kreis → Baum.
return (
<svg {...common}>
<circle cx="4.5" cy="8" r="2.5" strokeDasharray="1.4 1.2" />
<line x1="7.5" y1="8" x2="9" y2="8" />
<circle cx="12" cy="6.5" r="2.5" />
<line x1="12" y1="9" x2="12" y2="13" />
</svg>
);
case "column":
// Stütze: Quadrat-Querschnitt mit vertikalen Kanten (Pfeiler).
return (
+3 -3
View File
@@ -82,7 +82,7 @@ import {
/** Ein per 3D-Klick getroffenes Bauteil, oder null (Leerraum). */
export type Pick3dHit =
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid"; id: string }
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree"; id: string }
| null;
/** Klick-vs-Drag-Schwelle (Pixel): bleibt die Maus zwischen pointerdown und
@@ -1422,7 +1422,7 @@ export function Wasm3DViewport({
const ndc = toNdc(clientX, clientY);
if (!cb || !o || !ndc) return;
const ray = cameraRay(orbitCamera(o), ndc.ndcX, ndc.ndcY, ndc.aspect);
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes } = pickGeometry(
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees } = pickGeometry(
projectRef.current,
explodeRef.current,
);
@@ -1430,7 +1430,7 @@ export function Wasm3DViewport({
// Meshes + freie 2D-Zeichnungen (Linie/Polylinie/Rechteck, s.
// `pickDrawingSegs`) — sonst wären im WASM-Viewport 2D-Elemente NIE
// anwählbar gewesen (Nutzer-Report).
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes);
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees);
cb(hit ? { kind: hit.kind, id: hit.id } : null, additive);
};
+9 -2
View File
@@ -18,7 +18,7 @@
import { DRAWING_PICK_TOLERANCE } from "../core";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh } from "../core";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh, PickTreeMesh } from "../core";
/** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */
export interface RayCamera {
@@ -42,7 +42,7 @@ export interface Ray {
/** Ergebnis eines Picks: getroffenes Bauteil + Distanz entlang des Strahls. */
export interface PickHit {
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid";
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree";
id: string;
t: number;
/** Bei `kind:"opening"` dieselbe Id wie `id` (ausdrucksstärkerer Zugriff). */
@@ -362,6 +362,7 @@ export function pickNearest(
openingMeshes?: readonly PickOpeningMesh[],
stairMeshes?: readonly PickStairMesh[],
drawingMeshes?: readonly PickDrawingMesh[],
trees?: readonly PickTreeMesh[],
): PickHit | null;
/**
* Nächstes getroffenes Bauteil (kleinstes t) über Wände, Decken, Öffnungen und
@@ -386,6 +387,7 @@ export function pickNearest(
openingMeshes: readonly PickOpeningMesh[] = [],
stairMeshes: readonly PickStairMesh[] = [],
drawingMeshes: readonly PickDrawingMesh[] = [],
trees: readonly PickTreeMesh[] = [],
): PickHit | null {
const TIE_EPS = 1e-6;
let hit: PickHit | null = null;
@@ -441,6 +443,11 @@ export function pickNearest(
const t = rayContextMeshTris(ray, { tris: c.tris, contextObjectId: c.columnId });
if (t !== null) consider({ kind: "column", id: c.columnId, t }, 1);
}
// [149] Bäume (Stamm + Krone), Rang wie Wand/Decke.
for (const tr of trees) {
const t = rayContextMeshTris(ray, { tris: tr.tris, contextObjectId: tr.treeId });
if (t !== null) consider({ kind: "tree", id: tr.treeId, t }, 1);
}
// [137] Freie Körper (truck-Netz bzw. Prisma-Näherung), Rang wie Wand/Decke.
for (const s of solids) {
const t = rayContextMeshTris(ray, { tris: s.tris, contextObjectId: s.solidId });
+41 -12
View File
@@ -190,7 +190,7 @@ export interface PlanViewHandle {
const PICK_ORDER: readonly PickKind[] = [
"section", "opening", "wall", "column", "drawing", "solid",
"section", "opening", "wall", "column", "drawing", "solid", "tree",
"ceiling", "stair", "room", "roof", "site", "context",
];
@@ -221,9 +221,13 @@ const EMPTY_PICK: PickIds = {
sectionLineId: null,
contextObjectId: null,
siteId: null,
treeId: null,
};
/** Mac: Cmd+Klick; sonst Strg+Klick (Alt+Klick ist die Schere, Ctrl+Klick unter macOS das Kontextmenü). */
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
const TREE_PICK = "@tree:";
const IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
const cycleModifier = (e: { metaKey: boolean; ctrlKey: boolean }): boolean => (IS_MAC ? e.metaKey : e.ctrlKey);
@@ -300,6 +304,11 @@ export interface PlanSelection {
* wenn kein Element höherer Priorität getroffen wurde; Vorrang vor Kontext-Objekten (sie liegt darüber).
*/
siteId?: string | null;
/**
* [149] Getroffener Baum (Kronenfläche, Pick-Id `@tree:<id>` im Feld `contextObjectId`), wenn keine
* Öffnung/Wand/Stütze/2D-Element/Körper getroffen wurde; Vorrang vor Decke, Raum, Dach und Gelände.
*/
treeId?: string | null;
/**
* War beim Klick Shift gedrückt? Dann ERWEITERT der Aufrufer (App) die
* Auswahl um das getroffene Element (bzw. schaltet es ab/zu), statt sie zu
@@ -687,6 +696,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
groups: selectedGroupIds,
drawings: selectedDrawingIds,
site: selectedSite,
trees: selectedTreeIds,
} = selection;
const selectedDrawingId = single(selection, "drawings");
// Linke Maustaste liegt beim Werkzeug/der Transformation, wenn App das meldet
@@ -1613,11 +1623,17 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
// [137] Getroffene Lage-Darstellung: Quelle `"sunStudy"`/`"siteRules"` (Baurechtslinie vor Schatten) oder null.
const pickSiteAt = (clientX: number, clientY: number): string | null => {
const ids = contextIdsAt(clientX, clientY).filter((id) => id.startsWith("@"));
const ids = contextIdsAt(clientX, clientY).filter((id) => id.startsWith("@") && !id.startsWith(TREE_PICK));
const id = ids.find((x) => x === "@siteRules") ?? ids[0];
return id ? id.slice(1) : null;
};
// [149] Getroffener Baum (oberste Kronenfläche) oder null.
const pickTree = (clientX: number, clientY: number): string | null => {
const id = contextIdsAt(clientX, clientY).find((x) => x.startsWith(TREE_PICK));
return id ? id.slice(TREE_PICK.length) : null;
};
const pickContextObject = (clientX: number, clientY: number): string | null =>
contextIdsAt(clientX, clientY).find((id) => !id.startsWith("@")) ?? null;
@@ -2148,27 +2164,30 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
openingId || wallId || columnId || drawingId
? null
: polyExtrudedSolidId ?? pickExtrudedSolid(clientX, clientY);
// [149] Baum (Kronenfläche) vor Decke, Raum, Dach und Gelände.
const treeId =
openingId || wallId || columnId || drawingId || extrudedSolidId ? null : pickTree(clientX, clientY);
// Decke nur, wenn weder Öffnung/Wand noch 2D-Element getroffen wurde. Da die
// Decken-Polygone UNTER der Wand-Poché liegen, trifft ein direkter Klick
// auf die Wand zuerst die Wand; freie Deckenfläche trifft die Decke.
const hitCeilingId =
hit && hit.kind === "polygon" ? hit.ceilingId ?? null : null;
const ceilingId =
openingId || wallId || columnId || drawingId || extrudedSolidId ? null : hitCeilingId;
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId ? null : hitCeilingId;
// Treppe nur, wenn nichts anderes getroffen wurde (Tritte liegen frei).
const stairId =
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId
? null
: pickStair(clientX, clientY);
// Raum als vorletzte Priorität: die Raum-Fläche liegt UNTER allem anderen.
const roomId =
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId
? null
: pickRoom(clientX, clientY);
// Dach als LETZTE Priorität: die Traufe-Fläche deckt den ganzen Grundriss
// ab, daher erst wählen, wenn wirklich nichts anderes getroffen wurde.
const roofId =
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId || roomId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId
? null
: pickRoof(clientX, clientY);
// Kontext-Objekt (Gebäude/Terrain) als ALLERLETZTE Priorität — seine
@@ -2176,11 +2195,11 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
// nichts anderes getroffen wurde.
// [137] Schatten/Baurechtslinien (Lage-Darstellung) über dem Gelände, unter allen Bauteilen.
const siteId =
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId || roomId || roofId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId || roofId
? null
: pickSiteAt(clientX, clientY);
const contextObjectId =
openingId || wallId || columnId || drawingId || extrudedSolidId || ceilingId || stairId || roomId || roofId || siteId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId || roofId || siteId
? null
: pickContextObject(clientX, clientY);
return {
@@ -2197,6 +2216,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
sectionLineId: null,
contextObjectId,
siteId,
treeId,
};
};
@@ -2327,6 +2347,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
add("column", dp.columnId, dp.hitIndex);
add("drawing", dp.drawingId, dp.hitIndex);
add("solid", dp.extrudedSolidId, dp.hitIndex);
add("tree", dp.treeId, dp.hitIndex);
add("ceiling", dp.ceilingId, dp.hitIndex);
add("stair", dp.stairId, dp.hitIndex);
add("room", dp.roomId, dp.hitIndex);
@@ -2353,7 +2374,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
addRest("stair", p.stairId, idx);
addRest("room", p.roomId, idx);
addRest("roof", p.roofId, idx);
if (p.contextObjectId?.startsWith("@")) addRest("site", p.contextObjectId.slice(1), idx);
if (p.contextObjectId?.startsWith(TREE_PICK)) addRest("tree", p.contextObjectId.slice(TREE_PICK.length), idx);
else if (p.contextObjectId?.startsWith("@")) addRest("site", p.contextObjectId.slice(1), idx);
else addRest("context", p.contextObjectId, idx);
addRest("section", p.sectionLineId, idx);
}
@@ -2364,6 +2386,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
addRest("stair", pickStair(clientX, clientY), null);
addRest("room", pickRoom(clientX, clientY), null);
addRest("roof", pickRoof(clientX, clientY), null);
addRest("tree", pickTree(clientX, clientY), null);
addRest("site", pickSiteAt(clientX, clientY), null);
addRest("context", pickContextObject(clientX, clientY), null);
addRest("section", pickSectionLine(clientX, clientY), null);
@@ -2401,6 +2424,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
sectionLineId: c.kind === "section" ? c.id : null,
contextObjectId: c.kind === "context" ? c.id : null,
siteId: c.kind === "site" ? c.id : null,
treeId: c.kind === "tree" ? c.id : null,
});
};
@@ -2930,10 +2954,14 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
// überzeichnen — analog zur Dach-/Raum-Auswahl.
// [137] Gewählte Lage-Darstellung (Schatten/Baurecht): ihre Flächen bzw. Bänder (`@…`-Ids) ebenso.
const highlightContextObjectPolys = useMemo(() => {
const ids = [...(selectedContextObjectIds ?? []), ...(selectedSite ?? []).map((s) => "@" + s)];
const ids = [
...(selectedContextObjectIds ?? []),
...(selectedSite ?? []).map((s) => "@" + s),
...(selectedTreeIds ?? []).map((s) => TREE_PICK + s),
];
if (!ids.length) return [];
return primsOwnedBy("contextObjectId", ids, (p): p is Extract<Primitive, { kind: "polygon" }> => p.kind === "polygon");
}, [plan, selectedContextObjectIds, selectedSite]);
}, [plan, selectedContextObjectIds, selectedSite, selectedTreeIds]);
// Hervorhebung der selektierten Schnitt-/Ansichtslinie: das (unsichtbare)
// Pick-Band (Polygon mit sectionLineId) mit Akzentkontur überzeichnen.
@@ -2971,7 +2999,8 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
const hoverPrims = useMemo((): Primitive[] => {
if (!hoverPick) return [];
if (hoverPick.kind === "site") return primsOwnedBy("contextObjectId", ["@" + hoverPick.id], (_p): _p is Primitive => true);
const field: Record<Exclude<PickKind, "site">, OwnerField> = {
if (hoverPick.kind === "tree") return primsOwnedBy("contextObjectId", [TREE_PICK + hoverPick.id], (_p): _p is Primitive => true);
const field: Record<Exclude<PickKind, "site" | "tree">, OwnerField> = {
wall: "wallId", drawing: "drawingId", ceiling: "ceilingId", opening: "openingId",
stair: "stairId", room: "roomId", roof: "roofId", context: "contextObjectId",
section: "sectionLineId", solid: "extrudedSolidId", column: "columnId",
+1
View File
@@ -34,6 +34,7 @@ const KIND_FIELD: Record<PickKind, SelectionKind> = {
column: "columns",
drawing: "drawings",
solid: "solids",
tree: "trees",
ceiling: "ceilings",
stair: "stairs",
room: "rooms",
+5 -4
View File
@@ -280,7 +280,7 @@ export const Content = memo(function Content({
() => (explode > 0 ? (explodeFloorOffsets(project, explode)[level.id] ?? 0) : 0),
[project, explode, level.id],
);
const { walls, ceilings, openings, stairs, roofs, contextObjects, columns, solids } = selection;
const { walls, ceilings, openings, stairs, roofs, contextObjects, columns, solids, trees } = selection;
const selectionLines = useMemo(
() =>
walls.length === 0 &&
@@ -290,10 +290,11 @@ export const Content = memo(function Content({
roofs.length === 0 &&
contextObjects.length === 0 &&
columns.length === 0 &&
solids.length === 0
solids.length === 0 &&
trees.length === 0
? null
: selectionHighlightLines(project, walls, ceilings, HIGHLIGHT_RGB, openings, stairs, roofs, contextObjects, explode, columns, solids),
[project, explode, walls, ceilings, openings, stairs, roofs, contextObjects, columns, solids],
: selectionHighlightLines(project, walls, ceilings, HIGHLIGHT_RGB, openings, stairs, roofs, contextObjects, explode, columns, solids, trees),
[project, explode, walls, ceilings, openings, stairs, roofs, contextObjects, columns, solids, trees],
);
// Kollisionen der letzten Prüfung: rote Hüllquader zusätzlich zur Auswahl-Hervorhebung.
const highlightLines = useMemo(() => {