Merge branch 'pending-213' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-13 19:31:43 +00:00
commit 1a6fa43b45
10 files changed
+173 -18

No files matched your search

+7 -3
View File
@@ -214,7 +214,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
Wiederholtes wie Fenster/Bäume), Sichtkegel-Culling, Schatten-Map nur bei Änderung von Licht/Modell, Kantenpass günstiger, LOD für
Kontext/Gelände. Messbar machen (Bench in `dossier-cli bench` bzw. render3d-Test) und vorher/nachher belegen. Opus. · L
- [211] Rendering mit Blender/Cycles (◐, Eintrag unter „Import und Export“): Mac-Gegenprobe (Tauri, Metal), Blender 3.6/4.x, Dialog im Browser klicken.
- [213] Kameras und Begehen/WASD (◐, Eintrag unter „Grundriss“): Kopieren/Gruppen/IFC, Mac-Gegenprobe.
- [213] Kameras und Begehen/WASD (◐, Eintrag unter „Grundriss“): Gruppen, Mac-Gegenprobe (IFC entfällt: keine Kamera-Entität).
- ◐ **[214]** 3D-Engine optimieren (12.11., Wunsch Maintainer). Messung: `BENCH_3D=1 BENCH_3D_OUT=<dir> npx vitest run
src/viewport/render3d.bench.test.ts` (Kern/TS je Änderung wie `updateModel`, Szenen komplex/gross/kontext) und
`render_png --bench <dir>/<szene>` (Aufbau, Bildzeit, Draw-Calls, Teil-Update, GPU-Speicher); Kern-Profil `model3d_cache::tests::bench214`.
@@ -458,8 +458,12 @@ Punktwolken/BCF-Ausbau, Windows-Paket, [C5]/[C7]/[15] Kern-Umbauten — ausser s
exakt (Reiterwechsel, Sonnenstudie übernimmt `sunWhen`); `viewport/cameraView.ts::cameraToView(project, camera)` liefert dieselbe `ViewCamera` wie `getCamera()`
(Anschluss für das Rendering [211]: `cameraToView` statt der Live-Ansicht). Begehen: Umschalt+F bzw. Knopf „Begehen“, darin W/A/S/D und Pfeile gehen (horizontal, Augenhöhe bleibt),
Q/E runter/hoch, Umschalt ×4, Alt ×0.25, Maus (links oder rechts) schaut um den Augpunkt, Esc beendet; die Tasten gelten nur im Modus (sonst kollidieren sie mit S/D/Q, [190]), pro Frame mit
gekapptem Zeitschritt (`viewport/walk.ts`). Beispiel: Kamera „Südost“ im Musterhaus komplex. Offen: nicht in der Tauri-App geprüft (3D headless leer, Kamera-Brücke nur per Zustand); nativer Mac-3D ohne
Begehen/Kameras (`native.rs` ist Linux/winit); Kameras fehlen in Verschieben/Kopieren/Gruppen/IFC/Zwischenablage; Stil „Sonne am Tag“ (Datum/Uhrzeit-Dialog) und Animation entlang mehrerer Kameras. · M
gekapptem Zeitschritt (`viewport/walk.ts`). Beispiel: Kamera „Südost“ im Musterhaus komplex. Bearbeiten (13.11.): Kameras gehen in Verschieben/Kopieren/Reihe/Drehen/Spiegeln/Skalieren (Kern `cmd_transform.rs::mv_camera`: Standpunkt und Ziel
werden abgebildet, Augen-/Zielhöhe, Bildwinkel, Sichthöhe bleiben; gesperrte bleiben; Kopie = neue id `camera-…` und Name „… Kopie“, nummeriert bei Kollision; Vorschau mit Blicklinie),
in die Mehrfachauswahl (`cameraIds` in `TransformSelection`/`CommandSelection`) und in die Element-Zwischenablage (Ctrl/Cmd+C/V, `cmd_paste.rs`, auf dem aktiven Geschoss, Name „… Kopie“).
Gruppen: Kameras sind NICHT gruppierbar (das Gruppenmodell hat feste Listen `wallIds … treeIds`, keine generische; bräuchte `cameraIds` in `Group`, `groups.rs`, `groupActions.ts`, Sperr-Helfer).
IFC: Kameras werden bewusst nicht exportiert (IFC kennt keine Kamera als Bauteil). Offen: nicht in der Tauri-App geprüft (3D headless leer, Kamera-Brücke nur per Zustand); nativer Mac-3D ohne
Begehen/Kameras (`native.rs` ist Linux/winit); Kameras in Gruppen; Stil „Sonne am Tag“ (Datum/Uhrzeit-Dialog) und Animation entlang mehrerer Kameras. · M
- ◐ **[205]** Pausfolie/Referenz wie Archicad „Trace & Reference“ (12.11., Wunsch Maintainer). Umgesetzt (12.11.): **Entscheid:** die Pausfolie ist UI-Zustand je Reiter (`state.trace`, Typ `TraceReference` aus dem Rust-Modell; mit dem Reiter in `uiState.viewTabs` und im Ausschnitt `ViewSnapshot.trace` gespeichert, kein Op, kein Undo, nie im Druck/Export). Die Quelle rechnen die bestehenden Abfragen (`planDomains`, `sectionPlan` + eigene 2D-Elemente, `elevationPlan`), die TS-Fassade `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 Schnittlinie aufgeklappt, u längs der Linie, jenseits des Grundrisses; Grundriss hinter Schnitt wie bisher die Unterlage `underlay.rs`; gleicher Raum deckungsgleich, Schnitt hinter Schnitt höhengleich), dann Verschieben/Drehen (Starrkörper), Auswahl-Ids weg, Farbe nach Deckkraft zur Papierfarbe aufgehellt in den Primitiven selbst — alle drei Zeichenwege (WebGPU, Metal, SVG) ohne eigene Logik; `withTrace` legt sie unter/über den Plan. **Vereinheitlicht:** die [203]-Überlagerung anderer Geschosse über den Modus „Andere grau“ entfällt im Grundriss (Modus wirkt nur noch im 3D), die Grundriss-Unterlage `DrawingLevel.planUnderlayId` (Objekt-Info Schnittlinie, Abfrage `planUnderlay`) entfällt, Schnitt/Ansicht hinter freien Zeichnungen über das Auge entfällt — alles nur noch als Pausfolie; Auge/Modus komponiert weiter Geschoss ↔ freie Zeichnung. **Bedienung:** Navigator-Kontextmenü „Als Pausfolie zeigen“, Statusleiste „Pausfolie“ (Ein/Aus, ▴: Quelle, Farbe, Deckkraft, über/unter, Versatz, Drehung, Verschieben/Drehen per Klick, Zurücksetzen), Kürzel Cmd/Ctrl+Shift+T (rebindbar, Menü Ansicht), Befehle `tracemove`/`tracerotate`. Tests: Rust `plan::trace` (9), vitest `plan/trace.test.ts`, `state/traceRef.test.ts`, `levelTrace203` angepasst, e2e `trace205`. Offen: Fang auf der Pause nur im Schnitt/in der Ansicht (im Grundriss nicht); Blatt/Layout als Quelle und Pause im Layout; nicht in der Tauri-App/auf dem Mac (Metal) geprüft. Opus. · L
- ◐ **[182]** Tabs/Ansichten wie Archicad (11.11., Wunsch Maintainer). Umgesetzt: Reiter-Arten Grundriss · 3D · Schnitt · Ansicht ·
2D-Zeichnung/Layout werden nie gemischt (`navigateToLevel`/`switchViewKind` in `state/viewTabs.ts`, Anwendung in
+35 -9
View File
@@ -20,7 +20,7 @@ use std::collections::HashMap;
/// Listen der Zwischenablage: (Schlüssel in `clip`, Projekt-Liste, id-Präfix, Geschoss-Feld).
/// Reihenfolge = Reihenfolge der ids und der Ops (Wände vor Öffnungen).
const LISTS: [(&str, &str, &str, &str); 10] = [
const LISTS: [(&str, &str, &str, &str); 11] = [
("walls", "walls", "W", "floorId"),
("drawings", "drawings2d", "dr2d", "levelId"),
("ceilings", "ceilings", "C", "floorId"),
@@ -31,15 +31,19 @@ const LISTS: [(&str, &str, &str, &str); 10] = [
("extrudedSolids", "extrudedSolids", "extrude", "levelId"),
("columns", "columns", "column", "floorId"),
("trees", "trees", "tree", "floorId"),
("cameras", "cameras", "camera", "floorId"),
];
/// Ops des Einfügens: je Liste ein `add` (leere Listen ohne Op).
pub fn paste_ops(clip: &Value, level_id: &str, stamp: &str) -> Vec<Op> {
/// `root` = das Projekt-Dokument (nur für die Namen vorhandener Kameras, [213]).
pub fn paste_ops(root: &serde_json::Map<String, Value>, clip: &Value, level_id: &str, stamp: &str) -> Vec<Op> {
let mut ids = IdGen::new(stamp);
// Alte → neue ids der Wirte (Wände, Decken, Dächer; ids sind projektweit eindeutig).
let mut host_ids: HashMap<String, String> = HashMap::new();
let level = Value::String(level_id.to_owned());
let mut ops = Vec::new();
// [213] Eingefügte Kameras heissen „… Kopie“ (nummeriert bei Kollision), damit Namen eindeutig bleiben.
let mut cam_names: std::collections::HashSet<String> = arr(root.get("cameras")).iter().filter_map(|c| field(c, "name").and_then(Value::as_str).map(String::from)).collect();
for (key, collection, prefix, level_field) in LISTS {
let mut items = Vec::new();
for e in arr(field(clip, key)) {
@@ -60,7 +64,12 @@ pub fn paste_ops(clip: &Value, level_id: &str, stamp: &str) -> Vec<Op> {
host_ids.insert(old.to_owned(), id.clone());
}
}
items.push(with_all(&as_copy(e), vec![("id", Value::String(id)), (level_field, level.clone())]));
let mut v = with_all(&as_copy(e), vec![("id", Value::String(id)), (level_field, level.clone())]);
if key == "cameras" {
let name = crate::cmd_transform::copy_name(field(e, "name").and_then(Value::as_str).unwrap_or(""), &mut cam_names);
v = with_all(&v, vec![("name", Value::String(name))]);
}
items.push(v);
}
if !items.is_empty() {
ops.push(Op::Add { collection: collection.into(), items, at: None });
@@ -82,7 +91,7 @@ mod tests {
"openings": [{"id": "o1", "hostWallId": "w1", "ifcGlobalId": "1AbcDEFghijKLMNOPQRSt2"}],
"columns": [{"id": "c1", "floorId": "eg", "ifcGlobalId": "2AbcDEFghijKLMNOPQRSt3"}]
});
for op in paste_ops(&clip, "og", "s") {
for op in paste_ops(&Default::default(), &clip, "og", "s") {
for item in op.to_json()["items"].as_array().unwrap() {
assert!(item.get("ifcGlobalId").is_none(), "{item}");
}
@@ -104,7 +113,7 @@ mod tests {
"columns": [{"id": "c1", "floorId": "eg"}],
"rooms": []
});
let ops: Vec<Value> = paste_ops(&clip, "og", "s").iter().map(Op::to_json).collect();
let ops: Vec<Value> = paste_ops(&Default::default(), &clip, "og", "s").iter().map(Op::to_json).collect();
assert_eq!(ops.len(), 4);
assert_eq!(ops[0]["collection"], "walls");
let walls = ops[0]["items"].as_array().unwrap();
@@ -134,7 +143,7 @@ mod tests {
{"id": "c", "hostWallId": "", "hostCeilingId": "c9"}
]
});
let ops: Vec<Value> = paste_ops(&clip, "eg", "s").iter().map(Op::to_json).collect();
let ops: Vec<Value> = paste_ops(&Default::default(), &clip, "eg", "s").iter().map(Op::to_json).collect();
let os = ops.iter().find(|o| o["collection"] == "openings").unwrap()["items"].as_array().unwrap().clone();
assert_eq!(os.len(), 3, "Deckenöffnung ohne kopierte Decke fällt weg");
assert_eq!((&os[0]["hostWallId"], &os[1]["hostWallId"]), (&json!("W-s-1"), &json!("W-s-1")));
@@ -142,10 +151,27 @@ mod tests {
assert_eq!((&os[2]["hostRoofId"], &os[2]["hostWallId"]), (&json!("RF-s-2"), &json!("")));
}
/// [213] Kameras: neue id, aktives Geschoss, Name „… Kopie“ (nummeriert bei Kollision).
#[test]
fn kameras_bekommen_kopie_namen() {
let clip = json!({"cameras": [
{"id": "k1", "type": "camera", "name": "Süd", "floorId": "eg", "position": {"x": 1, "y": 2}, "target": {"x": 5, "y": 2}, "fovDeg": 50},
{"id": "k2", "type": "camera", "name": "Süd", "floorId": "eg", "position": {"x": 1, "y": 2}, "target": {"x": 5, "y": 2}}
]});
let root = json!({"cameras": [{"id": "k1", "name": "Süd"}, {"id": "x", "name": "Süd Kopie"}]});
let ops: Vec<Value> = paste_ops(root.as_object().unwrap(), &clip, "og", "s").iter().map(Op::to_json).collect();
assert_eq!(ops.len(), 1);
assert_eq!(ops[0]["collection"], "cameras");
let c = ops[0]["items"].as_array().unwrap();
assert_eq!((c[0]["id"].as_str(), c[0]["name"].as_str(), c[0]["floorId"].as_str()), (Some("camera-s-1"), Some("Süd Kopie 2"), Some("og")));
assert_eq!(c[1]["name"], "Süd Kopie 3");
assert_eq!((c[0]["fovDeg"].clone(), c[0]["position"].clone()), (json!(50), json!({"x": 1, "y": 2})));
}
#[test]
fn leere_oder_kaputte_zwischenablage_ergibt_nichts() {
assert!(paste_ops(&json!({}), "og", "s").is_empty());
assert!(paste_ops(&json!(null), "og", "s").is_empty());
assert!(paste_ops(&json!({"walls": 3, "openings": [{"id": "o"}]}), "og", "s").is_empty());
assert!(paste_ops(&Default::default(), &json!({}), "og", "s").is_empty());
assert!(paste_ops(&Default::default(), &json!(null), "og", "s").is_empty());
assert!(paste_ops(&Default::default(), &json!({"walls": 3, "openings": [{"id": "o"}]}), "og", "s").is_empty());
}
}
+79 -3
View File
@@ -287,6 +287,28 @@ fn mv_tree(t: &Value, xf: &Xf) -> Value {
with(t, "position", pt(n.0, n.1))
}
/// [213] Kamera: Standpunkt und Ziel werden abgebildet (Drehen dreht beide um den Drehpunkt, Spiegeln spiegelt
/// beide); Augenhöhe, Zielhöhe, Bildwinkel und Sichthöhe bleiben (Skalieren: Abstand Standpunkt–Ziel skaliert mit).
fn mv_camera(c: &Value, xf: &Xf) -> Value {
let (px, py) = xy(field(c, "position").unwrap_or(&Value::Null));
let (tx, ty) = xy(field(c, "target").unwrap_or(&Value::Null));
let (p, t) = (xf.apply(px, py), xf.apply(tx, ty));
with_all(c, vec![("position", pt(p.0, p.1)), ("target", pt(t.0, t.1))])
}
/// [213] Name einer Kopie: „Name Kopie“, bei Kollision „Name Kopie 2“, „Name Kopie 3“ …; `used` wächst mit.
pub fn copy_name(name: &str, used: &mut std::collections::HashSet<String>) -> String {
let base = if name.is_empty() { "Kamera".to_string() } else { name.to_string() };
let mut cand = format!("{base} Kopie");
let mut n = 2;
while used.contains(&cand) {
cand = format!("{base} Kopie {n}");
n += 1;
}
used.insert(cand.clone());
cand
}
/// [193] Gelände-/Umgebungs-Element (`Project.context`): alle x/y abbilden, z bleibt. Netze (`importedMesh`,
/// `terrainMesh`): Positionen (x,y,z flach), bei Spiegelung Dreiecks-Umlauf umkehren; Höhenlinien: Punkte
/// (eine wahre Kurve `curve` fällt weg, ausser bei reiner Verschiebung); Baugrube: Umriss; Luftbild: Rahmen.
@@ -680,6 +702,8 @@ pub struct Sel {
pub opening_ids: Option<Vec<String>>,
/// [149] Gewählte Bäume.
pub tree_ids: Option<Vec<String>>,
/// [213] Gewählte Kameras (Standpunkt und Ziel werden transformiert).
pub camera_ids: Option<Vec<String>>,
/// [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`).
pub context_ids: Option<Vec<String>>,
}
@@ -737,6 +761,7 @@ enum Kind {
Stair,
Room,
Tree,
Camera,
Context,
}
@@ -773,6 +798,7 @@ fn gather<'a>(root: &'a Map<String, Value>, sel: &Sel, op: &str, ignore_lock: bo
each("stairs", Ids::opt(&sel.stair_ids), Kind::Stair);
each("rooms", Ids::opt(&sel.room_ids), Kind::Room);
each("trees", Ids::opt(&sel.tree_ids), Kind::Tree);
each("cameras", Ids::opt(&sel.camera_ids), Kind::Camera);
each("context", Ids::opt(&sel.context_ids), Kind::Context);
out
}
@@ -959,6 +985,10 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
if !trees.is_empty() {
patch("trees", &|t| trees.has(t) && !locked(t), &|t| mv_tree(t, &xf));
}
let cams = Ids::opt(&sel.camera_ids);
if !cams.is_empty() {
patch("cameras", &|c| cams.has(c) && !locked(c), &|c| mv_camera(c, &xf));
}
let ctx = Ids::opt(&sel.context_ids);
if !ctx.is_empty() {
patch("context", &|c| ctx.has(c), &|c| mv_context(c, &xf));
@@ -979,8 +1009,10 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
// Kopien (Kopie/Reihe/Verteilen bzw. gespiegelte Kopie).
let mut ids = IdGen::new(&req.stamp);
let mut new: [Vec<Value>; 10] = Default::default();
let mut new: [Vec<Value>; 11] = Default::default();
let mut new_openings = Vec::new();
// [213] Namen der vorhandenen Kameras (Kopien heissen „… Kopie“, nummeriert bei Kollision).
let mut cam_names: std::collections::HashSet<String> = list(root, "cameras").iter().filter_map(|c| field(c, "name").and_then(Value::as_str).map(String::from)).collect();
for t in copy_ts(op, &req.mode, req.count.0) {
let xf = Xf::of(op, &pts, t);
let prefixes: Vec<&str> = items
@@ -995,6 +1027,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => "ST",
Kind::Room => "RM",
Kind::Tree => "tree",
Kind::Camera => "camera",
Kind::Context => "ctx",
})
.collect();
@@ -1021,9 +1054,15 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => (6, mv_stair(e, &xf, k_at(t))),
Kind::Room => (7, mv_room(e, &xf)),
Kind::Tree => (8, mv_tree(e, &xf)),
Kind::Camera => (10, mv_camera(e, &xf)),
Kind::Context => (9, mv_context(e, &xf)),
};
new[slot].push(with(&as_copy(&v), "id", Value::String(new_id.clone())));
let mut v = with(&as_copy(&v), "id", Value::String(new_id.clone()));
if matches!(kind, Kind::Camera) {
let name = copy_name(field(e, "name").and_then(Value::as_str).unwrap_or(""), &mut cam_names);
v = with(&v, "name", Value::String(name));
}
new[slot].push(v);
}
// Öffnungen kopierter Dächer/Decken ([103]) mit neuem Wirt mitkopieren.
for o in list(root, "openings") {
@@ -1043,7 +1082,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
}
}
}
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context"];
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras"];
for (key, items) in keys.iter().zip(new) {
ops.extend(add(key, items));
}
@@ -1359,6 +1398,15 @@ fn item_preview(p: &Project, kind: Kind, e: &Value, xf: &Xf, out: &mut Pending)
let ring: Vec<(f64, f64)> = crate::tree::circle([c.0, c.1], d / 2.0, 24).into_iter().map(|q| (q[0], q[1])).collect();
s.poly(&ring);
}
Kind::Camera => {
// [213] Gehäuse am neuen Standpunkt und die Blicklinie zum neuen Ziel.
let (px, py) = pt("position");
let (tx, ty) = pt("target");
let (a, b) = (xf.apply(px, py), xf.apply(tx, ty));
s.line(a, b);
let ring: Vec<(f64, f64)> = crate::tree::circle([a.0, a.1], 0.25, 12).into_iter().map(|q| (q[0], q[1])).collect();
s.poly(&ring);
}
Kind::Context => {
// [193] Baugrube: Umriss; Netze, Höhenlinien, Bild: Rahmen der abgebildeten Punkte.
let pts: Vec<(f64, f64)> = match field(e, "type").and_then(Value::as_str) {
@@ -1591,6 +1639,34 @@ mod tests {
assert_eq!(ops[0]["items"][0]["position"], json!({"x":4,"y":3}));
}
/// [213] Kameras: Standpunkt und Ziel werden abgebildet, Höhen und Bildwinkel bleiben; Kopien heissen „… Kopie“.
#[test]
fn kameras_transformieren() {
let cam = json!({"id":"k","type":"camera","name":"Süd","floorId":"eg","position":{"x":1,"y":0},"target":{"x":5,"y":0},"eyeHeight":1.6,"targetHeight":1.2,"fovDeg":50,"orthoHeight":8});
let r = root(json!({"cameras":[cam, {"id":"z","name":"Fest","position":{"x":0,"y":0},"target":{"x":1,"y":0},"locked":true}]}));
let run = |op: &str, mode: &str, pts: Value| {
let req: TransformReq = serde_json::from_value(json!({"sel":{"wallIds":[],"cameraIds":["k","z"]},"op":op,"pts":pts,"mode":mode,"count":1,"stamp":"s"})).unwrap();
transform_ops(&r, &Project::default(), &req).iter().map(|o| o.to_json()).collect::<Vec<_>>()
};
let ops = run("move", "move", json!([[0, 0], [3, 1]]));
assert_eq!(ops.len(), 1, "gesperrte Kamera bleibt");
let e = &ops[0]["entity"];
assert_eq!((&e["position"], &e["target"]), (&json!({"x":4,"y":1}), &json!({"x":8,"y":1})));
assert_eq!((&e["eyeHeight"], &e["targetHeight"], &e["fovDeg"], &e["orthoHeight"]), (&json!(1.6), &json!(1.2), &json!(50), &json!(8)));
// Drehen um den Ursprung um 90 Grad (Punkte: Drehpunkt, Start, Ziel).
let ops = run("rotate", "move", json!([[0, 0], [1, 0], [0, 1]]));
let e = &ops[0]["entity"];
let near = |v: &Value, x: f64, y: f64| (v["x"].as_f64().unwrap() - x).abs() < 1e-9 && (v["y"].as_f64().unwrap() - y).abs() < 1e-9;
assert!(near(&e["position"], 0.0, 1.0) && near(&e["target"], 0.0, 5.0), "{e}");
// Spiegeln an der y-Achse (Spiegellinie x = 0): x wechselt das Vorzeichen, Kopie mit neuem Namen.
let ops = run("mirror", "copy", json!([[0, 0], [0, 1]]));
assert_eq!(ops.len(), 1);
assert_eq!(ops[0]["collection"], "cameras");
let c = &ops[0]["items"][0];
assert!(near(&c["position"], -1.0, 0.0) && near(&c["target"], -5.0, 0.0), "{c}");
assert_eq!((&c["id"], &c["name"], &c["fovDeg"]), (&json!("camera-s-1"), &json!("Süd Kopie"), &json!(50)));
}
/// [193] Gelände-/Umgebungs-Elemente verschieben: Baugrube (Umriss), Höhenlinien, Gelände-Netz (z bleibt), Spiegeln kehrt den Netz-Umlauf um.
#[test]
fn kontext_verschieben() {
+1 -1
View File
@@ -43,7 +43,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
"align" => crate::cmd_transform::align_ops(root, &ids("ids"), &s("mode")),
"distribute" => crate::cmd_transform::distribute_ops(root, &ids("ids"), &s("axis")),
"defblock" => crate::cmd_transform::defblock_ops(root, &parse(&v, cmd)?),
"paste" => crate::cmd_paste::paste_ops(v.get("clip").unwrap_or(&Value::Null), &s("levelId"), &s("stamp")),
"paste" => crate::cmd_paste::paste_ops(root, v.get("clip").unwrap_or(&Value::Null), &s("levelId"), &s("stamp")),
"split" => crate::cmd_split::split_ops(root, &ids("ids"), &s("stamp")),
"cutSegment" => crate::cmd_split::cut_segment_ops(root, &s("id"), crate::cmd_split::point_arg(&v, "at")),
other => return Err(format!("Unbekannter Befehl: {other}")),
+2
View File
@@ -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[];
}
+29 -1
View File
@@ -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"]);
});
});
+13 -1
View File
@@ -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;
+1
View File
@@ -86,6 +86,7 @@ describe("Selection", () => {
roomIds: [],
openingIds: [],
treeIds: [],
cameraIds: [],
contextIds: [],
});
expect(toTransformSelection(s)).toEqual(c);
+2
View File
@@ -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
);
}
+4
View File
@@ -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
);
}