Changeset 6f7f652 in sasview
- Timestamp:
- Mar 1, 2017 10:16:45 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:
- 86f88d1
- Parents:
- 68c96d3
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r68c96d3 r6f7f652 1 1 import sys 2 import numpy 2 3 3 4 from PyQt4 import QtCore … … 83 84 available_tabs = list(map(lambda tab:tab.acceptsData(), self.tabs)) 84 85 85 if True in available_tabs:86 if numpy.any(available_tabs): 86 87 self.tabs[available_tabs.index(True)].data = data_item 87 88 else: -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rf46f6dc r6f7f652 59 59 self.setTableProperties(self.lstMagnetic) 60 60 61 # Fill in the combo boxes 62 structure_factor_list = self.master_category_dict.pop('Structure Factor') 63 for (structure_factor, enabled) in structure_factor_list: 64 self.cbStructureFactor.addItem(structure_factor) 65 61 # Defaults for the strcutre factors 62 self.setDefaultStructureCombo() 63 64 # make structure factor and model CBs disabled 65 self.disableModelCombo() 66 self.disableStructureCombo() 67 68 # Generate the category list for display 66 69 category_list = sorted(self.master_category_dict.keys()) 70 self.cbCategory.addItem("Choose category...") 67 71 self.cbCategory.addItems(category_list) 68 69 category = self.cbCategory.currentText() 70 model_list = self.master_category_dict[str(category)] 71 for (model, enabled) in model_list: 72 self.cbModel.addItem(model) 72 self.cbCategory.addItem("Structure Factor") 73 self.cbCategory.setCurrentIndex(0) 73 74 74 75 # Connect GUI element signals … … 113 114 return not self.data_assigned 114 115 116 def disableModelCombo(self): 117 self.cbModel.setEnabled(False) 118 self.label_3.setEnabled(False) 119 120 def enableModelCombo(self): 121 self.cbModel.setEnabled(True) 122 self.label_3.setEnabled(True) 123 124 def disableStructureCombo(self): 125 self.cbStructureFactor.setEnabled(False) 126 self.label_4.setEnabled(False) 127 128 def enableStructureCombo(self): 129 self.cbStructureFactor.setEnabled(True) 130 self.label_4.setEnabled(True) 131 132 def setDefaultStructureCombo(self): 133 # Fill in the structure factors combo box with defaults 134 structure_factor_list = self.master_category_dict.pop('Structure Factor') 135 structure_factors = [] 136 self.cbStructureFactor.clear() 137 for (structure_factor, _) in structure_factor_list: 138 structure_factors.append(structure_factor) 139 self.cbStructureFactor.addItems(sorted(structure_factors)) 140 115 141 def selectCategory(self): 116 142 """ … … 118 144 :return: 119 145 """ 146 category = self.cbCategory.currentText() 147 if category == "Structure Factor": 148 self.disableModelCombo() 149 self.enableStructureCombo() 150 return 151 152 self.cbModel.blockSignals(True) 120 153 self.cbModel.clear() 121 category = self.cbCategory.currentText() 154 self.cbModel.blockSignals(False) 155 self.enableModelCombo() 156 self.disableStructureCombo() 157 122 158 model_list = self.master_category_dict[str(category)] 123 for (model, enabled) in model_list: 124 self.cbModel.addItem(model) 159 models = [] 160 for (model, _) in model_list: 161 models.append(model) 162 self.cbModel.addItems(sorted(models)) 125 163 126 164 def selectModel(self): … … 138 176 :return: 139 177 """ 178 model = self.cbStructureFactor.currentText() 179 self.setModelModel(model) 140 180 141 181 def _readCategoryInfo(self): … … 173 213 self.model_enabled_dict[model] = enabled 174 214 175 def checkMultiplicity(self, model): 176 """ 215 def getIterParams(self, model): 216 """ 217 Returns a list of all multi-shell parameters in 'model' 218 """ 219 iter_params = list(filter(lambda par: "[" in par.name, model.iq_parameters)) 220 221 return iter_params 222 223 def getMultiplicity(self, model): 224 """ 225 Finds out if 'model' has multishell parameters. 226 If so, returns the name of the counter parameter and the number of shells 177 227 """ 178 228 iter_param = "" 179 229 iter_length = 0 180 for param in model.iq_parameters: 181 name = param.name 182 if "[" in name: 183 # pull out the iterator parameter name 184 #iter_param = name[name.index('[')+1:-1] 185 iter_length = param.length 186 iter_param = param.length_control 230 231 iter_params = self.getIterParams(model) 232 # pull out the iterator parameter name and length 233 if iter_params: 234 iter_length = iter_params[0].length 235 iter_param = iter_params[0].length_control 187 236 return (iter_param, iter_length) 188 237 … … 216 265 self._model_model.appendRow([item1, item2, item3, item4, item5]) 217 266 218 multishell_param_name, multishell_param_length = self.checkMultiplicity(self.model_parameters) 219 multishell_param_fullname = "[%s]" % multishell_param_name 267 multishell_parameters = self.getIterParams(self.model_parameters) 268 multishell_param_name, _ = self.getMultiplicity(self.model_parameters) 269 220 270 #TODO: iq_parameters are used here. If orientation paramateres or magnetic are needed 221 271 # kernel_paramters should be used instead … … 227 277 # Modify parameter name from <param>[n] to <param>1 228 278 item_name = param.name 229 if multishell_param_fullname in param.name:279 if param in multishell_parameters: 230 280 item_name = self.replaceShellName(param.name, 1) 231 281 item1 = QtGui.QStandardItem(item_name) … … 253 303 Updates parameter name from <param_name>[n_shell] to <param_name>value 254 304 """ 255 new_name = param_name[:param_name.index('[')]+str(value)256 return new_name305 assert('[' in param_name) 306 return param_name[:param_name.index('[')]+str(value) 257 307 258 308 def setTableProperties(self, table): … … 343 393 Add a combobox for multiple shell display 344 394 """ 345 param_name, param_length = self. checkMultiplicity(self.model_parameters)395 param_name, param_length = self.getMultiplicity(self.model_parameters) 346 396 347 397 if param_length == 0: 348 398 return 349 399 400 # cell 1: variable name 350 401 item1 = QtGui.QStandardItem(param_name) 351 402 … … 353 404 func.addItems([str(i+1) for i in xrange(param_length)]) 354 405 406 # cell 2: combobox 355 407 item2 = QtGui.QStandardItem() 356 408 self._model_model.appendRow([item1, item2]) 357 409 410 # Beautify the row: span columns 2-4 358 411 shell_row = self._model_model.rowCount() 359 412 shell_index = self._model_model.index(shell_row-1, 1) … … 363 416 def togglePoly(self, isChecked): 364 417 """ 418 Enable/disable the polydispersity tab 365 419 """ 366 420 self.tabFitting.setTabEnabled(TAB_POLY, isChecked) … … 368 422 def toggleMagnetism(self, isChecked): 369 423 """ 424 Enable/disable the magnetism tab 370 425 """ 371 426 self.tabFitting.setTabEnabled(TAB_MAGNETISM, isChecked) … … 373 428 def toggle2D(self, isChecked): 374 429 """ 430 Enable/disable the controls dependent on 1D/2D data instance 375 431 """ 376 432 self.chkMagnetism.setEnabled(isChecked) -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
rf46f6dc r6f7f652 94 94 </item> 95 95 <item row="1" column="2"> 96 <widget class="QComboBox" name="cbStructureFactor"> 97 <item> 98 <property name="text"> 99 <string>Hard Sphere Structure</string> 100 </property> 101 </item> 102 <item> 103 <property name="text"> 104 <string>None</string> 105 </property> 106 </item> 107 </widget> 96 <widget class="QComboBox" name="cbStructureFactor"/> 108 97 </item> 109 98 </layout>
Note: See TracChangeset
for help on using the changeset viewer.