Ignore:
Timestamp:
May 2, 2018 6:59:34 AM (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:
b0ba43e
Parents:
6da860a
Message:

Add a stop calculations button to P(r). Plus unit tests.

File:
1 edited

Legend:

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

    r6da860a r72ecbdf2  
    7979        self.estimationThread = None 
    8080        self.estimationThreadNT = None 
     81        self.isCalculating = False 
    8182 
    8283        # Mapping for all data items 
     
    167168        self.calculateAllButton.clicked.connect(self.startThreadAll) 
    168169        self.calculateThisButton.clicked.connect(self.startThread) 
     170        self.stopButton.clicked.connect(self.stopCalculation) 
    169171        self.removeButton.clicked.connect(self.removeData) 
    170172        self.helpButton.clicked.connect(self.help) 
     
    301303        """ 
    302304        self.calculateAllButton.setEnabled(len(self._dataList) > 1 
    303                                            and not self.isBatch) 
     305                                           and not self.isBatch 
     306                                           and not self.isCalculating) 
    304307        self.calculateThisButton.setEnabled(self.logic.data_is_loaded 
    305                                             and not self.isBatch) 
     308                                            and not self.isBatch 
     309                                            and not self.isCalculating) 
    306310        self.removeButton.setEnabled(self.logic.data_is_loaded) 
    307311        self.explorerButton.setEnabled(self.logic.data_is_loaded) 
     312        self.stopButton.setVisible(self.isCalculating) 
    308313        self.regConstantSuggestionButton.setEnabled( 
    309314            self.logic.data_is_loaded and 
     
    413418            self.batchResultsWindow.setupTable(self.batchResults) 
    414419        self.batchResultsWindow.show() 
     420 
     421    def stopCalculation(self): 
     422        """ Stop all threads, return to the base state and update GUI """ 
     423        if self.calcThread: 
     424            self.calcThread.stop() 
     425        if self.estimationThread: 
     426            self.estimationThread.stop() 
     427        if self.estimationThreadNT: 
     428            self.estimationThreadNT.stop() 
     429        # Show any batch calculations that successfully completed 
     430        if self.isBatch and self.batchResultsWindow is not None: 
     431            self.showBatchOutput() 
     432        self.isBatch = False 
     433        self.isCalculating = False 
     434        self.updateGuiValues() 
    415435 
    416436    ###################################################################### 
     
    571591 
    572592    def startThreadAll(self): 
     593        self.isCalculating = True 
    573594        self.isBatch = True 
    574595        self.batchComplete = [] 
     
    592613        else: 
    593614            # If no data sets left, end batch calculation 
     615            self.isCalculating = False 
    594616            self.batchComplete = [] 
    595617            self.calculateAllButton.setText("Calculate All") 
     
    604626 
    605627        # Set data before running the calculations 
     628        self.isCalculating = True 
     629        self.enableButtons() 
    606630        self.updateCalculator() 
    607631        # Disable calculation buttons to prevent thread interference 
    608         self.calculateAllButton.setEnabled(False) 
    609         self.calculateThisButton.setEnabled(False) 
    610632 
    611633        # If a thread is already started, stop it 
     
    744766        # Udpate internals and GUI 
    745767        self.updateDataList(self._data) 
    746         self.updateGuiValues() 
    747768        if self.isBatch: 
    748769            self.batchComplete.append(self.dataList.currentIndex()) 
    749770            self.startNextBatchItem() 
     771        else: 
     772            self.isCalculating = False 
     773        self.updateGuiValues() 
    750774 
    751775    def _threadError(self, error): 
Note: See TracChangeset for help on using the changeset viewer.