[213] Kameras in Verschieben/Kopieren/Drehen/Spiegeln, Mehrfachauswahl und Zwischenablage: Standpunkt und Ziel werden abgebildet, Kopien heissen „… Kopie“; Gruppen offen, IFC bewusst ohne Kameras
This commit is contained in:
10 files changed
+173
-18
No files matched your search
@@ -88,6 +88,8 @@ export interface CommandSelection {
|
||||
openingIds?: string[];
|
||||
/** [149] Gewählte Bäume (Verschieben/Kopieren/Spiegeln/Drehen: Stammmitte). */
|
||||
treeIds?: string[];
|
||||
/** [213] Gewählte Kameras (Verschieben/Kopieren/Drehen/Spiegeln: Standpunkt und Ziel). */
|
||||
cameraIds?: string[];
|
||||
/** [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`: Gelände, Höhenlinien, Baugrube, Netze, Bilder). */
|
||||
contextIds?: string[];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { describe, it, expect } from "vitest";
|
||||
import { collectElementClipboard, pasteElementClipboard, isClipboardEmpty } from "./elementClipboard";
|
||||
import { applyOps } from "../core/ops";
|
||||
import type { ElementSelectionIds } from "./elementClipboard";
|
||||
import type { Project, Wall, Opening, Ceiling } from "../model/types";
|
||||
import type { Project, Wall, Opening, Ceiling, Camera } from "../model/types";
|
||||
|
||||
function emptySel(): ElementSelectionIds {
|
||||
return {
|
||||
@@ -151,3 +151,31 @@ describe("pasteElementClipboard", () => {
|
||||
expect(p.walls[0].id).toBe("w1");
|
||||
});
|
||||
});
|
||||
|
||||
describe("[213] Kameras in der Zwischenablage", () => {
|
||||
const cam = (id: string, name: string): Camera => ({
|
||||
id, type: "camera", name, floorId: "eg", categoryCode: "92",
|
||||
position: { x: 1, y: 2 }, eyeHeight: 1.6, target: { x: 6, y: 2 }, targetHeight: 1.4,
|
||||
fovDeg: 55, projection: "perspective",
|
||||
});
|
||||
|
||||
it("kopiert und fügt Kameras mit neuer id, Namen „… Kopie“ und auf dem aktiven Geschoss ein", () => {
|
||||
const p = { ...project(), cameras: [cam("k1", "Süd")] };
|
||||
const clip = collectElementClipboard(p, { ...emptySel(), cameraIds: ["k1"] })!;
|
||||
expect(clip).not.toBeNull();
|
||||
expect(isClipboardEmpty(clip)).toBe(false);
|
||||
const { ops, pastedIds } = pasteElementClipboard(p, clip, "og");
|
||||
const next = applyOps(p, ops);
|
||||
expect(next.cameras!.length).toBe(2);
|
||||
const c = next.cameras!.find((x) => x.id === pastedIds.cameraIds[0])!;
|
||||
expect(c.id).not.toBe("k1");
|
||||
expect(c.floorId).toBe("og");
|
||||
expect(c.name).toBe("Süd Kopie");
|
||||
expect(c.position).toEqual({ x: 1, y: 2 });
|
||||
expect(c.target).toEqual({ x: 6, y: 2 });
|
||||
expect(c.fovDeg).toBe(55);
|
||||
// Zweites Einfügen: Namen bleiben eindeutig.
|
||||
const again = applyOps(next, pasteElementClipboard(next, clip, "og").ops);
|
||||
expect(again.cameras!.map((x) => x.name).sort()).toEqual(["Süd", "Süd Kopie", "Süd Kopie 2"]);
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,7 @@
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type {
|
||||
Camera,
|
||||
Ceiling,
|
||||
Column,
|
||||
Drawing2D,
|
||||
@@ -48,6 +49,8 @@ export interface ElementSelectionIds {
|
||||
columnIds: string[];
|
||||
/** [149] Bäume (optional: ältere Aufrufer kennen sie nicht). */
|
||||
treeIds?: string[];
|
||||
/** [213] Kameras. */
|
||||
cameraIds?: string[];
|
||||
}
|
||||
|
||||
/** Tiefe Kopie der gewählten Elemente über alle Bauteil-Arten hinweg. */
|
||||
@@ -63,6 +66,8 @@ export interface ElementClipboard {
|
||||
columns: Column[];
|
||||
/** [149] Bäume (optional: Zwischenablagen älterer Fenster haben sie nicht). */
|
||||
trees?: Tree[];
|
||||
/** [213] Kameras (optional: ältere Zwischenablagen haben sie nicht). */
|
||||
cameras?: Camera[];
|
||||
}
|
||||
|
||||
const EMPTY_CLIPBOARD: ElementClipboard = {
|
||||
@@ -89,7 +94,8 @@ export function isClipboardEmpty(c: ElementClipboard): boolean {
|
||||
c.rooms.length === 0 &&
|
||||
c.extrudedSolids.length === 0 &&
|
||||
c.columns.length === 0 &&
|
||||
(c.trees?.length ?? 0) === 0
|
||||
(c.trees?.length ?? 0) === 0 &&
|
||||
(c.cameras?.length ?? 0) === 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -130,6 +136,8 @@ export function collectElementClipboard(
|
||||
const columns = (project.columns ?? []).filter((c) => columnIds.has(c.id));
|
||||
const treeIds = new Set(sel.treeIds ?? []);
|
||||
const trees = (project.trees ?? []).filter((t) => treeIds.has(t.id));
|
||||
const cameraIds = new Set(sel.cameraIds ?? []);
|
||||
const cameras = (project.cameras ?? []).filter((c) => cameraIds.has(c.id));
|
||||
|
||||
const clip: ElementClipboard = {
|
||||
walls: walls.map((w) => structuredClone(w)),
|
||||
@@ -142,6 +150,7 @@ export function collectElementClipboard(
|
||||
extrudedSolids: extrudedSolids.map((s) => structuredClone(s)),
|
||||
columns: columns.map((c) => structuredClone(c)),
|
||||
trees: trees.map((t) => structuredClone(t)),
|
||||
cameras: cameras.map((c) => structuredClone(c)),
|
||||
};
|
||||
return isClipboardEmpty(clip) ? null : clip;
|
||||
}
|
||||
@@ -158,6 +167,7 @@ export interface PastedIds {
|
||||
extrudedSolidIds: string[];
|
||||
columnIds: string[];
|
||||
treeIds: string[];
|
||||
cameraIds: string[];
|
||||
}
|
||||
|
||||
/** Projekt-Liste → Feld in {@link PastedIds}. */
|
||||
@@ -172,6 +182,7 @@ const PASTED_KEY: Record<string, keyof PastedIds> = {
|
||||
extrudedSolids: "extrudedSolidIds",
|
||||
columns: "columnIds",
|
||||
trees: "treeIds",
|
||||
cameras: "cameraIds",
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -202,6 +213,7 @@ export function addedIds(ops: readonly CoreOp[]): PastedIds {
|
||||
extrudedSolidIds: [],
|
||||
columnIds: [],
|
||||
treeIds: [],
|
||||
cameraIds: [],
|
||||
};
|
||||
for (const op of ops) {
|
||||
const key = op.kind === "add" ? PASTED_KEY[op.collection] : undefined;
|
||||
|
||||
@@ -86,6 +86,7 @@ describe("Selection", () => {
|
||||
roomIds: [],
|
||||
openingIds: [],
|
||||
treeIds: [],
|
||||
cameraIds: [],
|
||||
contextIds: [],
|
||||
});
|
||||
expect(toTransformSelection(s)).toEqual(c);
|
||||
|
||||
@@ -145,6 +145,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
|
||||
roomIds: sel.rooms,
|
||||
openingIds: sel.openings,
|
||||
treeIds: sel.trees,
|
||||
cameraIds: sel.cameras,
|
||||
contextIds: sel.contextObjects,
|
||||
};
|
||||
}
|
||||
@@ -167,6 +168,7 @@ export function hasTransformable(sel: Selection): boolean {
|
||||
sel.rooms.length > 0 ||
|
||||
sel.openings.length > 0 ||
|
||||
sel.trees.length > 0 ||
|
||||
sel.cameras.length > 0 ||
|
||||
sel.contextObjects.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ export interface TransformSelection {
|
||||
openingIds?: string[];
|
||||
/** [149] Gewählte Bäume (Stammmitte wird transformiert). */
|
||||
treeIds?: string[];
|
||||
/** [213] Gewählte Kameras (Standpunkt und Ziel werden transformiert, Höhen/Bildwinkel bleiben). */
|
||||
cameraIds?: string[];
|
||||
/** [193] Gewählte Gelände-/Umgebungs-Elemente (alle Punkte x/y werden abgebildet). */
|
||||
contextIds?: string[];
|
||||
}
|
||||
@@ -73,6 +75,7 @@ export function toTransformSel(sel: CommandSelection): TransformSelection {
|
||||
roomIds: sel.roomIds,
|
||||
openingIds: sel.openingIds,
|
||||
treeIds: sel.treeIds,
|
||||
cameraIds: sel.cameraIds,
|
||||
contextIds: sel.contextIds,
|
||||
};
|
||||
}
|
||||
@@ -95,6 +98,7 @@ export function hasTransformSelection(sel: CommandSelection, op?: string): boole
|
||||
(sel.stairIds?.length ?? 0) > 0 ||
|
||||
(sel.roomIds?.length ?? 0) > 0 ||
|
||||
(sel.treeIds?.length ?? 0) > 0 ||
|
||||
(sel.cameraIds?.length ?? 0) > 0 ||
|
||||
(sel.contextIds?.length ?? 0) > 0
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user