[140] Tusche als Standard: Schwarz-Weiss behält Grautöne, Schraffur, Schatten und Luftbilder; Ansicht ohne Materialfarben; grob: Türen mit Bogen, Fenster zwei Striche

This commit is contained in:
Claude committed 2026-11-06 08:48:16 +00:00
1 parent 4664c4afcd
commit cee7cbe0f9
9 files changed
+192 -48

No files matched your search

+46 -4
View File
@@ -21,7 +21,10 @@ const SILHOUETTE_MM: f64 = 0.18;
/// [140] Abstand (m), bis zu dem eine Kante als Teil der Silhouette gilt.
const SILHOUETTE_TOL: f64 = 2e-3;
const FRAME_MM: f64 = 0.13;
const GLASS_FILL_MONO: &str = "#c4c8cd";
/// [140] Tusche (Schwarz-Weiss, Standard): Glas hellgrau, Schatten neutral grau und hell.
const GLASS_FILL_MONO: &str = "#dcdcdc";
const SHADOW_FILL_MONO: &str = "#c4c4c4";
const OPENING_SHADOW_FILL_MONO: &str = "#d2d2d2";
/// [140] Glas hellgrau statt blau (Farbe nur, wo der Nutzer sie setzt).
const GLASS_FILL_COLOR: &str = "#d3d8dd";
const SHADOW_FILL: &str = "#8f959e";
@@ -1433,7 +1436,7 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
})
.collect();
i += 2 * count;
let mut prim = polygon(pts, SHADOW_FILL, "none", 0.0, no_hatch());
let mut prim = polygon(pts, if mono { SHADOW_FILL_MONO } else { SHADOW_FILL }, "none", 0.0, no_hatch());
// [137] Klick auf den Schlagschatten wählt die Schatten-Einstellung der Ansicht (keine Element-Id).
if let Primitive::Polygon { context_object_id, .. } = &mut prim {
*context_object_id = Some(crate::plan::extras::SITE_PICK_VIEW_SHADOWS.into());
@@ -1497,7 +1500,7 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
let f_v = min(0.3, 0.08 / max(h_v, 1e-6));
for (fa0, fa1, fz0, fz1) in [(0.0, 1.0, 1.0 - f_v, 1.0), (0.0, f_u, 0.0, 1.0 - f_v)] {
let r = [quad_at(fa0, fz0), quad_at(fa1, fz0), quad_at(fa1, fz1), quad_at(fa0, fz1)];
push(polygon(to_vec(&r), OPENING_SHADOW_FILL, "none", 0.0, no_hatch()));
push(polygon(to_vec(&r), if mono { OPENING_SHADOW_FILL_MONO } else { OPENING_SHADOW_FILL }, "none", 0.0, no_hatch()));
}
}
for (a, b) in &op.divisions {
@@ -1623,6 +1626,8 @@ fn pattern_style(sp: &SurfacePattern, comp: &Component) -> (f64, String) {
}
const PATTERN_INK: &str = "#3a3f47";
/// [140] Ansichtsschraffur in Tusche: feines Grau (Materialstruktur tritt hinter die Kanten zurück).
const MONO_PATTERN_INK: &str = "#8c8c8c";
/// Linie der Ansichtsschraffur: Endpunkte, Verdeckungstiefe, Maler-Tiefe, Stil-Index.
type PatternLine = (Pt, Pt, f64, f64, usize);
@@ -1740,7 +1745,7 @@ fn surface_patterns(p: &Project, faces: &mut [Face], frame: &[f64; 9], scale: f6
}
if mono {
for s in &mut styles {
s.1 = PATTERN_INK.into();
s.1 = MONO_PATTERN_INK.into();
}
}
(lines, styles)
@@ -1975,6 +1980,43 @@ mod tests {
assert_eq!(render(&p, 2000.0).matches("elevation-surface-pattern").count(), 0, "grob: weggelassen");
}
/// [140] Tusche-Ansicht (Schwarz-Weiss, Standard): keine Materialfarben, Flächen weiss, Glas hellgrau,
/// Schatten und Ansichtsschraffur in neutralem Grau (Schatten bleiben).
#[test]
fn tusche_ansicht_ohne_materialfarben() {
let mut p = sample();
let outer = p.wall_types.iter().find(|t| t.id == "aw").unwrap().layers[0].component_id.clone();
let c = p.components.iter_mut().find(|c| c.id == outer).unwrap();
c.elevation_color = Some("#c0603a".into());
c.surface_pattern = Some(SurfacePattern { kind: SurfacePatternKind::Lines, spacing: 0.1, color: Some("#a0522d".into()), ..Default::default() });
let l = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
let level = LevelSpec::from_json(&serde_json::to_value(l).unwrap());
let (prims, _) = elevation_primitives(&p, &level, true, true, &Visibility::default(), 50.0).unwrap().unwrap();
let neutral = |c: &str| c == "none" || crate::plan::extras::is_neutral(c);
let mut shadow = false;
let mut pattern = false;
for q in &prims {
match q {
Primitive::Polygon { fill, stroke, context_object_id, .. } => {
assert!(neutral(fill) && neutral(stroke), "bunt: {fill} {stroke}");
shadow |= context_object_id.as_deref() == Some(crate::plan::extras::SITE_PICK_VIEW_SHADOWS);
}
Primitive::Line { cls, color, .. } => {
let c = color.as_deref().unwrap_or("#000");
assert!(neutral(c), "bunte Linie {cls}: {c}");
if cls == "elevation-surface-pattern" {
pattern = true;
assert_eq!(c, MONO_PATTERN_INK, "Muster grau, nicht schwarz");
}
}
_ => {}
}
}
assert!(shadow && pattern);
let json = serde_json::to_string(&prims).unwrap();
assert!(json.contains(GLASS_FILL_MONO) && !json.contains("#c0603a"));
}
/// [G3] Formöffnung: Rahmen als Umriss (viele Ecken), Glas eingerückt; [103] Dachfenster auf der
/// Südfläche sichtbar.
#[test]
+68 -5
View File
@@ -416,7 +416,11 @@ impl Post {
fn hatch(&self, h: &mut HatchRender) {
if self.mono && h.pattern != HatchPattern::None {
h.color = (if h.pattern == HatchPattern::Solid { HATCH_INK } else { MONO_INK }).into();
if h.pattern == HatchPattern::Solid {
h.color = HATCH_INK.into();
} else if !is_neutral(&h.color) {
h.color = MONO_INK.into();
}
}
if self.lw != 1.0 {
h.line_weight = scale_weight(h.line_weight, self.lw);
@@ -430,9 +434,16 @@ impl Post {
if self.mono {
let solid = hatch.pattern == HatchPattern::Solid;
if *fill != "none" {
*fill = (if solid { HATCH_INK } else { "#ffffff" }).into();
if solid {
*fill = HATCH_INK.into();
} else if !is_neutral(fill) {
*fill = "#ffffff".into();
}
}
// [140] „none" bleibt (Wandschichten ohne Umriss: sonst Kontur statt Schraffur).
if *stroke != "none" && !is_neutral(stroke) {
*stroke = MONO_INK.into();
}
*stroke = MONO_INK.into();
}
self.hatch(hatch);
if self.lw != 1.0 {
@@ -445,7 +456,7 @@ impl Post {
}
}
Primitive::Line { weight_mm, color, .. } => {
if self.mono {
if self.mono && !color.as_deref().is_some_and(is_neutral) {
*color = Some(MONO_INK.into());
}
if self.lw != 1.0 {
@@ -463,10 +474,24 @@ 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 { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
(if self.mono && !color.is_some_and(is_neutral) { Some(MONO_INK) } else { color }, scale_weight(w, self.lw))
}
}
/// [140] Unbunte Farbe (Grau/Schwarz/Weiss, `#rgb`/`#rrggbb`/`#rrggbbaa`): bleibt in Schwarz-Weiss erhalten
/// (Schatten, Gelände-Grau, Treppen-Grau); bunte Farben werden Tinte bzw. Papier.
pub fn is_neutral(c: &str) -> bool {
let h = c.trim().trim_start_matches('#');
let ch = |i: usize, n: usize| u8::from_str_radix(h.get(i..i + n)?, 16).ok().map(|v| if n == 1 { v * 17 } else { v });
let rgb = match h.len() {
3 | 4 => (ch(0, 1), ch(1, 1), ch(2, 1)),
6 | 8 => (ch(0, 2), ch(2, 2), ch(4, 2)),
_ => return false,
};
let (Some(r), Some(g), Some(b)) = rgb else { return false };
r.max(g).max(b) - r.min(g).min(b) <= 20
}
/// [32] Strichstärken nach Massstab auf Schnitt-/Ansichts-Primitive (wie im Grundriss über [`post_for`]):
/// Faktor [`line_weight_factor`] auf Linien, Umrisse und Schraffurlinien; ohne Projekt-Option nichts.
pub fn scale_line_weights(p: &Project, scale: f64, prims: &mut [Primitive]) {
@@ -785,4 +810,42 @@ mod tests {
}
assert_eq!(post.line(None, 0.25), (Some(MONO_INK), 0.25));
}
/// [140] Schwarz-Weiss als Tusche-Standard: Wandschichten ohne Umriss bleiben ohne Umriss (sonst verdrängt
/// 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 mut p = flat_polygon(vec![], "#3c3c3c", 0.0);
if let Primitive::Polygon { stroke, hatch, .. } = &mut p {
*stroke = "none".into();
*hatch = HatchRender { pattern: HatchPattern::Diagonal, color: "#808080".into(), ..no_hatch() };
}
post.apply(&mut p);
match &p {
Primitive::Polygon { fill, stroke, hatch, .. } => {
assert_eq!(fill, "#3c3c3c");
assert_eq!(stroke, "none");
assert_eq!(hatch.color, "#808080");
}
_ => unreachable!(),
}
let mut q = flat_polygon(vec![], "#e8dcc0", 0.0);
if let Primitive::Polygon { stroke, hatch, .. } = &mut q {
*stroke = "#b06030".into();
*hatch = HatchRender { pattern: HatchPattern::Diagonal, color: "#c04020".into(), ..no_hatch() };
}
post.apply(&mut q);
match &q {
Primitive::Polygon { fill, stroke, hatch, .. } => {
assert_eq!(fill, "#ffffff");
assert_eq!(stroke, MONO_INK);
assert_eq!(hatch.color, MONO_INK);
}
_ => unreachable!(),
}
assert_eq!(post.line(Some("#8a8a8a"), 0.13), (Some("#8a8a8a"), 0.13));
assert_eq!(post.line(Some("#a05a2c"), 0.13), (Some(MONO_INK), 0.13));
assert!(is_neutral("#fff") && is_neutral("#1a1a1aff") && !is_neutral("#ff0000") && !is_neutral("rot"));
}
}
+40 -13
View File
@@ -85,8 +85,11 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let (sx, sy, ex, ey, total, ref_off) = (r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let (position, width) = (r.num()?, r.num()?);
let is_door = r.num()? != 0.0;
let detail = match r.num()? as i64 {
0 => Detail::Grob,
// [140] Code −1 = Übersicht (grob ab 1:500): Türen ohne Aufschlag-Bogen.
let detail_code = r.num()? as i64;
let overview = detail_code < 0;
let detail = match detail_code {
i64::MIN..=0 => Detail::Grob,
1 => Detail::Mittel,
_ => Detail::Fein,
};
@@ -185,7 +188,7 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
};
for leaf in leaves(&door) {
o.line(C_LEAF, hair, 0.0, 0.0, leaf.hinge, leaf.open_end);
if detail != Detail::Grob {
if !overview {
o.arc(hair, leaf.hinge, leaf.closed_end, leaf.open_end, leaf.radius);
}
}
@@ -194,7 +197,7 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let other = DoorParams { swing_right: !door.swing_right, ..door };
for leaf in leaves(&other) {
o.line(C_LEAF, hair, 0.0, 3.0, leaf.hinge, leaf.open_end);
if detail != Detail::Grob {
if !overview {
// Bögen laufen gegen den Uhrzeigersinn von `from` nach `to`: kurzen Bogen wählen.
let (a, b) = (sub(leaf.closed_end, leaf.hinge), sub(leaf.open_end, leaf.hinge));
let (from, to) = if a.x * b.y - a.y * b.x >= 0.0 { (leaf.closed_end, leaf.open_end) } else { (leaf.open_end, leaf.closed_end) };
@@ -257,14 +260,16 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
}
None => (ref_off - total / 2.0, ref_off + total / 2.0),
};
if has_type {
if has_type && detail != Detail::Grob {
let zone = if win_inset_side == 1.0 { (f_hi, ref_off + total / 2.0) } else { (ref_off - total / 2.0, f_lo) };
rebate_nibs(&mut o, &w, position, width, rebate, Some(zone));
}
if detail == Detail::Grob {
let idx = sym.glass_lines.len() / 2;
if let Some(g) = sym.glass_lines.get(idx).or_else(|| sym.glass_lines.first()) {
o.line(C_GLASS, sash_w, 4.0, 0.0, g.0, g.1);
// [140] Grob: zwei Striche quer durch die Öffnung in den Wandfluchten (kein Rahmen, Glas, Bank).
if let Some((js, je)) = opening_jambs(&w, position, width) {
for off in [ref_off - total / 2.0, ref_off + total / 2.0] {
o.line(C_WINDOW_FRAME, frame_hair, 2.0, 0.0, add(js, scale(wn, off)), add(je, scale(wn, off)));
}
}
} else {
o.polygon(1.0, frame_view_w, 3.0, &sym.frame);
@@ -586,9 +591,13 @@ mod tests {
t
}
/// [140] Grob (auch automatisch ab 1:200): Tür mit Blatt UND Aufschlag-Bogen; Übersicht (1:500, Code −1)
/// nur das Blatt.
#[test]
fn tuer_grob_hat_pick_blatt_und_zwei_sturzlinien() {
fn tuer_grob_hat_pick_blatt_bogen_und_zwei_sturzlinien() {
let t = tags(&plan_opening(&input(true, 0.0, false, &[])));
assert_eq!(t, vec![1.0, 2.0, 3.0, 2.0, 2.0]);
let t = tags(&plan_opening(&input(true, -1.0, false, &[])));
assert_eq!(t, vec![1.0, 2.0, 2.0, 2.0]);
}
@@ -599,10 +608,24 @@ mod tests {
assert_eq!(t.len(), 1 + 1 + 1 + 2 + 2);
}
/// [140] Fenster grob: nur zwei Striche quer durch die Öffnung in den Wandfluchten (kein Rahmen, kein Glas,
/// keine Bank, kein Anschlag) — auch mit Fenstertyp, Anschlag und Bank.
#[test]
fn fenster_grob_hat_eine_glaslinie() {
let t = tags(&plan_opening(&input(false, 0.0, false, &[])));
assert_eq!(t, vec![1.0, 2.0]);
fn fenster_grob_zwei_striche_in_der_wandflucht() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0], [0.0, 1.0, NAN, NAN, 1.0]];
for (has_type, sa) in [(false, &[][..]), (true, &sashes[..])] {
let mut b = input(false, 0.0, has_type, sa);
b[DETAILS] = 0.04; // Anschlag
b[DETAILS + 1] = 3.0; // Bank beidseitig
let f = plan_opening(&b);
assert_eq!(tags(&f), vec![1.0, 2.0, 2.0], "Lücke + zwei Striche");
let mut ys: Vec<f64> = lines(&f).iter().map(|l| {
assert!((l.3 - l.5).abs() < 1e-9 && (l.2 - 1.0).abs() < 1e-9 && (l.4 - 1.9).abs() < 1e-9, "quer durch die Öffnung: {l:?}");
l.3
}).collect();
ys.sort_by(f64::total_cmp);
assert!((ys[0] + 0.15).abs() < 1e-9 && (ys[1] - 0.15).abs() < 1e-9, "Wandfluchten: {ys:?}");
}
}
#[test]
@@ -751,9 +774,13 @@ mod tests {
assert_eq!(count_cls(&f, C_GLASS), 2);
b[KIND] = 3.0;
assert_eq!(arcs(&plan_opening(&b)), 2);
// Grob: keine Bögen, aber beide Blätter.
// Grob: Bögen und beide Blätter; Übersicht (1:500): keine Bögen.
b[9] = 0.0;
let f = plan_opening(&b);
assert_eq!(arcs(&f), 2);
assert_eq!(count_cls(&f, C_LEAF), 2);
b[9] = -1.0;
let f = plan_opening(&b);
assert_eq!(arcs(&f), 0);
assert_eq!(count_cls(&f, C_LEAF), 2);
}
+7 -6
View File
@@ -187,13 +187,14 @@ pub fn plan_svg(parts: &mut [Part], o: &SvgOptions) -> Option<String> {
out.push(String::new());
stitch.add(attrs.clone(), run, out.len() - 1);
}
continue;
} else {
out.push(format!(
"<polygon points=\"{pl}\" fill=\"{fill}\" stroke=\"{stroke}\" stroke-width=\"{}\"{}/>",
num(f[2] * mm_to_m),
op(greyed, opacity(4))
));
}
out.push(format!(
"<polygon points=\"{pl}\" fill=\"{fill}\" stroke=\"{stroke}\" stroke-width=\"{}\"{}/>",
num(f[2] * mm_to_m),
op(greyed, opacity(4))
));
// [140] Schraffur auch bei Kantenläufen (Wandschichten mit offenen Kanten).
if o.hatch && f[3] >= 0.0 {
let (_, h, color) = hatches.get(whole(f[3])?)?.clone();
if h.pattern != Pattern::None && h.pattern != Pattern::Solid && h.kind != hatch::HatchKind::Image {
+2
View File
@@ -388,6 +388,8 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
];
let b01 = |b: bool| if b { 1.0 } else { 0.0 };
let detail_code = match detail {
// [140] Übersicht (1:500 und kleiner): Türen ohne Aufschlag-Bogen.
Detail::Grob if c.a.scale >= super::domains::OVERVIEW_FROM => -1.0,
Detail::Grob => 0.0,
Detail::Mittel => 1.0,
Detail::Fein => 2.0,
+5 -3
View File
@@ -240,14 +240,16 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
let a = domains::PlanArgs::parse(args[0], text)?;
Ok(drawings::underlay_groups(&domains::Ctx::new(p, &a)).iter().flat_map(|v| v.to_le_bytes()).collect())
}
// Linien der Zeichnungen `[Massstab, gedimmt, Index…]` (Index in `drawings2d`), mit Override-Regeln.
// Linien der Zeichnungen `[Massstab, Schalter, Index…]` (Index in `drawings2d`), mit Override-Regeln;
// Schalter: Bit 1 = gedimmt, Bit 2 = Schwarz-Weiss ([140]).
("drawingLines", n) if n >= 2 => {
let mut a = domains::PlanArgs::parse(1.0, "{}")?;
a.scale = args[0];
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: false, lw: crate::plan::extras::line_weight_factor(p, args[0]), sketch: 0.0 }).filter(crate::plan::extras::Post::active);
buf_with(post, |sink| drawings::underlay_lines(&c, &args[2..], args[1] != 0.0, sink))
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);
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]`.
("drawingPrims", 1) => {