Ignore:
Timestamp:
Aug 30, 2018 10:47:39 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
eef298d4
Parents:
b8080e1
Message:

plotting fixes: appended plots now update; Show Plot no longer breaks if file's plot(s) have been appended to

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    rf7d39c9 r9463ca2  
    526526        # Now query the model item for available plots 
    527527        plots = GuiUtils.plotsFromFilename(filename, model) 
    528         ids = [list(self.active_plots.values())[id].data.id for id in range(len(self.active_plots))] 
    529         ids2 = [list(self.active_plots.keys())[id] for id in range(len(self.active_plots))] 
     528        ids_keys = list(self.active_plots.keys()) 
     529        ids_vals = [val.data.id for val in self.active_plots.values()] 
    530530 
    531531        new_plots = [] 
    532532        for item, plot in plots.items(): 
    533533            plot_id = plot.id 
    534             if plot_id in ids or plot_id in ids2: 
     534            if plot_id in ids_keys: 
    535535                self.active_plots[plot_id].replacePlot(plot_id, plot) 
     536            elif plot_id in ids_vals: 
     537                list(self.active_plots.values())[ids_vals.index(plot_id)].replacePlot(plot_id, plot) 
    536538            else: 
    537539                # Don't plot intermediate results, e.g. P(Q), S(Q) 
     
    666668                old_plot.data = plot_set 
    667669                old_plot.plot() 
     670                # need this for lookup - otherwise this plot will never update 
     671                self.active_plots[plot_set.id] = old_plot 
    668672 
    669673    def updatePlot(self, new_data): 
     
    674678        assert type(data).__name__ in ['Data1D', 'Data2D'] 
    675679 
    676         id = data.id 
    677         if data.id in list(self.active_plots.keys()): 
    678             self.active_plots[id].replacePlot(id, data) 
     680        ids_keys = list(self.active_plots.keys()) 
     681        ids_vals = [val.data.id for val in self.active_plots.values()] 
     682 
     683        data_id = data.id 
     684        if data_id in ids_keys: 
     685            self.active_plots[data_id].replacePlot(data_id, data) 
     686        elif data_id in ids_vals: 
     687            list(self.active_plots.values())[ids_vals.index(data_id)].replacePlot(data_id, data) 
    679688 
    680689    def chooseFiles(self): 
Note: See TracChangeset for help on using the changeset viewer.