Skip to content

Commit 8cd5fec

Browse files
committed
Store number_of_plots in serial_devices for persistence
1 parent 44dc75f commit 8cd5fec

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/gui.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ pub struct MyApp {
174174
device_idx: usize,
175175
serial_devices: SerialDevices,
176176
plotting_range: usize,
177-
number_of_plots: usize,
178177
plot_serial_display_ratio: f32,
179178
console: Vec<Print>,
180179
picked_path: PathBuf,
@@ -238,7 +237,6 @@ impl MyApp {
238237
send_tx,
239238
clear_tx,
240239
plotting_range: usize::MAX,
241-
number_of_plots: 1,
242240
plot_serial_display_ratio: 0.45,
243241
command: "".to_string(),
244242
show_sent_cmds: true,
@@ -310,7 +308,7 @@ impl MyApp {
310308
let panel_height = ui.available_size().y;
311309
let height = ui.available_size().y * self.plot_serial_display_ratio;
312310
let plots_height = height;
313-
let plot_height = plots_height / (self.number_of_plots as f32);
311+
let plot_height = plots_height / (self.serial_devices.number_of_plots as f32);
314312
let spacing = 5.0;
315313
let width = ui.available_size().x - 2.0 * border - RIGHT_PANEL_WIDTH;
316314

@@ -341,7 +339,7 @@ impl MyApp {
341339
let t_fmt = |x, _range: &RangeInclusive<f64>| format!("{:4.2} s", x);
342340

343341
let plots_ui = ui.vertical(|ui| {
344-
for graph_idx in 0..self.number_of_plots {
342+
for graph_idx in 0..self.serial_devices.number_of_plots {
345343
if graph_idx != 0 {
346344
ui.separator();
347345
}
@@ -684,13 +682,15 @@ impl MyApp {
684682

685683
ui.horizontal(|ui| {
686684
if ui.button("<").clicked() {
687-
self.number_of_plots = (self.number_of_plots - 1).clamp(1, 10);
685+
self.serial_devices.number_of_plots =
686+
(self.serial_devices.number_of_plots - 1).clamp(1, 10);
688687
}
689-
ui.add(egui::DragValue::new(&mut self.number_of_plots)
688+
ui.add(egui::DragValue::new(&mut self.serial_devices.number_of_plots)
690689
.clamp_range(1..=10))
691690
.on_hover_text("Select the number of plots to be shown.");
692691
if ui.button(">").clicked() {
693-
self.number_of_plots = (self.number_of_plots + 1).clamp(1, 10);
692+
self.serial_devices.number_of_plots =
693+
(self.serial_devices.number_of_plots + 1).clamp(1, 10);
694694
}
695695
});
696696

src/serial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ use crate::{print_to_console, Packet, Print, APP_INFO, PREFS_KEY_SERIAL};
1414
pub struct SerialDevices {
1515
pub devices: Vec<Device>,
1616
pub labels: Vec<Vec<String>>,
17+
pub number_of_plots: usize,
1718
}
1819

1920
impl Default for SerialDevices {
2021
fn default() -> Self {
2122
SerialDevices {
2223
devices: vec![Device::default()],
2324
labels: vec![vec!["Column 0".to_string()]],
25+
number_of_plots: 1,
2426
}
2527
}
2628
}

0 commit comments

Comments
 (0)