[26] Ecke einfügen/löschen an Umrissen: Dach (Umriss + Höfe), Decke, Raum, Baugrube, geschlossene Polylinie; Einfüge-Raute, Kontextmenü, Aufräumen
This commit is contained in:
15 files changed
+628
-15
No files matched your search
@@ -63,7 +63,7 @@ import { reorderByIds } from "../model/reorder";
|
||||
import { transformMutation } from "../tools/transform";
|
||||
import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform";
|
||||
import { uniqueId } from "../tools/types";
|
||||
import { gripPt, type GripRequest } from "../core";
|
||||
import { gripPt, type GripRequest, type RingKind } from "../core";
|
||||
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
|
||||
import { DEFAULT_PRESETS, type TextStylePreset } from "../text/richText";
|
||||
import { t } from "../i18n";
|
||||
@@ -394,6 +394,14 @@ export interface ProjectSlice {
|
||||
deleteSectionBend: (id: string, index: number) => void;
|
||||
/** [176] Nach dem Ziehen: Knicke auf einem Nachbarpunkt oder auf der Geraden entfernen. */
|
||||
tidySectionLine: (id: string, coalesceKey?: string, tol?: number) => void;
|
||||
/** [26] Ecke von Dach/Decke/Raum/Baugrube/geschlossener Polylinie ziehen (Kern wählt den Op je `kind`); `coalesceKey` fasst Einfügen + Zug zusammen. */
|
||||
moveRingVertex: (kind: RingKind, id: string, index: number, pt: Vec2, coalesceKey?: string) => void;
|
||||
/** [26] Ecke hinter Ecke `seg` (Dach: flacher Index) einfügen; Kanten-Eigenschaften erbt die neue Kante. */
|
||||
insertRingVertex: (kind: RingKind, id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
|
||||
/** [26] Ecke löschen (mind. 3 bleiben); ein Undo-Schritt. */
|
||||
deleteRingVertex: (kind: RingKind, id: string, index: number) => void;
|
||||
/** [26] Nach dem Ziehen: Ecke auf Nachbar bzw. Gerade zwischen den Nachbarn entfällt. */
|
||||
tidyRingVertex: (kind: RingKind, id: string, index: number, coalesceKey?: string, tol?: number) => void;
|
||||
moveExcavationEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
|
||||
/** Verschiebt eine Decke (ganzer Umriss) um `delta`. */
|
||||
moveCeilingBy: (ceilingId: string, delta: Vec2) => void;
|
||||
@@ -1256,6 +1264,22 @@ export function createProjectSlice(
|
||||
applyGrip({ op: "sectionLineGrip", id, index, pt: gripPt(pt) }, coalesceKey ?? `moveSectionLineGrip:${id}:${index}`),
|
||||
insertSectionBend: (id, seg, pt, coalesceKey) => applyGrip({ op: "sectionBendInsert", id, seg, pt: gripPt(pt) }, coalesceKey),
|
||||
deleteSectionBend: (id, index) => applyGrip({ op: "sectionBendDelete", id, index }),
|
||||
moveRingVertex: (kind, id, index, pt, coalesceKey) => {
|
||||
const p = gripPt(pt);
|
||||
const req: GripRequest =
|
||||
kind === "roof" ? { op: "roofVertex", id, index, pt: p }
|
||||
: kind === "ceiling" ? { op: "ceilingGrip", id, index, pt: p }
|
||||
: kind === "room" ? { op: "roomGrip", id, index, pt: p }
|
||||
: kind === "excavation" ? { op: "excavationGrip", id, index, pt: p }
|
||||
: { op: "moveGrip", drawingId: id, wallId: null, index, pt: p, scale: DEFAULT_SCALE_DENOMINATOR };
|
||||
applyGrip(req, coalesceKey ?? `moveRingVertex:${kind}:${id}:${index}`);
|
||||
},
|
||||
insertRingVertex: (kind, id, seg, pt, coalesceKey) =>
|
||||
applyGrip(kind === "polyline" ? { op: "insertPoint", id, seg, pt: gripPt(pt) } : { op: "ringInsert", kind, id, seg, pt: gripPt(pt) }, coalesceKey),
|
||||
deleteRingVertex: (kind, id, index) =>
|
||||
applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }),
|
||||
tidyRingVertex: (kind, id, index, coalesceKey, tol) =>
|
||||
applyGrip({ op: "ringTidy", kind, id, index, ...(tol != null ? { tol } : {}) }, coalesceKey),
|
||||
tidySectionLine: (id, coalesceKey, tol) => applyGrip({ op: "sectionLineTidy", id, ...(tol != null ? { tol } : {}) }, coalesceKey),
|
||||
|
||||
moveExcavationEdge: (id, aIndex, bIndex, delta) =>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// [26] Ecke einfügen/löschen an Umriss-Ringen (Dach samt Hof, Decke, geschlossene Polylinie) über den Store:
|
||||
// ein Undo-Schritt je Aktion, Einfügen + Zug + Aufräumen mit gleichem Schlüssel ebenso; Kanten-Neigung des Dachs läuft mit.
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { getState, setState } from "./appStore";
|
||||
import type { Project, Roof } from "../model/types";
|
||||
|
||||
const roof: Roof = {
|
||||
id: "RF1",
|
||||
type: "roof",
|
||||
floorId: "eg",
|
||||
categoryCode: "31",
|
||||
outline: [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 12, y: 0 },
|
||||
{ x: 12, y: 8 },
|
||||
{ x: 0, y: 8 },
|
||||
],
|
||||
holes: [
|
||||
[
|
||||
{ x: 4, y: 2 },
|
||||
{ x: 4, y: 6 },
|
||||
{ x: 8, y: 6 },
|
||||
],
|
||||
],
|
||||
edgePitchDeg: [30, null, 40, 50, 20, 21, 22],
|
||||
shape: "walm",
|
||||
pitchDeg: 35,
|
||||
overhang: 0,
|
||||
ridgeAxis: "x",
|
||||
thickness: 0.2,
|
||||
};
|
||||
|
||||
const baseProject = {
|
||||
id: "p",
|
||||
name: "T",
|
||||
layers: [],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, baseElevation: 0 }],
|
||||
walls: [],
|
||||
drawings2d: [
|
||||
{
|
||||
id: "pl",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "polyline", closed: true, pts: [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }] },
|
||||
},
|
||||
],
|
||||
roofs: [roof],
|
||||
} as unknown as Project;
|
||||
|
||||
const current = (): Roof => getState().project.roofs![0];
|
||||
const poly = () => {
|
||||
const g = getState().project.drawings2d.find((d) => d.id === "pl")!.geom;
|
||||
if (g.shape !== "polyline") throw new Error("keine Polylinie");
|
||||
return g;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
setState({ project: JSON.parse(JSON.stringify(baseProject)), undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
|
||||
getState().clearHistory();
|
||||
});
|
||||
|
||||
describe("Ecken am Dach", () => {
|
||||
it("Einfügen erbt die geteilte Kante, ein Undo-Schritt", () => {
|
||||
getState().insertRingVertex("roof", "RF1", 1, { x: 13, y: 4 });
|
||||
expect(current().outline).toHaveLength(5);
|
||||
expect(current().outline[2]).toEqual({ x: 13, y: 4 });
|
||||
expect(current().edgePitchDeg).toEqual([30, null, null, 40, 50, 20, 21, 22]);
|
||||
expect(getState().undoDepth).toBe(1);
|
||||
getState().undo();
|
||||
expect(current().outline).toHaveLength(4);
|
||||
expect(current().edgePitchDeg).toEqual([30, null, 40, 50, 20, 21, 22]);
|
||||
});
|
||||
|
||||
it("Einfügen, Ziehen und Aufräumen mit gleichem Schlüssel sind ein Schritt; auf die Gerade zurück entfällt die Ecke", () => {
|
||||
const key = "ringInsert:RF1:1";
|
||||
getState().insertRingVertex("roof", "RF1", 0, { x: 6, y: 1 }, key);
|
||||
getState().moveRingVertex("roof", "RF1", 1, { x: 6, y: 3 }, key);
|
||||
getState().moveRingVertex("roof", "RF1", 1, { x: 6, y: 0.001 }, key);
|
||||
getState().tidyRingVertex("roof", "RF1", 1, key, 0.01);
|
||||
expect(current().outline).toHaveLength(4);
|
||||
expect(current().edgePitchDeg).toEqual([30, null, 40, 50, 20, 21, 22]);
|
||||
getState().undo();
|
||||
expect(current().outline).toHaveLength(4);
|
||||
expect(getState().canUndo).toBe(false);
|
||||
});
|
||||
|
||||
it("gezogene Ecke bleibt, solange sie nicht auf der Geraden liegt (ein Undo-Schritt)", () => {
|
||||
const key = "ringInsert:RF1:2";
|
||||
getState().insertRingVertex("roof", "RF1", 0, { x: 6, y: 1 }, key);
|
||||
getState().moveRingVertex("roof", "RF1", 1, { x: 6, y: -2 }, key);
|
||||
getState().tidyRingVertex("roof", "RF1", 1, key, 0.01);
|
||||
expect(current().outline).toHaveLength(5);
|
||||
expect(current().outline[1]).toEqual({ x: 6, y: -2 });
|
||||
expect(getState().undoDepth).toBe(1);
|
||||
});
|
||||
|
||||
it("Löschen: Hof-Ecke geht nicht unter drei, Umriss-Ecke schon, Kanten-Eintrag entfällt", () => {
|
||||
getState().deleteRingVertex("roof", "RF1", 4); // Hof hat 3 Ecken
|
||||
expect(current().holes![0]).toHaveLength(3);
|
||||
expect(getState().canUndo).toBe(false);
|
||||
getState().deleteRingVertex("roof", "RF1", 2);
|
||||
expect(current().outline).toHaveLength(3);
|
||||
expect(current().edgePitchDeg).toEqual([30, null, 50, 20, 21, 22]);
|
||||
expect(getState().undoDepth).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ecken an der geschlossenen Polylinie", () => {
|
||||
it("Einfügen, Aufräumen auf der Geraden, Löschen", () => {
|
||||
const key = "ringInsert:pl:1";
|
||||
getState().insertRingVertex("polyline", "pl", 0, { x: 2, y: 1 }, key);
|
||||
expect(poly().pts).toHaveLength(5);
|
||||
getState().moveRingVertex("polyline", "pl", 1, { x: 2, y: 0.002 }, key);
|
||||
getState().tidyRingVertex("polyline", "pl", 1, key, 0.01);
|
||||
expect(poly().pts).toHaveLength(4);
|
||||
expect(getState().undoDepth).toBe(1);
|
||||
|
||||
getState().deleteRingVertex("polyline", "pl", 2);
|
||||
expect(poly().pts).toHaveLength(3);
|
||||
// Mindestens drei Ecken bleiben.
|
||||
getState().deleteRingVertex("polyline", "pl", 0);
|
||||
expect(poly().pts).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,7 @@
|
||||
import { useRef, useState, type RefObject } from "react";
|
||||
import { useEventBundle, useSameData } from "./useEvent";
|
||||
import { leftNormal, normalize, scale, sub, wallCorners } from "../model/geometry";
|
||||
import type { RingKind } from "../core";
|
||||
import type { Ceiling, Drawing2D, EdgeGrip, Excavation, Project, Roof, Room, Vec2, Wall } from "../model/types";
|
||||
import { wallTypeThickness } from "../model/types";
|
||||
import { bulgeArcPoints, drawingVertices, surfaceOpeningGripPatch, surfaceOpeningGrips, surfaceOpeningInfo, wallArcBand } from "../core";
|
||||
@@ -199,6 +200,8 @@ export function useGripEditing(opts: {
|
||||
/** Pixel je Meter beim letzten Zug (Aufräum-Toleranz). */
|
||||
const sectionPxRef = useRef(0);
|
||||
const sectionDragRef = useRef<{ id: string; key: string; midIndex: number; bendIndex: number } | null>(null);
|
||||
/** [26] Laufender Zug an einer Einfüge-Raute: gemeinsamer Undo-Schlüssel, Raute-Index und Index der eingefügten Ecke. */
|
||||
const ringDragRef = useRef<{ kind: RingKind; id: string; key: string; midIndex: number; vertex: number } | null>(null);
|
||||
// Mit gezeigter Beschriftung dazu ihr Griff (`labelOffset`, s. `treeGrips.ts`).
|
||||
const treeGrips = (tr: NonNullable<typeof selectedTree>): Vec2[] => treeGripPoints(tr, scaleDenominator);
|
||||
const selectedRoomId = single(selection, "rooms");
|
||||
@@ -220,6 +223,9 @@ export function useGripEditing(opts: {
|
||||
drawingId?: string;
|
||||
wallId?: string;
|
||||
localIndex: number;
|
||||
/** [26] Einfüge-Griff (Raute) in Kante `insertSeg` des Umriss-Rings `ring` (Dach: flacher Index). */
|
||||
insertSeg?: number;
|
||||
ring?: { kind: RingKind; id: string };
|
||||
}
|
||||
const gripOwners: GripOwner[] = [];
|
||||
// [ersterFlachIndex, letzterFlachIndex] DESSELBEN Elements — für die Anker-
|
||||
@@ -310,6 +316,32 @@ export function useGripEditing(opts: {
|
||||
return [];
|
||||
})();
|
||||
|
||||
const MAX_INSERT_GRIP_POINTS = 100; // Kataster-Umrisse mit tausenden Punkten: keine Rauten
|
||||
/** Anteil entlang der Kante, an dem der Einfüge-Griff sitzt (neben dem Kanten-Anfasser in der Mitte). */
|
||||
const INSERT_AT = 0.25;
|
||||
/**
|
||||
* [26] Einfüge-Griffe (Rauten) je Kante der Ringe hinter die Ecken-Griffe in `out` hängen: Ziehen fügt dort eine
|
||||
* Ecke ein. `rings` mit Start-Index im flachen Ecken-Index (Dach: Umriss, dann Höfe).
|
||||
*/
|
||||
const pushInsertGrips = (
|
||||
out: Vec2[],
|
||||
rings: { pts: Vec2[]; off: number }[],
|
||||
ring: { kind: RingKind; id: string },
|
||||
owner: { drawingId?: string } = {},
|
||||
keep?: (seg: number) => boolean,
|
||||
) => {
|
||||
const start = out.length;
|
||||
for (const { pts, off } of rings) {
|
||||
pts.forEach((a, i) => {
|
||||
if (keep && !keep(off + i)) return;
|
||||
const b = pts[(i + 1) % pts.length];
|
||||
out.push({ x: a.x + (b.x - a.x) * INSERT_AT, y: a.y + (b.y - a.y) * INSERT_AT, insert: true } as Vec2);
|
||||
gripOwners.push({ ...owner, localIndex: -1, insertSeg: off + i, ring });
|
||||
});
|
||||
}
|
||||
for (let i = start; i < out.length; i++) gripOwnerRange.push([start, out.length - 1]);
|
||||
};
|
||||
|
||||
const grips: Vec2[] = (() => {
|
||||
// Öffnung (Fenster/Tür): EIN Mittelpunkt-Griff auf der Wandachse. Ziehen
|
||||
// verschiebt die Öffnung entlang der Wirts-Wand (siehe applyGrip →
|
||||
@@ -364,12 +396,14 @@ export function useGripEditing(opts: {
|
||||
for (const { pts, off } of roofRings(selectedRoof)) {
|
||||
pts.forEach((q, i) => { out.push(q); gripOwners.push({ localIndex: off + i }); gripOwnerRange.push([off, off + pts.length - 1]); });
|
||||
}
|
||||
pushInsertGrips(out, roofRings(selectedRoof), { kind: "roof", id: selectedRoof.id });
|
||||
return out;
|
||||
}
|
||||
// [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt).
|
||||
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
const pts = excavationGripPoints(selectedExcavation);
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
pushInsertGrips(pts, [{ pts: selectedExcavation.outline, off: 0 }], { kind: "excavation", id: selectedExcavation.id });
|
||||
return pts;
|
||||
}
|
||||
// Decke: die Umriss-Vertices als Griffe (nur bei genau einer gewählten Decke,
|
||||
@@ -377,6 +411,7 @@ export function useGripEditing(opts: {
|
||||
if (modelEditable && selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
const pts = [...selectedCeiling.outline];
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
if (!selectedCeiling.locked) pushInsertGrips(pts, [{ pts: selectedCeiling.outline, off: 0 }], { kind: "ceiling", id: selectedCeiling.id });
|
||||
return pts;
|
||||
}
|
||||
// Raum: die Umriss-Vertices als Griffe (nur bei genau einem gewählten Raum).
|
||||
@@ -389,6 +424,7 @@ export function useGripEditing(opts: {
|
||||
) {
|
||||
const pts = [...selectedRoom.boundary];
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
if (!selectedRoom.locked) pushInsertGrips(pts, [{ pts: selectedRoom.boundary, off: 0 }], { kind: "room", id: selectedRoom.id });
|
||||
return pts;
|
||||
}
|
||||
// Mehrfachauswahl (Regel- UND Standardfall): je gewähltem 2D-Element bzw.
|
||||
@@ -425,6 +461,10 @@ export function useGripEditing(opts: {
|
||||
? (i: number) => i < g.pts.length || Math.abs(g.bulge?.[i - g.pts.length] ?? 0) > 1e-9
|
||||
: undefined;
|
||||
pushGroup(drawingVertices(d, scaleDenominator), { drawingId: id }, keep);
|
||||
// [26] Geschlossene Polylinie: Einfüge-Raute auf jedem geraden Segment (Bogen-Segmente haben ihren Mitten-Griff).
|
||||
if (g.shape === "polyline" && g.closed && !d.locked && g.pts.length >= 3 && g.pts.length <= MAX_INSERT_GRIP_POINTS) {
|
||||
pushInsertGrips(out, [{ pts: g.pts, off: 0 }], { kind: "polyline", id }, { drawingId: id }, (seg) => Math.abs(g.bulge?.[seg] ?? 0) < 1e-9);
|
||||
}
|
||||
}
|
||||
if (modelEditable && effectiveDrawingIds.length === 0) {
|
||||
for (const id of selectedWallIds) {
|
||||
@@ -716,6 +756,7 @@ export function useGripEditing(opts: {
|
||||
// Wand/Öffnung/Treppe haben keine Polygon-Nachbarn → null.
|
||||
const resolvePolygonRing = (index: number): { pts: Vec2[]; index: number; closed: boolean } | null => {
|
||||
const owner = gripOwners[index];
|
||||
if (owner?.insertSeg != null) return null;
|
||||
if (roofGripsOn && selectedRoof && !owner?.drawingId && !owner?.wallId) {
|
||||
const ring = roofRings(selectedRoof).find((rg) => index >= rg.off && index < rg.off + rg.pts.length);
|
||||
return ring ? { pts: ring.pts, index: index - ring.off, closed: true } : null;
|
||||
@@ -935,6 +976,20 @@ 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, arcLength?: number) => {
|
||||
// [26] Einfüge-Raute am Umriss (Dach, Decke, Raum, Baugrube, geschlossene Polylinie): der erste Zug fügt die Ecke
|
||||
// ein, danach folgt sie dem Zeiger; Einfügen, Zug und Aufräumen sind ein Undo-Schritt (gleicher Schlüssel).
|
||||
const rd = ringDragRef.current;
|
||||
if (rd && rd.midIndex === index) {
|
||||
storeState().moveRingVertex(rd.kind, rd.id, rd.vertex, pt, rd.key);
|
||||
return;
|
||||
}
|
||||
const ins = gripOwners[index];
|
||||
if (modelEditable && ins?.insertSeg != null && ins.ring) {
|
||||
const key = `ringInsert:${ins.ring.id}:${Date.now()}`;
|
||||
ringDragRef.current = { ...ins.ring, key, midIndex: index, vertex: ins.insertSeg + 1 };
|
||||
storeState().insertRingVertex(ins.ring.kind, ins.ring.id, ins.insertSeg, pt, key);
|
||||
return;
|
||||
}
|
||||
// Ö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
|
||||
@@ -1112,13 +1167,18 @@ export function useGripEditing(opts: {
|
||||
else if (pa.kind === "excavation") moveExcavationGrip(pa.id, pa.index, pa.pt);
|
||||
else if (pa.kind === "roof") opts.moveRoofVertex?.(pa.id, pa.index, pa.pt);
|
||||
else moveCeilingGrip(pa.id, pa.index, pa.pt);
|
||||
// [26] Ecke auf einem Nachbarn bzw. auf der Geraden zwischen den Nachbarn entfällt (im selben Undo-Schritt).
|
||||
storeState().tidyRingVertex(pa.kind, pa.id, pa.index, undefined, ringTidyTol());
|
||||
}
|
||||
const pw = pendingWallGripRef.current;
|
||||
pendingWallGripRef.current = null;
|
||||
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);
|
||||
if (pend) {
|
||||
moveGripOf(pend.drawingId, null, pend.localIndex, pend.pt, scaleDenominator);
|
||||
storeState().tidyRingVertex("polyline", pend.drawingId, pend.localIndex, undefined, ringTidyTol());
|
||||
}
|
||||
};
|
||||
|
||||
/** Polylinien-Element (nicht gesperrt), dessen Änderung aufgeschoben werden darf. */
|
||||
@@ -1254,8 +1314,16 @@ export function useGripEditing(opts: {
|
||||
// Zeiger-Genauigkeit: ca. 6 Pixel der Ansicht.
|
||||
if (drag) storeState().tidySectionLine(drag.id, drag.key, sectionPxRef.current > 0 ? 6 / sectionPxRef.current : undefined);
|
||||
};
|
||||
/** Aufräum-Abstand (m) der Ecken: ca. 6 Pixel der Ansicht (unbekannt = Kern-Vorgabe). */
|
||||
const ringTidyTol = (): number | undefined => (sectionPxRef.current > 0 ? 6 / sectionPxRef.current : undefined);
|
||||
/** [26] Nach einem Zug an einer Einfüge-Raute: die eingefügte Ecke entfällt, wenn sie auf der Geraden liegt. */
|
||||
const tidyRingDrag = () => {
|
||||
const rd = ringDragRef.current;
|
||||
if (rd) storeState().tidyRingVertex(rd.kind, rd.id, rd.vertex, rd.key, ringTidyTol());
|
||||
};
|
||||
const endEditing = () => {
|
||||
sectionDragRef.current = null;
|
||||
ringDragRef.current = null;
|
||||
setDraft(null);
|
||||
edgeAppliedDeltaRef.current = null; // Kanten-Drag beendet → Anker zurücksetzen
|
||||
moveCoincidentRef.current = null; // Körper-Koinzidenz-Gruppe verwerfen
|
||||
@@ -1377,6 +1445,7 @@ export function useGripEditing(opts: {
|
||||
// verankern (s. Kommentar an gripOriginRef).
|
||||
if (gripDragInfoRef.current === null) {
|
||||
sectionDragRef.current = null; // [176] neuer Zug: eigener Undo-Schlüssel, kein eingefügter Knick
|
||||
ringDragRef.current = null; // [26] dito für eingefügte Ecken
|
||||
gripOriginRef.current = grips[index];
|
||||
const op0 = selectedOpeningId ? (project.openings ?? []).find((o) => o.id === selectedOpeningId) : undefined;
|
||||
const dir0 = op0 ? openingWallDir() : null;
|
||||
@@ -1609,6 +1678,7 @@ export function useGripEditing(opts: {
|
||||
commitPendingGrip();
|
||||
commitPendingBody();
|
||||
tidySectionDrag();
|
||||
tidyRingDrag();
|
||||
endEditing();
|
||||
},
|
||||
// Bewaffneten Punkt-Griff verwerfen (Escape): exakt auf `origin`
|
||||
@@ -1625,6 +1695,10 @@ export function useGripEditing(opts: {
|
||||
} else if (sectionDragRef.current) {
|
||||
applyGrip(index, origin);
|
||||
tidySectionDrag();
|
||||
} else if (ringDragRef.current) {
|
||||
// Eingefügte Ecke zurück auf die Kante: das Aufräumen entfernt sie wieder.
|
||||
applyGrip(index, origin);
|
||||
tidyRingDrag();
|
||||
} else if (!selectedSectionLine) applyGrip(index, origin);
|
||||
endEditing();
|
||||
},
|
||||
|
||||
@@ -128,6 +128,8 @@ export function useProjectActions(
|
||||
const insertDrawingPoint = useStore((s) => s.insertDrawingPoint);
|
||||
const insertSectionBend = useStore((s) => s.insertSectionBend);
|
||||
const deleteSectionBend = useStore((s) => s.deleteSectionBend);
|
||||
const insertRingVertex = useStore((s) => s.insertRingVertex);
|
||||
const deleteRingVertex = useStore((s) => s.deleteRingVertex);
|
||||
const deleteDrawingPoint = useStore((s) => s.deleteDrawingPoint);
|
||||
const setPolylineVertexType = useStore((s) => s.setPolylineVertexType);
|
||||
// Wandstile: immutable Patch eines Wandtyps (z. B. Schichtfugen-Stile). Kein
|
||||
@@ -448,6 +450,8 @@ export function useProjectActions(
|
||||
insertDrawingPoint,
|
||||
insertSectionBend,
|
||||
deleteSectionBend,
|
||||
insertRingVertex,
|
||||
deleteRingVertex,
|
||||
deleteDrawingPoint,
|
||||
setPolylineVertexType,
|
||||
patchWallType,
|
||||
|
||||
Reference in new issue
Block a user