fixes
This commit is contained in:
parent
e16d35ed62
commit
92bc183dbd
@ -184,6 +184,8 @@ impl epi::App for MathApp {
|
|||||||
} else {
|
} else {
|
||||||
function.update(proc_func_str, integral, Some(self.integral_min_x), Some(self.integral_max_x), Some(self.integral_num));
|
function.update(proc_func_str, integral, Some(self.integral_min_x), Some(self.integral_max_x), Some(self.integral_num));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
function.func_str = "".to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,15 +240,13 @@ impl epi::App for MathApp {
|
|||||||
let maxx_bounds: f64 = bounds.max()[0];
|
let maxx_bounds: f64 = bounds.max()[0];
|
||||||
|
|
||||||
let mut i: usize = 0;
|
let mut i: usize = 0;
|
||||||
let mut functions_2: Vec<Function> = Vec::new(); // Todo: figure out why this is required
|
for function in self.functions.iter_mut() {
|
||||||
for function_1 in self.functions.iter_mut() {
|
|
||||||
let function = function_1;
|
|
||||||
function.update_bounds(minx_bounds, maxx_bounds, available_width);
|
|
||||||
|
|
||||||
if self.func_strs[i].is_empty() {
|
if self.func_strs[i].is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function.update_bounds(minx_bounds, maxx_bounds, available_width);
|
||||||
|
|
||||||
let output = function.run();
|
let output = function.run();
|
||||||
let back = output.get_back();
|
let back = output.get_back();
|
||||||
plot_ui.line(Line::new(Values::from_values(back)).color(Color32::RED));
|
plot_ui.line(Line::new(Values::from_values(back)).color(Color32::RED));
|
||||||
@ -261,9 +261,7 @@ impl epi::App for MathApp {
|
|||||||
area_list.push(0.0);
|
area_list.push(0.0);
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
functions_2.push(function.clone());
|
|
||||||
}
|
}
|
||||||
self.functions = functions_2;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let duration = start.elapsed();
|
let duration = start.elapsed();
|
||||||
|
|||||||
@ -163,7 +163,7 @@ impl Function {
|
|||||||
self.max_x = max_x;
|
self.max_x = max_x;
|
||||||
self.pixel_width = pixel_width;
|
self.pixel_width = pixel_width;
|
||||||
} else if ((min_x != self.min_x) | (max_x != self.max_x)) && self.back_cache.is_some() {
|
} else if ((min_x != self.min_x) | (max_x != self.max_x)) && self.back_cache.is_some() {
|
||||||
// debug_log("back_cache: partial regen");
|
debug_log("back_cache: partial regen");
|
||||||
let range_new: f64 = max_x.abs() + min_x.abs();
|
let range_new: f64 = max_x.abs() + min_x.abs();
|
||||||
|
|
||||||
let resolution: f64 = (self.pixel_width as f64 / range_new) as f64;
|
let resolution: f64 = (self.pixel_width as f64 / range_new) as f64;
|
||||||
@ -209,11 +209,11 @@ impl Function {
|
|||||||
pub fn run(&mut self) -> FunctionOutput {
|
pub fn run(&mut self) -> FunctionOutput {
|
||||||
let back_values: Vec<Value> = match self.back_cache.is_some() {
|
let back_values: Vec<Value> = match self.back_cache.is_some() {
|
||||||
true => {
|
true => {
|
||||||
// debug_log("back_cache: using");
|
debug_log("back_cache: using");
|
||||||
self.back_cache.as_ref().expect("").clone()
|
self.back_cache.as_ref().expect("").clone()
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
// debug_log("back_cache: regen");
|
debug_log("back_cache: regen");
|
||||||
let absrange = (self.max_x - self.min_x).abs();
|
let absrange = (self.max_x - self.min_x).abs();
|
||||||
let resolution: f64 = (self.pixel_width as f64 / absrange) as f64;
|
let resolution: f64 = (self.pixel_width as f64 / absrange) as f64;
|
||||||
let back_data: Vec<Value> = (1..=self.pixel_width)
|
let back_data: Vec<Value> = (1..=self.pixel_width)
|
||||||
@ -231,13 +231,13 @@ impl Function {
|
|||||||
if self.integral {
|
if self.integral {
|
||||||
let front_bars: (Vec<Bar>, f64) = match self.front_cache.is_some() {
|
let front_bars: (Vec<Bar>, f64) = match self.front_cache.is_some() {
|
||||||
true => {
|
true => {
|
||||||
// debug_log("front_cache: using");
|
debug_log("front_cache: using");
|
||||||
let cache = self.front_cache.as_ref().expect("");
|
let cache = self.front_cache.as_ref().expect("");
|
||||||
let vec_bars: Vec<Bar> = cache.0.to_vec();
|
let vec_bars: Vec<Bar> = cache.0.to_vec();
|
||||||
(vec_bars, cache.1)
|
(vec_bars, cache.1)
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
// debug_log("front_cache: regen");
|
debug_log("front_cache: regen");
|
||||||
let (data, area) = self.integral_rectangles();
|
let (data, area) = self.integral_rectangles();
|
||||||
let bars: Vec<Bar> = data.iter().map(|(x, y)| Bar::new(*x, *y)).collect();
|
let bars: Vec<Bar> = data.iter().map(|(x, y)| Bar::new(*x, *y)).collect();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user