Ignore:
Timestamp:
May 2, 2017 9:04:48 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
02ddfb4
Parents:
0a6e097
Message:

Compute/Show? Plot button logic: SASVIEW-271
Unit tests for plotting in fitting: SASVIEW-501

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r61a92d4 rd48cc19  
    7474        self.weighting = 0 
    7575 
     76        # Data for chosen model 
     77        self.model_data = None 
     78 
    7679        # Which tab is this widget displayed in? 
    7780        self.tab_id = id 
     
    250253        """ 
    251254        self.cmdFit.setEnabled(False) 
    252         self.cmdPlot.setEnabled(True) 
     255        self.cmdPlot.setEnabled(False) 
    253256        self.options_widget.cmdComputePoints.setVisible(False) # probably redundant 
    254257        self.chkPolydispersity.setEnabled(True) 
     
    305308        self.has_error_column = False 
    306309 
     310        # Set enablement on calculate/plot 
     311        self.cmdPlot.setEnabled(True) 
     312 
    307313        # SasModel -> QModel 
    308314        self.SASModelToQModel(model) 
    309315 
    310316        if self.data_is_loaded: 
     317            self.cmdPlot.setText("Show Plot") 
    311318            self.calculateQGridForModel() 
    312319        else: 
     320            self.cmdPlot.setText("Calculate") 
    313321            # Create default datasets if no data passed 
    314322            self.createDefaultDataset() 
     
    569577        Plot the current set of data 
    570578        """ 
     579        # Regardless of previous state, this should now be `plot show` functionality only 
     580        self.cmdPlot.setText("Show Plot") 
     581        self.recalculatePlotData() 
     582        self.showPlot() 
     583 
     584    def recalculatePlotData(self): 
     585        """ 
     586        Generate a new dataset for model 
     587        """ 
    571588        if not self.data_is_loaded: 
    572589            self.createDefaultDataset() 
    573590        self.calculateQGridForModel() 
     591 
     592    def showPlot(self): 
     593        """ 
     594        Show the current plot in MPL 
     595        """ 
     596        # Show the chart if ready 
     597        data_to_show = self.data if self.data_is_loaded else self.model_data 
     598        if data_to_show is not None: 
     599            self.communicate.plotRequestedSignal.emit([data_to_show]) 
    574600 
    575601    def onOptionsUpdate(self): 
     
    582608        self.lblMinRangeDef.setText(str(self.q_range_min)) 
    583609        self.lblMaxRangeDef.setText(str(self.q_range_max)) 
    584         self.onPlot() 
     610        self.recalculatePlotData() 
    585611 
    586612    def setDefaultStructureCombo(self): 
     
    766792        # Force the chart update when actual parameters changed 
    767793        if model_column == 1: 
    768             self.onPlot() 
     794            self.recalculatePlotData() 
    769795 
    770796    def checkboxSelected(self, item): 
     
    891917        Plot the current 1D data 
    892918        """ 
    893         fitted_plot = self.logic.new1DPlot(return_data, self.tab_id) 
    894         self.calculateResiduals(fitted_plot) 
     919        fitted_data = self.logic.new1DPlot(return_data, self.tab_id) 
     920        self.calculateResiduals(fitted_data) 
     921        self.model_data = fitted_data 
    895922 
    896923    def complete2D(self, return_data): 
     
    900927        fitted_data = self.logic.new2DPlot(return_data) 
    901928        self.calculateResiduals(fitted_data) 
     929        self.model_data = fitted_data 
    902930 
    903931    def calculateResiduals(self, fitted_data): 
     
    914942        self.lblChi2Value.setText(chi2_repr) 
    915943 
     944        self.communicate.plotUpdateSignal.emit([fitted_data]) 
     945 
    916946        # Plot residuals if actual data 
    917947        if self.data_is_loaded: 
     
    920950            self.createNewIndex(residuals_plot) 
    921951            self.communicate.plotUpdateSignal.emit([residuals_plot]) 
    922  
    923         self.communicate.plotUpdateSignal.emit([fitted_data]) 
    924952 
    925953    def calcException(self, etype, value, tb): 
Note: See TracChangeset for help on using the changeset viewer.