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

# Conflicts:
#	src/state/useSelectionCommands.ts
This commit is contained in:
Claude committed 2026-11-11 23:02:11 +00:00
commit b980bf7e52
21 files changed
+695 -138

No files matched your search

+1 -1
View File
@@ -74,7 +74,7 @@ export { drawingVertices, gripPt, openEdges, polylineEdgeGrips, ringEdges } from
export { verticalExtents } from "../geometry/grips";
export type { VerticalExtent } from "../geometry/grips";
export type { GripRequest, RingKind } from "../geometry/grips";
export { clampInside, coincidentGripPoints, excavationGripPoints, gripArcWallRadius, gripArcWallResize, gripArcWallTarget, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, sheetHeightDrag, stairMoveHandle, stairParamPoints, wallGripPoints } from "../geometry/gripDrag";
export { clampInside, coincidentGripPoints, excavationGripPoints, gripArcWallRadius, gripArcWallResize, gripArcWallTarget, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, sheetHeightDrag, snapSheetHeight, stairMoveHandle, stairParamPoints, wallGripPoints } from "../geometry/gripDrag";
export type { EdgeDrive, GripLocks, SheetHeightKind } from "../geometry/gripDrag";
export { openingPreviewProject, openingPreviewSvgs } from "../plan/openingPreview";
export type { OpeningPreviewSvgs } from "../plan/openingPreview";
+12 -4
View File
@@ -14,6 +14,7 @@ import {
openingSheetSlide,
openingTypedPosition,
sheetHeightDrag,
snapSheetHeight,
wallGripPoints,
} from "./gripDrag";
@@ -44,10 +45,17 @@ describe("Griff-Zug (Kern)", () => {
expect(gripEdgeTarget(free, { x: 3.2, y: 1.4 }, { shift: true })).toEqual({ x: 3.2, y: 1 });
});
it("Höhen-Griffe: Patch je Art", () => {
expect(sheetHeightDrag("wallTop", { base: 3, top: 5.6, bottom: 3 }, 5.7349, false)).toEqual({ top: 5.73, bottom: 3, patch: { height: 2.73 } });
const r = sheetHeightDrag("openingBottom", { base: 0, top: 2.1, bottom: 0.9 }, 0.6, false);
expect(r.patch).toEqual({ sillHeight: 0.6, height: 1.5 });
it("Höhen-Griffe: Vorschau je Art, Fang", () => {
expect(sheetHeightDrag("wallTop", { base: 3, top: 5.6, bottom: 3 }, 5.7349, false)).toEqual({ top: 5.73, bottom: 3 });
expect(sheetHeightDrag("openingBottom", { base: 0, top: 2.1, bottom: 0.9 }, 0.6, false)).toEqual({ top: 2.1, bottom: 0.6 });
// Decke: OK schiebt die Platte, bei gebundener UK ändert sie die Dicke; UK ändert die Dicke.
const slab = { base: 0, top: 2.6, bottom: 2.35 };
expect(sheetHeightDrag("ceilingTop", slab, 2.8, false)).toEqual({ top: 2.8, bottom: 2.55 });
expect(sheetHeightDrag("ceilingTop", { ...slab, bottomFixed: true }, 2.8, false)).toEqual({ top: 2.8, bottom: 2.35 });
expect(sheetHeightDrag("ceilingBottom", slab, 2.2, false)).toEqual({ top: 2.6, bottom: 2.2 });
expect(sheetHeightDrag("wallBottom", { base: 0, top: 2.6, bottom: 0 }, -0.5, false)).toEqual({ top: 2.6, bottom: -0.5 });
expect(snapSheetHeight(2.63, [0, 2.6, 3], 0.05)).toBe(2.6);
expect(snapSheetHeight(2.8, [0, 2.6, 3], 0.05)).toBe(2.8);
});
it("Öffnung entlang der Wand und im Schnitt", () => {
+17 -9
View File
@@ -108,23 +108,31 @@ export function gripEdgeTarget(edge: EdgeGrip, raw: Vec2, d: EdgeDrive = {}): Ve
);
}
/** Art eines Höhen-Griffs im Schnitt/in der Ansicht. */
export type SheetHeightKind = "wallTop" | "openingTop" | "openingBottom";
/** Art eines Höhen-Griffs im Schnitt/in der Ansicht ([187]; Index = `sheet_height::Kind` im Kern). */
export type SheetHeightKind = "wallTop" | "openingTop" | "openingBottom" | "wallBottom" | "ceilingTop" | "ceilingBottom";
const SHEET_KIND = { wallTop: 0, openingTop: 1, openingBottom: 2, wallBottom: 3, ceilingTop: 4, ceilingBottom: 6 } as const;
/**
* Höhen-Griff auf die Blatt-Höhe `y` ziehen (1-cm-Raster, `free` = ohne): neue Ober-/Unterkante im Blatt und
* der Patch fürs Bauteil (`height`, Fenster-Unterkante zusätzlich `sillHeight`; mm-genau).
* Höhen-Griff auf die Blatt-Höhe `y` ziehen (1-cm-Raster, `free` = ohne): neue Ober-/Unterkante im Blatt für die
* Vorschau (Mindestmasse im Kern). `base` = tiefste Brüstungskante (UK der Wand), `bottomFixed` = Decke mit
* gebundener Unterkante (OK ändert dann die Dicke statt die Platte zu verschieben). Die Änderung am Bauteil
* rechnet der Kern beim Loslassen (Griff-Anfrage `sheetHeight`).
*/
export function sheetHeightDrag(
kind: SheetHeightKind,
g: { base: number; top: number; bottom: number },
g: { base: number; top: number; bottom: number; bottomFixed?: boolean },
y: number,
free: boolean,
): { top: number; bottom: number; patch: Record<string, number> } {
const k = kind === "wallTop" ? 0 : kind === "openingTop" ? 1 : 2;
): { top: number; bottom: number } {
const k = kind === "ceilingTop" && g.bottomFixed ? 5 : SHEET_KIND[kind];
const f = core().grip_sheet_height(k, g.base, g.top, g.bottom, y, free);
const patch: Record<string, number> = kind === "openingBottom" ? { sillHeight: f[3], height: f[2] } : { height: f[2] };
return { top: f[0], bottom: f[1], patch };
return f.length ? { top: f[0], bottom: f[1] } : { top: g.top, bottom: g.bottom };
}
/** Fang einer Blatt-Höhe auf die nächste Kote aus `levels` innerhalb `tol` Metern. */
export function snapSheetHeight(y: number, levels: readonly number[], tol: number): number {
return core().grip_snap_height(y, Float64Array.from(levels), tol);
}
/**
+3
View File
@@ -13,6 +13,7 @@ import { core } from "../engine/coreWasm";
import { toMarkedJson } from "../core/ops";
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
import { textFrameCorners } from "../text/textFrame";
import type { SheetHeightKind } from "./gripDrag";
/** Punkt als `[x, y]` (Anfragen an den Kern). */
type P = [number, number];
@@ -50,6 +51,8 @@ export type GripRequest =
| { op: "insertPoint"; id: string; seg: number; pt: P }
| { op: "deletePoint"; id: string; index: number }
| { op: "vertexType"; id: string; index: number; vertexType: "corner" | "arc" | "spline" }
// [187] Höhen-Griff im Schnitt/in der Ansicht: Kante `kind` auf die Blatt-Höhe `a` (absolutes Z) ziehen (Kern `sheet_height.rs`).
| { op: "sheetHeight"; kind: SheetHeightKind; id: string; a: number; free?: boolean; newId: string; newName: string }
| { op: "wallThickness" | "ceilingThickness"; id: string; thickness: number; newId: string; newName: string }
// [144] Wandöffnung gleiten lassen (Kern `opening_slide`): Griff-Zug nach `pt` bzw. Position `a` ab Wandanfang.
| { op: "openingSlide"; id: string; pt: P }
+2
View File
@@ -2320,6 +2320,8 @@ export const de = {
"edit.cutSegment.label": "Segment löschen",
// Tab-Feld-Zyklus (Präzisionseingabe): geordnete Zahlenfelder je Schritt.
"cmd.field.length": "Länge",
"cmd.field.level": "Kote",
"grip.sheetHeight": "Kote {z} m · Höhe {d} m",
"cmd.field.angle": "Winkel",
"cmd.field.width": "Breite",
"cmd.field.height": "Höhe",
+2
View File
@@ -2308,6 +2308,8 @@ export const en: Record<TranslationKey, string> = {
"edit.cutSegment.label": "Delete segment",
// Tab field cycle (precision input): ordered numeric fields per step.
"cmd.field.length": "Length",
"cmd.field.level": "Level",
"grip.sheetHeight": "Level {z} m · height {d} m",
"cmd.field.angle": "Angle",
"cmd.field.width": "Width",
"cmd.field.height": "Height",
+14 -1
View File
@@ -63,7 +63,7 @@ import { reorderByIds } from "../model/reorder";
import { transformMutation } from "../tools/transform";
import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform";
import { uniqueId } from "../tools/types";
import { gripPt, type GripRequest, type RingKind } from "../core";
import { gripPt, type GripRequest, type RingKind, type SheetHeightKind } from "../core";
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
import { DEFAULT_PRESETS, type TextStylePreset } from "../text/richText";
import { t } from "../i18n";
@@ -420,6 +420,8 @@ export interface ProjectSlice {
) => void;
/** Setzt die Gesamtdicke einer Decke (thickness-Übersteuerung, Meter). */
setCeilingThickness: (ceilingId: string, thickness: number) => void;
/** [187] Höhen-Griff im Schnitt/in der Ansicht: Kante `kind` des Bauteils `id` auf die Blatt-Höhe `y` (absolutes Z) ziehen. */
sheetHeightGrip: (kind: SheetHeightKind, id: string, y: number, free?: boolean) => void;
// ── Öffnungs-Editieren (Object-Info-Panel) ────────────────────────────────
/** Generischer immutabler Patch auf eine Öffnung (per ID). */
@@ -1310,6 +1312,17 @@ export function createProjectSlice(
newName: t("default.ceilingTypeSingle", { thickness: thickness.toFixed(2) }),
}),
sheetHeightGrip: (kind, id, y, free) =>
applyGrip({
op: "sheetHeight",
kind,
id,
a: y,
free: !!free,
newId: `ct-${Date.now()}`,
newName: t("default.ceilingTypeSingle", { thickness: "{t}" }), // {t} setzt der Kern ein
}),
// ── Öffnungs-Editieren ────────────────────────────────────────────────
updateOpening: (id, patch) => applyChange((p) => patchItem(p, "openings", id, patch)),
slideOpening: (id, to, coalesceKey) =>
+18 -1
View File
@@ -5,7 +5,8 @@
import { core, coreEpoch, coreReady } from "../engine/coreWasm";
import { getState } from "./appStore";
import { storeDocument } from "./historySlice";
import { computeSection, generatePlan, generateSectionPlan, pickGeometry, projectToModel3d } from "../core";
import { ceilingThickness } from "../model/types";
import { computeSection, generatePlan, verticalExtents, generateSectionPlan, pickGeometry, projectToModel3d } from "../core";
import { getViewStateBridge } from "./viewTabs";
import { getView3dFilter, toFilter3d } from "./view3dFilter";
@@ -27,6 +28,12 @@ declare global {
selected: () => { drawings: string[]; groups: string[]; all: string };
/** [144] Öffnungen (id, Wirtswand, Lage ab Wandanfang). */
openings: () => { id: string; hostWallId: string; position: number }[];
/** [187] Höhen von Decken (UK/OK/Dicke), Wänden (UK/OK) und Fenstern (Brüstung/Höhe) aus dem Kern, in Metern (absolutes Z). */
heights: () => {
ceilings: { id: string; zBottom: number; zTop: number; thickness: number }[];
walls: { id: string; zBottom: number; zTop: number }[];
openings: { id: string; sillHeight: number; height: number }[];
};
/** [144] Auswahl setzen (wie ein Klick), z. B. `{ openings: ["D1"] }`. */
select: (patch: Record<string, string[]>) => void;
/** [144] Punkte einer Bemassung (Kette) — folgt sie der Öffnung? */
@@ -76,6 +83,16 @@ export function installTestHooks(): void {
polylines: (prefix) =>
getState().project.drawings2d.flatMap((d) => (d.id.startsWith(prefix) && d.geom.shape === "polyline" ? [{ id: d.id, pts: d.geom.pts }] : [])),
openings: () => (getState().project.openings ?? []).map((o) => ({ id: o.id, hostWallId: o.hostWallId, position: o.position })),
heights: () => {
const p = getState().project;
const ceilings = p.ceilings ?? [];
const ext = verticalExtents(p, p.walls, ceilings);
return {
ceilings: ceilings.map((c, i) => ({ id: c.id, zBottom: ext.ceilings[i].zBottom, zTop: ext.ceilings[i].zTop, thickness: ceilingThickness(p, c) })),
walls: p.walls.map((w, i) => ({ id: w.id, zBottom: ext.walls[i].zBottom, zTop: ext.walls[i].zTop })),
openings: (p.openings ?? []).map((o) => ({ id: o.id, sillHeight: o.sillHeight, height: o.height })),
};
},
select: (patch) => getState().setSelection(patch),
dimPts: (id) => {
const g = getState().project.drawings2d.find((d) => d.id === id)?.geom;
+105 -42
View File
@@ -5,10 +5,11 @@
//
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { useRef, useState, type RefObject } from "react";
import { useRef, useState, useSyncExternalStore, type RefObject } from "react";
import { useEventBundle, useSameData } from "./useEvent";
import { leftNormal, normalize, scale, sub, wallCorners } from "../model/geometry";
import type { RingKind } from "../core";
import type { RingKind, SheetHeightKind } from "../core";
import { t } from "../i18n";
import type { Ceiling, Drawing2D, EdgeGrip, Excavation, Project, Roof, Room, Vec2, Wall } from "../model/types";
import { wallTypeThickness } from "../model/types";
import { bulgeArcPoints, drawingVertices, surfaceOpeningGripPatch, surfaceOpeningGrips, surfaceOpeningInfo, wallArcBand } from "../core";
@@ -28,6 +29,7 @@ import {
openingSheetSlide,
openingTypedPosition,
sheetHeightDrag,
snapSheetHeight,
stairMoveHandle,
stairParamPoints,
wallGripPoints,
@@ -37,13 +39,13 @@ import { areaMovePreview, drawingMovePreview } from "../tools/transform";
import type { DraftShape, SnapResult, SnapSettings, ToolDraft, ToolMods } from "../tools/types";
import { computeSnap } from "../tools/snapping";
import { useCommandTabShortcut } from "./useKeyboardShortcuts";
import { sheetOwnerOutlines } from "../tools/sheetSnapGeometry";
import { sheetOutlinesVersion, sheetOwnerOutlines, subscribeSheetOutlines } from "../tools/sheetSnapGeometry";
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 { patchItem, verticalExtents } from "../core";
import { treeGripPatch, treeGripPoints } from "./treeGrips";
import type { Selection } from "./selection";
@@ -105,8 +107,8 @@ export function useGripEditing(opts: {
updateOpening: (id: string, patch: Record<string, unknown>) => void;
/** [144] Wandöffnung gleiten lassen (Kern: Wand, Bogenwand, Nachbaröffnungen). */
slideOpening: (id: string, to: { position: number } | { pt: Vec2 }, coalesceKey?: string) => void;
/** Wand ändern (Höhen-Griff im Schnitt); `coalesceKey` fasst einen Zug zu EINEM Undo-Schritt. */
updateWall: (id: string, patch: Partial<import("../model/types").Wall>, coalesceKey?: string) => void;
/** [187] Höhen-Griff im Schnitt/in der Ansicht anwenden (Kern `sheet_height.rs`); EIN Aufruf je Zug. */
sheetHeightGrip: (kind: SheetHeightKind, id: string, y: number, free?: boolean) => void;
moveStairBy: (id: string, delta: Vec2) => void;
/** [151] Parameter-Griff einer Podesttreppe ziehen (Index ohne den Bewegpunkt). */
dragStairParam?: (id: string, index: number, pt: Vec2) => void;
@@ -164,7 +166,7 @@ export function useGripEditing(opts: {
commandLineRef,
updateOpening,
slideOpening,
updateWall,
sheetHeightGrip,
moveStairBy,
moveRoomGrip,
moveCeilingGrip,
@@ -178,6 +180,8 @@ export function useGripEditing(opts: {
moveCeilingBy,
moveElementByOf,
} = opts;
// [187] Die Höhen-Griffe stehen an den gezeichneten Umrissen des Schnitts, die sich asynchron erneuern.
useSyncExternalStore(subscribeSheetOutlines, sheetOutlinesVersion);
const selectedOpeningId = single(selection, "openings");
const selectedStairId = single(selection, "stairs");
// [149] Baum: Griff in der Stammmitte (verschieben) und am Kronenrand (Kronendurchmesser).
@@ -268,7 +272,7 @@ export function useGripEditing(opts: {
// an Ober- und Unterkante (Höhe bzw. Brüstung, Oberkante bleibt stehen); Tür nur oben.
// Alles in Blatt-Koordinaten (u, Höhe über ±0.00). Projekt erst beim Loslassen.
type SheetHeightGrip = {
kind: "wallTop" | "openingTop" | "openingBottom";
kind: SheetHeightKind;
id: string;
pt: Vec2;
u0: number;
@@ -276,10 +280,15 @@ export function useGripEditing(opts: {
base: number;
top: number;
bottom: number;
/** Decke mit gebundener Unterkante: die Oberkante ändert dann die Dicke statt die Platte zu verschieben. */
bottomFixed?: boolean;
};
// [187] Höhen-Griffe im Schnitt/in der Ansicht: Wand (Ober-/Unterkante), Öffnung (Brüstung, Sturz), Decke (Ober-/
// Unterkante). Breite (u, entlang der Schnittlinie) aus den gezeichneten Umrissen, Höhen (v) aus dem Modell; die
// Änderung am Bauteil rechnet der Kern beim Loslassen (`sheetHeight`). Gesperrte Bauteile haben keine.
const sheetHeightGrips: SheetHeightGrip[] = (() => {
if (modelEditable || !sheet) return [];
const bbox = (kind: "wall" | "opening", id: string) => {
const bbox = (kind: "wall" | "opening" | "ceiling", id: string) => {
const polys = sheetOwnerOutlines(sheet.levelId, kind, id);
if (polys.length === 0) return null;
let u0 = Infinity, u1 = -Infinity, v0 = Infinity, v1 = -Infinity;
@@ -289,28 +298,45 @@ export function useGripEditing(opts: {
}
return { u0, u1, v0, v1 };
};
const floorBase = (floorId: string) => project.drawingLevels.find((l) => l.id === floorId)?.baseElevation ?? 0;
// Höhen aus dem Modell (nicht aus den gezeichneten Umrissen: ein von Fenstern oder Decken zerschnittener Rest
// reicht nicht von UK bis OK), nur die Breite (u) kommt aus dem Blatt.
if (selectedOpeningId) {
const op = (project.openings ?? []).find((o) => o.id === selectedOpeningId);
const w = op && project.walls.find((x) => x.id === op.hostWallId);
const bb = op && bbox("opening", op.id);
if (!op || !w || !bb || op.locked) return [];
const base = floorBase(w.floorId);
const base = verticalExtents(project, [w]).walls[0].zBottom;
const bottom = base + Math.max(0, op.sillHeight || 0);
const top = bottom + op.height;
const mid = (bb.u0 + bb.u1) / 2;
const out: SheetHeightGrip[] = [
{ kind: "openingTop", id: op.id, pt: { x: mid, y: bb.v1 }, u0: bb.u0, u1: bb.u1, base, top: bb.v1, bottom: bb.v0 },
];
if (op.kind === "window") {
out.push({ kind: "openingBottom", id: op.id, pt: { x: mid, y: bb.v0 }, u0: bb.u0, u1: bb.u1, base, top: bb.v1, bottom: bb.v0 });
}
const common = { id: op.id, u0: bb.u0, u1: bb.u1, base, top, bottom };
const out: SheetHeightGrip[] = [{ kind: "openingTop", pt: { x: mid, y: top }, ...common }];
if (op.kind === "window") out.push({ kind: "openingBottom", pt: { x: mid, y: bottom }, ...common });
return out;
}
if (selectedWallId && selectedWallIds.length <= 1) {
const w = project.walls.find((x) => x.id === selectedWallId);
const bb = w && bbox("wall", w.id);
if (!w || !bb || w.locked) return [];
const { zBottom, zTop } = verticalExtents(project, [w]).walls[0];
const mid = (bb.u0 + bb.u1) / 2;
const common = { id: w.id, u0: bb.u0, u1: bb.u1, base: zBottom, top: zTop, bottom: zBottom };
return [
{ kind: "wallTop", id: w.id, pt: { x: (bb.u0 + bb.u1) / 2, y: bb.v1 }, u0: bb.u0, u1: bb.u1, base: floorBase(w.floorId), top: bb.v1, bottom: bb.v0 },
{ kind: "wallTop", pt: { x: mid, y: zTop }, ...common },
{ kind: "wallBottom", pt: { x: mid, y: zBottom }, ...common },
];
}
if (selectedCeilingId) {
const c = (project.ceilings ?? []).find((x) => x.id === selectedCeilingId);
const bb = c && bbox("ceiling", c.id);
if (!c || !bb || c.locked) return [];
const { zBottom, zTop } = verticalExtents(project, [], [c]).ceilings[0];
// Dünne Platte: die zwei Griffe sitzen nebeneinander (Drittelspunkte), nicht übereinander.
const at = (f: number) => bb.u0 + (bb.u1 - bb.u0) * f;
const common = { id: c.id, u0: bb.u0, u1: bb.u1, base: zBottom, top: zTop, bottom: zBottom, bottomFixed: !!c.bottom };
return [
{ kind: "ceilingTop", pt: { x: at(1 / 3), y: zTop }, ...common },
{ kind: "ceilingBottom", pt: { x: at(2 / 3), y: zBottom }, ...common },
];
}
return [];
@@ -671,8 +697,10 @@ export function useGripEditing(opts: {
const pendingWallMoveRef = useRef<{ wallId: string; total: Vec2 } | null>(null);
/** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */
const pendingOpeningMoveRef = useRef<{ id: string; position: number } | null>(null);
/** Aufgeschobene Höhen-Änderung im Schnitt (Wand `height` bzw. Öffnung `height`/`sillHeight`). */
const pendingSheetHeightRef = useRef<{ kind: "wall" | "opening"; id: string; patch: Record<string, number> } | null>(null);
/** Aufgeschobene Höhen-Änderung im Schnitt (Kante `kind` auf die Höhe `y`, Kern `sheetHeight`). */
const pendingSheetHeightRef = useRef<{ kind: SheetHeightKind; id: string; y: number; free: boolean } | null>(null);
/** [187] Kote der gezogenen Kante im laufenden Höhen-Zug (Tab-Feld „Kote“). */
const sheetDragRef = useRef<{ z: number } | null>(null);
/** Laufendes Blatt-Delta (u, Meter) eines Zugs im Schnitt (s. moveInSheet). */
const sheetDuRef = useRef<{ id: string; du: number } | null>(null);
const pendingBodyRef = useRef<{ drawingId: string; total: Vec2 } | null>(null);
@@ -712,6 +740,11 @@ export function useGripEditing(opts: {
const ge = gripEdit;
const info = gripDragInfoRef.current;
if (!ge || !info) return [];
// [187] Höhen-Zug im Schnitt: ein Feld, die Kote der gezogenen Kante (m, absolutes Z).
if (!modelEditable && sheet) {
const live = sheetDragRef.current?.z ?? 0;
return [{ id: "length", labelKey: "cmd.field.level", value: ge.locks.length ?? live, locked: ge.locks.length != null, active: true }];
}
const apex = arcWallApex(info.index);
if (apex) {
const live = gripArcWallRadius(apex, gripFreeRef.current, undefined, info.raw)?.radius ?? 0;
@@ -802,6 +835,12 @@ export function useGripEditing(opts: {
const cycleGripEditField = () => {
const info = gripDragInfoRef.current;
if (!info) return;
if (!modelEditable && sheet) {
// [187] Höhen-Zug: Tab friert die Kote ein (danach zählt nur der getippte Wert, Maus wirkt nicht mehr).
const z = sheetDragRef.current?.z;
if (z != null) setGripEdit((prev) => prev ?? { anchor: { x: 0, y: 0 }, active: "length", locks: { length: z } });
return;
}
const anchor = resolveGripAnchor(info.index);
if (!anchor) return; // ohne Anker keine polare Eingabe möglich
const wallDir = openingWallDir();
@@ -851,6 +890,11 @@ export function useGripEditing(opts: {
const ge = gripEditRef.current;
const info = gripDragInfoRef.current;
if (!ge || !info) return;
if (!modelEditable && sheet) {
setGripEdit({ ...ge, locks: { length: value } });
applySheetHeight(info.index, value, true);
return;
}
const locks = { ...ge.locks, [ge.active]: value };
const next = ge.active === "length" && !arcWallEnd(info.index) && !arcWallApex(info.index) ? "angle" : "length";
setGripEdit({ ...ge, locks, active: next });
@@ -1156,10 +1200,7 @@ export function useGripEditing(opts: {
const commitPendingGripChanges = () => {
const ph = pendingSheetHeightRef.current;
pendingSheetHeightRef.current = null;
if (ph) {
if (ph.kind === "wall") updateWall(ph.id, ph.patch as Partial<import("../model/types").Wall>);
else updateOpening(ph.id, ph.patch);
}
if (ph) sheetHeightGrip(ph.kind, ph.id, ph.y, ph.free);
const pa = pendingAreaGripRef.current;
pendingAreaGripRef.current = null;
if (pa) {
@@ -1334,6 +1375,8 @@ export function useGripEditing(opts: {
pendingAreaMoveRef.current = null;
pendingWallMoveRef.current = null;
pendingOpeningMoveRef.current = null;
pendingSheetHeightRef.current = null;
sheetDragRef.current = null;
sheetDuRef.current = null;
pendingBodyRef.current = null;
pendingEdgeRef.current = null;
@@ -1417,28 +1460,48 @@ export function useGripEditing(opts: {
setDraft({ preview, vertices: [], snap: null });
};
/**
* [187] Höhen-Zug anwenden: nur Vorschau und HUD (das Projekt ändert sich beim Loslassen, EIN Undo-Schritt).
* `y` = Blatt-Höhe (absolutes Z); `free` ohne 1-cm-Raster.
*/
const applySheetHeight = (index: number, y: number, free: boolean, snapResult: SnapResult | null = null) => {
const g = sheetHeightGrips[index];
if (!g) return;
const { top, bottom } = sheetHeightDrag(g.kind, g, y, free);
const z = g.kind.endsWith("Top") ? top : bottom;
pendingSheetHeightRef.current = { kind: g.kind, id: g.id, y, free };
sheetDragRef.current = { z };
setDraft({
preview: [{
kind: "poly",
pts: [{ x: g.u0, y: bottom }, { x: g.u1, y: bottom }, { x: g.u1, y: top }, { x: g.u0, y: top }],
closed: true,
}],
vertices: [],
snap: snapResult,
hud: { at: { x: g.pt.x, y: z }, text: t("grip.sheetHeight", { z: z.toFixed(2), d: (top - bottom).toFixed(2) }) },
});
};
const gripHandlers = {
onGripMove: (index: number, raw: Vec2, pxPerMeter: number, mods: ToolMods) => {
sectionPxRef.current = pxPerMeter;
// Schnitt/Ansicht: Höhen-Griff (Wand-Oberkante, Fenster Ober-/Unterkante).
// Schnitt/Ansicht ([187]): Höhen-Griff (Wand, Öffnung, Decke).
if (!modelEditable && sheet) {
const g = sheetHeightGrips[index];
if (!g) return;
// 1-cm-Raster, Strg = frei; Mindestmasse und mm-Rundung im Kern (`sheetHeightDrag`).
const { top: newTop, bottom: newBottom, patch } = sheetHeightDrag(g.kind, g, raw.y, !!mods.ctrl);
pendingSheetHeightRef.current = { kind: g.kind === "wallTop" ? "wall" : "opening", id: g.id, patch };
const bottom = g.kind === "wallTop" ? g.bottom : newBottom;
setDraft({
preview: [{
kind: "poly",
pts: [{ x: g.u0, y: bottom }, { x: g.u1, y: bottom }, { x: g.u1, y: newTop }, { x: g.u0, y: newTop }],
closed: true,
}],
vertices: [],
snap: null,
hud: { at: { x: (g.u0 + g.u1) / 2, y: g.kind === "openingBottom" ? newBottom : newTop }, text: `${(newTop - bottom).toFixed(2)} m` },
});
return;
gripDragInfoRef.current = { index, raw };
const typed = gripEditRef.current?.locks.length; // Tab: getippte Kote
if (typed != null) return applySheetHeight(index, typed, true);
if (mods.ctrl) return applySheetHeight(index, raw.y, true);
// Fang: erst Geschoss-Koten, dann Geometrie des Schnitts (Kanten, Ecken, Höhenkoten), sonst 1-cm-Raster.
const tol = 8 / Math.max(pxPerMeter, 1e-9);
const levels = project.drawingLevels.flatMap((l) =>
l.kind === "floor" ? [l.baseElevation ?? 0, (l.baseElevation ?? 0) + (l.floorHeight ?? 0)] : [],
);
const lv = snapSheetHeight(raw.y, levels, tol);
if (lv !== raw.y) return applySheetHeight(index, lv, true);
const sn = snapFor(raw, pxPerMeter, mods);
const geo = !!sn && sn.kind !== "grid" && sn.kind !== "ortho";
return applySheetHeight(index, geo ? sn!.point.y : raw.y, geo, geo ? sn : null);
}
// Erster Move-Event nach dem Grab (gripDragInfoRef noch leer): die
// AKTUELLE — hier noch unveränderte — Position als Flucht-Bezugspunkt
+2
View File
@@ -384,6 +384,7 @@ export function useProjectActions(
const moveCeilingEdge = useStore((s) => s.moveCeilingEdge);
const updateCeiling = useStore((s) => s.updateCeiling);
const setCeilingThickness = useStore((s) => s.setCeilingThickness);
const sheetHeightGrip = useStore((s) => s.sheetHeightGrip);
const updateStair = useStore((s) => s.updateStair);
const moveStairBy = useStore((s) => s.moveStairBy);
const dragStairParam = useStore((s) => s.dragStairParam);
@@ -508,6 +509,7 @@ export function useProjectActions(
moveCeilingEdge,
updateCeiling,
setCeilingThickness,
sheetHeightGrip,
updateStair,
moveStairBy,
dragStairParam,
+16 -1
View File
@@ -14,6 +14,20 @@ const byLevel = new Map<string, SnapSeg[]>();
/** Je Ebene: Umriss-Polygone je Bauteil (`wall:<id>` / `ceiling:<id>`) — Vorschau beim Ziehen im Schnitt. */
const outlinesByLevel = new Map<string, Map<string, Vec2[][]>>();
// [187] Die Umrisse ändern sich asynchron (der Schnitt rechnet nach Undo/Änderung neu): Höhen-Griffe, die daraus stehen,
// müssen mitziehen — Version + Abo für `useSyncExternalStore`.
let outlinesVersion = 0;
const outlineListeners = new Set<() => void>();
const bumpOutlines = () => {
outlinesVersion++;
outlineListeners.forEach((l) => l());
};
export function subscribeSheetOutlines(l: () => void): () => void {
outlineListeners.add(l);
return () => void outlineListeners.delete(l);
}
export const sheetOutlinesVersion = (): number => outlinesVersion;
/** Strecken der Ebene `levelId` setzen (leeres Array/`null` = entfernen). */
export function setSheetSnapSegments(levelId: string, segs: SnapSeg[] | null): void {
if (!segs || segs.length === 0) byLevel.delete(levelId);
@@ -68,7 +82,7 @@ export type SheetOwnerKind = "wall" | "ceiling" | "opening" | "stair";
*/
export function setSheetOwnerOutlines(levelId: string, prims: readonly Primitive[] | null): void {
if (!prims) {
outlinesByLevel.delete(levelId);
if (outlinesByLevel.delete(levelId)) bumpOutlines();
return;
}
const map = new Map<string, Vec2[][]>();
@@ -85,6 +99,7 @@ export function setSheetOwnerOutlines(levelId: string, prims: readonly Primitive
else if (p.ceilingId) add(`ceiling:${p.ceilingId}`, p.pts);
}
outlinesByLevel.set(levelId, map);
bumpOutlines();
}
/** Schnittflächen eines Bauteils im Blatt der Ebene `levelId` (leer, wenn nicht geschnitten). */
+1 -1
View File
@@ -136,7 +136,7 @@ export function ViewportCenter(props: {
commandLineRef,
updateOpening: pa.updateOpening,
slideOpening: pa.slideOpening,
updateWall: pa.updateWall,
sheetHeightGrip: pa.sheetHeightGrip,
moveStairBy: pa.moveStairBy,
dragStairParam: pa.dragStairParam,
moveRoomGrip: pa.moveRoomGrip,