From 5d58c8c3c809481d04be6fc451b2a31568b54e70 Mon Sep 17 00:00:00 2001 From: Kien Le <kienle@passcal.nmt.edu> Date: Thu, 23 Mar 2023 11:14:53 -0600 Subject: [PATCH] Fix plots' point count texts not being removed between zoom --- .../view/plotting/plotting_widget/plotting_widget.py | 10 ++++++++-- .../view/plotting/state_of_health_widget.py | 12 ++++++++++++ sohstationviewer/view/plotting/waveform_dialog.py | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py index b5ca49e63..c9816e1c0 100755 --- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py @@ -475,8 +475,7 @@ class PlottingWidget(QtWidgets.QScrollArea): if not first_time: # x, y new_x_indexes = np.where((ax.x >= self.min_x) & - (ax.x <= self.max_x)) - + (ax.x <= self.max_x))[0] # reset total of samples on the right ax.sampleLbl.set_text(len(new_x_indexes)) @@ -542,3 +541,10 @@ class PlottingWidget(QtWidgets.QScrollArea): :param widgets: [PlottingWidgets,] - List of other plotting widgets """ self.peer_plotting_widgets = widgets + + def remove_plot_num_points_text(self): + """ + Remove the texts showing the number of points in each plot. + """ + for ax in self.axes: + ax.texts.clear() diff --git a/sohstationviewer/view/plotting/state_of_health_widget.py b/sohstationviewer/view/plotting/state_of_health_widget.py index 2f3b08565..96b59c6f0 100644 --- a/sohstationviewer/view/plotting/state_of_health_widget.py +++ b/sohstationviewer/view/plotting/state_of_health_widget.py @@ -144,3 +144,15 @@ class SOHWidget(plotting_widget.PlottingWidget): else: getattr(self.plotting, plot_functions[plot_type][1])( c_data, chan_db_info, chan_id, c_data['ax'], None) + + def set_lim(self, first_time=False): + """ + Remove all texts that show the numbers of points in the plots before + setting the limits of the plots. + + :param first_time: whether this method was called on the initial + plotting + """ + if not first_time: + self.remove_plot_num_points_text() + super().set_lim() diff --git a/sohstationviewer/view/plotting/waveform_dialog.py b/sohstationviewer/view/plotting/waveform_dialog.py index 33ab98d68..47efc2615 100755 --- a/sohstationviewer/view/plotting/waveform_dialog.py +++ b/sohstationviewer/view/plotting/waveform_dialog.py @@ -169,6 +169,9 @@ class WaveformWidget(plotting_widget.PlottingWidget): :param first_time: flag that indicate whether set_lim is called the fist time for a data set. """ + if not first_time: + self.remove_plot_num_points_text() + self.data_processors = [] if not self.is_working: self.is_working = True -- GitLab