Changeset 8eaa101 in sasview
- Timestamp:
- Jun 9, 2017 1:26:39 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:
- 125c4be
- Parents:
- 919d47c
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r919d47c r8eaa101 484 484 485 485 # Extract changed value. 486 if model_column == self.lstPoly.itemDelegate(). POLY_PARAMETER:486 if model_column == self.lstPoly.itemDelegate().poly_parameter: 487 487 # Is the parameter checked for fitting? 488 488 value = item.checkState() … … 494 494 self.parameters_to_fit.remove(parameter_name) 495 495 return 496 elif model_column in [self.lstPoly.itemDelegate(). POLY_MIN, self.lstPoly.itemDelegate().POLY_MAX]:496 elif model_column in [self.lstPoly.itemDelegate().poly_min, self.lstPoly.itemDelegate().poly_max]: 497 497 try: 498 498 value = float(item.text()) … … 505 505 current_details = self.kernel_module.details[parameter_name] 506 506 current_details[model_column-1] = value 507 elif model_column == self.lstPoly.itemDelegate(). POLY_FUNCTION:507 elif model_column == self.lstPoly.itemDelegate().poly_function: 508 508 # name of the function - just pass 509 509 return … … 519 519 # PD[ratio] -> width, npts -> npts, nsigs -> nsigmas 520 520 self.kernel_module.setParam(parameter_name + '.' + \ 521 self.lstPoly.itemDelegate(). POLY_COLUMN_DICT[model_column], value)521 self.lstPoly.itemDelegate().columnDict()[model_column], value) 522 522 523 523 def onHelp(self): … … 790 790 return 791 791 792 # Duck type delegate variables 793 self.lstPoly.itemDelegate().POLY_MIN = 3 794 self.lstPoly.itemDelegate().POLY_MAX = 4 795 self.lstPoly.itemDelegate().POLY_NPTS = 5 796 self.lstPoly.itemDelegate().POLY_NSIGS = 6 797 self.lstPoly.itemDelegate().POLY_FUNCTION = 7 798 self.lstPoly.itemDelegate().POLY_COLUMN_DICT = { 799 2: 'width', 800 3: 'min', 801 4: 'max', 802 5: 'npts', 803 6: 'nsigmas'} 804 792 self.lstPoly.itemDelegate().addErrorColumn() 805 793 error_column = [] 806 794 self.iterateOverModel(createErrorColumn) … … 1361 1349 self._poly_model.blockSignals(False) 1362 1350 1363 npts_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate(). POLY_NPTS)1364 nsigs_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate(). POLY_NSIGS)1351 npts_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_npts) 1352 nsigs_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_nsigs) 1365 1353 1366 1354 npts = POLYDISPERSITY_MODELS[str(combo_string)].default['npts'] -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r70080a0 r8eaa101 99 99 delegate = fittingWindow.lstPoly.itemDelegate() 100 100 self.assertEqual(len(delegate.POLYDISPERSE_FUNCTIONS), 5) 101 self.assertEqual(delegate. POLY_EDITABLE_PARAMS, [2, 3, 4, 5])102 self.assertEqual(delegate. POLY_FUNCTION, 6)101 self.assertEqual(delegate.editableParameters(), [2, 3, 4, 5]) 102 self.assertEqual(delegate.poly_function, 6) 103 103 self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 104 104 -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r919d47c r8eaa101 82 82 Custom delegate for appearance and behavior control of the polydispersity view 83 83 """ 84 # polydispersity functions 85 POLYDISPERSE_FUNCTIONS=['rectangle', 'array', 'lognormal', 'gaussian', 'schulz'] 86 # polydispersity columns 87 POLY_PARAMETER=0 88 POLY_PD=1 89 POLY_MIN=2 90 POLY_MAX=3 91 POLY_NPTS=4 92 POLY_NSIGS=5 93 POLY_FUNCTION=6 94 POLY_EDITABLE_PARAMS = [POLY_MIN, POLY_MAX, POLY_NPTS, POLY_NSIGS] 95 POLY_COLUMN_DICT = { 96 POLY_PD: 'width', 97 POLY_MIN: 'min', 98 POLY_MAX: 'max', 99 POLY_NPTS: 'npts', 100 POLY_NSIGS: 'nsigmas'} 84 POLYDISPERSE_FUNCTIONS = ['rectangle', 'array', 'lognormal', 'gaussian', 'schulz'] 101 85 102 86 combo_updated = QtCore.pyqtSignal(str, int) 87 88 def __init__(self, parent=None): 89 """ 90 Overwrite generic constructor to allow for some globals 91 """ 92 super(QtGui.QStyledItemDelegate, self).__init__() 93 94 self.poly_parameter = 0 95 self.poly_pd = 1 96 self.poly_min = 2 97 self.poly_max = 3 98 self.poly_npts = 4 99 self.poly_nsigs = 5 100 self.poly_function = 6 101 102 def editableParameters(self): 103 return [self.poly_min, self.poly_max, self.poly_npts, self.poly_nsigs] 104 105 def columnDict(self): 106 return {self.poly_pd: 'width', 107 self.poly_min: 'min', 108 self.poly_max: 'max', 109 self.poly_npts: 'npts', 110 self.poly_nsigs: 'nsigmas'} 111 112 def addErrorColumn(self): 113 """ 114 Modify local column pointers 115 Note: the reverse is never required! 116 """ 117 self.poly_parameter = 0 118 self.poly_pd = 1 119 self.poly_min = 3 120 self.poly_max = 4 121 self.poly_npts = 5 122 self.poly_nsigs = 6 123 self.poly_function = 7 103 124 104 125 def createEditor(self, widget, option, index): … … 107 128 if not index.isValid(): 108 129 return 0 109 if index.column() == self. POLY_FUNCTION:130 if index.column() == self.poly_function: 110 131 editor = QtGui.QComboBox(widget) 111 132 for function in self.POLYDISPERSE_FUNCTIONS: … … 115 136 editor.currentIndexChanged.connect(lambda: self.combo_updated.emit(str(editor.currentText()), index.row())) 116 137 return editor 117 elif index.column() in self. POLY_EDITABLE_PARAMS:138 elif index.column() in self.editableParameters(): 118 139 editor = QtGui.QLineEdit(widget) 119 140 validator = QtGui.QDoubleValidator() … … 127 148 Overwrite generic painter for certain columns 128 149 """ 129 if index.column() in (self. POLY_MIN, self.POLY_MAX):150 if index.column() in (self.poly_min, self.poly_max): 130 151 # Units - present in nice HTML 131 152 options = QtGui.QStyleOptionViewItemV4(option)
Note: See TracChangeset
for help on using the changeset viewer.