From 13a3049e7062bdf564a91fbdee86acb5d9f297a6 Mon Sep 17 00:00:00 2001 From: ldam <ldam@passcal.nmt.edu> Date: Fri, 21 Jun 2024 16:58:31 -0600 Subject: [PATCH] reset zoom_minmax_list when replot but not when add/remove --- .../plotting_widget/multi_threaded_plotting_widget.py | 6 ++++-- .../view/plotting/plotting_widget/plotting_widget.py | 9 +++++++-- sohstationviewer/view/select_channels_to_show_dialog.py | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py index c57e818f..7b7ad46d 100644 --- a/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py +++ b/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py @@ -234,8 +234,8 @@ class MultiThreadedPlottingWidget(PlottingWidget): channel_processor.stopped.connect(self.has_stopped) def plot_channels( - self, d_obj, data_set_id, start_tm, end_tm, - time_ticks_total, pref_order=[]): + self, d_obj, data_set_id, start_tm=None, end_tm=None, + time_ticks_total=0, pref_order=[], keep_zoom=False): """ Prepare to plot waveform/SOH/mass-position data: + get_plotting_info: get sizing info @@ -256,6 +256,8 @@ class MultiThreadedPlottingWidget(PlottingWidget): self.start_tm = start_tm self.end_tm = end_tm self.time_ticks_total = time_ticks_total + if not keep_zoom: + self.zoom_minmax_list = [] if 'VST' in pref_order: # pref_order use original name VST to read from file. diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py index 42f79ade..3681a34f 100644 --- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py @@ -710,8 +710,13 @@ class PlottingWidget(QtWidgets.QScrollArea): fist time for this data set or not. :param is_zoom_in: if set_lim comes from zoom_in task """ + from_add_remove_channels = False if is_zoom_in: - self.zoom_minmax_list.append((self.min_x, self.max_x)) + if first_time and self.zoom_minmax_list: + self.min_x, self.max_x = self.zoom_minmax_list[-1] + from_add_remove_channels = True + else: + self.zoom_minmax_list.append((self.min_x, self.max_x)) self.plotting_axes.update_timestamp_bar(self.timestamp_bar_top) self.plotting_axes.update_timestamp_bar(self.timestamp_bar_bottom) @@ -732,7 +737,7 @@ class PlottingWidget(QtWidgets.QScrollArea): break ax.set_xlim(self.min_x, self.max_x) - if not first_time: + if not first_time or from_add_remove_channels: new_min_y = None new_max_y = None if hasattr(ax, 'x_top'): diff --git a/sohstationviewer/view/select_channels_to_show_dialog.py b/sohstationviewer/view/select_channels_to_show_dialog.py index 78ceba6a..082d5877 100644 --- a/sohstationviewer/view/select_channels_to_show_dialog.py +++ b/sohstationviewer/view/select_channels_to_show_dialog.py @@ -153,7 +153,9 @@ class SelectChanelsToShowDialog(QDialog): self.parent.start_tm, self.parent.end_tm, self.parent.time_ticks_total, - new_pref_order) + new_pref_order, + keep_zoom=True + ) self.parent.draw() self.close() -- GitLab