[279] Geländer als eigenes Bauteil: Modell, Grundriss, Schnitt, Ansicht, 3D, 3D-Dokument, IFC IfcRailing, DXF-Ebene, Umbau und Varianten, Befehl gelaender, Objekt-Info, Griffe, Beispiel Wettbewerb

This commit is contained in:
Claude committed 2026-11-18 00:13:02 +00:00
1 parent 89c2d0c9a8
commit 6f766ef149
103 files changed
+2289 -73

No files matched your search

+1
View File
@@ -36,6 +36,7 @@ const EMPTY_MEM = {
openingIds: [] as string[],
treeIds: [] as string[],
cameraIds: [] as string[],
railingIds: [] as string[],
};
function project(groups: Group[]): Project {
+11
View File
@@ -28,6 +28,7 @@ const KEYS: MemberKind[] = [
"openingIds",
"treeIds",
"cameraIds",
"railingIds",
];
/** Vereinigung je Art (erste Vorkommen in Reihenfolge) — für Auswahl-Mengen in der Hülle. */
@@ -46,6 +47,7 @@ const PICK3D_KIND: Partial<Record<string, MemberKind>> = {
roof: "roofIds",
column: "columnIds",
tree: "treeIds",
railing: "railingIds",
};
/**
@@ -61,6 +63,7 @@ export function pick3dGroup(project: Project, kind: string, id: string, groupPat
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
const TREE_PICK = "@tree:";
const RAILING_PICK = "@railing:";
/** [213] Präfix der Kamera-Pick-Id im Feld `contextObjectId` (Kern `plan/cameras.rs`). */
const CAMERA_PICK = "@camera:";
@@ -104,6 +107,7 @@ export function applyGroupDimming(
openingIds: new Set(mem.openingIds),
treeIds: new Set(mem.treeIds),
cameraIds: new Set(mem.cameraIds),
railingIds: new Set(mem.railingIds),
};
return primitives.map((p) => {
const rec = p as unknown as Record<string, unknown>;
@@ -121,6 +125,11 @@ export function applyGroupDimming(
hasId = true;
if (sets.treeIds.has(ctx.slice(TREE_PICK.length))) inside = true;
}
// [279] Geländer: `contextObjectId = "@railing:<id>"`.
if (typeof ctx === "string" && ctx.startsWith(RAILING_PICK)) {
hasId = true;
if (sets.railingIds.has(ctx.slice(RAILING_PICK.length))) inside = true;
}
// [213] Kameras: `contextObjectId = "@camera:<id>"`.
if (typeof ctx === "string" && ctx.startsWith(CAMERA_PICK)) {
hasId = true;
@@ -179,6 +188,7 @@ export function groupSelection(
openingIds: sel.openingIds,
...(sel.treeIds.length ? { treeIds: sel.treeIds } : {}),
...(sel.cameraIds.length ? { cameraIds: sel.cameraIds } : {}),
...(sel.railingIds.length ? { railingIds: sel.railingIds } : {}),
groupIds: [...selectedGroupIds],
};
return { ops: addItems("groups", [g]), groupId: id };
@@ -210,6 +220,7 @@ export function ungroup(
openingIds: g.openingIds,
treeIds: g.treeIds ?? [],
cameraIds: g.cameraIds ?? [],
railingIds: g.railingIds ?? [],
},
subGroupIds: g.groupIds,
};
+1 -1
View File
@@ -34,7 +34,7 @@ export interface SelectionAppearance {
/** Zahl der gewählten Elemente (ohne Gruppen, Schnittlinien, Lage-Darstellung, Bäume). */
export function selectedCount(sel: Selection): number {
return ELEMENT_KINDS.filter((k) => k !== "sectionLines" && k !== "site" && k !== "trees" && k !== "cameras").reduce((n, k) => n + sel[k].length, 0);
return ELEMENT_KINDS.filter((k) => k !== "sectionLines" && k !== "site" && k !== "trees" && k !== "railings" && k !== "cameras").reduce((n, k) => n + sel[k].length, 0);
}
/** Effektive Strichstärke und Farbe über die gewählten Wände/Decken/2D-Elemente. */
+4
View File
@@ -38,6 +38,8 @@ export function isLocked(project: Project, kind: MemberKind, id: string): boolea
return !!(project.trees ?? []).find((t) => t.id === id)?.locked;
case "cameraIds":
return !!(project.cameras ?? []).find((c) => c.id === id)?.locked;
case "railingIds":
return !!(project.railings ?? []).find((c) => c.id === id)?.locked;
}
}
@@ -64,6 +66,8 @@ export function lockOps(project: Project, kind: MemberKind, id: string, locked:
return patchItem(project, "trees", id, { locked });
case "cameraIds":
return patchItem(project, "cameras", id, { locked });
case "railingIds":
return patchItem(project, "railings", id, { locked });
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ export function openObjectSettings(deps: ObjectSettingsDeps, group?: InfoGroupId
const sel = selectionInfoFor(project, selection);
let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined));
// Baum, Lage-Darstellung und Schnittlinie sind keine `SelectionInfo`, haben aber ihre Felder in der Objekt-Info.
if (!target && (selection.trees.length > 0 || selection.cameras.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) {
if (!target && (selection.trees.length > 0 || selection.railings.length > 0 || selection.cameras.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) {
target = { group: selection.sectionLines.length > 0 ? "sectionLine" : null };
}
if (!target) return false;
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import type { Railing } from "../model/types";
import { railingGripPatch, railingGripPoints } from "./railingGrips";
const base = {
id: "g",
type: "railing",
floorId: "eg",
categoryCode: "41",
points: [{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 3, y: 2 }],
height: 1,
kind: "bars",
} as unknown as Railing;
describe("[279] Geländer-Griffe", () => {
it("ein Griff je Achsenpunkt", () => {
expect(railingGripPoints(base)).toEqual([{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 3, y: 2 }]);
});
it("Ziehen ersetzt genau diesen Punkt; Unsinn ändert nichts", () => {
expect(railingGripPatch(base, 1, { x: 4, y: 1 })).toEqual({ points: [{ x: 0, y: 0 }, { x: 4, y: 1 }, { x: 3, y: 2 }] });
expect(railingGripPatch(base, 5, { x: 4, y: 1 })).toEqual({});
expect(railingGripPatch(base, -1, { x: 4, y: 1 })).toEqual({});
expect(railingGripPatch(base, 0, { x: NaN, y: 1 })).toEqual({});
});
});
+17
View File
@@ -0,0 +1,17 @@
// [279] Griffe eines Geländers im Grundriss: jeder Punkt der Achse (verschieben). Die Punkte folgen dem Modell
// (`Railing.points`); ein Ziehen ersetzt genau diesen Punkt, Höhe, Art und Teilung bleiben.
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Railing, Vec2 } from "../model/types";
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge. */
export function railingGripPoints(r: Railing): Vec2[] {
return r.points.map((p) => ({ x: p.x, y: p.y }));
}
/** Änderung beim Ziehen des Griffs `index` an `pt`; unbekannter Index ändert nichts. */
export function railingGripPatch(r: Railing, index: number, pt: Vec2): Partial<Railing> {
if (!Number.isFinite(pt.x) || !Number.isFinite(pt.y) || index < 0 || index >= r.points.length) return {};
return { points: r.points.map((p, i) => (i === index ? { x: pt.x, y: pt.y } : p)) };
}
+1 -1
View File
@@ -26,7 +26,7 @@ export function renovationFilterLabel(id: string, own: readonly { id: string; na
/** Ids der Auswahl, die einen Umbau-Status tragen (Wände, Öffnungen, Decken, Dächer, Treppen, Stützen, Körper, Räume, 2D-Elemente, Bäume). */
export function selectionRenovationIds(sel: Selection): string[] {
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms, ...sel.drawings, ...sel.trees];
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms, ...sel.drawings, ...sel.trees, ...sel.railings];
}
const NO_PHASES: readonly RenovationPhase[] = [];
+1
View File
@@ -86,6 +86,7 @@ describe("Selection", () => {
roomIds: [],
openingIds: [],
treeIds: [],
railingIds: [],
cameraIds: [],
contextIds: [],
});
+9
View File
@@ -41,6 +41,8 @@ export interface Selection {
trees: string[];
/** [213] Kameras (`Project.cameras`). */
cameras: string[];
/** [279] Geländer (`Project.railings`). */
railings: string[];
/**
* Gewählte Gruppen — rein informativ (Bounding-Box, Doppelklick-Ziel); die
* Mitglieder stehen zusätzlich in den übrigen Arten (s. `groupActions.ts`).
@@ -66,6 +68,7 @@ export const SELECTION_KINDS: readonly SelectionKind[] = [
"site",
"trees",
"cameras",
"railings",
"groups",
];
@@ -145,6 +148,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
roomIds: sel.rooms,
openingIds: sel.openings,
treeIds: sel.trees,
railingIds: sel.railings,
cameraIds: sel.cameras,
contextIds: sel.contextObjects,
};
@@ -168,6 +172,7 @@ export function hasTransformable(sel: Selection): boolean {
sel.rooms.length > 0 ||
sel.openings.length > 0 ||
sel.trees.length > 0 ||
sel.railings.length > 0 ||
sel.cameras.length > 0 ||
sel.contextObjects.length > 0
);
@@ -191,6 +196,8 @@ export interface SelectionIdLists {
treeIds?: string[];
/** [213] Kameras (gruppierbar wie Bäume). */
cameraIds?: string[];
/** [279] Geländer (gruppierbar). */
railingIds?: string[];
}
const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
@@ -208,6 +215,7 @@ const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
["groups", "groupIds"],
["trees", "treeIds"],
["cameras", "cameraIds"],
["railings", "railingIds"],
];
/** Auswahl → `…Ids`-Listen (passt strukturell auf `GroupMembership` und `BcfSelection`). */
@@ -240,5 +248,6 @@ export function toMembership(sel: Selection): GroupMembership {
openingIds: sel.openings,
treeIds: sel.trees,
cameraIds: sel.cameras,
railingIds: sel.railings,
};
}
+1 -1
View File
@@ -73,5 +73,5 @@ export function hideSelectionIn3d(): void {
const ids = selectionIds3d(st.selection);
if (!ids.length) return;
setView3dFilter(hideSelection3d(getView3dFilter(), ids));
st.setSelection(clearKinds("walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "cameras", "drawings", "groups"));
st.setSelection(clearKinds("walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "railings", "cameras", "drawings", "groups"));
}
+18 -1
View File
@@ -51,6 +51,7 @@ import { getPlanViewport, subscribePlanViewport } from "./planViewport";
import { growRect, meshGripIndices } from "../core";
import { patchItem, verticalExtents } from "../core";
import { treeGripPatch, treeGripPoints } from "./treeGrips";
import { railingGripPatch, railingGripPoints } from "./railingGrips";
import { cameraGripPoints } from "../core";
import type { Selection } from "./selection";
@@ -213,6 +214,9 @@ export function useGripEditing(opts: {
);
const selectedTreeId = single(selection, "trees");
const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined;
// [279] Geländer: Griffe an allen Achsenpunkten (nur auf dem Geschoss des Geländers).
const selectedRailingId = single(selection, "railings");
const selectedRailing = selectedRailingId ? (project.railings ?? []).find((x) => x.id === selectedRailingId && x.floorId === levelId) : undefined;
// [213] Kamera: Griffe an Standpunkt, Ziel und Sichtkegel-Rand (Bildwinkel); nur auf dem Geschoss der Kamera.
const selectedCameraId = single(selection, "cameras");
const selectedCamera = selectedCameraId ? (project.cameras ?? []).find((x) => x.id === selectedCameraId && x.floorId === levelId) : undefined;
@@ -278,7 +282,7 @@ export function useGripEditing(opts: {
// [26] Dach-Griffe: nur bei einzeln gewähltem, nicht gesperrtem Dach und ohne andere Griff-Träger in der Auswahl.
const roofGripsOn =
modelEditable && !!selectedRoof && !selectedRoof.locked && !!opts.moveRoofVertex && !selectedCeiling && !selectedRoom &&
!selectedExcavation && !selectedTree && !selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0;
!selectedExcavation && !selectedTree && !selectedRailing && !selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0;
/** Ringe des Dachs in der Reihenfolge des flachen Index (Umriss, dann Höfe) samt Start-Index. */
const roofRings = (r: Roof): { pts: Vec2[]; off: number; bulge?: number[] }[] => {
let off = 0;
@@ -522,6 +526,11 @@ export function useGripEditing(opts: {
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
return pts;
}
if (selectedRailing && modelEditable && !selectedRailing.locked) {
const pts = railingGripPoints(selectedRailing);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
return pts;
}
if (selectedTree && modelEditable && !selectedTree.locked) {
const pts = treeGrips(selectedTree);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
@@ -1261,6 +1270,14 @@ export function useGripEditing(opts: {
if (!selectedCamera.locked) storeState().moveCameraGrip(selectedCamera.id, index, pt);
return;
}
// [279] Geländer: Achsenpunkt live, ein Undo-Schritt je Zug (gleicher coalesceKey).
if (selectedRailing) {
const rl = selectedRailing;
if (rl.locked) return;
const patch = railingGripPatch(rl, index, pt);
if (patch.points) storeState().applyChange((p) => patchItem(p, "railings", rl.id, patch), `railingGrip:${rl.id}:${index}`);
return;
}
// [149] Baum: Stammmitte, Kronenrand bzw. Beschriftung live, ein Undo-Schritt je Zug (gleicher coalesceKey).
if (selectedTree) {
const tr = selectedTree;
+14
View File
@@ -40,6 +40,7 @@ function selHit(sel: PlanSelection): { kind: MemberKind; id: string } | null {
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 };
if (sel.railingId) return { kind: "railingIds", id: sel.railingId };
if (sel.cameraId) return { kind: "cameraIds", id: sel.cameraId };
return null;
}
@@ -218,6 +219,7 @@ export function useMouseSelectionHandlers(opts: {
context: "contextObjects",
site: "site",
tree: "trees",
railing: "railings",
camera: "cameras",
} as const satisfies Record<string, SelectionKind>;
type Kind = keyof typeof channels;
@@ -239,6 +241,8 @@ export function useMouseSelectionHandlers(opts: {
? { kind: "solid", id: sel.extrudedSolidId }
: sel.treeId
? { kind: "tree", id: sel.treeId }
: sel.railingId
? { kind: "railing", id: sel.railingId }
: sel.cameraId
? { kind: "camera", id: sel.cameraId }
: sel.columnId
@@ -307,6 +311,8 @@ export function useMouseSelectionHandlers(opts: {
? ["site", sel.siteId]
: sel.treeId
? ["trees", sel.treeId]
: sel.railingId
? ["railings", sel.railingId]
: sel.cameraId
? ["cameras", sel.cameraId]
: null;
@@ -330,6 +336,7 @@ export function useMouseSelectionHandlers(opts: {
openingIds: [],
treeIds: sel.treeIds ?? [],
cameraIds: sel.cameraIds ?? [],
railingIds: sel.railingIds ?? [],
};
// Gruppen-Isolation: ausserhalb der aktiven Gruppe getroffene Elemente
// sind gesperrt (werden ignoriert), wie beim Einzelklick.
@@ -347,6 +354,7 @@ export function useMouseSelectionHandlers(opts: {
openingIds: [],
treeIds: raw.treeIds.filter((id) => isInsideActiveGroup(project, "treeIds", id, groupPath)),
cameraIds: raw.cameraIds.filter((id) => isInsideActiveGroup(project, "cameraIds", id, groupPath)),
railingIds: raw.railingIds.filter((id) => isInsideActiveGroup(project, "railingIds", id, groupPath)),
};
// Gruppen-Erweiterung: jedes getroffene Element, das zu einer sichtbaren
// Gruppe gehört, zieht deren ganze (transitive) Mitgliedschaft nach.
@@ -363,6 +371,7 @@ export function useMouseSelectionHandlers(opts: {
stairs: expanded.stairIds,
rooms: expanded.roomIds,
trees: expanded.treeIds,
railings: expanded.railingIds,
cameras: expanded.cameraIds,
groups: groupIds,
});
@@ -428,6 +437,11 @@ export function useMouseSelectionHandlers(opts: {
setSelection({ ...clearKinds(), trees: [hit.id] });
return;
}
// [279] Geländer: Objekt-Info wie im Grundriss.
if (hit.kind === "railing") {
setSelection({ ...clearKinds(), railings: [hit.id] });
return;
}
// [137] Freier Körper (Loft, Rotation, Extrusion): Objekt-Info wie im Grundriss.
if (hit.kind === "solid") {
setSelection({ ...clearKinds(), solids: [hit.id] });
+4
View File
@@ -151,6 +151,8 @@ export function useSelectionCommands(opts: {
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));
// [279] Geländer (gesperrte bleiben).
const railids = new Set(selection.railings.filter((id) => !(project.railings ?? []).find((r) => r.id === id)?.locked));
// [213] Kameras (gesperrte bleiben).
const camids = new Set(selection.cameras.filter((id) => !(project.cameras ?? []).find((c) => c.id === id)?.locked));
// [193] Abgeleitete Lage-Darstellung (Schatten, Baurecht) ist kein Element: Entf blendet sie aus
@@ -177,6 +179,7 @@ export function useSelectionCommands(opts: {
...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),
...removeItems(p, "railings", railids),
...removeItems(p, "cameras", camids),
// Gelöschte Elemente verlassen ihre Gruppen.
...pruneGroupMembers(p, {
@@ -189,6 +192,7 @@ export function useSelectionCommands(opts: {
columnIds: colids,
treeIds: treeids,
cameraIds: camids,
railingIds: railids,
}),
]),
);
+1 -1
View File
@@ -21,7 +21,7 @@ export interface 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"];
const KINDS_3D: readonly SelectionKind[] = ["walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "railings", "drawings"];
/** Element-ids der Auswahl, die im 3D vorkommen (ohne Doppel, in Wahl-Reihenfolge). */
export function selectionIds3d(sel: Selection): string[] {