[205] Pausfolie wie Archicad: andere Ansicht gedämpft hinter/über der aktiven, je Reiter
Entscheid: Die Pausfolie ist UI-Zustand je Reiter (View-Slice `trace`, Typ `TraceReference` aus dem Rust-Modell), gespeichert mit dem Reiter (`uiState.viewTabs`) und im Ausschnitt (`ViewSnapshot.trace`); kein Op, kein Undo, nie im Druck/Export. Die Quelle rechnen die bestehenden Abfragen (planDomains, sectionPlan + eigene 2D-Elemente, elevationPlan) – `plan/trace.ts` schickt sie als Teil-Abfragen an die neue Kern-Abfrage `tracePlan` (`plan/trace.rs`): Ausrichtung nach Koordinatenraum (Schnitt/Ansicht hinter Grundriss an der Linie aufgeklappt, Grundriss hinter Schnitt wie die bisherige Unterlage, gleicher Raum deckungsgleich), Verschieben/Drehen, ohne Auswahl-Ids, Farbe nach Deckkraft in den Primitiven (WebGPU, Metal, SVG ohne eigene Logik). Vereinheitlicht: [203]-Geschoss-Überlagerung über „Andere grau“, `DrawingLevel.planUnderlayId` (Abfrage planUnderlay) und Schnitt/Ansicht hinter freien Zeichnungen über das Auge entfallen – nur noch Pausfolie. Bedienung: Navigator-Kontextmenü „Als Pausfolie zeigen“, Statusleiste „Pausfolie“ (Ein/Aus, Quelle, Farbe, Deckkraft, über/unter, Versatz, Drehung, Verschieben/Drehen per Klick, Zurücksetzen), Cmd/Ctrl+Shift+T (rebindbar, Menü Ansicht), Befehle tracemove/tracerotate. Tests: Rust plan::trace, vitest trace/traceRef (+ angepasste 203-/Overlay-Tests), e2e trace205/levelTrace203. Nicht in der Tauri-App/auf dem Mac (Metal) geprüft.
This commit is contained in:
50 files changed
+1664
-336
No files matched your search
@@ -0,0 +1,109 @@
|
||||
// [205] Pausfolie verschieben / drehen (Archicad „Referenz verschieben/drehen"): ändert nur die Lage der Pause des
|
||||
// Reiters (UI-Zustand, `state/traceActions.ts`), nie das Modell — `commit` bleibt leer.
|
||||
// tracemove: Basispunkt → Zielpunkt (oder Versatz als Zahl/relativ getippt, wie Bewegen).
|
||||
// tracerotate: Drehpunkt → Bezugsrichtung → Zielrichtung (oder Winkel in Grad getippt).
|
||||
|
||||
import { moveTraceAction, rotateTraceAction, shownTrace } from "../../state/traceActions";
|
||||
import type { Command, CommandResult, CommandState, ToolDraft, Vec2 } from "../types";
|
||||
|
||||
interface Idle extends CommandState {
|
||||
phase: "base";
|
||||
}
|
||||
interface Pick1 extends CommandState {
|
||||
phase: "second";
|
||||
a: Vec2;
|
||||
cursor: Vec2 | null;
|
||||
}
|
||||
interface Pick2 extends CommandState {
|
||||
phase: "third";
|
||||
a: Vec2;
|
||||
b: Vec2;
|
||||
cursor: Vec2 | null;
|
||||
}
|
||||
type S = Idle | Pick1 | Pick2;
|
||||
|
||||
const START: Idle = { phase: "base", lastPoint: null };
|
||||
const done = (): [CommandState, CommandResult] => [{ ...START }, { draft: null, done: true }];
|
||||
const ok = (p: Vec2 | undefined): p is Vec2 => !!p && Number.isFinite(p.x) && Number.isFinite(p.y);
|
||||
const deg = (c: Vec2, p: Vec2) => (Math.atan2(p.y - c.y, p.x - c.x) * 180) / Math.PI;
|
||||
|
||||
function lineDraft(a: Vec2, b: Vec2 | null, c?: Vec2 | null): ToolDraft | null {
|
||||
if (!b) return null;
|
||||
return { preview: [{ kind: "poly", pts: c ? [b, a, c] : [a, b], closed: false }], vertices: [a] };
|
||||
}
|
||||
|
||||
/** Ohne eingeschaltete Pausfolie startet der Befehl nicht. */
|
||||
const precondition = () => (shownTrace() ? null : ("cmd.tracemove.none" as const));
|
||||
|
||||
export const traceMoveCommand: Command = {
|
||||
name: "tracemove",
|
||||
labelKey: "cmd.tracemove.label",
|
||||
prompt: (s) => ((s as S).phase === "second" ? "cmd.tracemove.to" : "cmd.tracemove.from"),
|
||||
accepts: (s) => ((s as S).phase === "second" ? ["point", "number"] : ["point"]),
|
||||
options: () => [],
|
||||
precondition,
|
||||
init: () => ({ ...START }),
|
||||
onInput: (state, input): [CommandState, CommandResult] => {
|
||||
const s = state as S;
|
||||
if (s.phase === "second" && input.kind === "number" && Number.isFinite(input.value) && s.cursor) {
|
||||
// Distanz in Richtung des Cursors.
|
||||
const dx = s.cursor.x - s.a.x;
|
||||
const dy = s.cursor.y - s.a.y;
|
||||
const len = Math.hypot(dx, dy);
|
||||
if (len > 1e-12) moveTraceAction({ x: (dx / len) * input.value, y: (dy / len) * input.value });
|
||||
return done();
|
||||
}
|
||||
if (input.kind !== "point" || !ok(input.point)) return [s, { draft: null }];
|
||||
if (s.phase === "base") return [{ phase: "second", a: input.point, cursor: null, lastPoint: input.point } as Pick1, { draft: null }];
|
||||
if (s.phase === "second") {
|
||||
moveTraceAction({ x: input.point.x - s.a.x, y: input.point.y - s.a.y });
|
||||
return done();
|
||||
}
|
||||
return done();
|
||||
},
|
||||
onMove: (state, point): [CommandState, CommandResult] => {
|
||||
const s = state as S;
|
||||
if (s.phase !== "second" || !ok(point)) return [s, { draft: null }];
|
||||
return [{ ...s, cursor: point } as S, { draft: lineDraft(s.a, point) }];
|
||||
},
|
||||
onConfirm: () => done(),
|
||||
onCancel: () => done(),
|
||||
};
|
||||
|
||||
export const traceRotateCommand: Command = {
|
||||
name: "tracerotate",
|
||||
labelKey: "cmd.tracerotate.label",
|
||||
prompt: (s) => {
|
||||
const p = (s as S).phase;
|
||||
return p === "base" ? "cmd.tracerotate.center" : p === "second" ? "cmd.tracerotate.ref" : "cmd.tracerotate.to";
|
||||
},
|
||||
accepts: (s) => ((s as S).phase === "base" ? ["point"] : ["point", "number"]),
|
||||
options: () => [],
|
||||
precondition,
|
||||
init: () => ({ ...START }),
|
||||
onInput: (state, input): [CommandState, CommandResult] => {
|
||||
const s = state as S;
|
||||
if (s.phase !== "base" && input.kind === "number" && Number.isFinite(input.value)) {
|
||||
// Winkel getippt: Drehung um den Drehpunkt um so viele Grad (CCW).
|
||||
rotateTraceAction(s.a, input.value);
|
||||
return done();
|
||||
}
|
||||
if (input.kind !== "point" || !ok(input.point)) return [s, { draft: null }];
|
||||
if (s.phase === "base") return [{ phase: "second", a: input.point, cursor: null, lastPoint: input.point } as Pick1, { draft: null }];
|
||||
if (s.phase === "second") {
|
||||
if (Math.hypot(input.point.x - s.a.x, input.point.y - s.a.y) < 1e-9) return [s, { draft: null }];
|
||||
return [{ phase: "third", a: s.a, b: input.point, cursor: null, lastPoint: input.point } as Pick2, { draft: null }];
|
||||
}
|
||||
if (Math.hypot(input.point.x - s.a.x, input.point.y - s.a.y) < 1e-9) return [s, { draft: null }];
|
||||
rotateTraceAction(s.a, deg(s.a, input.point) - deg(s.a, s.b));
|
||||
return done();
|
||||
},
|
||||
onMove: (state, point): [CommandState, CommandResult] => {
|
||||
const s = state as S;
|
||||
if (s.phase === "base" || !ok(point)) return [s, { draft: null }];
|
||||
if (s.phase === "second") return [{ ...s, cursor: point } as S, { draft: lineDraft(s.a, point) }];
|
||||
return [{ ...s, cursor: point } as S, { draft: lineDraft(s.a, s.b, point) }];
|
||||
},
|
||||
onConfirm: () => done(),
|
||||
onCancel: () => done(),
|
||||
};
|
||||
@@ -75,6 +75,7 @@ import { georefCommand } from "./cmds/georef";
|
||||
import { blockCommand } from "./cmds/block";
|
||||
import { defblockCommand } from "./cmds/defblock";
|
||||
import { presentationCommand } from "./cmds/presentation";
|
||||
import { traceMoveCommand, traceRotateCommand } from "./cmds/tracemove";
|
||||
|
||||
/** Alle bekannten Befehle, Schlüssel = Befehlsname (lowercase). */
|
||||
export const COMMANDS: Record<string, Command> = {
|
||||
@@ -157,6 +158,8 @@ export const COMMANDS: Record<string, Command> = {
|
||||
georef: georefCommand,
|
||||
block: blockCommand,
|
||||
defblock: defblockCommand,
|
||||
tracemove: traceMoveCommand,
|
||||
tracerotate: traceRotateCommand,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user