From beaff07e150b48f10d3b962b7691f3122ec91410 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Mon, 9 Dec 2024 00:01:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(ImagePlotter):=20Add=20parameter?= =?UTF-8?q?=20to=20`show=5Fonly`=20and=20update=20plot=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <1341398182@qq.com> --- src/image_plotter.rs | 12 +++++++++--- src/image_shower.rs | 4 +--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/image_plotter.rs b/src/image_plotter.rs index c2cf7bd..da34313 100644 --- a/src/image_plotter.rs +++ b/src/image_plotter.rs @@ -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 } @@ -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( diff --git a/src/image_shower.rs b/src/image_shower.rs index 505a14d..201ae62 100644 --- a/src/image_shower.rs +++ b/src/image_shower.rs @@ -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};