[144] Öffnungen verschieben: Griff-Zug und Objekt-Info über den Kern (Bogenwand, Nachbaröffnung), Hinweise, vitest

This commit is contained in:
Claude committed 2026-11-06 07:38:23 +00:00
1 parent 8d916a290c
commit c77a57b9bb
14 files changed
+118 -55

No files matched your search

+3
View File
@@ -1028,6 +1028,7 @@ export default function App() {
updateWall,
setWallThickness,
updateOpening,
slideOpening,
moveCeilingGrip,
moveExcavationGrip,
moveExcavationEdge,
@@ -1132,6 +1133,7 @@ export default function App() {
engineRef,
commandLineRef,
updateOpening,
slideOpening,
updateWall,
moveStairBy,
moveRoomGrip,
@@ -1973,6 +1975,7 @@ export default function App() {
updateWall,
setWallThickness,
updateOpening,
slideOpening,
updateCeiling,
setCeilingThickness,
updateStair,
+1 -1
View File
@@ -72,7 +72,7 @@ export { drawingVertices, gripPt, openEdges, polylineEdgeGrips, ringEdges } from
export { verticalExtents } from "../geometry/grips";
export type { VerticalExtent } from "../geometry/grips";
export type { GripRequest } from "../geometry/grips";
export { coincidentGripPoints, excavationGripPoints, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingSlidePosition, sheetHeightDrag, stairMoveHandle, wallGripPoints } from "../geometry/gripDrag";
export { coincidentGripPoints, excavationGripPoints, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, sheetHeightDrag, stairMoveHandle, wallGripPoints } from "../geometry/gripDrag";
export type { EdgeDrive, GripLocks, SheetHeightKind } from "../geometry/gripDrag";
export { openingPreviewProject, openingPreviewSvgs } from "../plan/openingPreview";
export type { OpeningPreviewSvgs } from "../plan/openingPreview";
+4 -3
View File
@@ -9,7 +9,6 @@ import {
gripPolarPoint,
openingGripPoint,
openingSheetSlide,
openingSlidePosition,
sheetHeightDrag,
wallGripPoints,
} from "./gripDrag";
@@ -49,8 +48,10 @@ describe("Griff-Zug (Kern)", () => {
it("Öffnung entlang der Wand und im Schnitt", () => {
expect(openingGripPoint(wall, { position: 1, width: 1.2 })).toEqual({ x: 1.6, y: 0 });
expect(openingSlidePosition(wall, { width: 1.2 }, { x: 2.6, y: 3 })).toBe(2);
expect(openingSlidePosition({ start: wall.start, end: wall.start }, { width: 1.2 }, { x: 1, y: 0 })).toBeNull();
// Bogenwand (Halbkreis, Radius 2.5): Mitte bei der Bogenlänge 2.5·π/2 liegt im Scheitel.
const g = openingGripPoint({ ...wall, bulge: 1 }, { position: 2.5 * Math.PI / 2 - 0.6, width: 1.2 });
expect(g.x).toBeCloseTo(2.5, 9);
expect(Math.abs(g.y)).toBeCloseTo(2.5, 9);
expect(openingSheetSlide(wall, { position: 1, width: 1.2 }, { x: -1, y: 0 }, 0.5)).toEqual({ position: 0.5, du: 0.5 });
expect(openingSheetSlide(wall, { position: 1, width: 1.2 }, { x: 0.1, y: 0.995 }, 1)).toBeNull();
});
+6 -9
View File
@@ -96,15 +96,12 @@ export function sheetHeightDrag(
return { top: f[0], bottom: f[1], patch };
}
/** Mittelpunkt-Griff einer Öffnung auf der Achse ihrer Wirtswand. */
export function openingGripPoint(w: Pick<Wall, "start" | "end">, op: Pick<Opening, "position" | "width">): Vec2 {
return v(core().grip_opening_point(w.start.x, w.start.y, w.end.x, w.end.y, op.position, op.width));
}
/** Neue `position` beim Ziehen des Öffnungs-Griffs nach `pt` (auf die Wand geklemmt); null = Wand ohne Länge. */
export function openingSlidePosition(w: Pick<Wall, "start" | "end">, op: Pick<Opening, "width">, pt: Vec2): number | null {
const f = core().grip_opening_slide(w.start.x, w.start.y, w.end.x, w.end.y, op.width, pt.x, pt.y);
return f.length ? f[0] : null;
/**
* Mittelpunkt-Griff einer Öffnung auf der Achse ihrer Wirtswand (Bogenwand [T2]: auf dem Bogen, `position`
* = Bogenlänge). Den Zug selbst rechnet der Kern (`slideOpening`, Griff-Anfrage `openingSlide`).
*/
export function openingGripPoint(w: Pick<Wall, "start" | "end" | "bulge">, op: Pick<Opening, "position" | "width">): Vec2 {
return v(core().grip_opening_point(w.start.x, w.start.y, w.end.x, w.end.y, w.bulge ?? 0, op.position, op.width));
}
/**
+4 -1
View File
@@ -31,7 +31,10 @@ 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" }
| { op: "wallThickness" | "ceilingThickness"; id: string; thickness: number; 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 }
| { op: "openingPosition"; id: string; a: number };
/** Punkt als Anfrage-Paar. */
export const gripPt = (p: Vec2): P => [p.x, p.y];
+2
View File
@@ -801,6 +801,8 @@ export const de = {
"objinfo.opening.slope": "Neigung der Fläche",
"objinfo.opening.position": "Position (ab Wandanfang)",
"objinfo.opening.positionEnd": "Abstand ab Wandende",
"opening.overlapClamped": "Öffnung hält vor der Nachbaröffnung an (Steg 5 cm).",
"opening.noRoom": "In der Zielwand ist kein Platz für die Öffnung.",
"objinfo.opening.width": "Breite",
"objinfo.opening.height": "Höhe",
"objinfo.opening.sill": "Brüstung",
+2
View File
@@ -800,6 +800,8 @@ export const en: Record<TranslationKey, string> = {
"objinfo.opening.slope": "Surface slope",
"objinfo.opening.position": "Position (from wall start)",
"objinfo.opening.positionEnd": "Distance from wall end",
"opening.overlapClamped": "Opening stops at the neighbouring opening (5 cm web).",
"opening.noRoom": "No room for the opening in the target wall.",
"objinfo.opening.width": "Width",
"objinfo.opening.height": "Height",
"objinfo.opening.sill": "Sill height",
+8
View File
@@ -403,6 +403,12 @@ export interface ProjectSlice {
id: string,
patch: Partial<import("../model/types").Opening>,
) => void;
/**
* [144] Wandöffnung in ihrer Wand verschieben (Kern `opening_slide`): auf `position` (ab Wandanfang,
* Bogenwand: Bogenlänge) bzw. zum Griff-Punkt `pt`; geklemmt auf die Wand und 5 cm vor der Nachbar-
* öffnung (mit Hinweis). `coalesceKey` fasst einen Griff-Zug zu einem Undo-Schritt.
*/
slideOpening: (id: string, to: { position: number } | { pt: Vec2 }, coalesceKey?: string) => void;
/**
* Immutable Änderung eines Dachs (Form/Neigung/Überstand/Firstrichtung/
@@ -1253,6 +1259,8 @@ export function createProjectSlice(
// ── Öffnungs-Editieren ────────────────────────────────────────────────
updateOpening: (id, patch) => applyChange((p) => patchItem(p, "openings", id, patch)),
slideOpening: (id, to, coalesceKey) =>
applyGrip("pt" in to ? { op: "openingSlide", id, pt: gripPt(to.pt) } : { op: "openingPosition", id, a: to.position }, coalesceKey),
// ── Dach-Editieren ─────────────────────────────────────────────────────
updateRoof: (id, patch, coalesceKey) => applyChange((p) => patchItem(p, "roofs", id, patch), coalesceKey),
+13 -8
View File
@@ -22,7 +22,6 @@ import {
gripPolarPoint,
openingGripPoint,
openingSheetSlide,
openingSlidePosition,
sheetHeightDrag,
stairMoveHandle,
wallGripPoints,
@@ -93,6 +92,8 @@ export function useGripEditing(opts: {
engineRef: RefObject<CommandEngine | null>;
commandLineRef: RefObject<CommandLineHandle | null>;
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;
moveStairBy: (id: string, delta: Vec2) => void;
@@ -143,6 +144,7 @@ export function useGripEditing(opts: {
engineRef,
commandLineRef,
updateOpening,
slideOpening,
updateWall,
moveStairBy,
moveRoomGrip,
@@ -385,9 +387,12 @@ export function useGripEditing(opts: {
if (!selectedOpeningId) return null;
const op = (project.openings ?? []).find((o) => o.id === selectedOpeningId);
const w = op && !op.hostRoofId && !op.hostCeilingId ? project.walls.find((x) => x.id === op.hostWallId) : undefined;
if (!w) return null;
const dx = w.end.x - w.start.x;
const dy = w.end.y - w.start.y;
if (!w || !op) return null;
// Sehne über die Öffnung (gerade Wand: Wandrichtung; Bogenwand: ≈ Tangente in der Öffnungsmitte).
const a = openingGripPoint(w, { position: op.position - op.width / 2, width: op.width });
const b = openingGripPoint(w, { position: op.position + op.width / 2, width: op.width });
const dx = b.x - a.x;
const dy = b.y - a.y;
const len = Math.hypot(dx, dy);
return len > 1e-9 ? { x: dx / len, y: dy / len } : null;
};
@@ -796,9 +801,9 @@ export function useGripEditing(opts: {
if (patch) updateOpening(op.id, patch);
return;
}
const w = op && project.walls.find((x) => x.id === op.hostWallId);
const pos = op && w ? openingSlidePosition(w, op, pt) : null;
if (op && pos != null) updateOpening(op.id, { position: pos });
// Wandöffnung ([144]): der Kern projiziert auf die Achse (Bogenwand: auf den Bogen), klemmt auf
// die Wand und hält vor der Nachbaröffnung an.
if (op && !op.locked) slideOpening(op.id, { pt }, `slideOpening:${op.id}`);
return;
}
// Treppe: den Bewegpunkt verfolgen → ganze Treppe um das Delta (Ziel −
@@ -959,7 +964,7 @@ export function useGripEditing(opts: {
}
const pom = pendingOpeningMoveRef.current;
pendingOpeningMoveRef.current = null;
if (pom) updateOpening(pom.id, { position: pom.position });
if (pom) slideOpening(pom.id, { position: pom.position });
const pa = pendingAreaMoveRef.current;
pendingAreaMoveRef.current = null;
if (pa && (pa.total.x !== 0 || pa.total.y !== 0)) {
+6 -4
View File
@@ -209,6 +209,7 @@ export function usePanelHostBase(opts: {
| "updateWall"
| "setWallThickness"
| "updateOpening"
| "slideOpening"
| "updateCeiling"
| "setCeilingThickness"
| "updateStair"
@@ -324,6 +325,7 @@ export function usePanelHostBase(opts: {
updateWall,
setWallThickness,
updateOpening,
slideOpening,
updateCeiling,
setCeilingThickness,
updateStair,
@@ -952,10 +954,10 @@ export function usePanelHostBase(opts: {
},
onSetOpeningPosition: (position) => {
if (selection?.kind !== "opening" || !Number.isFinite(position)) return;
// [144] In der Wand halten: auf [0, Wandlänge − Breite] klemmen (Bogenwand: nur ≥ 0).
const o = selection.opening;
const max = o?.wallLength != null ? Math.max(0, o.wallLength - o.width) : Infinity;
updateOpening(selection.id, { position: Math.min(max, Math.max(0, position)) });
// [144] Dach-/Deckenöffnung: Feld frei; Wandöffnung: der Kern klemmt auf [0, Wandlänge − Breite]
// (Bogenwand: Bogenlänge) und hält 5 cm vor der Nachbaröffnung an (mit Hinweis).
if (selection.opening?.wallLength == null) updateOpening(selection.id, { position: Math.max(0, position) });
else slideOpening(selection.id, { position });
},
onSetOpeningSwingAngle: (swingAngle) => {
if (selection?.kind === "opening" && swingAngle > 0)
+2
View File
@@ -372,6 +372,7 @@ export function useProjectActions(
const updateWall = useStore((s) => s.updateWall);
const setWallThickness = useStore((s) => s.setWallThickness);
const updateOpening = useStore((s) => s.updateOpening);
const slideOpening = useStore((s) => s.slideOpening);
const moveCeilingGrip = useStore((s) => s.moveCeilingGrip);
const moveExcavationGrip = useStore((s) => s.moveExcavationGrip);
const moveExcavationEdge = useStore((s) => s.moveExcavationEdge);
@@ -490,6 +491,7 @@ export function useProjectActions(
updateWall,
setWallThickness,
updateOpening,
slideOpening,
moveCeilingGrip,
moveExcavationGrip,
moveExcavationEdge,
+53
View File
@@ -3,6 +3,7 @@
import { describe, expect, it } from "vitest";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { transformMutation } from "./transform";
import { getState } from "../state/appStore";
describe("Öffnungen verschieben (Musterhaus komplex)", () => {
it("jede Wandöffnung gleitet entlang ihrer Wand", () => {
@@ -26,3 +27,55 @@ describe("Öffnungen verschieben (Musterhaus komplex)", () => {
}
});
});
// [144] Store-Fluss: Befehl (cmdMutation), Objekt-Info/Griff (`slideOpening`) — Bemassung folgt, Bogenwand,
// Nachbaröffnung mit Hinweis, Dachöffnung allein.
describe("Öffnungen verschieben (Store, Musterhaus komplex)", () => {
const load = () => getState().loadProject(buildComplexSampleProject());
const opening = (id: string) => getState().project.openings!.find((o) => o.id === id)!;
const dimPts = () => (getState().project.drawings2d.find((d) => d.id === "mass-fenster-eg")!.geom as { pts: { x: number }[] }).pts;
it("Bemassung auf die Leibungen folgt Befehl und Objekt-Info", () => {
load();
const x0 = dimPts()[0].x;
getState().setProject(transformMutation({ wallIds: [], drawingId: null, openingIds: ["eg-f1"] }, "move", [{ x: 0, y: 0 }, { x: 0.5, y: 0 }], "move", 1));
expect(opening("eg-f1").position).toBeCloseTo(2.1, 9);
expect(dimPts()[0].x).toBeCloseTo(x0 + 0.5, 9);
expect(dimPts()[1].x).toBeCloseTo(x0 + 0.5 + opening("eg-f1").width, 9);
getState().slideOpening("eg-f1", { position: 1 });
expect(dimPts()[0].x).toBeCloseTo(x0 - 0.6, 9);
getState().undo();
expect(dimPts()[0].x).toBeCloseTo(x0 + 0.5, 9);
});
it("Bogenwand: Lage = Bogenlänge, Anschlag an der Nachbaröffnung mit Hinweis", () => {
load();
const before = getState().notifications.length;
// Erker EG (Halbkreis r = 2): f5 bei 1.2 (1 m breit), f6 bei 3.6 — f5 hält bei 3.6 − 0.05 − 1 = 2.55.
getState().slideOpening("eg-f5", { position: 3 });
expect(opening("eg-f5").position).toBeCloseTo(2.55, 9);
expect(getState().notifications.length).toBe(before + 1);
expect(getState().notifications.at(-1)?.kind).toBe("warning");
getState().undo();
expect(opening("eg-f5").position).toBe(1.2);
// Griff-Zug ausserhalb des Scheitels (17, 5): Mitte auf der halben Bogenlänge π.
getState().slideOpening("eg-f6", { pt: { x: 17.4, y: 5 } });
expect(opening("eg-f6").position).toBeCloseTo(Math.PI - 0.5, 9);
// Weiter zum Anfang: f5 endet bei 2.2 → Anschlag bei 2.25.
getState().slideOpening("eg-f6", { pt: { x: 15, y: 3 } });
expect(opening("eg-f6").position).toBeCloseTo(2.25, 9);
// Befehl: f6 übers Bogenende hinaus → Bogenlänge 2π − Breite, gleiche Wand.
getState().setProject(transformMutation({ wallIds: [], drawingId: null, openingIds: ["eg-f6"] }, "move", [{ x: 17, y: 5 }, { x: 13, y: 9 }], "move", 1));
expect(opening("eg-f6").position).toBeCloseTo(2 * Math.PI - 1, 9);
expect(opening("eg-f6").hostWallId).toBe("eg-aw-erker");
});
it("Dach-/Deckenöffnung allein verschieben", () => {
load();
const o = (getState().project.openings ?? []).find((x) => (x.hostRoofId || x.hostCeilingId) && !x.locked);
expect(o).toBeDefined();
const hp = o!.hostPoint!;
getState().setProject(transformMutation({ wallIds: [], drawingId: null, openingIds: [o!.id] }, "move", [{ x: 0, y: 0 }, { x: 0.3, y: 0 }], "move", 1));
expect(opening(o!.id).hostPoint!.x).toBeCloseTo(hp.x + 0.3, 9);
});
});