Skip to content

Commit

Permalink
🔧(ImagePlotter): Add parameter to show_only and update plot settings
Browse files Browse the repository at this point in the history
Add a `bool` parameter to the `show_only` method to control its behavior, and update the plot settings based on the value of `show_only`, including toggling axes, scroll, zoom, drag, and axis visibility.

Signed-off-by: Benign X <[email protected]>
  • Loading branch information
W-Mai committed Dec 8, 2024
1 parent 666a6a3 commit beaff07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/image_plotter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl ImagePlotter {
s
}

pub fn show_only(self) -> Self {
pub fn show_only(self, only: bool) -> Self {
let mut s = self;
s.show_only = true;
s.show_only = only;
s
}

Expand Down Expand Up @@ -121,7 +121,13 @@ impl ImagePlotter {
.boxed_zoom_pointer_button(PointerButton::Extra2)
.show_grid([self.show_grid, self.show_grid])
.clamp_grid(true)
.sharp_grid_lines(false);
.sharp_grid_lines(false)
.show_axes([!self.show_only, !self.show_only])
.allow_scroll(!self.show_only)
.allow_zoom(!self.show_only)
.allow_drag(!self.show_only)
.show_x(!self.show_only)
.show_y(!self.show_only);

plot.show(ui, |plot_ui| {
plot_ui.image(PlotImage::new(
Expand Down
4 changes: 1 addition & 3 deletions src/image_shower.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::image_plotter::ImagePlotter;
use eframe::egui;
use eframe::egui::load::SizedTexture;
use eframe::egui::{Color32, ColorImage, PointerButton};
use egui_plot::{CoordinatesFormatter, Corner, PlotImage, PlotPoint};
use eframe::egui::Color32;
use icu_lib::midata::MiData;
use serde::{Deserialize, Serialize};

Expand Down

0 comments on commit beaff07

Please sign in to comment.