Merge [191] Baugrube mit Bögen

This commit is contained in:
Claude committed 2026-11-12 06:19:13 +00:00
commit cd76a2475c
23 files changed
+678 -105

No files matched your search

+8 -6
View File
@@ -5,7 +5,7 @@
// die Anzeige-Werte zur Auswahl rechnet `selectionMenuState`.
import type { RefObject } from "react";
import { useStore } from "../state/appStore";
import { getState, useStore } from "../state/appStore";
import { ContextMenu } from "../ui/ContextMenu";
import type { Vec2 } from "../model/types";
import type { PlanViewHandle } from "../views/plan/PlanView";
@@ -164,15 +164,16 @@ export function AppContextMenu(props: {
if (total !== 1) return null;
const roof = selection.roofs.length === 1 ? (project.roofs ?? []).find((x) => x.id === selection.roofs[0]) : undefined;
if (roof && !roof.locked) {
return { kind: "roof" as const, id: roof.id, rings: [roof.outline, ...(roof.holes ?? [])].reduce<{ pts: Vec2[]; off: number }[]>(
(acc, pts) => [...acc, { pts, off: acc.reduce((n, r) => n + r.pts.length, 0) }], []) };
const bulges = [roof.outlineBulge, ...(roof.holes ?? []).map((_, k) => roof.holesBulge?.[k])];
return { kind: "roof" as const, id: roof.id, rings: [roof.outline, ...(roof.holes ?? [])].reduce<{ pts: Vec2[]; off: number; bulge?: number[] }[]>(
(acc, pts, k) => [...acc, { pts, off: acc.reduce((n, r) => n + r.pts.length, 0), bulge: bulges[k] }], []) };
}
const ceiling = selection.ceilings.length === 1 ? (project.ceilings ?? []).find((x) => x.id === selection.ceilings[0]) : undefined;
if (ceiling && !ceiling.locked) return { kind: "ceiling" as const, id: ceiling.id, rings: [{ pts: ceiling.outline, off: 0 }] };
if (ceiling && !ceiling.locked) return { kind: "ceiling" as const, id: ceiling.id, rings: [{ pts: ceiling.outline, off: 0, bulge: ceiling.outlineBulge }] };
const room = selection.rooms.length === 1 ? (project.rooms ?? []).find((x) => x.id === selection.rooms[0]) : undefined;
if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0 }] };
if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0, bulge: room.boundaryBulge }] };
const ctx = selection.contextObjects.length === 1 ? (project.context ?? []).find((x) => x.id === selection.contextObjects[0]) : undefined;
if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0 }] };
if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0, bulge: ctx.outlineBulge }] };
// [193] Höhenlinien-Satz: je Linie ein Ring (flacher Index über alle Linien); offene Linien haben kein Schlusssegment.
if (ctx && ctx.type === "contourSet") {
return { kind: "contours" as const, id: ctx.id, rings: ctx.contours.reduce<{ pts: Vec2[]; off: number; closed: boolean }[]>(
@@ -188,6 +189,7 @@ export function AppContextMenu(props: {
})(),
askMeshPointHeight: (id, index) => setMeshHeightPrompt({ id, index }),
deleteMeshPoint: (id, index) => { deleteMeshPoint(id, index); },
setRingArc: (kind, id, seg, pt) => getState().setRingArc(kind, id, seg, pt),
insertPolylinePoint: insertDrawingPoint,
deletePolylinePoint: deleteDrawingPoint,
setPolylineVertexType,
+15 -3
View File
@@ -8,7 +8,7 @@
// Kommentare deutsch (CONVENTIONS.md).
import { t } from "../i18n";
import { canSetVertexType, vertexTypeOf, type PolylineVertexType, type RingKind } from "../core";
import { canSetVertexType, edgeArcToggle, vertexTypeOf, type ArcRingKind, type PolylineVertexType, type RingKind } from "../core";
import { meshTolerance, nearestMeshVertex, nearestPolylineTarget, toleranceFor } from "../core";
import type { LayerCategory, Project, Vec2 } from "../model/types";
import { flattenCategories } from "../model/types";
@@ -90,8 +90,10 @@ export interface MenuActions {
selectedSectionLine?: { id: string; pts: Vec2[] } | null;
insertSectionBend?: (id: string, seg: number, pt: Vec2) => void;
/** [26] Einzeln gewähltes Element mit Umriss (Dach samt Höfen, Decke, Raum, Baugrube): Ringe mit Start-Index im flachen Ecken-Index. */
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean }[] } | null;
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean; bulge?: number[] }[] } | null;
insertRingVertex?: (kind: RingKind, id: string, seg: number, pt: Vec2) => void;
/** [191] Bogen-Scheitel einer Umriss-Kante setzen („Kante gerade ↔ Bogen"). */
setRingArc?: (kind: ArcRingKind, id: string, seg: number, pt: Vec2) => void;
deleteRingVertex?: (kind: RingKind, id: string, index: number) => void;
/** [193] Einzeln gewähltes Gelände-/Netz-Element: Rechtsklick auf einen Netzpunkt → „Höhe setzen …" / „Netzpunkt löschen". */
selectedMesh?: { id: string; positions: number[] } | null;
@@ -368,7 +370,7 @@ function planMenuItems(
// [26] Umriss-Element: Ecke am Klick einfügen bzw. die getroffene Ecke löschen (mindestens drei bleiben).
const ring = a.selectedRing;
if (ring) {
for (const { pts, off, closed = true } of ring.rings) {
for (const { pts, off, closed = true, bulge } of ring.rings) {
const geom = { pts, closed };
const hit = nearestPolylineTarget(geom, model, toleranceFor(geom));
if (!hit) continue;
@@ -379,6 +381,16 @@ function planMenuItems(
onClick: () => a.insertRingVertex?.(ring.kind, ring.id, off + hit.segIndex, hit.at),
});
}
// [191] Kante gerade ↔ Bogen (Decke, Raum, Dach, Baugrube); die Pfeilhöhe danach am Scheitel-Griff.
const arcKind = ring.kind === "polyline" || ring.kind === "contours" ? null : ring.kind;
const toggle = hit.kind === "segment" && closed && arcKind ? edgeArcToggle(pts, bulge, hit.segIndex) : null;
if (toggle && arcKind && a.setRingArc && hit.kind === "segment") {
pointItems.push({
label: t(toggle.toArc ? "ctx.edgeToArc" : "ctx.edgeStraight"),
icon: <MenuIcon name={toggle.toArc ? "line_curve" : "horizontal_rule"} />,
onClick: () => a.setRingArc?.(arcKind, ring.id, off + hit.segIndex, toggle.pt),
});
}
if (hit.kind === "vertex" && a.deleteRingVertex) {
const enabled = pts.length > (closed ? 3 : 2);
pointItems.push({