[140] Plan: Achsen am Gebäude unterbrochen, Ansicht nur Stummel; mittel ab 1:200 automatisch grob, Übersicht 1:500; Raumstempel in Tinte; Schatten heller; Höhenlinien ausgedünnt
This commit is contained in:
9 files changed
+192
-34
No files matched your search
@@ -133,7 +133,7 @@ impl Clone for PlanCache {
|
||||
|
||||
/// Schlüssel eines Argument-Satzes ohne Sichtbarkeit/Dimmen (die wirken je Element).
|
||||
pub fn ctx_key(a: &PlanArgs) -> String {
|
||||
format!("{}\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)
|
||||
format!("{}\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)
|
||||
}
|
||||
|
||||
/// Sichtbarkeit und Dimmen als vergleichbarer Text (Mengen sortiert).
|
||||
|
||||
@@ -50,6 +50,7 @@ fn floor_args(a: &PlanArgs, floor: &str) -> PlanArgs {
|
||||
compact: a.compact,
|
||||
mono: a.mono,
|
||||
sun_when: None,
|
||||
auto_coarse: a.auto_coarse,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,9 +128,11 @@ pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
|
||||
const TERRAIN_INK: &str = "#7a5b3a";
|
||||
/// [140] Kleinster Papierabstand (mm) zwischen Höhenlinien; enger werden Zwischenlinien ausgelassen.
|
||||
const CONTOUR_MIN_GAP_MM: f64 = 0.6;
|
||||
|
||||
/// [140] Aussenringe der Gebäudegrundfläche (Wände und Körper aller Geschosse vereinigt, ohne Innenhöfe/Räume).
|
||||
fn building_rings(p: &Project) -> Vec<Vec<Vec2>> {
|
||||
pub(super) fn building_rings(p: &Project) -> Vec<Vec<Vec2>> {
|
||||
crate::site_rules::building_footprint(p).into_iter().filter_map(|poly| poly.into_iter().next()).filter(|r| r.len() >= 3).collect()
|
||||
}
|
||||
|
||||
@@ -147,7 +149,7 @@ fn inside(q: Vec2, ring: &[Vec2]) -> bool {
|
||||
}
|
||||
|
||||
/// Teile der Strecke a–b ausserhalb aller `rings`.
|
||||
fn outside(a: Vec2, b: Vec2, rings: &[Vec<Vec2>]) -> Vec<(Vec2, Vec2)> {
|
||||
pub(super) fn outside(a: Vec2, b: Vec2, rings: &[Vec<Vec2>]) -> Vec<(Vec2, Vec2)> {
|
||||
let (dx, dy) = (b.x - a.x, b.y - a.y);
|
||||
let (lo_x, hi_x, lo_y, hi_y) = (a.x.min(b.x), a.x.max(b.x), a.y.min(b.y), a.y.max(b.y));
|
||||
let mut ts = vec![0.0, 1.0];
|
||||
@@ -193,7 +195,22 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec<Primitive>, house: &
|
||||
let every = t.contour_index_every.filter(|v| v.is_finite() && *v >= 1.0).map_or(5, |v| v.round() as i64);
|
||||
let st = crate::excavation::site_terrain(c.p, t);
|
||||
let text_h = 0.002 * c.a.scale.max(1.0);
|
||||
for l in crate::terrain::isolines(st.current(), iv, 0.0) {
|
||||
let tin = st.current();
|
||||
let idx = crate::terrain::TinIndex::new(tin);
|
||||
// [140] Papierabstand (mm) benachbarter Höhenlinien am Punkt: Äquidistanz / Gefälle des Dreiecks.
|
||||
let spacing_mm = |x: f64, y: f64| -> f64 {
|
||||
let Some(([a, b, cc], _)) = idx.bary_at(x, y) else { return f64::INFINITY };
|
||||
let (pa, pb, pc) = (tin.xy[a], tin.xy[b], tin.xy[cc]);
|
||||
let (ux, uy, uz) = (pb[0] - pa[0], pb[1] - pa[1], tin.z[b] - tin.z[a]);
|
||||
let (vx, vy, vz) = (pc[0] - pa[0], pc[1] - pa[1], tin.z[cc] - tin.z[a]);
|
||||
let d = ux * vy - vx * uy;
|
||||
if d.abs() < 1e-12 {
|
||||
return f64::INFINITY;
|
||||
}
|
||||
let g = ((uz * vy - vz * uy) / d).hypot((ux * vz - vx * uz) / d);
|
||||
if g > 1e-12 { iv / g * 1000.0 / c.a.scale.max(1.0) } else { f64::INFINITY }
|
||||
};
|
||||
for l in crate::terrain::isolines(tin, iv, 0.0) {
|
||||
let k = (l.level / iv).round() as i64;
|
||||
let index = k.rem_euclid(every) == 0;
|
||||
// [140] Zähllinie mittel (0.18), Höhenlinie fein (0.1): Gelände bleibt unter dem Gebäude zurück.
|
||||
@@ -210,6 +227,14 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec<Primitive>, house: &
|
||||
for i in 0..segs {
|
||||
let (a, b) = (l.pts[i], l.pts[(i + 1) % n]);
|
||||
let d = seg_len(i);
|
||||
// [140] Zu eng (< 0.6 mm auf dem Papier): nur jede zweite, bei < 0.3 mm nur die Zähllinien.
|
||||
if !index {
|
||||
let s = spacing_mm((a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0);
|
||||
if s < CONTOUR_MIN_GAP_MM && (k.rem_euclid(2) != 0 || 2.0 * s < CONTOUR_MIN_GAP_MM) {
|
||||
acc += d;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Anteile (Bruchteile 0..1) des Segments ausserhalb der Lücke.
|
||||
let mut spans = vec![(0.0, 1.0)];
|
||||
if let (Some((g0, g1)), true) = (gap, d > 0.0) {
|
||||
@@ -444,6 +469,31 @@ mod tests {
|
||||
assert!(lines.iter().all(|(a, b)| !((a.x - 15.0).abs() < 1e-6 && (a.y + b.y) / 2.0 > 0.0 && (a.y + b.y) / 2.0 < 10.0)), "Höhenlinie im Haus");
|
||||
}
|
||||
|
||||
/// [140] Steile Stellen (Stützmauer, Böschung): Höhenlinien enger als 0.6 mm auf dem Papier werden
|
||||
/// ausgedünnt (jede zweite, sonst nur Zähllinien); im flachen Teil bleiben alle.
|
||||
#[test]
|
||||
fn hoehenlinien_ausgeduennt_wo_zu_eng() {
|
||||
// x 0..10 flach (z = 0.1 x), x 10..11 steil (z 1 → 11).
|
||||
let t = TerrainMesh {
|
||||
id: "t".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 10.0, 0.0, 1.0, 10.0, 10.0, 1.0, 0.0, 10.0, 0.0, 11.0, 0.0, 11.0, 11.0, 10.0, 11.0],
|
||||
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 1.0, 4.0, 5.0, 1.0, 5.0, 2.0],
|
||||
contour_interval: Some(0.1),
|
||||
..Default::default()
|
||||
};
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let xs: Vec<f64> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK && (a.x - b.x).abs() < 1e-9 => Some(a.x), _ => None }).collect();
|
||||
let flat = xs.iter().filter(|x| **x > 0.5 && **x < 9.5).count();
|
||||
let steep: Vec<f64> = xs.iter().copied().filter(|x| *x > 10.05 && *x < 10.95).collect();
|
||||
assert_eq!(flat, 18, "flach: alle neun Linien (je zwei Dreiecke)");
|
||||
// Steil: Abstand 1 mm = 0.01 mm Papier → nur Zähllinien (jede 5.: z = 1.5, 2 … 10.5).
|
||||
assert!(!steep.is_empty() && steep.len() <= 3 * 19, "{steep:?}");
|
||||
assert!(steep.iter().all(|x| { let z = 1.0 + (x - 10.0) * 10.0; ((z * 2.0).round() - z * 2.0).abs() < 1e-6 }), "nur Zähllinien: {steep:?}");
|
||||
}
|
||||
|
||||
/// [T6]/[68] Höhenlinien (Zähllinien dicker + beschriftet) und Baugrube (Sohle, Oberkante, Schraffur).
|
||||
#[test]
|
||||
fn hoehenlinien_und_baugrube() {
|
||||
|
||||
@@ -50,6 +50,23 @@ pub struct PlanArgs {
|
||||
pub mono: bool,
|
||||
/// Zeitpunkt der Schattenstudie (Unix-ms; fehlt/ungültig = kein Schatten).
|
||||
pub sun_when: Option<f64>,
|
||||
/// [140] Detailgrad „mittel" ab 1:200 automatisch als „grob" gezeichnet (Raumstempel bleiben, nur
|
||||
/// knapper; ab 1:500 ohne Masslinien).
|
||||
pub auto_coarse: bool,
|
||||
}
|
||||
|
||||
/// [140] Ab diesem Massstab (1:N) zeichnet der Detailgrad „mittel" wie „grob".
|
||||
pub const AUTO_COARSE_FROM: f64 = 200.0;
|
||||
/// [140] Ab diesem Massstab (1:N) im automatisch groben Plan: Raumstempel nur mit Namen, keine Masslinien.
|
||||
pub const OVERVIEW_FROM: f64 = 500.0;
|
||||
|
||||
/// [140] Wirksamer Detailgrad: „mittel" ab 1:200 wie „grob" (zweiter Wert: automatisch vergröbert).
|
||||
pub fn effective_detail(requested: Detail, scale: f64) -> (Detail, bool) {
|
||||
if requested == Detail::Mittel && scale >= AUTO_COARSE_FROM {
|
||||
(Detail::Grob, true)
|
||||
} else {
|
||||
(requested, false)
|
||||
}
|
||||
}
|
||||
|
||||
impl PlanArgs {
|
||||
@@ -59,22 +76,26 @@ impl PlanArgs {
|
||||
pub fn parse(detail: f64, text: &str) -> Result<PlanArgs, String> {
|
||||
let v: serde_json::Value = serde_json::from_str(text).map_err(|e| format!("Plan-Argumente: {e}"))?;
|
||||
let set = |k: &str| -> HashSet<String> { v.get(k).and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()).unwrap_or_default() };
|
||||
let scale = v.get("scale").and_then(|b| b.as_f64()).unwrap_or(super::drawings::DEFAULT_SCALE_DENOMINATOR);
|
||||
let requested = match detail as i64 {
|
||||
0 => Detail::Grob,
|
||||
2 => Detail::Fein,
|
||||
_ => Detail::Mittel,
|
||||
};
|
||||
let (detail, auto_coarse) = effective_detail(requested, scale);
|
||||
Ok(PlanArgs {
|
||||
floor: v.get("floor").and_then(|f| f.as_str()).unwrap_or_default().to_string(),
|
||||
detail: match detail as i64 {
|
||||
0 => Detail::Grob,
|
||||
2 => Detail::Fein,
|
||||
_ => Detail::Mittel,
|
||||
},
|
||||
detail,
|
||||
show: set("show"),
|
||||
grey: set("grey"),
|
||||
reference_lines: v.get("referenceLines").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
global: v.get("global").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
scale: v.get("scale").and_then(|b| b.as_f64()).unwrap_or(super::drawings::DEFAULT_SCALE_DENOMINATOR),
|
||||
scale,
|
||||
for_print: v.get("forPrint").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
compact: v.get("compact").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
mono: v.get("mono").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
sun_when: v.get("sunWhen").and_then(|b| b.as_f64()),
|
||||
auto_coarse,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -604,12 +625,20 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
let pts: Vec<[f64; 2]> = room.boundary.iter().map(|v| [v.x, v.y]).collect();
|
||||
let res = crate::room_area::evaluate(&pts, 0.0);
|
||||
out.push(polygon(room.boundary.clone(), &with_alpha(color, ROOM_FILL_ALPHA), color, LAYER_LINE_MM * c.a.detail.layer_factor(), no_hatch(), greyed, None, Pick::Room(&room.id)));
|
||||
if c.a.detail == Detail::Grob {
|
||||
if c.a.detail == Detail::Grob && !c.a.auto_coarse {
|
||||
continue;
|
||||
}
|
||||
let at = room.stamp_anchor.unwrap_or(pv(res.centroid));
|
||||
let small = c.a.scale >= ROOM_STAMP_SMALL_FROM;
|
||||
// [140] Übersicht (ab 1:500, automatisch grob): nur der Name.
|
||||
let overview = c.a.auto_coarse && c.a.scale >= OVERVIEW_FROM;
|
||||
// [140] Raumstempel in Tinte (Druck ohne Schwarz-Weiss); Farbe nur aus einer Darstellungsregel
|
||||
// oder aus den Auszeichnungen des Stempel-Texts.
|
||||
let text_color = ov.color.as_deref().unwrap_or(MONO_INK);
|
||||
let (doc, extra_lines) = match &room.stamp {
|
||||
_ if overview => (doc_from_text(room.stamp.as_ref().map_or(&room.name, |s| &s.name)), vec![]),
|
||||
// [140] ab 1:200 auch eigene Stempel ohne Nutzungs-/Personenzeile.
|
||||
Some(s) if small => (room_stamp_to_doc(s), room_stamp_extra_lines(&RoomStamp { show_usage: false, occupancy: None, ..s.clone() }, res.net, room.sia_category)),
|
||||
Some(s) => (room_stamp_to_doc(s), room_stamp_extra_lines(s, res.net, room.sia_category)),
|
||||
None => {
|
||||
let mut lines = vec![StampLine { text: format!("{} m²", to_fixed(res.net, 2)), align: Align::Center }];
|
||||
@@ -619,7 +648,7 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
(room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)), lines)
|
||||
}
|
||||
};
|
||||
out.push(Primitive::Text { at, doc, extra_lines, base_pt: if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, color: color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
|
||||
out.push(Primitive::Text { at, doc, extra_lines, base_pt: if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, color: text_color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,7 +983,15 @@ fn assemble_cached(c: &Ctx, revs: &crate::document::Revs, cc: &mut super::cache:
|
||||
}
|
||||
h ^ cc.drawings.sig.wrapping_mul(0xff51_afd7_ed55_8ccd)
|
||||
};
|
||||
let chunks = super::drawings::plan_drawings_chunked(c, revs.item_stamps("drawings2d").unwrap_or(&[]), &mut cc.drawings, salt, have, &mut bounds)?;
|
||||
// [140] Achsraster enden an der Gebäudegrundfläche: ihr Stand folgt auch Wänden, Körpern und Dächern.
|
||||
let stamps = revs.item_stamps("drawings2d").unwrap_or(&[]);
|
||||
let house_rev = ["walls", "extrudedSolids", "roofs"].iter().fold(0u64, |h, k| (h ^ revs.field(k)).wrapping_mul(0x0000_0100_0000_01b3));
|
||||
let stamps: std::borrow::Cow<[u64]> = if house_rev != 0 && c.p.drawings2d.iter().any(|d| matches!(d.geom, crate::model::Drawing2DGeom::Grid { .. })) {
|
||||
c.p.drawings2d.iter().zip(stamps).map(|(d, &st)| if matches!(d.geom, crate::model::Drawing2DGeom::Grid { .. }) { st ^ house_rev.rotate_left(17) } else { st }).collect::<Vec<_>>().into()
|
||||
} else {
|
||||
stamps.into()
|
||||
};
|
||||
let chunks = super::drawings::plan_drawings_chunked(c, &stamps, &mut cc.drawings, salt, have, &mut bounds)?;
|
||||
for k in 7..11 {
|
||||
put(w, k, &mut segs);
|
||||
}
|
||||
@@ -1000,6 +1037,36 @@ mod tests {
|
||||
};
|
||||
assert_eq!(stamp(100.0), (ROOM_STAMP_PT, 2));
|
||||
assert_eq!(stamp(200.0), (ROOM_STAMP_SMALL_PT, 1));
|
||||
// [140] 1:500 (mittel → automatisch grob): nur der Name; Stempel in Tinte.
|
||||
assert_eq!(stamp(500.0), (ROOM_STAMP_SMALL_PT, 0));
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": 100 }).to_string();
|
||||
let r = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
assert!(r.rooms.iter().all(|q| !matches!(q, Primitive::Text { color, .. } if color != MONO_INK)), "Stempel in Tinte");
|
||||
// Eigener Stempel ab 1:200 ohne Nutzungszeile.
|
||||
let mut q = p.clone();
|
||||
for r in q.rooms.as_mut().unwrap() {
|
||||
r.stamp = Some(RoomStamp { name: r.name.clone(), show_floor_area: true, show_usage: true, occupancy: Some(3.0), ..Default::default() });
|
||||
}
|
||||
let lines = |scale: f64| {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": scale }).to_string();
|
||||
plan_domains(&q, &PlanArgs::parse(1.0, &t).unwrap()).unwrap().rooms.iter().find_map(|q| match q { Primitive::Text { extra_lines, .. } => Some(extra_lines.len()), _ => None }).unwrap()
|
||||
};
|
||||
assert_eq!((lines(100.0), lines(200.0), lines(500.0)), (3, 1, 0));
|
||||
}
|
||||
|
||||
/// [140] „mittel" ab 1:200 wie „grob" (Wände als Sammelfläche), „fein" bleibt; explizit „grob" ohne Stempel.
|
||||
#[test]
|
||||
fn mittel_ab_1_200_automatisch_grob() {
|
||||
assert_eq!(effective_detail(Detail::Mittel, 100.0), (Detail::Mittel, false));
|
||||
assert_eq!(effective_detail(Detail::Mittel, 200.0), (Detail::Grob, true));
|
||||
assert_eq!(effective_detail(Detail::Fein, 500.0), (Detail::Fein, false));
|
||||
assert_eq!(effective_detail(Detail::Grob, 500.0), (Detail::Grob, false));
|
||||
let p = sample();
|
||||
let rooms = |detail: f64| {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": 200 }).to_string();
|
||||
plan_domains(&p, &PlanArgs::parse(detail, &t).unwrap()).unwrap().rooms.iter().filter(|q| matches!(q, Primitive::Text { .. })).count()
|
||||
};
|
||||
assert!(rooms(1.0) > 0 && rooms(0.0) == 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -776,6 +776,8 @@ fn emit_inner(c: &Ctx, d: &Drawing2D, attrs: Attrs, geom: &Drawing2DGeom, greyed
|
||||
em.seg(q[q.len() - 1], q[0]);
|
||||
}
|
||||
}
|
||||
// [140] Übersichtsplan (ab 1:500, Detail „mittel" automatisch grob): keine Masslinien.
|
||||
Drawing2DGeom::Dimension { .. } if c.a.auto_coarse && c.a.scale >= super::domains::OVERVIEW_FROM => {}
|
||||
Drawing2DGeom::Dimension { pts, offset, gap_mm, overshoot_mm, tick_len_mm, text_height_mm, line_weight_mm, ext_weight_mm, tick_weight_mm, text_offsets_mm, refs, kind, arc_center } => {
|
||||
let mm = |x: f64| mm_to_model(x, scale);
|
||||
if let Some(k) = kind {
|
||||
@@ -873,7 +875,9 @@ fn emit_inner(c: &Ctx, d: &Drawing2D, attrs: Attrs, geom: &Drawing2DGeom, greyed
|
||||
}
|
||||
Drawing2DGeom::Grid { bubble_mm, .. } => {
|
||||
if let Some(spec) = crate::grid::Spec::of(geom) {
|
||||
emit_grid(&mut em, &spec, crate::grid::bubble_diameter(*bubble_mm, scale), scale);
|
||||
// [140] Achsen enden an der Gebäudegrundfläche (alle Geschosse vereinigt).
|
||||
let house = super::context::building_rings(p);
|
||||
emit_grid(&mut em, &spec, crate::grid::bubble_diameter(*bubble_mm, scale), scale, &house);
|
||||
}
|
||||
}
|
||||
Drawing2DGeom::Text { at, text: s, height, angle, width, marks, doc, leader_target, leader_bend_points, path_pts, paper_height } => {
|
||||
@@ -1003,7 +1007,7 @@ fn dimension_segment(em: &mut Em, a: Vec2, b: Vec2, offset: f64, st: &DimStyle)
|
||||
}
|
||||
|
||||
/// Achsraster ([112]): Achsen strichpunktiert, an den Enden Blasen mit der Beschriftung.
|
||||
fn emit_grid(em: &mut Em, spec: &crate::grid::Spec, diameter: f64, scale: f64) {
|
||||
fn emit_grid(em: &mut Em, spec: &crate::grid::Spec, diameter: f64, scale: f64, house: &[Vec<Vec2>]) {
|
||||
use crate::grid::Shape;
|
||||
let mm = |x: f64| mm_to_model(x, scale);
|
||||
let dash = [mm(12.0), mm(2.5), mm(1.5), mm(2.5)];
|
||||
@@ -1013,7 +1017,11 @@ fn emit_grid(em: &mut Em, spec: &crate::grid::Spec, diameter: f64, scale: f64) {
|
||||
let text_h = diameter * 0.5;
|
||||
for ax in spec.axes() {
|
||||
match ax.shape {
|
||||
Shape::Line { a, b } => em.line(v(a.0, a.1), v(b.0, b.1), w, Some(&dash), dash_ref),
|
||||
Shape::Line { a, b } => {
|
||||
for (p0, p1) in super::context::outside(v(a.0, a.1), v(b.0, b.1), house) {
|
||||
em.line(p0, p1, w, Some(&dash), dash_ref);
|
||||
}
|
||||
}
|
||||
Shape::Arc { c, r: rad, a0, a1 } => {
|
||||
let dash_v = Some(dash.to_vec());
|
||||
if a1 - a0 >= std::f64::consts::TAU - 1e-9 {
|
||||
@@ -1782,6 +1790,25 @@ mod tests {
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::DrawingArc { r, .. } if (*r - 4.0).abs() < 1e-9)));
|
||||
}
|
||||
|
||||
/// [140] Achsen im Grundriss enden am Gebäude: innerhalb der Gebäudegrundfläche keine Achslinie,
|
||||
/// ausserhalb (bis zu den Blasen) strichpunktiert.
|
||||
#[test]
|
||||
fn achsraster_unterbrochen_im_gebaeude() {
|
||||
let p = project(serde_json::json!({"extrudedSolids": [{"id": "s", "type": "extrudedSolid", "levelId": "eg", "height": 3,
|
||||
"points": [{"x": -1, "y": 1}, {"x": 6, "y": 1}, {"x": 6, "y": 3}, {"x": -1, "y": 3}]}]}));
|
||||
let grid = drawing(serde_json::json!({"shape": "grid", "origin": {"x": 0, "y": 0}, "angle": 0,
|
||||
"a": [{"label": "1", "pos": 0}, {"label": "2", "pos": 5}], "b": [{"label": "A", "pos": 0}, {"label": "B", "pos": 4}], "extend": 1}));
|
||||
let prims = render(&p, grid, 100.0);
|
||||
let segs: Vec<(Vec2, Vec2)> = prims.iter().filter_map(|q| match q { Primitive::Line { a, b, dash: Some(Some(_)), .. } => Some((*a, *b)), _ => None }).collect();
|
||||
// Achsen 1, 2 (senkrecht) je zwei Stücke, A, B (waagrecht, ausserhalb) je eins.
|
||||
assert_eq!(segs.len(), 6, "{segs:?}");
|
||||
for (a, b) in &segs {
|
||||
let m = v((a.x + b.x) / 2.0, (a.y + b.y) / 2.0);
|
||||
assert!(!(m.x > -1.0 && m.x < 6.0 && m.y > 1.0 && m.y < 3.0), "Achse im Gebäude: {a:?} {b:?}");
|
||||
}
|
||||
assert_eq!(prims.iter().filter(|q| matches!(q, Primitive::DrawingCircle { .. })).count(), 8, "Blasen bleiben");
|
||||
}
|
||||
|
||||
/// [112] Raster erscheint in jedem Geschoss, bei `levels` nur in den genannten.
|
||||
#[test]
|
||||
fn achsraster_je_geschoss() {
|
||||
|
||||
@@ -1372,6 +1372,7 @@ fn sheets(cx: &mut Ctx, main: &mut Buf, layer_by_code: &HashMap<&str, String>) {
|
||||
compact: false,
|
||||
mono: false,
|
||||
sun_when: None,
|
||||
auto_coarse: false,
|
||||
};
|
||||
if let Some(entries) = plan_domains_buf(p, &args).ok().and_then(|buf| {
|
||||
let view = View::parse(&buf)?;
|
||||
|
||||
@@ -20,7 +20,8 @@ pub const SITE_PICK_VIEW_SHADOWS: &str = "@viewShadows";
|
||||
|
||||
/// Füllfarbe der Schattenflächen.
|
||||
pub const SUN_SHADOW_FILL: &str = "#3a4a66";
|
||||
const SUN_SHADOW_OPACITY: f64 = 0.28;
|
||||
/// [140] Schatten heller (0.28 → 0.16): Bemassung und Stempel darüber bleiben lesbar.
|
||||
const SUN_SHADOW_OPACITY: f64 = 0.16;
|
||||
/// Linien-Klassen und Füllfarbe des Baurechts.
|
||||
pub const SITE_PARCEL_CLS: &str = "site-parcel";
|
||||
pub const SITE_ALLOWED_CLS: &str = "site-allowed";
|
||||
|
||||
@@ -90,21 +90,25 @@ fn one(spec: &Spec, plane: &Plane, level: &LevelSpec, bounds: [f64; 4], scale: f
|
||||
if x < lo - 1e-9 || x > hi + 1e-9 {
|
||||
continue;
|
||||
}
|
||||
out.push(Primitive::Line {
|
||||
a: v2(x, y0),
|
||||
b: v2(x, y1),
|
||||
cls: "draw2d".into(),
|
||||
weight_mm: AXIS_MM,
|
||||
dash: Some(Some(dash.clone())),
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(INK.into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed: None,
|
||||
opacity: None,
|
||||
});
|
||||
// [140] Ansicht: die Achse läuft nicht über die Fassade, nur Stummel unter und über dem Bild.
|
||||
let spans: &[(f64, f64)] = if level.kind == "elevation" { &[(y0, bounds[1]), (bounds[3], y1)] } else { &[(y0, y1)] };
|
||||
for &(ya, yb) in spans {
|
||||
out.push(Primitive::Line {
|
||||
a: v2(x, ya),
|
||||
b: v2(x, yb),
|
||||
cls: "draw2d".into(),
|
||||
weight_mm: AXIS_MM,
|
||||
dash: Some(Some(dash.clone())),
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(INK.into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed: None,
|
||||
opacity: None,
|
||||
});
|
||||
}
|
||||
let (y, dir) = if bubbles == GridBubbles::Start { (y0, -1.0) } else { (y1, 1.0) };
|
||||
let c = v2(x, y + dir * r);
|
||||
out.push(Primitive::DrawingCircle { center: c, r, fill: "none".into(), stroke: INK.into(), weight_mm: 0.25, dash: None, drawing_id: None, greyed: None, opacity: None });
|
||||
@@ -164,6 +168,11 @@ mod tests {
|
||||
assert!(union_bounds([0.0, 0.0, 9.0, 6.0], &prims)[3] > 6.0);
|
||||
// Ansicht von Süden (y = -3): Achsen 1, 2 stehen senkrecht zur Ebene und erscheinen an ihrer Lage.
|
||||
let level = LevelSpec { kind: "elevation".into(), line: Some([v2(-1.0, -3.0), v2(8.0, -3.0)]), ..Default::default() };
|
||||
assert_eq!(texts(&grid_prims(&p, &level, [0.0, 0.0, 9.0, 6.0], 100.0)), ["1", "2"]);
|
||||
let prims = grid_prims(&p, &level, [0.0, 0.0, 9.0, 6.0], 100.0);
|
||||
assert_eq!(texts(&prims), ["1", "2"]);
|
||||
// [140] In der Ansicht laufen die Achsen nicht über die Fassade: nur Stummel unter und über dem Bild.
|
||||
let lines: Vec<(f64, f64)> = prims.iter().filter_map(|q| if let Primitive::Line { a, b, .. } = q { Some((a.y.min(b.y), a.y.max(b.y))) } else { None }).collect();
|
||||
assert_eq!(lines.len(), 4, "{lines:?}");
|
||||
assert!(lines.iter().all(|(lo, hi)| *hi <= 0.0 + 1e-9 || *lo >= 6.0 - 1e-9), "{lines:?}");
|
||||
}
|
||||
}
|
||||
@@ -64,9 +64,10 @@ fn detail_of(d: DetailLevel) -> Detail {
|
||||
|
||||
/// Plan-Argumente eines Viewports (wie `ViewportPlanSvg`: projektglobal, nicht für den Druck).
|
||||
pub fn viewport_args(snap: &ViewSnapshot, scale: f64) -> PlanArgs {
|
||||
let (detail, auto_coarse) = crate::plan::domains::effective_detail(detail_of(snap.detail), scale);
|
||||
PlanArgs {
|
||||
floor: snap.active_level_id.clone(),
|
||||
detail: detail_of(snap.detail),
|
||||
detail,
|
||||
show: snap.layer_visibility.iter().filter(|(_, v)| **v).map(|(k, _)| k.clone()).collect::<HashSet<String>>(),
|
||||
grey: HashSet::new(),
|
||||
reference_lines: false,
|
||||
@@ -76,6 +77,7 @@ pub fn viewport_args(snap: &ViewSnapshot, scale: f64) -> PlanArgs {
|
||||
compact: false,
|
||||
mono: false,
|
||||
sun_when: None,
|
||||
auto_coarse,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user