Changeset ba01ad1 in sasview for src/sas/qtgui
- Timestamp:
- Jan 19, 2018 6:02:09 AM (7 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:
- 0764593
- Parents:
- c5a2722f
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py
rc5a2722f rba01ad1 152 152 param_str = self.cbParam2.currentText() 153 153 constraint_text = constraint_text.strip() 154 model_str = constraint_text[:constraint_text.index('.')] 155 #constraint_text = constraint_text[constraint_text.index('.')+1:] 154 model_str = self.txtName2.text() 156 155 157 156 # 0. Has to contain the model name … … 159 158 return False 160 159 161 # Remove model name from constraint text160 # Remove model name from constraint 162 161 constraint_text = constraint_text.replace(model_str+".",'') 163 162 -
src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
rc5a2722f rba01ad1 25 25 # Remember previous content of modified cell 26 26 self.current_cell = "" 27 28 # Tabs used in simultaneous fitting 29 # tab_name : True/False 30 self.tabs_for_fitting = {} 27 31 28 32 # Set up the widgets … … 75 79 76 80 # QTableWidgets 77 self.tblTabList.cellChanged.connect(self.on MonikerEdit)81 self.tblTabList.cellChanged.connect(self.onTabCellEdit) 78 82 self.tblTabList.cellDoubleClicked.connect(self.onTabCellEntered) 79 83 self.tblConstraints.cellChanged.connect(self.onConstraintChange) 80 84 81 85 # External signals 82 self.parent.tabsModifiedSignal.connect(self.initializeFitList) 86 #self.parent.tabsModifiedSignal.connect(self.initializeFitList) 87 self.parent.tabsModifiedSignal.connect(self.onModifiedTabs) 83 88 84 89 def updateSignalsFromTab(self, tab=None): … … 95 100 single fit/batch fit 96 101 """ 102 source = self.sender().objectName() 103 self.currentType = "BatchPage" if source == "btnBatch" else "FitPage" 104 self.initializeFitList() 105 106 def onSpecialCaseChange(self, index): 107 """ 108 Respond to the combobox change for special case constraint sets 109 """ 97 110 pass 98 111 99 def on SpecialCaseChange(self, index):100 """ 101 Respond to the combobox change for special case constraint sets112 def onFit(self): 113 """ 114 Perform the constrained/simultaneous fit 102 115 """ 103 116 pass 104 117 105 def on Fit(self):106 """ 107 Perform the constrained/simultaneous fit118 def onHelp(self): 119 """ 120 Display the help page 108 121 """ 109 122 pass 110 123 111 def onHelp(self): 112 """ 113 Display the help page 114 """ 115 pass 116 117 def onMonikerEdit(self, row, column): 118 """ 119 Modify the model moniker 120 """ 124 def onTabCellEdit(self, row, column): 125 """ 126 Respond to check/uncheck and to modify the model moniker actions 127 """ 128 item = self.tblTabList.item(row, column) 129 if column == 0: 130 # Update the tabs for fitting list 131 tab_name = item.text() 132 self.tabs_for_fitting[tab_name] = (item.checkState() == QtCore.Qt.Checked) 133 # Enable fitting only when there are models to fit 134 self.cmdFit.setEnabled(any(self.tabs_for_fitting.values())) 135 121 136 if column not in self.editable_tab_columns: 122 137 return 123 item = self.tblTabList.item(row, column)124 138 new_moniker = item.data(0) 125 139 … … 131 145 item.setBackground(QtCore.Qt.red) 132 146 self.cmdFit.setEnabled(False) 133 else: 134 self.tblTabList.blockSignals(True) 135 item.setBackground(QtCore.Qt.white) 136 self.tblTabList.blockSignals(False) 137 self.cmdFit.setEnabled(True) 138 if not self.current_cell: 139 return 140 # Remember the value 141 if self.current_cell not in self.available_tabs: 142 return 143 temp_tab = self.available_tabs[self.current_cell] 144 # Remove the key from the dictionaries 145 self.available_tabs.pop(self.current_cell, None) 146 # Change the model name 147 model = temp_tab.kernel_module 148 model.name = new_moniker 149 # Replace constraint name 150 temp_tab.replaceConstraintName(self.current_cell, new_moniker) 151 # Reinitialize the display 152 self.initializeFitList() 153 pass 147 return 148 self.tblTabList.blockSignals(True) 149 item.setBackground(QtCore.Qt.white) 150 self.tblTabList.blockSignals(False) 151 self.cmdFit.setEnabled(True) 152 if not self.current_cell: 153 return 154 # Remember the value 155 if self.current_cell not in self.available_tabs: 156 return 157 temp_tab = self.available_tabs[self.current_cell] 158 # Remove the key from the dictionaries 159 self.available_tabs.pop(self.current_cell, None) 160 # Change the model name 161 model = temp_tab.kernel_module 162 model.name = new_moniker 163 # Replace constraint name 164 temp_tab.replaceConstraintName(self.current_cell, new_moniker) 165 # Reinitialize the display 166 self.initializeFitList() 154 167 155 168 def onConstraintChange(self, row, column): 156 169 """ 157 170 Modify the constraint in-place. 158 Tricky. 159 """ 160 pass 171 """ 172 item = self.tblConstraints.item(row, column) 173 if column == 0: 174 # Update the tabs for fitting list 175 constraint = self.available_constraints[row] 176 constraint.active = (item.checkState() == QtCore.Qt.Checked) 161 177 162 178 def onTabCellEntered(self, row, column): … … 168 184 return 169 185 self.current_cell = self.tblTabList.item(row, column).data(0) 186 187 def onModifiedTabs(self): 188 """ 189 Respond to tabs being deleted by deleting involved constraints 190 191 This should probably be done in FittingWidget as it is the owner of 192 all the fitting data, but I want to keep the FW oblivious about 193 dependence on other FW tabs, so enforcing the constraint deletion here. 194 """ 195 # Get the list of all constraints from querying the table 196 #constraints = getConstraintsForModel() 197 198 # Get the current list of tabs 199 #tabs = ObjectLibrary.listObjects() 200 201 # Check if any of the constraint dependencies got deleted 202 # Check the list of constraints 203 self.initializeFitList() 204 pass 170 205 171 206 def isTabImportable(self, tab): … … 339 374 Update a single line of the table widget with tab info 340 375 """ 341 model = ObjectLibrary.getObject(tab).kernel_module 376 fit_page = ObjectLibrary.getObject(tab) 377 model = fit_page.kernel_module 342 378 if model is None: 343 379 return … … 345 381 model_name = model.id 346 382 moniker = model.name 347 model_data = ObjectLibrary.getObject(tab).data383 model_data = fit_page.data 348 384 model_filename = model_data.filename 349 self.available_tabs[moniker] = ObjectLibrary.getObject(tab)385 self.available_tabs[moniker] = fit_page 350 386 351 387 # Update the model table widget 352 #item = QtWidgets.QTableWidgetItem(tab_name)353 #item.setCheckState(QtCore.Qt.Checked)354 #item.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )355 388 pos = self.tblTabList.rowCount() 356 389 self.tblTabList.insertRow(pos) 357 390 item = self.uneditableItem(tab_name) 358 391 item.setFlags(item.flags() ^ QtCore.Qt.ItemIsUserCheckable) 359 item.setCheckState(QtCore.Qt.Checked) 392 if tab_name in self.tabs_for_fitting: 393 state = QtCore.Qt.Checked if self.tabs_for_fitting[tab_name] else QtCore.Qt.Unchecked 394 item.setCheckState(state) 395 else: 396 item.setCheckState(QtCore.Qt.Checked) 397 self.tabs_for_fitting[tab_name] = True 398 360 399 self.tblTabList.setItem(pos, 0, item) 361 400 self.tblTabList.setItem(pos, 1, self.uneditableItem(model_name)) … … 369 408 370 409 # Check if any constraints present in tab 371 constraints = ObjectLibrary.getObject(tab).getConstraintsForModel() 410 constraint_names = fit_page.getConstraintsForModel() 411 constraints = fit_page.getConstraintObjectsForModel() 372 412 if not constraints: 373 413 return 374 414 self.tblConstraints.setEnabled(True) 375 for constraint in constraints:415 for constraint, constraint_name in zip(constraints, constraint_names): 376 416 # Create the text for widget item 377 label = moniker + ":"+ constraint[0] + " = " + constraint[1] 417 label = moniker + ":"+ constraint_name[0] + " = " + constraint_name[1] 418 pos = self.tblConstraints.rowCount() 419 self.available_constraints[pos] = constraint 378 420 379 421 # Show the text in the constraint table 380 item = QtWidgets.QTableWidgetItem(label) 422 item = self.uneditableItem(label) 423 item.setFlags(item.flags() ^ QtCore.Qt.ItemIsUserCheckable) 381 424 item.setCheckState(QtCore.Qt.Checked) 382 pos = self.tblConstraints.rowCount()383 425 self.tblConstraints.insertRow(pos) 384 426 self.tblConstraints.setItem(pos, 0, item) 385 self.available_constraints[pos] = constraints386 427 387 428 def initializeFitList(self): … … 461 502 462 503 constraint.func = constraint_text 463 #constraint.param = param1504 constraint.param = param1 464 505 # Find the right tab 465 506 constrained_tab = self.getObjectByName(model1) -
src/sas/qtgui/Perspectives/Fitting/Constraints.py
- Property mode changed from 100755 to 100644
reae226b rba01ad1 7 7 self._param = param 8 8 self._func = func 9 self.active = False9 self.active = True 10 10 self._min = min 11 11 self._max = max … … 53 53 def delete(self, constraint=None): 54 54 pass 55 56 57 class ConstrainedParameters(object):58 """59 Representation of two constrained parameters60 """61 def __init__(self, parent=None):62 pass63 64 def add(self, constraint=None):65 pass66 67 def delete(self, constraint=None):68 pass69 -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rc5a2722f rba01ad1 783 783 return params 784 784 785 def getConstraintObjectsForModel(self): 786 """ 787 Returns Constraint objects present on the whole model 788 """ 789 param_number = self._model_model.rowCount() 790 constraints = [self._model_model.item(s, 1).child(0).data() 791 for s in range(param_number) if self.rowHasConstraint(s)] 792 793 return constraints 794 785 795 def showModelDescription(self): 786 796 """
Note: See TracChangeset
for help on using the changeset viewer.