adjust storing and processing of area info

This commit is contained in:
Simon Gardling 2022-05-18 11:51:56 -04:00
parent 45c7fb47b7
commit 6258b0ac16

View File

@ -91,7 +91,7 @@ pub struct MathApp {
functions: FunctionManager, functions: FunctionManager,
/// Contains the list of Areas calculated (the vector of f64) and time it took for the last frame (the Duration). Stored in a Tuple. /// Contains the list of Areas calculated (the vector of f64) and time it took for the last frame (the Duration). Stored in a Tuple.
last_info: (Vec<Option<f64>>, Option<String>), last_info: (Option<String>, Option<String>),
/// Whether or not dark mode is enabled /// Whether or not dark mode is enabled
dark_mode: bool, dark_mode: bool,
@ -253,7 +253,7 @@ impl MathApp {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
functions: FunctionManager::default(), functions: FunctionManager::default(),
last_info: (vec![None], None), last_info: (None, None),
dark_mode: true, // dark mode is default and is previously set dark_mode: true, // dark mode is default and is previously set
text: data.text, text: data.text,
opened: Opened::default(), opened: Opened::default(),
@ -460,8 +460,8 @@ impl App for MathApp {
} }
// Display Area and time of last frame // Display Area and time of last frame
if self.last_info.0.iter().any(|e| e.is_some()) { if let Some(ref area) = self.last_info.0 {
ui.label(format!("Area: {}", option_vec_printer(&self.last_info.0))); ui.label(area);
} }
}); });
}); });
@ -578,7 +578,7 @@ impl App for MathApp {
function.calculate(width_changed, min_max_changed, &self.settings) function.calculate(width_changed, min_max_changed, &self.settings)
}); });
self.last_info.0 = self let area: Vec<Option<f64>> = self
.functions .functions
.get_entries() .get_entries()
.iter() .iter()
@ -587,6 +587,12 @@ impl App for MathApp {
function.display(plot_ui, &self.settings, COLORS[i]) function.display(plot_ui, &self.settings, COLORS[i])
}) })
.collect(); .collect();
self.last_info.0 = if area.iter().any(|e| e.is_some()) {
Some(format!("Area: {}", option_vec_printer(area.as_slice())))
} else {
None
};
}); });
}); });