[T2] Bogenwand: Bogenlänge per Tab über dem Halbkreis (Seite aus dem Cursor), Vorschau mit echtem Bulge
This commit is contained in:
9 files changed
+150
-31
No files matched your search
+1
-1
@@ -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 } from "../geometry/grips";
|
||||
export { clampInside, coincidentGripPoints, excavationGripPoints, gripArcWallRadius, 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, 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";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
gripArcWallRadius,
|
||||
gripArcWallResize,
|
||||
gripArcWallTarget,
|
||||
coincidentGripPoints,
|
||||
gripAxisLock,
|
||||
@@ -97,3 +99,26 @@ describe("[T2] Bogenwand-Endpunkt-Griff", () => {
|
||||
expect(gripArcWallTarget(wall, 1, -1, { x: 3, y: 3 })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("[T2] Bogenwand: Länge über dem Halbkreis, Radius-Griff", () => {
|
||||
const wall = { start: { x: 0, y: 0 }, end: { x: 4, y: 0 }, bulge: 1 };
|
||||
it("Bogenlänge 3π: Öffnungswinkel 270°, Seite vom Cursor", () => {
|
||||
const up = gripArcWallResize(wall, 1, 3 * Math.PI, { x: 3, y: 3 });
|
||||
const down = gripArcWallResize(wall, 1, 3 * Math.PI, { x: 3, y: -3 });
|
||||
expect(up?.end.x).toBeCloseTo(2, 9);
|
||||
expect(up?.end.y).toBeCloseTo(-2, 9);
|
||||
expect(down?.end.y).toBeCloseTo(2, 9);
|
||||
expect(up?.bulge).toBeCloseTo(Math.tan((3 * Math.PI) / 8), 9);
|
||||
expect(down?.bulge).toBeCloseTo(-Math.tan((3 * Math.PI) / 8), 9);
|
||||
expect(gripArcWallResize(wall, 1, 5 * Math.PI, { x: 3, y: 3 })).toBeNull();
|
||||
});
|
||||
it("Radius mit festem Mittelpunkt und mit festen Endpunkten", () => {
|
||||
const fixed = gripArcWallRadius(wall, true, 5, { x: 2, y: 1 });
|
||||
expect(fixed?.pt.x).toBeCloseTo(2, 9);
|
||||
expect(fixed?.pt.y).toBeCloseTo(5, 9);
|
||||
expect(fixed?.radius).toBe(5);
|
||||
const ends = gripArcWallRadius(wall, false, 5, { x: 2, y: 1 });
|
||||
expect(ends?.pt.y).toBeCloseTo(5 - Math.sqrt(21), 9);
|
||||
expect(gripArcWallRadius(wall, false, 1, { x: 2, y: 1 })).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -51,6 +51,16 @@ export function gripArcWallTarget(w: Pick<Wall, "start" | "end" | "bulge">, inde
|
||||
return f.length >= 3 ? { pt: v(f), arcLength: f[2] } : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* [T2] Endpunkt-Griff einer Bogenwand: die ganze Wand danach (Start, Ende, Bulge). `arcLength` = getippte Bogenlänge
|
||||
* ab dem festen Ende (auch über dem Halbkreis; der Cursor `raw` bestimmt nur die Seite), sonst der auf den Kreis
|
||||
* projizierte Cursor. `null` bei Unsinn.
|
||||
*/
|
||||
export function gripArcWallResize(w: Pick<Wall, "start" | "end" | "bulge">, index: 0 | 1, arcLength: number | undefined, raw: Vec2): { start: Vec2; end: Vec2; bulge: number } | null {
|
||||
const f = core().grip_arc_wall_resize(w.start.x, w.start.y, w.end.x, w.end.y, w.bulge ?? 0, index, arcLength ?? NaN, raw.x, raw.y);
|
||||
return f.length >= 5 ? { start: { x: f[0], y: f[1] }, end: { x: f[2], y: f[3] }, bulge: f[4] } : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* [T2] Scheitel-Griff einer Bogenwand: Zielpunkt und Radius der Wand danach. `fixedCenter` (Shift) = Radius um den
|
||||
* festen Mittelpunkt (Enden wandern radial), sonst Endpunkte fest. `radius` = getippter Radius, sonst folgt der
|
||||
|
||||
@@ -19,7 +19,7 @@ type P = [number, number];
|
||||
|
||||
/** Eine Griff-Änderung für den Kern (`grips.rs::run`); Zahlen dürfen NaN/±∞ sein (Marken). */
|
||||
export type GripRequest =
|
||||
| { op: "moveGrip"; drawingId: string | null; wallId: string | null; index: number; pt: P; scale: number; free?: boolean }
|
||||
| { op: "moveGrip"; drawingId: string | null; wallId: string | null; index: number; pt: P; scale: number; free?: boolean; arcLength?: number }
|
||||
| { op: "moveBy"; drawingId: string | null; wallId: string | null; delta: P }
|
||||
| { op: "moveEdge"; drawingId: string | null; wallId: string | null; a: number; b: number; delta: P }
|
||||
| { op: "resize"; kind: string; id: string; w: number; h: number; fx: number; fy: number }
|
||||
|
||||
@@ -244,8 +244,13 @@ export interface ProjectSlice {
|
||||
pt: Vec2,
|
||||
/** Papier-Massstab (1:N), nur für den Masszahl-Griff der Bemassung. */
|
||||
scaleDenominator?: number,
|
||||
/** [172] Masszahl-Griff ohne Einrasten (Alt gehalten). */
|
||||
/**
|
||||
* Modifikator gehalten: Masszahl-Griff ohne Einrasten ([172], Alt) bzw. Scheitel-Griff einer Bogenwand mit
|
||||
* festem Mittelpunkt ([T2], Shift).
|
||||
*/
|
||||
free?: boolean,
|
||||
/** [T2] Getippte Bogenlänge (Tab) beim Endpunkt-Griff einer Bogenwand, auch über dem Halbkreis. */
|
||||
arcLength?: number,
|
||||
) => void;
|
||||
moveElementByOf: (
|
||||
drawingId: string | null,
|
||||
@@ -1145,9 +1150,9 @@ export function createProjectSlice(
|
||||
// Diese Aktionen laufen AD-HOC bei jedem Maus-Move-Schritt eines Drags
|
||||
// (kein Draft/Commit-Muster wie bei den Zeichenwerkzeugen) — daher mit
|
||||
// coalesceKey, damit EIN Drag EINEN Undo-Schritt erzeugt statt vieler.
|
||||
moveGripOf: (drawingId, wallId, index, pt, scaleDenominator = DEFAULT_SCALE_DENOMINATOR, free) =>
|
||||
moveGripOf: (drawingId, wallId, index, pt, scaleDenominator = DEFAULT_SCALE_DENOMINATOR, free, arcLength) =>
|
||||
applyGrip(
|
||||
{ op: "moveGrip", drawingId, wallId, index, pt: gripPt(pt), scale: scaleDenominator, ...(free ? { free: true } : {}) },
|
||||
{ op: "moveGrip", drawingId, wallId, index, pt: gripPt(pt), scale: scaleDenominator, ...(free ? { free: true } : {}), ...(arcLength != null ? { arcLength } : {}) },
|
||||
`moveGripOf:${drawingId ?? ""}:${wallId ?? ""}:${index}`,
|
||||
),
|
||||
|
||||
|
||||
+22
-10
@@ -17,6 +17,7 @@ import {
|
||||
coincidentGripPoints,
|
||||
excavationGripPoints,
|
||||
gripArcWallRadius,
|
||||
gripArcWallResize,
|
||||
gripArcWallTarget,
|
||||
gripAxisLock,
|
||||
gripEdgeTarget,
|
||||
@@ -117,6 +118,7 @@ export function useGripEditing(opts: {
|
||||
pt: Vec2,
|
||||
scaleDenominator?: number,
|
||||
free?: boolean,
|
||||
arcLength?: number,
|
||||
) => void;
|
||||
moveRoomEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
|
||||
moveCeilingEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
|
||||
@@ -566,7 +568,7 @@ export function useGripEditing(opts: {
|
||||
const pendingGripRef = useRef<{ drawingId: string; localIndex: number; flat: number; pt: Vec2 } | null>(null);
|
||||
// Dasselbe für das Verschieben eines ganzen 2D-Elements (Gesamt-Delta) und für
|
||||
// Kanten-Griffe von Polylinien (Ziel-Delta): bis zum Loslassen nur Vorschau.
|
||||
const pendingWallGripRef = useRef<{ wallId: string; localIndex: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingWallGripRef = useRef<{ wallId: string; localIndex: number; flat: number; pt: Vec2; arcLength?: number } | null>(null);
|
||||
const pendingAreaGripRef = useRef<{ kind: "room" | "ceiling" | "excavation"; id: string; index: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingAreaMoveRef = useRef<{ kind: "ceiling" | "room" | "stair"; id: string; total: Vec2 } | null>(null);
|
||||
const pendingWallMoveRef = useRef<{ wallId: string; total: Vec2 } | null>(null);
|
||||
@@ -763,6 +765,9 @@ export function useGripEditing(opts: {
|
||||
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 if (length != null && arcWallEnd(index)) {
|
||||
// Bogenwand-Ende ([T2]): der rohe Cursor legt nur die Seite fest, die Länge der Kern (auch über dem Halbkreis).
|
||||
applyGrip(index, gripDragInfoRef.current?.raw ?? pt, length);
|
||||
} else applyGrip(index, pt);
|
||||
};
|
||||
|
||||
@@ -868,7 +873,7 @@ export function useGripEditing(opts: {
|
||||
|
||||
// Editier-Dispatch: bei gewählter Decke auf die Decken-Aktionen umleiten, sonst
|
||||
// auf die Wand/2D-Aktionen. So teilen Plan- UND 3D-Griffe denselben Pfad.
|
||||
const applyGrip = (index: number, pt: Vec2) => {
|
||||
const applyGrip = (index: number, pt: Vec2, arcLength?: number) => {
|
||||
// Öffnung: den gezogenen Punkt auf die Wandachse projizieren → neue
|
||||
// `position` (Abstand des ersten Pfostens vom Wand-Start), sodass die
|
||||
// Öffnung entlang der Wand gleitet. Griff sitzt in der Öffnungsmitte, daher
|
||||
@@ -940,11 +945,11 @@ export function useGripEditing(opts: {
|
||||
if (wId && !dId && local <= 1) {
|
||||
const w = project.walls.find((x) => x.id === wId);
|
||||
if (w && !w.locked) {
|
||||
pendingWallGripRef.current = { wallId: wId, localIndex: local, flat: index, pt };
|
||||
pendingWallGripRef.current = { wallId: wId, localIndex: local, flat: index, pt, arcLength };
|
||||
return;
|
||||
}
|
||||
}
|
||||
moveGripOf(dId, wId, local, pt, scaleDenominator, gripFreeRef.current);
|
||||
moveGripOf(dId, wId, local, pt, scaleDenominator, gripFreeRef.current, arcLength);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -967,13 +972,20 @@ export function useGripEditing(opts: {
|
||||
if (!w) return [];
|
||||
const wt = project.wallTypes.find((t) => t.id === w.wallTypeId);
|
||||
const th = wt ? wallTypeThickness(wt) : 0.2;
|
||||
const a = pw.localIndex === 0 ? pw.pt : w.start;
|
||||
const b = pw.localIndex === 0 ? w.end : pw.pt;
|
||||
// Bogenwand: der Bogen behält seinen Öffnungswinkel (Bulge), Vorschau als Band samt Achse.
|
||||
let a = pw.localIndex === 0 ? pw.pt : w.start;
|
||||
let b = pw.localIndex === 0 ? w.end : pw.pt;
|
||||
// Bogenwand ([T2]): der Endpunkt läuft auf dem Kreis, der Bulge folgt (Kern `gripArcWallResize`);
|
||||
// Vorschau als Band samt Achse.
|
||||
if (w.bulge) {
|
||||
const arc = wallArcBand(a, b, w.bulge, th);
|
||||
const nw = pw.localIndex <= 1 ? gripArcWallResize(w, pw.localIndex as 0 | 1, pw.arcLength, pw.pt) : null;
|
||||
if (nw) {
|
||||
a = nw.start;
|
||||
b = nw.end;
|
||||
}
|
||||
const bulge = nw?.bulge ?? w.bulge;
|
||||
const arc = wallArcBand(a, b, bulge, th);
|
||||
if (arc) return [{ kind: "poly", pts: arc.band, closed: true }, { kind: "poly", pts: arc.axis, closed: false }];
|
||||
return [{ kind: "poly", pts: bulgeArcPoints(a, b, w.bulge), closed: false }];
|
||||
return [{ kind: "poly", pts: bulgeArcPoints(a, b, bulge), closed: false }];
|
||||
}
|
||||
return [
|
||||
{ kind: "poly", pts: wallCorners(a, b, th), closed: true },
|
||||
@@ -1006,7 +1018,7 @@ export function useGripEditing(opts: {
|
||||
}
|
||||
const pw = pendingWallGripRef.current;
|
||||
pendingWallGripRef.current = null;
|
||||
if (pw) moveGripOf(null, pw.wallId, pw.localIndex, pw.pt, scaleDenominator);
|
||||
if (pw) moveGripOf(null, pw.wallId, pw.localIndex, pw.pt, scaleDenominator, undefined, pw.arcLength);
|
||||
const pend = pendingGripRef.current;
|
||||
pendingGripRef.current = null;
|
||||
if (pend) moveGripOf(pend.drawingId, null, pend.localIndex, pend.pt, scaleDenominator);
|
||||
|
||||
Reference in new issue
Block a user