Merge branch 'worktree-agent-a89936bb3fbc2bbb1' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-17 22:09:07 +00:00
commit 369df24be0
17 files changed
+213 -26

No files matched your search

+26 -3
View File
@@ -229,14 +229,20 @@ pub struct Edit {
pub set: String,
pub option: String,
pub grey: bool,
/// [272] Häkchen „ausserhalb sperren“ (nur 3D-Pick, `lock`): Elemente ausserhalb sind im 3D nicht anwählbar.
pub lock: bool,
/// [272] 3D-Fenster: das Grau kommt als durchscheinende Geisterschicht (`model3d::ClassFilter`, render3d), nicht als
/// helle Teilefarbe ([`crate::renovation::View::resolve`] färbt dann nicht).
pub layer: bool,
}
/// Liest `{"set", "option", "grey"}` (Ids oder Namen); unbekannter Satz/Variante oder Unsinn ⇒ `None`.
/// Liest `{"set", "option", "grey", "lock", "layer"}` (Ids oder Namen); unbekannter Satz/Variante oder Unsinn ⇒ `None`.
pub fn parse_edit(p: &Project, v: Option<&Value>) -> Option<Edit> {
let v = v?.as_object()?;
let s = find_set(p, v.get("set")?.as_str()?)?;
let o = find_option(s, v.get("option")?.as_str()?)?;
Some(Edit { set: s.id.clone(), option: o.id.clone(), grey: v.get("grey").and_then(Value::as_bool).unwrap_or(false) })
let flag = |k: &str| v.get(k).and_then(Value::as_bool).unwrap_or(false);
Some(Edit { set: s.id.clone(), option: o.id.clone(), grey: flag("grey"), lock: flag("lock"), layer: flag("layer") })
}
impl Edit {
@@ -269,12 +275,29 @@ impl Edit {
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
// 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 {
if d.design_option.is_some() && !self.holds(d.design_option.as_ref()) {
out.insert(d.id.clone());
}
}
out
}
/// Ids der Elemente, die bei „ausserhalb sperren“ im 3D nicht anwählbar sind: alles ausserhalb ([`Self::outside`]),
/// alle 2D-Elemente ohne die Bearbeitungsvariante, Bäume und Kontext (wie `designOptionLocked` der Auswahl).
pub fn locked(&self, p: &Project) -> HashSet<String> {
let mut out = self.outside(p);
out.extend(p.drawings2d.iter().filter(|d| !self.holds(d.design_option.as_ref())).map(|d| d.id.clone()));
out.extend(p.trees.iter().flatten().map(|t| t.id.clone()));
out.extend(p.context.iter().flatten().map(|c| c.id().to_string()));
out
}
/// Schlüssel für Caches.
pub fn key(&self) -> String {
format!("{}={}{}", self.set, self.option, if self.grey { ":grey" } else { "" })
format!("{}={}{}{}", self.set, self.option, if self.grey { ":grey" } else { "" }, if self.layer { ":layer" } else { "" })
}
}
+78 -1
View File
@@ -708,7 +708,7 @@ fn bearbeiten_zeigt_die_variante_und_graut_den_rest_nur_auf_anfrage() {
}
// Cache-Schlüssel unterscheidet die Bearbeitung.
let k = |e: Option<Edit>| crate::renovation::View::editing(crate::renovation::View::new(&p, None, None), &p, e).map(|v| v.key());
let e = |grey| Some(Edit { set: "dach".into(), option: "b".into(), grey });
let e = |grey| Some(Edit { set: "dach".into(), option: "b".into(), grey, lock: false, layer: false });
assert_ne!(k(None), k(e(true)));
assert_ne!(k(e(false)), k(e(true)));
}
@@ -760,3 +760,80 @@ fn bearbeiten_auch_ohne_elemente_in_varianten() {
assert!(!has_wall(&r, "W2"));
assert!(wall_fills(&r, "W9").iter().all(|f| *f == ghost.fill));
}
/// Fixture mit zweitem Satz „Fassade“ (X Haupt): Raum R2 ohne Variante (Hauptmodell), Linie L-g in Fassade X.
fn fixture_two_sets() -> Value {
let mut v = fixture();
v["designOptionSets"].as_array_mut().unwrap().push(json!({"id": "fas", "name": "Fassade", "options": [{"id": "x", "name": "X"}, {"id": "y", "name": "Y"}], "primary": "x"}));
let mut r2 = v["rooms"][0].clone();
r2["id"] = json!("R2");
r2.as_object_mut().unwrap().remove("designOption");
v["rooms"].as_array_mut().unwrap().push(r2);
v["drawings2d"].as_array_mut().unwrap().push(json!({"id": "L-g", "type": "line", "levelId": "eg", "categoryCode": "00", "geom": {"shape": "line", "a": {"x": 0, "y": 0}, "b": {"x": 2, "y": 0}}, "designOption": {"set": "fas", "option": "x"}}));
v["drawings2d"].as_array_mut().unwrap().push(json!({"id": "L-0", "type": "line", "levelId": "eg", "categoryCode": "00", "geom": {"shape": "line", "a": {"x": 0, "y": 1}, "b": {"x": 2, "y": 1}}}));
v
}
#[test]
fn bearbeiten_graut_raeume_und_2d_elemente_ausserhalb() {
let p = project(&fixture_two_sets());
let ghost = crate::renovation::ghost_style();
let line = ghost.line.clone().unwrap();
let room_fill = |prims: &[Primitive], id: &str| -> Vec<String> {
prims.iter().filter_map(|q| match q { Primitive::Polygon { room_id: Some(r), fill, stroke, .. } if r == id => Some(format!("{fill}|{stroke}")), _ => None }).collect()
};
let text_color = |prims: &[Primitive], id: &str| prims.iter().find_map(|q| match q { Primitive::Text { room_id: Some(r), color, .. } if r == id => Some(color.to_string()), _ => None });
let line_color = |prims: &[Primitive], id: &str| prims.iter().find_map(|q| match q { Primitive::Line { drawing_id: Some(d), color, .. } if d == id => Some(color.as_ref().map(|c| c.to_string())), _ => None });
// Stift auf B (Dachform): R2 (Hauptmodell) und L-g (Fassade X, anderer Satz) grau, L-b (in B) und L-0 (ohne Variante) nicht.
let g = plan_with(&p, edit("b", true));
assert!(!room_fill(&g, "R2").is_empty() && room_fill(&g, "R2").iter().all(|f| f.ends_with(&format!("|{line}"))), "{:?}", room_fill(&g, "R2"));
assert_eq!(text_color(&g, "R2"), Some(line.clone()));
assert!(g.iter().any(|q| matches!(q, Primitive::Text { room_id: Some(r), greyed: Some(true), .. } if r == "R2")), "Stempel nicht gedämpft");
assert!(!plan_with(&p, json!({})).iter().any(|q| matches!(q, Primitive::Text { room_id: Some(r), greyed: Some(true), .. } if r == "R2")));
assert_eq!(line_color(&g, "L-g"), Some(Some(line.clone())));
assert_ne!(line_color(&g, "L-b"), Some(Some(line.clone())));
assert_ne!(line_color(&g, "L-0"), Some(Some(line.clone())));
// Ohne Grau-Häkchen und ohne Stift: nichts grau.
for t in [edit("b", false), json!({})] {
let n = plan_with(&p, t);
assert!(room_fill(&n, "R2").iter().all(|f| !f.ends_with(&format!("|{line}"))));
assert_ne!(line_color(&n, "L-g"), Some(Some(line.clone())));
}
}
#[test]
fn bearbeiten_3d_geisterschicht_und_sperre() {
let p = project(&fixture_two_sets());
let model = |t: Value| -> Value { serde_json::from_str(&crate::queries::run(&p, "model3dParts", &[1.0, 1.0, 0.0], &t.to_string()).unwrap()).unwrap() };
let walls = |v: &Value| -> Vec<String> { v["walls"].as_array().unwrap().iter().map(|w| w["wallId"].as_str().unwrap().to_string()).collect() };
let e = |layer: bool, lock: bool| json!({"designOptionEdit": {"set": "dach", "option": "b", "grey": true, "layer": layer, "lock": lock}});
// Ohne Schicht (Standardform): W1 im Hauptmodell, grau gefärbt (unverändert).
assert!(walls(&model(e(false, false))).contains(&"W1".to_string()));
// Mit Schicht: W1 (Hauptmodell, ausserhalb) fehlt im Hauptmodell, W9 (in B) bleibt.
let main = walls(&model(e(true, false)));
assert!(!main.contains(&"W1".to_string()) && main.contains(&"W9".to_string()), "{main:?}");
// Geisterschicht: nur das Graue, in seiner eigenen Farbe (nicht hellgrau eingefärbt).
let mut t = e(true, false);
t["ghost"] = json!(true);
let ghost = model(t);
let gw = walls(&ghost);
assert!(gw.contains(&"W1".to_string()) && !gw.contains(&"W9".to_string()), "{gw:?}");
let col = |w: &Value| w["color"].as_array().unwrap().iter().map(|x| x.as_f64().unwrap()).collect::<Vec<_>>();
let w1 = ghost["walls"].as_array().unwrap().iter().find(|w| w["wallId"] == "W1").unwrap();
assert_ne!(col(w1), crate::style::hex_to_rgb(&crate::renovation::ghost_style().fill, [0.0; 3]).to_vec());
// Ohne Grau-Häkchen keine Geisterschicht.
let mut off = e(true, false);
off["designOptionEdit"]["grey"] = json!(false);
off["ghost"] = json!(true);
assert!(walls(&model(off)).is_empty());
// Pick: ohne Sperre bleiben Elemente ausserhalb anwählbar (auch graue), mit Sperre nur die der Variante.
let pick = |t: Value| -> Value { serde_json::from_str(&crate::queries::run(&p, "pickGeometry", &[0.0], &t.to_string()).unwrap()).unwrap() };
let ids = |v: &Value| -> Vec<String> { v["walls"].as_array().unwrap().iter().map(|x| x["wallId"].as_str().unwrap().to_string()).collect() };
let free = ids(&pick(e(true, false)));
assert!(free.contains(&"W1".to_string()) && free.contains(&"W9".to_string()), "{free:?}");
let locked = ids(&pick(e(true, true)));
assert!(!locked.contains(&"W1".to_string()) && locked.contains(&"W9".to_string()), "{locked:?}");
// Variante per Stift sichtbar, auch wenn die Kombination die andere zeigt: W9 ist pickbar ohne `designOptions`.
assert!(ids(&pick(json!({"designOptionEdit": {"set": "dach", "option": "b", "grey": false}}))).contains(&"W9".to_string()));
assert!(!ids(&pick(json!({}))).contains(&"W9".to_string()));
}
+21 -5
View File
@@ -70,6 +70,10 @@ pub struct ElementSelection {
pub grey_floors: HashSet<String>,
/// [180] Gesperrte Klassen des Darstellungsmodus: sichtbar (bzw. grau), aber nicht anwählbar.
pub lock: HashSet<String>,
/// [272] Einzelne Elemente (Ids) im Modus „grau“: Elemente ausserhalb der Bearbeitungsvariante (Stift, `designOptionEdit`).
pub grey_ids: HashSet<String>,
/// [272] Einzelne gesperrte Elemente (Ids): ausserhalb der Bearbeitungsvariante bei „sperren“, im Pick nicht anwählbar.
pub lock_ids: HashSet<String>,
/// [180] Geisterschicht: NUR die grauen (nicht ausgeblendeten) Elemente liefern.
pub ghost: bool,
}
@@ -77,7 +81,7 @@ pub struct ElementSelection {
impl ElementSelection {
/// Keine Einschränkung.
pub fn is_empty(&self) -> bool {
self.only.is_none() && self.hide.is_empty() && self.hide_floors.is_empty() && self.grey.is_empty() && self.grey_floors.is_empty() && self.lock.is_empty() && !self.ghost
self.only.is_none() && self.hide.is_empty() && self.hide_floors.is_empty() && self.grey.is_empty() && self.grey_floors.is_empty() && self.lock.is_empty() && self.grey_ids.is_empty() && self.lock_ids.is_empty() && !self.ghost
}
}
@@ -132,10 +136,10 @@ impl ClassFilter {
let mut add = |code: &str, id: &str, floor: &str| {
if codes.contains(code) || sel.hide.contains(id) || sel.hide_floors.contains(floor) || only.as_ref().is_some_and(|o| !o.contains(id)) {
hidden.insert(id.to_owned());
} else if sel.grey.contains(code) || sel.grey_floors.contains(floor) {
} else if sel.grey.contains(code) || sel.grey_floors.contains(floor) || sel.grey_ids.contains(id) {
grey.insert(id.to_owned());
}
if sel.lock.contains(code) {
if sel.lock.contains(code) || sel.lock_ids.contains(id) {
locked.insert(id.to_owned());
}
};
@@ -171,10 +175,10 @@ impl ClassFilter {
for o in p.openings.as_deref().unwrap_or(&[]) {
if codes.contains(&o.category_code) || sel.hide.contains(&o.id) || opening_hosts(o).any(|h| hidden.contains(h)) {
hidden.insert(o.id.clone());
} else if sel.grey.contains(&o.category_code) || opening_hosts(o).any(|h| grey.contains(h)) {
} else if sel.grey.contains(&o.category_code) || sel.grey_ids.contains(&o.id) || opening_hosts(o).any(|h| grey.contains(h)) {
grey.insert(o.id.clone());
}
if sel.lock.contains(&o.category_code) {
if sel.lock.contains(&o.category_code) || sel.lock_ids.contains(&o.id) {
locked.insert(o.id.clone());
}
}
@@ -219,7 +223,19 @@ impl ClassFilter {
grey_floors: list("greyFloors").unwrap_or_default().into_iter().collect(),
lock: list("lock").unwrap_or_default().into_iter().collect(),
ghost: v.as_ref().and_then(|v| v.get("ghost")).and_then(|b| b.as_bool()).unwrap_or(false),
..Default::default()
};
// [272] Bearbeitungsvariante (Stift): im 3D-Fenster (`layer`) steht, was ausserhalb liegt, in der Geisterschicht
// (halbtransparent); mit `lock` sind diese Elemente (dazu Bäume, Kontext) nicht anwählbar.
let mut sel = sel;
if let Some(e) = v.as_ref().and_then(|v| crate::design_options::parse_edit(p, v.get("designOptionEdit"))) {
if e.grey && e.layer {
sel.grey_ids = e.outside(p);
}
if e.lock {
sel.lock_ids = e.locked(p);
}
}
ClassFilter::with_elements(p, &list("hide").unwrap_or_default(), &sel)
}
+7 -3
View File
@@ -1569,7 +1569,9 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
bounds.acc(q.x, q.y);
}
let ov = c.overrides(Some("room"), &room.category_code, Some(&room.name));
let color = ov.color.as_deref().unwrap_or(&room.color);
// [272] Raum ausserhalb der Bearbeitungsvariante (Grau): Fläche, Rand und Stempel gedämpft.
let ghost = c.renovation().and_then(|r| r.styled.get(&room.id)).filter(|s| s.ghost);
let color = ghost.and_then(|g| g.line.as_deref()).or(ov.color.as_deref()).unwrap_or(&room.color);
let greyed = Some(c.greyed(&room.category_code));
if room.boundary.len() < 3 {
continue;
@@ -1589,7 +1591,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
let overview = c.a.auto_coarse && c.a.scale >= OVERVIEW_FROM;
// [140] Raumstempel in Tinte (Druck ohne Schwarz-Weiss); Farbe nur aus einer Darstellungsregel
// oder aus den Auszeichnungen des Stempel-Texts.
let text_color = ov.color.as_deref().unwrap_or(MONO_INK);
let text_color = ghost.and_then(|g| g.line.as_deref()).or(ov.color.as_deref()).unwrap_or(MONO_INK);
// [173] Zeilen nach der Modelldarstellung: die Einstellung am Stempel geht vor (`StampOpts::line`); die
// Raumnummer zeigt die Stufe (Basis ja), der Stempel liefert nur den Text.
let st = &c.mv().stamp;
@@ -1670,7 +1672,9 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, top: &mut Vec<Primitive>, bounds: &m
}
}
}
out.push(Primitive::Text { at, doc, extra_lines, base_pt, color: text_color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
// [272] Grau: der Stempel-Text trägt seine Farbe im Text-Dokument, darum gedämpft über `greyed` (wie gedimmte Geschosse).
let text_greyed = if ghost.is_some() { Some(true) } else { greyed };
out.push(Primitive::Text { at, doc, extra_lines, base_pt, color: text_color.into(), room_id: Some(room.id.clone()), greyed: text_greyed, opacity: None });
}
}
+3 -2
View File
@@ -183,8 +183,9 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
("explodeOffsets", _) => json(&crate::explode3d::floor_offsets(p, args.first().copied().unwrap_or(0.0))),
// [180] Ohne die Elemente ausgeblendeter Klassen (`text` = `{"hide": [codes]}`, s. `model3d::ClassFilter`).
("pickGeometry", _) => {
// [272] Elemente anderer Varianten nicht picken.
let q = options_state(p, text);
// [272] Elemente anderer Varianten nicht picken; mit Stift gilt die Bearbeitungsvariante als sichtbar, bei
// „sperren“ sind die Elemente ausserhalb nicht anwählbar (`ClassFilter`, `designOptionEdit`).
let q = crate::renovation::filtered(p, crate::renovation::screen_view_from_text(p, if text.trim_start().starts_with('{') { text } else { "" }));
let p = q.as_ref();
let mut g = crate::explode3d::pick_geometry(p, args.first().copied().unwrap_or(0.0))?;
model3d::ClassFilter::from_text(p, text).retain_pick(&mut g);
+2 -1
View File
@@ -386,7 +386,8 @@ impl View {
self.resolve_filter(p, &mut out);
}
// [272] Grau ausserhalb der Bearbeitungsvariante: geht der Umbau-Farbe vor; Ausgeblendetes bleibt weg.
if let Some(e) = self.edit.as_ref().filter(|e| e.grey) {
// Im 3D-Fenster (`layer`) zeigt die Geisterschicht das Grau, nicht die Teilefarbe.
if let Some(e) = self.edit.as_ref().filter(|e| e.grey && !e.layer) {
let g = ghost_style();
for id in e.outside(p) {
if !out.hidden.contains(&id) {