From 81a0d7787494b62227e16ab84d728ac0250e50fd Mon Sep 17 00:00:00 2001 From: Lan <ldam@passcal.nmt.edu> Date: Fri, 4 Aug 2023 07:55:00 -0600 Subject: [PATCH] multi_threaded_plotting_widget.py: fix some wrong in resolving conflict when merging to master, save pref_order to be used when zoom in --- .../multi_threaded_plotting_widget.py | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 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 e8afaff4a..7e4e0d3ab 100644 --- a/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py +++ b/sohstationviewer/view/plotting/plotting_widget/multi_threaded_plotting_widget.py @@ -30,7 +30,8 @@ class MultiThreadedPlottingWidget(PlottingWidget): def __init__(self, *args, **kwargs): PlottingWidget.__init__(self, *args, **kwargs) self.data_processors: List[PlottingChannelProcessor] = [] - + # pref_order: order of channels to be plotted + self.pref_order: List[str] = [] # Only one data processor can run at a time, so it is not a big problem # self.thread_pool = QtCore.QThreadPool() @@ -108,18 +109,17 @@ class MultiThreadedPlottingWidget(PlottingWidget): def create_plotting_channel_processors( self, plotting_data: Dict, - get_plot_info: Optional[Callable[[str, Dict, str], Dict]], - pref_order: List[str] = []) -> None: + need_db_info: bool = False) -> None: """ Create a data processor for each channel data in the order of pref_order. If pref_order isn't given, process in order of plotting_data. :param plotting_data: dict of data by chan_id - :param get_plot_info: function to get plotting info from database - :param pref_order: order of channels to be plotted + :param need_db_info: flag to get db info """ - chan_order = pref_order if pref_order else list(plotting_data.keys()) + chan_order = self.pref_order if self.pref_order \ + else sorted(list(plotting_data.keys())) chan_order = replace_actual_quest_chans( chan_order, plotting_data.keys()) chan_order = remove_not_found_chans( @@ -127,11 +127,10 @@ class MultiThreadedPlottingWidget(PlottingWidget): not_plot_chans = [] for chan_id in chan_order: - if get_plot_info is not None: - chan_db_info = get_plot_info(chan_id, - plotting_data[chan_id], - self.parent.data_type, - self.c_mode) + if need_db_info: + chan_db_info = get_chan_plot_info(chan_id, + self.parent.data_type, + self.c_mode) if (chan_db_info['height'] == 0 or chan_db_info['plotType'] == ''): # not draw @@ -186,7 +185,7 @@ class MultiThreadedPlottingWidget(PlottingWidget): self.plotting_data1[channel] = self.plotting_data1.pop(channel) def plot_channels(self, d_obj, key, start_tm, end_tm, time_ticks_total, - pref_soh_order=[]): + pref_order=[]): """ Prepare to plot waveform/SOH/mass-position data by creating a data processor for each channel, then, run the processors. @@ -198,6 +197,7 @@ class MultiThreadedPlottingWidget(PlottingWidget): :param time_ticks_total: max number of tick to show on time bar :param pref_order: order of channels to be plotted """ + self.pref_order = pref_order if not self.is_working: self.reset_widget() self.is_working = True @@ -211,10 +211,8 @@ class MultiThreadedPlottingWidget(PlottingWidget): self.finished.emit() return - self.create_plotting_channel_processors( - self.plotting_data1, self.get_plot_info, pref_soh_order) - self.create_plotting_channel_processors( - self.plotting_data2, get_chan_plot_info) + self.create_plotting_channel_processors(self.plotting_data1, True) + self.create_plotting_channel_processors(self.plotting_data2, True) self.process_channel() -- GitLab