Added min and max values to json.
[?]
CrEcTsRjb1hHQjHuumqRfqdbVV4X58iLEubi4noaDPFa
Jul 25, 2021, 5:14 AM
R2OU7BE4I4QC5IRZU7BJGHJQNTBNF3265LOHZB3QQDQD7OL46G5ACDependencies
- [2]
YAE43L6ACompleted first try at UIData. - [3]
XI5ALEH6Take advantage of keytree FromStr functionality. - [4]
TTR5IFSGWorking on building generic TSSpec. - [5]
GQVS55HIFinished generate_ts_spec() function. - [6]
4QOTH75IFixed UI specification code.
Change contents
- edit in src/ui.rs at line 31
#[derive(Debug)] - replacement in src/ui.rs at line 35
pub struct FixedScale {x_max: f32,x_min: f32,y_max: f32,y_min: f32,pub enum Scale {Group {x_min: f32,x_max: f32,y_min: f32,y_max: f32,},Single {x_min: f32,x_max: f32,y_min: f32,y_max: f32,}, - replacement in src/ui.rs at line 53
pub fn into_ui_data(&self) -> Result<UIData, Error> {pub fn into_data(&self) -> Result<UIData, Error> { - replacement in src/ui.rs at line 75
sized: Option<FixedScale>,scale: Scale, - edit in src/ui.rs at line 85
}pub struct GraphicBuilder {lines: Vec<LineJson>,x_min: Option<f32>,x_max: Option<f32>,y_min: Option<f32>,y_max: Option<f32>, - edit in src/ui.rs at line 94
impl GraphicBuilder {// Update if requiredfn x_min(&mut self, x: f32) {match self.x_min {None => self.x_min = Some(x),Some(old) => if x < old { self.x_min = Some(x) },}}// Update if requiredfn x_max(&mut self, x: f32) {match self.x_max {None => self.x_min = Some(x),Some(old) => if x > old { self.x_max = Some(x) },}} - edit in src/ui.rs at line 112
// Update if requiredfn y_min(&mut self, y: f32) {match self.y_min {None => self.y_min = Some(y),Some(old) => if y < old { self.y_min = Some(y) },}}// Update if requiredfn y_max(&mut self, y: f32) {match self.y_max {None => self.y_min = Some(y),Some(old) => if y > old { self.y_max = Some(y) },}}fn scale(&self) -> Scale {Scale::Single {x_min: self.x_min.unwrap(),x_max: self.x_max.unwrap(),y_min: self.y_min.unwrap(),y_max: self.y_max.unwrap(),}}}#[derive(Debug)] - edit in src/ui.rs at line 140
- replacement in src/ui.rs at line 161
kt.to_ref().try_into().map_err(|err: keytree::error::Error| {dbg!(&kt);let out = kt.to_ref().try_into().map_err(|err: keytree::error::Error| { - replacement in src/ui.rs at line 164
})});out - replacement in src/ui.rs at line 179
// GraphicJson builderlet mut graphic_json = GraphicJson {country: *country,index: *index,lines: Vec::new(),sized: None,dbg!((country, index));let mut graphic_json_builder = GraphicBuilder {lines: Vec::new(),x_min: None,x_max: None,y_min: None,y_max: None, - edit in src/ui.rs at line 203
let x_min = x_rts.min(0);let x_max = x_rts.max(0); - edit in src/ui.rs at line 216
let y_min = y_rts.min(0);let y_max = y_rts.max(0); - replacement in src/ui.rs at line 229
graphic_json.lines.push(line_json);graphic_json_builder.lines.push(line_json);graphic_json_builder.x_min(x_min);graphic_json_builder.x_max(x_max);graphic_json_builder.y_min(y_min);graphic_json_builder.y_max(y_max); - edit in src/ui.rs at line 235
let graphic_json = GraphicJson {country: *country,index: *index,scale: graphic_json_builder.scale(),lines: graphic_json_builder.lines,}; - replacement in src/ui.rs at line 254
Spec(self.vec_at("ui_spec::ui_graphic")?)Spec(self.vec_at("ui_spec::graphic")?) - edit in src/ui.rs at line 259
#[derive(Debug)] - edit in src/ui.rs at line 289
#[derive(Debug)]