[284] Review vor der Beta: Träger im Varianten-/Umbaufilter, Gefällelinie wandert mit, Export nur Auswahl mit Geländern, Gruppen, Fang-Cache, Cmd+A, Geschoss löschen

Träger fehlten in design_options (hidden/outside) und section::without_elements (3D, Schnitt, Kennzahlen, IFC im Filter); slope.from/to in cmd_transform, geo_translate, geo_rebase; selection_filter mit railings/trees; group_ops mit Trägern/Geländern/Bäumen; snap_model MODEL_FIELDS mit beams; selectAll mit Geländern; deleteLevel entfernt Dächer, Stützen, Träger, Geländer; Robustheits-Regression für neue Bauteile mit Randwerten (kein Panic).
This commit is contained in:
Claude committed 2026-11-18 09:36:51 +00:00
1 parent 11730f7602
commit eeb320f96c
17 files changed
+149 -10

No files matched your search

+19
View File
@@ -154,3 +154,22 @@ fn umbaufilter_wie_stuetze() {
assert_eq!(with("abbruch"), 0);
assert!(with("neubau") > 0);
}
#[test]
fn varianten_blenden_traeger_aus() {
// [284] Träger in Variante B: in der Hauptkombination (A) ausgeblendet, in B sichtbar.
let mut p = project(json!({"designOption": {"set": "s", "option": "b"}}));
p.design_option_sets = Some(vec![serde_json::from_value(json!({"id": "s", "name": "Tragwerk", "options": [{"id": "a", "name": "A"}, {"id": "b", "name": "B"}], "primary": "a"})).unwrap()]);
let with = |f: Value| {
let t = json!({"floor": "eg", "show": ["30", "50"], "grey": [], "scale": 50, "global": true, "mono": true, "designOptions": f}).to_string();
plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap().columns.len()
};
assert_eq!(with(json!({})), 0, "Hauptkombination ohne Träger der Variante B");
assert!(with(json!("Tragwerk=B")) > 0);
assert!(crate::design_options::Combination::primary(&p).hidden(&p).contains("T1"));
// 3D, Schnitt, Kennzahlen und Exporte rechnen auf dem gefilterten Projekt: dort fehlt der Träger.
assert!(crate::renovation::project_for_text(&p, "{}").beams.as_deref().unwrap_or(&[]).is_empty());
// Umbau: abgebrochener Träger fehlt im Neubau-Zustand.
let q = project(json!({"renovation": {"status": "demolish"}}));
assert!(crate::renovation::project_in_state(&q, Some("neubau"), None).beams.as_deref().unwrap_or(&[]).is_empty());
}
+6 -2
View File
@@ -1393,7 +1393,7 @@ pub fn query(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Result
// ── Gruppen-Zuordnung ────────────────────────────────────────────────────────
/// Mitglieds-Listen einer Gruppe und ihre Element-Listen (Reihenfolge wie `KEYS` in der Hülle).
const MEMBER_KEYS: [(&str, &str); 8] = [
const MEMBER_KEYS: [(&str, &str); 11] = [
("wallIds", "walls"),
("drawingIds", "drawings2d"),
("ceilingIds", "ceilings"),
@@ -1402,6 +1402,10 @@ const MEMBER_KEYS: [(&str, &str); 8] = [
("columnIds", "columns"),
("roofIds", "roofs"),
("openingIds", "openings"),
// [284] Träger liegen im Auswahlkanal der Stützen; Geländer und Bäume eigene Listen.
("columnIds", "beams"),
("railingIds", "railings"),
("treeIds", "trees"),
];
/// Zeichnet man in einer betretenen Gruppe (`group` = innerste aktive Gruppe), werden die neu
@@ -1443,7 +1447,7 @@ pub fn group_ops(root: &Map<String, Value>, ops: &[Op], group: &str) -> Vec<Op>
}
};
arr(m.get(key)).iter().for_each(&mut push);
if let Some((_, ids)) = added.iter().find(|(k, _)| *k == key) {
for (_, ids) in added.iter().filter(|(k, _)| *k == key) {
ids.iter().for_each(|id| push(&Value::String(id.clone())));
}
m.insert(key.into(), Value::Array(list));
+22
View File
@@ -415,6 +415,10 @@ fn mv_ceiling(c: &Value, xf: &Xf) -> Value {
f.push(("openings", Value::Array(arr(field(c, "openings")).iter().map(|h| xf.pts(Some(h))).collect())));
}
f.extend(flip_bulges(c, xf, &["outlineBulge"], &["openingsBulge"]));
// [284] Gefällelinie der geneigten Decke/Rampe wandert mit (sonst kippt die Ebene beim Verschieben/Drehen).
if let Some(s) = field(c, "slope").filter(|s| s.is_object()) {
f.push(("slope", with_all(s, vec![("from", xf.pt_of(field(s, "from"))), ("to", xf.pt_of(field(s, "to")))])));
}
with_all(c, f)
}
@@ -1697,6 +1701,24 @@ mod tests {
assert_eq!(ops[0]["items"][0]["position"], json!({"x":4,"y":3}));
}
/// [284] Geneigte Decke: die Gefällelinie wandert beim Verschieben und Kopieren mit (sonst kippt die Ebene).
#[test]
fn gefaellelinie_wandert_mit() {
let c = json!({"id":"C","outline":[{"x":0,"y":0},{"x":4,"y":0},{"x":4,"y":2},{"x":0,"y":2}],"slope":{"from":{"x":0,"y":1},"to":{"x":4,"y":1},"rise":0.5,"ramp":true}});
let r = root(json!({"ceilings":[c]}));
let run = |mode: &str| {
let req: TransformReq = serde_json::from_value(json!({"sel":{"wallIds":[],"ceilingIds":["C"]},"op":"move","pts":[[0, 0], [3, 1]],"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");
assert_eq!(ops[0]["entity"]["slope"], json!({"from":{"x":3,"y":2},"to":{"x":7,"y":2},"rise":0.5,"ramp":true}));
let ops = run("copy");
assert_eq!(ops[0]["items"][0]["slope"]["from"], json!({"x":3,"y":2}));
// Verschieben des Projekts (Bezugspunkt, Welt-Koordinaten im Export) ebenso.
let p = crate::geo_translate::project_patch(&r, 1.0, 2.0);
assert_eq!(p["ceilings"][0]["slope"]["to"], json!({"x":5.0,"y":3.0}));
}
/// [213] Kameras: Standpunkt und Ziel werden abgebildet, Höhen und Bildwinkel bleiben; Kopien heissen „… Kopie“.
#[test]
fn kameras_transformieren() {
+2 -2
View File
@@ -182,7 +182,7 @@ impl Combination {
}
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
each!(ceilings, roofs, stairs, columns, beams, extruded_solids, rooms, railings);
for d in &p.drawings2d {
if !self.shows(d.design_option.as_ref()) {
out.insert(d.id.clone());
@@ -276,7 +276,7 @@ impl Edit {
}
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
each!(ceilings, roofs, stairs, columns, beams, extruded_solids, rooms, railings);
// 2D-Elemente (Möbel, Linien, Masse, Texte): nur die, die einer anderen Variante angehören — ohne Zugehörigkeit
// stehen sie im Hauptmodell, wo sie nicht grau werden (sonst wäre jede Beschriftung grau).
for d in &p.drawings2d {
+8
View File
@@ -97,6 +97,10 @@ pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
for h in c.openings.iter_mut().flatten() {
shift_all(h, dx, dy);
}
if let Some(s) = &mut c.slope {
s.from = shift(s.from, dx, dy);
s.to = shift(s.to, dx, dy);
}
}
for r in out.roofs.iter_mut().flatten() {
shift_all(&mut r.outline, dx, dy);
@@ -115,6 +119,10 @@ pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
for c in out.columns.iter_mut().flatten() {
c.position = shift(c.position, dx, dy);
}
for b in out.beams.iter_mut().flatten() {
b.start = shift(b.start, dx, dy);
b.end = shift(b.end, dx, dy);
}
for t in out.trees.iter_mut().flatten() {
t.position = shift(t.position, dx, dy);
}
+6
View File
@@ -142,6 +142,12 @@ fn shift_element(key: &str, e: &Value, dx: f64, dy: f64) -> (Value, bool) {
let n: Vec<Value> = h.iter().map(|h| shift_all(Some(h), dx, dy)).collect();
m.insert("openings".into(), Value::Array(n));
}
// [284] Gefällelinie der geneigten Decke/Rampe.
if let Some(s) = e.get("slope").filter(|s| s.is_object()) {
let mut s = obj(s);
shift_pts_fields(&mut s, &["from", "to"], dx, dy, &[]);
m.insert("slope".into(), Value::Object(s));
}
}
"roofs" => {
shift_pts_fields(&mut m, &[], dx, dy, &["outline"]);
+4
View File
@@ -453,6 +453,10 @@ pub fn without_elements(p: &Project, ids: &HashSet<String>) -> Project {
if let Some(v) = &mut q.columns {
v.retain(|x| !ids.contains(&x.id));
}
// [284] Träger (sonst blieben sie in 3D, Schnitt und Exporten trotz Umbau-/Variantenfilter stehen).
if let Some(v) = &mut q.beams {
v.retain(|x| !ids.contains(&x.id));
}
// [279] Geländer.
if let Some(v) = &mut q.railings {
v.retain(|x| !ids.contains(&x.id));
+6 -2
View File
@@ -8,7 +8,7 @@ use serde_json::{Map, Value};
use std::collections::HashSet;
/// Projekt-Liste → (Mitglieds-ids der Art).
const KINDS: [(&str, &str); 9] = [
const KINDS: [(&str, &str); 11] = [
("walls", "wallIds"),
("drawings2d", "drawingIds"),
("ceilings", "ceilingIds"),
@@ -19,6 +19,9 @@ const KINDS: [(&str, &str); 9] = [
("beams", "columnIds"),
("roofs", "roofIds"),
("openings", "openingIds"),
// [284] Geländer und Bäume: sonst gingen beim Export „nur Auswahl“ alle mit.
("railings", "railingIds"),
("trees", "treeIds"),
];
/// Gekürzte Listen (alle acht Schlüssel, fehlende Listen = leer); Elemente in Listen-Reihenfolge, auch Doppelte.
@@ -55,7 +58,8 @@ mod tests {
assert_eq!(p["rooms"], json!([]));
assert_eq!(p["drawings2d"], json!([]));
assert_eq!(p["roofs"], json!([]));
assert_eq!(p.len(), 9);
assert_eq!(p.len(), 11);
assert_eq!(p["railings"], json!([]));
assert!(p.get("layers").is_none());
}
}
+1
View File
@@ -299,6 +299,7 @@ fn candidate_codes(p: &Project) -> HashSet<String> {
codes.extend(p.extruded_solids.iter().flatten().map(|e| e.category_code.clone()));
codes.extend(p.columns.iter().flatten().map(|e| e.category_code.clone()));
codes.extend(p.beams.iter().flatten().map(|e| e.category_code.clone()));
codes.extend(p.railings.iter().flatten().map(|e| e.category_code.clone()));
codes
}
+1 -1
View File
@@ -487,7 +487,7 @@ struct PartKey {
}
/// Felder, aus denen der Modell-Teil sammelt (ändert sich eines, wird neu gesammelt).
const MODEL_FIELDS: [&str; 8] = ["walls", "wallTypes", "rooms", "ceilings", "roofs", "stairs", "columns", "extrudedSolids"];
const MODEL_FIELDS: [&str; 9] = ["walls", "wallTypes", "rooms", "ceilings", "roofs", "stairs", "columns", "beams", "extrudedSolids"];
const DRAWING_FIELDS: [&str; 1] = ["drawings2d"];
/// So viele Teile je Art und abgelegte Geschosse bleiben (älteste fallen weg).
const KEEP: usize = 6;