Merge branch 'worktree-agent-af5a19cf1bb7e2468' into claude/practical-noether-1hb2s1
This commit is contained in:
11 files changed
+499
-59
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, 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,26 @@ 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
|
||||
* Punkt dem Cursor `raw`. `null` bei Unsinn (z. B. Radius unter der halben Sehne).
|
||||
*/
|
||||
export function gripArcWallRadius(w: Pick<Wall, "start" | "end" | "bulge">, fixedCenter: boolean, radius: number | undefined, raw: Vec2): { pt: Vec2; radius: number } | null {
|
||||
const f = core().grip_arc_wall_radius(w.start.x, w.start.y, w.end.x, w.end.y, w.bulge ?? 0, fixedCenter, radius ?? NaN, raw.x, raw.y);
|
||||
return f.length >= 3 ? { pt: v(f), radius: f[2] } : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift-Achsen-Lock eines Punkt-Griffs: Welt-H/V durch den Nachbar-Griff `anchor`, bei einem Vielecks-
|
||||
* Eckpunkt (`ring` = Punkte des Elements, `index` darin, `origin` = Lage vor dem Zug) zusätzlich die Flucht
|
||||
|
||||
@@ -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}`,
|
||||
),
|
||||
|
||||
|
||||
+60
-14
@@ -16,6 +16,8 @@ import { openEdges, polylineEdgeGrips, ringEdges } from "../core";
|
||||
import {
|
||||
coincidentGripPoints,
|
||||
excavationGripPoints,
|
||||
gripArcWallRadius,
|
||||
gripArcWallResize,
|
||||
gripArcWallTarget,
|
||||
gripAxisLock,
|
||||
gripEdgeTarget,
|
||||
@@ -116,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;
|
||||
@@ -565,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);
|
||||
@@ -594,7 +597,15 @@ export function useGripEditing(opts: {
|
||||
const wall = owner?.wallId ? project.walls.find((x) => x.id === owner.wallId) : undefined;
|
||||
return wall && wall.bulge && (owner?.localIndex === 0 || owner?.localIndex === 1) ? { wall, end: owner.localIndex } : null;
|
||||
};
|
||||
// [T2] Scheitel-Griff einer Bogenwand: Tab-Feld ist der Radius (Shift = fester Mittelpunkt statt fester Endpunkte).
|
||||
const arcWallApex = (index: number): Wall | null => {
|
||||
const owner = gripOwners[index];
|
||||
const wall = owner?.wallId ? project.walls.find((x) => x.id === owner.wallId) : undefined;
|
||||
return wall && wall.bulge && owner?.localIndex === 2 ? wall : null;
|
||||
};
|
||||
const gripEditPoint = (anchor: Vec2, locks: GripLocks, raw: Vec2, index?: number): Vec2 => {
|
||||
const apex = index != null ? arcWallApex(index) : null;
|
||||
if (apex) return gripArcWallRadius(apex, gripFreeRef.current, locks.length, raw)?.pt ?? raw;
|
||||
const arc = index != null ? arcWallEnd(index) : null;
|
||||
return (arc && gripArcWallTarget(arc.wall, arc.end, locks.length, raw)?.pt) ?? gripPolarPoint(anchor, locks, raw);
|
||||
};
|
||||
@@ -604,6 +615,11 @@ export function useGripEditing(opts: {
|
||||
const ge = gripEdit;
|
||||
const info = gripDragInfoRef.current;
|
||||
if (!ge || !info) return [];
|
||||
const apex = arcWallApex(info.index);
|
||||
if (apex) {
|
||||
const live = gripArcWallRadius(apex, gripFreeRef.current, undefined, info.raw)?.radius ?? 0;
|
||||
return [{ id: "length", labelKey: "cmd.field.radius", value: ge.locks.length ?? live, locked: ge.locks.length != null, active: true }];
|
||||
}
|
||||
const arc = arcWallEnd(info.index);
|
||||
if (arc) {
|
||||
const live = gripArcWallTarget(arc.wall, arc.end, undefined, info.raw)?.arcLength ?? 0;
|
||||
@@ -688,7 +704,14 @@ export function useGripEditing(opts: {
|
||||
if (!anchor) return; // ohne Anker keine polare Eingabe möglich
|
||||
const wallDir = openingWallDir();
|
||||
const arcEnd = arcWallEnd(info.index);
|
||||
const apex = arcWallApex(info.index);
|
||||
setGripEdit((prev) => {
|
||||
if (apex) {
|
||||
// Bogenwand-Scheitel ([T2]): nur das Radiusfeld, eingefroren auf dem aktuellen Radius.
|
||||
if (prev) return prev;
|
||||
const radius = gripArcWallRadius(apex, gripFreeRef.current, undefined, grips[info.index])?.radius;
|
||||
return radius != null ? { anchor, active: "length", locks: { length: radius } } : prev;
|
||||
}
|
||||
if (arcEnd) {
|
||||
// Bogenwand ([T2]): nur das Längenfeld (Bogenlänge), eingefroren auf der aktuellen Länge.
|
||||
if (prev) return prev;
|
||||
@@ -727,7 +750,7 @@ export function useGripEditing(opts: {
|
||||
const info = gripDragInfoRef.current;
|
||||
if (!ge || !info) return;
|
||||
const locks = { ...ge.locks, [ge.active]: value };
|
||||
const next = ge.active === "length" && !arcWallEnd(info.index) ? "angle" : "length";
|
||||
const next = ge.active === "length" && !arcWallEnd(info.index) && !arcWallApex(info.index) ? "angle" : "length";
|
||||
setGripEdit({ ...ge, locks, active: next });
|
||||
// Zielpunkt mit dem frischen Lock anwenden (live, ohne Maus-Bewegung).
|
||||
const pt = gripEditPoint(ge.anchor, locks, info.raw, info.index);
|
||||
@@ -742,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);
|
||||
};
|
||||
|
||||
@@ -847,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
|
||||
@@ -919,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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -946,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 },
|
||||
@@ -985,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);
|
||||
@@ -1098,7 +1131,10 @@ export function useGripEditing(opts: {
|
||||
// Bogenwand ([T2]): Länge = Bogenlänge der Wand mit dem Endpunkt am Cursor.
|
||||
const arc = arcWallEnd(index);
|
||||
const arcLength = arc ? gripArcWallTarget(arc.wall, arc.end, undefined, pt)?.arcLength : undefined;
|
||||
return { at: pt, length: arcLength ?? length, angleDeg };
|
||||
// Scheitel einer Bogenwand: Länge = Radius der Wand mit dem Scheitel am Cursor.
|
||||
const apex = arcWallApex(index);
|
||||
const radius = apex ? gripArcWallRadius(apex, gripFreeRef.current, undefined, pt)?.radius : undefined;
|
||||
return { at: pt, length: radius ?? arcLength ?? length, angleDeg };
|
||||
};
|
||||
// Dasselbe für einen gezogenen Kanten-Griff: freie Kanten zeigen Länge+Winkel
|
||||
// (wie ein Punkt-Griff), geführte Kanten nur EINEN Wert (Abstand entlang der
|
||||
@@ -1270,6 +1306,16 @@ export function useGripEditing(opts: {
|
||||
// also nutzlos für „entlang der bestehenden Kante weiterziehen". Der Lock
|
||||
// dominiert (kein Snap), damit die Endkoordinate garantiert eine Achse
|
||||
// trifft — identisch zum bisherigen Ortho-Verhalten.
|
||||
// [T2] Scheitel einer Bogenwand: Shift = Radius mit festem Mittelpunkt (Kern, `free` im Zug), kein Achsen-Lock.
|
||||
const apexWall = arcWallApex(index);
|
||||
if (apexWall) {
|
||||
gripFreeRef.current = !!mods.shift;
|
||||
if (mods.shift) {
|
||||
applyGrip(index, raw);
|
||||
setDraft({ preview: gripPreviewShapes(), vertices: [], snap: null, hud: hudFor(index, raw) });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mods.shift && anchor) {
|
||||
const origin = gripOriginRef.current;
|
||||
const ring = origin ? resolvePolygonRing(index) : null;
|
||||
@@ -1279,10 +1325,10 @@ export function useGripEditing(opts: {
|
||||
return;
|
||||
}
|
||||
// [172] Masszahl-Griff: der Kern rastet an festen Stellen ein (Alt = frei); Objektfang würde das stören.
|
||||
gripFreeRef.current = !!mods.alt;
|
||||
gripFreeRef.current = !apexWall && !!mods.alt;
|
||||
if (owner?.drawingId) {
|
||||
const od = project.drawings2d.find((x) => x.id === owner.drawingId);
|
||||
if (od?.geom.shape === "dimension" && !od.geom.kind && owner.localIndex > od.geom.pts.length) {
|
||||
if (od?.geom.shape === "dimension" && owner.localIndex > od.geom.pts.length) {
|
||||
applyGrip(index, raw);
|
||||
setDraft({ preview: gripPreviewShapes(), vertices: [], snap: null, hud: hudFor(index, raw) });
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user