1pub use crate::prelude::DstvElement;
2use crate::{dstv_element::ParseDstvError, get_f64_from_str, prelude::PartFace};
3use std::str::FromStr;
4
5#[derive(Debug)]
8pub struct Numeration {
9 pub angle: f64,
11 pub letterheight: f64,
13 pub text: String,
15 pub x_coord: f64,
17 pub y_coord: f64,
19 pub fl_code: PartFace,
21}
22
23impl DstvElement for Numeration {
24 fn from_str(line: &str) -> Result<Self, ParseDstvError> {
30 let mut iter = line.split_whitespace();
31 let fl_code = PartFace::from_str(iter.next().ok_or(ParseDstvError::new("No Numeration Found"))?)?;
32 let x_coord = get_f64_from_str(iter.next(), "x_coord")?;
33 let y_coord = get_f64_from_str(iter.next(), "y_coord")?;
34 let angle = get_f64_from_str(iter.next(), "angle")?;
35 let letterheight = get_f64_from_str(iter.next(), "letterheight")?;
36 let text = iter
37 .next()
38 .ok_or(ParseDstvError::new("Text element not found"))?
39 .to_string();
40
41 Ok(Self {
42 angle,
43 letterheight,
44 text,
45 x_coord,
46 y_coord,
47 fl_code,
48 })
49 }
50
51 fn to_svg(&self) -> String {
53 "".to_string()
55 }
56
57 fn get_index(&self) -> usize {
58 2
59 }
60
61 fn get_facing(&self) -> &PartFace {
62 &self.fl_code
63 }
64}