[176] Schnittmarke als L (markerStyle, Modelldarstellung sectionMarks); Ansichtsmarker nur flaches Dreieck mit Bezeichnung dahinter
Neu: DrawingLevel.markerStyle (arrow | lAngle) mit Vorgabe ModelViewOption.sectionMarks.style (Ebene > Modelldarstellung > Pfeil). L-Marke: je Ende langer Schenkel (12 mm) längs der Linie, kurzer (6 mm) in Blickrichtung, keine Linie, kein Dreieck, Bezeichnung waagrecht aussen; Knickstücke bleiben. Ansichtsmarker ohne Kreis: Dreieck Basis 6 mm, Höhe 3 mm, Bezeichnung dahinter. UI: Objekt-Info (Schnitt) und Ressourcen-Tab. Goldens: nur Ansichtsmarker.
This commit is contained in:
24 files changed
+355
-173
No files matched your search
@@ -1847,6 +1847,11 @@ pub struct DrawingLevel {
|
||||
#[serde(rename = "bendPoints", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bend_points: Option<Vec<Vec2>>,
|
||||
/// [176] Schnittmarke im Grundriss: "arrow" (Pfeil mit Dreieck, Basis) oder "lAngle" (nur ein L je Ende). Fehlt ⇒ die
|
||||
/// Vorgabe der Modelldarstellung (`sectionMarks.style`), sonst Pfeil. Nur Schnitt.
|
||||
#[serde(rename = "markerStyle", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub marker_style: Option<SectionMarkerStyle>,
|
||||
/// Blickrichtung relativ zur Schnittlinie (nur Schnitt/Ansicht).
|
||||
#[serde(rename = "directionSign", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional, type = "1 | -1")]
|
||||
@@ -2076,11 +2081,42 @@ pub struct ModelViewOption {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub elevation: Option<ModelViewElevation>,
|
||||
/// [176] Schnittmarken im Grundriss.
|
||||
#[serde(rename = "sectionMarks", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub section_marks: Option<ModelViewSectionMarks>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [176] Schnittmarken in der Modelldarstellung (fehlt ⇒ Pfeil).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct ModelViewSectionMarks {
|
||||
/// Markentyp der Schnitte (die Ebene geht vor; Basis: Pfeil).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub style: Option<SectionMarkerStyle>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [176] Markentyp einer Schnittlinie im Grundriss: Pfeil (kräftige Endstücke, dünne Linie, Schenkel mit Dreieck)
|
||||
/// oder nur ein L an jedem Ende (langer Schenkel längs der Linie, kurzer in Blickrichtung, keine Linie dazwischen).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum SectionMarkerStyle {
|
||||
#[default]
|
||||
#[serde(rename = "arrow")]
|
||||
Arrow,
|
||||
#[serde(rename = "lAngle")]
|
||||
LAngle,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [173] Türen in der Modelldarstellung (fehlt ⇒ wie Basis).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
|
||||
@@ -20,8 +20,6 @@ const SECTION_LINE_MARK_MM: f64 = 0.5;
|
||||
const SECTION_LINE_DASH: [f64; 4] = super::line_pattern::SECTION_LINE;
|
||||
/// [176] Beschriftungshöhe in Papier-mm (Modell-Meter = mm · Massstab/1000).
|
||||
const SECTION_LABEL_MM: f64 = 3.5;
|
||||
const VIEW_MARKER_RING_MM: f64 = 0.25;
|
||||
const VIEW_MARKER_MIN_FONT_MM: f64 = 2.4;
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
@@ -833,41 +831,20 @@ pub fn section_label_tag(name: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// [176] Ansichtsmarker als eigenes Symbol: Kreis (Ø 8 mm Papier, 0.25 mm) in der Mitte der Ansichtslinie, gefülltes
|
||||
/// Dreieck in Blickrichtung, Bezeichnung waagrecht im Kreis (verkleinert, wenn nötig) bzw. rechts daneben; Pick-Band
|
||||
/// über dem ganzen Symbol. Keine durchgehende Linie.
|
||||
/// [176] Ansichtsmarker als eigenes Symbol: nur ein flaches gefülltes Dreieck in Blickrichtung (kein Kreis, keine Linie),
|
||||
/// die Bezeichnung waagrecht dahinter (auf der dem Blick abgewandten Seite); Pick-Band über Dreieck und Text.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k: f64, tag: &str, greyed: Option<bool>, obst: &mut super::stamp_place::Obstacles, out: &mut Vec<Primitive>) {
|
||||
let _ = c;
|
||||
let f = crate::plan::misc::view_marker_sized(p0.x, p0.y, p1.x, p1.y, sign, k);
|
||||
let h = SECTION_LABEL_MM * k;
|
||||
let w = crate::text_layout::text_width_em(tag, false) * h;
|
||||
let f = crate::plan::misc::view_marker_sized(p0.x, p0.y, p1.x, p1.y, sign, k, w);
|
||||
if f.is_empty() {
|
||||
return;
|
||||
}
|
||||
let (mut i, mut center, mut r) = (1, v2(0.0, 0.0), 0.0);
|
||||
let mut i = 1;
|
||||
for _ in 0..f[0] as usize {
|
||||
if f[i] == 4.0 {
|
||||
center = v2(f[i + 1], f[i + 2]);
|
||||
r = f[i + 3];
|
||||
for (from, to) in [(v2(center.x + r, center.y), v2(center.x - r, center.y)), (v2(center.x - r, center.y), v2(center.x + r, center.y))] {
|
||||
let arc = Primitive::Arc {
|
||||
center,
|
||||
from,
|
||||
to,
|
||||
r,
|
||||
cls: "section-line".into(),
|
||||
weight_mm: VIEW_MARKER_RING_MM,
|
||||
dash: None,
|
||||
color: Some(SECTION_LINE_INK.into()),
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
};
|
||||
obst.add_prim(&arc);
|
||||
out.push(arc);
|
||||
}
|
||||
i += 4;
|
||||
} else if f[i] == 3.0 {
|
||||
if f[i] == 3.0 {
|
||||
let pts: Vec<Vec2> = (0..3).map(|j| v2(f[i + 1 + 2 * j], f[i + 2 + 2 * j])).collect();
|
||||
let ring: Vec<[f64; 2]> = pts.iter().map(|q| [q.x, q.y]).collect();
|
||||
obst.area(ring);
|
||||
@@ -877,41 +854,33 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
|
||||
}
|
||||
out.push(tri);
|
||||
i += 7;
|
||||
} else if f[i] == 5.0 {
|
||||
let at = v2(f[i + 1], f[i + 2]);
|
||||
i += 3;
|
||||
if !(w > 0.0) {
|
||||
continue;
|
||||
}
|
||||
let pad = 0.1 * h;
|
||||
obst.area(vec![[at.x - pad, at.y - pad], [at.x + w + pad, at.y - pad], [at.x + w + pad, at.y + 0.75 * h + pad], [at.x - pad, at.y + 0.75 * h + pad]]);
|
||||
out.push(Primitive::DrawingText {
|
||||
at,
|
||||
text: tag.to_string(),
|
||||
height_m: h,
|
||||
angle: 0.0,
|
||||
color: SECTION_LINE_INK.into(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
drawing_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
} else {
|
||||
let pts = (0..4).map(|j| v2(f[i + 1 + 2 * j], f[i + 2 + 2 * j])).collect();
|
||||
out.push(pick_band(pts, None, Some(&level.id)));
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
// Bezeichnung: im Kreis, solange sie mit mindestens 2.4 mm Schrift in 1.6 · r passt, sonst rechts neben dem Kreis.
|
||||
let w_em = crate::text_layout::text_width_em(tag, false);
|
||||
if !(w_em > 0.0) {
|
||||
return;
|
||||
}
|
||||
let inner_mm = 1.6 * r / k;
|
||||
let font_mm = SECTION_LABEL_MM.min(inner_mm / w_em);
|
||||
let (h, at) = if font_mm >= VIEW_MARKER_MIN_FONT_MM {
|
||||
let h = font_mm * k;
|
||||
(h, v2(center.x - w_em * h / 2.0, center.y - 0.375 * h))
|
||||
} else {
|
||||
let h = SECTION_LABEL_MM * k;
|
||||
(h, v2(center.x + r + k, center.y - 0.375 * h))
|
||||
};
|
||||
let (w, pad) = (w_em * h, 0.1 * h);
|
||||
obst.area(vec![[at.x - pad, at.y - pad], [at.x + w + pad, at.y - pad], [at.x + w + pad, at.y + 0.75 * h + pad], [at.x - pad, at.y + 0.75 * h + pad]]);
|
||||
out.push(Primitive::DrawingText {
|
||||
at,
|
||||
text: tag.to_string(),
|
||||
height_m: h,
|
||||
angle: 0.0,
|
||||
color: SECTION_LINE_INK.into(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
drawing_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
}
|
||||
|
||||
/// Schnittführungs-Symbole aller Schnitt-/Ansichtsebenen mit Linie (`addSectionLines`).
|
||||
@@ -948,7 +917,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let mut path: Vec<(f64, f64)> = vec![(p0.x, p0.y)];
|
||||
path.extend(level.bend_points.iter().flatten().map(|q| (q.x, q.y)));
|
||||
path.push((p1.x, p1.y));
|
||||
let f = crate::plan::misc::section_polyline_sized(&path, sign, k, label_w);
|
||||
let f = crate::plan::misc::section_polyline_styled(&path, sign, k, label_w, c.mv().section_marker(level.marker_style));
|
||||
if f.is_empty() {
|
||||
continue;
|
||||
}
|
||||
@@ -1155,10 +1124,10 @@ mod tests {
|
||||
assert!(d.bounds.is_some_and(|b| b[3] >= top - 1e-9), "{:?} < {top}", d.bounds);
|
||||
}
|
||||
|
||||
/// [176] Ansichtsmarker: Kreis (Ø 8 mm Papier) mit gefülltem Dreieck in Blickrichtung und Bezeichnung im Kreis,
|
||||
/// keine durchgehende Linie; Pick-Band trägt die Ebenen-ID.
|
||||
/// [176] Ansichtsmarker: nur flaches gefülltes Dreieck (Basis 6 mm, Höhe 3 mm) in Blickrichtung, Bezeichnung waagrecht
|
||||
/// dahinter (gegen den Blick), kein Kreis, keine Linie; Pick-Band trägt die Ebenen-ID.
|
||||
#[test]
|
||||
fn ansichtsmarker_ist_kreis_mit_pfeil_und_bezeichnung() {
|
||||
fn ansichtsmarker_ist_dreieck_mit_bezeichnung() {
|
||||
let p = Project {
|
||||
drawing_levels: vec![serde_json::from_value(serde_json::json!({ "id": "n", "name": "Ansicht Süd", "kind": "elevation", "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 0.0, "y": -2.0 }, { "x": 10.0, "y": -2.0 }] })).unwrap()],
|
||||
@@ -1167,18 +1136,49 @@ mod tests {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(&p, &a), &mut out);
|
||||
assert!(!out.iter().any(|q| matches!(q, Primitive::Line { .. })), "keine Linie");
|
||||
let arcs: Vec<f64> = out.iter().filter_map(|q| match q { Primitive::Arc { r, center, .. } => { assert!((center.x - 5.0).abs() < 1e-9 && (center.y + 2.0).abs() < 1e-9); Some(*r) } _ => None }).collect();
|
||||
assert_eq!(arcs.len(), 2);
|
||||
assert!((arcs[0] - 0.4).abs() < 1e-9, "Ø 8 mm bei 1:100 = r 0.4 m, ist {}", arcs[0]);
|
||||
assert!(!out.iter().any(|q| matches!(q, Primitive::Line { .. } | Primitive::Arc { .. })), "keine Linie, kein Kreis");
|
||||
let tri = out.iter().find_map(|q| match q { Primitive::Polygon { pts, fill, .. } if fill != "none" => Some(pts.clone()), _ => None }).unwrap();
|
||||
// Blickrichtung +y (Linie von links nach rechts, Vorzeichen 1): Spitze oberhalb des Kreises.
|
||||
assert!(tri[0].y > -2.0 + 0.4, "{tri:?}");
|
||||
// Blickrichtung +y (Linie von links nach rechts, Vorzeichen 1): Spitze 3 mm · 100 = 0.3 m über der Linie, Basis 0.6 m breit.
|
||||
assert!((tri[0].y - (-2.0 + 0.3)).abs() < 1e-9 && (tri[0].x - 5.0).abs() < 1e-9, "{tri:?}");
|
||||
assert!(((tri[1].x - tri[2].x).abs() - 0.6).abs() < 1e-9, "{tri:?}");
|
||||
assert!(out.iter().any(|q| matches!(q, Primitive::Polygon { section_line_id: Some(id), .. } if id == "n")));
|
||||
let t = out.iter().find_map(|q| match q { Primitive::DrawingText { at, text, height_m, .. } => Some((*at, text.clone(), *height_m)), _ => None }).unwrap();
|
||||
assert_eq!(t.1, "Süd");
|
||||
// Text hinter der Basis (unterhalb der Linie), waagrecht um die Mitte, ohne das Dreieck zu überlappen.
|
||||
let w = crate::text_layout::text_width_em("Süd", false) * t.2;
|
||||
assert!(t.0.x > 5.0 - 0.4 && t.0.x + w < 5.0 + 0.4, "Text im Kreis: {t:?}");
|
||||
assert!(t.0.y + 0.75 * t.2 < -2.0 && ((t.0.x + w / 2.0) - 5.0).abs() < 1e-9, "{t:?}");
|
||||
}
|
||||
|
||||
/// [176] Schnittmarke als L: Ebenenfeld `markerStyle` bzw. Vorgabe der Modelldarstellung (`sectionMarks.style`);
|
||||
/// Ebene > Modelldarstellung > Pfeil. L: keine dünne Linie, kein Dreieck.
|
||||
#[test]
|
||||
fn schnittmarke_als_l_nach_ebene_und_modelldarstellung() {
|
||||
let mk = |style: Option<&str>| -> Project {
|
||||
let mut lv = serde_json::json!({ "id": "s", "name": "Schnitt A-A", "kind": "section", "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 0.0, "y": 0.0 }, { "x": 10.0, "y": 0.0 }] });
|
||||
if let Some(st) = style {
|
||||
lv["markerStyle"] = st.into();
|
||||
}
|
||||
let mut p = Project { drawing_levels: vec![serde_json::from_value(lv).unwrap()], ..Default::default() };
|
||||
p.model_view_options = Some(vec![serde_json::from_value(serde_json::json!({ "id": "m", "name": "M", "sectionMarks": { "style": "lAngle" } })).unwrap()]);
|
||||
p
|
||||
};
|
||||
let run = |p: &Project, mv: bool| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
};
|
||||
let is_l = |out: &[Primitive]| !out.iter().any(|q| matches!(q, Primitive::Line { dash: Some(_), .. })) && !out.iter().any(|q| matches!(q, Primitive::Polygon { fill, .. } if fill != "none"));
|
||||
let heavy = |out: &[Primitive]| out.iter().filter(|q| matches!(q, Primitive::Line { weight_mm, .. } if *weight_mm > 0.4)).count();
|
||||
assert!(!is_l(&run(&mk(None), false)), "Basis = Pfeil");
|
||||
assert!(!is_l(&run(&mk(None), false)));
|
||||
let l = run(&mk(Some("lAngle")), false);
|
||||
assert!(is_l(&l));
|
||||
assert_eq!(heavy(&l), 4, "je Ende zwei Schenkel");
|
||||
assert_eq!(l.iter().filter(|q| matches!(q, Primitive::DrawingText { .. })).count(), 2);
|
||||
assert!(is_l(&run(&mk(None), true)), "Vorgabe der Modelldarstellung");
|
||||
assert!(!is_l(&run(&mk(Some("arrow")), true)), "Ebene geht vor");
|
||||
}
|
||||
|
||||
/// [176] Geknickter Schnitt: Knickpunkte aus `bendPoints` erscheinen als kräftige Stücke im Grundriss; ohne
|
||||
|
||||
+120
-28
@@ -15,7 +15,10 @@
|
||||
//! 5 label [5, x, y] (unten links; Kurz-Tag setzt der Aufrufer)
|
||||
//! 1 polygon [1, x0, y0 … x3, y3] (unsichtbares Pick-Band)
|
||||
//! ```
|
||||
//! Ansicht ([176]): `view_marker_sized` → `[3, 4 circle [4, cx, cy, r], 3 triangle, 1 polygon]`.
|
||||
//! L-Marke ([176], `SectionMarkerStyle::LAngle`): `section_polyline_styled(.., LAngle)` → je Ende zwei kräftige Linien
|
||||
//! (langer Schenkel längs der Linie nach innen, kurzer in Blickrichtung), Label, an Knicken Knickstücke; keine Linie dazwischen,
|
||||
//! kein Dreieck, Pick-Band je Segment.
|
||||
//! Ansicht ([176]): `view_marker_sized` → `[n, 3 triangle (flach), 5 label, 1 polygon]`, kein Kreis.
|
||||
//!
|
||||
//! ## Linienende
|
||||
//! `end_mark(x, y, dx, dy, art, mm, massstab)` → `[verkuerzung, n, Eintrag × n]` (leer = nichts):
|
||||
@@ -28,6 +31,7 @@
|
||||
|
||||
use crate::jsmath::hypot2;
|
||||
use crate::jsnum::round;
|
||||
use crate::model::SectionMarkerStyle;
|
||||
use std::collections::HashSet;
|
||||
|
||||
const FOOTPRINT_Z_TOL: f64 = 0.6;
|
||||
@@ -39,10 +43,12 @@ const SECTION_HEAD_LEN_MM: f64 = 3.5;
|
||||
const SECTION_HEAD_HALF_MM: f64 = 1.3;
|
||||
const SECTION_LABEL_MM: f64 = 3.5;
|
||||
const SECTION_PICK_HALF: f64 = 0.3;
|
||||
/// [176] Ansichtsmarker: Kreis Ø 8 mm, Pfeilspitze 3.5 mm lang und 3.2 mm breit.
|
||||
pub const VIEW_MARKER_R_MM: f64 = 4.0;
|
||||
const VIEW_MARKER_TIP_MM: f64 = 3.5;
|
||||
const VIEW_MARKER_HALF_MM: f64 = 1.6;
|
||||
/// [176] L-Marke: langer Schenkel längs der Linie, kurzer in Blickrichtung.
|
||||
const L_LONG_MM: f64 = 12.0;
|
||||
const L_SHORT_MM: f64 = 6.0;
|
||||
/// [176] Ansichtsmarker: flaches gefülltes Dreieck, Basis 6 mm, Höhe 3 mm in Blickrichtung.
|
||||
const VIEW_MARKER_HEIGHT_MM: f64 = 3.0;
|
||||
const VIEW_MARKER_HALF_MM: f64 = 3.0;
|
||||
const ARROW_ASPECT: f64 = 0.32;
|
||||
|
||||
/// Ganzzahl-Schlüssel für die Quantisierung; NaN/∞ bekommen feste Platzhalter (wie ihre Textform in JS).
|
||||
@@ -162,6 +168,15 @@ pub fn section_line_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm:
|
||||
/// Stücke (6 mm) auf beiden Seiten; Schenkel/Dreieck/Beschriftung an den Enden gehören zum ersten bzw. letzten
|
||||
/// Segment; je Segment ein Pick-Band. Mit zwei Punkten identisch zur geraden Linie. Segmente unter 1 µm entfallen.
|
||||
pub fn section_polyline_sized(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f64) -> Vec<f64> {
|
||||
section_polyline_styled(pts, sign, mm, label_w, SectionMarkerStyle::Arrow)
|
||||
}
|
||||
|
||||
/// [176] Wie [`section_polyline_sized`] mit Markentyp: `Arrow` = bisher; `LAngle` = an jedem Ende ein L (langer Schenkel
|
||||
/// 12 mm längs der Linie nach innen, kurzer 6 mm in Blickrichtung, beide kräftig), keine Linie dazwischen und kein Dreieck;
|
||||
/// die Beschriftung steht waagrecht neben dem Ende des kurzen Schenkels, ausserhalb der Linie. An Knicken die
|
||||
/// Knickstücke wie beim Pfeil.
|
||||
pub fn section_polyline_styled(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f64, style: SectionMarkerStyle) -> Vec<f64> {
|
||||
let l_angle = style == SectionMarkerStyle::LAngle;
|
||||
if pts.len() < 2 || !pts.iter().all(|p| p.0.is_finite() && p.1.is_finite()) || ![sign, mm, label_w].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -194,12 +209,33 @@ pub fn section_polyline_sized(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f
|
||||
let len = hypot2(b.0 - a.0, b.1 - a.1);
|
||||
let ps = (if i == 0 { SECTION_END_PIECE_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0);
|
||||
let pe = (if i == segs - 1 { SECTION_END_PIECE_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0);
|
||||
if l_angle {
|
||||
// Langer Schenkel am Ende (12 mm), Knickstücke (6 mm) an den Knicken; dazwischen nichts.
|
||||
let (ps, pe) = ((if i == 0 { L_LONG_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0), (if i == segs - 1 { L_LONG_MM } else { SECTION_BEND_PIECE_MM } * mm).min(len / 3.0));
|
||||
line(&mut o, &mut n, 1.0, a, (a.0 + ux * ps, a.1 + uy * ps));
|
||||
line(&mut o, &mut n, 1.0, (b.0 - ux * pe, b.1 - uy * pe), b);
|
||||
continue;
|
||||
}
|
||||
line(&mut o, &mut n, 1.0, a, (a.0 + ux * ps, a.1 + uy * ps));
|
||||
line(&mut o, &mut n, 0.0, (a.0 + ux * ps, a.1 + uy * ps), (b.0 - ux * pe, b.1 - uy * pe));
|
||||
line(&mut o, &mut n, 1.0, (b.0 - ux * pe, b.1 - uy * pe), b);
|
||||
}
|
||||
if l_angle {
|
||||
let short = L_SHORT_MM * mm;
|
||||
for (end, (ux, uy), outward) in [(pts[0], dirs[0], -1.0), (pts[segs], dirs[segs - 1], 1.0)] {
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let tip = (end.0 + bnx * short, end.1 + bny * short);
|
||||
line(&mut o, &mut n, 1.0, end, tip);
|
||||
// Beschriftung neben dem Ende des kurzen Schenkels, nach aussen (längs der Linie, vom Ende weg).
|
||||
let (ox, oy) = (ux * outward, uy * outward);
|
||||
let reach = mm * 1.0 + ox.abs() * label_w / 2.0 + oy.abs() * label_h / 2.0;
|
||||
let (cx, cy) = (tip.0 + ox * reach, tip.1 + oy * reach);
|
||||
o.extend([5.0, cx - label_w / 2.0, cy - label_h / 2.0]);
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
let (head_l, head_hw) = (SECTION_HEAD_LEN_MM * mm, SECTION_HEAD_HALF_MM * mm);
|
||||
for (end, (ux, uy)) in [(pts[0], dirs[0]), (pts[segs], dirs[segs - 1])] {
|
||||
for (end, (ux, uy)) in if l_angle { vec![] } else { vec![(pts[0], dirs[0]), (pts[segs], dirs[segs - 1])] } {
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let tip = (end.0 + bnx * leg, end.1 + bny * leg);
|
||||
line(&mut o, &mut n, 1.0, end, tip);
|
||||
@@ -225,12 +261,14 @@ pub fn section_polyline_sized(pts: &[(f64, f64)], sign: f64, mm: f64, label_w: f
|
||||
out
|
||||
}
|
||||
|
||||
/// [176] Ansichtsmarker (eigenes Symbol statt Schnittlinie): Kreis (Ø 8 mm Papier) in der Mitte der Ansichtslinie
|
||||
/// `p0`–`p1`, daran ein gefülltes Dreieck in Blickrichtung (`sign` wie bei der Schnittlinie). `mm` = Modell-Meter je
|
||||
/// Papier-mm. Ergebnis `[n, Eintrag × n]` mit `4 circle [4, cx, cy, r]`, `3 triangle` und `1 polygon` (Pick-Band);
|
||||
/// die Bezeichnung setzt der Aufrufer. Leer bei zu kurzer Linie oder Unsinn.
|
||||
pub fn view_marker_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm: f64) -> Vec<f64> {
|
||||
if ![p0x, p0y, p1x, p1y, sign, mm].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
/// [176] Ansichtsmarker (eigenes Symbol statt Schnittlinie): nur ein flaches gefülltes Dreieck (Basis 6 mm, Höhe 3 mm
|
||||
/// Papier) in Blickrichtung (`sign` wie bei der Schnittlinie) mit der Basis in der Mitte der Ansichtslinie `p0`–`p1`,
|
||||
/// dahinter (auf der dem Blick abgewandten Seite) waagrecht die Bezeichnung (Breite `label_w`, Schrift
|
||||
/// `SECTION_LABEL_MM · mm`). `mm` = Modell-Meter je Papier-mm. Ergebnis `[n, Eintrag × n]` mit `3 triangle`,
|
||||
/// `5 label [5, x, y]` (unten links) und `1 polygon` (Pick-Band über Dreieck und Text). Kein Kreis, keine Linie.
|
||||
/// Leer bei zu kurzer Linie oder Unsinn.
|
||||
pub fn view_marker_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm: f64, label_w: f64) -> Vec<f64> {
|
||||
if ![p0x, p0y, p1x, p1y, sign, mm, label_w].iter().all(|x| x.is_finite()) || !(mm > 0.0) {
|
||||
return Vec::new();
|
||||
}
|
||||
let (ax, ay) = (p1x - p0x, p1y - p0y);
|
||||
@@ -241,15 +279,21 @@ pub fn view_marker_sized(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64, mm:
|
||||
let (ux, uy) = (ax / len, ay / len);
|
||||
let (bnx, bny) = (-uy * sign, ux * sign);
|
||||
let (cx, cy) = ((p0x + p1x) / 2.0, (p0y + p1y) / 2.0);
|
||||
let r = VIEW_MARKER_R_MM * mm;
|
||||
let (tip_l, hw) = (VIEW_MARKER_TIP_MM * mm, VIEW_MARKER_HALF_MM * mm);
|
||||
let base = (cx + bnx * r, cy + bny * r);
|
||||
let tip = (base.0 + bnx * tip_l, base.1 + bny * tip_l);
|
||||
let mut o = vec![4.0, cx, cy, r];
|
||||
o.extend([3.0, tip.0, tip.1, base.0 + ux * hw, base.1 + uy * hw, base.0 - ux * hw, base.1 - uy * hw]);
|
||||
let back = (cx - bnx * r, cy - bny * r);
|
||||
let (tip_l, hw) = (VIEW_MARKER_HEIGHT_MM * mm, VIEW_MARKER_HALF_MM * mm);
|
||||
let tip = (cx + bnx * tip_l, cy + bny * tip_l);
|
||||
let mut o = vec![3.0, tip.0, tip.1, cx + ux * hw, cy + uy * hw, cx - ux * hw, cy - uy * hw];
|
||||
// Bezeichnung hinter der Basis (gegen die Blickrichtung): Mitte im Abstand 1 mm + halbe Kastenausdehnung.
|
||||
let label_h = SECTION_LABEL_MM * mm * 0.75;
|
||||
let ext = bnx.abs() * label_w / 2.0 + bny.abs() * label_h / 2.0;
|
||||
let reach = mm * 1.0 + ext;
|
||||
let (lx, ly) = (cx - bnx * reach, cy - bny * reach);
|
||||
o.extend([5.0, lx - label_w / 2.0, ly - label_h / 2.0]);
|
||||
// Pick-Band: orientiertes Rechteck von der Rückseite des Textes bis zur Spitze, breit genug für Dreieck und Text.
|
||||
let back_d = reach + ext;
|
||||
let half_u = hw.max(ux.abs() * label_w / 2.0 + uy.abs() * label_h / 2.0);
|
||||
let back = (cx - bnx * back_d, cy - bny * back_d);
|
||||
o.push(1.0);
|
||||
o.extend([back.0 + ux * r, back.1 + uy * r, tip.0 + ux * r, tip.1 + uy * r, tip.0 - ux * r, tip.1 - uy * r, back.0 - ux * r, back.1 - uy * r]);
|
||||
o.extend([back.0 + ux * half_u, back.1 + uy * half_u, tip.0 + ux * half_u, tip.1 + uy * half_u, tip.0 - ux * half_u, tip.1 - uy * half_u, back.0 - ux * half_u, back.1 - uy * half_u]);
|
||||
let mut out = vec![3.0];
|
||||
out.extend(o);
|
||||
out
|
||||
@@ -347,16 +391,64 @@ mod tests {
|
||||
assert_eq!(f[0], 10.0);
|
||||
}
|
||||
|
||||
/// [176] Ansichtsmarker: Kreis Ø 8 mm in der Linienmitte, Dreieck in Blickrichtung, kein Linienstück.
|
||||
/// [176] Ansichtsmarker: nur flaches Dreieck (Basis 6 mm, Höhe 3 mm) in Blickrichtung, Bezeichnung dahinter, Pick-Band.
|
||||
#[test]
|
||||
fn ansichtsmarker_kreis_dreieck_pick() {
|
||||
let f = view_marker_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2);
|
||||
fn ansichtsmarker_dreieck_label_pick() {
|
||||
let f = view_marker_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0);
|
||||
// Dreieck, Label, Pick (kein Kreis).
|
||||
assert_eq!(f[0], 3.0);
|
||||
assert_eq!(f[1..5], [4.0, 5.0, 0.0, 0.8]);
|
||||
// Dreieck: Spitze 0.8 + 0.7 m in +y (Blickrichtung bei sign 1).
|
||||
assert!((f[6] - 5.0).abs() < 1e-12 && (f[7] - 1.5).abs() < 1e-12);
|
||||
assert!(view_marker_sized(0.0, 0.0, 0.0, 0.0, 1.0, 0.2).is_empty());
|
||||
assert!(view_marker_sized(f64::NAN, 0.0, 1.0, 0.0, 1.0, 0.2).is_empty());
|
||||
assert_eq!(f[1], 3.0);
|
||||
// Spitze: Mitte (5, 0) + 3 mm · 0.2 in +y; Basis ± 3 mm · 0.2 längs der Linie.
|
||||
let near = |x: &[f64], y: &[f64]| x.iter().zip(y).all(|(a, b)| (a - b).abs() < 1e-9);
|
||||
assert!(near(&f[2..8], &[5.0, 0.6, 5.6, 0.0, 4.4, 0.0]), "{:?}", &f[2..8]);
|
||||
// Label hinter der Basis (y < 0), waagrecht um x = 5 zentriert, ohne das Dreieck zu berühren.
|
||||
assert_eq!(f[8], 5.0);
|
||||
let label_h = 3.5 * 0.2 * 0.75;
|
||||
assert!((f[9] - 4.5).abs() < 1e-9 && f[10] + 0.0 < 0.0 && f[10] + label_h <= -0.2 + 1e-9, "{:?}", &f[8..11]);
|
||||
assert_eq!(f[11], 1.0);
|
||||
assert!(view_marker_sized(0.0, 0.0, 0.0, 0.0, 1.0, 0.2, 1.0).is_empty());
|
||||
assert!(view_marker_sized(f64::NAN, 0.0, 1.0, 0.0, 1.0, 0.2, 1.0).is_empty());
|
||||
}
|
||||
|
||||
/// [176] L-Marke: je Ende zwei kräftige Linien (12 mm längs der Linie nach innen, 6 mm in Blickrichtung), keine
|
||||
/// dünne Linie, kein Dreieck; Label ausserhalb neben dem kurzen Schenkel; Pick-Band je Segment.
|
||||
#[test]
|
||||
fn l_marke_zwei_schenkel_je_ende_ohne_linie() {
|
||||
let f = section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::LAngle);
|
||||
// 2 × (langer + kurzer Schenkel + Label) + 1 Pick = 7
|
||||
assert_eq!(f[0], 7.0);
|
||||
let near = |x: &[f64], y: &[f64]| x.iter().zip(y).all(|(a, b)| (a - b).abs() < 1e-9);
|
||||
assert!(near(&f[1..7], &[2.0, 1.0, 0.0, 0.0, 2.4, 0.0]), "lang links");
|
||||
assert!(near(&f[7..13], &[2.0, 1.0, 7.6, 0.0, 10.0, 0.0]), "lang rechts");
|
||||
assert!(near(&f[13..19], &[2.0, 1.0, 0.0, 0.0, 0.0, 1.2]), "kurz links");
|
||||
// Label links: ausserhalb (x < 0) auf Höhe des kurzen Schenkels (y ≈ 1.2).
|
||||
assert_eq!(f[19], 5.0);
|
||||
assert!(f[20] + 1.0 < 0.0 && (f[21] + 3.5 * 0.2 * 0.75 / 2.0 - 1.2).abs() < 1e-9, "{:?}", &f[19..22]);
|
||||
// Weder dünne Linie (art 0) noch Dreieck (3).
|
||||
let mut i = 1;
|
||||
for _ in 0..7 {
|
||||
match f[i] {
|
||||
2.0 => {
|
||||
assert_eq!(f[i + 1], 1.0);
|
||||
i += 6;
|
||||
}
|
||||
5.0 => i += 3,
|
||||
1.0 => i += 9,
|
||||
t => panic!("unerwarteter Eintrag {t}"),
|
||||
}
|
||||
}
|
||||
// Pfeil unverändert.
|
||||
assert_eq!(section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::Arrow), section_line_sized(0.0, 0.0, 10.0, 0.0, 1.0, 0.2, 1.0));
|
||||
}
|
||||
|
||||
/// [176] L-Marke mit Knick: Knickstücke (6 mm) bleiben, Schenkel nur an den Enden.
|
||||
#[test]
|
||||
fn l_marke_geknickt_behaelt_knickstuecke() {
|
||||
let f = section_polyline_styled(&[(0.0, 0.0), (10.0, 0.0), (10.0, 8.0)], 1.0, 0.2, 1.0, SectionMarkerStyle::LAngle);
|
||||
// 4 Endstücke/Knickstücke je Segment 2 = 4, 2 kurze Schenkel, 2 Label, 2 Pick = 10
|
||||
assert_eq!(f[0], 10.0);
|
||||
let near = |x: &[f64], y: &[f64]| x.iter().zip(y).all(|(a, b)| (a - b).abs() < 1e-9);
|
||||
assert!(near(&f[7..13], &[2.0, 1.0, 8.8, 0.0, 10.0, 0.0]));
|
||||
}
|
||||
|
||||
/// [176] Fixe Papiergrösse: Schenkel 8 mm, Endstück 12 mm; Ansicht ohne kräftige Endstücke.
|
||||
|
||||
@@ -240,6 +240,8 @@ pub struct Options {
|
||||
pub elevation: ElevOpts,
|
||||
pub floor_finish_mv: Option<FloorFinishDisplay>,
|
||||
pub terrain_mv: Option<bool>,
|
||||
/// [176] Markentyp der Schnitte laut Modelldarstellung (die Ebene geht vor, s. [`Options::section_marker`]).
|
||||
pub section_marker_mv: Option<SectionMarkerStyle>,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@@ -255,6 +257,10 @@ impl Options {
|
||||
pub fn terrain(&self, level: Option<bool>) -> Option<bool> {
|
||||
level.or(self.terrain_mv)
|
||||
}
|
||||
/// [176] Schnittmarke: Ebene > Modelldarstellung > Pfeil.
|
||||
pub fn section_marker(&self, level: Option<SectionMarkerStyle>) -> SectionMarkerStyle {
|
||||
level.filter(|s| *s != SectionMarkerStyle::Unknown).or(self.section_marker_mv).unwrap_or(SectionMarkerStyle::Arrow)
|
||||
}
|
||||
/// Schlagschatten der Ansicht: Ebene > Modelldarstellung > aus.
|
||||
pub fn shadows(&self, level: Option<bool>) -> bool {
|
||||
level.or(self.elevation.shadows_mv).unwrap_or(false)
|
||||
@@ -395,6 +401,7 @@ pub fn resolve(mv: Option<&ModelViewOption>, detail: Detail, scale: f64) -> Opti
|
||||
elevation: ElevOpts { shadows_mv: el.and_then(|e| e.shadows), material_hatch: el.and_then(|e| e.material_hatch).unwrap_or(true) },
|
||||
floor_finish_mv: mv.and_then(|m| m.slabs.as_ref()).and_then(|s| s.floor_finish).filter(|f| *f != FloorFinishDisplay::Unknown),
|
||||
terrain_mv: mv.and_then(|m| m.site.as_ref()).and_then(|s| s.terrain),
|
||||
section_marker_mv: mv.and_then(|m| m.section_marks.as_ref()).and_then(|s| s.style).filter(|s| *s != SectionMarkerStyle::Unknown),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user