Merge af1b4eed1e57ae91b
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
18 files changed
+1587
-25
No files matched your search
@@ -10,6 +10,8 @@
|
||||
// 2) „Zweiter Punkt:" → Punkt (Position auf DERSELBEN Kurve) → commit:
|
||||
// der Abschnitt zwischen beiden Positionen (Klick-Reihenfolge egal)
|
||||
// fällt weg, bis zu zwei Reststücke bleiben.
|
||||
// Wände ([113], gerade und Bogen) ebenso: das Stück dazwischen entfällt, Öffnungen bleiben am
|
||||
// richtigen Reststück (Lage umgerechnet), Bemassungs-Bezüge werden umgehängt.
|
||||
//
|
||||
// Bewusst NICHT unterstützt (Klick auf eine geschlossene Kurve oder eine mit
|
||||
// Bogen-Segmenten bricht NICHT ab, sondern bleibt im ersten Schritt — sonst
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
// Befehl bleibt aktiv).
|
||||
// • Wiederholend, bis Esc/Enter.
|
||||
//
|
||||
// Wände ([113], gerade und Bogen) verlängert der Kern bis zur nächsten Wandachse/-fläche, 2D-Kurve
|
||||
// oder Rasterachse (Bogenwände auf demselben Kreis).
|
||||
//
|
||||
// Geschlossene Formen (rect, geschlossene polyline) und reine Punktformen
|
||||
// (circle/arc/text) sind nicht extend-fähig — ein geschlossener Ring hat kein
|
||||
// "Ende". Treffer, Schneider und Verlängerung rechnet der Kern
|
||||
@@ -25,7 +28,14 @@
|
||||
|
||||
import { cmdMutation } from "../../core";
|
||||
import { cmdQuery, decodeShapes, pair } from "../../tools/coreCmd";
|
||||
import type { Command, CommandResult, CommandState } from "../types";
|
||||
import type { CmdOption, Command, CommandResult, CommandState } from "../types";
|
||||
|
||||
/**
|
||||
* Wände ([113]): Grenze ist die Achse der anderen Wand (ergibt einen T-Stoss) oder — Option „Fläche" —
|
||||
* ihre Aussenflächen. Die Wahl bleibt über Aufrufe erhalten.
|
||||
*/
|
||||
let toFace = false;
|
||||
const faceOption = (): CmdOption => ({ id: "face", labelKey: "cmd.wallEdit.faceOpt", value: toFace ? "on" : "off" });
|
||||
|
||||
// ── Zustand ───────────────────────────────────────────────────────────────────
|
||||
// Einziger Schritt „pick": auf die zu verlängernde Kurve (nahe dem Ende) klicken;
|
||||
@@ -47,24 +57,28 @@ export const extendCommand: Command = {
|
||||
name: "extend",
|
||||
labelKey: "cmd.extend.label",
|
||||
prompt: () => "cmd.extend.pick",
|
||||
accepts: () => ["point"],
|
||||
options: () => [],
|
||||
accepts: () => ["point", "option"],
|
||||
options: () => [faceOption()],
|
||||
|
||||
init: (): ExtendPick => ({ phase: "pick", lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as ExtendState;
|
||||
if (s.phase === "done") return finish();
|
||||
if (input.kind === "option" && input.id === "face") {
|
||||
toFace = !toFace;
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const { hit } = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickOpen", level: ctx.level.id, pt: pair(input.point) });
|
||||
if (!hit) return [s, { draft: null }];
|
||||
return [s, { draft: null, commit: cmdMutation({ cmd: "extend", id: hit, pt: pair(input.point) }) }];
|
||||
return [s, { draft: null, commit: cmdMutation({ cmd: "extend", id: hit, pt: pair(input.point), face: toFace }) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as ExtendState;
|
||||
if (s.phase !== "pick") return [s, { draft: null }];
|
||||
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "extend", level: ctx.level.id, pt: pair(point) });
|
||||
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "extend", level: ctx.level.id, pt: pair(point), face: toFace });
|
||||
if (!r.hit) return [s, { draft: null }];
|
||||
const preview = decodeShapes(r.shapes);
|
||||
return [s, { draft: { preview, vertices: [], hud: { at: point, text: "↗" } } }];
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
// 1) „Ecke wählen:" → Punkt (nächstgelegener Eckpunkt einer polyline/rect
|
||||
// wird gewählt; ein einzelnes `line`-Element hat keine eigene Ecke)
|
||||
// 2) „Radius:" → Punkt (Abstand von der Ecke) ODER getippte Zahl → commit
|
||||
// Wände ([113]): trifft der erste Klick keine Ecke, aber eine Wand, folgt „Zweite Wand“ (Zahl =
|
||||
// Radius, Vorgabe 0 = L-Ecke am Achsschnittpunkt; Radius nur bei geraden Wänden → Bogenwand).
|
||||
//
|
||||
// Die Verrundung wird als ECHTES Bogen-Segment gespeichert (`bulge`, s.
|
||||
// `geometry/bulge.ts`), nicht mehr tesselliert — editierbar wie jeder andere
|
||||
@@ -26,6 +28,7 @@ import type {
|
||||
Vec2,
|
||||
} from "../types";
|
||||
import { cornerPreview, pickCorner } from "./cornerHit";
|
||||
import { cmdQuery, decodeShapes, pair } from "../../tools/coreCmd";
|
||||
import type { CornerHit } from "./cornerHit";
|
||||
|
||||
const DEFAULT_RADIUS = 0.1; // m — Startwert, bis der Nutzer per Maus/Tab einen eigenen setzt
|
||||
@@ -53,7 +56,25 @@ interface FilletRadius extends CommandState {
|
||||
interface FilletDone extends CommandState {
|
||||
phase: "done";
|
||||
}
|
||||
type FilletState = FilletPick | FilletRadius | FilletDone;
|
||||
/**
|
||||
* Wände ([113]): erste Wand getroffen (statt einer Polylinien-Ecke), jetzt die zweite wählen. Beide
|
||||
* werden bis zum Achsschnittpunkt gestutzt/verlängert (L-Ecke); mit Radius > 0 (nur gerade Wände)
|
||||
* schliesst eine Bogenwand tangential an.
|
||||
*/
|
||||
interface FilletWall2 extends CommandState {
|
||||
phase: "wall2";
|
||||
wall: string;
|
||||
p1: Vec2;
|
||||
}
|
||||
type FilletState = FilletPick | FilletRadius | FilletDone | FilletWall2;
|
||||
|
||||
/** Radius der Wand-Verrundung (0 = scharfe L-Ecke), bleibt über Aufrufe. */
|
||||
let wallRadius = 0;
|
||||
|
||||
function wallDraft(ctx: CommandContext, s: FilletWall2, point: Vec2): ToolDraft | null {
|
||||
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "filletWalls", level: ctx.level.id, id: s.wall, p1: pair(s.p1), pt: pair(point), r: wallRadius });
|
||||
return { preview: decodeShapes(r.shapes), vertices: [s.p1], hud: { at: point, text: `R: ${wallRadius.toFixed(3)}m${r.hit ? "" : " ✗"}` } };
|
||||
}
|
||||
|
||||
const finish = (): [CommandState, CommandResult] => [
|
||||
{ phase: "done", lastPoint: null } as FilletDone,
|
||||
@@ -63,8 +84,11 @@ const finish = (): [CommandState, CommandResult] => [
|
||||
export const filletCommand: Command = {
|
||||
name: "fillet",
|
||||
labelKey: "cmd.fillet.label",
|
||||
prompt: (s) => ((s as FilletState).phase === "radius" ? "cmd.fillet.radius" : "cmd.fillet.pick"),
|
||||
accepts: (s) => ((s as FilletState).phase === "radius" ? ["point", "number"] : ["point"]),
|
||||
prompt: (s) => {
|
||||
const ph = (s as FilletState).phase;
|
||||
return ph === "radius" ? "cmd.fillet.radius" : ph === "wall2" ? "cmd.fillet.wall2" : "cmd.fillet.pick";
|
||||
},
|
||||
accepts: (s) => ((s as FilletState).phase === "radius" || (s as FilletState).phase === "wall2" ? ["point", "number"] : ["point"]),
|
||||
options: () => [],
|
||||
fields: (s) => ((s as FilletState).phase === "radius" ? RADIUS_FIELDS : []),
|
||||
|
||||
@@ -76,10 +100,28 @@ export const filletCommand: Command = {
|
||||
if (s.phase === "pick") {
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const { hit, preview } = pickCorner(ctx.project, ctx.level.id, input.point, "fillet", DEFAULT_RADIUS);
|
||||
if (!hit) return [s, { draft: null }]; // daneben geklickt → aktiv bleiben
|
||||
if (!hit) {
|
||||
const wall = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickWall", level: ctx.level.id, pt: pair(input.point) }).hit;
|
||||
if (!wall) return [s, { draft: null }]; // daneben geklickt → aktiv bleiben
|
||||
const w2: FilletWall2 = { phase: "wall2", wall, p1: input.point, lastPoint: input.point };
|
||||
return [w2, { draft: { preview: [], vertices: [input.point] } }];
|
||||
}
|
||||
const next: FilletRadius = { phase: "radius", hit, radius: DEFAULT_RADIUS, lastPoint: input.point };
|
||||
return [next, { draft: filletDraft(hit, preview, next.radius, input.point) }];
|
||||
}
|
||||
if (s.phase === "wall2") {
|
||||
if (input.kind === "number") {
|
||||
wallRadius = Math.max(0, input.value);
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const id2 = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickWall", level: ctx.level.id, pt: pair(input.point) }).hit;
|
||||
if (!id2 || id2 === s.wall) return [s, { draft: null }];
|
||||
return [
|
||||
{ phase: "done", lastPoint: null } as FilletDone,
|
||||
{ draft: null, done: true, commit: cmdMutation({ cmd: "filletWalls", id: s.wall, p1: pair(s.p1), id2, p2: pair(input.point), r: wallRadius }) },
|
||||
];
|
||||
}
|
||||
// phase === "radius"
|
||||
let r = s.radius;
|
||||
if (input.kind === "number") r = Math.max(0, input.value);
|
||||
@@ -98,6 +140,7 @@ export const filletCommand: Command = {
|
||||
if (!hit) return [s, { draft: null }];
|
||||
return [s, { draft: filletDraft(hit, preview, DEFAULT_RADIUS, point) }];
|
||||
}
|
||||
if (s.phase === "wall2") return [s, { draft: wallDraft(ctx, s, point) }];
|
||||
if (s.phase !== "radius") return [s, { draft: null }];
|
||||
const r = Math.max(0, dist(s.hit.corner, point));
|
||||
const ns: FilletRadius = { ...s, radius: r };
|
||||
|
||||
@@ -37,7 +37,8 @@ export const joinCommand: Command = {
|
||||
|
||||
// Sofort auf der Auswahl ausführen (kein Pick nötig).
|
||||
autoRun: (ctx: CommandContext): CommandResult => {
|
||||
const ids = selectedDrawingIds(ctx.selection);
|
||||
// Wände ([113]): kollineare (gleiche Laufrichtung) bzw. Bögen auf demselben Kreis werden eine Wand.
|
||||
const ids = [...selectedDrawingIds(ctx.selection), ...ctx.selection.wallIds];
|
||||
if (ids.length < 2) return { draft: null, done: true };
|
||||
return { draft: null, done: true, commit: cmdMutation({ cmd: "join", ids, stamp: uniqueStamp() }) };
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Offset — DAS Architektur-Primitiv (docs §2.10/§3.4 Tier-1, §3.6 persistente
|
||||
// Offset — DAS Architektur-Primitiv (auch für Wände, [113]) (docs §2.10/§3.4 Tier-1, §3.6 persistente
|
||||
// Distanz). Erzeugt eine parallel versetzte Kopie einer 2D-Kurve (line/polyline/
|
||||
// rect). Schritte:
|
||||
// 1) Kurve bestimmen: ist genau EIN passendes Drawing2D (line/polyline/rect)
|
||||
@@ -50,16 +50,24 @@ function isOffsetable(d: Drawing2D): boolean {
|
||||
return g.shape === "line" || g.shape === "polyline" || g.shape === "rect";
|
||||
}
|
||||
|
||||
/** Genau ein passendes Drawing2D vorselektiert? Dann liefere es. */
|
||||
function singleSelectedCurve(project: Project, sel: CommandSelection): Drawing2D | null {
|
||||
/**
|
||||
* Genau ein passendes Element vorselektiert? Dann liefere seine id: ein offset-fähiges Drawing2D oder
|
||||
* genau eine Wand ([113]: parallele, bei Bogenwänden konzentrische Kopie im Achsabstand).
|
||||
*/
|
||||
function singleSelectedCurve(project: Project, sel: CommandSelection): { id: string } | null {
|
||||
if (!sel.drawingId && sel.wallIds.length === 1) {
|
||||
const w = project.walls.find((x) => x.id === sel.wallIds[0]);
|
||||
return w && !w.locked ? { id: w.id } : null;
|
||||
}
|
||||
if (!sel.drawingId || sel.wallIds.length > 0) return null;
|
||||
const d = project.drawings2d.find((x) => x.id === sel.drawingId);
|
||||
if (d && isOffsetable(d)) return d;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Gibt es die Kurve noch (Side-Zustand)? */
|
||||
/** Gibt es die Kurve (oder Wand) noch (Side-Zustand)? */
|
||||
function hasCurve(project: Project, drawingId: string): boolean {
|
||||
if (project.walls.some((w) => w.id === drawingId)) return true;
|
||||
const src = project.drawings2d.find((x) => x.id === drawingId);
|
||||
return !!src && isOffsetable(src);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Split — teilt eine Wand (gerade oder Bogen) oder eine offene 2D-Kurve ([113]). Ein Schritt, wiederholend:
|
||||
// • Klick auf das Element → Teilung an dieser Stelle (Wand: Lot auf die Achse; Kurve: nächster Punkt).
|
||||
// • Option „Schnittpunkte" → der Klick teilt das Element an allen Schnittpunkten mit den übrigen
|
||||
// Wänden (Achsen), 2D-Kurven und Achsrastern des Geschosses.
|
||||
// Öffnungen bleiben am Stück, in dem ihre Mitte liegt (Lage umgerechnet), Bemassungs-Bezüge ([38])
|
||||
// werden auf die Stücke umgehängt. Treffer, Teilung und Vorschau rechnet der Kern
|
||||
// (`src-tauri/core/src/cmd_edit.rs` → `cmd_wall_edit.rs`); hier nur der Zustandsautomat.
|
||||
|
||||
import { cmdMutation } from "../../core";
|
||||
import { uniqueStamp } from "../../tools/types";
|
||||
import { cmdQuery, decodeShapes, pair } from "../../tools/coreCmd";
|
||||
import type { CmdOption, Command, CommandResult, CommandState } from "../types";
|
||||
|
||||
/** An allen Schnittpunkten statt am Klickpunkt teilen (bleibt über Aufrufe). */
|
||||
let atIntersections = false;
|
||||
const interOption = (): CmdOption => ({ id: "inter", labelKey: "cmd.split.interOpt", value: atIntersections ? "on" : "off" });
|
||||
|
||||
interface SplitPick extends CommandState {
|
||||
phase: "pick";
|
||||
}
|
||||
interface SplitDone extends CommandState {
|
||||
phase: "done";
|
||||
}
|
||||
type SplitState = SplitPick | SplitDone;
|
||||
|
||||
const finish = (): [CommandState, CommandResult] => [{ phase: "done", lastPoint: null } as SplitDone, { draft: null, done: true }];
|
||||
|
||||
export const splitCommand: Command = {
|
||||
name: "split",
|
||||
labelKey: "cmd.split.label",
|
||||
prompt: () => "cmd.split.pick",
|
||||
accepts: () => ["point", "option"],
|
||||
options: () => [interOption()],
|
||||
init: (): SplitPick => ({ phase: "pick", lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as SplitState;
|
||||
if (s.phase === "done") return finish();
|
||||
if (input.kind === "option" && input.id === "inter") {
|
||||
atIntersections = !atIntersections;
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const { hit } = cmdQuery<{ hit: string | null }>(ctx.project, { q: "split", level: ctx.level.id, pt: pair(input.point), inter: atIntersections });
|
||||
if (!hit) return [s, { draft: null }];
|
||||
const req = atIntersections ? { cmd: "splitInter", id: hit, stamp: uniqueStamp() } : { cmd: "splitAt", id: hit, pt: pair(input.point), stamp: uniqueStamp() };
|
||||
return [s, { draft: null, commit: cmdMutation(req) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as SplitState;
|
||||
if (s.phase !== "pick") return [s, { draft: null }];
|
||||
const r = cmdQuery<{ hit: string | null; shapes: number[] }>(ctx.project, { q: "split", level: ctx.level.id, pt: pair(point), inter: atIntersections });
|
||||
if (!r.hit) return [s, { draft: null }];
|
||||
return [s, { draft: { preview: decodeShapes(r.shapes), vertices: [point], hud: { at: point, text: "⫽" } } }];
|
||||
},
|
||||
|
||||
onConfirm: (): [CommandState, CommandResult] => finish(),
|
||||
onCancel: (): [CommandState, CommandResult] => finish(),
|
||||
};
|
||||
@@ -12,7 +12,8 @@
|
||||
// Linie → wird gekürzt/aufgeteilt; Polylinie → der getroffene Abschnitt fällt
|
||||
// raus (kann die Polylinie in Stücke teilen). Treffer, Schneider, Rest-Ketten und
|
||||
// Vorschau rechnet der Kern (`src-tauri/core/src/cmd_edit.rs`, [K4] S3); hier nur
|
||||
// der Zustandsautomat. Wände sind ausgenommen (nur Drawing2D). Sowohl Ziel-Kurve
|
||||
// der Zustandsautomat. Wände (gerade und Bogen, [113]) gehen genauso: Klick auf den wegzuschneidenden
|
||||
// Teil; Schneider sind die anderen Wände (Achse/Fläche), 2D-Kurven und Achsraster. Sowohl Ziel-Kurve
|
||||
// als auch Schneider dürfen Bogen-Segmente (bulge) tragen.
|
||||
//
|
||||
// Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md).
|
||||
@@ -20,7 +21,14 @@
|
||||
import { cmdMutation } from "../../core";
|
||||
import { uniqueStamp } from "../../tools/types";
|
||||
import { cmdQuery, decodeShapes, pair } from "../../tools/coreCmd";
|
||||
import type { Command, CommandResult, CommandState } from "../types";
|
||||
import type { CmdOption, Command, CommandResult, CommandState } from "../types";
|
||||
|
||||
/**
|
||||
* Wände ([113]): Grenze ist die Achse der anderen Wand (ergibt einen T-Stoss) oder — Option „Fläche" —
|
||||
* ihre Aussenflächen. Die Wahl bleibt über Aufrufe erhalten.
|
||||
*/
|
||||
let toFace = false;
|
||||
const faceOption = (): CmdOption => ({ id: "face", labelKey: "cmd.wallEdit.faceOpt", value: toFace ? "on" : "off" });
|
||||
|
||||
// ── Zustand ───────────────────────────────────────────────────────────────────
|
||||
// Einziger Schritt „pick": auf den wegzuschneidenden Abschnitt klicken;
|
||||
@@ -42,14 +50,18 @@ export const trimCommand: Command = {
|
||||
name: "trim",
|
||||
labelKey: "cmd.trim.label",
|
||||
prompt: () => "cmd.trim.pick",
|
||||
accepts: () => ["point"],
|
||||
options: () => [],
|
||||
accepts: () => ["point", "option"],
|
||||
options: () => [faceOption()],
|
||||
|
||||
init: (): TrimPick => ({ phase: "pick", lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as TrimState;
|
||||
if (s.phase === "done") return finish();
|
||||
if (input.kind === "option" && input.id === "face") {
|
||||
toFace = !toFace;
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
const { hit } = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickCurve", level: ctx.level.id, pt: pair(input.point) });
|
||||
if (!hit) {
|
||||
@@ -57,13 +69,13 @@ export const trimCommand: Command = {
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
// Wiederholend: NICHT done — nach dem Commit bleibt „pick" aktiv.
|
||||
return [s, { draft: null, commit: cmdMutation({ cmd: "trim", id: hit, pt: pair(input.point), stamp: uniqueStamp() }) }];
|
||||
return [s, { draft: null, commit: cmdMutation({ cmd: "trim", id: hit, pt: pair(input.point), face: toFace, stamp: uniqueStamp() }) }];
|
||||
},
|
||||
|
||||
onMove: (state, point, _snap, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as TrimState;
|
||||
if (s.phase !== "pick") return [s, { draft: null }];
|
||||
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "trim", level: ctx.level.id, pt: pair(point) });
|
||||
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "trim", level: ctx.level.id, pt: pair(point), face: toFace });
|
||||
if (!r.hit) return [s, { draft: null }];
|
||||
const preview = decodeShapes(r.shapes);
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// Wand-Editierbefehle ([113]): Trim, Extend, Teilen, Bruch, Verrunden, Verketten und Offset an Wänden über
|
||||
// die Befehls-Automaten (Treffer und Ops rechnet der Kern, `cmd_wall_edit.rs`).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../../model/sampleProject";
|
||||
import type { Opening, Project, Wall } from "../../model/types";
|
||||
import type { CmdInput, Command, CommandContext } from "../types";
|
||||
import type { ProjectMutation } from "../../core";
|
||||
import { trimCommand } from "./trim";
|
||||
import { extendCommand } from "./extend";
|
||||
import { splitCommand } from "./split";
|
||||
import { breakCommand } from "./break";
|
||||
import { filletCommand } from "./fillet";
|
||||
import { joinCommand } from "./join";
|
||||
import { offsetCommand } from "./offset";
|
||||
|
||||
const level = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
|
||||
const wt = sampleProject.wallTypes[0].id;
|
||||
const wall = (id: string, a: [number, number], b: [number, number], bulge?: number): Wall => ({
|
||||
id,
|
||||
type: "wall",
|
||||
floorId: level.id,
|
||||
categoryCode: "20",
|
||||
start: { x: a[0], y: a[1] },
|
||||
end: { x: b[0], y: b[1] },
|
||||
...(bulge !== undefined ? { bulge } : {}),
|
||||
wallTypeId: wt,
|
||||
height: 2.6,
|
||||
});
|
||||
const opening = (id: string, host: string, position: number): Opening =>
|
||||
({ id, type: "opening", hostWallId: host, categoryCode: "21", kind: "window", position, width: 1, height: 1.2, sillHeight: 0.9 }) as Opening;
|
||||
const proj = (walls: Wall[], openings: Opening[] = []): Project => ({ ...sampleProject, walls, openings, drawings2d: [], rooms: [], ceilings: [], stairs: [] });
|
||||
|
||||
function run(cmd: Command, p: Project, inputs: CmdInput[], wallIds: string[] = []): Project {
|
||||
const ctx: CommandContext = {
|
||||
project: p,
|
||||
level,
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: wt,
|
||||
lastPoint: null,
|
||||
selection: { wallIds, drawingId: null, drawingIds: [] },
|
||||
};
|
||||
let st = cmd.init();
|
||||
let fn: ProjectMutation | undefined = cmd.autoRun?.(ctx).commit;
|
||||
for (const input of inputs) {
|
||||
const [ns, res] = cmd.onInput(st, input, ctx);
|
||||
st = ns;
|
||||
if (res.commit) fn = res.commit;
|
||||
}
|
||||
return fn ? fn(p) : p;
|
||||
}
|
||||
const pt = (x: number, y: number): CmdInput => ({ kind: "point", point: { x, y } });
|
||||
const byId = (p: Project, id: string) => p.walls.find((w) => w.id === id)!;
|
||||
|
||||
describe("Wand-Editierbefehle ([113])", () => {
|
||||
it("Trim an der Querwand: Ende auf deren Achse, Öffnung im Rest bleibt, die weggeschnittene entfällt", () => {
|
||||
const p = proj([wall("a", [0, 0], [10, 0]), wall("b", [6, -3], [6, 3])], [opening("o1", "a", 1), opening("o2", "a", 7)]);
|
||||
const out = run(trimCommand, p, [pt(8, 0.02)]);
|
||||
expect(byId(out, "a").end).toEqual({ x: 6, y: 0 });
|
||||
expect(out.openings!.map((o) => o.id)).toEqual(["o1"]);
|
||||
});
|
||||
|
||||
it("Extend bis zur Achse bzw. (Option Fläche) bis zur Fläche", () => {
|
||||
const p = proj([wall("a", [0, 0], [4, 0]), wall("b", [6, -3], [6, 3])]);
|
||||
expect(byId(run(extendCommand, p, [pt(3.9, 0)]), "a").end).toEqual({ x: 6, y: 0 });
|
||||
const half = sampleProject.wallTypes[0].layers.reduce((s, l) => s + l.thickness, 0) / 2;
|
||||
const face = run(extendCommand, p, [{ kind: "option", id: "face" }, pt(3.9, 0)]);
|
||||
run(extendCommand, p, [{ kind: "option", id: "face" }]); // Option zurück (bleibt über Aufrufe)
|
||||
expect(byId(face, "a").end.x).toBeCloseTo(6 - half, 9);
|
||||
});
|
||||
|
||||
it("Teilen am Punkt: zwei Wände, Öffnung hängt am zweiten Stück mit umgerechneter Lage", () => {
|
||||
const p = proj([wall("a", [0, 0], [10, 0])], [opening("o", "a", 7)]);
|
||||
const out = run(splitCommand, p, [pt(4, 0.05)]);
|
||||
expect(out.walls).toHaveLength(2);
|
||||
expect(byId(out, "a").end).toEqual({ x: 4, y: 0 });
|
||||
const second = out.walls.find((w) => w.id !== "a")!;
|
||||
expect(out.openings![0].hostWallId).toBe(second.id);
|
||||
expect(out.openings![0].position).toBeCloseTo(3, 9);
|
||||
});
|
||||
|
||||
it("Teilen an Schnittpunkten einer Bogenwand", () => {
|
||||
const p = proj([wall("a", [-5, 0], [5, 0], 1), wall("b", [0, -8], [0, 8])]);
|
||||
const out = run(splitCommand, p, [{ kind: "option", id: "inter" }, pt(-5, 0.01)]);
|
||||
run(splitCommand, p, [{ kind: "option", id: "inter" }]);
|
||||
const arcs = out.walls.filter((w) => w.id !== "b");
|
||||
expect(arcs).toHaveLength(2);
|
||||
for (const w of arcs) expect(w.bulge).toBeCloseTo(Math.tan(Math.PI / 8), 9);
|
||||
});
|
||||
|
||||
it("Bruch: das Stück zwischen zwei Punkten entfällt", () => {
|
||||
const p = proj([wall("a", [0, 0], [10, 0])]);
|
||||
const out = run(breakCommand, p, [pt(3, 0), pt(5, 0)]);
|
||||
expect(out.walls.map((w) => [w.start.x, w.end.x])).toEqual([
|
||||
[0, 3],
|
||||
[5, 10],
|
||||
]);
|
||||
});
|
||||
|
||||
it("Verrunden zweier Wände: L-Ecke am Achsschnittpunkt, mit Radius eine Bogenwand", () => {
|
||||
const p = proj([wall("a", [0, 0], [4, 0]), wall("b", [6, 5], [6, -2])]);
|
||||
const l = run(filletCommand, p, [pt(2, 0), pt(6, 3)]);
|
||||
expect(byId(l, "a").end).toEqual({ x: 6, y: 0 });
|
||||
expect(byId(l, "b").end).toEqual({ x: 6, y: 0 });
|
||||
const r = run(filletCommand, p, [pt(2, 0), { kind: "number", value: 1 }, pt(6, 3)]);
|
||||
run(filletCommand, p, [pt(2, 0), { kind: "number", value: 0 }]);
|
||||
expect(r.walls).toHaveLength(3);
|
||||
const arc = r.walls.find((w) => w.bulge)!;
|
||||
expect(arc.start.x).toBeCloseTo(5, 9);
|
||||
expect(arc.end.y).toBeCloseTo(1, 9);
|
||||
});
|
||||
|
||||
it("Verketten kollinearer Wände und Offset", () => {
|
||||
const p = proj([wall("a", [0, 0], [4, 0]), wall("b", [4, 0], [10, 0])], [opening("o", "b", 1)]);
|
||||
const j = run(joinCommand, p, [], ["a", "b"]);
|
||||
expect(j.walls).toHaveLength(1);
|
||||
expect(j.walls[0].end).toEqual({ x: 10, y: 0 });
|
||||
expect(j.openings![0]).toMatchObject({ hostWallId: "a", position: 5 });
|
||||
const o = run(offsetCommand, proj([wall("a", [0, 0], [4, 0])]), [{ kind: "number", value: 2 }], ["a"]);
|
||||
expect(o.walls).toHaveLength(2);
|
||||
expect(Math.abs(o.walls[1].start.y)).toBeCloseTo(2, 9);
|
||||
});
|
||||
});
|
||||
@@ -59,6 +59,7 @@ import { revolveCommand } from "./cmds/revolve";
|
||||
import { loftCommand } from "./cmds/loft";
|
||||
import { trimCommand } from "./cmds/trim";
|
||||
import { breakCommand } from "./cmds/break";
|
||||
import { splitCommand } from "./cmds/split";
|
||||
import { extendCommand } from "./cmds/extend";
|
||||
import { filletCommand } from "./cmds/fillet";
|
||||
import { chamferCommand } from "./cmds/chamfer";
|
||||
@@ -133,6 +134,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
loft: loftCommand,
|
||||
trim: trimCommand,
|
||||
break: breakCommand,
|
||||
split: splitCommand,
|
||||
extend: extendCommand,
|
||||
fillet: filletCommand,
|
||||
chamfer: chamferCommand,
|
||||
@@ -271,6 +273,7 @@ export const ALIASES: Record<string, string> = {
|
||||
tr: "trim",
|
||||
br: "break",
|
||||
unterbrechen: "break",
|
||||
teilen: "split",
|
||||
ext: "extend",
|
||||
verlaengern: "extend",
|
||||
verlängern: "extend",
|
||||
|
||||
@@ -1905,6 +1905,11 @@ export const de = {
|
||||
"cmd.fillet.label": "Verrunden",
|
||||
"cmd.fillet.pick": "Ecke wählen:",
|
||||
"cmd.fillet.radius": "Radius:",
|
||||
"cmd.fillet.wall2": "Zweite Wand wählen (Zahl = Radius):",
|
||||
"cmd.wallEdit.faceOpt": "Fläche",
|
||||
"cmd.split.label": "Teilen",
|
||||
"cmd.split.pick": "Wand oder Linie an der Teilstelle anklicken (Esc beendet):",
|
||||
"cmd.split.interOpt": "Schnittpunkte",
|
||||
// Chamfer: Eckpunkt-Fasung mit Distanz (Maus oder getippt) — wie Fillet, ohne Bogen.
|
||||
"cmd.chamfer.label": "Fasen",
|
||||
"cmd.chamfer.pick": "Ecke wählen:",
|
||||
|
||||
@@ -1893,6 +1893,11 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.fillet.label": "Fillet",
|
||||
"cmd.fillet.pick": "Select corner:",
|
||||
"cmd.fillet.radius": "Radius:",
|
||||
"cmd.fillet.wall2": "Select second wall (number = radius):",
|
||||
"cmd.wallEdit.faceOpt": "Face",
|
||||
"cmd.split.label": "Split",
|
||||
"cmd.split.pick": "Click the wall or line at the split point (Esc to finish):",
|
||||
"cmd.split.interOpt": "Intersections",
|
||||
// Chamfer: corner bevel with a distance (mouse or typed) — like Fillet, no arc.
|
||||
"cmd.chamfer.label": "Chamfer",
|
||||
"cmd.chamfer.pick": "Select corner:",
|
||||
|
||||
@@ -368,7 +368,7 @@ const TOOLS_2D: ToolId[] = [
|
||||
];
|
||||
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
|
||||
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
|
||||
|
||||
type ToolsView = "list" | "icons";
|
||||
const VIEW_STORAGE_KEY = "dossier.toolsPanel.view";
|
||||
|
||||
@@ -114,6 +114,14 @@ export function CommandIcon({ name }: { name: string }) {
|
||||
<circle cx="4" cy="5" r="2" />
|
||||
</svg>
|
||||
);
|
||||
case "split":
|
||||
// Linie mit Teilstelle (Querstrich) — Teilen ([113]).
|
||||
return (
|
||||
<svg {...common}>
|
||||
<line x1="2.5" y1="9" x2="13.5" y2="9" />
|
||||
<line x1="8" y1="4" x2="8" y2="12" />
|
||||
</svg>
|
||||
);
|
||||
case "break":
|
||||
// Linie mit Lücke in der Mitte (Unterbrechen) + zwei Marker an den Bruchstellen.
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user