Changes in / [3ba060e1:531dd64] in sasview
- Location:
- src/sas/qtgui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
rba8046c re5ae812 1599 1599 while len(indices) > 0: 1600 1600 index = indices[0] 1601 row_index = proxy.mapToSource(index) 1602 item_to_delete = model.itemFromIndex(row_index) 1601 #row_index = proxy.mapToSource(index) 1602 #item_to_delete = model.itemFromIndex(row_index) 1603 item_to_delete = model.itemFromIndex(index) 1603 1604 if item_to_delete and item_to_delete.isCheckable(): 1604 row = row_index.row() 1605 #row = row_index.row() 1606 row = index.row() 1605 1607 1606 1608 # store the deleted item details so we can pass them on later -
src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py
r9c207f5 rd72ac57 37 37 self.operator = '=' 38 38 self._constraint = Constraint() 39 self.all_menu = None40 39 41 40 self.warning = self.lblWarning.text() … … 61 60 self.cmdOK.clicked.connect(self.onApply) 62 61 self.cmdHelp.clicked.connect(self.onHelp) 62 self.cmdRevert.clicked.connect(self.onRevert) 63 63 self.txtConstraint.editingFinished.connect(self.validateFormula) 64 self.cbModel1.currentIndexChanged.connect(self.onModelIndexChange)65 self.cbModel2.currentIndexChanged.connect(self.onModelIndexChange)66 64 67 65 self.cbParam1.currentIndexChanged.connect(self.onParamIndexChange) … … 73 71 Setup widgets based on current parameters 74 72 """ 75 self. cbModel1.insertItems(0, self.tab_names)76 self. cbModel2.insertItems(0, self.tab_names)73 self.txtName1.setText(self.tab_names[0]) 74 self.txtName2.setText(self.tab_names[1]) 77 75 78 76 self.setupParamWidgets() 79 77 80 self.setupMenu() 81 82 def setupMenu(self): 83 # Add menu to the Apply button, if necessary 84 if self.cbModel1.currentText() ==self.cbModel2.currentText(): 85 self.cmdOK.setArrowType(QtCore.Qt.NoArrow) 86 self.cmdOK.setPopupMode(QtWidgets.QToolButton.DelayedPopup) 87 self.cmdOK.setMenu(None) 88 return 89 self.all_menu = QtWidgets.QMenu() 78 # Add menu to the Apply button 79 all_menu = QtWidgets.QMenu() 90 80 self.actionAddAll = QtWidgets.QAction(self) 91 81 self.actionAddAll.setObjectName("actionAddAll") … … 94 84 self.actionAddAll.setToolTip(ttip) 95 85 self.actionAddAll.triggered.connect(self.onSetAll) 96 self.all_menu.addAction(self.actionAddAll)86 all_menu.addAction(self.actionAddAll) 97 87 # https://bugreports.qt.io/browse/QTBUG-13663 98 self.all_menu.setToolTipsVisible(True) 99 self.cmdOK.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) 100 self.cmdOK.setArrowType(QtCore.Qt.DownArrow) 101 self.cmdOK.setMenu(self.all_menu) 88 all_menu.setToolTipsVisible(True) 89 self.cmdOK.setMenu(all_menu) 102 90 103 91 def setupParamWidgets(self): … … 106 94 """ 107 95 self.cbParam1.clear() 108 tab_index1 = self.cbModel1.currentIndex() 109 items1 = [param for param in self.params[tab_index1] if not self.tabs[tab_index1].paramHasConstraint(param)] 96 items1 = [param for param in self.params[0] if not self.tabs[0].paramHasConstraint(param)] 110 97 self.cbParam1.addItems(items1) 111 98 112 99 # M2 doesn't have to be non-constrained 113 100 self.cbParam2.clear() 114 tab_index2 = self.cbModel2.currentIndex()115 items2 = [param for param in self.params[ tab_index2]]101 #items2 = [param for param in self.params[1] if not self.tabs[1].paramHasConstraint(param)] 102 items2 = [param for param in self.params[1]] 116 103 self.cbParam2.addItems(items2) 117 104 118 self.txtParam.setText(self.tab_names[ tab_index1] + ":" + self.cbParam1.currentText())105 self.txtParam.setText(self.tab_names[0] + ":" + self.cbParam1.currentText()) 119 106 120 107 self.cbOperator.clear() … … 122 109 self.txtOperator.setText(self.cbOperator.currentText()) 123 110 124 self.txtConstraint.setText(self.tab_names[ tab_index2]+"."+self.cbParam2.currentText())111 self.txtConstraint.setText(self.tab_names[1]+"."+self.cbParam2.currentText()) 125 112 126 113 # disable Apply if no parameters available … … 168 155 self.lblWarning.setText(txt) 169 156 170 def onModelIndexChange(self, index):171 """172 Respond to mode combo box changes173 """174 # disable/enable Add All175 self.setupMenu()176 # Reload parameters177 self.setupParamWidgets()178 157 179 158 def onOperatorChange(self, index): … … 183 162 self.txtOperator.setText(self.cbOperator.currentText()) 184 163 164 def onRevert(self): 165 """ 166 switch M1 <-> M2 167 """ 168 # Switch parameters 169 self.params[1], self.params[0] = self.params[0], self.params[1] 170 self.tab_names[1], self.tab_names[0] = self.tab_names[0], self.tab_names[1] 171 self.tabs[1], self.tabs[0] = self.tabs[0], self.tabs[1] 172 # Try to swap parameter names in the line edit 173 current_text = self.txtConstraint.text() 174 new_text = current_text.replace(self.cbParam1.currentText(), self.cbParam2.currentText()) 175 self.txtConstraint.setText(new_text) 176 # Update labels and tooltips 177 index1 = self.cbParam1.currentIndex() 178 index2 = self.cbParam2.currentIndex() 179 indexOp = self.cbOperator.currentIndex() 180 self.setupWidgets() 181 182 # Original indices 183 index2 = index2 if index2 >= 0 else 0 184 index1 = index1 if index1 >= 0 else 0 185 self.cbParam1.setCurrentIndex(index2) 186 self.cbParam2.setCurrentIndex(index1) 187 self.cbOperator.setCurrentIndex(indexOp) 188 self.setupTooltip() 189 185 190 def validateFormula(self): 186 191 """ 187 192 Add visual cues when formula is incorrect 188 193 """ 189 # temporarily disable validation190 return191 #192 194 formula_is_valid = self.validateConstraint(self.txtConstraint.text()) 193 195 if not formula_is_valid: … … 206 208 return False 207 209 208 # M1.scale --> model_str='M1', constraint_text='scale'210 # M1.scale --> model_str='M1', constraint_text='scale' 209 211 param_str = self.cbParam2.currentText() 210 212 constraint_text = constraint_text.strip() 211 model_str = self. cbModel2.currentText()213 model_str = self.txtName2.text() 212 214 213 215 # 0. Has to contain the model name 214 if model_str != model_str:216 if model_str != self.txtName2.text(): 215 217 return False 216 218 … … 247 249 value = self.cbParam2.currentText() 248 250 func = self.txtConstraint.text() 249 value_ex = self. cbModel2.currentText() + "." + self.cbParam2.currentText()250 model1 = self. cbModel1.currentText()251 value_ex = self.txtName2.text() + "." + self.cbParam2.currentText() 252 model1 = self.txtName1.text() 251 253 operator = self.cbOperator.currentText() 252 254 … … 275 277 """ 276 278 # loop over parameters in constrained model 277 index1 = self.cbModel1.currentIndex() 278 index2 = self.cbModel2.currentIndex() 279 items1 = [param for param in self.params[index1] if not self.tabs[index1].paramHasConstraint(param)] 280 items2 = self.params[index2] 279 items1 = [param for param in self.params[0] if not self.tabs[0].paramHasConstraint(param)] 280 #items2 = [param for param in self.params[1] if not self.tabs[1].paramHasConstraint(i)] 281 items2 = self.params[1] 281 282 for item in items1: 282 283 if item not in items2: continue 283 284 param = item 284 285 value = item 285 func = self. cbModel2.currentText() + "." + param286 value_ex = self. cbModel1.currentText() + "." + param287 model1 = self. cbModel1.currentText()286 func = self.txtName2.text() + "." + param 287 value_ex = self.txtName1.text() + "." + param 288 model1 = self.txtName1.text() 288 289 operator = self.cbOperator.currentText() 289 290 -
src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py
r2e5081b r72651df 33 33 self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) 34 34 35 self._is_dragged = False35 self._is_dragged = True 36 36 37 37 def isDragged(self): … … 872 872 """ 873 873 selected_rows = self.selectedParameters(self.tblTabList) 874 875 tab_list = [ObjectLibrary.getObject(self.tblTabList.item(s, 0).data(0)) for s in range(self.tblTabList.rowCount())] 874 if len(selected_rows)!=2: 875 msg = "Please select two fit pages from the Source Choice table." 876 msgbox = QtWidgets.QMessageBox(self.parent) 877 msgbox.setIcon(QtWidgets.QMessageBox.Warning) 878 msgbox.setText(msg) 879 msgbox.setWindowTitle("2 fit page constraints") 880 retval = msgbox.exec_() 881 return 882 883 tab_list = [ObjectLibrary.getObject(self.tblTabList.item(s, 0).data(0)) for s in selected_rows] 876 884 # Create and display the widget for param1 and param2 877 885 cc_widget = ComplexConstraint(self, tabs=tab_list) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rba8046c r9c05f22 270 270 self.custom_models = self.customModels() 271 271 # Polydisp widget table default index for function combobox 272 self.orig_poly_index = 4272 self.orig_poly_index = 3 273 273 # copy of current kernel model 274 274 self.kernel_module_copy = None … … 3022 3022 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_function) 3023 3023 combo_box = self.lstPoly.indexWidget(file_index) 3024 try:3025 self.disp_model = POLYDISPERSITY_MODELS[combo_string]()3026 except IndexError:3027 logger.error("Error in setting the dispersion model. Reverting to Gaussian.")3028 self.disp_model = POLYDISPERSITY_MODELS['gaussian']()3029 3024 3030 3025 def updateFunctionCaption(row): … … 3032 3027 if not self.isCheckable(row): 3033 3028 return 3034 param_name = self._model_model.item(row, 0).text() 3029 self._model_model.blockSignals(True) 3030 param_name = str(self._model_model.item(row, 0).text()) 3031 self._model_model.blockSignals(False) 3035 3032 if param_name != param.name: 3036 3033 return … … 3046 3043 if combo_string == 'array': 3047 3044 try: 3048 # assure the combo is at the right index3049 combo_box.blockSignals(True)3050 combo_box.setCurrentIndex(combo_box.findText(combo_string))3051 combo_box.blockSignals(False)3052 # Load the file3053 3045 self.loadPolydispArray(row_index) 3054 3046 # Update main model for display 3055 3047 self.iterateOverModel(updateFunctionCaption) 3056 self.kernel_module.set_dispersion(param.name, self.disp_model)3057 # uncheck the parameter3058 self._poly_model.item(row_index, 0).setCheckState(QtCore.Qt.Unchecked)3059 3048 # disable the row 3060 lo = self.lstPoly.itemDelegate().poly_p arameter3049 lo = self.lstPoly.itemDelegate().poly_pd 3061 3050 hi = self.lstPoly.itemDelegate().poly_function 3062 self._poly_model.blockSignals(True)3063 3051 [self._poly_model.item(row_index, i).setEnabled(False) for i in range(lo, hi)] 3064 self._poly_model.blockSignals(False)3065 3052 return 3066 3053 except IOError: … … 3068 3055 # Pass for cancel/bad read 3069 3056 pass 3070 else:3071 self.kernel_module.set_dispersion(param.name, self.disp_model)3072 3057 3073 3058 # Enable the row in case it was disabled by Array … … 3121 3106 3122 3107 # If everything went well - update the sasmodel values 3108 self.disp_model = POLYDISPERSITY_MODELS['array']() 3123 3109 self.disp_model.set_weights(np.array(values), np.array(weights)) 3124 3110 # + update the cell with filename -
src/sas/qtgui/Perspectives/Fitting/UI/ComplexConstraintUI.ui
r2e5081b recc5d043 7 7 <x>0</x> 8 8 <y>0</y> 9 <width>4 96</width>10 <height>2 60</height>9 <width>478</width> 10 <height>257</height> 11 11 </rect> 12 12 </property> … … 21 21 </property> 22 22 <layout class="QGridLayout" name="gridLayout"> 23 <item row="1" column="0"> 24 <layout class="QHBoxLayout" name="horizontalLayout_2"> 25 <item> 26 <widget class="QLabel" name="txtParam"> 27 <property name="sizePolicy"> 28 <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 29 <horstretch>0</horstretch> 30 <verstretch>0</verstretch> 31 </sizepolicy> 32 </property> 33 <property name="text"> 34 <string>param1</string> 35 </property> 36 </widget> 37 </item> 38 <item> 39 <widget class="QLabel" name="txtOperator"> 40 <property name="text"> 41 <string>=</string> 42 </property> 43 </widget> 44 </item> 45 <item> 46 <widget class="QLineEdit" name="txtConstraint"> 47 <property name="text"> 48 <string/> 49 </property> 50 </widget> 51 </item> 52 </layout> 53 </item> 23 54 <item row="0" column="0"> 24 55 <layout class="QHBoxLayout" name="horizontalLayout"> 25 56 <item> 26 <widget class="QComboBox" name="cbModel1"/> 57 <widget class="QLabel" name="txtName1"> 58 <property name="text"> 59 <string>name1</string> 60 </property> 61 </widget> 27 62 </item> 28 63 <item> … … 54 89 </item> 55 90 <item> 56 <widget class="QComboBox" name="cbModel2"/> 91 <widget class="QLabel" name="txtName2"> 92 <property name="text"> 93 <string>name2</string> 94 </property> 95 </widget> 57 96 </item> 58 97 <item> … … 74 113 </widget> 75 114 </item> 76 </layout> 77 </item> 78 <item row="1" column="0"> 79 <layout class="QHBoxLayout" name="horizontalLayout_2"> 80 <item> 81 <widget class="QLabel" name="txtParam"> 82 <property name="sizePolicy"> 83 <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 84 <horstretch>0</horstretch> 85 <verstretch>0</verstretch> 86 </sizepolicy> 87 </property> 88 <property name="text"> 89 <string>param1</string> 90 </property> 91 </widget> 92 </item> 93 <item> 94 <widget class="QLabel" name="txtOperator"> 95 <property name="text"> 96 <string>=</string> 97 </property> 98 </widget> 99 </item> 100 <item> 101 <widget class="QLineEdit" name="txtConstraint"> 102 <property name="text"> 103 <string/> 115 <item> 116 <spacer name="horizontalSpacer"> 117 <property name="orientation"> 118 <enum>Qt::Horizontal</enum> 119 </property> 120 <property name="sizeHint" stdset="0"> 121 <size> 122 <width>40</width> 123 <height>20</height> 124 </size> 125 </property> 126 </spacer> 127 </item> 128 <item> 129 <widget class="QPushButton" name="cmdRevert"> 130 <property name="text"> 131 <string>Swap</string> 104 132 </property> 105 133 </widget> … … 160 188 </property> 161 189 <property name="popupMode"> 162 <enum>QToolButton:: InstantPopup</enum>190 <enum>QToolButton::MenuButtonPopup</enum> 163 191 </property> 164 192 <property name="toolButtonStyle"> -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py
r2e5081b rd72ac57 69 69 self.assertEqual(self.widget.txtConstraint.text(), 'M1.scale') 70 70 self.assertEqual(self.widget.txtOperator.text(), '=') 71 self.assertEqual(self.widget. cbModel1.currentText(), 'M1')72 self.assertEqual(self.widget. cbModel2.currentText(), 'M1')71 self.assertEqual(self.widget.txtName1.text(), 'M1') 72 self.assertEqual(self.widget.txtName2.text(), 'M1') 73 73 74 74 def testTooltip(self): … … 81 81 self.assertEqual(self.widget.txtConstraint.toolTip(), tooltip) 82 82 83 def notestValidateFormula(self):83 def testValidateFormula(self): 84 84 ''' assure enablement and color for valid formula ''' 85 85 # Invalid string … … 141 141 c = self.widget.constraint() 142 142 self.assertEqual(c[0], 'M1') 143 self.assertEqual(c[1].func, 'M1. bjerrum_length')143 self.assertEqual(c[1].func, 'M1.sld_solvent') 144 144 #self.assertEqual(c[1].operator, '>=') 145 145
Note: See TracChangeset
for help on using the changeset viewer.