[176] Geknickter Schnitt: Knick per Mittel-Griff einfügen, per Kontextmenü löschen, Aufräumen nach dem Ziehen; Grundriss-Unterlage folgt den Knicken

Mittel-Griff je Segment (Ziehen fügt den Knick ein), Kern-Ops sectionBendInsert/sectionBendDelete/sectionLineTidy
(Knick auf Nachbarpunkt oder Geraden entfällt auch im Modell, Toleranz 6 Bildschirm-Pixel), ein Undo-Schritt je Zug.
Kontextmenü Knick einfügen/löschen. Unterlage im Schnitt (underlay_for_level) je Segment abgewickelt und an den
Winkelhalbierenden zugeschnitten. e2e/sectionBend.spec.ts. Goldens unverändert (Drift der komplex-Grundrisse besteht schon vorher).
This commit is contained in:
Claude committed 2026-11-10 18:20:48 +00:00
1 parent 1b9e01bc00
commit e53a2089dc
14 files changed
+452 -21

No files matched your search

+3
View File
@@ -31,6 +31,9 @@ export type GripRequest =
| { op: "excavationGrip"; id: string; index: number; pt: P }
// [176] Schnittlinie: 0 = Anfang, dann `bendPoints`, zuletzt das Ende.
| { op: "sectionLineGrip"; id: string; index: number; pt: P }
| { op: "sectionBendInsert"; id: string; seg: number; pt: P }
| { op: "sectionBendDelete"; id: string; index: number }
| { op: "sectionLineTidy"; id: string; tol?: number }
// [151] Parameter-Griff einer Podesttreppe (Kern `grip_drag::stair_param_drag`).
| { op: "stairParam"; id: string; index: number; pt: P }
| { op: "excavationEdge"; id: string; a: number; b: number; delta: P }
+2
View File
@@ -1030,6 +1030,8 @@ export const de = {
"ctx.print": "Drucken",
"ctx.insertPoint": "Punkt einfügen",
"ctx.deletePoint": "Punkt löschen",
"ctx.insertBend": "Knick einfügen",
"ctx.deleteBend": "Knick löschen",
"ctx.vertexType.corner": "Eckpunkt",
"ctx.vertexType.arc": "Bogenpunkt",
"ctx.vertexType.spline": "Splinepunkt",
+2
View File
@@ -1025,6 +1025,8 @@ export const en: Record<TranslationKey, string> = {
"ctx.print": "Print",
"ctx.insertPoint": "Insert point",
"ctx.deletePoint": "Delete point",
"ctx.insertBend": "Insert bend",
"ctx.deleteBend": "Delete bend",
"ctx.vertexType.corner": "Corner point",
"ctx.vertexType.arc": "Arc point",
"ctx.vertexType.spline": "Spline point",
+10
View File
@@ -57,6 +57,8 @@ export function AppContextMenu(props: {
deleteLevel,
reorderDrawings,
insertDrawingPoint,
insertSectionBend,
deleteSectionBend,
deleteDrawingPoint,
setPolylineVertexType,
reorderDrawingLevels,
@@ -139,6 +141,14 @@ export function AppContextMenu(props: {
? { id: d.id, pts: d.geom.pts, closed: d.geom.closed, bulge: d.geom.bulge }
: null;
})(),
// [176] Geknickte Schnittlinie: Knick einfügen/löschen am gewählten Schnitt.
selectedSectionLine: (() => {
if (selection.sectionLines.length !== 1) return null;
const l = project.drawingLevels.find((x) => x.id === selection.sectionLines[0] && x.linePoints);
return l?.linePoints ? { id: l.id, pts: [l.linePoints[0], ...(l.bendPoints ?? []), l.linePoints[1]] } : null;
})(),
insertSectionBend,
deleteSectionBend,
insertPolylinePoint: insertDrawingPoint,
deletePolylinePoint: deleteDrawingPoint,
setPolylineVertexType,
+21
View File
@@ -86,6 +86,10 @@ export interface MenuActions {
* anderes selektiert ist; dann entfallen die beiden Einträge.
*/
selectedPolyline: { id: string; pts: Vec2[]; closed: boolean; bulge?: number[] } | null;
/** [176] Einzeln gewählte Schnittlinie: Anfang, Knickpunkte, Ende (für „Knick einfügen/löschen"). */
selectedSectionLine?: { id: string; pts: Vec2[] } | null;
insertSectionBend?: (id: string, seg: number, pt: Vec2) => void;
deleteSectionBend?: (id: string, index: number) => void;
/** Ob eine Element-Stil-Zwischenablage gefüllt ist (aktiviert „Einfügen"). */
hasDrawingStyleClipboard: boolean;
/** Kopiert das Aussehen des ERSTEN gewählten 2D-Elements. */
@@ -315,6 +319,23 @@ function planMenuItems(
typeItem("spline", "ctx.vertexType.spline", "gesture"),
);
}
// [176] Schnittlinie: Knick am Klick einfügen bzw. den getroffenen Knick löschen (Anfang/Ende nicht).
const sec = a.selectedSectionLine;
const secTarget = sec ? nearestPolylineTarget({ pts: sec.pts, closed: false }, model, toleranceFor({ pts: sec.pts, closed: false })) : null;
if (sec && secTarget?.kind === "segment" && a.insertSectionBend) {
pointItems.push({
label: t("ctx.insertBend"),
icon: <MenuIcon name="add_circle" />,
onClick: () => a.insertSectionBend?.(sec.id, secTarget.segIndex, secTarget.at),
});
}
if (sec && secTarget?.kind === "vertex" && secTarget.index > 0 && secTarget.index < sec.pts.length - 1 && a.deleteSectionBend) {
pointItems.push({
label: t("ctx.deleteBend"),
icon: <MenuIcon name="do_not_disturb_on" />,
onClick: () => a.deleteSectionBend?.(sec.id, secTarget.index),
});
}
// Eigenschaften übertragen — dasselbe Muster wie im Ebenen-Menü, nur für
// 2D-Elemente. Kopieren ab einem gewählten Element, Einfügen sobald etwas
// in der Zwischenablage liegt.
+12 -2
View File
@@ -387,7 +387,13 @@ export interface ProjectSlice {
/** [68] Baugrube: Umriss-Ecke ziehen (Index = Ecke; Index = Eckenzahl: Sohlenhöhe). */
moveExcavationGrip: (id: string, index: number, pt: Vec2) => void;
/** [176] Griff einer Schnittlinie: 0 = Anfang, dann die Knickpunkte, zuletzt das Ende. */
moveSectionLineGrip: (id: string, index: number, pt: Vec2) => void;
moveSectionLineGrip: (id: string, index: number, pt: Vec2, coalesceKey?: string) => void;
/** [176] Knick in Segment `seg` (Mittel-Griff) einfügen; `coalesceKey` fasst den anschliessenden Zug zusammen. */
insertSectionBend: (id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
/** [176] Knick löschen (`index` wie bei {@link moveSectionLineGrip}; Anfang/Ende lassen sich nicht löschen). */
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;
moveExcavationEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
/** Verschiebt eine Decke (ganzer Umriss) um `delta`. */
moveCeilingBy: (ceilingId: string, delta: Vec2) => void;
@@ -1242,7 +1248,11 @@ export function createProjectSlice(
applyGrip({ op: "ceilingGrip", id: ceilingId, index, pt: gripPt(pt) }, `moveCeilingGrip:${ceilingId}:${index}`),
moveExcavationGrip: (id, index, pt) => applyGrip({ op: "excavationGrip", id, index, pt: gripPt(pt) }, `moveExcavationGrip:${id}:${index}`),
moveSectionLineGrip: (id, index, pt) => applyGrip({ op: "sectionLineGrip", id, index, pt: gripPt(pt) }, `moveSectionLineGrip:${id}:${index}`),
moveSectionLineGrip: (id, index, pt, coalesceKey) =>
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 }),
tidySectionLine: (id, coalesceKey, tol) => applyGrip({ op: "sectionLineTidy", id, ...(tol != null ? { tol } : {}) }, coalesceKey),
moveExcavationEdge: (id, aIndex, bIndex, delta) =>
applyGrip({ op: "excavationEdge", id, a: aIndex, b: bIndex, delta: gripPt(delta) }, `moveExcavationEdge:${id}:${aIndex}:${bIndex}`),
+47 -5
View File
@@ -181,8 +181,17 @@ export function useGripEditing(opts: {
const selectedSectionLine = modelEditable && selectedSectionLineId
? project.drawingLevels.find((l) => l.id === selectedSectionLineId && l.linePoints)
: undefined;
const sectionLineGrips = (l: NonNullable<typeof selectedSectionLine>): Vec2[] =>
l.linePoints ? [l.linePoints[0], ...(l.bendPoints ?? []), l.linePoints[1]] : [];
// Dahinter je Segment ein Mittel-Griff: Ziehen fügt dort einen Knick ein (Index = Punktzahl + Segment).
const sectionLineGrips = (l: NonNullable<typeof selectedSectionLine>): Vec2[] => {
if (!l.linePoints) return [];
const pts = [l.linePoints[0], ...(l.bendPoints ?? []), l.linePoints[1]];
const mids = pts.slice(1).map((q, i) => ({ x: (pts[i].x + q.x) / 2, y: (pts[i].y + q.y) / 2 }));
return [...pts, ...mids];
};
/** Laufender Zug an einer Schnittlinie: gemeinsamer Undo-Schlüssel, bei Mittel-Griff der eingefügte Knick. */
/** 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);
// 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");
@@ -324,7 +333,8 @@ export function useGripEditing(opts: {
}
if (selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
const pts = sectionLineGrips(selectedSectionLine);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
const nCorner = (selectedSectionLine.bendPoints?.length ?? 0) + 2;
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push(i < nCorner ? [0, nCorner - 1] : [nCorner, pts.length - 1]); });
return pts;
}
// [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt).
@@ -925,7 +935,25 @@ export function useGripEditing(opts: {
}
// [176] Schnittlinie: Endpunkt bzw. Knickpunkt live, ein Undo-Schritt je Zug (Kern `grips.rs`).
if (selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
storeState().moveSectionLineGrip(selectedSectionLine.id, index, pt);
const l = selectedSectionLine;
const nCorner = (l.bendPoints?.length ?? 0) + 2;
let drag = sectionDragRef.current;
if (!drag || drag.id !== l.id) {
drag = { id: l.id, key: `sectionLineDrag:${l.id}:${Date.now()}`, midIndex: -1, bendIndex: -1 };
sectionDragRef.current = drag;
}
if (drag.midIndex === index) {
// Mittel-Griff, Knick schon eingefügt: er folgt dem Zeiger (Index zählt gegen die alte Punktzahl).
storeState().moveSectionLineGrip(l.id, drag.bendIndex, pt, drag.key);
} else if (index < nCorner) {
storeState().moveSectionLineGrip(l.id, index, pt, drag.key);
} else {
// Erster Zug an einem Mittel-Griff: Knick in dieses Segment einfügen (Griff-Index des Knicks = Segment + 1).
const seg = index - nCorner;
drag.midIndex = index;
drag.bendIndex = seg + 1;
storeState().insertSectionBend(l.id, seg, pt, drag.key);
}
return;
}
// [68] Baugrube: Sohlen-Griff sofort (Höhe), Ecken als Vorschau bis zum Setzen.
@@ -1166,7 +1194,15 @@ export function useGripEditing(opts: {
// Aufräumen nach Abschluss/Verwerfen eines Griff- ODER Kanten-Drags (geteilt
// von onGripEnd/onGripCancel/onEdgeEnd/onEdgeCancel — nie beide gleichzeitig
// aktiv, ein gemeinsames Aufräumen ist daher unschädlich und einfacher).
// [176] Nach einem Zug an einer Schnittlinie: Knicke auf einem Nachbarpunkt / auf der Geraden entfernen
// (gleicher Undo-Schritt wie der Zug).
const tidySectionDrag = () => {
const drag = sectionDragRef.current;
// Zeiger-Genauigkeit: ca. 6 Pixel der Ansicht.
if (drag) storeState().tidySectionLine(drag.id, drag.key, sectionPxRef.current > 0 ? 6 / sectionPxRef.current : undefined);
};
const endEditing = () => {
sectionDragRef.current = null;
setDraft(null);
edgeAppliedDeltaRef.current = null; // Kanten-Drag beendet → Anker zurücksetzen
moveCoincidentRef.current = null; // Körper-Koinzidenz-Gruppe verwerfen
@@ -1262,6 +1298,7 @@ export function useGripEditing(opts: {
const gripHandlers = {
onGripMove: (index: number, raw: Vec2, pxPerMeter: number, mods: ToolMods) => {
sectionPxRef.current = pxPerMeter;
// Schnitt/Ansicht: Höhen-Griff (Wand-Oberkante, Fenster Ober-/Unterkante).
if (!modelEditable && sheet) {
const g = sheetHeightGrips[index];
@@ -1286,6 +1323,7 @@ export function useGripEditing(opts: {
// AKTUELLE — hier noch unveränderte — Position als Flucht-Bezugspunkt
// verankern (s. Kommentar an gripOriginRef).
if (gripDragInfoRef.current === null) {
sectionDragRef.current = null; // [176] neuer Zug: eigener Undo-Schlüssel, kein eingefügter Knick
gripOriginRef.current = grips[index];
const op0 = selectedOpeningId ? (project.openings ?? []).find((o) => o.id === selectedOpeningId) : undefined;
const dir0 = op0 ? openingWallDir() : null;
@@ -1517,6 +1555,7 @@ export function useGripEditing(opts: {
onGripEnd: () => {
commitPendingGrip();
commitPendingBody();
tidySectionDrag();
endEditing();
},
// Bewaffneten Punkt-Griff verwerfen (Escape): exakt auf `origin`
@@ -1530,7 +1569,10 @@ export function useGripEditing(opts: {
pendingGripRef.current = null;
pendingWallGripRef.current = null;
pendingAreaGripRef.current = null;
} else applyGrip(index, origin);
} else if (sectionDragRef.current) {
applyGrip(index, origin);
tidySectionDrag();
} else if (!selectedSectionLine) applyGrip(index, origin);
endEditing();
},
onEdgeEnd: () => {
+4
View File
@@ -126,6 +126,8 @@ export function useProjectActions(
const setCustomPaletteVisible = useStore((s) => s.setCustomPaletteVisible);
const setBuiltinPaletteVisible = useStore((s) => s.setBuiltinPaletteVisible);
const insertDrawingPoint = useStore((s) => s.insertDrawingPoint);
const insertSectionBend = useStore((s) => s.insertSectionBend);
const deleteSectionBend = useStore((s) => s.deleteSectionBend);
const deleteDrawingPoint = useStore((s) => s.deleteDrawingPoint);
const setPolylineVertexType = useStore((s) => s.setPolylineVertexType);
// Wandstile: immutable Patch eines Wandtyps (z. B. Schichtfugen-Stile). Kein
@@ -444,6 +446,8 @@ export function useProjectActions(
setCustomPaletteVisible,
setBuiltinPaletteVisible,
insertDrawingPoint,
insertSectionBend,
deleteSectionBend,
deleteDrawingPoint,
setPolylineVertexType,
patchWallType,