Ignore:
Timestamp:
Feb 2, 2018 7:21:48 AM (6 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:
a90c9c5
Parents:
5e66738
Message:

More code review related fixes

File:
1 edited

Legend:

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

    rda9a0722 r14ec91c5  
    55 
    66import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     7import sas.qtgui.Utilities.LocalConfig as LocalConfig 
     8 
    79from PyQt5 import QtGui, QtCore, QtWidgets 
    810 
     
    1517from sas.qtgui.Perspectives.Fitting.ConsoleUpdate import ConsoleUpdate 
    1618from sas.qtgui.Perspectives.Fitting.ComplexConstraint import ComplexConstraint 
    17 from sas.qtgui.Perspectives.Fitting.Constraints import Constraint 
     19from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 
    1820 
    1921class ConstraintWidget(QtWidgets.QWidget, Ui_ConstraintWidgetUI): 
     
    2224    """ 
    2325 
    24     def __init__(self, parent=None, tab_id=1): 
     26    def __init__(self, parent=None): 
    2527        super(ConstraintWidget, self).__init__() 
    2628        self.parent = parent 
    2729        self.setupUi(self) 
    2830        self.currentType = "FitPage" 
    29         self.tab_id = tab_id 
    3031        # Page id for fitting 
    3132        # To keep with previous SasView values, use 300 as the start offset 
    32         self.page_id = 300 + self.tab_id 
     33        self.page_id = 301 
    3334 
    3435        # Remember previous content of modified cell 
     
    118119        pass 
    119120 
     121    def getTabsForFit(self): 
     122        """ 
     123        Returns list of tab names selected for fitting 
     124        """ 
     125        return [tab for tab in self.tabs_for_fitting if self.tabs_for_fitting[tab]] 
     126 
    120127    def onFit(self): 
    121128        """ 
     
    123130        """ 
    124131        # Find out all tabs to fit 
    125         tabs_to_fit = [tab for tab in self.tabs_for_fitting if self.tabs_for_fitting[tab]] 
     132        tabs_to_fit = self.getTabsForFit() 
    126133 
    127134        # Single fitter for the simultaneous run 
    128135        sim_fitter = Fit() 
    129136        sim_fitter.fitter_id = self.page_id 
     137 
     138        # Notify the parent about fitting started 
     139        self.parent.fittingStartedSignal.emit(tabs_to_fit) 
    130140 
    131141        # prepare fitting problems for each tab 
     
    157167        completefn = self.onBatchFitComplete if self.currentType=='BatchPage' else self.onFitComplete 
    158168 
    159         #if USING_TWISTED: 
    160         handler = None 
    161         updater = None 
    162         #else: 
    163         #    handler = ConsoleUpdate(parent=self.parent, 
    164         #                            manager=self, 
    165         #                            improvement_delta=0.1) 
    166         #    updater = handler.update_fit 
     169        if LocalConfig.USING_TWISTED: 
     170            handler = None 
     171            updater = None 
     172        else: 
     173            handler = ConsoleUpdate(parent=self.parent, 
     174                                    manager=self, 
     175                                    improvement_delta=0.1) 
     176            updater = handler.update_fit 
    167177 
    168178        batch_inputs = {} 
     
    178188                             completefn=completefn) 
    179189 
    180         #if USING_TWISTED: 
    181         # start the trhrhread with twisted 
    182         calc_thread = threads.deferToThread(calc_fit.compute) 
    183         calc_thread.addCallback(completefn) 
    184         calc_thread.addErrback(self.onFitFailed) 
    185         #else: 
    186         #    # Use the old python threads + Queue 
    187         #    calc_fit.queue() 
    188         #    calc_fit.ready(2.5) 
     190        if LocalConfig.USING_TWISTED: 
     191            # start the trhrhread with twisted 
     192            calc_thread = threads.deferToThread(calc_fit.compute) 
     193            calc_thread.addCallback(completefn) 
     194            calc_thread.addErrback(self.onFitFailed) 
     195        else: 
     196            # Use the old python threads + Queue 
     197            calc_fit.queue() 
     198            calc_fit.ready(2.5) 
    189199 
    190200 
     
    300310        self.cmdFit.setEnabled(True) 
    301311 
     312        # Notify the parent about completed fitting 
     313        self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) 
     314 
    302315        # get the elapsed time 
    303316        elapsed = result[1] 
     
    330343        self.cmdFit.setEnabled(True) 
    331344 
     345        # Notify the parent about completed fitting 
     346        self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) 
     347 
    332348        # get the elapsed time 
    333349        elapsed = result[1] 
     
    348364        self.cmdFit.setText("Fit") 
    349365        self.cmdFit.setEnabled(True) 
     366 
     367        # Notify the parent about completed fitting 
     368        self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) 
    350369 
    351370        msg = "Fitting failed: %s s.\n" % reason 
Note: See TracChangeset for help on using the changeset viewer.