[271] Umbaufilter: Status Bestand/Abbruch/Neu mit Etappen, Filter wie Archicad in Grundriss, Schnitt, Ansicht, Axo, 3D, Kennzahlen, DXF und IFC
Modell (Rust, gen:types): `renovation: {status, phase?}` an Wand, Öffnung (ohne eigenen Status
folgt sie der Wand), Decke, Dach, Treppe, Stütze, Körper und Raum (Raum nur Sichtbarkeit und
Flächen, keine Farbe); `Project.renovation` (Etappen, Farben, eigene Filter, KNOWN_KEYS);
`renovationFilter`/`renovationPhase` an DrawingLevel, ViewTemplate und ViewSnapshot — der Filter
gehört zur Ebene wie die Modelldarstellung [173], damit je Reiter, Ausschnitt und Vorlage.
Kern `renovation.rs` als ein Ort für „sichtbar/wie gezeichnet im Filter“: Vorgaben Bestand,
Abbruch, Neubau, Umbauplan, Endzustand; SIA-400-Farben (Bestand grau, Abbruch gelb gestrichelt,
Neu rot), anpassbar; Etappe „bis n“; neue Öffnung in Bestandswand = Abbruch-Stück, zugemauerte
Öffnung = Ausfachung (die Wand schliesst, wo die Öffnung ausgeblendet ist, wie bei der Regel
„Ausblenden“). Angebunden: Grundriss (Ctx.hidden, Farben je Element-Bereich, nur Schnittflächen
gefüllt, Symbole in Linienfarbe), Schnitt (without_elements + CutRules::with_renovation), Ansicht,
Vektor-Axo, 3D (model3dParts mit Filter, 3D-Fenster nimmt den Filter der aktiven Ebene),
Kennzahlen/Flächen (Text = Zustand), DXF (Layer <Klasse>_Abbruch/_Neu), IFC (Status im
Pset_*Common, Etappe in Dossier_Umbau). Tusche behält die Umbau-Farben (extras::KeepColors).
Neue Bauteile der Zeichenbefehle tragen den Zeichen-Status (commands::stamp_renovation).
Bedienung: Objekt-Info/Objekteinstellungen „Umbau“ und „Etappe“ (Mehrfachauswahl, ein
Undo-Schritt), Statusleiste „Umbau: …“ mit Zeichen-Status und Umbaufilter der Ansicht (im
Überlauf „⋯“ mit der Pausfolie), Befehl `umbau` (B/A/N; getippte Options-Kürzel mit Enter),
Ressourcen-Tab „Umbau“ (Etappen, Farben), Flächenbilanz „Zustand“, Vorlage „Beispiel Umbau“
(CLI :umbau), CLI --renovation/--phase für plan, section, elevation, axo, model3d, kennzahlen.
Tests: Kern renovation_tests.rs (20: Vorgaben, Etappen, Öffnungen in Bestandswand, Grundriss,
Schnitt, Ansicht, Kennzahlen, DXF, IFC, 3D, Tusche, Zeichen-Status, Unsinn), Robustheit (Plan,
Schnitt, Ansicht, Kennzahlen, 3D mit Filter), vitest model/renovation.test.ts und
commands/cmds/renovation.test.ts, e2e renovation271.spec.ts (2× grün). Goldens unverändert.
Bilder doc/review-271 (CLI-SVG --hatch in Chromium, App). Nur im Linux-Container geprüft, nicht
in der Tauri-App/auf dem Mac (Prüfschritt RELEASE-1.0 13.37). Offen: TODO [271].
This commit is contained in:
73 files changed
+2888
-56
No files matched your search
@@ -32,6 +32,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `plan/` | Grundriss, Deckenspiegel, Schnitt, Ansicht, Ausgaben; eigene `plan/README.md` |
|
||||
| `gpu_compile.rs` | GPU-Kompilierung von Plan-Puffern (nativer macOS-Weg) |
|
||||
| `style.rs` | Farben, Schraffur und Schnitt-Linienstil aus dem Modell |
|
||||
| `renovation.rs` | [271] Umbau: Status je Bauteil, Etappen, Umbaufilter (`View`, `Resolved`), SIA-Farben; ein Ort für „sichtbar/wie gezeichnet im Filter“ (s. `doc/ARCHITEKTUR.md` 3.8) |
|
||||
| `standards.rs` | Standard-Bibliothek: Baustoffe mit SIA-400-Schraffur und Kennwerten, Linientypen, Standard-Aufbauten |
|
||||
| `standards_names.rs` | [264] Englische Namen der Standards nach Kennung (`Lang`, `name_in`); neue Projekte in englischer UI bekommen sie über `standardsMergeOps(lang)` |
|
||||
| `furniture_lib.rs` | Objektbibliothek 2D ([253]): Katalog der Standard-Symbole mit Parametern (Definition) und Zeichenfunktionen nach Detailgrad (Erzeugung), Register, Platzhalter für unbekannte Ids; s. `doc/ARCHITEKTUR.md` 3.7 |
|
||||
|
||||
@@ -33,7 +33,8 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
return Ok(ops);
|
||||
}
|
||||
if let Some(ops) = crate::cmd_create::ops(root, p, &v) {
|
||||
return Ok(ops);
|
||||
// [271] Aktueller Zeichen-Status (`renovation` der Anfrage): neue Bauteile tragen ihn (Bestand = ohne Feld).
|
||||
return Ok(stamp_renovation(ops, v.get("renovation")));
|
||||
}
|
||||
if let Some(ops) = crate::cmd_context::ops(root, p, &v) {
|
||||
return Ok(ops);
|
||||
@@ -50,6 +51,34 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
})
|
||||
}
|
||||
|
||||
/// Listen, deren neue Elemente den Zeichen-Status bekommen ([271]).
|
||||
const RENOVATION_COLLECTIONS: [&str; 8] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"];
|
||||
|
||||
/// [271] Neue Bauteile der Ops (`add` in [`RENOVATION_COLLECTIONS`]) erhalten `renovation` (ein Objekt mit gültigem
|
||||
/// `status`), sofern sie keines tragen; sonst unverändert.
|
||||
pub fn stamp_renovation(mut ops: Vec<Op>, ren: Option<&Value>) -> Vec<Op> {
|
||||
let Some(r) = ren.filter(|r| matches!(r.get("status").and_then(Value::as_str), Some("new" | "demolish" | "existing"))) else { return ops };
|
||||
let r = match (r.get("status").and_then(Value::as_str), r.get("phase").and_then(Value::as_str).filter(|x| !x.is_empty())) {
|
||||
(Some("existing"), None) => return ops,
|
||||
(Some(st), Some(ph)) => serde_json::json!({"status": st, "phase": ph}),
|
||||
(Some(st), None) => serde_json::json!({"status": st}),
|
||||
_ => return ops,
|
||||
};
|
||||
for op in ops.iter_mut() {
|
||||
if let Op::Add { collection, items, .. } = op {
|
||||
if !RENOVATION_COLLECTIONS.contains(&collection.as_str()) {
|
||||
continue;
|
||||
}
|
||||
for it in items.iter_mut() {
|
||||
if let Some(o) = it.as_object_mut() {
|
||||
o.entry("renovation").or_insert_with(|| r.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
/// Wie [`ops`], mit Hinweis-Schlüssel (i18n) für die Hülle; bisher nur Verschieben ([144]: Öffnung an
|
||||
/// der Nachbaröffnung angehalten).
|
||||
pub fn result(root: &Map<String, Value>, p: &Project, text: &str) -> Result<GripResult, String> {
|
||||
|
||||
@@ -124,6 +124,22 @@ fn structure_props(external: Option<bool>, load_bearing: Option<bool>) -> Vec<Pr
|
||||
v
|
||||
}
|
||||
|
||||
/// [271] Umbau-Status als `Status` im `Pset_<Bauteil>Common` (IFC4 `PEnum_ElementStatus`: NEW, EXISTING, DEMOLISH; das
|
||||
/// IFC-Mittel für Umbau, das Revit/Archicad beim Austausch lesen) und die Etappe als `Dossier_Umbau.Etappe` (IFC kennt
|
||||
/// Bauphasen nur über Vorgänge `IfcTask` — für Austausch und Filter genügt die Eigenschaft). Nur mit Angabe im Modell.
|
||||
fn renovation_props(p: &Project, psets: &mut Vec<Pset>, common: &'static str, r: Option<&Renovation>) {
|
||||
let Some(r) = r else { return };
|
||||
let status = Prop::Label("Status", crate::renovation::ifc_status(crate::renovation::status_of(Some(r))).to_string());
|
||||
match psets.iter_mut().find(|ps| ps.name == common) {
|
||||
Some(ps) => ps.props.push(status),
|
||||
None => psets.insert(0, Pset { name: common, props: vec![status] }),
|
||||
}
|
||||
let phase = r.phase.as_deref().and_then(|id| crate::renovation::phases(p).iter().find(|x| x.id == id)).map(|x| x.name.trim()).filter(|n| !n.is_empty());
|
||||
if let Some(n) = phase {
|
||||
psets.push(Pset { name: "Dossier_Umbau", props: vec![Prop::Label("Etappe", n.to_string())] });
|
||||
}
|
||||
}
|
||||
|
||||
fn ident(name: &'static str, v: &str) -> Prop {
|
||||
Prop::Ident(name, v.to_string())
|
||||
}
|
||||
@@ -757,6 +773,7 @@ fn fill_psets(p: &Project, o: &Opening, width: f64, height: f64) -> Vec<Pset> {
|
||||
props.extend(o.u_value.filter(|u| *u > 0.0).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
props.extend(label("SecurityRating", &o.burglary_class));
|
||||
let mut psets = vec![Pset { name: pset_name, props }];
|
||||
renovation_props(p, &mut psets, pset_name, crate::renovation::opening_renovation(p, o));
|
||||
psets.extend(qto(if is_door { "Qto_DoorBaseQuantities" } else { "Qto_WindowBaseQuantities" }, qty::opening_quantities(width, height)));
|
||||
psets
|
||||
}
|
||||
@@ -1128,12 +1145,14 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
props.extend(structure_props(wall.is_external, wall.load_bearing));
|
||||
props.extend(crate::u_value::wall_u_value(p, wall).and_then(|u| u.u).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
let mut ps = vec![Pset { name: "Pset_WallCommon", props }];
|
||||
renovation_props(p, &mut ps, "Pset_WallCommon", wall.renovation.as_ref());
|
||||
ps.extend(q);
|
||||
(wt.name.clone(), Some((wt.id.clone(), wt.name.clone(), layers)), ps)
|
||||
}
|
||||
None => {
|
||||
props.extend(structure_props(wall.is_external, wall.load_bearing));
|
||||
let mut ps = if props.is_empty() { Vec::new() } else { vec![Pset { name: "Pset_WallCommon", props }] };
|
||||
renovation_props(p, &mut ps, "Pset_WallCommon", wall.renovation.as_ref());
|
||||
ps.extend(q);
|
||||
(wall.id.clone(), None, ps)
|
||||
}
|
||||
@@ -1405,6 +1424,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
if !slab_props.is_empty() {
|
||||
psets.push(Pset { name: "Pset_SlabCommon", props: slab_props });
|
||||
}
|
||||
renovation_props(&p, &mut psets, "Pset_SlabCommon", c.renovation.as_ref());
|
||||
// Aussparungen (wie im 3D) als innere Ringe des Profils; Netto zieht sie ab.
|
||||
let hole_rings = crate::opening_shape::ceiling_hole_rings(&p, c);
|
||||
let inner: Vec<&[Vec2]> = hole_rings.iter().filter(|r| r.len() >= 3).map(|r| r.as_slice()).collect();
|
||||
@@ -1717,6 +1737,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
props.push(Prop::Bool("IsExternal", true));
|
||||
props.extend(crate::u_value::roof_u_value(&p, roof).and_then(|u| u.u).map(|u| Prop::Thermal("ThermalTransmittance", u)));
|
||||
let mut psets = vec![Pset { name: "Pset_RoofCommon", props }];
|
||||
renovation_props(&p, &mut psets, "Pset_RoofCommon", roof.renovation.as_ref());
|
||||
let (roof_q, dormer_q) = roof_base_quantities(&p, roof);
|
||||
psets.extend(qto("Qto_RoofBaseQuantities", roof_q));
|
||||
psets.extend(qto("Qto_DossierDormerQuantities", dormer_q));
|
||||
@@ -1783,6 +1804,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
classified.push((format!("column/{}", col.id), Kind::Column, col.category_code.clone()));
|
||||
let label = crate::plan::domains::column_label(col);
|
||||
let mut psets = vec![Pset { name: "Pset_ColumnCommon", props: vec![ident("Reference", &label)] }];
|
||||
renovation_props(&p, &mut psets, "Pset_ColumnCommon", col.renovation.as_ref());
|
||||
let quantities = if let [(footprint, zb, zt)] = pieces.as_slice() {
|
||||
qty::column_quantities(footprint, zt - zb)
|
||||
} else {
|
||||
|
||||
@@ -59,6 +59,7 @@ pub use dossier_hatch::jsnum;
|
||||
pub use dossier_hatch::hatch;
|
||||
pub mod hatch_flat;
|
||||
pub mod plan;
|
||||
pub mod renovation;
|
||||
pub mod project_format;
|
||||
pub mod queries;
|
||||
pub mod gpu_compile;
|
||||
|
||||
@@ -1953,6 +1953,16 @@ pub struct DrawingLevel {
|
||||
#[serde(rename = "modelViewOptionId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub model_view_option_id: Option<String>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -2038,6 +2048,16 @@ pub struct ViewTemplate {
|
||||
#[serde(rename = "modelViewOptionId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub model_view_option_id: Option<String>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -2913,6 +2933,136 @@ pub enum SliceTermination {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Status eines Bauteils (Archicad „Renovation Status“; SIA 400: Bestand schwarz/grau, Abbruch gelb,
|
||||
/// Neu rot).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RenovationStatus {
|
||||
#[default]
|
||||
#[serde(rename = "existing")]
|
||||
Existing,
|
||||
#[serde(rename = "demolish")]
|
||||
Demolish,
|
||||
#[serde(rename = "new")]
|
||||
New,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Angaben eines Elements.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct Renovation {
|
||||
pub status: RenovationStatus,
|
||||
/// Etappe (`Project.renovation.phases`, Id): beim Status „neu“ die Bau-, bei „abbruch“ die Abbruch-Etappe.
|
||||
/// Fehlt ⇒ erste Etappe.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Eine Bau-Etappe (Reihenfolge = Reihenfolge der Liste).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationPhase {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Darstellung eines Status im Umbaufilter.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RenovationShow {
|
||||
/// Normal zeichnen (wie ohne Umbau-Angaben).
|
||||
#[default]
|
||||
#[serde(rename = "show")]
|
||||
Show,
|
||||
/// Ausblenden (wie nicht vorhanden: verdeckt nichts, eine Öffnung schliesst ihre Wand).
|
||||
#[serde(rename = "hide")]
|
||||
Hide,
|
||||
/// Mit der Umbau-Farbe des Status (`RenovationStyle`).
|
||||
#[serde(rename = "override")]
|
||||
Override,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farbe eines Status: Füllung der Schnittflächen, Linienfarbe, gestrichelt. Fehlende Felder ⇒ SIA-Vorgabe.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationStyle {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub fill: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub line: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub dashed: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben je Status (fehlt ⇒ SIA-400-Vorgabe, `renovation::default_style`).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationStyles {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub existing: Option<RenovationStyle>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub demolish: Option<RenovationStyle>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub new: Option<RenovationStyle>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Ein Umbaufilter (wie Archicads „Renovation Filter“): Darstellung je Status.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationFilter {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub existing: RenovationShow,
|
||||
pub demolish: RenovationShow,
|
||||
pub new: RenovationShow,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [271] Umbau-Einstellungen des Projekts.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RenovationSettings {
|
||||
/// Etappen in ihrer Reihenfolge (Neubau/Abbruch Etappe 1, 2 …).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub phases: Option<Vec<RenovationPhase>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub styles: Option<RenovationStyles>,
|
||||
/// Eigene Umbaufilter (zusätzlich zu den eingebauten).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub filters: Option<Vec<RenovationFilter>>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Eine Wand, definiert über ihre Achse (Centerline) und ihren Typ.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
@@ -3082,6 +3232,10 @@ pub struct Wall {
|
||||
#[serde(rename = "surfacePatternOffset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub surface_pattern_offset: Option<Vec2>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3240,6 +3394,10 @@ pub struct Ceiling {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bottom: Option<VerticalAnchor>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3443,6 +3601,10 @@ pub struct Roof {
|
||||
#[serde(rename = "parapetComponentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub parapet_component_id: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3935,6 +4097,10 @@ pub struct Opening {
|
||||
#[serde(rename = "doorFrame", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub door_frame: Option<DoorFrameDetail>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand wie die Wand (eine neue Öffnung in einer Bestandswand bricht die Wand dort ab, eine Öffnung „Abbruch“ wird zugemauert).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4196,6 +4362,10 @@ pub struct Stair {
|
||||
#[serde(rename = "postDepth", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub post_depth: Option<f64>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4472,6 +4642,10 @@ pub struct Room {
|
||||
#[serde(rename = "floorBuildUp", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub floor_build_up: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand (nur Sichtbarkeit und Flächen je Zustand, keine Umbau-Farbe: ein Raum ist kein Bauteil).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4820,6 +4994,10 @@ pub struct ExtrudedSolid {
|
||||
#[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub component_id: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -4927,6 +5105,10 @@ pub struct Column {
|
||||
#[serde(rename = "hatchSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hatch_source: Option<AttributeSource>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -5478,6 +5660,16 @@ pub struct ViewSnapshot {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub doc3d: Option<Doc3d>,
|
||||
/// [271] Umbaufilter (eingebaut „bestand“, „abbruch“, „neubau“, „umbauplan“, „endzustand“ oder Id aus
|
||||
/// `Project.renovation.filters`). Fehlt ⇒ kein Filter: alle Bauteile wie ohne Umbau-Angaben.
|
||||
#[serde(rename = "renovationFilter", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_filter: Option<String>,
|
||||
/// [271] Etappe, bis zu der der Umbaufilter gilt (Id aus `Project.renovation.phases`): Neues späterer Etappen fehlt
|
||||
/// noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
#[serde(rename = "renovationPhase", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation_phase: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -6568,6 +6760,10 @@ pub struct Project {
|
||||
#[serde(rename = "geoAnchor", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional, inline)]
|
||||
pub geo_anchor: Option<ProjectGeoAnchor>,
|
||||
/// [271] Umbau: Etappen, Farben je Status (SIA 400) und eigene Umbaufilter.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<RenovationSettings>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -705,8 +705,21 @@ pub fn axo_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>, St
|
||||
let mono = args.first().is_some_and(|&x| x != 0.0);
|
||||
let scale = args.get(1).copied().filter(|s| s.is_finite() && *s > 0.0).unwrap_or(100.0);
|
||||
let mut w = crate::plan::buf::Writer::new(true);
|
||||
// [271] Umbaufilter (`renovation`, `renovationPhase`): Ausgeblendetes fehlt, Flächen in der Umbau-Farbe.
|
||||
let ren = crate::renovation::View::new(p, v.get("renovation").and_then(|x| x.as_str()), v.get("renovationPhase").and_then(|x| x.as_str())).map(|r| r.resolve(p));
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
let Some(a) = AxoArgs::parse(p, &v) else { return Ok(w.finish()) };
|
||||
if let Some((mut prims, bounds)) = axo_primitives(p, &a, mono)? {
|
||||
if let Some(r) = ren.as_ref().filter(|r| !r.styled.is_empty()) {
|
||||
for q in prims.iter_mut() {
|
||||
let Some(st) = crate::renovation::prim_element(q).and_then(|id| r.styled.get(id)) else { continue };
|
||||
if let Primitive::Polygon { fill, stroke, .. } = q {
|
||||
*fill = st.fill.clone();
|
||||
*stroke = st.fill.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
super::extras::scale_line_weights(p, scale, &mut prims);
|
||||
w.group(&prims);
|
||||
w.bounds = Some(bounds);
|
||||
|
||||
@@ -148,6 +148,7 @@ pub fn ctx_key(a: &PlanArgs) -> String {
|
||||
});
|
||||
format!("{}\u{1}{:?}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}\u{1}{}", a.floor, a.detail, a.reference_lines, a.global, a.scale.to_bits(), a.for_print, a.compact, a.mono, a.auto_coarse, rules) + &a.model_view.as_deref().map_or(String::new(), |m| format!("\u{1}mv:{m}"))
|
||||
+ &a.trace_of.as_deref().map_or(String::new(), |t| format!("\u{1}trace:{t}"))
|
||||
+ &a.renovation.as_deref().map_or(String::new(), |t| format!("\u{1}ren:{t}:{}", a.renovation_phase.as_deref().unwrap_or("")))
|
||||
}
|
||||
|
||||
/// Sichtbarkeit und Dimmen als vergleichbarer Text (Mengen sortiert).
|
||||
|
||||
@@ -55,6 +55,8 @@ fn floor_args(a: &PlanArgs, floor: &str) -> PlanArgs {
|
||||
// [173] Die Modelldarstellung der Deckenspiegel-Ebene gilt auch für das Bezugsgeschoss.
|
||||
model_view: a.model_view.clone(),
|
||||
trace_of: None,
|
||||
renovation: a.renovation.clone(),
|
||||
renovation_phase: a.renovation_phase.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,10 @@ pub struct PlanArgs {
|
||||
/// [203] Pausfolie: dieser Plan liegt gedimmt unter dem Grundriss des Geschosses `trace_of` (Zeichnungsebenen-Modus
|
||||
/// „Andere grau"). Achsraster, die auch dort stehen, fehlen hier — sie stehen nur einmal im Bild. `None` = eigener Plan.
|
||||
pub trace_of: Option<String>,
|
||||
/// [271] Ausdrücklich angefragter Umbaufilter (Id oder Name; CLI `--renovation`, Blatt-Ausschnitt) und Etappe;
|
||||
/// `None` = der der Ebene (`DrawingLevel.renovationFilter`), sonst kein Filter (`renovation.rs`).
|
||||
pub renovation: Option<String>,
|
||||
pub renovation_phase: Option<String>,
|
||||
}
|
||||
|
||||
/// [140] Ab diesem Massstab (1:N) zeichnet der Detailgrad „mittel" wie „grob".
|
||||
@@ -110,6 +114,8 @@ impl PlanArgs {
|
||||
rules: v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()),
|
||||
model_view: v.get("modelView").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
trace_of: v.get("traceOf").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation: v.get("renovation").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation_phase: v.get("renovationPhase").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -156,6 +162,8 @@ pub struct Ctx<'a> {
|
||||
bubble_obst: std::cell::OnceCell<super::stamp_place::Obstacles>,
|
||||
/// [207] Linienzüge der Strassen-Klasse („11“) je Geschoss für Strassennamen entlang der Achse (`plan/text_curve.rs`).
|
||||
road_axes: std::cell::OnceCell<Vec<(String, Vec<crate::model::Vec2>)>>,
|
||||
/// [271] Umbaufilter dieser Plan-Erzeugung (ausgeblendete Elemente stehen zusätzlich in `hidden`).
|
||||
ren: Option<crate::renovation::Resolved>,
|
||||
}
|
||||
|
||||
impl<'a> Ctx<'a> {
|
||||
@@ -164,10 +172,27 @@ impl<'a> Ctx<'a> {
|
||||
for c in p.flat_categories() {
|
||||
cats.insert(c.code.as_str(), c);
|
||||
}
|
||||
let hidden = overrides::hidden_elements(p, overrides::RuleView::at(a.scale, a.rules.as_ref()).view("plan"));
|
||||
let mut hidden = overrides::hidden_elements(p, overrides::RuleView::at(a.scale, a.rules.as_ref()).view("plan"));
|
||||
// [271] Umbaufilter: ausgeblendete Bauteile wie bei der Regel „Ausblenden“ (eine Öffnung schliesst ihre Wand).
|
||||
let ren = crate::renovation::View::for_level(p, &a.floor, a.renovation.as_deref(), a.renovation_phase.as_deref()).map(|v| v.resolve(p)).filter(|r| !r.is_empty());
|
||||
if let Some(r) = &ren {
|
||||
hidden.extend(r.hidden.iter().cloned());
|
||||
}
|
||||
let mv_sel = super::model_view::selected_id(p, &a.floor, a.model_view.as_deref()).and_then(|id| super::model_view::find(p, id));
|
||||
let mv = super::model_view::resolve(mv_sel, a.detail, a.scale);
|
||||
Ctx { p, a, cats, hidden, mv_sel, mv, house: Default::default(), drawn_obst: Default::default(), obst_busy: Default::default(), bubble_obst: Default::default(), road_axes: Default::default() }
|
||||
Ctx { p, a, cats, hidden, mv_sel, mv, house: Default::default(), drawn_obst: Default::default(), obst_busy: Default::default(), bubble_obst: Default::default(), road_axes: Default::default(), ren }
|
||||
}
|
||||
|
||||
/// [271] Umbaufilter (Farben, Ersatzstücke der Öffnungen); `None` ohne Filter.
|
||||
pub fn renovation(&self) -> Option<&crate::renovation::Resolved> {
|
||||
self.ren.as_ref()
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben auf `out[from..]` (Primitive nach ihrem Element, sonst nach `owner`).
|
||||
pub fn renovation_restyle(&self, out: &mut Vec<Primitive>, from: usize, owner: Option<&str>) {
|
||||
if let Some(r) = &self.ren {
|
||||
crate::renovation::restyle_range(r, out, from, owner);
|
||||
}
|
||||
}
|
||||
|
||||
/// [179] Aussenringe der Gebäudegrundfläche (`context::building_rings`), einmal je Plan.
|
||||
@@ -1643,7 +1668,7 @@ pub fn room_stamp_spots(p: &Project, floor: &str, show: &HashSet<String>, scale:
|
||||
return out;
|
||||
}
|
||||
let (detail, auto_coarse) = effective_detail(Detail::Mittel, scale);
|
||||
let a = PlanArgs { floor: floor.to_string(), detail, show: show.clone(), grey: HashSet::new(), reference_lines: false, global: true, scale, for_print: false, compact: false, mono: false, sun_when: None, auto_coarse, rules: None, model_view: None, trace_of: None };
|
||||
let a = PlanArgs { floor: floor.to_string(), detail, show: show.clone(), grey: HashSet::new(), reference_lines: false, global: true, scale, for_print: false, compact: false, mono: false, sun_when: None, auto_coarse, rules: None, model_view: None, trace_of: None, renovation: None, renovation_phase: None };
|
||||
let Ok(d) = plan_domains(p, &a) else { return out };
|
||||
for q in d.rooms.iter().chain(&d.sections) {
|
||||
if let Primitive::Text { at, room_id: Some(id), .. } = q {
|
||||
@@ -1967,6 +1992,12 @@ fn domains_before(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) -> Result
|
||||
// [149] Bäume (Planzeichen) mit den Stützen in einer Gruppe.
|
||||
super::trees::plan_trees(c, &mut out.columns);
|
||||
solids(c, &mut out.solids);
|
||||
// [271] Umbaufilter: Decken, Dächer, Treppen, Stützen und Körper in ihrer Umbau-Farbe (Wände: `plan_walls`).
|
||||
if c.renovation().is_some() {
|
||||
for v in [&mut out.ceilings, &mut out.roofs, &mut out.stairs, &mut out.columns, &mut out.solids] {
|
||||
c.renovation_restyle(v, 0, None);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1460,7 +1460,9 @@ pub fn collect(parts: &mut [Part], project: &Project, o: &DxfOptions) -> Option<
|
||||
cx.flat.add_layer(LAYER_EXTRUSION, Some(rgb_from_hex("#d98c40")), 13.0);
|
||||
cx.flat.add_layer(LAYER_ZERO, None, 25.0);
|
||||
|
||||
emit_entries(&mut cx, &mut main, &entries, &layer_by_code, true);
|
||||
// [271] Umbau: Bauteile mit Status Abbruch/Neu auf eigene Ebenen „<Ebene>_Abbruch“ bzw. „<Ebene>_Neu“ (Bestand bleibt).
|
||||
let ren_layer = renovation_layers(&mut cx, &cats);
|
||||
emit_entries(&mut cx, &mut main, &entries, &layer_by_code, &ren_layer, true);
|
||||
cx.flat.set_pen(&mut main, -1.0);
|
||||
cx.flat.set_epen(&mut main, -1.0, -1.0, -1.0);
|
||||
|
||||
@@ -1484,7 +1486,37 @@ pub fn collect(parts: &mut [Part], project: &Project, o: &DxfOptions) -> Option<
|
||||
/// Bemassungen, Blockinstanzen und Öffnungen als CAD-Objekte, der Rest je Primitiv.
|
||||
/// `objects = false`: auch Bemassungen, Blockinstanzen und Öffnungen nur als ihre Primitive (Inhalt
|
||||
/// eines Blocks, der keine weiteren Blöcke definieren darf).
|
||||
fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code: &HashMap<&str, String>, objects: bool) {
|
||||
/// [271] Ebene je Bauteil mit Umbau-Status Abbruch/Neu (Wände, Stützen, Öffnungen samt Wand-Rückfall): Element-Id →
|
||||
/// Ebenen-Name, die Ebenen sind angelegt (Farbe und Strichstärke der Kategorie).
|
||||
fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, String> {
|
||||
use crate::model::RenovationStatus as S;
|
||||
let p = cx.project;
|
||||
let mut items: Vec<(&str, &str, S)> = Vec::new();
|
||||
for w in &p.walls {
|
||||
items.push((&w.id, &w.category_code, crate::renovation::status_of(w.renovation.as_ref())));
|
||||
}
|
||||
for c in p.columns.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
items.push((&o.id, &o.category_code, crate::renovation::status_of(crate::renovation::opening_renovation(p, o))));
|
||||
}
|
||||
let mut out = HashMap::new();
|
||||
for (id, code, st) in items {
|
||||
let suffix = match st {
|
||||
S::Demolish => "Abbruch",
|
||||
S::New => "Neu",
|
||||
_ => continue,
|
||||
};
|
||||
let Some(c) = cats.iter().find(|c| c.code == code) else { continue };
|
||||
let name = format!("{}_{}_{}", c.code, c.name, suffix);
|
||||
cx.flat.add_layer(&name, Some(rgb_from_hex(&c.color)), mm_to_lwe(c.lw));
|
||||
out.insert(id.to_string(), name);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code: &HashMap<&str, String>, ren_layer: &HashMap<String, String>, objects: bool) {
|
||||
let project = cx.project;
|
||||
// 2) Rückverweise Primitiv → Kategorie.
|
||||
let code_by_wall: HashMap<&str, &str> = project.walls.iter().map(|w| (w.id.as_str(), w.category_code.as_str())).collect();
|
||||
@@ -1501,6 +1533,9 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
let layer_for = |e: &Entry| -> String {
|
||||
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)) {
|
||||
return l.clone();
|
||||
}
|
||||
if let Some(w) = &e.ids.wall {
|
||||
return layer_of_code(&code_by_wall, w).unwrap_or_else(|| LAYER_DEFAULT.to_string());
|
||||
}
|
||||
@@ -1668,7 +1703,7 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
}
|
||||
_ => {
|
||||
let op = opening_by_id[id];
|
||||
let layer = layer_by_code.get(op.category_code.as_str()).cloned().unwrap_or_else(|| LAYER_SYMBOLS.to_string());
|
||||
let layer = ren_layer.get(&op.id).or_else(|| layer_by_code.get(op.category_code.as_str())).cloned().unwrap_or_else(|| LAYER_SYMBOLS.to_string());
|
||||
if !cx.opening(main, op, &members, &layer, &mut names) {
|
||||
for m in &members {
|
||||
let l = layer_for(m);
|
||||
@@ -1746,6 +1781,8 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
|
||||
rules: None,
|
||||
model_view: None,
|
||||
trace_of: None,
|
||||
renovation: None,
|
||||
renovation_phase: None,
|
||||
};
|
||||
if let Some(entries) = plan_domains_buf(p, &args).ok().and_then(|buf| {
|
||||
let view = View::parse(&buf)?;
|
||||
@@ -1756,7 +1793,7 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
|
||||
let o1 = DxfOptions { scale: 1.0, include_hatches: cx.o.include_hatches, dim_cm: cx.o.dim_cm, paper_layout: false, bounds: [0.0; 4], default_font: cx.o.default_font.clone(), floor: String::new(), table_labels: String::new() };
|
||||
let mut sub = Ctx { project: p, o: &o1, flat: std::mem::replace(&mut cx.flat, Flat::new()) };
|
||||
let mut content = Buf::block();
|
||||
emit_entries(&mut sub, &mut content, &entries, layer_by_code, false);
|
||||
emit_entries(&mut sub, &mut content, &entries, layer_by_code, &HashMap::new(), false);
|
||||
let bname = format!("SHEET_{}", n + 1);
|
||||
sub.flat.define_block(main, &bname, &name, &[], content);
|
||||
cx.flat = sub.flat;
|
||||
|
||||
@@ -102,6 +102,22 @@ fn surf_ov(p: &Project, v: RuleView, kind: &str, code: &str, name: Option<&str>,
|
||||
(o.fill.is_some() || o.no_pattern || o.outline.is_some() || o.color.is_some() || o.lineweight.is_some() || o.dash.is_some() || o.hide).then(|| Rc::new(o))
|
||||
}
|
||||
|
||||
/// [271] Umbau-Farben je Ansichtsfläche (Füllung ohne Muster, Kanten in der Linienfarbe, gestrichelt bei Abbruch); gehen
|
||||
/// den Regeln vor.
|
||||
pub(super) fn renovation_faces(faces: &mut [Face], r: &crate::renovation::Resolved) {
|
||||
if r.styled.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut memo: HashMap<String, Rc<SurfOv>> = HashMap::new();
|
||||
for f in faces.iter_mut().filter(|f| !f.id.is_empty()) {
|
||||
let Some(st) = r.styled.get(&f.id) else { continue };
|
||||
let o = memo.entry(f.id.clone()).or_insert_with(|| {
|
||||
Rc::new(SurfOv { fill: Some(st.fill.clone()), no_pattern: true, hatch: None, outline: None, color: st.line.clone(), lineweight: None, dash: st.dashed.then(|| Some(crate::renovation::DEMOLISH_DASH.to_vec())), hide: false })
|
||||
});
|
||||
f.ov = Some(o.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Override-Regeln je Ansichtsfläche: Wand (Wandtyp, sichtbare Seite = äusserste bzw. innerste
|
||||
/// Schicht), Decke/Bodenplatte, Treppe, Dach (Eindeckung = erste Schicht), Stütze. Ohne aktive Regel nichts.
|
||||
pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
|
||||
|
||||
@@ -205,6 +205,12 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
|
||||
/// `None` = Schalter im Projekt). [33] Regeln wirken auf Flächen (Füllung, Schraffur, ausblenden), Kanten
|
||||
/// (Farbe, Stärke, Umriss aus) und Öffnungen (Linien, Glasfüllung).
|
||||
pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, mono: bool, vis: &Visibility, scale: f64, rules: Option<&HashSet<String>>) -> Result<Option<(Vec<Primitive>, [f64; 4])>, String> {
|
||||
elevation_primitives_ren(p, level, shadows, mono, vis, scale, rules, None)
|
||||
}
|
||||
|
||||
/// [271] Wie [`elevation_primitives_with`] mit den Umbau-Farben `ren` (das Ausgeblendete fehlt schon in `p`).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, mono: bool, vis: &Visibility, scale: f64, rules: Option<&HashSet<String>>, ren: Option<&crate::renovation::Resolved>) -> Result<Option<(Vec<Primitive>, [f64; 4])>, String> {
|
||||
let Some(plane) = level.plane() else { return Ok(None) };
|
||||
let frame = frame_of(&plane);
|
||||
let mut walls = model3d::emit_walls_with(p, false, false)?;
|
||||
@@ -295,6 +301,9 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
|
||||
// Wände samt ihren Öffnungen.
|
||||
let rv = RuleView::at(scale, rules).view("elevation");
|
||||
face_overrides(p, &mut faces, rv);
|
||||
if let Some(r) = ren {
|
||||
face::renovation_faces(&mut faces, r);
|
||||
}
|
||||
let hidden_walls: HashSet<String> = faces.iter().filter(|f| f.role == Role::Wall && f.ov.as_ref().is_some_and(|o| o.hide)).map(|f| f.id.clone()).collect();
|
||||
faces.retain(|f| !f.ov.as_ref().is_some_and(|o| o.hide));
|
||||
|
||||
@@ -958,7 +967,11 @@ pub fn elevation_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u
|
||||
w.post = super::extras::sketch_post(Some(level.sketch), scale);
|
||||
// [33] Eingeschaltete Override-Regeln eines Blatt-Viewports (`rules`: ids; fehlt = Schalter im Projekt).
|
||||
let on: Option<HashSet<String>> = v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect());
|
||||
if let Some((mut prims, bounds)) = elevation_primitives_with(p, &level, shadows, mono, &vis, scale, on.as_ref())? {
|
||||
// [271] Umbaufilter (angefragt, sonst der der Ebene): Ausgeblendetes fehlt (verdeckt nichts), Farben auf die Flächen.
|
||||
let ren = super::section::query::renovation_view(p, &v, &level).map(|r| r.resolve(p)).filter(|r| !r.is_empty());
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
if let Some((mut prims, bounds)) = elevation_primitives_ren(p, &level, shadows, mono, &vis, scale, on.as_ref(), ren.as_ref())? {
|
||||
super::extras::scale_line_weights(p, scale, &mut prims);
|
||||
w.group(&prims);
|
||||
// Achsraster ([112]): Achsen quer zur Blickebene.
|
||||
|
||||
@@ -636,6 +636,40 @@ pub struct Post {
|
||||
pub lw: f64,
|
||||
/// Skizzenstil ([67], `plan/sketch.rs`): Meter Modell je Papier-mm; 0 = aus.
|
||||
pub sketch: f64,
|
||||
/// [271] Farben, die Schwarz-Weiss nicht ändert (Umbau-Farben: im Umbauplan sind sie die Aussage).
|
||||
pub keep: KeepColors,
|
||||
}
|
||||
|
||||
/// [271] Bis zu sechs Farben (RGB), die [`Post`] in Schwarz-Weiss stehen lässt.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||
pub struct KeepColors {
|
||||
rgb: [u32; 6],
|
||||
n: u8,
|
||||
}
|
||||
|
||||
impl KeepColors {
|
||||
/// Aus Hex-Farben (`#rrggbb`); ungültige und überzählige fallen weg.
|
||||
pub fn of<'a>(colors: impl IntoIterator<Item = &'a str>) -> KeepColors {
|
||||
let mut k = KeepColors::default();
|
||||
for c in colors {
|
||||
if let Some(v) = hex_rgb(c) {
|
||||
if (k.n as usize) < k.rgb.len() && !k.rgb[..k.n as usize].contains(&v) {
|
||||
k.rgb[k.n as usize] = v;
|
||||
k.n += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
k
|
||||
}
|
||||
|
||||
pub fn has(&self, c: &str) -> bool {
|
||||
self.n > 0 && hex_rgb(c).is_some_and(|v| self.rgb[..self.n as usize].contains(&v))
|
||||
}
|
||||
}
|
||||
|
||||
fn hex_rgb(c: &str) -> Option<u32> {
|
||||
let h = c.trim().strip_prefix('#')?;
|
||||
(h.len() == 6).then(|| u32::from_str_radix(h, 16).ok()).flatten()
|
||||
}
|
||||
|
||||
impl Post {
|
||||
@@ -666,12 +700,12 @@ impl Post {
|
||||
if *fill != "none" {
|
||||
if solid {
|
||||
*fill = HATCH_INK.into();
|
||||
} else if !is_neutral(fill) {
|
||||
} else if !is_neutral(fill) && !self.keep.has(fill) {
|
||||
*fill = "#ffffff".into();
|
||||
}
|
||||
}
|
||||
// [140] „none" bleibt (Wandschichten ohne Umriss: sonst Kontur statt Schraffur).
|
||||
if *stroke != "none" && !is_neutral(stroke) {
|
||||
if *stroke != "none" && !is_neutral(stroke) && !self.keep.has(stroke) {
|
||||
*stroke = MONO_INK.into();
|
||||
}
|
||||
}
|
||||
@@ -692,7 +726,7 @@ impl Post {
|
||||
}
|
||||
}
|
||||
Primitive::Line { weight_mm, color, .. } => {
|
||||
if self.mono && !color.as_deref().is_some_and(is_neutral) {
|
||||
if self.mono && !color.as_deref().is_some_and(|c| is_neutral(c) || self.keep.has(c)) {
|
||||
*color = Some(MONO_INK.into());
|
||||
}
|
||||
if self.lw != 1.0 {
|
||||
@@ -710,7 +744,7 @@ impl Post {
|
||||
|
||||
/// Farbe und Stärke einer Linie.
|
||||
pub fn line<'a>(&self, color: Option<&'a str>, w: f64) -> (Option<&'a str>, f64) {
|
||||
(if self.mono && !color.is_some_and(is_neutral) { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
|
||||
(if self.mono && !color.is_some_and(|c| is_neutral(c) || self.keep.has(c)) { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,7 +769,7 @@ pub fn scale_line_weights(p: &Project, scale: f64, prims: &mut [Primitive]) {
|
||||
if lw == 1.0 {
|
||||
return;
|
||||
}
|
||||
let post = Post { mono: false, lw, sketch: 0.0 };
|
||||
let post = Post { mono: false, lw, sketch: 0.0, keep: KeepColors::default() };
|
||||
for q in prims.iter_mut() {
|
||||
match q {
|
||||
Primitive::Line { weight_mm, .. } => *weight_mm = scale_weight(*weight_mm, lw),
|
||||
@@ -750,7 +784,13 @@ pub fn post_for(p: &Project, a: &super::domains::PlanArgs) -> Option<Post> {
|
||||
let level = p.floor(&a.floor);
|
||||
let sheet = level.is_some_and(|l| l.layout_id.is_some());
|
||||
let sketch = if sheet { 0.0 } else { sketch_k(level.and_then(|l| l.sketch), a.scale) };
|
||||
Some(Post { mono: a.mono, lw: if sheet { 1.0 } else { line_weight_factor(p, a.scale) }, sketch }).filter(Post::active)
|
||||
// [271] Umbau-Farben bleiben auch in Schwarz-Weiss (Tusche): ohne sie sagt ein Umbauplan nichts.
|
||||
let keep = if a.mono {
|
||||
crate::renovation::View::for_level(p, &a.floor, a.renovation.as_deref(), a.renovation_phase.as_deref()).map_or_else(KeepColors::default, |v| KeepColors::of(v.colors().iter().map(String::as_str)))
|
||||
} else {
|
||||
KeepColors::default()
|
||||
};
|
||||
Some(Post { mono: a.mono, lw: if sheet { 1.0 } else { line_weight_factor(p, a.scale) }, sketch, keep }).filter(Post::active)
|
||||
}
|
||||
|
||||
/// [67] Skizzenstil einer Ebene beim Massstab 1:`scale`: Meter je Papier-mm, 0 = aus.
|
||||
@@ -764,7 +804,7 @@ pub fn sketch_k(on: Option<bool>, scale: f64) -> f64 {
|
||||
|
||||
/// [67] Nachbearbeitung nur mit Skizzenstil (Schnitt/Ansicht; `None` = aus).
|
||||
pub fn sketch_post(on: Option<bool>, scale: f64) -> Option<Post> {
|
||||
Some(Post { mono: false, lw: 1.0, sketch: sketch_k(on, scale) }).filter(Post::active)
|
||||
Some(Post { mono: false, lw: 1.0, sketch: sketch_k(on, scale), keep: KeepColors::default() }).filter(Post::active)
|
||||
}
|
||||
|
||||
// ── Ausmass ─────────────────────────────────────────────────────────────────────────────────────
|
||||
@@ -1124,7 +1164,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn mono_poche_bleibt_schwarz() {
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0 };
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() };
|
||||
let mut solid = HatchRender { pattern: HatchPattern::Solid, ..no_hatch() };
|
||||
solid.color = "#123456".into();
|
||||
let mut p = flat_polygon(vec![], "#abcdef", 1.0);
|
||||
@@ -1156,10 +1196,10 @@ mod tests {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut p = stamp();
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0 }.apply(&mut p);
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() }.apply(&mut p);
|
||||
assert_eq!(colors(&p), (MONO_INK.to_string(), vec![Some("#808080".into()), Some(MONO_INK.into())]));
|
||||
let mut p = stamp();
|
||||
Post { mono: false, lw: 0.8, sketch: 0.0 }.apply(&mut p);
|
||||
Post { mono: false, lw: 0.8, sketch: 0.0, keep: KeepColors::default() }.apply(&mut p);
|
||||
assert_eq!(colors(&p), ("#2255cc".to_string(), vec![Some("#808080".into()), Some("#d0342c".into())]));
|
||||
}
|
||||
|
||||
@@ -1167,7 +1207,7 @@ mod tests {
|
||||
/// die Kontur die Schraffur), Grautöne (Schatten, Gelände, Treppe) bleiben, bunte Farben werden Tinte/Papier.
|
||||
#[test]
|
||||
fn mono_behaelt_grau_und_ohne_umriss() {
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0 };
|
||||
let post = Post { mono: true, lw: 1.0, sketch: 0.0, keep: KeepColors::default() };
|
||||
let mut p = flat_polygon(vec![], "#3c3c3c", 0.0);
|
||||
if let Primitive::Polygon { stroke, hatch, .. } = &mut p {
|
||||
*stroke = "none".into();
|
||||
|
||||
@@ -26,7 +26,7 @@ mod meshes;
|
||||
mod projection;
|
||||
mod primitives;
|
||||
mod openings;
|
||||
mod query;
|
||||
pub(crate) mod query;
|
||||
pub mod unfold;
|
||||
|
||||
use input::*;
|
||||
@@ -131,6 +131,9 @@ pub struct LevelSpec {
|
||||
pub cut_hatch: bool,
|
||||
/// [173] Modelldarstellung der Ebene (`modelViewOptionId`; Ansicht: Öffnungslinien der Fenster).
|
||||
pub model_view: Option<String>,
|
||||
/// [271] Umbaufilter und Etappe der Ebene (`renovationFilter`, `renovationPhase`).
|
||||
pub renovation: Option<String>,
|
||||
pub renovation_phase: Option<String>,
|
||||
}
|
||||
|
||||
impl LevelSpec {
|
||||
@@ -149,6 +152,8 @@ impl LevelSpec {
|
||||
sketch: v.get("sketch").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
cut_hatch: v.get("cutHatch").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
model_view: v.get("modelViewOptionId").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation: v.get("renovationFilter").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
renovation_phase: v.get("renovationPhase").and_then(|m| m.as_str()).filter(|m| !m.is_empty()).map(String::from),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +303,27 @@ pub struct CutRules {
|
||||
}
|
||||
|
||||
impl CutRules {
|
||||
/// [271] Umbau-Farben als Override der Schnittflächen: Füllung der Farbe, ohne Muster, Umriss gestrichelt bei
|
||||
/// Abbruch. Geht den Regeln vor (der Umbaufilter ist die Aussage des Plans).
|
||||
pub fn with_renovation(mut self, out: &Output, r: Option<&crate::renovation::Resolved>) -> CutRules {
|
||||
let Some(r) = r.filter(|r| !r.styled.is_empty()) else { return self };
|
||||
if out.cuts.iter().all(|c| c.source_id.as_ref().is_none_or(|s| !r.styled.contains_key(s))) {
|
||||
return self;
|
||||
}
|
||||
self.ov.resize(out.cuts.len(), None);
|
||||
for (i, c) in out.cuts.iter().enumerate() {
|
||||
let Some(st) = c.source_id.as_ref().and_then(|s| r.styled.get(s)) else { continue };
|
||||
let prev = self.ov[i].take();
|
||||
self.ov[i] = Some(CutOv {
|
||||
fill: Some(st.fill.clone()),
|
||||
hatch: HatchOv::None,
|
||||
outline: prev.as_ref().and_then(|o| o.outline).or(Some(true)),
|
||||
dash: if st.dashed { Some(Some(crate::renovation::DEMOLISH_DASH.to_vec())) } else { prev.and_then(|o| o.dash) },
|
||||
});
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// `v`: Massstab und eingeschaltete Regeln der Darstellung ([`super::overrides::RuleView`]).
|
||||
pub fn of(p: &Project, out: &Output, v: RuleView) -> CutRules {
|
||||
let ts = crate::excavation::terrains(p);
|
||||
|
||||
@@ -40,6 +40,17 @@ fn cache_put(key: (f64, u64), o: std::rc::Rc<Output>) {
|
||||
});
|
||||
}
|
||||
|
||||
/// [271] Umbaufilter eines Schnitts/einer Ansicht: `renovation`/`renovationPhase` im Aufruf (CLI, Blatt-Ausschnitt), sonst
|
||||
/// die Felder der Ebene (`renovationFilter`, `renovationPhase`).
|
||||
pub fn renovation_view(p: &Project, v: &serde_json::Value, level: &LevelSpec) -> Option<crate::renovation::View> {
|
||||
let req = v.get("renovation").and_then(|m| m.as_str()).filter(|m| !m.is_empty());
|
||||
let (f, ph) = match req {
|
||||
Some(f) => (Some(f), v.get("renovationPhase").and_then(|m| m.as_str())),
|
||||
None => (level.renovation.as_deref(), level.renovation_phase.as_deref()),
|
||||
};
|
||||
crate::renovation::View::new(p, f, ph)
|
||||
}
|
||||
|
||||
/// Abfrage `sectionPlan`: `args` = `[mono, openings, key]` (`key` > 0
|
||||
/// = Schlüssel des vorbereiteten Schnitts, s. Cache unten, 0 = immer rechnen),
|
||||
/// `text` = `{"level": {...}, "hiddenLines", "hasVis", "invisible", "hasDisplay", "norender", "grey"}`.
|
||||
@@ -57,7 +68,12 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
|
||||
let on: Option<HashSet<String>> = v.get("rules").and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect());
|
||||
let rv = RuleView::at(scale, on.as_ref()).view("section");
|
||||
// [33] Regel „Ausblenden“: Schnitt ohne diese Elemente (sie verdecken nichts, Wände samt Öffnungen).
|
||||
let hidden_ids = crate::plan::overrides::hidden_elements(p, rv);
|
||||
let mut hidden_ids = crate::plan::overrides::hidden_elements(p, rv);
|
||||
// [271] Umbaufilter (angefragt, sonst der der Ebene): Ausgeblendetes wie „Ausblenden“, Farben auf die Schnittflächen.
|
||||
let ren = renovation_view(p, &v, &level).map(|r| r.resolve(p));
|
||||
if let Some(r) = &ren {
|
||||
hidden_ids.extend(r.hidden.iter().cloned());
|
||||
}
|
||||
let filtered = (!hidden_ids.is_empty()).then(|| without_elements(p, &hidden_ids));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
// [184] Öffnungen mit Detailgrad grob (Strich im Schnitt): Wandschnitt an Sturz/Brüstung flach. Das ändert die
|
||||
@@ -118,7 +134,7 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
|
||||
let mvo = mv_id.map(|id| crate::plan::model_view::for_view(p, Some(id), detail, scale));
|
||||
let smv = mvo.as_ref().map(|o| SectionMv::of(p, &out, o));
|
||||
let detail = mvo.as_ref().map_or(detail, |o| o.detail);
|
||||
let (mut prims, bounds) = section_primitives_mv(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &CutRules::of(p, &out, rv), smv.as_ref());
|
||||
let (mut prims, bounds) = section_primitives_mv(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &CutRules::of(p, &out, rv).with_renovation(&out, ren.as_ref()), smv.as_ref());
|
||||
w.post = crate::plan::extras::sketch_post(Some(level.sketch), scale);
|
||||
// Strichstärken nach Massstab ([32]) wie im Grundriss.
|
||||
crate::plan::extras::scale_line_weights(p, scale, &mut prims);
|
||||
|
||||
@@ -168,7 +168,7 @@ fn tiefe_blendet_ferne_bauteile_aus() {
|
||||
let mut p = Project::default();
|
||||
// quer: von der Ebene geschnitten und weit nach hinten; nah: 3 m, fern: 10 m hinter der Ebene (höher).
|
||||
p.walls = vec![wall("quer", (0.0, -1.0), (0.0, 12.0), 2.5), wall("nah", (2.0, 3.0), (6.0, 3.0), 2.5), wall("fern", (2.0, 10.0), (6.0, 10.0), 4.0)];
|
||||
let lv = |depth: Option<f64>| LevelSpec { model_view: None, bends: Vec::new(), sketch: false, cut_hatch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
|
||||
let lv = |depth: Option<f64>| LevelSpec { model_view: None, renovation: None, renovation_phase: None, bends: Vec::new(), sketch: false, cut_hatch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
|
||||
let top = |o: &Output| o.visible.iter().map(|e| e.a[1].max(e.b[1])).fold(f64::NEG_INFINITY, f64::max);
|
||||
let all = compute_section(&p, &lv(None), &[]).unwrap().unwrap();
|
||||
assert!(top(&all) > 3.9, "ohne Tiefe ist die ferne Wand sichtbar: {}", top(&all));
|
||||
|
||||
@@ -220,7 +220,7 @@ fn kataster_gewaesser_mit_schraffur_auch_in_tusche() {
|
||||
// Abstand 1.2 mm auf dem Papier bei 1:500: 8 · scale / 90 m = 0.6 m.
|
||||
assert!((8.0 * hatch.scale / 90.0 - 0.6).abs() < 1e-9, "Abstand {}", 8.0 * hatch.scale / 90.0);
|
||||
let mut q = water[0].clone();
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0 }.apply(&mut q);
|
||||
Post { mono: true, lw: 1.0, sketch: 0.0, keep: Default::default() }.apply(&mut q);
|
||||
let Primitive::Polygon { fill, hatch, .. } = &q else { unreachable!() };
|
||||
assert_eq!(fill, "#ffffff");
|
||||
assert_eq!(hatch.pattern, HatchPattern::Diagonal);
|
||||
|
||||
@@ -1247,6 +1247,27 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
|
||||
if let Some(d) = range.restyle_dash(zone) {
|
||||
super::view_range::restyle(out, out_start, d);
|
||||
}
|
||||
// [271] Umbaufilter: Wand und Öffnungen in ihrer Umbau-Farbe; Ersatzstücke neuer (Abbruch-Stück) bzw.
|
||||
// zugemauerter Öffnungen (Ausfachung) — über der geschlossenen Wand, sonst unter dem Öffnungssymbol.
|
||||
if let Some(r) = c.renovation() {
|
||||
crate::renovation::restyle_range(r, out, out_start, Some(&w.id));
|
||||
if zone == Zone::Cut && !cut.covered {
|
||||
for pa in r.patches.iter().filter(|pa| pa.wall_id == w.id) {
|
||||
let Some(o) = p.openings_of_wall(&w.id).find(|o| o.id == pa.opening_id) else { continue };
|
||||
let Some(ring) = crate::renovation::patch_ring(p, w, o) else { continue };
|
||||
let q = crate::renovation::patch_prims(ring, &pa.style, lw * c.a.detail.outline_factor(), &o.id);
|
||||
if pa.closed {
|
||||
out.extend(q);
|
||||
} else {
|
||||
let n = q.len();
|
||||
out.splice(out_start..out_start, q);
|
||||
for s in closed_syms.iter_mut().filter(|s| s.0 >= out_start) {
|
||||
*s = (s.0 + n, s.1 + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [256] Auf schwarzer Sammelfläche (ab 1:100) verschwände das Symbol: der Teil in der Fläche wird hell
|
||||
// (Modelldarstellung `walls.contrastOnSolid`, Basis an). Hinten anfangen, die Bereiche verschieben sich.
|
||||
|
||||
@@ -15,7 +15,7 @@ const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
|
||||
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
|
||||
|
||||
/// Bekannte Felder von `Project` (für die Meldung unbekannter Felder).
|
||||
const KNOWN_KEYS: [&str; 59] = [
|
||||
const KNOWN_KEYS: [&str; 60] = [
|
||||
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
|
||||
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
|
||||
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
|
||||
@@ -26,6 +26,7 @@ const KNOWN_KEYS: [&str; 59] = [
|
||||
"lineCap", "lineJoin", "trees", "uiState",
|
||||
"modelViewOptions", "cameras",
|
||||
"costEstimate",
|
||||
"renovation",
|
||||
];
|
||||
|
||||
/// Ergebnis des Einlesens.
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn run_doc(d: &mut crate::document::Document, name: &str, args: &[f64], text
|
||||
// des Aufrufers (0 = alles), Antwort als Änderung (`model3d_cache::write_delta`).
|
||||
let delta = (name == "model3dPartsDelta").then(|| args.get(5).copied().filter(|m| m.is_finite() && *m >= 0.0).unwrap_or(0.0) as u64);
|
||||
// [173] Mit Modelldarstellung (`text`) ohne den Cache (eigene Teile, s. `model3d_mv`).
|
||||
if (name == "model3dParts" || delta.is_some()) && args.len() >= 3 && !explode && model3d_mv_id(text).is_none() {
|
||||
if (name == "model3dParts" || delta.is_some()) && args.len() >= 3 && !explode && model3d_mv_id(text).is_none() && !text.contains("\"renovation\"") {
|
||||
let voids = args.get(3).is_some_and(|v| *v != 0.0);
|
||||
// [214] Ohne Abzugskörper braucht es die Wände/Decken nicht als Werte (spart das Kopieren): leere `voidMeshes`.
|
||||
if voids && crate::plan::extras::void_prisms(d.project()?).is_empty() {
|
||||
@@ -68,11 +68,29 @@ fn model3d_mv(p: &Project, text: &str, detail: f64) -> (f64, bool) {
|
||||
(base, o.stair.handrail.is_some())
|
||||
}
|
||||
|
||||
/// [271] Projekt im Umbau-Zustand des Texts (`renovation::view_from_text`), sonst unverändert.
|
||||
fn renovation_state<'a>(p: &'a Project, text: &str) -> std::borrow::Cow<'a, Project> {
|
||||
match crate::renovation::view_from_text(p, text) {
|
||||
Some(v) => {
|
||||
let r = v.resolve(p);
|
||||
if r.hidden.is_empty() {
|
||||
std::borrow::Cow::Borrowed(p)
|
||||
} else {
|
||||
std::borrow::Cow::Owned(crate::renovation::without_hidden(p, &r.hidden))
|
||||
}
|
||||
}
|
||||
None => std::borrow::Cow::Borrowed(p),
|
||||
}
|
||||
}
|
||||
|
||||
/// Führt die Abfrage `name` aus. `args`: Zahlen, `text`: ein Text (z. B. eine id).
|
||||
pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String, String> {
|
||||
match (name, args.len()) {
|
||||
("kennzahlen", _) => json(&kennzahlen::compute(p)),
|
||||
("areaTable", _) => json(&flaechen::area_table(p)),
|
||||
// [271] Mit Umbau-Zustand (`text` = Filter-Id, z. B. „bestand“ oder „endzustand“; leer = alles).
|
||||
("kennzahlen", _) => json(&kennzahlen::compute(&renovation_state(p, text))),
|
||||
("areaTable", _) => json(&flaechen::area_table(&renovation_state(p, text))),
|
||||
// [271] Umbaufilter (eingebaute und eigene) für die Oberfläche.
|
||||
("renovationFilters", _) => json(&crate::renovation::filter_list(p)),
|
||||
// [209] Kostenschätzung grob; `costDefaults` mit Text „gf“/„gv“ = Beispielwerte der Methode.
|
||||
("costEstimate", _) => json(&crate::kosten::estimate(p)),
|
||||
("costDefaults", _) => json(&crate::kosten::default_estimate(if text.trim() == "gf" { crate::model::CostMethod::Gf } else { crate::model::CostMethod::Gv })),
|
||||
@@ -153,8 +171,15 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
}
|
||||
return Ok(v.to_string());
|
||||
}
|
||||
// [271] Umbaufilter (`text` = `{"renovation": …, "renovationPhase": …}`): Ausgeblendetes fehlt, Farben je Status.
|
||||
let ren = crate::renovation::view_from_text(p, text).map(|v| v.resolve(p));
|
||||
let filtered = ren.as_ref().filter(|r| !r.hidden.is_empty()).map(|r| crate::renovation::without_hidden(p, &r.hidden));
|
||||
let p = filtered.as_ref().unwrap_or(p);
|
||||
let (detail, rails) = model3d_mv(p, text, args[1]);
|
||||
let mut parts = model3d::parts_filtered(p, args[0] != 0.0, detail, args[2] != 0.0, &filter)?;
|
||||
if let Some(r) = &ren {
|
||||
crate::renovation::color_parts(p, &mut parts, r);
|
||||
}
|
||||
if !rails {
|
||||
parts.stair_railings.clear();
|
||||
}
|
||||
@@ -329,7 +354,7 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
|
||||
let c = domains::Ctx::new(p, &a);
|
||||
let flags = if args[1].is_finite() && args[1] >= 0.0 { args[1] as u32 } else { 0 };
|
||||
// Strichstärken nach Massstab wie im übrigen Plan.
|
||||
let post = Some(crate::plan::extras::Post { mono: flags & 2 != 0, lw: crate::plan::extras::line_weight_factor(p, args[0]), sketch: 0.0 }).filter(crate::plan::extras::Post::active);
|
||||
let post = Some(crate::plan::extras::Post { mono: flags & 2 != 0, lw: crate::plan::extras::line_weight_factor(p, args[0]), sketch: 0.0, keep: Default::default() }).filter(crate::plan::extras::Post::active);
|
||||
buf_with(post, |sink| drawings::underlay_lines(&c, &args[2..], flags & 1 != 0, sink))
|
||||
}
|
||||
// Primitive einer Zeichnung (JSON in `text`, ohne Override-Regeln) beim Massstab `args[0]`.
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
//! [271] Umbau wie Archicads „Renovation“: Status je Bauteil (Bestand, Abbruch, Neu), Etappen und Umbaufilter.
|
||||
//!
|
||||
//! **Ein Ort im Kern** für „ist sichtbar / wie gezeichnet im Filter F“: Grundriss (`plan/domains.rs::Ctx`), Schnitt
|
||||
//! (`plan/section/query.rs`), Ansicht (`plan/elevation`), 3D (`model3d`), Kennzahlen und Exporte fragen [`View`]
|
||||
//! bzw. [`Resolved`] — wie die Klassen-Sichtbarkeit ([180]) und die Regel „Ausblenden“ ([33]).
|
||||
//!
|
||||
//! - **Status** (`Renovation.status`) fehlt ⇒ Bestand (Vorgabe beim Zeichnen, Wunsch Maintainer 17.11.). Eine Öffnung
|
||||
//! ohne eigenen Status folgt ihrer Wand.
|
||||
//! - **Filter** (eingebaut, s. [`BUILTIN`], oder `Project.renovation.filters`): je Status zeigen, ausblenden oder mit
|
||||
//! Umbau-Farbe ([`Style`], SIA 400: Bestand grau, Abbruch gelb gestrichelt, Neu rot; anpassbar in
|
||||
//! `Project.renovation.styles`). Ausgeblendetes ist wie nicht vorhanden: es verdeckt nichts, eine ausgeblendete
|
||||
//! Öffnung schliesst ihre Wand (wie die Regel „Ausblenden“).
|
||||
//! - **Etappen** (`Project.renovation.phases`, Reihenfolge der Liste): Ein Filter „bis Etappe n“ zeigt den Stand
|
||||
//! der Etappe n — Neues früherer Etappen ist dann Bestand, Abbruch früherer Etappen ist weg, Neues späterer
|
||||
//! Etappen fehlt noch, Abbruch späterer Etappen steht noch als Bestand. Ohne Etappe gelten die Status unverändert.
|
||||
//! - **Öffnungen in Bestandswänden** (fachlich wie im Umbauplan üblich): Eine neue Öffnung in einer Bestandswand
|
||||
//! bricht dort Mauerwerk ab — der Wandteil in der Öffnung ist ein Abbruch-Stück ([`Patch`], gelb). Eine Öffnung
|
||||
//! „Abbruch“ wird zugemauert — die Ausfachung ist ein Neu-Stück (rot). Ist die Öffnung ausgeblendet (Bestand:
|
||||
//! die neue Öffnung gibt es noch nicht; Neubau/Endzustand: die alte ist zu), ist die Wand dort geschlossen.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::prim::Primitive;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// Eingebaute Umbaufilter (Ids; Namen übersetzt die Oberfläche).
|
||||
pub const BUILTIN: [&str; 5] = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"];
|
||||
|
||||
/// Strichmuster (Papier-mm) für Abbruch: gestrichelt wie verdeckte Kanten.
|
||||
pub const DEMOLISH_DASH: [f64; 2] = crate::plan::line_pattern::HIDDEN;
|
||||
|
||||
/// Eingebauter Filter nach Id.
|
||||
pub fn builtin(id: &str) -> Option<RenovationFilter> {
|
||||
use RenovationShow::{Hide, Override, Show};
|
||||
let (existing, demolish, new) = match id {
|
||||
// Bestandsplan: alles, was heute steht (auch das, was abgebrochen wird), ohne Farbe.
|
||||
"bestand" => (Show, Show, Hide),
|
||||
// Abbruchplan: Bestand, Abbruch gelb.
|
||||
"abbruch" => (Show, Override, Hide),
|
||||
// Neubauplan: Bestand, Neu rot, Abbruch weg.
|
||||
"neubau" => (Show, Hide, Override),
|
||||
// Umbauplan: alle drei in den Umbau-Farben.
|
||||
"umbauplan" => (Override, Override, Override),
|
||||
// Endzustand: Bestand und Neu ohne Farbe, Abbruch weg.
|
||||
"endzustand" => (Show, Hide, Show),
|
||||
_ => return None,
|
||||
};
|
||||
Some(RenovationFilter { id: id.to_string(), name: id.to_string(), existing, demolish, new, ..Default::default() })
|
||||
}
|
||||
|
||||
/// Filter nach Id (eigene vor eingebauten), sonst nach Name ohne Gross-/Kleinschreibung (CLI `--renovation`).
|
||||
pub fn find_filter(p: &Project, key: &str) -> Option<RenovationFilter> {
|
||||
let key = key.trim();
|
||||
if key.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let own = p.renovation.as_ref().and_then(|r| r.filters.as_deref()).unwrap_or(&[]);
|
||||
if let Some(f) = own.iter().find(|f| f.id == key) {
|
||||
return Some(f.clone());
|
||||
}
|
||||
if let Some(f) = builtin(key) {
|
||||
return Some(f);
|
||||
}
|
||||
let low = key.to_lowercase();
|
||||
if let Some(f) = own.iter().find(|f| f.name.to_lowercase() == low) {
|
||||
return Some(f.clone());
|
||||
}
|
||||
builtin(&low)
|
||||
}
|
||||
|
||||
/// Etappen des Projekts in ihrer Reihenfolge.
|
||||
pub fn phases(p: &Project) -> &[RenovationPhase] {
|
||||
p.renovation.as_ref().and_then(|r| r.phases.as_deref()).unwrap_or(&[])
|
||||
}
|
||||
|
||||
/// Index einer Etappe nach Id oder Name (ohne Gross-/Kleinschreibung); `None` = unbekannt.
|
||||
pub fn phase_index(p: &Project, key: &str) -> Option<usize> {
|
||||
let ph = phases(p);
|
||||
let low = key.trim().to_lowercase();
|
||||
ph.iter().position(|x| x.id == key).or_else(|| ph.iter().position(|x| x.name.to_lowercase() == low))
|
||||
}
|
||||
|
||||
/// Status eines Elements (fehlt/unbekannt ⇒ Bestand).
|
||||
pub fn status_of(r: Option<&Renovation>) -> RenovationStatus {
|
||||
match r.map(|r| r.status) {
|
||||
Some(RenovationStatus::Demolish) => RenovationStatus::Demolish,
|
||||
Some(RenovationStatus::New) => RenovationStatus::New,
|
||||
_ => RenovationStatus::Existing,
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Angaben einer Öffnung: eigene, sonst die ihrer Wand.
|
||||
pub fn opening_renovation<'a>(p: &'a Project, o: &'a Opening) -> Option<&'a Renovation> {
|
||||
o.renovation.as_ref().or_else(|| p.walls.iter().find(|w| w.id == o.host_wall_id).and_then(|w| w.renovation.as_ref()))
|
||||
}
|
||||
|
||||
/// Umbau-Farbe eines Status, aufgelöst (Projekt-Vorgabe über der SIA-Vorgabe).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Style {
|
||||
/// Füllung der Schnittflächen (ohne Muster).
|
||||
pub fill: String,
|
||||
/// Linienfarbe (`None` = Linien wie ohne Filter).
|
||||
pub line: Option<String>,
|
||||
/// Linien gestrichelt ([`DEMOLISH_DASH`]).
|
||||
pub dashed: bool,
|
||||
}
|
||||
|
||||
/// SIA-400-Vorgabe: Bestand grau, Abbruch gelb und gestrichelt, Neu rot.
|
||||
pub fn default_style(s: RenovationStatus) -> Style {
|
||||
match s {
|
||||
RenovationStatus::Demolish => Style { fill: "#ffd800".into(), line: None, dashed: true },
|
||||
RenovationStatus::New => Style { fill: "#e3001b".into(), line: Some("#c00016".into()), dashed: false },
|
||||
_ => Style { fill: "#a6a6a6".into(), line: None, dashed: false },
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Farbe eines Status im Projekt.
|
||||
pub fn style(p: &Project, s: RenovationStatus) -> Style {
|
||||
let mut st = default_style(s);
|
||||
let own = p.renovation.as_ref().and_then(|r| r.styles.as_ref()).and_then(|x| match s {
|
||||
RenovationStatus::Demolish => x.demolish.as_ref(),
|
||||
RenovationStatus::New => x.new.as_ref(),
|
||||
_ => x.existing.as_ref(),
|
||||
});
|
||||
if let Some(o) = own {
|
||||
if let Some(f) = o.fill.as_deref().map(str::trim).filter(|f| !f.is_empty()) {
|
||||
st.fill = f.to_string();
|
||||
}
|
||||
if let Some(l) = o.line.as_deref().map(str::trim) {
|
||||
st.line = (!l.is_empty()).then(|| l.to_string());
|
||||
}
|
||||
if let Some(d) = o.dashed {
|
||||
st.dashed = d;
|
||||
}
|
||||
}
|
||||
st
|
||||
}
|
||||
|
||||
/// Wie ein Element im Filter erscheint.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Treat {
|
||||
Show,
|
||||
Hide,
|
||||
Style(Style),
|
||||
}
|
||||
|
||||
/// Ein aufgelöster Umbaufilter einer Darstellung.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct View {
|
||||
pub filter: RenovationFilter,
|
||||
/// Etappe, bis zu der der Filter gilt (Index), `None` = alle.
|
||||
pub upto: Option<usize>,
|
||||
phases: HashMap<String, usize>,
|
||||
styles: [Style; 3],
|
||||
}
|
||||
|
||||
impl View {
|
||||
/// Filter `filter` (Id oder Name) bis Etappe `phase` (Id oder Name); `None` ohne (gültigen) Filter.
|
||||
pub fn new(p: &Project, filter: Option<&str>, phase: Option<&str>) -> Option<View> {
|
||||
let filter = find_filter(p, filter?)?;
|
||||
let upto = phase.filter(|s| !s.trim().is_empty()).and_then(|s| phase_index(p, s));
|
||||
let phases = phases(p).iter().enumerate().map(|(i, x)| (x.id.clone(), i)).collect();
|
||||
let styles = [style(p, RenovationStatus::Existing), style(p, RenovationStatus::Demolish), style(p, RenovationStatus::New)];
|
||||
Some(View { filter, upto, phases, styles })
|
||||
}
|
||||
|
||||
/// Filter einer Darstellung: ausdrücklich angefragt (CLI, Blatt-Ausschnitt), sonst der der Ebene `level_id`
|
||||
/// (`DrawingLevel.renovationFilter`/`renovationPhase`, wie die Modelldarstellung [173]).
|
||||
pub fn for_level(p: &Project, level_id: &str, filter: Option<&str>, phase: Option<&str>) -> Option<View> {
|
||||
let l = p.floor(level_id);
|
||||
let f = filter.filter(|s| !s.is_empty()).or_else(|| l.and_then(|l| l.renovation_filter.as_deref()));
|
||||
let ph = if filter.is_some_and(|s| !s.is_empty()) { phase } else { phase.or_else(|| l.and_then(|l| l.renovation_phase.as_deref())) };
|
||||
Self::new(p, f, ph)
|
||||
}
|
||||
|
||||
/// Zustand des Elements in der Etappe des Filters; `None` = es steht dort (noch/schon) nicht.
|
||||
pub fn state(&self, r: Option<&Renovation>) -> Option<RenovationStatus> {
|
||||
let s = status_of(r);
|
||||
let Some(l) = self.upto else { return Some(s) };
|
||||
let i = r.and_then(|r| r.phase.as_deref()).and_then(|id| self.phases.get(id).copied()).unwrap_or(0);
|
||||
use std::cmp::Ordering::*;
|
||||
match (s, i.cmp(&l)) {
|
||||
(RenovationStatus::New, Greater) | (RenovationStatus::Demolish, Less) => None,
|
||||
(RenovationStatus::New, Less) | (RenovationStatus::Demolish, Greater) => Some(RenovationStatus::Existing),
|
||||
(s, _) => Some(s),
|
||||
}
|
||||
}
|
||||
|
||||
/// Darstellung eines Zustands im Filter.
|
||||
pub fn treat_state(&self, s: Option<RenovationStatus>) -> Treat {
|
||||
let Some(s) = s else { return Treat::Hide };
|
||||
let (show, k) = match s {
|
||||
RenovationStatus::Demolish => (self.filter.demolish, 1),
|
||||
RenovationStatus::New => (self.filter.new, 2),
|
||||
_ => (self.filter.existing, 0),
|
||||
};
|
||||
match show {
|
||||
RenovationShow::Hide => Treat::Hide,
|
||||
RenovationShow::Override => Treat::Style(self.styles[k].clone()),
|
||||
_ => Treat::Show,
|
||||
}
|
||||
}
|
||||
|
||||
/// Darstellung eines Elements mit diesen Umbau-Angaben.
|
||||
pub fn treat(&self, r: Option<&Renovation>) -> Treat {
|
||||
self.treat_state(self.state(r))
|
||||
}
|
||||
|
||||
/// Ist ein Element mit diesen Angaben im Filter sichtbar?
|
||||
pub fn visible(&self, r: Option<&Renovation>) -> bool {
|
||||
self.treat(r) != Treat::Hide
|
||||
}
|
||||
|
||||
/// Ausgeblendete Elemente, Umbau-Farben und Ersatzstücke der Öffnungen für das ganze Projekt.
|
||||
pub fn resolve(&self, p: &Project) -> Resolved {
|
||||
let mut out = Resolved::default();
|
||||
let mut put = |id: &str, t: Treat, out: &mut Resolved| match t {
|
||||
Treat::Hide => {
|
||||
out.hidden.insert(id.to_string());
|
||||
}
|
||||
Treat::Style(s) => {
|
||||
out.styled.insert(id.to_string(), s);
|
||||
}
|
||||
Treat::Show => {}
|
||||
};
|
||||
let mut wall_state: HashMap<&str, Option<RenovationStatus>> = HashMap::new();
|
||||
for w in &p.walls {
|
||||
let s = self.state(w.renovation.as_ref());
|
||||
wall_state.insert(w.id.as_str(), s);
|
||||
put(&w.id, self.treat_state(s), &mut out);
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
let host = wall_state.get(o.host_wall_id.as_str()).copied().flatten();
|
||||
if out.hidden.contains(&o.host_wall_id) {
|
||||
out.hidden.insert(o.id.clone());
|
||||
continue;
|
||||
}
|
||||
let s = self.state(opening_renovation(p, o));
|
||||
put(&o.id, self.treat_state(s), &mut out);
|
||||
// Ersatzstück nur, wenn die Öffnung einen anderen Zustand hat als ihre (Bestands-)Wand.
|
||||
if o.renovation.is_none() || host != Some(RenovationStatus::Existing) {
|
||||
continue;
|
||||
}
|
||||
let virt = match s {
|
||||
Some(RenovationStatus::New) => RenovationStatus::Demolish,
|
||||
Some(RenovationStatus::Demolish) => RenovationStatus::New,
|
||||
_ => continue,
|
||||
};
|
||||
if let Treat::Style(st) = self.treat_state(Some(virt)) {
|
||||
out.patches.push(Patch { opening_id: o.id.clone(), wall_id: o.host_wall_id.clone(), status: virt, style: st, closed: out.hidden.contains(&o.id) });
|
||||
}
|
||||
}
|
||||
for x in p.ceilings.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.roofs.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.stairs.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.columns.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
for x in p.extruded_solids.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
|
||||
}
|
||||
// Räume: nur sichtbar oder nicht (ein Raum ist kein Bauteil, er bekommt keine Umbau-Farbe).
|
||||
for x in p.rooms.iter().flatten() {
|
||||
if !self.visible(x.renovation.as_ref()) {
|
||||
out.hidden.insert(x.id.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Füll- und Linienfarben der Status, die der Filter farbig zeigt (bleiben in Schwarz-Weiss erhalten).
|
||||
pub fn colors(&self) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
for (show, st) in [(self.filter.existing, &self.styles[0]), (self.filter.demolish, &self.styles[1]), (self.filter.new, &self.styles[2])] {
|
||||
if show == RenovationShow::Override {
|
||||
out.push(st.fill.clone());
|
||||
out.extend(st.line.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Schlüssel für Caches (Filter samt Darstellungen, Etappe, Farben).
|
||||
pub fn key(&self) -> String {
|
||||
format!("{}:{:?}{:?}{:?}:{:?}:{:?}", self.filter.id, self.filter.existing, self.filter.demolish, self.filter.new, self.upto, self.styles)
|
||||
}
|
||||
}
|
||||
|
||||
/// Ersatzstück einer Öffnung in einer Bestandswand: abgebrochenes Mauerwerk (neue Öffnung) bzw. Ausfachung
|
||||
/// (zugemauerte Öffnung), mit der Umbau-Farbe seines Status.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Patch {
|
||||
pub opening_id: String,
|
||||
pub wall_id: String,
|
||||
/// Status des Stücks (Abbruch für eine neue Öffnung, Neu für eine zugemauerte).
|
||||
pub status: RenovationStatus,
|
||||
pub style: Style,
|
||||
/// Die Öffnung ist ausgeblendet (die Wand ist dort geschlossen): das Stück liegt über der Wand.
|
||||
pub closed: bool,
|
||||
}
|
||||
|
||||
/// Ergebnis eines Filters für ein Projekt.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Resolved {
|
||||
/// Ausgeblendete Elemente (ids): Wände nehmen ihre Öffnungen mit.
|
||||
pub hidden: HashSet<String>,
|
||||
/// Elemente mit Umbau-Farbe (id → Farbe).
|
||||
pub styled: HashMap<String, Style>,
|
||||
pub patches: Vec<Patch>,
|
||||
}
|
||||
|
||||
impl Resolved {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.hidden.is_empty() && self.styled.is_empty() && self.patches.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Das Projekt ohne die im Filter ausgeblendeten Elemente (Kennzahlen, 3D, Exporte, Schnitt und Ansicht).
|
||||
pub fn without_hidden(p: &Project, hidden: &HashSet<String>) -> Project {
|
||||
let mut q = crate::plan::section::without_elements(p, hidden);
|
||||
if let Some(v) = &mut q.extruded_solids {
|
||||
v.retain(|x| !hidden.contains(&x.id));
|
||||
}
|
||||
q
|
||||
}
|
||||
|
||||
/// Das Projekt im Zustand eines Filters (`filter`: Id/Name, `phase`: Etappe); ohne gültigen Filter unverändert.
|
||||
pub fn project_in_state<'a>(p: &'a Project, filter: Option<&str>, phase: Option<&str>) -> std::borrow::Cow<'a, Project> {
|
||||
match View::new(p, filter, phase) {
|
||||
Some(v) => {
|
||||
let r = v.resolve(p);
|
||||
if r.hidden.is_empty() {
|
||||
std::borrow::Cow::Borrowed(p)
|
||||
} else {
|
||||
std::borrow::Cow::Owned(without_hidden(p, &r.hidden))
|
||||
}
|
||||
}
|
||||
None => std::borrow::Cow::Borrowed(p),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ist eine Füllung sichtbar (nicht leer/„none“/ganz durchsichtig)? Nur solche Flächen bekommen die Umbau-Farbe.
|
||||
fn solid_fill(fill: &str) -> bool {
|
||||
let f = fill.trim();
|
||||
!(f.is_empty() || f == "none" || f == "transparent" || (f.starts_with('#') && f.len() == 9 && f.ends_with("00")))
|
||||
}
|
||||
|
||||
/// Umbau-Farbe auf ein Primitiv: Schnittflächen in der Füllfarbe ohne Muster, Linien in der Linienfarbe,
|
||||
/// gestrichelt bei Abbruch. Umrisse von Flächen werden dafür als Linien ausgegeben (`extra`), weil Flächen kein
|
||||
/// Strichmuster tragen.
|
||||
pub fn restyle(q: &mut Primitive, st: &Style, extra: &mut Vec<Primitive>) {
|
||||
restyle_with(q, st, extra, true);
|
||||
}
|
||||
|
||||
/// Wie [`restyle`]; `fill = false` lässt die Füllung von Flächen (nur Linien in Farbe und Strichmuster).
|
||||
pub fn restyle_with(q: &mut Primitive, st: &Style, extra: &mut Vec<Primitive>, with_fill: bool) {
|
||||
let dash = || Some(Some(DEMOLISH_DASH.to_vec()));
|
||||
match q {
|
||||
Primitive::Polygon { pts, fill, stroke, stroke_width_mm, hatch, no_stroke_edges, greyed, .. } => {
|
||||
if with_fill && solid_fill(fill) {
|
||||
*fill = st.fill.clone();
|
||||
*hatch = Box::new(crate::plan::style::no_hatch());
|
||||
}
|
||||
if let Some(l) = &st.line {
|
||||
if stroke.trim() != "none" && !stroke.is_empty() {
|
||||
*stroke = l.clone();
|
||||
}
|
||||
}
|
||||
if st.dashed && stroke.trim() != "none" && !stroke.is_empty() && *stroke_width_mm > 0.0 && pts.len() >= 2 {
|
||||
let skip: HashSet<usize> = no_stroke_edges.iter().flatten().filter(|x| x.is_finite() && **x >= 0.0).map(|x| *x as usize).collect();
|
||||
let n = pts.len();
|
||||
for i in 0..n {
|
||||
if skip.contains(&i) {
|
||||
continue;
|
||||
}
|
||||
let (a, b) = (pts[i], pts[(i + 1) % n]);
|
||||
extra.push(Primitive::Line { a, b, cls: "renovation-outline".into(), weight_mm: *stroke_width_mm, dash: dash(), zigzag: None, motif: None, color: Some(stroke.clone().into()), drawing_id: None, opening_id: None, stair_id: None, greyed: *greyed, opacity: None });
|
||||
}
|
||||
*stroke = "none".into();
|
||||
}
|
||||
}
|
||||
Primitive::Line { color, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*color = Some(l.clone().into());
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
Primitive::Arc { color, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*color = Some(l.clone().into());
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
Primitive::DrawingCircle { stroke, dash: d, .. } | Primitive::DrawingArc { stroke, dash: d, .. } => {
|
||||
if let Some(l) = &st.line {
|
||||
*stroke = l.clone();
|
||||
}
|
||||
if st.dashed {
|
||||
*d = dash();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Element-Id eines Primitivs (Öffnung vor Wand und übrigen Bauteilen).
|
||||
pub fn prim_element(q: &Primitive) -> Option<&str> {
|
||||
match q {
|
||||
Primitive::Polygon { opening_id, wall_id, ceiling_id, stair_id, extruded_solid_id, column_id, roof_id, .. } => {
|
||||
opening_id.as_deref().or(wall_id.as_deref()).or(ceiling_id.as_deref()).or(stair_id.as_deref()).or(extruded_solid_id.as_deref()).or(column_id.as_deref()).or(roof_id.as_deref())
|
||||
}
|
||||
Primitive::Line { opening_id, stair_id, .. } | Primitive::Arc { opening_id, stair_id, .. } => opening_id.as_deref().or(stair_id.as_deref()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Farben auf `prims[from..]`: jedes Primitiv nach seinem Element ([`prim_element`]), sonst nach `owner`
|
||||
/// (z. B. die Wand, deren Umrisslinien keine Id tragen). Umrisslinien gestrichelter Flächen kommen dahinter.
|
||||
pub fn restyle_range(r: &Resolved, prims: &mut Vec<Primitive>, from: usize, owner: Option<&str>) {
|
||||
if r.styled.is_empty() || from >= prims.len() {
|
||||
return;
|
||||
}
|
||||
let mut extra = Vec::new();
|
||||
for q in prims[from..].iter_mut() {
|
||||
let id = prim_element(q).or(owner);
|
||||
if let Some(st) = id.and_then(|id| r.styled.get(id)) {
|
||||
// Symbole und Ansichten (Fenster, Türflügel, Treppenstufen, Decken- und Dachkanten): nur Linien.
|
||||
let f = cut_fill(q);
|
||||
restyle_with(q, st, &mut extra, f);
|
||||
}
|
||||
}
|
||||
prims.extend(extra);
|
||||
}
|
||||
|
||||
/// Schnittfläche eines Bauteils (Wand-Poché, geschnittene Stütze), die die Umbau-Füllung bekommt — nicht die Flächen der
|
||||
/// Öffnungssymbole, Treppenstufen, Decken und Dächer (sonst wären Fensterrahmen oder Tritte grau/rot gefüllt).
|
||||
fn cut_fill(q: &Primitive) -> bool {
|
||||
matches!(q, Primitive::Polygon { opening_id: None, wall_id: Some(_), .. } | Primitive::Polygon { opening_id: None, column_id: Some(_), .. })
|
||||
}
|
||||
|
||||
/// Grundriss: Fläche eines Ersatzstücks (Wandband zwischen den Leibungen der Öffnung), `None` bei Bogenwänden
|
||||
/// oder ohne gültige Lage.
|
||||
pub fn patch_ring(p: &Project, w: &Wall, o: &Opening) -> Option<Vec<Vec2>> {
|
||||
if crate::wall_arc::WallArc::of_wall(w).is_some() {
|
||||
return None;
|
||||
}
|
||||
let total = p.wall_thickness(w, 0.2);
|
||||
let ref_off = crate::joins::reference_offset(crate::model3d::wall_reference(w), total);
|
||||
let wr = crate::opening_geom::WallRef { start: crate::opening_geom::v(w.start.x, w.start.y), end: crate::opening_geom::v(w.end.x, w.end.y), total, ref_off };
|
||||
let (from, to) = crate::opening_geom::opening_interval(&wr, o.position, o.width)?;
|
||||
let fp = crate::plan::wall_poche::wall_footprint([w.start.x, w.start.y], [w.end.x, w.end.y], total, ref_off);
|
||||
let at = |s: f64, n: f64| Vec2 { x: fp.a[0] + fp.u[0] * s + fp.m[0] * n, y: fp.a[1] + fp.u[1] * s + fp.m[1] * n };
|
||||
let (n0, n1) = (ref_off - fp.half, ref_off + fp.half);
|
||||
let ring = vec![at(from, n0), at(to, n0), at(to, n1), at(from, n1)];
|
||||
ring.iter().all(|v| v.x.is_finite() && v.y.is_finite()).then_some(ring)
|
||||
}
|
||||
|
||||
/// Grundriss: Ersatzstück als Fläche mit Umriss (gestrichelt bei Abbruch), an der Öffnung (Picken wählt sie).
|
||||
pub fn patch_prims(ring: Vec<Vec2>, st: &Style, weight_mm: f64, opening_id: &str) -> Vec<Primitive> {
|
||||
let stroke = st.line.clone().unwrap_or_else(|| "#000000".into());
|
||||
let mut q = Primitive::Polygon {
|
||||
pts: ring,
|
||||
fill: st.fill.clone(),
|
||||
stroke,
|
||||
stroke_width_mm: weight_mm,
|
||||
hatch: Box::new(crate::plan::style::no_hatch()),
|
||||
greyed: None,
|
||||
opacity: None,
|
||||
no_stroke_edges: None,
|
||||
wall_id: None,
|
||||
drawing_id: None,
|
||||
ceiling_id: None,
|
||||
opening_id: Some(opening_id.to_string()),
|
||||
stair_id: None,
|
||||
room_id: None,
|
||||
extruded_solid_id: None,
|
||||
context_object_id: None,
|
||||
column_id: None,
|
||||
roof_id: None,
|
||||
section_line_id: None,
|
||||
};
|
||||
let mut extra = Vec::new();
|
||||
if st.dashed {
|
||||
restyle(&mut q, &Style { fill: st.fill.clone(), line: None, dashed: true }, &mut extra);
|
||||
}
|
||||
// Linien des Stücks tragen die Öffnung (Picken, Kontrast).
|
||||
for l in extra.iter_mut() {
|
||||
if let Primitive::Line { opening_id: oid, .. } = l {
|
||||
*oid = Some(opening_id.to_string());
|
||||
}
|
||||
}
|
||||
let mut out = vec![q];
|
||||
out.extend(extra);
|
||||
out
|
||||
}
|
||||
|
||||
/// Umbaufilter aus einem JSON-Text (`{"renovation": Id/Name, "renovationPhase": Etappe}`, 3D und Kennzahlen);
|
||||
/// ein Text ohne `{` ist selbst die Filter-Id. `None` ohne Filter.
|
||||
pub fn view_from_text(p: &Project, text: &str) -> Option<View> {
|
||||
let t = text.trim();
|
||||
if t.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if !t.starts_with('{') {
|
||||
return View::new(p, Some(t), None);
|
||||
}
|
||||
let v: serde_json::Value = serde_json::from_str(t).ok()?;
|
||||
let f = v.get("renovation").and_then(|x| x.as_str())?;
|
||||
View::new(p, Some(f), v.get("renovationPhase").and_then(|x| x.as_str()))
|
||||
}
|
||||
|
||||
/// 3D: Teile in der Umbau-Farbe (Füllfarbe des Status) — Wände, Decken, Dächer, Stützen, Treppen, Körper.
|
||||
pub fn color_parts(p: &Project, parts: &mut crate::model3d::Parts, r: &Resolved) {
|
||||
if r.styled.is_empty() {
|
||||
return;
|
||||
}
|
||||
let rgb = |id: &str| r.styled.get(id).map(|s| crate::style::hex_to_rgb(&s.fill, crate::style::WALL_RGB));
|
||||
for w in &mut parts.walls {
|
||||
if let Some(c) = rgb(&w.wall_id) {
|
||||
w.color = c;
|
||||
w.material_index = None;
|
||||
}
|
||||
}
|
||||
for s in &mut parts.slabs {
|
||||
if let Some(c) = rgb(&s.ceiling_id) {
|
||||
s.color = c;
|
||||
}
|
||||
}
|
||||
let meshes = [&mut parts.column_meshes, &mut parts.stair_meshes, &mut parts.roof_meshes, &mut parts.solid_meshes, &mut parts.stair_railings];
|
||||
for list in meshes {
|
||||
for m in list.iter_mut() {
|
||||
if let Some(c) = m.owner.id(p).and_then(rgb) {
|
||||
m.color = c;
|
||||
m.vertex_colors = None;
|
||||
m.material_index = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
for l in &mut parts.roof_layers {
|
||||
if let Some(c) = l.owner.id(p).and_then(rgb) {
|
||||
l.color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Liste der Filter für die Oberfläche (Abfrage `renovationFilters`): eingebaute, dann eigene.
|
||||
pub fn filter_list(p: &Project) -> Vec<serde_json::Value> {
|
||||
let mut out: Vec<serde_json::Value> = BUILTIN.iter().map(|id| serde_json::json!({"id": id, "name": id, "builtin": true})).collect();
|
||||
for f in p.renovation.as_ref().and_then(|r| r.filters.as_deref()).unwrap_or(&[]) {
|
||||
out.push(serde_json::json!({"id": f.id, "name": f.name, "builtin": false}));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Statuswort für Exporte (DXF-Layer-Endung, IFC `Pset_*Common.Status`).
|
||||
pub fn ifc_status(s: RenovationStatus) -> &'static str {
|
||||
match s {
|
||||
RenovationStatus::Demolish => "DEMOLISH",
|
||||
RenovationStatus::New => "NEW",
|
||||
_ => "EXISTING",
|
||||
}
|
||||
}
|
||||
|
||||
/// Umbau-Angaben eines Bauteils nach Id (Wand, Öffnung mit Wand-Rückfall, Decke, Dach, Treppe, Stütze, Körper, Raum).
|
||||
pub fn renovation_of<'a>(p: &'a Project, id: &str) -> Option<&'a Renovation> {
|
||||
if let Some(w) = p.walls.iter().find(|w| w.id == id) {
|
||||
return w.renovation.as_ref();
|
||||
}
|
||||
if let Some(o) = p.openings.iter().flatten().find(|o| o.id == id) {
|
||||
return opening_renovation(p, o);
|
||||
}
|
||||
macro_rules! look {
|
||||
($($f:ident),*) => {$(
|
||||
if let Some(x) = p.$f.iter().flatten().find(|x| x.id == id) {
|
||||
return x.renovation.as_ref();
|
||||
}
|
||||
)*};
|
||||
}
|
||||
look!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "renovation_tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,491 @@
|
||||
//! [271] Tests des Umbaufilters: Vorgaben, Etappen, Öffnungen in Bestandswänden, Robustheit.
|
||||
|
||||
use super::*;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// Musterhaus (Fixture) mit Umbau-Angaben: W2 Abbruch, W9 Neu (Etappe 2), O1 neue Öffnung in Bestandswand W1,
|
||||
/// O2 zugemauert (Abbruch) in W3, Decke C1 Bestand; Etappen e1, e2.
|
||||
pub(crate) fn umbau_fixture() -> Value {
|
||||
let mut v: Value = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
let set = |v: &mut Value, coll: &str, id: &str, r: Value| {
|
||||
for x in v[coll].as_array_mut().unwrap() {
|
||||
if x["id"] == id {
|
||||
x["renovation"] = r.clone();
|
||||
}
|
||||
}
|
||||
};
|
||||
set(&mut v, "walls", "W2", json!({"status": "demolish"}));
|
||||
set(&mut v, "walls", "W9", json!({"status": "new", "phase": "e2"}));
|
||||
set(&mut v, "openings", "O1", json!({"status": "new"}));
|
||||
set(&mut v, "openings", "O2", json!({"status": "demolish"}));
|
||||
v["renovation"] = json!({"phases": [{"id": "e1", "name": "Etappe 1"}, {"id": "e2", "name": "Etappe 2"}]});
|
||||
v
|
||||
}
|
||||
|
||||
pub(crate) fn project(v: &Value) -> Project {
|
||||
serde_json::from_value(v.clone()).unwrap()
|
||||
}
|
||||
|
||||
fn st(s: &str) -> Option<Renovation> {
|
||||
Some(Renovation { status: serde_json::from_value(json!(s)).unwrap(), ..Default::default() })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vorgaben_je_status() {
|
||||
let p = project(&umbau_fixture());
|
||||
let t = |f: &str, s: &str| View::new(&p, Some(f), None).unwrap().treat(st(s).as_ref());
|
||||
let ex = |s| Treat::Style(default_style(s));
|
||||
// Bestand: alles, was heute steht.
|
||||
assert_eq!(t("bestand", "existing"), Treat::Show);
|
||||
assert_eq!(t("bestand", "demolish"), Treat::Show);
|
||||
assert_eq!(t("bestand", "new"), Treat::Hide);
|
||||
// Abbruch: Abbruch gelb, Neues fehlt.
|
||||
assert_eq!(t("abbruch", "demolish"), ex(RenovationStatus::Demolish));
|
||||
assert_eq!(t("abbruch", "new"), Treat::Hide);
|
||||
// Neubau: Neu rot, Abbruch weg.
|
||||
assert_eq!(t("neubau", "new"), ex(RenovationStatus::New));
|
||||
assert_eq!(t("neubau", "demolish"), Treat::Hide);
|
||||
assert_eq!(t("neubau", "existing"), Treat::Show);
|
||||
// Umbauplan: alle drei farbig.
|
||||
assert_eq!(t("umbauplan", "existing"), ex(RenovationStatus::Existing));
|
||||
assert_eq!(t("umbauplan", "demolish"), ex(RenovationStatus::Demolish));
|
||||
assert_eq!(t("umbauplan", "new"), ex(RenovationStatus::New));
|
||||
// Endzustand: ohne Farbe, Abbruch weg.
|
||||
assert_eq!(t("endzustand", "new"), Treat::Show);
|
||||
assert_eq!(t("endzustand", "demolish"), Treat::Hide);
|
||||
// Fehlender Status = Bestand.
|
||||
assert_eq!(View::new(&p, Some("umbauplan"), None).unwrap().treat(None), ex(RenovationStatus::Existing));
|
||||
// SIA: Abbruch gelb gestrichelt, Neu rot.
|
||||
assert!(default_style(RenovationStatus::Demolish).dashed);
|
||||
assert!(default_style(RenovationStatus::New).fill.starts_with("#e3"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kein_filter_ohne_gueltige_id() {
|
||||
let p = project(&umbau_fixture());
|
||||
assert!(View::new(&p, None, None).is_none());
|
||||
assert!(View::new(&p, Some(""), None).is_none());
|
||||
assert!(View::new(&p, Some("gibts-nicht"), None).is_none());
|
||||
// Name ohne Gross-/Kleinschreibung (CLI).
|
||||
assert_eq!(View::new(&p, Some("Umbauplan"), None).unwrap().filter.id, "umbauplan");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eigene_farben_und_filter() {
|
||||
let mut v = umbau_fixture();
|
||||
v["renovation"]["styles"] = json!({"new": {"fill": "#00ff00", "line": ""}, "demolish": {"dashed": false}});
|
||||
v["renovation"]["filters"] = json!([{"id": "f1", "name": "Nur Neu", "existing": "hide", "demolish": "hide", "new": "override"}]);
|
||||
let p = project(&v);
|
||||
let s = style(&p, RenovationStatus::New);
|
||||
assert_eq!(s.fill, "#00ff00");
|
||||
assert_eq!(s.line, None);
|
||||
assert!(!style(&p, RenovationStatus::Demolish).dashed);
|
||||
let f = View::new(&p, Some("Nur Neu"), None).unwrap();
|
||||
assert_eq!(f.treat(None), Treat::Hide);
|
||||
assert_eq!(f.treat(st("new").as_ref()), Treat::Style(s));
|
||||
assert_eq!(filter_list(&p).len(), 6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn etappen() {
|
||||
let p = project(&umbau_fixture());
|
||||
let e = |s: &str, ph: Option<&str>| Some(Renovation { status: serde_json::from_value(json!(s)).unwrap(), phase: ph.map(String::from), ..Default::default() });
|
||||
let v1 = View::new(&p, Some("umbauplan"), Some("e1")).unwrap();
|
||||
let v2 = View::new(&p, Some("umbauplan"), Some("Etappe 2")).unwrap();
|
||||
assert_eq!(v2.upto, Some(1));
|
||||
// Neu in Etappe 2: in Etappe 1 noch nicht da, in Etappe 2 neu.
|
||||
assert_eq!(v1.state(e("new", Some("e2")).as_ref()), None);
|
||||
assert_eq!(v2.state(e("new", Some("e2")).as_ref()), Some(RenovationStatus::New));
|
||||
// Neu in Etappe 1 (auch ohne Etappe = erste): in Etappe 2 Bestand.
|
||||
assert_eq!(v2.state(e("new", None).as_ref()), Some(RenovationStatus::Existing));
|
||||
// Abbruch in Etappe 2: in Etappe 1 noch Bestand; Abbruch in Etappe 1: in Etappe 2 schon weg.
|
||||
assert_eq!(v1.state(e("demolish", Some("e2")).as_ref()), Some(RenovationStatus::Existing));
|
||||
assert_eq!(v2.state(e("demolish", Some("e1")).as_ref()), None);
|
||||
assert_eq!(v2.treat(e("demolish", Some("e1")).as_ref()), Treat::Hide);
|
||||
// Ohne Etappe im Filter: Status unverändert.
|
||||
let all = View::new(&p, Some("umbauplan"), None).unwrap();
|
||||
assert_eq!(all.state(e("new", Some("e2")).as_ref()), Some(RenovationStatus::New));
|
||||
// Unbekannte Etappe im Filter = alle; unbekannte Etappe am Element = erste.
|
||||
assert_eq!(View::new(&p, Some("umbauplan"), Some("x")).unwrap().upto, None);
|
||||
assert_eq!(v2.state(e("new", Some("x")).as_ref()), Some(RenovationStatus::Existing));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aufloesen_mit_oeffnungen_in_bestandswand() {
|
||||
let p = project(&umbau_fixture());
|
||||
// Bestand: neue Wand W9 und neue Öffnung O1 fehlen (O1 schliesst die Wand), kein Ersatzstück.
|
||||
let r = View::new(&p, Some("bestand"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W9") && r.hidden.contains("O1") && !r.hidden.contains("W2") && !r.hidden.contains("O2"));
|
||||
assert!(r.styled.is_empty() && r.patches.is_empty());
|
||||
// Abbruch: W2 und O2 gelb; O1 fehlt, an ihrer Stelle das gelbe Abbruch-Stück über der geschlossenen Wand.
|
||||
let r = View::new(&p, Some("abbruch"), None).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("W2") && r.styled.contains_key("O2"));
|
||||
assert_eq!(r.patches.len(), 1);
|
||||
assert_eq!((r.patches[0].opening_id.as_str(), r.patches[0].status, r.patches[0].closed), ("O1", RenovationStatus::Demolish, true));
|
||||
// Neubau: W2 weg, O2 zugemauert (ausgeblendet, rote Ausfachung), O1 rot, ohne Abbruch-Stück.
|
||||
let r = View::new(&p, Some("neubau"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W2") && r.hidden.contains("O2") && !r.hidden.contains("O1"));
|
||||
assert!(r.styled.contains_key("O1") && r.styled.contains_key("W9") && !r.styled.contains_key("W1"));
|
||||
assert_eq!(r.patches.iter().map(|x| (x.opening_id.as_str(), x.status, x.closed)).collect::<Vec<_>>(), vec![("O2", RenovationStatus::New, true)]);
|
||||
// Umbauplan: beide Ersatzstücke in der offenen Öffnung, Bestand grau.
|
||||
let r = View::new(&p, Some("umbauplan"), None).unwrap().resolve(&p);
|
||||
assert_eq!(r.patches.len(), 2);
|
||||
assert!(r.patches.iter().all(|x| !x.closed));
|
||||
assert_eq!(r.styled["W1"], default_style(RenovationStatus::Existing));
|
||||
// Die Tür D1 ohne eigenen Status folgt ihrer Bestandswand.
|
||||
assert_eq!(r.styled["D1"], default_style(RenovationStatus::Existing));
|
||||
// Endzustand: wie Neubau ohne Farbe.
|
||||
let r = View::new(&p, Some("endzustand"), None).unwrap().resolve(&p);
|
||||
assert!(r.hidden.contains("W2") && r.hidden.contains("O2") && r.styled.is_empty() && r.patches.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oeffnung_folgt_abgebrochener_wand() {
|
||||
let mut v = umbau_fixture();
|
||||
for w in v["walls"].as_array_mut().unwrap() {
|
||||
if w["id"] == "W1" {
|
||||
w["renovation"] = json!({"status": "demolish"});
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
let r = View::new(&p, Some("neubau"), None).unwrap().resolve(&p);
|
||||
// Ausgeblendete Wand nimmt ihre Öffnungen mit, auch die „neue“ O1.
|
||||
assert!(r.hidden.contains("W1") && r.hidden.contains("D1") && r.hidden.contains("O1"));
|
||||
let r = View::new(&p, Some("abbruch"), None).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("D1"));
|
||||
// Kein Ersatzstück in einer Abbruch-Wand.
|
||||
assert!(r.patches.iter().all(|x| x.wall_id != "W1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn robust_bei_unbekannten_werten() {
|
||||
let mut v = umbau_fixture();
|
||||
for w in v["walls"].as_array_mut().unwrap() {
|
||||
if w["id"] == "W3" {
|
||||
w["renovation"] = json!({"status": "abgerissen", "phase": "nirgends"});
|
||||
}
|
||||
if w["id"] == "W4" {
|
||||
w["renovation"] = json!({});
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
assert_eq!(status_of(p.walls.iter().find(|w| w.id == "W3").unwrap().renovation.as_ref()), RenovationStatus::Existing);
|
||||
assert_eq!(status_of(p.walls.iter().find(|w| w.id == "W4").unwrap().renovation.as_ref()), RenovationStatus::Existing);
|
||||
let r = View::new(&p, Some("umbauplan"), Some("e2")).unwrap().resolve(&p);
|
||||
assert!(r.styled.contains_key("W3") && r.styled.contains_key("W4"));
|
||||
// Rundreise: unbekannter Status bleibt nicht als Text erhalten, das Feld aber lädt.
|
||||
assert!(serde_json::to_value(&p).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn projekt_im_zustand() {
|
||||
let p = project(&umbau_fixture());
|
||||
let b = project_in_state(&p, Some("bestand"), None);
|
||||
assert!(b.walls.iter().all(|w| w.id != "W9"));
|
||||
assert!(b.openings.iter().flatten().all(|o| o.id != "O1"));
|
||||
let e = project_in_state(&p, Some("endzustand"), None);
|
||||
assert!(e.walls.iter().all(|w| w.id != "W2"));
|
||||
assert!(e.walls.iter().any(|w| w.id == "W9"));
|
||||
// Ohne Filter unverändert (geliehen).
|
||||
assert!(matches!(project_in_state(&p, None, None), std::borrow::Cow::Borrowed(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restyle_flaechen_und_linien() {
|
||||
let ring = vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: 1.0, y: 0.0 }, Vec2 { x: 1.0, y: 0.2 }, Vec2 { x: 0.0, y: 0.2 }];
|
||||
let q = patch_prims(ring, &default_style(RenovationStatus::Demolish), 0.25, "O1");
|
||||
// Fläche gelb ohne Strich, vier gestrichelte Umrisslinien an der Öffnung.
|
||||
assert_eq!(q.len(), 5);
|
||||
match &q[0] {
|
||||
Primitive::Polygon { fill, stroke, opening_id, .. } => {
|
||||
assert_eq!(fill, "#ffd800");
|
||||
assert_eq!(stroke, "none");
|
||||
assert_eq!(opening_id.as_deref(), Some("O1"));
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
assert!(q[1..].iter().all(|l| matches!(l, Primitive::Line { dash: Some(Some(_)), opening_id: Some(_), .. })));
|
||||
// Leere Füllung bleibt leer.
|
||||
let mut poly = q[0].clone();
|
||||
if let Primitive::Polygon { fill, .. } = &mut poly {
|
||||
*fill = "none".into();
|
||||
}
|
||||
let mut extra = Vec::new();
|
||||
restyle(&mut poly, &default_style(RenovationStatus::New), &mut extra);
|
||||
assert!(matches!(&poly, Primitive::Polygon { fill, .. } if fill == "none"));
|
||||
}
|
||||
|
||||
// ── Ableitungen ───────────────────────────────────────────────────────────
|
||||
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
|
||||
fn plan_with(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let codes: Vec<String> = (0..100).map(|k| format!("{k:02}")).collect();
|
||||
let mut t = json!({"floor": "eg", "show": codes, "scale": 100});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
t[k] = x.clone();
|
||||
}
|
||||
let d = plan_domains(p, &PlanArgs::parse_in(p, 1.0, &t.to_string()).unwrap()).unwrap();
|
||||
[d.walls, d.ceilings, d.roofs, d.stairs, d.columns, d.solids].concat()
|
||||
}
|
||||
|
||||
fn has_wall(prims: &[Primitive], id: &str) -> bool {
|
||||
prims.iter().any(|q| matches!(q, Primitive::Polygon { wall_id: Some(w), .. } if w == id))
|
||||
}
|
||||
|
||||
fn has_opening(prims: &[Primitive], id: &str) -> bool {
|
||||
prims.iter().any(|q| match q {
|
||||
Primitive::Polygon { opening_id: Some(o), .. } | Primitive::Line { opening_id: Some(o), .. } | Primitive::Arc { opening_id: Some(o), .. } => o == id,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
fn fills_of(prims: &[Primitive], id: &str) -> Vec<String> {
|
||||
prims
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, wall_id, opening_id, .. } if opening_id.as_deref().or(wall_id.as_deref()) == Some(id) => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let red = default_style(RenovationStatus::New).fill;
|
||||
let yellow = default_style(RenovationStatus::Demolish).fill;
|
||||
// Ohne Filter: alles wie bisher, keine Umbau-Farbe.
|
||||
let all = plan_with(&p, json!({}));
|
||||
assert!(has_wall(&all, "W2") && has_wall(&all, "W9") && has_opening(&all, "O1"));
|
||||
assert!(fills_of(&all, "W9").iter().all(|f| *f != red));
|
||||
// Bestand: neue Wand und neue Öffnung fehlen.
|
||||
let b = plan_with(&p, json!({"renovation": "bestand"}));
|
||||
assert!(has_wall(&b, "W2") && !has_wall(&b, "W9") && !has_opening(&b, "O1") && has_opening(&b, "O2"));
|
||||
// Abbruch: W2 gelb mit gestrichelten Umrissen; O1 als gelbes Abbruch-Stück in der geschlossenen Wand.
|
||||
let a = plan_with(&p, json!({"renovation": "abbruch"}));
|
||||
assert!(fills_of(&a, "W2").iter().any(|f| *f == yellow), "{:?}", fills_of(&a, "W2"));
|
||||
assert_eq!(fills_of(&a, "O1"), vec![yellow.clone()]);
|
||||
assert!(a.iter().any(|q| matches!(q, Primitive::Line { dash: Some(Some(_)), opening_id: Some(o), .. } if o == "O1")));
|
||||
// Neubau: W2 weg, W9 rot, O2 zugemauert mit roter Ausfachung, Fenster O1 in roten Linien.
|
||||
let n = plan_with(&p, json!({"renovation": "neubau"}));
|
||||
assert!(!has_wall(&n, "W2"));
|
||||
assert!(fills_of(&n, "W9").iter().any(|f| *f == red), "{:?}", fills_of(&n, "W9"));
|
||||
assert_eq!(fills_of(&n, "O2"), vec![red.clone()]);
|
||||
let line = default_style(RenovationStatus::New).line.unwrap();
|
||||
assert!(n.iter().any(|q| matches!(q, Primitive::Line { opening_id: Some(o), color: Some(c), .. } if o == "O1" && **c == *line)));
|
||||
// Umbauplan: beide Ersatzstücke, Bestand grau.
|
||||
let u = plan_with(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(fills_of(&u, "W1").iter().any(|f| *f == default_style(RenovationStatus::Existing).fill));
|
||||
assert!(fills_of(&u, "O1").contains(&yellow) && fills_of(&u, "O2").contains(&red));
|
||||
// Endzustand: ohne Farbe, W2 und O2 weg.
|
||||
let e = plan_with(&p, json!({"renovation": "endzustand"}));
|
||||
assert!(!has_wall(&e, "W2") && !has_opening(&e, "O2") && has_wall(&e, "W9"));
|
||||
assert!(fills_of(&e, "W9").iter().all(|f| *f != red));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_filter_der_ebene_und_etappe() {
|
||||
let mut v = umbau_fixture();
|
||||
for l in v["drawingLevels"].as_array_mut().unwrap() {
|
||||
if l["id"] == "eg" {
|
||||
l["renovationFilter"] = json!("neubau");
|
||||
l["renovationPhase"] = json!("e1");
|
||||
}
|
||||
}
|
||||
let p = project(&v);
|
||||
// Filter der Ebene wirkt ohne Argument; W9 (Neu in Etappe 2) fehlt in Etappe 1 noch.
|
||||
let q = plan_with(&p, json!({}));
|
||||
assert!(!has_wall(&q, "W2") && !has_wall(&q, "W9"));
|
||||
// Angefragter Filter geht vor (ohne Etappe: alle).
|
||||
let q = plan_with(&p, json!({"renovation": "bestand"}));
|
||||
assert!(has_wall(&q, "W2") && !has_wall(&q, "W9"));
|
||||
let q = plan_with(&p, json!({"renovation": "neubau", "renovationPhase": "e2"}));
|
||||
assert!(has_wall(&q, "W9"));
|
||||
}
|
||||
|
||||
fn section_prims(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let level = p.drawing_levels.iter().find(|l| l.id == "schnitt-a").unwrap();
|
||||
let mut v = json!({"level": level, "scale": 50, "detail": "mittel"});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
let buf = crate::queries::run_bin(p, "sectionPlan", &[0.0, 1.0, 0.0], &v.to_string()).unwrap();
|
||||
crate::plan::buf::View::parse(&buf).and_then(|v| v.prims()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn cut_fills(prims: &[Primitive], id: &str) -> Vec<String> {
|
||||
prims
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, wall_id: Some(w), .. } if w == id => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schnitt_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let all = section_prims(&p, json!({}));
|
||||
assert!(!cut_fills(&all, "W2").is_empty() && !cut_fills(&all, "W9").is_empty());
|
||||
let u = section_prims(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(!cut_fills(&u, "W2").is_empty());
|
||||
assert!(cut_fills(&u, "W2").iter().all(|f| *f == default_style(RenovationStatus::Demolish).fill), "{:?}", cut_fills(&u, "W2"));
|
||||
assert!(cut_fills(&u, "W9").iter().all(|f| *f == default_style(RenovationStatus::New).fill));
|
||||
assert!(cut_fills(&u, "W4").iter().all(|f| *f == default_style(RenovationStatus::Existing).fill));
|
||||
let n = section_prims(&p, json!({"renovation": "neubau"}));
|
||||
assert!(cut_fills(&n, "W2").is_empty() && !cut_fills(&n, "W9").is_empty());
|
||||
// Filter der Ebene.
|
||||
let mut v = umbau_fixture();
|
||||
for l in v["drawingLevels"].as_array_mut().unwrap() {
|
||||
if l["id"] == "schnitt-a" {
|
||||
l["renovationFilter"] = json!("bestand");
|
||||
}
|
||||
}
|
||||
let q = project(&v);
|
||||
let b = section_prims(&q, json!({}));
|
||||
assert!(cut_fills(&b, "W9").is_empty() && !cut_fills(&b, "W2").is_empty());
|
||||
}
|
||||
|
||||
fn elevation_prims(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let level = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
|
||||
let mut v = json!({"level": level});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
let buf = crate::queries::run_bin(p, "elevationPlan", &[0.0, 0.0, 100.0], &v.to_string()).unwrap();
|
||||
crate::plan::buf::View::parse(&buf).and_then(|v| v.prims()).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ansicht_je_filter() {
|
||||
let p = project(&umbau_fixture());
|
||||
let grey = default_style(RenovationStatus::Existing).fill;
|
||||
let all = elevation_prims(&p, json!({}));
|
||||
assert!(!all.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if *fill == grey)));
|
||||
let u = elevation_prims(&p, json!({"renovation": "umbauplan"}));
|
||||
assert!(u.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if *fill == grey)), "Bestandswand W1 grau");
|
||||
// Bestand: die neue Öffnung O1 fehlt (Wand geschlossen) — weniger Linien als im Endzustand.
|
||||
let b = elevation_prims(&p, json!({"renovation": "bestand"}));
|
||||
let e = elevation_prims(&p, json!({"renovation": "endzustand"}));
|
||||
let lines = |v: &[Primitive]| v.iter().filter(|q| matches!(q, Primitive::Line { .. })).count();
|
||||
assert!(lines(&b) < lines(&e), "bestand {} endzustand {}", lines(&b), lines(&e));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kennzahlen_bestand_und_endzustand() {
|
||||
let mut v = umbau_fixture();
|
||||
// Ein neuer Raum (Anbau) zählt nur im Endzustand.
|
||||
let mut neu = v["rooms"][0].clone();
|
||||
neu["id"] = json!("R-neu");
|
||||
neu["name"] = json!("Anbau");
|
||||
neu["renovation"] = json!({"status": "new"});
|
||||
v["rooms"].as_array_mut().unwrap().push(neu);
|
||||
let p = project(&v);
|
||||
let b = crate::queries::run(&p, "kennzahlen", &[], "bestand").unwrap();
|
||||
let e = crate::queries::run(&p, "kennzahlen", &[], "endzustand").unwrap();
|
||||
assert_ne!(b, e);
|
||||
// Flächentabelle: Text als JSON oder als Filter-Id gleichwertig; der neue Raum fehlt im Bestand.
|
||||
let tb = crate::queries::run(&p, "areaTable", &[], "{\"renovation\": \"bestand\"}").unwrap();
|
||||
assert_eq!(tb, crate::queries::run(&p, "areaTable", &[], "bestand").unwrap());
|
||||
assert_ne!(tb, crate::queries::run(&p, "areaTable", &[], "endzustand").unwrap());
|
||||
assert!(crate::queries::run(&p, "renovationFilters", &[], "").unwrap().contains("umbauplan"));
|
||||
}
|
||||
|
||||
fn dxf_strings(p: &Project) -> Vec<String> {
|
||||
let a = PlanArgs::parse(1.0, r#"{"floor":"eg","show":["20","21","22","23","30","31","40"],"scale":100}"#).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, 10.0, 4.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_je_status() {
|
||||
let s = dxf_strings(&project(&umbau_fixture()));
|
||||
assert!(s.iter().any(|s| s.ends_with("_Abbruch")), "{:?}", s.iter().take(30).collect::<Vec<_>>());
|
||||
assert!(s.iter().any(|s| s.ends_with("_Neu")));
|
||||
// Ohne Umbau-Angaben keine Status-Ebenen.
|
||||
let q: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
assert!(!dxf_strings(&q).iter().any(|s| s.ends_with("_Abbruch") || s.ends_with("_Neu")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifc_status_und_etappe() {
|
||||
let p = project(&umbau_fixture());
|
||||
let f = crate::ifc_data::ifc_export_data(&p, &crate::ifc_data::IfcOptions::default()).unwrap();
|
||||
let (_, text) = crate::export_flat::from_bytes(&f.to_bytes()).unwrap();
|
||||
let s: Vec<&str> = text.split('\0').collect();
|
||||
for want in ["Status", "DEMOLISH", "NEW", "Dossier_Umbau", "Etappe 2"] {
|
||||
assert!(s.contains(&want), "fehlt: {want}");
|
||||
}
|
||||
let q: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
let f = crate::ifc_data::ifc_export_data(&q, &crate::ifc_data::IfcOptions::default()).unwrap();
|
||||
let (_, text) = crate::export_flat::from_bytes(&f.to_bytes()).unwrap();
|
||||
assert!(!text.split('\0').any(|x| x == "DEMOLISH" || x == "Dossier_Umbau"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drei_d_ausblenden_und_farbe() {
|
||||
let p = project(&umbau_fixture());
|
||||
let parts = |t: &str| -> Value { serde_json::from_str(&crate::queries::run(&p, "model3dParts", &[1.0, 1.0, 0.0], t).unwrap()).unwrap() };
|
||||
let all = parts("");
|
||||
let n = parts(r#"{"renovation":"neubau"}"#);
|
||||
let ids = |v: &Value| v["walls"].as_array().unwrap().iter().map(|w| w["wallId"].as_str().unwrap().to_string()).collect::<Vec<_>>();
|
||||
assert!(ids(&all).contains(&"W2".to_string()) && !ids(&n).contains(&"W2".to_string()));
|
||||
let w9 = n["walls"].as_array().unwrap().iter().find(|w| w["wallId"] == "W9").unwrap();
|
||||
let c = crate::style::hex_to_rgb(&default_style(RenovationStatus::New).fill, [0.0; 3]);
|
||||
assert!((w9["color"][0].as_f64().unwrap() - c[0]).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neue_bauteile_tragen_den_zeichen_status() {
|
||||
use crate::ops::Op;
|
||||
let add = |c: &str| Op::Add { collection: c.into(), items: vec![json!({"id": "x"}), json!({"id": "y", "renovation": {"status": "existing"}})], at: None };
|
||||
let out = crate::commands::stamp_renovation(vec![add("walls"), add("drawings2d")], Some(&json!({"status": "new", "phase": "e2"})));
|
||||
match &out[0] {
|
||||
Op::Add { items, .. } => {
|
||||
assert_eq!(items[0]["renovation"], json!({"status": "new", "phase": "e2"}));
|
||||
// Eigene Angabe bleibt.
|
||||
assert_eq!(items[1]["renovation"]["status"], "existing");
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
// 2D-Zeichnungen bekommen keinen Status.
|
||||
assert!(matches!(&out[1], Op::Add { items, .. } if items[0].get("renovation").is_none()));
|
||||
// Bestand ohne Etappe = ohne Feld; Unsinn wird ignoriert.
|
||||
for r in [json!({"status": "existing"}), json!({"status": "kaputt"}), json!(42), json!(null)] {
|
||||
let o = crate::commands::stamp_renovation(vec![add("walls")], Some(&r));
|
||||
assert!(matches!(&o[0], Op::Add { items, .. } if items[0].get("renovation").is_none()), "{}", r);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tusche_behaelt_umbau_farben_und_symbole_ohne_fuellung() {
|
||||
let p = project(&umbau_fixture());
|
||||
let codes: Vec<String> = (0..100).map(|k| format!("{k:02}")).collect();
|
||||
let buf = |ren: &str| {
|
||||
let t = json!({"floor": "eg", "show": codes, "scale": 100, "mono": true, "renovation": ren}).to_string();
|
||||
let b = crate::plan::domains::plan_domains_buf(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
crate::plan::buf::View::parse(&b).and_then(|v| v.prims()).unwrap_or_default()
|
||||
};
|
||||
let fills = |v: &[Primitive]| v.iter().filter_map(|q| if let Primitive::Polygon { fill, .. } = q { Some(fill.clone()) } else { None }).collect::<Vec<_>>();
|
||||
// Schwarz-Weiss (Tusche): Rot und Gelb bleiben, sonst wäre der Umbauplan stumm.
|
||||
let u = fills(&buf("umbauplan"));
|
||||
assert!(u.contains(&default_style(RenovationStatus::New).fill) && u.contains(&default_style(RenovationStatus::Demolish).fill));
|
||||
// Ohne Filter keine Umbau-Farbe (und Bunt wird wie bisher Papier).
|
||||
assert!(!fills(&buf("")).contains(&default_style(RenovationStatus::New).fill));
|
||||
// Flächen der Öffnungssymbole (Rahmen, Glas, Flügel) bleiben ohne Umbau-Füllung — nur die Ersatzstücke sind farbig.
|
||||
let n = plan_with(&p, json!({"renovation": "umbauplan"}));
|
||||
let o1: Vec<String> = n
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { fill, opening_id: Some(o), .. } if o == "D1" => Some(fill.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(o1.iter().all(|f| *f != default_style(RenovationStatus::Existing).fill), "{o1:?}");
|
||||
}
|
||||
@@ -102,7 +102,7 @@ pub fn level_with_template(l: &DrawingLevel, t: &ViewTemplate) -> DrawingLevel {
|
||||
macro_rules! take {
|
||||
($($f:ident),*) => { $(if t.$f.is_some() { l.$f = t.$f.clone(); })* };
|
||||
}
|
||||
take!(cut_height, view_top, view_bottom, view_depth, shadows, hidden_lines, sketch, cut_hatch, floor_finish, show_terrain, model_view_option_id);
|
||||
take!(cut_height, view_top, view_bottom, view_depth, shadows, hidden_lines, sketch, cut_hatch, floor_finish, show_terrain, model_view_option_id, renovation_filter, renovation_phase);
|
||||
l
|
||||
}
|
||||
|
||||
@@ -140,6 +140,9 @@ pub fn viewport_args(p: &Project, snap: &ViewSnapshot, scale: f64, mono: bool) -
|
||||
// [173] Modelldarstellung des Ausschnitts (sonst die der Ebene, auch über die verknüpfte Vorlage).
|
||||
model_view: snap.model_view_option_id.clone().filter(|s| !s.is_empty()),
|
||||
trace_of: None,
|
||||
// [271] Umbaufilter des Ausschnitts (sonst der der Ebene).
|
||||
renovation: snap.renovation_filter.clone().filter(|s| !s.is_empty()),
|
||||
renovation_phase: snap.renovation_phase.clone().filter(|s| !s.is_empty()),
|
||||
};
|
||||
a.apply_model_view(p);
|
||||
a
|
||||
|
||||
Reference in new issue
Block a user