- Timestamp:
- May 15, 2017 10:57:34 AM (8 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:
- 2a432e7
- Parents:
- 2241130
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r2241130 r00b3b40 370 370 371 371 # Update state stack 372 if self.undo_supported: 373 state = self.currentState() 374 self.pushFitPage(state) 372 self.updateUndo() 375 373 376 374 def onSelectStructureFactor(self): … … 429 427 name_index = self._poly_model.index(model_row, 0) 430 428 # Extract changed value. Assumes proper validation by QValidator/Delegate 431 # Checkbox in column 0429 # TODO: abstract away hardcoded column numbers 432 430 if model_column == 0: 431 # Is the parameter checked for fitting? 433 432 value = item.checkState() 433 # TODO: add the param to self.params_for_fitting 434 elif model_column == 6: 435 value = item.text() 436 # TODO: Modify Npts/Nsigs based on function choice 434 437 else: 435 438 try: … … 866 869 return 867 870 parameter_name = str(self._model_model.data(name_index).toPyObject()) # sld, background etc. 868 property_name = str(self._model_model.headerData(1, model_column).toPyObject()) # Value, min, max, etc. 869 871 property_index = self._model_model.headerData(1, model_column).toInt()[0]-1 # Value, min, max, etc. 872 873 # Update the parameter value - note: this supports +/-inf as well 870 874 self.kernel_module.params[parameter_name] = value 871 875 872 # TODO: update min/max based on property_name873 876 # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 874 # magnetic params in self.kernel_module.details['M0:parameter_name'] = value 875 # multishell params in self.kernel_module.details[??] = value 877 self.kernel_module.details[parameter_name][property_index] = value 878 879 # TODO: magnetic params in self.kernel_module.details['M0:parameter_name'] = value 880 # TODO: multishell params in self.kernel_module.details[??] = value 876 881 877 882 # Force the chart update when actual parameters changed … … 880 885 881 886 # Update state stack 882 if self.undo_supported: 883 state = self.currentState() 884 self.pushFitPage(state) 887 self.updateUndo() 885 888 886 889 def checkboxSelected(self, item): … … 943 946 Update a QStandardModelIndex containing model data 944 947 """ 945 if fitted_data.name is None: 946 name = self.nameForFittedData(self.logic.data.filename) 947 fitted_data.title = name 948 fitted_data.name = name 949 else: 950 name = fitted_data.name 948 name = self.nameFromData(fitted_data) 951 949 # Make this a line if no other defined 952 950 if hasattr(fitted_data, 'symbol') and fitted_data.symbol is None: … … 959 957 Create a QStandardModelIndex containing model data 960 958 """ 959 name = self.nameFromData(fitted_data) 960 # Notify the GUI manager so it can create the theory model in DataExplorer 961 new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(fitted_data), name=name) 962 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 963 964 def nameFromData(self, fitted_data): 965 """ 966 Return name for the dataset. Terribly impure function. 967 """ 961 968 if fitted_data.name is None: 962 name = self.nameForFittedData(self. kernel_module.name)969 name = self.nameForFittedData(self.logic.data.filename) 963 970 fitted_data.title = name 964 971 fitted_data.name = name … … 966 973 else: 967 974 name = fitted_data.name 968 # Notify the GUI manager so it can create the theory model in DataExplorer 969 new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(fitted_data), name=name) 970 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 975 return name 971 976 972 977 def methodCalculateForData(self): … … 1258 1263 # TODO: add polidyspersity and magnetism 1259 1264 1265 1266 def updateUndo(self): 1267 """ 1268 Create a new state page and add it to the stack 1269 """ 1270 if self.undo_supported: 1271 self.pushFitPage(self.currentState()) 1272 1260 1273 def currentState(self): 1261 1274 """ -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
rf7f5796 r00b3b40 394 394 <layout class="QGridLayout" name="gridLayout_9"> 395 395 <item row="0" column="0"> 396 <widget class="QTableView" name="lstPoly"/> 396 <widget class="QTableView" name="lstPoly"> 397 <property name="editTriggers"> 398 <set>QAbstractItemView::AllEditTriggers</set> 399 </property> 400 <property name="alternatingRowColors"> 401 <bool>true</bool> 402 </property> 403 <property name="selectionMode"> 404 <enum>QAbstractItemView::MultiSelection</enum> 405 </property> 406 <property name="selectionBehavior"> 407 <enum>QAbstractItemView::SelectRows</enum> 408 </property> 409 </widget> 397 410 </item> 398 411 </layout> -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r6011788 r00b3b40 22 22 POLY_FUNCTION=6 23 23 24 class CustomLineEdit(QtGui.QLineEdit):25 editingFinished = QtCore.pyqtSignal()26 def __init__(self, parent=None, old_value=None):27 super(CustomLineEdit, self).__init__(parent)28 self.setAutoFillBackground(True)29 self.old_value = old_value30 def focusOutEvent(self, event):31 self.editingFinished.emit()32 24 33 25 class ModelViewDelegate(QtGui.QStyledItemDelegate): … … 81 73 editor.setValidator(validator) 82 74 return editor 83 elif index.column() in (PARAM_MIN, PARAM_MAX):84 # Save current value in case we need to revert85 #self._old_value = index.data().toFloat()[0]86 self._old_value = index.data().toString()87 editor = CustomLineEdit(widget, old_value=self._old_value)88 editor.editingFinished.connect(self.commitAndCloseEditor)89 return editor90 75 91 76 return super(ModelViewDelegate, self).createEditor(widget, option, index) 92 77 93 #def setEditorData(self, editor, index): 94 # if index.column() == MIN: 95 # #value = index.data().toString()[0] 96 # value = index.model().data(index, QtCore.Qt.DisplayRole).toString() 97 # print "VALUE = ", value 98 # editor.setText('['+value+']') 99 # return editor 100 101 # return super(ModelViewDelegate, self).setEditorData(editor, index) 102 103 def commitAndCloseEditor(self): 104 editor = self.sender() 105 content = editor.text() 78 def setModelData(self, editor, model, index): 79 """ 80 Overwrite generic model update method for certain columns 81 """ 82 if index.column() in (PARAM_MIN, PARAM_MAX): 106 83 try: 107 value_float = float( content)84 value_float = float(editor.text()) 108 85 except ValueError: 109 # TODO: Notify the user 110 # <scary popup> 111 # Do nothing 86 # TODO: present the failure to the user 87 # balloon popup? tooltip? cell background colour flash? 112 88 return 113 self.commitData.emit(editor) 114 self.closeEditor.emit(editor, QtGui.QAbstractItemDelegate.NoHint) 89 QtGui.QStyledItemDelegate.setModelData(self, editor, model, index) 115 90 116 91 117 92 class PolyViewDelegate(QtGui.QStyledItemDelegate): 118 93 """ 119 Custom delegate for appearance and behavior control of the polydisper isty view94 Custom delegate for appearance and behavior control of the polydispersity view 120 95 """ 121 def createEditor(self, parent, option, index): 122 # TODO: set it to correct index on creation 96 def createEditor(self, widget, option, index): 97 # Remember the current choice 98 current_text = index.data().toString() 123 99 if index.column() == POLY_FUNCTION: 124 editor = QtGui.QComboBox( parent)100 editor = QtGui.QComboBox(widget) 125 101 for function in POLYDISPERSE_FUNCTIONS: 126 102 editor.addItem(function) 103 current_index = editor.findText(current_text) 104 editor.setCurrentIndex(current_index if current_index>-1 else 0) 127 105 return editor 128 106 else: 129 QtGui.QStyledItemDelegate.createEditor(self, parent, option, index)107 QtGui.QStyledItemDelegate.createEditor(self, widget, option, index)
Note: See TracChangeset
for help on using the changeset viewer.