[144] Öffnung in Bogenwand: Tab-Länge beim Griff und Zug im Schnitt-Blatt entlang des Bogens

This commit is contained in:
Claude committed 2026-11-06 09:06:51 +00:00
1 parent 5d9818d3cf
commit f4cad8b81c
7 files changed
+163 -17

No files matched your search

+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, sheetHeightDrag, stairMoveHandle, wallGripPoints } from "../geometry/gripDrag";
export { coincidentGripPoints, excavationGripPoints, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, 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";
+14
View File
@@ -9,6 +9,7 @@ import {
gripPolarPoint,
openingGripPoint,
openingSheetSlide,
openingTypedPosition,
sheetHeightDrag,
wallGripPoints,
} from "./gripDrag";
@@ -54,6 +55,19 @@ describe("Griff-Zug (Kern)", () => {
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();
// [144] Bogenwand im Schnitt: die Öffnungsmitte folgt dem Blatt-Delta auf dem Bogen (Bogenlänge > Blatt-Weg).
const arc = { ...wall, bulge: 1 };
const s = openingSheetSlide(arc, { position: 3, width: 1 }, { x: 1, y: 0 }, 0.4)!;
expect(s.du).toBeCloseTo(0.4, 6);
expect(openingGripPoint(arc, { position: s.position, width: 1 }).x - openingGripPoint(arc, { position: 3, width: 1 }).x).toBeCloseTo(0.4, 6);
expect(s.position - 3).toBeGreaterThan(0.4);
});
it("[144] getippte Länge an der Bogenwand = Bogenlänge ab der Lage beim Greifen", () => {
const dir = { x: 1, y: 0 };
const a = { x: 0, y: 0 };
expect(openingTypedPosition(2, 1.5, a, { x: 1.5, y: 0 }, dir)).toBe(3.5);
expect(openingTypedPosition(2, 1.5, a, { x: -1.5, y: 0.1 }, dir)).toBe(0.5);
});
it("Wand-Griffe und koinzidente Ecken", () => {
+13 -2
View File
@@ -104,17 +104,28 @@ export function openingGripPoint(w: Pick<Wall, "start" | "end" | "bulge">, op: P
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));
}
/**
* [144] Getippte Länge beim Griff-Zug einer Öffnung in einer Bogenwand: neue `position` = Lage beim Greifen
* `pos0` ± `length` als BOGENLÄNGE (nicht entlang der Sehne). Richtung aus dem Zielpunkt `pt` des
* Feld-Controllers relativ zum Bezug `anchor`, gemessen an der Wandrichtung `wallDir`.
*/
export function openingTypedPosition(pos0: number, length: number, anchor: Vec2, pt: Vec2, wallDir: Vec2): number {
const along = (pt.x - anchor.x) * wallDir.x + (pt.y - anchor.y) * wallDir.y;
return pos0 + (along < 0 ? -length : length);
}
/**
* Öffnung im Schnitt-Blatt waagrecht ziehen: Blatt-Delta `du` (gesamt, entlang `uAxis`) → neue `position`
* und das wirksame Delta (nach dem Klemmen); null, wenn die Wand fast quer zur Schnittlinie steht.
* Bogenwand ([144]): `position` = Bogenlänge, die Öffnungsmitte folgt dem Delta auf dem Bogen.
*/
export function openingSheetSlide(
w: Pick<Wall, "start" | "end">,
w: Pick<Wall, "start" | "end" | "bulge">,
op: Pick<Opening, "position" | "width">,
uAxis: Vec2,
du: number,
): { position: number; du: number } | null {
const f = core().grip_opening_slide_sheet(w.start.x, w.start.y, w.end.x, w.end.y, uAxis.x, uAxis.y, op.position, op.width, du);
const f = core().grip_opening_slide_sheet(w.start.x, w.start.y, w.end.x, w.end.y, w.bulge ?? 0, uAxis.x, uAxis.y, op.position, op.width, du);
return f.length ? { position: f[0], du: f[1] } : null;
}
+30 -5
View File
@@ -22,6 +22,7 @@ import {
gripPolarPoint,
openingGripPoint,
openingSheetSlide,
openingTypedPosition,
sheetHeightDrag,
stairMoveHandle,
wallGripPoints,
@@ -561,6 +562,8 @@ export function useGripEditing(opts: {
// Position gemessen werden, sonst würde die Richtung während des Ziehens
// mitdriften).
const gripOriginRef = useRef<Vec2 | null>(null);
// [144] Lage (`position`) der gewählten Wandöffnung beim Greifen: Bezug der getippten Bogenlänge.
const gripOpeningPos0Ref = useRef<{ position: number; dir: Vec2 } | null>(null);
// Endpunkt aus Anker + (gelockten/Live-)Länge/Winkel (Kern `gripPolarPoint`) — wie lineEndFromFields.
const gripEditPoint = gripPolarPoint;
@@ -652,9 +655,14 @@ export function useGripEditing(opts: {
if (!prev && wallDir) {
// Öffnung ([144]): Richtung = Wandrichtung (bzw. Gegenrichtung, je nach bisherigem Zug), damit
// die getippte Länge genau die Strecke entlang der Wand ist.
// Bogenwand: Länge = bisher gezogene Bogenlänge, Richtung = Wandrichtung beim Greifen.
const op = (project.openings ?? []).find((o) => o.id === selectedOpeningId);
const arc = !!project.walls.find((x) => x.id === op?.hostWallId)?.bulge;
const at0 = gripOpeningPos0Ref.current;
const dir = arc && at0 ? at0.dir : wallDir;
const g = grips[info.index];
const along = (g.x - anchor.x) * wallDir.x + (g.y - anchor.y) * wallDir.y;
const deg = (Math.atan2(wallDir.y, wallDir.x) * 180) / Math.PI + (along < 0 ? 180 : 0);
const along = arc && at0 && op ? op.position - at0.position : (g.x - anchor.x) * wallDir.x + (g.y - anchor.y) * wallDir.y;
const deg = (Math.atan2(dir.y, dir.x) * 180) / Math.PI + (along < 0 ? 180 : 0);
return { anchor, active: "length", locks: { length: Math.abs(along), angle: ((deg % 360) + 360) % 360 } };
}
if (!prev) {
@@ -680,7 +688,18 @@ export function useGripEditing(opts: {
setGripEdit({ ...ge, locks, active: next });
// Zielpunkt mit dem frischen Lock anwenden (live, ohne Maus-Bewegung).
const pt = gripEditPoint(ge.anchor, locks, info.raw);
applyGrip(info.index, pt);
applyGripEdit(info.index, pt, ge.anchor, locks.length);
};
// Zielpunkt des Feld-Controllers anwenden. [144] Öffnung in einer Bogenwand: die getippte Länge ist
// die Bogenlänge ab der Lage beim Greifen (nicht die Strecke entlang der Sehne).
const applyGripEdit = (index: number, pt: Vec2, anchor: Vec2, length: number | undefined) => {
const op = selectedOpeningId ? (project.openings ?? []).find((o) => o.id === selectedOpeningId) : undefined;
const host = op && !op.hostRoofId && !op.hostCeilingId ? project.walls.find((x) => x.id === op.hostWallId) : undefined;
const at0 = gripOpeningPos0Ref.current;
if (op && !op.locked && host?.bulge && at0 && length != null) {
slideOpening(op.id, { position: openingTypedPosition(at0.position, length, anchor, pt, at0.dir) }, `slideOpening:${op.id}`);
} else applyGrip(index, pt);
};
// Feld-Controller schließen (Escape MIT Fokus in der Befehlszeile, s.
@@ -1054,6 +1073,7 @@ export function useGripEditing(opts: {
pendingBodyRef.current = null;
pendingEdgeRef.current = null;
gripOriginRef.current = null; // Flucht-Bezugspunkt verwerfen
gripOpeningPos0Ref.current = null;
setGripEdit(null); // (c) Feld-Controller schließen
edgeDragInfoRef.current = null; // Kanten-Drag-Info verwerfen
setEdgeEdit(null); // Kanten-Feld-Controller schließen
@@ -1157,7 +1177,12 @@ export function useGripEditing(opts: {
// Erster Move-Event nach dem Grab (gripDragInfoRef noch leer): die
// AKTUELLE — hier noch unveränderte — Position als Flucht-Bezugspunkt
// verankern (s. Kommentar an gripOriginRef).
if (gripDragInfoRef.current === null) gripOriginRef.current = grips[index];
if (gripDragInfoRef.current === null) {
gripOriginRef.current = grips[index];
const op0 = selectedOpeningId ? (project.openings ?? []).find((o) => o.id === selectedOpeningId) : undefined;
const dir0 = op0 ? openingWallDir() : null;
gripOpeningPos0Ref.current = op0 && dir0 ? { position: op0.position, dir: dir0 } : null;
}
// (c) Vertex-Drag mit aktivem Feld-Controller: `locks` ist ab dem
// ÖFFNEN (Tab) immer für BEIDE Felder befüllt (s. cycleGripEditField),
// die Maus wirkt also erst wieder, sobald ein Feld per Tab explizit
@@ -1166,7 +1191,7 @@ export function useGripEditing(opts: {
gripDragInfoRef.current = { index, raw };
if (ge && (ge.locks.length != null || ge.locks.angle != null)) {
const pt = gripEditPoint(ge.anchor, ge.locks, raw);
applyGrip(index, pt);
applyGripEdit(index, pt, ge.anchor, ge.locks.length);
setDraft({ preview: gripPreviewShapes(), vertices: [], snap: null, hud: hudFor(index, pt) });
return;
}