mirror of
https://github.com/hubaldv/bioz-host-rs.git
synced 2026-03-10 01:20:31 +00:00
Implement clear view plot.
This commit is contained in:
18
src/app.rs
18
src/app.rs
@@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use atomic_float::AtomicF32;
|
||||
use tokio::{sync::mpsc::{Sender}};
|
||||
|
||||
use eframe::egui::{self, Color32, DragValue, Key, Label, Layout, Modifiers};
|
||||
use eframe::egui::{self, Button, Color32, DragValue, Key, Label, Layout, Modifiers};
|
||||
use egui_plot::{Corner, Legend, Line, Plot, PlotPoints, Points, PlotBounds};
|
||||
|
||||
use crate::plot::TimeSeriesPlot;
|
||||
@@ -54,6 +54,11 @@ impl App {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_view(&self) {
|
||||
self.magnitude_series.lock().unwrap().clear();
|
||||
self.phase_series.lock().unwrap().clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
@@ -81,6 +86,12 @@ impl eframe::App for App {
|
||||
self.update_start_stop();
|
||||
};
|
||||
|
||||
ui.separator();
|
||||
|
||||
if ui.add_enabled(connected, Button::new("Reset view")).clicked() {
|
||||
self.reset_view();
|
||||
}
|
||||
|
||||
// Spacer to push the LED to the right
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.scope(|ui| {
|
||||
@@ -198,6 +209,11 @@ impl eframe::App for App {
|
||||
self.update_start_stop();
|
||||
}
|
||||
|
||||
// Reset view
|
||||
if ctx.input(|i| i.key_pressed(Key::C)) {
|
||||
self.reset_view();
|
||||
}
|
||||
|
||||
ctx.request_repaint();
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user