Changeset 5b144c6 in sasview for src/sas


Ignore:
Timestamp:
Sep 8, 2018 2:23:48 PM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
5d28d6b
Parents:
685602a
git-author:
Piotr Rozyczko <rozyczko@…> (09/08/18 14:21:23)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/08/18 14:23:48)
Message:

Clumsy fix to the single-data, multi-fitpage plotting issue SASVIEW-1018.
Fixed tests after replacing plot_dict indexing from .id to .name

Location:
src/sas/qtgui
Files:
6 edited

Legend:

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

    r0cd98a1 r5b144c6  
    553553        return item 
    554554 
    555     def displayFile(self, filename=None, is_data=True): 
     555    def displayFile(self, filename=None, is_data=True, id=None): 
    556556        """ 
    557557        Forces display of charts for the given filename 
     
    560560        # Now query the model item for available plots 
    561561        plots = GuiUtils.plotsFromFilename(filename, model) 
    562  
     562        # Each fitpage contains the name based on fit widget number 
     563        fitpage_name = "" if id is None else "M"+str(id) 
    563564        new_plots = [] 
    564565        for item, plot in plots.items(): 
    565             if not self.updatePlot(plot): 
    566                 # Don't plot intermediate results, e.g. P(Q), S(Q) 
    567                 match = GuiUtils.theory_plot_ID_pattern.match(plot.id) 
    568                 # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 
    569                 if match and match.groups()[1] != None: 
    570                     continue 
     566            if self.updatePlot(plot) and filename != plot.name: 
     567                continue 
     568            # Don't plot intermediate results, e.g. P(Q), S(Q) 
     569            match = GuiUtils.theory_plot_ID_pattern.match(plot.id) 
     570            # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]") 
     571            if match and match.groups()[1] != None: 
     572                continue 
     573            # Don't include plots from different fitpages, but always include the original data 
     574            if fitpage_name in plot.name or filename == plot.name: 
    571575                # 'sophisticated' test to generate standalone plot for residuals 
    572576                if 'esiduals' in plot.title: 
     
    579583            self.plotData(new_plots) 
    580584 
    581     def displayData(self, data_list): 
     585    def displayData(self, data_list, id): 
    582586        """ 
    583587        Forces display of charts for the given data set 
     
    588592        # the data explorer indices. 
    589593        filename = plot_to_show.filename 
    590         self.displayFile(filename=filename, is_data=plot_to_show.is_data) 
     594        self.displayFile(filename=filename, is_data=plot_to_show.is_data, id=id) 
    591595 
    592596    def addDataPlot2D(self, plot_set, item): 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r339e22b r5b144c6  
    921921            self.filesWidget.displayFile(filename=filename, is_data=True) 
    922922 
    923     def showPlot(self, plot): 
     923    def showPlot(self, plot, id): 
    924924        """ 
    925925        Pass the show plot request to the data explorer 
    926926        """ 
    927927        if hasattr(self, "filesWidget"): 
    928             self.filesWidget.displayData(plot) 
     928            self.filesWidget.displayData(plot, id) 
    929929 
    930930    def uncheckAllMenuItems(self, menuObject): 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r685602a r5b144c6  
    18411841        data_to_show = self.data if self.data_is_loaded else self.model_data 
    18421842        if data_to_show is not None: 
    1843             self.communicate.plotRequestedSignal.emit([data_to_show]) 
     1843            self.communicate.plotRequestedSignal.emit([data_to_show], self.tab_id) 
    18441844 
    18451845    def onOptionsUpdate(self): 
     
    24222422 
    24232423        if self.data_is_loaded: 
    2424             GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
     2424            #GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 
     2425            pass 
    24252426        else: 
    24262427            # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 
  • src/sas/qtgui/Plotting/Plotter.py

    r0cd98a1 r5b144c6  
    561561 
    562562        #Remove another Fit, if exists 
    563         self.removePlot("fit") 
     563        self.removePlot("Fit") 
    564564 
    565565        self.fit_result.reset_view() 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py

    rb8080e1 r5b144c6  
    5757        self.plotter.data = self.data 
    5858        self.plotter.show() 
    59         FigureCanvas.draw_idle = MagicMock() 
     59        FigureCanvas.draw = MagicMock() 
    6060 
    6161        self.plotter.plot(hide_error=False) 
    6262 
    6363        self.assertEqual(self.plotter.ax.get_xscale(), 'log') 
    64         self.assertTrue(FigureCanvas.draw_idle.called) 
     64        self.assertTrue(FigureCanvas.draw.called) 
    6565 
    6666        self.plotter.figure.clf() 
     
    7070        self.plotter.data = self.data 
    7171        self.plotter.show() 
    72         FigureCanvas.draw_idle = MagicMock() 
     72        FigureCanvas.draw = MagicMock() 
    7373 
    7474        self.plotter.plot(hide_error=True) 
    7575 
    7676        self.assertEqual(self.plotter.ax.get_yscale(), 'log') 
    77         self.assertTrue(FigureCanvas.draw_idle.called) 
     77        self.assertTrue(FigureCanvas.draw.called) 
    7878        self.plotter.figure.clf() 
    7979 
     
    9191        self.plotter.data = data 
    9292        self.plotter.show() 
    93         FigureCanvas.draw_idle = MagicMock() 
     93        FigureCanvas.draw = MagicMock() 
    9494 
    9595        self.plotter.plot(hide_error=True) 
     
    9797        self.assertEqual(self.plotter.ax.get_xscale(), 'linear') 
    9898        self.assertEqual(self.plotter.ax.get_yscale(), 'linear') 
    99         self.assertTrue(FigureCanvas.draw_idle.called) 
     99        self.assertTrue(FigureCanvas.draw.called) 
    100100 
    101101    def testCreateContextMenuQuick(self): 
     
    262262        # Just this one plot 
    263263        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) 
    264         self.plotter.onLinearFit(1) 
     264        self.plotter.onLinearFit('Test name') 
    265265 
    266266        # Check that exec_ got called 
     
    289289 
    290290        # Delete one set 
    291         self.plotter.onRemovePlot(2) 
     291        self.plotter.onRemovePlot('Test name 2') 
    292292        # Assure we have two sets 
    293293        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) 
     
    296296 
    297297        # Delete the remaining set 
    298         self.plotter.onRemovePlot(1) 
     298        self.plotter.onRemovePlot('Test name') 
    299299        # Assure we have no plots 
    300300        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 0) 
     
    331331        self.assertEqual(yl, "$YAXIS(cake)$") 
    332332        # The hide_error flag should also remain 
    333         self.assertTrue(self.plotter.plot_dict[2].hide_error) 
     333        self.assertTrue(self.plotter.plot_dict['Test name 2'].hide_error) 
    334334        self.plotter.figure.clf() 
    335335 
     
    355355 
    356356        # Reverse the toggle 
    357         self.plotter.onToggleHideError(2) 
     357        self.plotter.onToggleHideError('Test name 2') 
    358358        # See that the labels didn't change 
    359359        xl = self.plotter.ax.xaxis.label.get_text() 
     
    362362        self.assertEqual(yl, "$YAXIS(cake)$") 
    363363        # The hide_error flag should toggle 
    364         self.assertEqual(self.plotter.plot_dict[2].hide_error, not error_status) 
     364        self.assertEqual(self.plotter.plot_dict['Test name 2'].hide_error, not error_status) 
    365365        self.plotter.figure.clf() 
    366366 
     
    417417        self.assertEqual(yl, "$YAXIS(cake)$") 
    418418        # The hide_error flag should be as set 
    419         self.assertEqual(self.plotter.plot_dict[2].hide_error, error_status) 
     419        self.assertEqual(self.plotter.plot_dict['Test name 2'].hide_error, error_status) 
    420420        self.plotter.figure.clf() 
    421421 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r339e22b r5b144c6  
    225225    # New plot requested from the GUI manager 
    226226    # Old "NewPlotEvent" 
    227     plotRequestedSignal = QtCore.pyqtSignal(list) 
     227    plotRequestedSignal = QtCore.pyqtSignal(list, int) 
    228228 
    229229    # Plot from file names 
     
    288288    for index in range(item.rowCount()): 
    289289        plot_item = item.child(index) 
    290         if plot_item.isCheckable(): 
    291             plot_data = plot_item.child(0).data() 
    292             if plot_data.id is not None and \ 
    293                    (plot_data.name == update_data.name or plot_data.id == update_data.id): 
     290        if not plot_item.isCheckable(): 
     291            continue 
     292        plot_data = plot_item.child(0).data() 
     293        if plot_data.id is not None and \ 
     294                plot_data.name == update_data.name: 
     295                #(plot_data.name == update_data.name or plot_data.id == update_data.id): 
    294296            # if plot_data.id is not None and plot_data.id == update_data.id: 
    295                 # replace data section in item 
    296                 plot_item.child(0).setData(update_data) 
    297                 plot_item.setText(name) 
    298                 # Plot title if any 
    299                 if plot_item.child(1).hasChildren(): 
    300                     plot_item.child(1).child(0).setText("Title: %s"%name) 
    301                 # Force redisplay 
    302                 return 
     297            # replace data section in item 
     298            plot_item.child(0).setData(update_data) 
     299            plot_item.setText(name) 
     300            # Plot title if any 
     301            if plot_item.child(1).hasChildren(): 
     302                plot_item.child(1).child(0).setText("Title: %s"%name) 
     303            # Force redisplay 
     304            return 
    303305 
    304306    # Create the new item 
Note: See TracChangeset for help on using the changeset viewer.