[267] Ansichten aller Seiten: Befehl ansichten und Menü Ansicht legen Nord/Ost/Süd/West um das Gebäude an (Hauptrichtung aus minimalem Hüllrechteck, vorhandene Seiten ausgelassen, ein Undo-Schritt)

This commit is contained in:
Claude committed 2026-11-16 12:49:52 +00:00
1 parent 4c3f7d4f6c
commit 96a801ccb2
21 files changed
+646 -9

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
// [267] Befehl `ansichten`: Ansichten Nord/Ost/Süd/West um das Gebäude in einem Schritt. Geometrie (Hauptrichtung,
// gedrehtes Haus, L-Form) prüft der Kern (`elevation_set.rs`); hier der Weg über Befehl, Meldung und Ops.
import { describe, expect, it } from "vitest";
import { elevationsCommand } from "./elevations";
import { emptyProject, sampleProject } from "../../model/sampleProject";
import type { Project } from "../../model/types";
import type { CommandContext } from "../types";
import { applyOps } from "../../core/ops";
import { getCommand } from "../registry";
const ctxOf = (p: Project) => ({ project: p, level: { id: "eg", kind: "floor" }, defaultCategoryCode: "20", activeWallTypeId: "", selection: { wallIds: [], drawingId: null } }) as unknown as CommandContext;
const run = (p: Project) => elevationsCommand.autoRun!(ctxOf(p));
const apply = (p: Project) => {
const res = run(p);
return { res, project: res.commit ? applyOps(p, res.commit.toOps(p)) : p };
};
const elevations = (p: Project) => p.drawingLevels.filter((l) => l.kind === "elevation");
describe("ansichten", () => {
it("ist als Befehl und Alias registriert", () => {
expect(getCommand("ansichten")).toBe(elevationsCommand);
});
it("Musterhaus: legt Nord, Ost, West an; die vorhandene Süd-Ansicht bleibt", () => {
const before = elevations(sampleProject);
expect(before.map((l) => l.name)).toEqual(["Ansicht Süd"]);
const { res, project } = apply(sampleProject);
expect(res.done).toBe(true);
expect(res.notice?.key).toBe("elevations.doneSkipped");
expect(res.notice?.params).toMatchObject({ n: 3 });
const names = elevations(project).map((l) => l.name);
expect(names).toEqual(["Ansicht Süd", "Ansicht Nord", "Ansicht Ost", "Ansicht West"]);
for (const l of elevations(project)) {
expect(l.linePoints).toHaveLength(2);
expect(l.directionSign).toBe(1);
}
// Nord blickt nach −y (Linie nördlich des Hauses, von rechts nach links), Ost nach −x.
const nord = elevations(project).find((l) => l.name === "Ansicht Nord")!.linePoints!;
expect(nord[1].x).toBeLessThan(nord[0].x);
expect(nord[0].y).toBeGreaterThan(4);
});
it("zweiter Lauf: nichts mehr zu tun, keine Änderung", () => {
const { project } = apply(sampleProject);
const again = apply(project);
expect(again.res.commit).toBeUndefined();
expect(again.res.notice?.key).toBe("elevations.allExist");
expect(elevations(again.project)).toHaveLength(4);
});
it("leeres Projekt: Meldung, keine Ebenen", () => {
const { res, project } = apply(emptyProject);
expect(res.commit).toBeUndefined();
expect(res.notice).toMatchObject({ key: "elevations.empty", kind: "warning" });
expect(elevations(project)).toHaveLength(elevations(emptyProject).length);
});
});
+26
View File
@@ -0,0 +1,26 @@
// [267] Ansichten aller Seiten — legt die Ansichten Nord/Ost/Süd/West um das Gebäude an und endet sofort
// (Null-Schritt-Befehl wie `terrain`). Rechnung im Kern (`elevation_set.rs`), Brücke in `commands/elevationSetFor.ts`.
import { elevationSetFor } from "../elevationSetFor";
import type { Command, CommandContext, CommandResult, CommandState } from "../types";
const IDLE: CommandState = { phase: "idle", lastPoint: null };
const run = (ctx: CommandContext): CommandResult => {
const { commit, notice } = elevationSetFor(ctx.project);
return { draft: null, done: true, ...(commit ? { commit } : {}), notice };
};
export const elevationsCommand: Command = {
name: "ansichten",
labelKey: "cmd.elevations.label",
prompt: () => "cmd.elevations.prompt",
accepts: () => [],
options: () => [],
init: () => ({ ...IDLE }),
autoRun: run,
onInput: (_s, _i, ctx): [CommandState, CommandResult] => [{ ...IDLE }, run(ctx)],
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
onConfirm: (_s, ctx): [CommandState, CommandResult] => [{ ...IDLE }, run(ctx)],
onCancel: (): [CommandState, CommandResult] => [{ ...IDLE }, { draft: null, done: true }],
};
+51
View File
@@ -0,0 +1,51 @@
// [267] Ansichten Nord/Ost/Süd/West in einem Schritt: der Kern (`elevation_set.rs`) legt um das Gebaute vier
// Ansichtslinien an und lässt Seiten mit vorhandener Ansicht aus. Hier nur die Brücke: Namen (t()), Abfrage vorab
// für die Meldung, Mutation. Gebraucht vom Befehl `ansichten` und vom Menü (`state/elevationSet.ts`); ohne Store, damit der Befehl keinen Importzyklus über die Registry bildet.
import { cmdMutation, documentFor } from "../core/document";
import type { ProjectMutation } from "../core";
import type { Project } from "../model/types";
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { uniqueStamp } from "../tools/types";
type Side = "north" | "east" | "south" | "west";
const NAME_KEY: Record<Side, TranslationKey> = {
north: "elevations.name.north",
east: "elevations.name.east",
south: "elevations.name.south",
west: "elevations.name.west",
};
interface Plan {
empty: boolean;
create: Side[];
existing: Side[];
}
/** Meldung (i18n-Key + Platzhalter + Art) zum Ergebnis. */
export interface ElevationSetNotice {
key: TranslationKey;
params?: Record<string, string | number>;
kind: "info" | "warning";
}
const names = (sides: Side[]): string => sides.map((s) => t(NAME_KEY[s])).join(", ");
/** Mutation (nur wenn etwas entsteht) und Meldung für `project`. */
export function elevationSetFor(project: Project): { commit?: ProjectMutation; notice: ElevationSetNotice } {
const plan = documentFor(project).createQuery<Plan>({ q: "elevationsPlan" });
if (plan.empty) return { notice: { key: "elevations.empty", kind: "warning" } };
if (plan.create.length === 0) return { notice: { key: "elevations.allExist", kind: "info" } };
const commit = cmdMutation({
cmd: "elevations",
names: { north: t(NAME_KEY.north), east: t(NAME_KEY.east), south: t(NAME_KEY.south), west: t(NAME_KEY.west) },
stamp: uniqueStamp(),
});
const done = { n: plan.create.length, names: names(plan.create) };
const notice: ElevationSetNotice = plan.existing.length
? { key: "elevations.doneSkipped", params: { ...done, existing: names(plan.existing) }, kind: "info" }
: { key: "elevations.done", params: done, kind: "info" };
return { commit, notice };
}
+4
View File
@@ -72,6 +72,7 @@ import { excavationCommand } from "./cmds/excavation";
import { meshCropCommand } from "./cmds/meshcrop";
import { measureCommand } from "./cmds/measure";
import { sectionLineCommand, viewLineCommand } from "./cmds/sectionline";
import { elevationsCommand } from "./cmds/elevations";
import { georefCommand } from "./cmds/georef";
import { blockCommand } from "./cmds/block";
import { defblockCommand } from "./cmds/defblock";
@@ -162,6 +163,7 @@ export const COMMANDS: Record<string, Command> = {
measure: measureCommand,
sectionline: sectionLineCommand,
viewline: viewLineCommand,
ansichten: elevationsCommand,
georef: georefCommand,
block: blockCommand,
defblock: defblockCommand,
@@ -326,6 +328,8 @@ export const ALIASES: Record<string, string> = {
netzzuschnitt: "meshcrop",
schnittlinie: "sectionline",
ansichtslinie: "viewline",
elevations: "ansichten",
fassaden: "ansichten",
bezugspunkt: "georef",
nullpunkt: "georef",
};
+13
View File
@@ -2086,6 +2086,19 @@ export const de = {
"cmd.roof.shape.flach": "Flachdach",
"cmd.sectionline.label": "Schnittlinie",
"cmd.viewline.label": "Ansichtslinie",
// [267] Ansichten aller Seiten
"cmd.elevations.label": "Ansichten aller Seiten",
"cmd.elevations.prompt": "Ansichten Nord, Ost, Süd und West um das Gebäude anlegen",
"menu.view.elevations": "Ansichten aller Seiten erzeugen",
"history.cmd.ansichten": "Ansichten aller Seiten",
"elevations.name.north": "Ansicht Nord",
"elevations.name.east": "Ansicht Ost",
"elevations.name.south": "Ansicht Süd",
"elevations.name.west": "Ansicht West",
"elevations.empty": "Kein Gebäude gefunden: zeichne zuerst Wände, Decken oder Dächer, dann entstehen die Ansichten um das Gebäude.",
"elevations.done": "{n} Ansichten angelegt: {names}.",
"elevations.doneSkipped": "{n} Ansichten angelegt: {names}. Schon vorhanden: {existing}.",
"elevations.allExist": "Alle vier Ansichten sind schon vorhanden.",
"cmd.sectionline.start": "Schnitt-Startpunkt:",
"cmd.sectionline.end": "Schnitt-Endpunkt:",
"cmd.sectionline.next": "Knickpunkt oder Endpunkt (Enter/Doppelklick beendet):",
+13
View File
@@ -2075,6 +2075,19 @@ export const en: Record<TranslationKey, string> = {
"cmd.roof.shape.flach": "Flat roof",
"cmd.sectionline.label": "Section line",
"cmd.viewline.label": "Elevation line",
// [267] Elevations of all sides
"cmd.elevations.label": "Elevations of all sides",
"cmd.elevations.prompt": "Create north, east, south and west elevations around the building",
"menu.view.elevations": "Create Elevations of All Sides",
"history.cmd.ansichten": "Elevations of all sides",
"elevations.name.north": "Elevation North",
"elevations.name.east": "Elevation East",
"elevations.name.south": "Elevation South",
"elevations.name.west": "Elevation West",
"elevations.empty": "No building found: draw walls, slabs or roofs first, then the elevations are placed around the building.",
"elevations.done": "{n} elevations created: {names}.",
"elevations.doneSkipped": "{n} elevations created: {names}. Already present: {existing}.",
"elevations.allExist": "All four elevations already exist.",
"cmd.sectionline.start": "Section start point:",
"cmd.sectionline.end": "Section end point:",
"cmd.sectionline.next": "Bend point or end point (Enter/double-click finishes):",
+7
View File
@@ -19,6 +19,7 @@ import { openRenderDialog } from "../state/renderDialogHook";
import { openShortcutOverview } from "../state/shortcutOverviewHook";
import { openBugReport, openQuickGuide } from "../state/helpMenuHook";
import { openImageExportDialog } from "../state/imageExportDialogHook";
import { createElevationSet } from "../state/elevationSet";
import { APP_VERSION } from "../ui/TopBar";
import { BUILD_INFO } from "../update/buildInfo";
import type { View3d, ViewType } from "../model/viewTypes";
@@ -441,6 +442,12 @@ export function useNativeAppMenu(
accelerator: "CmdOrCtrl+Shift+T",
action: () => handlersRef.current.onSelectionAction?.("toggleTrace"),
}),
// [267] Ansichten Nord/Ost/Süd/West um das Gebäude anlegen.
await PredefinedMenuItem.new({ item: "Separator" }),
await MenuItem.new({
text: t("menu.view.elevations"),
action: () => createElevationSet(),
}),
// [211] Rendering mit Blender/Cycles (Dialog in App montiert, Öffner über den Modul-Hook).
await PredefinedMenuItem.new({ item: "Separator" }),
await MenuItem.new({
+1 -1
View File
@@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "ansichten", "autodim", "excavation"];
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure", "erkennen"];
type ToolsView = "list" | "icons";
+15
View File
@@ -0,0 +1,15 @@
// [267] Menü Ansicht → „Ansichten aller Seiten erzeugen“: dieselbe Rechnung wie der Befehl `ansichten`
// (`commands/elevationSetFor.ts`), angewendet als ein Undo-Schritt, Meldung über `notify`.
import { elevationSetFor } from "../commands/elevationSetFor";
import { t } from "../i18n";
import { getState } from "./appStore";
/** Menü: Ansichten anlegen (ein Undo-Schritt) und melden. */
export function createElevationSet(): void {
const st = getState();
const res = elevationSetFor(st.project);
const commit = res.commit;
if (commit) st.applyChange((p) => commit.toOps(p));
st.notify(t(res.notice.key, res.notice.params), res.notice.kind);
}
+4
View File
@@ -16,6 +16,7 @@ import { openAboutDialog } from "../state/aboutDialogHook";
import { openBugReport, openQuickGuide } from "../state/helpMenuHook";
import { openShortcutOverview } from "../state/shortcutOverviewHook";
import { openImageExportDialog } from "../state/imageExportDialogHook";
import { createElevationSet } from "../state/elevationSet";
export interface AppMenuBarProps {
/** Datei: Neu/Neu aus Vorlage/Öffnen/Speichern/Importieren. */
@@ -174,6 +175,9 @@ export const AppMenuBar = memo(function AppMenuBar({
active: referenceLines,
},
{ divider: true },
// [267] Ansichten Nord/Ost/Süd/West um das Gebäude anlegen (ein Undo-Schritt, Meldung statt Dialog).
{ label: t("menu.view.elevations"), onSelect: createElevationSet },
{ divider: true },
// [211] Rendering mit Blender/Cycles (Dialog in App montiert, Öffner über den Modul-Hook).
{ label: t("menu.view.image3d"), onSelect: openImageExportDialog },
{ label: t("menu.view.rendering"), onSelect: openRenderDialog, preview: true },
+11
View File
@@ -333,6 +333,17 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
<polyline points="11.5,11.5 11.5,8 8,8" />
</svg>
);
case "ansichten":
// Ansichten aller Seiten: Gebäude (Rechteck) mit vier Blickpfeilen von aussen.
return (
<svg {...common}>
<rect x="5.5" y="5.5" width="5" height="5" />
<polyline points="6.5,1.5 8,3 9.5,1.5" />
<polyline points="6.5,14.5 8,13 9.5,14.5" />
<polyline points="1.5,6.5 3,8 1.5,9.5" />
<polyline points="14.5,6.5 13,8 14.5,9.5" />
</svg>
);
case "viewline":
// Ansichtslinie: Standpunkt (Kreis) mit Blickkegel.
return (