Changeset 116dd4c1 in sasview for src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
- Timestamp:
- Jan 24, 2018 8:07:08 AM (6 years ago)
- 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:
- c6343a5
- Parents:
- eb1a386
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
reb1a386 r116dd4c1 2 2 import sys 3 3 4 from twisted.internet import threads 5 4 6 import sas.qtgui.Utilities.GuiUtils as GuiUtils 5 7 from PyQt5 import QtGui, QtCore, QtWidgets 6 8 9 from sas.sascalc.fit.BumpsFitting import BumpsFit as Fit 10 7 11 import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 8 9 12 from sas.qtgui.Perspectives.Fitting.UI.ConstraintWidgetUI import Ui_ConstraintWidgetUI 10 13 from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget 14 from sas.qtgui.Perspectives.Fitting.FitThread import FitThread 15 from sas.qtgui.Perspectives.Fitting.ConsoleUpdate import ConsoleUpdate 11 16 from sas.qtgui.Perspectives.Fitting.ComplexConstraint import ComplexConstraint 12 17 from sas.qtgui.Perspectives.Fitting.Constraints import Constraint … … 17 22 """ 18 23 19 def __init__(self, parent=None ):24 def __init__(self, parent=None, tab_id=1): 20 25 super(ConstraintWidget, self).__init__() 21 26 self.parent = parent 22 27 self.setupUi(self) 23 28 self.currentType = "FitPage" 29 self.tab_id = tab_id 30 # Page id for fitting 31 # To keep with previous SasView values, use 300 as the start offset 32 self.page_id = 300 + self.tab_id 24 33 25 34 # Remember previous content of modified cell … … 114 123 Perform the constrained/simultaneous fit 115 124 """ 116 pass 125 # Find out all tabs to fit 126 tabs_to_fit = [tab for tab in self.tabs_for_fitting if self.tabs_for_fitting[tab]] 127 128 # Single fitter for the simultaneous run 129 sim_fitter = Fit() 130 sim_fitter.fitter_id = self.page_id 131 132 # prepare fitting problems for each tab 133 # 134 page_ids = [] 135 fitter_id = 0 136 sim_fitter=[sim_fitter] 137 for tab in tabs_to_fit: 138 tab_object = ObjectLibrary.getObject(tab) 139 sim_fitter, fitter_id = tab_object.prepareFitters(fitter=sim_fitter[0], fit_id=fitter_id) 140 page_ids.append([tab_object.page_id]) 141 142 # Create the fitting thread, based on the fitter 143 completefn = self.onBatchFitComplete if self.currentType=='BatchPage' else self.onFitComplete 144 145 #if USING_TWISTED: 146 handler = None 147 updater = None 148 #else: 149 # handler = ConsoleUpdate(parent=self.parent, 150 # manager=self, 151 # improvement_delta=0.1) 152 # updater = handler.update_fit 153 154 batch_inputs = {} 155 batch_outputs = {} 156 157 # new fit thread object 158 calc_fit = FitThread(handler=handler, 159 fn=sim_fitter, 160 batch_inputs=batch_inputs, 161 batch_outputs=batch_outputs, 162 page_id=page_ids, 163 updatefn=updater, 164 completefn=completefn) 165 166 #if USING_TWISTED: 167 # start the trhrhread with twisted 168 calc_thread = threads.deferToThread(calc_fit.compute) 169 calc_thread.addCallback(self.onFitComplete) 170 calc_thread.addErrback(self.onFitFailed) 171 #else: 172 # # Use the old python threads + Queue 173 # calc_fit.queue() 174 # calc_fit.ready(2.5) 175 176 177 #disable the Fit button 178 self.cmdFit.setText('Running...') 179 self.parent.communicate.statusBarUpdateSignal.emit('Fitting started...') 180 self.cmdFit.setEnabled(False) 117 181 118 182 def onHelp(self): … … 172 236 def onConstraintChange(self, row, column): 173 237 """ 174 Modify the constraint in-place.238 Modify the constraint's "active" instance variable. 175 239 """ 176 240 item = self.tblConstraints.item(row, column) … … 208 272 pass 209 273 274 def onFitComplete(self, result): 275 """ 276 Respond to the successful fit complete signal 277 """ 278 pass 279 280 def onBatchFitComplete(self, result): 281 """ 282 Respond to the successful batch fit complete signal 283 """ 284 pass 285 286 def onFitFailed(self, reason): 287 """ 288 """ 289 print("FIT FAILED: ", reason) 290 pass 291 210 292 def isTabImportable(self, tab): 211 293 """
Note: See TracChangeset
for help on using the changeset viewer.