[K4][6][8] Aktionen erzeugen Ops direkt statt Projekt → Projekt + diffToOps

- Store `applyChange(ops | (p) => ops, coalesceKey?)` geht ohne Differenz an den Kern;
  `setProject` erkennt `opsMutation`-Funktionen und nimmt deren Ops.
- Umgestellt: Griffe (moveGripOf/moveElementByOf/moveEdgeOf, Decke/Dach/Treppe/Raum),
  Objekt-Info (updateWall/-Ceiling/-Opening/-Roof/-Stair/-Room/-Drawing2D, Farbe, Füllung,
  Vorder-/Hintergrund, Resize, Wand-/Deckendicke, Polylinien-Punkte), Auswahl verschieben/
  kopieren/drehen (`transformOps`), Löschen der Auswahl (+ Schnittlinien, eine Gruppe),
  Ebenen/Sichtbarkeit/Kategorien, Text-Tippen, Panel-Zeichnungs-Eigenschaften und die
  Zeichenbefehle (Wand, Decke, Raum, Treppe, Öffnung, Dach, Stütze, Extrusion, alle
  2D-Zeichenbefehle, move/copy/mirror/rotate/scale/array). Gruppen-Zuordnung beim Zeichnen
  in einer Gruppe über `activeGroupOps`.
- Griff-Zug mit mitgeführten Ecken: je Mausschritt eine Gruppe mit Schlüssel → ein
  Undo-Schritt für den ganzen Zug; aufgeschobene Commits beim Loslassen als Gruppe.
- Tests: Store-Zufallsfolgen (Leseansicht = Kern, Aktion = applyOps(vorher, ihre Ops),
  Undo bis Anfang/Redo bis Ende exakt), activeGroupOps = addNewElementsToActiveGroup;
  beim Umbau zusätzlich 2400 Zufallsschritte gegen die alte setProject-Fassung und 400
  Transformationen gegen das alte commitTransform geprüft (gleiches Projekt bis auf
  erzeugte ids und fehlend/leere Listen).
- Messung (vitest, 3000 Wände): Griff ziehen 3,3 → 0,2–0,3 ms/Schritt, Auswahl (300 Wände)
  verschieben 30 → 6–7 ms, Eigenschaft tippen 3 → 0,03 ms.

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-28 22:02:40 +00:00
1 parent b33f336bf0
commit a24cfbb3d7
49 files changed
+1001 -750

No files matched your search

+8 -7
View File
@@ -19,10 +19,11 @@ import type {
CommandResult,
CommandState,
DraftShape,
Project,
ToolDraft,
Vec2,
} from "../types";
import { addItems, opsMutation } from "../../core";
import type { CoreOp } from "../../core";
const EPS = 1e-6;
const CLOSE_HIT = 0.15; // Modell-Meter: Klick nahe Startpunkt schliesst den Zug
@@ -62,9 +63,9 @@ function revcloudDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
return draft;
}
function appendRevcloud(p: Project, points: Vec2[], closed: boolean, ctx: CommandContext): Project {
function appendRevcloud(points: Vec2[], closed: boolean, ctx: CommandContext): CoreOp[] {
const expanded = revisionCloudPts(points, closed, lastArcSize);
if (!expanded) return p;
if (!expanded) return [];
const d: Drawing2D = {
id: uniqueId("dr2d"),
type: "drawing2d",
@@ -72,7 +73,7 @@ function appendRevcloud(p: Project, points: Vec2[], closed: boolean, ctx: Comman
categoryCode: ctx.defaultCategoryCode,
geom: { shape: "polyline", pts: expanded.pts, closed, bulge: expanded.bulge },
};
return { ...p, drawings2d: [...p.drawings2d, d] };
return addItems("drawings2d", [d]);
}
const idle = (): [CommandState, CommandResult] => [
@@ -105,7 +106,7 @@ export const revcloudCommand: Command = {
}
if (input.id === "close" && s.phase === "next" && s.points.length >= 3) {
const pts = s.points;
return [idle()[0], { draft: null, done: true, commit: (p) => appendRevcloud(p, pts, true, ctx) }];
return [idle()[0], { draft: null, done: true, commit: opsMutation(() => appendRevcloud(pts, true, ctx)) }];
}
return [s, { draft: null }];
}
@@ -123,7 +124,7 @@ export const revcloudCommand: Command = {
// Klick nahe Startpunkt (≥3 Punkte) → schliessen (committet als Ring).
if (s.points.length >= 3 && segLen(s.points[0], pt) < CLOSE_HIT) {
const pts = s.points;
return [idle()[0], { draft: null, done: true, commit: (p) => appendRevcloud(p, pts, true, ctx) }];
return [idle()[0], { draft: null, done: true, commit: opsMutation(() => appendRevcloud(pts, true, ctx)) }];
}
const points = [...s.points, pt];
const ns: RevcloudDrawing = { phase: "next", points, cursor: pt, lastPoint: pt };
@@ -142,7 +143,7 @@ export const revcloudCommand: Command = {
const s = state as RevcloudState;
if (s.phase === "next" && s.points.length >= 2) {
const pts = s.points;
return [idle()[0], { draft: null, done: true, commit: (p) => appendRevcloud(p, pts, false, ctx) }];
return [idle()[0], { draft: null, done: true, commit: opsMutation(() => appendRevcloud(pts, false, ctx)) }];
}
return idle();
},