[271] DXF-Ebenen für Möbel und Bäume je Umbau-Status (<Ebene>_Abbruch/_Neu wie bei Wänden); Kern baut wieder (Style.ghost, resolve_filter)
This commit is contained in:
4 files changed
+76
-4
No files matched your search
@@ -785,6 +785,8 @@ struct Ids {
|
||||
solid: Option<String>,
|
||||
room: Option<String>,
|
||||
opening: Option<String>,
|
||||
/// [271] Baum (Kronenumriss, Stamm): Id aus der Pick-Fläche `@tree:<id>`, den übrigen Teilen nachgetragen.
|
||||
tree: Option<String>,
|
||||
}
|
||||
|
||||
struct Entry {
|
||||
@@ -818,6 +820,7 @@ fn read_entry(part: &mut Part, i: usize, hatches: &[(i32, Hatch, i32)], text: Op
|
||||
6 => ids.room = Some(s),
|
||||
7 => ids.solid = Some(s),
|
||||
9 => ids.column = Some(s),
|
||||
8 => ids.tree = s.strip_prefix(crate::tree::TREE_PICK_PREFIX).map(str::to_string),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -1492,6 +1495,13 @@ fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, S
|
||||
use crate::model::RenovationStatus as S;
|
||||
let p = cx.project;
|
||||
let mut items: Vec<(&str, &str, S)> = Vec::new();
|
||||
// Möbel/Symbole und 2D-Elemente mit ausdrücklichem Status; Bäume: ihr `status` ist der Umbau-Status ([149]).
|
||||
for d in &p.drawings2d {
|
||||
items.push((&d.id, &d.category_code, crate::renovation::status_of(d.renovation.as_ref())));
|
||||
}
|
||||
for t in p.trees.iter().flatten() {
|
||||
items.push((&t.id, &t.category_code, crate::renovation::tree_renovation(t).status));
|
||||
}
|
||||
for w in &p.walls {
|
||||
items.push((&w.id, &w.category_code, crate::renovation::status_of(w.renovation.as_ref())));
|
||||
}
|
||||
@@ -1526,11 +1536,16 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
let layer_of_code = |m: &HashMap<&str, &str>, id: &str| -> Option<String> { layer_by_code.get(m.get(id).copied().unwrap_or("")).cloned() };
|
||||
let drawing_layer = |id: Option<&String>, fallback: &str| -> String {
|
||||
match id {
|
||||
Some(id) if ren_layer.contains_key(id) => ren_layer[id].clone(),
|
||||
Some(id) => layer_of_code(&code_by_drawing, id).unwrap_or_else(|| LAYER_DEFAULT.to_string()),
|
||||
None => fallback.to_string(),
|
||||
}
|
||||
};
|
||||
let layer_for = |e: &Entry| -> String {
|
||||
// [271] Teile eines Baums mit Status Abbruch/Neu: Status-Ebene (Bestand bleibt auf der bisherigen Ebene).
|
||||
if let Some(l) = e.ids.tree.as_ref().and_then(|id| ren_layer.get(id)) {
|
||||
return l.clone();
|
||||
}
|
||||
match e.tag {
|
||||
T_POLYGON => {
|
||||
if let Some(l) = e.ids.wall.as_ref().or(e.ids.column.as_ref()).and_then(|id| ren_layer.get(id)) {
|
||||
@@ -1719,6 +1734,27 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
}
|
||||
}
|
||||
|
||||
/// [271] Baum-Symbol (`plan/trees.rs::tree_symbol`): Pick-Fläche `@tree:<id>`, dann Kronenlinien (`tree-crown`,
|
||||
/// `tree-remove`), zuletzt der Stamm (Fläche ohne Ids). Linien und Stamm tragen keine Id — sie bekommen die des Baums.
|
||||
fn tag_tree_parts(entries: &mut [Entry]) {
|
||||
let mut cur: Option<String> = None;
|
||||
for e in entries.iter_mut() {
|
||||
if e.ids.tree.is_some() {
|
||||
cur = e.ids.tree.clone();
|
||||
continue;
|
||||
}
|
||||
let crown = matches!(&e.prim, Prim::Line { cls, .. } if cls == "tree-crown" || cls == "tree-remove");
|
||||
let bare = e.ids.wall.is_none() && e.ids.drawing.is_none() && e.ids.column.is_none() && e.ids.solid.is_none() && e.ids.room.is_none() && e.ids.opening.is_none();
|
||||
if cur.is_some() && crown {
|
||||
e.ids.tree = cur.clone();
|
||||
} else if cur.is_some() && bare && e.tag == T_POLYGON {
|
||||
e.ids.tree = cur.take();
|
||||
} else {
|
||||
cur = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Primitive der Abschnitte in Plan-Reihenfolge lesen (Texte gesetzt beim Massstab `scale`).
|
||||
fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>> {
|
||||
let mut entries: Vec<Entry> = Vec::new();
|
||||
@@ -1729,6 +1765,7 @@ fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>
|
||||
entries.push(read_entry(part, i, &hatches, text.as_ref())?);
|
||||
}
|
||||
}
|
||||
tag_tree_parts(&mut entries);
|
||||
Some(entries)
|
||||
}
|
||||
|
||||
|
||||
@@ -362,10 +362,10 @@ impl View {
|
||||
}
|
||||
// [271] 2D-Zeichnungen (Möbel, Symbole und Elemente mit ausdrücklichem Status) und Bäume ([149]: Status = Umbau-Status).
|
||||
for x in p.drawings2d.iter().filter(|d| drawing_takes_part(d)) {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
for t in p.trees.iter().flatten() {
|
||||
put(&t.id, self.treat(Some(&tree_renovation(t))), &mut out);
|
||||
put(&t.id, self.treat(Some(&tree_renovation(t))), out);
|
||||
}
|
||||
// Räume: nur sichtbar oder nicht (ein Raum ist kein Bauteil, er bekommt keine Umbau-Farbe).
|
||||
for x in p.rooms.iter().flatten() {
|
||||
@@ -577,7 +577,7 @@ pub fn restyle_linework(prims: &mut Vec<Primitive>, from: usize, st: &Style, fil
|
||||
if from >= prims.len() {
|
||||
return;
|
||||
}
|
||||
let st = Style { fill: st.fill.clone(), line: Some(st.line.clone().unwrap_or_else(|| st.fill.clone())), dashed: st.dashed };
|
||||
let st = Style { fill: st.fill.clone(), line: Some(st.line.clone().unwrap_or_else(|| st.fill.clone())), dashed: st.dashed, ghost: st.ghost };
|
||||
let mut extra = Vec::new();
|
||||
for q in prims[from..].iter_mut() {
|
||||
restyle_with(q, &st, &mut extra, fill);
|
||||
|
||||
@@ -418,3 +418,38 @@ fn bogenwand_traegt_ersatzstueck_in_allen_drei_zeichnungen() {
|
||||
assert_eq!(patch_polys(§ion_q(&p, json!({"renovation": "umbauplan"})), "O1", &yellow).len(), 1);
|
||||
assert_eq!(patch_polys(&elevation_of(&p, "ansicht-sued", json!({"renovation": "umbauplan"})), "O1", &yellow).len(), 1);
|
||||
}
|
||||
|
||||
/// DXF-Ebenenliste (Strings des Exports) eines Projekts, Grundriss EG mit allen Ebenen.
|
||||
fn dxf_layer_names(p: &Project) -> Vec<String> {
|
||||
let a = PlanArgs::parse(1.0, &plan_args(&json!({}))).unwrap();
|
||||
let buf = crate::plan::domains::plan_domains_buf(p, &a).unwrap();
|
||||
let view = crate::plan::buf::View::parse(&buf).unwrap();
|
||||
let len = view.len();
|
||||
let mut parts = [crate::plan::parts::Part::new(view, 0, len).unwrap()];
|
||||
let o = crate::plan::dxf::DxfOptions { scale: 100.0, include_hatches: true, dim_cm: false, paper_layout: false, bounds: [0.0, 0.0, 20.0, 6.0], default_font: "Arial".into(), floor: "eg".into(), table_labels: String::new() };
|
||||
crate::plan::dxf::collect(&mut parts, p, &o).unwrap().strings
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dxf_ebenen_fuer_moebel_und_baeume() {
|
||||
let mut v = fixture();
|
||||
let s = dxf_layer_names(&project(&v));
|
||||
// Möbel (M1 neu, M2 Abbruch) und Bäume (T2 zu fällen, T3 neu) auf Status-Ebenen ihrer Kategorie.
|
||||
for n in ["22_Möbel_Abbruch", "22_Möbel_Neu", "13_Bäume_Abbruch", "13_Bäume_Neu"] {
|
||||
assert!(s.iter().any(|x| x == n), "{n} fehlt: {:?}", s.iter().filter(|x| x.contains('_')).collect::<Vec<_>>());
|
||||
}
|
||||
// Bestand (M3, T1) bleibt auf der Kategorie-Ebene.
|
||||
assert!(s.iter().any(|x| x == "22_Möbel") && s.iter().any(|x| x == "13_Bäume"));
|
||||
// Ohne Umbau-Angaben keine Status-Ebenen für Möbel/Bäume.
|
||||
for coll in ["drawings2d", "trees"] {
|
||||
for d in v[coll].as_array_mut().unwrap() {
|
||||
d.as_object_mut().unwrap().remove("renovation");
|
||||
if coll == "trees" {
|
||||
d["status"] = json!("existing");
|
||||
}
|
||||
}
|
||||
}
|
||||
let s = dxf_layer_names(&project(&v));
|
||||
assert!(!s.iter().any(|x| x.starts_with("22_") && (x.ends_with("_Abbruch") || x.ends_with("_Neu"))));
|
||||
assert!(!s.iter().any(|x| x.starts_with("13_") && (x.ends_with("_Abbruch") || x.ends_with("_Neu"))));
|
||||
}
|
||||
Reference in new issue
Block a user