Changeset ecc5d043 in sasview for src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
- Timestamp:
- Nov 16, 2018 3:05:20 AM (5 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 09e0c32
- Parents:
- baeac95
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
re5ae812 recc5d043 22 22 Constraints Dialog to select the desired parameter/model constraints. 23 23 """ 24 24 fitCompleteSignal = QtCore.pyqtSignal(tuple) 25 25 def __init__(self, parent=None): 26 26 super(ConstraintWidget, self).__init__() … … 93 93 self.cmdFit.clicked.connect(self.onFit) 94 94 self.cmdHelp.clicked.connect(self.onHelp) 95 self.cmdAdd.clicked.connect(self.showMultiConstraint) 95 96 self.chkChain.toggled.connect(self.onChainFit) 96 97 … … 100 101 self.tblConstraints.cellChanged.connect(self.onConstraintChange) 101 102 103 # Internal signals 104 self.fitCompleteSignal.connect(self.fitComplete) 105 102 106 # External signals 103 107 self.parent.tabsModifiedSignal.connect(self.initializeFitList) … … 156 160 fitter = Fit() 157 161 fitter.fitter_id = self.page_id 158 159 # Notify the parent about fitting started160 self.parent.fittingStartedSignal.emit(tabs_to_fit)161 162 162 163 # prepare fitting problems for each tab … … 177 178 except ValueError: 178 179 # No parameters selected in one of the tabs 179 no_params_msg = "Fitting can 180 no_params_msg = "Fitting cannot be performed.\n" +\ 180 181 "Not all tabs chosen for fitting have parameters selected for fitting." 181 182 QtWidgets.QMessageBox.warning(self, … … 200 201 batch_inputs = {} 201 202 batch_outputs = {} 203 204 # Notify the parent about fitting started 205 self.parent.fittingStartedSignal.emit(tabs_to_fit) 202 206 203 207 # new fit thread object … … 292 296 """ 293 297 item = self.tblConstraints.item(row, column) 294 if column == 0: 295 # Update the tabs for fitting list 296 constraint = self.available_constraints[row] 297 constraint.active = (item.checkState() == QtCore.Qt.Checked) 298 if column != 0: return 299 # Update the tabs for fitting list 300 constraint = self.available_constraints[row] 301 constraint.active = (item.checkState() == QtCore.Qt.Checked) 302 # Update the constraint formula 303 constraint = self.available_constraints[row] 304 function = item.text() 305 # remove anything left of '=' to get the constraint 306 function = function[function.index('=')+1:] 307 # No check on function here - trust the user (R) 308 if function != constraint.func: 309 #from sas.sascalc.fit.expression import compile_constraints 310 constraint.func = function 298 311 299 312 def onTabCellEntered(self, row, column): … … 307 320 308 321 def onFitComplete(self, result): 322 """ 323 Send the fit complete signal to main thread 324 """ 325 self.fitCompleteSignal.emit(result) 326 327 def fitComplete(self, result): 309 328 """ 310 329 Respond to the successful fit complete signal … … 383 402 msg = "Fitting failed: %s s.\n" % reason 384 403 self.parent.communicate.statusBarUpdateSignal.emit(msg) 385 404 386 405 def isTabImportable(self, tab): 387 406 """ … … 596 615 # Show the text in the constraint table 597 616 item = self.uneditableItem(label) 617 item = QtWidgets.QTableWidgetItem(label) 598 618 item.setFlags(item.flags() ^ QtCore.Qt.ItemIsUserCheckable) 599 619 item.setCheckState(QtCore.Qt.Checked) … … 664 684 return None 665 685 686 def onAcceptConstraint(self, con_tuple): 687 """ 688 Receive constraint tuple from the ComplexConstraint dialog and adds contraint 689 """ 690 #"M1, M2, M3" etc 691 model_name, constraint = con_tuple 692 constrained_tab = self.getObjectByName(model_name) 693 if constrained_tab is None: 694 return 695 696 # Find the constrained parameter row 697 constrained_row = constrained_tab.getRowFromName(constraint.param) 698 699 # Update the tab 700 constrained_tab.addConstraintToRow(constraint, constrained_row) 701 666 702 def showMultiConstraint(self): 667 703 """ … … 669 705 """ 670 706 selected_rows = self.selectedParameters(self.tblTabList) 671 assert(len(selected_rows)==2) 707 if len(selected_rows)!=2: 708 msg = "Please select two fit pages from the Source Choice table." 709 msgbox = QtWidgets.QMessageBox(self.parent) 710 msgbox.setIcon(QtWidgets.QMessageBox.Warning) 711 msgbox.setText(msg) 712 msgbox.setWindowTitle("2 fit page constraints") 713 retval = msgbox.exec_() 714 return 672 715 673 716 tab_list = [ObjectLibrary.getObject(self.tblTabList.item(s, 0).data(0)) for s in selected_rows] 674 717 # Create and display the widget for param1 and param2 675 718 cc_widget = ComplexConstraint(self, tabs=tab_list) 719 cc_widget.constraintReadySignal.connect(self.onAcceptConstraint) 720 676 721 if cc_widget.exec_() != QtWidgets.QDialog.Accepted: 677 722 return 678 679 constraint = Constraint()680 model1, param1, operator, constraint_text = cc_widget.constraint()681 682 constraint.func = constraint_text683 # param1 is the parameter we're constraining684 constraint.param = param1685 686 # Find the right tab687 constrained_tab = self.getObjectByName(model1)688 if constrained_tab is None:689 return690 691 # Find the constrained parameter row692 constrained_row = constrained_tab.getRowFromName(param1)693 694 # Update the tab695 constrained_tab.addConstraintToRow(constraint, constrained_row)696 723 697 724 def getFitPage(self):
Note: See TracChangeset
for help on using the changeset viewer.