Changeset 570a2f73 in sasview


Ignore:
Timestamp:
Oct 29, 2017 12:55:14 PM (6 years ago)
Author:
krzywon
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:
4cac8a47
Parents:
c00a28ff
Message:

Track P(r) plots so they can be updated rather than replaced.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    rc00a28ff r570a2f73  
    2121 
    2222def is_float(value): 
     23    """Converts text input values to floats. Empty strings throw ValueError""" 
    2324    try: 
    2425        return float(value) 
     
    2627        return 0.0 
    2728 
     29 
     30# TODO: Remove data 
     31# TODO: Modify plot references, don't just send new 
     32# TODO: Explorer button - link to PR from AW 
     33# TODO: Update help with batch capabilities 
     34# TODO: Window should not be fixed size 
     35# TODO: Easy way to scroll through results - no tabs in window(?) - 'spreadsheet' 
     36# TODO: Method to export results in some meaningful way 
    2837class InversionWindow(QtGui.QTabWidget, Ui_PrInversion): 
    2938    """ 
     
    7180                self._data_list[datum] = self._calculator.clone() 
    7281 
    73         # plots 
     82        # plots for current data 
    7483        self.pr_plot = None 
    7584        self.data_plot = None 
     85        # plot references for all data in perspective 
     86        self.pr_plot_list = {} 
     87        self.data_plot_list = {} 
    7688 
    7789        self.model = QtGui.QStandardItemModel(self) 
     
    299311            self.close() 
    300312            InversionWindow.__init__(self.parent(), self._data_list.keys()) 
    301             return 
     313            exit(0) 
     314        # TODO: Only send plot first time - otherwise, update in complete 
    302315        if self.pr_plot is not None: 
    303316            title = self.pr_plot.name 
     
    356369 
    357370        for data in data_item: 
    358             self.setCurrentData(data) 
     371            # Create initial internal mappings 
     372            self._data_list[data] = self._calculator.clone() 
     373            self._data_set = GuiUtils.dataFromItem(data) 
     374            self.data_plot_list[data] = self.data_plot 
     375            self.pr_plot_list[data] = self.pr_plot 
    359376            ref_var = QtCore.QVariant(data) 
    360377            self.populateDataComboBox(self._data_set.filename, ref_var) 
     378            self.setCurrentData(data) 
     379 
     380            # Estimate initial values from data 
     381            self.performEstimate() 
     382            self.logic = InversionLogic(self._data_set) 
     383 
     384            # Estimate q range 
     385            qmin, qmax = self.logic.computeDataRange() 
     386            self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem( 
     387                "{:.4g}".format(qmin))) 
     388            self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem( 
     389                "{:.4g}".format(qmax))) 
     390 
     391        self.enableButtons() 
    361392 
    362393    def setCurrentData(self, data_ref): 
    363         """Set the selected data set to be the current data""" 
     394        """Get the current data and display as necessary""" 
    364395 
    365396        if not isinstance(data_ref, QtGui.QStandardItem): 
     
    370401        self._data = data_ref 
    371402        self._data_set = GuiUtils.dataFromItem(data_ref) 
    372         self._data_list[self._data] = self._calculator 
    373  
    374         # Estimate initial values from data 
    375         self.performEstimate() 
    376         self.logic = InversionLogic(self._data_set) 
    377  
    378         # Estimate q range 
    379         qmin, qmax = self.logic.computeDataRange() 
    380         self.model.setItem(WIDGETS.W_QMIN, QtGui.QStandardItem( 
    381             "{:.4g}".format(qmin))) 
    382         self.model.setItem(WIDGETS.W_QMAX, QtGui.QStandardItem( 
    383             "{:.4g}".format(qmax))) 
    384  
    385         self.enableButtons() 
     403        self._calculator = self._data_list[data_ref] 
     404        self.pr_plot = self.pr_plot_list[data_ref] 
     405        self.data_plot = self.data_plot_list[data_ref] 
    386406 
    387407    ###################################################################### 
     
    524544        # Show result on control panel 
    525545 
    526         # TODO: Connect self._calculator to GUI 
     546        # TODO: Connect self._calculator to GUI - two-to-one connection possible? 
    527547        self.model.setItem(WIDGETS.W_RG, QtGui.QStandardItem(str(pr.rg(out)))) 
    528548        self.model.setItem(WIDGETS.W_I_ZERO, 
     
    550570        self._data_list[self._data] = self._calculator.clone() 
    551571 
    552         # FIXME: Update plots if exist 
    553         # TODO: Keep plot references so they can be updated. 
    554         # TODO: On data change, update current reference to this->plot 
    555  
     572        # Create new P(r) and fit plots 
    556573        if self.pr_plot is None: 
    557574            self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 
     575            self.pr_plot_list[self._data] = self.pr_plot 
     576        else: 
     577            # FIXME: this should update the existing plot, not create a new one 
     578            self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 
     579            self.pr_plot_list[self._data] = self.pr_plot 
    558580        if self.data_plot is None: 
    559581            self.data_plot = self.logic.new1DPlot(out, self._calculator) 
     582            self.data_plot_list[self._data] = self.data_plot 
     583        else: 
     584            # FIXME: this should update the existing plot, not create a new one 
     585            self.data_plot = self.logic.new1DPlot(out, self._calculator) 
     586            self.data_plot_list[self._data] = self.data_plot 
    560587 
    561588    def _threadError(self, error): 
Note: See TracChangeset for help on using the changeset viewer.