Changeset c00a28ff in sasview


Ignore:
Timestamp:
Oct 29, 2017 12:04:00 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:
570a2f73
Parents:
dfd8233
Message:

Allow P(r) to calculate current data set or all. Update documentation and error handling.

Location:
src/sas/qtgui/Perspectives/Inversion
Files:
1 added
3 edited

Legend:

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

    rdfd8233 rc00a28ff  
    8383        # Set up the Widget Map 
    8484        self.setupMapper() 
     85        # Set base window state 
     86        self.setupWindow() 
    8587 
    8688    ###################################################################### 
     
    118120    def setupLinks(self): 
    119121        """Connect the use controls to their appropriate methods""" 
    120         self.enableButtons() 
    121122        self.dataList.currentIndexChanged.connect(self.displayChange) 
    122         self.calculateButton.clicked.connect(self.startThread) 
     123        self.calculateAllButton.clicked.connect(self.startThreadAll) 
     124        self.calculateThisButton.clicked.connect(self.startThread) 
    123125        self.helpButton.clicked.connect(self.help) 
    124126        self.estimateBgd.toggled.connect(self.toggleBgd) 
     
    149151                str(self.slitHeightInput.text())))) 
    150152        self.model.itemChanged.connect(self.model_changed) 
    151         self.estimateBgd.setChecked(True) 
    152153 
    153154    def setupMapper(self): 
     
    194195 
    195196        # Main Buttons 
    196         self.mapper.addMapping(self.calculateButton, WIDGETS.W_CALCULATE) 
     197        self.mapper.addMapping(self.calculateAllButton, WIDGETS.W_CALCULATE_ALL) 
     198        self.mapper.addMapping(self.calculateThisButton, 
     199                               WIDGETS.W_CALCULATE_VISIBLE) 
    197200        self.mapper.addMapping(self.helpButton, WIDGETS.W_HELP) 
    198201 
     
    238241        self.model.setItem(WIDGETS.W_SIGMA_POS_FRACTION, item) 
    239242 
     243    def setupWindow(self): 
     244        """Initialize base window state on init""" 
     245        self.setTabPosition(0) 
     246        self.enableButtons() 
     247        self.estimateBgd.setChecked(True) 
     248 
    240249    ###################################################################### 
    241250    # Methods for updating GUI 
     
    245254        Enable buttons when data is present, else disable them 
    246255        """ 
    247         if self.logic.data_is_loaded: 
    248             self.explorerButton.setEnabled(True) 
    249             self.calculateButton.setEnabled(True) 
    250         else: 
    251             self.calculateButton.setEnabled(False) 
    252             self.explorerButton.setEnabled(False) 
     256        self.explorerButton.setEnabled(self.logic.data_is_loaded) 
     257        self.calculateAllButton.setEnabled(self.logic.data_is_loaded) 
     258        self.calculateThisButton.setEnabled(self.logic.data_is_loaded) 
    253259 
    254260    def populateDataComboBox(self, filename, data_ref): 
     
    287293        """Update the values when user makes changes""" 
    288294        if not self.mapper: 
     295            msg = "Unable to update P{r}. The connection between the main GUI " 
     296            msg += "and P(r) was severed. Attempting to restart P(r)." 
     297            logging.warning(msg) 
     298            self.setClosable(True) 
     299            self.close() 
     300            InversionWindow.__init__(self.parent(), self._data_list.keys()) 
    289301            return 
    290302        if self.pr_plot is not None: 
     
    314326        """ 
    315327        Toggle the background between manual and estimated 
    316         :param item: gui item that was triggered 
    317328        """ 
    318329        sender = self.sender() 
     
    326337        Open the Explorer window to see correlations between params and results 
    327338        """ 
    328         # TODO: This depends on SVCC-45 
     339        # TODO: Look at PR from AW - Is there anything else I need to do? 
    329340        pass 
    330341 
     
    334345    def setData(self, data_item=None, is_batch=False): 
    335346        """ 
    336         Assign new data set or sets to the P(r) perspective 
    337         Obtain a QStandardItem object and dissect it to get Data1D/2D 
     347        Assign new data set(s) to the P(r) perspective 
     348        Obtain a QStandardItem object and parse it to get Data1D/2D 
    338349        Pass it over to the calculator 
    339350        """ 
     
    350361 
    351362    def setCurrentData(self, data_ref): 
    352         """Set an individual data set to the current data""" 
     363        """Set the selected data set to be the current data""" 
    353364 
    354365        if not isinstance(data_ref, QtGui.QStandardItem): 
     
    377388    # Thread Creators 
    378389 
    379     def startThread(self): 
    380         """ 
    381             Start a calculation thread 
    382         """ 
    383         from Thread import CalcPr 
    384  
     390    # TODO: Move to individual class(?) 
     391 
     392    def startThreadAll(self): 
    385393        for data_ref, pr in self._data_list.items(): 
    386394            self._data_set = GuiUtils.dataFromItem(data_ref) 
    387395            self._calculator = pr 
    388             # Set data before running the calculations 
    389             self.update_calculator() 
    390  
    391             # If a thread is already started, stop it 
    392             if self.calc_thread is not None and self.calc_thread.isrunning(): 
    393                 self.calc_thread.stop() 
    394             pr = self._calculator.clone() 
    395             nfunc = int(UI.TabbedInversionUI._fromUtf8( 
    396                 self.noOfTermsInput.text())) 
    397             self.calc_thread = CalcPr(pr, nfunc, 
    398                                       error_func=self._threadError, 
    399                                       completefn=self._completed, updatefn=None) 
    400             self.calc_thread.queue() 
    401             self.calc_thread.ready(2.5) 
     396            self.startThread() 
     397 
     398    def startThread(self): 
     399        """ 
     400            Start a calculation thread 
     401        """ 
     402        from Thread import CalcPr 
     403 
     404        # Set data before running the calculations 
     405        self.update_calculator() 
     406 
     407        # If a thread is already started, stop it 
     408        if self.calc_thread is not None and self.calc_thread.isrunning(): 
     409            self.calc_thread.stop() 
     410        pr = self._calculator.clone() 
     411        nfunc = int(UI.TabbedInversionUI._fromUtf8( 
     412            self.noOfTermsInput.text())) 
     413        self.calc_thread = CalcPr(pr, nfunc, 
     414                                  error_func=self._threadError, 
     415                                  completefn=self._completed, updatefn=None) 
     416        self.calc_thread.queue() 
     417        self.calc_thread.ready(2.5) 
    402418 
    403419    def performEstimateNT(self): 
     
    534550        self._data_list[self._data] = self._calculator.clone() 
    535551 
     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 
    536556        if self.pr_plot is None: 
    537557            self.pr_plot = self.logic.newPRPlot(out, self._calculator, cov) 
  • src/sas/qtgui/Perspectives/Inversion/InversionUtils.py

    re7651ff rc00a28ff  
    2727                'W_SIGMA_POS_FRACTION', 
    2828                # bottom buttons 
    29                 'W_CALCULATE', 
     29                'W_CALCULATE_ALL', 
     30                'W_CALCULATE_VISIBLE', 
    3031                'W_HELP' 
    3132) 
  • src/sas/qtgui/Perspectives/Inversion/UI/TabbedInversionUI.ui

    r57ad773 rc00a28ff  
    3939     </property> 
    4040     <item> 
    41       <widget class="QPushButton" name="calculateButton"> 
     41      <widget class="QPushButton" name="calculateThisButton"> 
     42       <property name="text"> 
     43        <string>Calculate</string> 
     44       </property> 
     45      </widget> 
     46     </item> 
     47     <item> 
     48      <widget class="QPushButton" name="calculateAllButton"> 
    4249       <property name="sizePolicy"> 
    4350        <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> 
     
    4754       </property> 
    4855       <property name="text"> 
    49         <string>Calculate</string> 
     56        <string>Calculate All</string> 
    5057       </property> 
    5158      </widget> 
Note: See TracChangeset for help on using the changeset viewer.