[144] Öffnungen verschieben: Griff-Zug und Objekt-Info über den Kern (Bogenwand, Nachbaröffnung), Hinweise, vitest
This commit is contained in:
14 files changed
+118
-55
No files matched your search
@@ -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),
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user