[77] Zauberstab: Option S wählt die Schraffur (oder nur Umriss)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-11-04 14:33:53 +00:00
1 parent 6fc77c28e4
commit 990d616680
5 files changed
+44 -10

No files matched your search

+1 -1
View File
@@ -1739,7 +1739,7 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
- ◐ **[77] Zauberstab.** · M — 4.11.: Befehl `wand` (Kürzel `zs`/`zauberstab`): Klick in eine von Linien umschlossene
Fläche (2D-Zeichnungen + Modellkanten des Geschosses, Kreise/Bögen als Sehnenzüge, Kreuzungen werden geteilt) →
geschlossene Polylinie mit der ersten Projekt-Schraffur; Vorschau beim Überfahren. Kern `magic_wand.rs`
(planarer Graph, kleinste Masche, `kernel2d::room_from_point_inside_faces`), Tests Rust + vitest. Offen: Wahl der
(planarer Graph, kleinste Masche, `kernel2d::room_from_point_inside_faces`), Tests Rust + vitest. Offen:
Schraffur/Option „nur Umriss", Inseln (Löcher) in der Fläche; Knopf in der Werkzeugleiste (2D) seit 4.11.; nicht in der App geklickt.
- ✅ **[78] Autotext im Plankopf.** Titelblock löst Projekt/Blatt/Massstab/Datum auf; Plannummer laufend
oder `Layout.planNumber` (27.10.).
+12
View File
@@ -34,6 +34,18 @@ describe("wandCommand", () => {
if (d.geom.shape === "polyline") expect(d.geom.closed).toBe(true);
});
it("Option S: nächste Schraffur, dann „keine“ (nur Umriss)", () => {
const p = project();
const ctx = ctxOf(p);
const [s1] = wandCommand.onInput(wandCommand.init(), { kind: "option", id: "hatch" }, ctx);
expect(wandCommand.options(s1)[0].value).toBe("—");
const [, r] = wandCommand.onInput(s1, { kind: "point", point: { x: 1, y: 1 } }, ctx);
const next = r.commit!(p);
expect(next.drawings2d[next.drawings2d.length - 1].hatchId).toBeUndefined();
const [s2] = wandCommand.onInput(s1, { kind: "option", id: "hatch" }, ctx);
expect(wandCommand.options(s2)[0].value).toBe("Beton");
});
it("Klick ausserhalb: kein Commit, Befehl bleibt aktiv", () => {
const p = project();
const [, r] = wandCommand.onInput(wandCommand.init(), { kind: "point", point: { x: 9, y: 9 } }, ctxOf(p));
+29 -9
View File
@@ -1,28 +1,48 @@
// Zauberstab ([77]): EIN Klick in eine von Linien umschlossene Fläche (2D-Zeichnungen und Modellkanten des
// Geschosses) → geschlossene Polylinie mit Schraffur. Die Masche sucht der Kern (`magic_wand.rs`); die Vorschau
// zeigt sie schon beim Überfahren. Schraffur: die erste Schraffur des Projekts (ohne Schraffuren nur der Umriss).
// zeigt sie schon beim Überfahren. Option S schaltet durch die Schraffuren des Projekts und „keine" (nur Umriss);
// Vorgabe ist die erste Schraffur. Die Wahl bleibt über mehrere Klicks (`sticky`).
import type { Command, CommandContext, CommandResult, CommandState, Vec2 } from "../types";
import type { CmdOption, Command, CommandContext, CommandResult, CommandState, Vec2 } from "../types";
import { createMutation, createPreview } from "../createCore";
interface WandState extends CommandState {
/** `hatch`: Index in `project.hatches` (`NONE` = nur Umriss); `name`: Anzeige in der Befehlszeile. */
sticky: { hatch: number; name?: string };
}
const NONE = -1;
const idle = (): [CommandState, CommandResult] => [{ phase: "point", lastPoint: null }, { draft: null, done: true }];
const hatchOf = (ctx: CommandContext): string | undefined => ctx.project.hatches[0]?.id;
/** Gewählte Schraffur: Index in `project.hatches`, `NONE` = nur Umriss; ausser Reichweite → erste. */
const hatchOf = (s: WandState, ctx: CommandContext): string | undefined =>
s.sticky.hatch === NONE ? undefined : (ctx.project.hatches[s.sticky.hatch] ?? ctx.project.hatches[0])?.id;
export const wandCommand: Command = {
name: "wand",
labelKey: "cmd.wand.label",
prompt: () => "cmd.wand.point",
accepts: () => ["point"],
options: () => [],
init: () => ({ phase: "point", lastPoint: null }),
accepts: () => ["point", "option"],
options: (state): CmdOption[] => {
const s = state as WandState;
const value = s.sticky?.hatch === NONE ? "—" : (s.sticky?.name ?? "1");
return [{ id: "hatch", labelKey: "cmd.wand.hatch", key: "S", value }];
},
init: (): WandState => ({ phase: "point", lastPoint: null, sticky: { hatch: 0 } }),
onInput: (state, input, ctx): [CommandState, CommandResult] => {
if (input.kind !== "point") return [state, { draft: null }];
const s = state as WandState;
if (input.kind === "option" && input.id === "hatch") {
const n = ctx.project.hatches.length;
// Reihenfolge: 0, 1, …, n−1, keine, 0 …
const next = s.sticky.hatch === NONE ? 0 : s.sticky.hatch + 1 >= n ? NONE : s.sticky.hatch + 1;
return [{ ...s, sticky: { hatch: next, name: next === NONE ? undefined : ctx.project.hatches[next]?.name } } as WandState, { draft: null }];
}
if (input.kind !== "point") return [s, { draft: null }];
const at: Vec2 = input.point;
// Kein Treffer: Befehl bleibt aktiv (nächster Klick), nichts wird angelegt.
if (!createPreview(ctx, { cmd: "wand" }, [at]).ok) return [state, { draft: null }];
return [state, { draft: null, commit: createMutation(ctx, { cmd: "wand", at, hatchId: hatchOf(ctx) }) }];
if (!createPreview(ctx, { cmd: "wand" }, [at]).ok) return [s, { draft: null }];
return [s, { draft: null, commit: createMutation(ctx, { cmd: "wand", at, hatchId: hatchOf(s, ctx) }) }];
},
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
+1
View File
@@ -1805,6 +1805,7 @@ export const de = {
"cmd.pointmarker.point": "Punkt:",
"cmd.wand.label": "Zauberstab",
"cmd.wand.point": "In eine umschlossene Fläche klicken:",
"cmd.wand.hatch": "Schraffur",
"cmd.grid.label": "Achsraster",
"cmd.grid.origin": "Ursprung des Achsrasters ( Radial ):",
"cmd.grid.radial": "Radial",
+1
View File
@@ -1794,6 +1794,7 @@ export const en: Record<TranslationKey, string> = {
"cmd.pointmarker.point": "Point:",
"cmd.wand.label": "Magic wand",
"cmd.wand.point": "Click inside an enclosed area:",
"cmd.wand.hatch": "Hatch",
"cmd.grid.label": "Structural grid",
"cmd.grid.origin": "Grid origin ( Radial ):",
"cmd.grid.radial": "Radial",