diff --git a/TODO.md b/TODO.md index 0922fa2d..97b9ee23 100644 --- a/TODO.md +++ b/TODO.md @@ -459,9 +459,13 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* - ◐ **[179]** Leistung messen und gezielt optimieren (11.11.2026, Linux-Container, `bench159`, Musterhaus komplex, Mittel ms). Erledigt: Raster-Hindernisse (Masse/Koten, Zeichnungen, Achsblasen) und Gebäuderinge je Plan einmal im `Ctx` statt je Raster und je Aufrufer neu; Masse/Koten und Zeichnungen in einem Durchgang. eg 1:100 83→57, 1:50 90→~62, mit Schatten 116→~90, - Schnittlinien 14.6→6.8, Zeichnungen 11.9→10; Wand verschieben + Plan 90→65 / 67→43. Goldens byte-gleich. Offen (grösste - Fresser): Kontext/Gelände 25 ms (Cache-Treffer klont 29–35k Primitive mit Strings, 6–25 ms: `cls`/`color` als `Rc` - oder gepufferte Treffer), Schatten 30 ms, Räume/Stempel 1:50 14 ms, Kleine Änderung baut den Plan noch voll (kein Teil-Cache). Mac nicht gemessen. · M + Schnittlinien 14.6→6.8, Zeichnungen 11.9→10; Wand verschieben + Plan 90→65 / 67→43. Goldens byte-gleich. + Etappe 2 (11.11., Container, Mittel ≥3 Läufe, ohne LTO gebaut): `Primitive` von 952 auf 400 Byte (Schraffur im Polygon als + `Box`), `cls`/`color` der Linien/Bögen als geteilte `Sstr` (Arc, Clone = Zähler); Cache-Treffer der Höhenlinien + reserviert Luft (vorher verdoppelte das Anhängen der Pick-Flächen den 30k-Puffer: 16 ms). Kontext/Gelände 1:100 24→4 ms, + 1:50 18→6, mit Schatten 22→7; eg 1:100 61→41, 1:50 65→43, mit Schatten 88→83 (Maschine ausgelastet, Schatten schwankt). JSON/Puffer + byte-gleich (Goldens ungeändert). Offen: Schatten/Baurecht 25–40 ms, Räume/Stempel 1:50 11–15 ms, kleine Änderung baut den Plan noch voll + (kein Teil-Cache; Gelände-Höhenlinien bei geändertem Hindernis-Schlüssel neu: ~35 ms). Mac nicht gemessen. · M - ◐ **[58]** Inkrementelle Ableitung. 3D ist inkrementell; Schnitt/Ansicht (~100 ms) und Plan-Szene (`planToRenderScene` ~30 ms) noch voll; Gehrung über alle Wände je Update (~9 ms); Explosion ohne Cache; Upload/Frame mit echter GPU nicht gemessen. · L diff --git a/src-tauri/core/src/plan/buf.rs b/src-tauri/core/src/plan/buf.rs index 5ebdcd90..39dc7626 100644 --- a/src-tauri/core/src/plan/buf.rs +++ b/src-tauri/core/src/plan/buf.rs @@ -891,7 +891,7 @@ impl<'a> View<'a> { fill: self.opt_string(f[0])?.unwrap_or_default(), stroke: self.opt_string(f[1])?.unwrap_or_default(), stroke_width_mm: f[2], - hatch: if f[3] == -1.0 { crate::plan::style::no_hatch() } else { hatches.get(whole(f[3])?)?.clone() }, + hatch: if f[3] == -1.0 { Box::new(crate::plan::style::no_hatch()) } else { Box::new(hatches.get(whole(f[3])?)?.clone()) }, greyed, opacity: opt(fl, F_OPACITY, f[4]), no_stroke_edges: match rec.nse { @@ -913,7 +913,7 @@ impl<'a> View<'a> { T_LINE => Primitive::Line { a: v(f[4], f[5]), b: v(f[6], f[7]), - cls: self.opt_string(f[0])?.unwrap_or_default(), + cls: self.opt_string(f[0])?.unwrap_or_default().into(), weight_mm: f[2], dash, zigzag: rec.zigzag.map(|(amplitude, wavelength)| LineStyleZigzag { amplitude, wavelength, ..Default::default() }), @@ -921,7 +921,7 @@ impl<'a> View<'a> { Some((length, o, n)) => Some(LineStyleMotif { points: to_vec2(self.pool_pts(o, n)?), length, ..Default::default() }), None => None, }, - color: if fl & F_COLOR != 0 { self.opt_string(f[1])? } else { None }, + color: if fl & F_COLOR != 0 { self.opt_string(f[1])?.map(Into::into) } else { None }, drawing_id, opening_id, stair_id, @@ -933,10 +933,10 @@ impl<'a> View<'a> { from: v(f[6], f[7]), to: v(f[8], f[9]), r: f[10], - cls: self.opt_string(f[0])?.unwrap_or_default(), + cls: self.opt_string(f[0])?.unwrap_or_default().into(), weight_mm: f[2], dash, - color: if fl & F_COLOR != 0 { self.opt_string(f[1])? } else { None }, + color: if fl & F_COLOR != 0 { self.opt_string(f[1])?.map(Into::into) } else { None }, opening_id, stair_id, greyed, @@ -2258,7 +2258,7 @@ pub(crate) mod tests { fill: "#fff".into(), stroke: "none".into(), stroke_width_mm: 0.35, - hatch: hatch(), + hatch: Box::new(hatch()), greyed: Some(true), opacity: Some(0.5), no_stroke_edges: Some(vec![1.0, 2.0]), @@ -2279,7 +2279,7 @@ pub(crate) mod tests { fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: f64::NAN, - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed: Some(false), opacity: None, no_stroke_edges: None, diff --git a/src-tauri/core/src/plan/context.rs b/src-tauri/core/src/plan/context.rs index e7c84663..9f847b57 100644 --- a/src-tauri/core/src/plan/context.rs +++ b/src-tauri/core/src/plan/context.rs @@ -35,7 +35,7 @@ pub(super) fn pick_band(pts: Vec, context_id: Option<&str>, section_id: Op fill: "none".into(), stroke: "none".into(), stroke_width_mm: 0.0, - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed: None, opacity: None, no_stroke_edges: None, @@ -225,7 +225,7 @@ pub(super) fn restyle_lines(p: &Project, a: &super::overrides::Actions, prims: & match q { Primitive::Line { color, weight_mm, dash: d, .. } => { if let Some(c) = &a.color { - *color = Some(c.clone()); + *color = Some(c.clone().into()); } if let Some(w) = a.lineweight.filter(|w| w.is_finite() && *w >= 0.0) { *weight_mm = w; @@ -595,6 +595,8 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec, house: & } let key: LinesKey = (st.key, iv.to_bits(), every, c.a.scale.max(1.0).to_bits(), h.finish(), obst.sig()); if let Some(v) = CONTOUR_LINES.with(|m| m.borrow().iter().find(|(k, _)| *k == key).map(|(_, v)| v.clone())) { + // [179] Mit Luft: sonst verdoppelt das spätere Anhängen (Pick-Flächen) den ganzen Puffer (~20 MB kopieren). + out.reserve(v.len() + 4096); out.extend(v.iter().cloned()); return; } diff --git a/src-tauri/core/src/plan/domains.rs b/src-tauri/core/src/plan/domains.rs index cfd68aa5..cb6dde19 100644 --- a/src-tauri/core/src/plan/domains.rs +++ b/src-tauri/core/src/plan/domains.rs @@ -317,7 +317,7 @@ pub(super) fn polygon(pts: Vec, fill: &str, stroke: &str, w: f64, hatch: H fill: fill.into(), stroke: stroke.into(), stroke_width_mm: w, - hatch, + hatch: Box::new(hatch), greyed, opacity: None, no_stroke_edges, @@ -1512,7 +1512,7 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec) { dash: None, zigzag: None, motif: None, - color: Some(stroke.to_string()), + color: Some(stroke.to_string().into()), drawing_id: None, opening_id: None, stair_id: None, @@ -2287,7 +2287,7 @@ mod tests { for q in &d.stairs { if let Primitive::Line { a, b, cls, .. } = q { if matches!(cls.as_str(), "stair-run" | "stair-arrow" | "stair-tread" | "stair-break") { - seen.insert(cls.clone()); + seen.insert(cls.to_string()); let m = Vec2 { x: (a.x + b.x) / 2.0, y: (a.y + b.y) / 2.0 }; assert_eq!(o.clearance(m, 0.001, 0.001), 0.0, "{cls}"); } @@ -2760,7 +2760,7 @@ mod tests { r.ceilings .iter() .filter_map(|q| match q { - Primitive::Line { a, b, cls, weight_mm, color, .. } if cls == "floor-finish-pattern" => Some((*a, *b, *weight_mm, color.clone().unwrap_or_default())), + Primitive::Line { a, b, cls, weight_mm, color, .. } if cls == "floor-finish-pattern" => Some((*a, *b, *weight_mm, color.as_ref().map(|c| c.to_string()).unwrap_or_default())), _ => None, }) .collect() @@ -3061,7 +3061,7 @@ mod tests { let lines: Vec<(String, Vec2, Vec2, bool)> = st .iter() .filter_map(|q| match q { - Primitive::Line { a, b, cls, dash, stair_id, .. } if stair_id.as_deref() == Some("ST1") => Some((cls.clone(), *a, *b, dash.as_ref().is_some_and(|d| d.is_some()))), + Primitive::Line { a, b, cls, dash, stair_id, .. } if stair_id.as_deref() == Some("ST1") => Some((cls.to_string(), *a, *b, dash.as_ref().is_some_and(|d| d.is_some()))), _ => None, }) .collect(); diff --git a/src-tauri/core/src/plan/drawings.rs b/src-tauri/core/src/plan/drawings.rs index 4d94f5c1..5958f4a0 100644 --- a/src-tauri/core/src/plan/drawings.rs +++ b/src-tauri/core/src/plan/drawings.rs @@ -193,7 +193,7 @@ impl<'o> Sink<'o> { dash: l.dash.map(|d| d.map(|x| x.to_vec())), zigzag: l.zigzag.cloned(), motif: l.motif.cloned(), - color: l.color.map(String::from), + color: l.color.map(|c| c.to_string().into()), drawing_id: l.drawing_id.map(String::from), opening_id: l.opening_id.map(String::from), stair_id: l.stair_id.map(String::from), @@ -365,7 +365,7 @@ fn polygon(pts: Vec, fill: &str, stroke: &str, w: f64, hatch: HatchRender, fill: fill.into(), stroke: stroke.into(), stroke_width_mm: w, - hatch, + hatch: Box::new(hatch), greyed: Some(greyed), opacity: None, no_stroke_edges: None, diff --git a/src-tauri/core/src/plan/elevation/face.rs b/src-tauri/core/src/plan/elevation/face.rs index 23b1cc0c..c8bf6f26 100644 --- a/src-tauri/core/src/plan/elevation/face.rs +++ b/src-tauri/core/src/plan/elevation/face.rs @@ -55,7 +55,7 @@ impl SurfOv { pub(super) fn restyle(&self, mut l: Primitive) -> Primitive { if let Primitive::Line { color, weight_mm, dash, .. } = &mut l { if let Some(c) = &self.color { - *color = Some(c.clone()); + *color = Some(c.clone().into()); } if let Some(w) = self.lineweight { *weight_mm = w; diff --git a/src-tauri/core/src/plan/extras.rs b/src-tauri/core/src/plan/extras.rs index c4485029..ddd57660 100644 --- a/src-tauri/core/src/plan/extras.rs +++ b/src-tauri/core/src/plan/extras.rs @@ -59,7 +59,7 @@ fn flat_polygon(pts: Vec, fill: &str, opacity: f64) -> Primitive { fill: fill.into(), stroke: "none".into(), stroke_width_mm: 0.0, - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed: None, opacity: Some(opacity), no_stroke_edges: None, @@ -844,7 +844,7 @@ mod tests { solid.color = "#123456".into(); let mut p = flat_polygon(vec![], "#abcdef", 1.0); if let Primitive::Polygon { hatch, stroke, .. } = &mut p { - *hatch = solid; + *hatch = Box::new(solid); *stroke = "#ff0000".into(); } post.apply(&mut p); @@ -886,7 +886,7 @@ mod tests { 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() }; + *hatch = Box::new(HatchRender { pattern: HatchPattern::Diagonal, color: "#808080".into(), ..no_hatch() }); } post.apply(&mut p); match &p { @@ -900,7 +900,7 @@ mod tests { 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() }; + *hatch = Box::new(HatchRender { pattern: HatchPattern::Diagonal, color: "#c04020".into(), ..no_hatch() }); } post.apply(&mut q); match &q { diff --git a/src-tauri/core/src/plan/mesh_plan.rs b/src-tauri/core/src/plan/mesh_plan.rs index 31eafedd..803abfc4 100644 --- a/src-tauri/core/src/plan/mesh_plan.rs +++ b/src-tauri/core/src/plan/mesh_plan.rs @@ -82,7 +82,7 @@ fn view_line(a: [f64; 2], b: [f64; 2], dash: Option<&[f64]>, greyed: bool, ov: O w = o.weight.unwrap_or(w); d = o.dash.clone().or(d); } - Primitive::Line { a: Vec2 { x: a[0], y: a[1] }, b: Vec2 { x: b[0], y: b[1] }, cls: "mesh-view".into(), weight_mm: w, dash: d, zigzag: None, motif: None, color: Some(color), drawing_id: None, opening_id: None, stair_id: None, greyed: Some(greyed), opacity: None } + Primitive::Line { a: Vec2 { x: a[0], y: a[1] }, b: Vec2 { x: b[0], y: b[1] }, cls: "mesh-view".into(), weight_mm: w, dash: d, zigzag: None, motif: None, color: Some(color.into()), drawing_id: None, opening_id: None, stair_id: None, greyed: Some(greyed), opacity: None } } /// Verdecker-Fläche (nur Verdecker, beidseitig) in Ansichtstiefe `depth` (Schnitthöhe − z). diff --git a/src-tauri/core/src/plan/prim.rs b/src-tauri/core/src/plan/prim.rs index af2b1f79..916d7b1d 100644 --- a/src-tauri/core/src/plan/prim.rs +++ b/src-tauri/core/src/plan/prim.rs @@ -4,6 +4,78 @@ use crate::model::*; use serde::{Deserialize, Deserializer, Serialize}; +use std::sync::Arc; + +/// Geteilte Zeichenkette (Klasse, Farbe): Clone = Zähler statt Kopie. Serde wie `String`, vergleichbar mit `str`. +#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Sstr(Arc); + +impl Sstr { + pub fn as_str(&self) -> &str { + &self.0 + } +} +impl std::ops::Deref for Sstr { + type Target = str; + fn deref(&self) -> &str { + &self.0 + } +} +impl std::fmt::Debug for Sstr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Debug::fmt(&*self.0, f) + } +} +impl std::fmt::Display for Sstr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&*self.0, f) + } +} +impl From<&str> for Sstr { + fn from(s: &str) -> Self { + Sstr(Arc::from(s)) + } +} +impl From<&String> for Sstr { + fn from(s: &String) -> Self { + Sstr(Arc::from(s.as_str())) + } +} +impl From for Sstr { + fn from(s: String) -> Self { + Sstr(Arc::from(s)) + } +} +impl From for String { + fn from(s: Sstr) -> String { + s.0.to_string() + } +} +impl PartialEq for Sstr { + fn eq(&self, o: &str) -> bool { + &*self.0 == o + } +} +impl PartialEq<&str> for Sstr { + fn eq(&self, o: &&str) -> bool { + &*self.0 == *o + } +} +impl PartialEq for Sstr { + fn eq(&self, o: &String) -> bool { + &*self.0 == o.as_str() + } +} +impl Serialize for Sstr { + fn serialize(&self, s: S) -> Result { + s.serialize_str(&self.0) + } +} +impl<'de> Deserialize<'de> for Sstr { + fn deserialize>(d: D) -> Result { + String::deserialize(d).map(Sstr::from) + } +} /// Aufgelöste Schraffur eines Polygons (`HatchRender`). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -64,7 +136,7 @@ pub enum Primitive { fill: String, stroke: String, stroke_width_mm: f64, - hatch: HatchRender, + hatch: Box, #[serde(skip_serializing_if = "Option::is_none")] greyed: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -98,7 +170,7 @@ pub enum Primitive { Line { a: Vec2, b: Vec2, - cls: String, + cls: Sstr, weight_mm: f64, #[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "de_dash")] dash: Dash, @@ -107,7 +179,7 @@ pub enum Primitive { #[serde(skip_serializing_if = "Option::is_none")] motif: Option, #[serde(skip_serializing_if = "Option::is_none")] - color: Option, + color: Option, #[serde(skip_serializing_if = "Option::is_none")] drawing_id: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -125,13 +197,13 @@ pub enum Primitive { from: Vec2, to: Vec2, r: f64, - cls: String, + cls: Sstr, weight_mm: f64, #[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "de_dash")] dash: Dash, /// Strichfarbe (sonst die der Klasse), z. B. Umriss einer Bogenwand ([T2]). #[serde(default, skip_serializing_if = "Option::is_none")] - color: Option, + color: Option, #[serde(skip_serializing_if = "Option::is_none")] opening_id: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -271,7 +343,7 @@ mod tests { #[test] fn polygon_tragt_kind_und_camel_case() { - let p = Primitive::Polygon { pts: vec![], fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.2, hatch: no_hatch(), greyed: None, opacity: None, no_stroke_edges: None, wall_id: Some("w".into()), drawing_id: None, ceiling_id: None, opening_id: None, stair_id: None, room_id: None, extruded_solid_id: None, context_object_id: None, column_id: None, roof_id: None, section_line_id: None }; + let p = Primitive::Polygon { pts: vec![], fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.2, hatch: Box::new(no_hatch()), greyed: None, opacity: None, no_stroke_edges: None, wall_id: Some("w".into()), drawing_id: None, ceiling_id: None, opening_id: None, stair_id: None, room_id: None, extruded_solid_id: None, context_object_id: None, column_id: None, roof_id: None, section_line_id: None }; let s = serde_json::to_string(&p).unwrap(); assert!(s.contains("\"kind\":\"polygon\"") && s.contains("strokeWidthMm") && s.contains("\"wallId\":\"w\"")); } diff --git a/src-tauri/core/src/plan/print_svg.rs b/src-tauri/core/src/plan/print_svg.rs index fa8fa897..8530e9db 100644 --- a/src-tauri/core/src/plan/print_svg.rs +++ b/src-tauri/core/src/plan/print_svg.rs @@ -823,7 +823,7 @@ mod tests { fill: "#fff".into(), stroke: "#123456".into(), stroke_width_mm: 0.5, - hatch: crate::plan::style::no_hatch(), + hatch: Box::new(crate::plan::style::no_hatch()), greyed: None, opacity: None, no_stroke_edges: Some(vec![3.0]), diff --git a/src-tauri/core/src/plan/section/mod.rs b/src-tauri/core/src/plan/section/mod.rs index b07c7eb9..e17d6661 100644 --- a/src-tauri/core/src/plan/section/mod.rs +++ b/src-tauri/core/src/plan/section/mod.rs @@ -321,7 +321,7 @@ impl MeshLineStyle { fn apply(&self, l: &mut Primitive) { if let Primitive::Line { color, weight_mm, dash, .. } = l { if let Some(c) = &self.color { - *color = Some(c.clone()); + *color = Some(c.clone().into()); } if let Some(w) = self.weight { *weight_mm = w; diff --git a/src-tauri/core/src/plan/section/primitives.rs b/src-tauri/core/src/plan/section/primitives.rs index dfc2eb49..4518b34a 100644 --- a/src-tauri/core/src/plan/section/primitives.rs +++ b/src-tauri/core/src/plan/section/primitives.rs @@ -10,7 +10,7 @@ pub(crate) fn polygon(pts: Vec, fill: &str, stroke: &str, w: f64, hatch: H fill: fill.into(), stroke: stroke.into(), stroke_width_mm: w, - hatch, + hatch: Box::new(hatch), greyed: None, opacity: None, no_stroke_edges: None, @@ -566,7 +566,7 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis: if let Some((a, _)) = tov.filter(|_| !pr.natural) { if let Primitive::Line { color, weight_mm, dash, .. } = &mut l { if let Some(c) = &a.color { - *color = Some(c.clone()); + *color = Some(c.clone().into()); } if let Some(w) = a.lineweight.filter(|w| w.is_finite() && *w >= 0.0) { *weight_mm = w; diff --git a/src-tauri/core/src/plan/stairs.rs b/src-tauri/core/src/plan/stairs.rs index 38990cec..d886f29c 100644 --- a/src-tauri/core/src/plan/stairs.rs +++ b/src-tauri/core/src/plan/stairs.rs @@ -53,7 +53,7 @@ fn stair_line(a: Vec2, b: Vec2, cls: &str, weight_mm: f64, dash: Option, f: &[f64], stroke: &str, greyed: Option, fill: if f[i + 2] != 0.0 { stroke.to_string() } else { "none".into() }, stroke: if visible { stroke.to_string() } else { "none".into() }, stroke_width_mm: f[i + 1], - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed, opacity: None, no_stroke_edges: None, diff --git a/src-tauri/core/src/plan/svg.rs b/src-tauri/core/src/plan/svg.rs index fbed331a..d0708492 100644 --- a/src-tauri/core/src/plan/svg.rs +++ b/src-tauri/core/src/plan/svg.rs @@ -573,7 +573,7 @@ mod tests { fill: fill.into(), stroke: if nse.is_some() { "#1a1a1a".into() } else { "none".into() }, stroke_width_mm: if nse.is_some() { 0.25 } else { 0.0 }, - hatch: crate::plan::style::no_hatch(), + hatch: Box::new(crate::plan::style::no_hatch()), greyed: None, opacity: None, no_stroke_edges: nse, @@ -627,7 +627,7 @@ mod tests { fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.5, - hatch: crate::plan::style::no_hatch(), + hatch: Box::new(crate::plan::style::no_hatch()), greyed: None, opacity: None, no_stroke_edges: Some(vec![1.0, 3.0]), @@ -675,7 +675,7 @@ mod tests { fill: "#ffffff".into(), stroke: "#000000".into(), stroke_width_mm: 0.35, - hatch: crate::plan::style::no_hatch(), + hatch: Box::new(crate::plan::style::no_hatch()), greyed: None, opacity: None, no_stroke_edges: nse, diff --git a/src-tauri/core/src/plan/trees.rs b/src-tauri/core/src/plan/trees.rs index 304c8079..c67044ae 100644 --- a/src-tauri/core/src/plan/trees.rs +++ b/src-tauri/core/src/plan/trees.rs @@ -45,7 +45,7 @@ fn poly(pts: Vec, fill: &str, stroke: &str, w: f64, pick: Option, fill: fill.into(), stroke: stroke.into(), stroke_width_mm: w, - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed, opacity: None, no_stroke_edges: None, diff --git a/src-tauri/core/src/plan/underlay.rs b/src-tauri/core/src/plan/underlay.rs index b3972f42..52fd1261 100644 --- a/src-tauri/core/src/plan/underlay.rs +++ b/src-tauri/core/src/plan/underlay.rs @@ -330,7 +330,7 @@ mod tests { use super::super::prim::HatchRender; let mut hatch: HatchRender = super::super::style::no_hatch(); hatch.angle = 10.0; - let poly = Primitive::Polygon { pts: vec![v(0.0, 0.0), v(1.0, 0.0), v(1.0, 1.0)], fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.2, hatch, greyed: None, opacity: None, no_stroke_edges: None, wall_id: Some("W".into()), drawing_id: None, ceiling_id: None, opening_id: None, stair_id: None, room_id: None, extruded_solid_id: None, context_object_id: None, column_id: None, roof_id: None, section_line_id: None }; + let poly = Primitive::Polygon { pts: vec![v(0.0, 0.0), v(1.0, 0.0), v(1.0, 1.0)], fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.2, hatch: Box::new(hatch), greyed: None, opacity: None, no_stroke_edges: None, wall_id: Some("W".into()), drawing_id: None, ceiling_id: None, opening_id: None, stair_id: None, room_id: None, extruded_solid_id: None, context_object_id: None, column_id: None, roof_id: None, section_line_id: None }; let img = Primitive::DrawingImage { min: v(0.0, 0.0), max: v(1.0, 1.0), src: "x".into(), opacity: 1.0, drawing_id: None, greyed: None }; // Linie entlang +y → Drehung um 90°. let out = underlay_primitives(Some([v(0.0, 0.0), v(0.0, 5.0)]), None, vec![poly, img], 0.0); diff --git a/src-tauri/core/src/plan/view_range.rs b/src-tauri/core/src/plan/view_range.rs index 354bed15..729c4a44 100644 --- a/src-tauri/core/src/plan/view_range.rs +++ b/src-tauri/core/src/plan/view_range.rs @@ -121,7 +121,7 @@ pub fn restyle(prims: &mut Vec, from: usize, dash: &[f64]) { dash: Some(Some(dash.to_vec())), zigzag: None, motif: None, - color: Some(stroke.clone()), + color: Some(stroke.clone().into()), drawing_id: None, opening_id: None, stair_id: None, @@ -134,7 +134,7 @@ pub fn restyle(prims: &mut Vec, from: usize, dash: &[f64]) { *fill = "none".into(); *stroke = "none".into(); *stroke_width_mm = 0.0; - *hatch = no_hatch(); + *hatch = Box::new(no_hatch()); prims.push(q); } Primitive::Line { dash: d, .. } | Primitive::Arc { dash: d, .. } => { @@ -221,7 +221,7 @@ mod tests { fill: "#fff".into(), stroke: "#000".into(), stroke_width_mm: 0.2, - hatch: no_hatch(), + hatch: Box::new(no_hatch()), greyed: None, opacity: None, no_stroke_edges: Some(vec![3.0]), diff --git a/src-tauri/core/src/plan/wall_join_tests.rs b/src-tauri/core/src/plan/wall_join_tests.rs index bb35db8c..bc6c1a1f 100644 --- a/src-tauri/core/src/plan/wall_join_tests.rs +++ b/src-tauri/core/src/plan/wall_join_tests.rs @@ -408,7 +408,7 @@ fn daemm_muster_gehen_an_der_gehrung_ineinander_ueber() { let bands: Vec<(String, Vec, super::prim::HatchRender)> = ps .iter() .filter_map(|q| match q { - Primitive::Polygon { pts, hatch, wall_id: Some(w), .. } if hatch.pattern == pat => Some((w.clone(), pts.clone(), hatch.clone())), + Primitive::Polygon { pts, hatch, wall_id: Some(w), .. } if hatch.pattern == pat => Some((w.clone(), pts.clone(), (**hatch).clone())), _ => None, }) .collect(); @@ -775,7 +775,7 @@ fn daemm_muster_im_wandring_eckquadrat_gehoert_einer_wand() { let bands: Vec<(Vec, super::prim::HatchRender)> = ps .iter() .filter_map(|q| match q { - Primitive::Polygon { pts, hatch, wall_id: Some(_), .. } if hatch.pattern == pat => Some((pts.clone(), hatch.clone())), + Primitive::Polygon { pts, hatch, wall_id: Some(_), .. } if hatch.pattern == pat => Some((pts.clone(), (**hatch).clone())), _ => None, }) .collect(); diff --git a/src-tauri/core/src/plan/walls.rs b/src-tauri/core/src/plan/walls.rs index 3280ef46..3a631646 100644 --- a/src-tauri/core/src/plan/walls.rs +++ b/src-tauri/core/src/plan/walls.rs @@ -173,7 +173,7 @@ fn wall_polygon(pts: Vec, fill: &str, stroke: &str, w: f64, hatch: HatchRe fill: fill.into(), stroke: stroke.into(), stroke_width_mm: w, - hatch, + hatch: Box::new(hatch), greyed: Some(greyed), opacity: None, no_stroke_edges, @@ -193,7 +193,7 @@ fn wall_polygon(pts: Vec, fill: &str, stroke: &str, w: f64, hatch: HatchRe #[allow(clippy::too_many_arguments)] fn mk_line(a: Vec2, b: Vec2, cls: &str, w: f64, dash: super::prim::Dash, color: Option<&str>, greyed: bool, opening_id: Option<&str>) -> Primitive { - Primitive::Line { a, b, cls: cls.into(), weight_mm: w, dash, zigzag: None, motif: None, color: color.map(String::from), drawing_id: None, opening_id: opening_id.map(String::from), stair_id: None, greyed: Some(greyed), opacity: None } + Primitive::Line { a, b, cls: cls.into(), weight_mm: w, dash, zigzag: None, motif: None, color: color.map(|c| c.to_string().into()), drawing_id: None, opening_id: opening_id.map(String::from), stair_id: None, greyed: Some(greyed), opacity: None } } fn v2(x: f64, y: f64) -> Vec2 { @@ -1419,7 +1419,7 @@ fn cut_pockets(prims: &mut Vec, from: usize, wp: &WallPockets) { let mut o = prim.clone(); if let Primitive::Polygon { fill, hatch, .. } = &mut o { *fill = "none".into(); - *hatch = no_hatch(); + *hatch = Box::new(no_hatch()); } prims.push(o); } @@ -1979,7 +1979,7 @@ pub(crate) mod tests { let polys: Vec<(&Vec, &HatchRender)> = prims .iter() .filter_map(|q| match q { - Primitive::Polygon { pts, hatch, wall_id: Some(_), fill, .. } if fill != "none" => Some((pts, hatch)), + Primitive::Polygon { pts, hatch, wall_id: Some(_), fill, .. } if fill != "none" => Some((pts, &**hatch)), _ => None, }) .collect();