Merge [272] Varianten: Auge/Stift, grau einfärben, sperren
check / check (push) Has been cancelled
check / licenses (push) Has been cancelled
check / e2e (push) Has been cancelled
macos / native (push) Has been cancelled

This commit is contained in:
Claude committed 2026-11-17 16:45:49 +00:00
commit 9f32c71ff7
36 files changed
+910 -81

No files matched your search

+62
View File
@@ -216,6 +216,68 @@ impl Combination {
}
}
// ── Bearbeiten wie im Archicad-Manager ([272] Nachtrag 17.11.: Stift und „grau einfärben“) ───────────────────────
/// Bearbeitungsvariante einer **Bildschirm**-Darstellung (Stift im Panel „Varianten“, Zustand der Sitzung): die Variante
/// ist sichtbar (Stift impliziert Auge, geht der Kombination der Ebene vor), mit `grey` zeichnet die Darstellung alles
/// ausserhalb von ihr (Hauptmodell und andere sichtbare Varianten) grau ([`crate::renovation::ghost_style`]). Kommt nur über
/// das Anfrage-Feld `designOptionEdit` der Bildschirm-Ansichten (Grundriss, Schnitt, Ansicht, Axo, 3D) — Druck, PDF,
/// Exporte, Kennzahlen und Goldens fragen nie damit. Die Sperre („Elemente ausserhalb sperren“) ist reine Auswahl-Logik
/// der Oberfläche (`model/designOptions.ts::designOptionLocked`).
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Edit {
pub set: String,
pub option: String,
pub grey: bool,
}
/// Liest `{"set", "option", "grey"}` (Ids oder Namen); unbekannter Satz/Variante oder Unsinn ⇒ `None`.
pub fn parse_edit(p: &Project, v: Option<&Value>) -> Option<Edit> {
let v = v?.as_object()?;
let s = find_set(p, v.get("set")?.as_str()?)?;
let o = find_option(s, v.get("option")?.as_str()?)?;
Some(Edit { set: s.id.clone(), option: o.id.clone(), grey: v.get("grey").and_then(Value::as_bool).unwrap_or(false) })
}
impl Edit {
/// Gehört ein Element mit dieser Zugehörigkeit zur Bearbeitungsvariante?
pub fn holds(&self, r: Option<&DesignOptionRef>) -> bool {
r.is_some_and(|r| r.set == self.set && r.option == self.option)
}
/// Ids aller Elemente ausserhalb der Bearbeitungsvariante (Öffnung ohne eigene Variante folgt ihrer Wand).
pub fn outside(&self, p: &Project) -> HashSet<String> {
let mut out = HashSet::new();
for w in &p.walls {
if !self.holds(w.design_option.as_ref()) {
out.insert(w.id.clone());
}
}
for o in p.openings.iter().flatten() {
let r = o.design_option.as_ref().or_else(|| p.walls.iter().find(|w| w.id == o.host_wall_id).and_then(|w| w.design_option.as_ref()));
if !self.holds(r) {
out.insert(o.id.clone());
}
}
macro_rules! each {
($($f:ident),*) => {$(
for x in p.$f.iter().flatten() {
if !self.holds(x.design_option.as_ref()) {
out.insert(x.id.clone());
}
}
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
out
}
/// Schlüssel für Caches.
pub fn key(&self) -> String {
format!("{}={}{}", self.set, self.option, if self.grey { ":grey" } else { "" })
}
}
/// Gespeicherte Wahl einer Ebene ([`stored_choice`]; über die verknüpfte Vorlage hat sie schon `level_with_template`).
pub fn level_choice(p: &Project, level_id: &str) -> Option<BTreeMap<String, String>> {
p.floor(level_id).and_then(|l| stored_choice(p, l.design_option_combination.as_deref(), l.design_options.as_ref()))
@@ -661,3 +661,102 @@ fn set_field_kennt_alle_wurzelfelder() {
d.undo().unwrap();
assert_eq!(d.project().unwrap().design_option_combinations.as_ref().unwrap()[0].id, "k1");
}
// ── Bearbeiten wie im Archicad-Manager: Stift, grau einfärben ([272] Nachtrag 17.11.) ───────────────────────────────
/// Bearbeitungsvariante der Bildschirm-Anfrage (`designOptionEdit`).
fn edit(option: &str, grey: bool) -> Value {
json!({"designOptionEdit": {"set": "dach", "option": option, "grey": grey}})
}
/// Füllungen der Wand-Polygone von `id`.
fn wall_fills(prims: &[Primitive], id: &str) -> Vec<String> {
prims
.iter()
.filter_map(|q| match q {
Primitive::Polygon { wall_id: Some(w), opening_id: None, fill, .. } if w == id && fill != "none" => Some(fill.clone()),
_ => None,
})
.collect()
}
#[test]
fn bearbeiten_zeigt_die_variante_und_graut_den_rest_nur_auf_anfrage() {
let p = project(&fixture());
let ghost = crate::renovation::ghost_style();
// Ohne Bearbeitung: nichts grau (Druck, PDF, Exporte, Goldens fragen nie mit `designOptionEdit`).
let plain = plan_with(&p, json!({}));
assert!(wall_fills(&plain, "W1").iter().all(|f| *f != ghost.fill));
// Stift auf B: B ist sichtbar (Stift impliziert Auge), obwohl die Ebene A zeigt; A ist weg.
let b = plan_with(&p, edit("b", true));
assert!(has_wall(&b, "W9") && !has_wall(&b, "W2") && has_opening(&b, "O2"));
// Hauptmodell grau (Füllung), die bearbeitete Variante nicht.
assert!(!wall_fills(&b, "W1").is_empty() && wall_fills(&b, "W1").iter().all(|f| *f == ghost.fill), "{:?}", wall_fills(&b, "W1"));
assert!(wall_fills(&b, "W9").iter().all(|f| *f != ghost.fill));
// Häkchen „grau“ aus: sichtbar wie oben, aber keine graue Fläche.
let nb = plan_with(&p, edit("b", false));
assert!(has_wall(&nb, "W9") && !has_wall(&nb, "W2"));
assert!(wall_fills(&nb, "W1").iter().all(|f| *f != ghost.fill));
// Stift auf A (= Hauptvariante): B bleibt aus, Hauptmodell grau, W2 (in A) nicht.
let a = plan_with(&p, edit("a", true));
assert!(has_wall(&a, "W2") && !has_wall(&a, "W9"));
assert!(wall_fills(&a, "W1").iter().all(|f| *f == ghost.fill) && wall_fills(&a, "W2").iter().all(|f| *f != ghost.fill));
// Unbekannte Variante oder Unsinn: wie ohne Bearbeitung.
for bad in [json!({"set": "dach", "option": "zz", "grey": true}), json!({"set": 1}), json!("dach"), json!(null), json!({"option": "b"})] {
let q = plan_with(&p, json!({"designOptionEdit": bad}));
assert_eq!(format!("{q:?}"), format!("{plain:?}"), "{bad}");
}
// Cache-Schlüssel unterscheidet die Bearbeitung.
let k = |e: Option<Edit>| crate::renovation::View::editing(crate::renovation::View::new(&p, None, None), &p, e).map(|v| v.key());
let e = |grey| Some(Edit { set: "dach".into(), option: "b".into(), grey });
assert_ne!(k(None), k(e(true)));
assert_ne!(k(e(false)), k(e(true)));
}
#[test]
fn bearbeiten_grau_in_schnitt_ansicht_axo_und_3d() {
let p = project(&fixture());
let ghost = crate::renovation::ghost_style();
let grey_fill = |prims: &[Primitive]| prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if *fill == ghost.fill));
// Schnitt: das Dach RF1 (B) erscheint, Hauptmodell grau; ohne Anfrage nichts grau.
let s = section_prims(&p, edit("b", true));
assert!(ids_in(&s).contains("RF1") && grey_fill(&s));
assert!(!grey_fill(&section_prims(&p, json!({}))));
assert!(!grey_fill(&section_prims(&p, edit("b", false))));
// Ansicht.
assert!(grey_fill(&elevation_prims(&p, edit("b", true))), "Ansicht ohne Grau");
assert!(!grey_fill(&elevation_prims(&p, json!({}))));
assert_eq!(format!("{:?}", elevation_prims(&p, edit("b", false))), format!("{:?}", elevation_prims(&p, json!({"designOptions": "Dachform=B"}))));
// Axo.
let axo = |t: Value| crate::queries::run_bin(&p, "axoPlan", &[0.0, 100.0], &t.to_string()).unwrap();
assert_ne!(axo(edit("b", true)), axo(edit("b", false)));
assert_eq!(axo(edit("b", false)), axo(json!({"designOptions": "Dachform=B"})));
// 3D: Hauptmodell-Wand W1 in der Graufarbe, W9 (B) nicht, W2 (A) fehlt.
let parts = |t: Value| -> Value { serde_json::from_str(&crate::queries::run(&p, "model3dParts", &[1.0, 1.0, 0.0], &t.to_string()).unwrap()).unwrap() };
let rgb = crate::style::hex_to_rgb(&ghost.fill, [0.0; 3]).to_vec();
let wall = |v: &Value, id: &str| v["walls"].as_array().unwrap().iter().find(|w| w["wallId"] == id).cloned();
let col = |w: Value| w["color"].as_array().unwrap().iter().map(|x| x.as_f64().unwrap()).collect::<Vec<_>>();
let g = parts(edit("b", true));
assert_eq!(col(wall(&g, "W1").unwrap()), rgb);
assert_ne!(col(wall(&g, "W9").unwrap()), rgb);
assert!(wall(&g, "W2").is_none());
assert_ne!(col(wall(&parts(json!({})), "W1").unwrap()), rgb);
// Kennzahlen kennen keine Bearbeitung (gleich wie die Hauptkombination).
assert_eq!(crate::queries::run(&p, "kennzahlen", &[], &edit("b", true).to_string()).unwrap(), crate::queries::run(&p, "kennzahlen", &[], "").unwrap());
}
#[test]
fn bearbeiten_auch_ohne_elemente_in_varianten() {
// Sätze ohne Elemente (gerade angelegt): Stift auf B graut alles, was es gibt.
let mut v = crate::renovation::tests::umbau_fixture();
v["designOptionSets"] = json!([{"id": "dach", "name": "Dachform", "options": [{"id": "a", "name": "A"}, {"id": "b", "name": "B"}], "primary": "a"}]);
let p = project(&v);
assert!(!active(&p));
let ghost = crate::renovation::ghost_style();
let b = plan_with(&p, edit("b", true));
assert!(!wall_fills(&b, "W1").is_empty() && wall_fills(&b, "W1").iter().all(|f| *f == ghost.fill));
// Mit Umbaufilter: Grau geht der Umbau-Farbe vor (ausserhalb der Variante), Ausgeblendetes bleibt weg.
let r = plan_with(&p, json!({"renovation": "neubau", "designOptionEdit": {"set": "dach", "option": "b", "grey": true}}));
assert!(!has_wall(&r, "W2"));
assert!(wall_fills(&r, "W9").iter().all(|f| *f == ghost.fill));
}
+3 -1
View File
@@ -712,7 +712,9 @@ pub fn axo_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>, St
// [271] Umbaufilter (`renovation`, `renovationPhase`): Ausgeblendetes fehlt, Flächen in der Umbau-Farbe.
// [272] Variantenkombination (`designOptions`, sonst die Hauptvarianten): andere Varianten fehlen.
let opts = crate::design_options::parse_request(v.get("designOptions"));
let ren = crate::renovation::View::with(p, v.get("renovation").and_then(|x| x.as_str()), v.get("renovationPhase").and_then(|x| x.as_str()), &[], &opts).map(|r| r.resolve(p));
let ren = crate::renovation::View::with(p, v.get("renovation").and_then(|x| x.as_str()), v.get("renovationPhase").and_then(|x| x.as_str()), &[], &opts);
// [272] Bearbeitungsvariante der Bildschirm-Ansicht (`designOptionEdit`).
let ren = crate::renovation::View::editing(ren, p, crate::design_options::parse_edit(p, v.get("designOptionEdit"))).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()) };
+1
View File
@@ -150,6 +150,7 @@ pub fn ctx_key(a: &PlanArgs) -> String {
+ &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("")))
+ &a.design_options.iter().map(|(k, v)| format!("\u{1}opt:{k}={v}")).collect::<String>()
+ &a.design_option_edit.as_ref().map_or(String::new(), |e| format!("\u{1}edit:{e}"))
}
/// Sichtbarkeit und Dimmen als vergleichbarer Text (Mengen sortiert).
+1
View File
@@ -58,6 +58,7 @@ fn floor_args(a: &PlanArgs, floor: &str) -> PlanArgs {
renovation: a.renovation.clone(),
renovation_phase: a.renovation_phase.clone(),
design_options: a.design_options.clone(),
design_option_edit: a.design_option_edit.clone(),
}
}
+9 -2
View File
@@ -71,6 +71,9 @@ pub struct PlanArgs {
/// [272] Ausdrücklich angefragte Variantenkombination (Blatt-Viewport, CLI `--options`), über der der Ebene
/// (`DrawingLevel.designOptions`) und den Hauptvarianten (`design_options.rs`).
pub design_options: crate::design_options::Request,
/// [272] Bearbeitungsvariante der Bildschirm-Ansicht (`designOptionEdit`: `{set, option, grey}`, nur Bildschirm;
/// aufgelöst in [`Ctx::new`] über `design_options::parse_edit`).
pub design_option_edit: Option<serde_json::Value>,
}
/// [140] Ab diesem Massstab (1:N) zeichnet der Detailgrad „mittel" wie „grob".
@@ -120,6 +123,7 @@ impl PlanArgs {
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),
design_options: crate::design_options::parse_request(v.get("designOptions")),
design_option_edit: v.get("designOptionEdit").filter(|e| e.is_object()).cloned(),
})
}
@@ -178,7 +182,10 @@ impl<'a> Ctx<'a> {
}
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(), &a.design_options).map(|v| v.resolve(p)).filter(|r| !r.is_empty());
let view = crate::renovation::View::for_level(p, &a.floor, a.renovation.as_deref(), a.renovation_phase.as_deref(), &a.design_options);
// [272] Bearbeitungsvariante (Stift, nur Bildschirm): sichtbar, mit „grau“ alles ausserhalb grau.
let view = crate::renovation::View::editing(view, p, crate::design_options::parse_edit(p, a.design_option_edit.as_ref()));
let ren = view.map(|v| v.resolve(p)).filter(|r| !r.is_empty());
if let Some(r) = &ren {
hidden.extend(r.hidden.iter().cloned());
}
@@ -1672,7 +1679,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, renovation: None, renovation_phase: None, design_options: Vec::new() };
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, design_options: Vec::new(), design_option_edit: 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 {
+1
View File
@@ -1784,6 +1784,7 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
renovation: None,
renovation_phase: None,
design_options: Vec::new(),
design_option_edit: None,
};
if let Some(entries) = plan_domains_buf(p, &args).ok().and_then(|buf| {
let view = View::parse(&buf)?;
+3 -1
View File
@@ -50,7 +50,9 @@ pub fn renovation_view(p: &Project, v: &serde_json::Value, level: &LevelSpec) ->
None => (level.renovation.as_deref(), level.renovation_phase.as_deref()),
};
let own = crate::design_options::stored_choice(p, level.design_option_combination.as_deref(), level.design_options.as_ref());
crate::renovation::View::with(p, f, ph, &own.iter().collect::<Vec<_>>(), &crate::design_options::parse_request(v.get("designOptions")))
let view = crate::renovation::View::with(p, f, ph, &own.iter().collect::<Vec<_>>(), &crate::design_options::parse_request(v.get("designOptions")));
// [272] Bearbeitungsvariante der Bildschirm-Ansicht (`designOptionEdit`, nie im Druck).
crate::renovation::View::editing(view, p, crate::design_options::parse_edit(p, v.get("designOptionEdit")))
}
/// Abfrage `sectionPlan`: `args` = `[mono, openings, key]` (`key` > 0
+2 -1
View File
@@ -200,7 +200,8 @@ 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));
// [272] Dazu die Bearbeitungsvariante des 3D-Fensters (`designOptionEdit`, grau ausserhalb).
let ren = crate::renovation::screen_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]);
+91 -21
View File
@@ -106,14 +106,24 @@ pub struct Style {
pub line: Option<String>,
/// Linien gestrichelt ([`DEMOLISH_DASH`]).
pub dashed: bool,
/// [272] Grau ausserhalb der Bearbeitungsvariante ([`ghost_style`]): alle gefüllten Flächen des Elements (nicht nur
/// die Schnittfläche) in der Füllfarbe, ohne Muster.
pub ghost: bool,
}
/// [272] Grau für Elemente ausserhalb der Bearbeitungsvariante (Häkchen „Elemente ausserhalb der Variante grau
/// einfärben“, nur Bildschirm): helles Grau, mit dem Papier gemischt wie die Pausfolie (`plan/trace.rs::Tone`), damit es
/// halbtransparent wirkt und in Ansicht und 3D (nur `#rrggbb`) gleich aussieht.
pub fn ghost_style() -> Style {
Style { fill: "#e3e3e3".into(), line: Some("#a8a8a8".into()), dashed: false, ghost: true }
}
/// 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 },
RenovationStatus::Demolish => Style { fill: "#ffd800".into(), line: None, dashed: true, ghost: false },
RenovationStatus::New => Style { fill: "#e3001b".into(), line: Some("#c00016".into()), dashed: false, ghost: false },
_ => Style { fill: "#a6a6a6".into(), line: None, dashed: false, ghost: false },
}
}
@@ -156,6 +166,8 @@ pub struct View {
pub options: Option<crate::design_options::Combination>,
/// Etappe, bis zu der der Filter gilt (Index), `None` = alle.
pub upto: Option<usize>,
/// [272] Bearbeitungsvariante der Bildschirm-Darstellung (Stift; [`View::editing`]), `None` = keine.
pub edit: Option<crate::design_options::Edit>,
phases: HashMap<String, usize>,
styles: [Style; 3],
}
@@ -185,7 +197,22 @@ impl View {
let upto = if filter.is_some() { phase.filter(|s| !s.trim().is_empty()).and_then(|s| phase_index(p, s)) } else { None };
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, options, upto, phases, styles })
Some(View { filter, options, upto, phases, styles, edit: None })
}
/// [272] Mit Bearbeitungsvariante (Stift, nur Bildschirm-Anfragen `designOptionEdit`): die Variante ist sichtbar (geht
/// der Kombination vor — Stift impliziert Auge), mit `grey` bekommt alles ausserhalb [`ghost_style`]. Gibt es
/// sonst keine `View` (kein Filter, keine Elemente in Varianten), entsteht eine. `edit = None` ⇒ `v` unverändert.
pub fn editing(v: Option<View>, p: &Project, edit: Option<crate::design_options::Edit>) -> Option<View> {
let Some(e) = edit else { return v };
let mut v = v.unwrap_or_else(|| {
let styles = [style(p, RenovationStatus::Existing), style(p, RenovationStatus::Demolish), style(p, RenovationStatus::New)];
View { filter: None, options: None, upto: None, phases: HashMap::new(), styles, edit: None }
});
let c = v.options.get_or_insert_with(|| crate::design_options::Combination::primary(p));
c.choice.insert(e.set.clone(), e.option.clone());
v.edit = Some(e);
Some(v)
}
/// Filter einer Darstellung: ausdrücklich angefragt (CLI, Blatt-Ausschnitt), sonst der der Ebene `level_id`
@@ -245,10 +272,25 @@ impl View {
if let Some(c) = &self.options {
out.hidden = c.hidden(p);
}
if self.filter.is_none() {
return out;
if self.filter.is_some() {
self.resolve_filter(p, &mut out);
}
let mut put = |id: &str, t: Treat, out: &mut Resolved| match t {
// [272] Grau ausserhalb der Bearbeitungsvariante: geht der Umbau-Farbe vor; Ausgeblendetes bleibt weg.
if let Some(e) = self.edit.as_ref().filter(|e| e.grey) {
let g = ghost_style();
for id in e.outside(p) {
if !out.hidden.contains(&id) {
out.styled.insert(id, g.clone());
}
}
out.patches.retain(|pa| !out.styled.get(&pa.opening_id).is_some_and(|s| s.ghost));
}
out
}
/// Ausgeblendetes, Farben und Ersatzstücke des Umbaufilters (mit Filter).
fn resolve_filter(&self, p: &Project, out: &mut Resolved) {
let put = |id: &str, t: Treat, out: &mut Resolved| match t {
Treat::Hide => {
out.hidden.insert(id.to_string());
}
@@ -261,7 +303,7 @@ impl View {
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);
put(&w.id, self.treat_state(s), out);
}
for o in p.openings.iter().flatten() {
let host = wall_state.get(o.host_wall_id.as_str()).copied().flatten();
@@ -270,7 +312,7 @@ impl View {
continue;
}
let s = self.state(opening_renovation(p, o));
put(&o.id, self.treat_state(s), &mut out);
put(&o.id, self.treat_state(s), 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;
@@ -285,19 +327,19 @@ impl View {
}
}
for x in p.ceilings.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
for x in p.roofs.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
for x in p.stairs.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
for x in p.columns.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
for x in p.extruded_solids.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), &mut out);
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
// Räume: nur sichtbar oder nicht (ein Raum ist kein Bauteil, er bekommt keine Umbau-Farbe).
for x in p.rooms.iter().flatten() {
@@ -305,7 +347,6 @@ impl View {
out.hidden.insert(x.id.clone());
}
}
out
}
/// Füll- und Linienfarben der Status, die der Filter farbig zeigt (bleiben in Schwarz-Weiss erhalten).
@@ -324,9 +365,10 @@ impl View {
/// Schlüssel für Caches (Filter samt Darstellungen, Etappe, Farben).
pub fn key(&self) -> String {
let opts = self.options.as_ref().map_or(String::new(), |c| c.key());
let edit = self.edit.as_ref().map_or(String::new(), |e| format!("|edit:{}", e.key()));
match &self.filter {
Some(f) => format!("{}:{:?}{:?}{:?}:{:?}:{:?}|{opts}", f.id, f.existing, f.demolish, f.new, self.upto, self.styles),
None => format!("-|{opts}"),
Some(f) => format!("{}:{:?}{:?}{:?}:{:?}:{:?}|{opts}{edit}", f.id, f.existing, f.demolish, f.new, self.upto, self.styles),
None => format!("-|{opts}{edit}"),
}
}
}
@@ -452,18 +494,25 @@ pub fn restyle_with(q: &mut Primitive, st: &Style, extra: &mut Vec<Primitive>, w
*stroke = "none".into();
}
}
Primitive::Line { color, dash: d, .. } => {
Primitive::Line { color, dash: d, greyed, .. } => {
if let Some(l) = &st.line {
*color = Some(l.clone().into());
}
// [272] Grau ausserhalb der Bearbeitungsvariante: auch Linien mit Klassenfarbe (Türbogen, Fensterrahmen).
if st.ghost {
*greyed = Some(true);
}
if st.dashed {
*d = dash();
}
}
Primitive::Arc { color, dash: d, .. } => {
Primitive::Arc { color, dash: d, greyed, .. } => {
if let Some(l) = &st.line {
*color = Some(l.clone().into());
}
if st.ghost {
*greyed = Some(true);
}
if st.dashed {
*d = dash();
}
@@ -502,7 +551,8 @@ pub fn restyle_range(r: &Resolved, prims: &mut Vec<Primitive>, from: usize, owne
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);
// [272] Grau ausserhalb der Bearbeitungsvariante: alle Flächen.
let f = st.ghost || cut_fill(q);
restyle_with(q, st, &mut extra, f);
}
}
@@ -558,7 +608,7 @@ pub fn patch_prims(ring: Vec<Vec2>, st: &Style, weight_mm: f64, opening_id: &str
};
let mut extra = Vec::new();
if st.dashed {
restyle(&mut q, &Style { fill: st.fill.clone(), line: None, dashed: true }, &mut extra);
restyle(&mut q, &Style { fill: st.fill.clone(), line: None, dashed: true, ghost: false }, &mut extra);
}
// Linien des Stücks tragen die Öffnung (Picken, Kontrast).
for l in extra.iter_mut() {
@@ -585,6 +635,18 @@ pub fn view_from_text(p: &Project, text: &str) -> Option<View> {
View::with(p, f, v.get("renovationPhase").and_then(|x| x.as_str()), &[], &req)
}
/// [272] Wie [`view_from_text`] für Bildschirm-Anfragen (3D-Fenster): dazu die Bearbeitungsvariante `designOptionEdit`
/// ([`View::editing`]). Kennzahlen und Exporte nehmen [`view_from_text`] und kennen sie nicht.
pub fn screen_view_from_text(p: &Project, text: &str) -> Option<View> {
let v = view_from_text(p, text);
let t = text.trim();
if !t.starts_with('{') {
return v;
}
let Ok(j) = serde_json::from_str::<serde_json::Value>(t) else { return v };
View::editing(v, p, crate::design_options::parse_edit(p, j.get("designOptionEdit")))
}
/// 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() {
@@ -617,6 +679,14 @@ pub fn color_parts(p: &Project, parts: &mut crate::model3d::Parts, r: &Resolved)
l.color = c;
}
}
// [272] Grau ausserhalb der Bearbeitungsvariante: auch Fenster und Türen (Umbau-Farben lassen sie, wie sie sind).
for m in parts.opening_meshes.iter_mut() {
if let Some(st) = m.owner.id(p).and_then(|id| r.styled.get(id)).filter(|s| s.ghost) {
m.color = crate::style::hex_to_rgb(&st.fill, crate::style::WALL_RGB);
m.vertex_colors = None;
m.material_index = None;
}
}
}
/// Liste der Filter für die Oberfläche (Abfrage `renovationFilters`): eingebaute, dann eigene.
+1
View File
@@ -184,6 +184,7 @@ pub fn viewport_args(p: &Project, snap: &ViewSnapshot, scale: f64, mono: bool) -
renovation_phase: snap.renovation_phase.clone().filter(|s| !s.is_empty()),
// [272] Variantenkombination des Ausschnitts (über der der Ebene).
design_options: crate::design_options::stored_choice(p, snap.design_option_combination.as_deref(), snap.design_options.as_ref()).into_iter().flatten().collect(),
design_option_edit: None,
};
a.apply_model_view(p);
a