Changeset b1e36a3 in sasview
- Timestamp:
- Mar 23, 2017 9:53:10 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:
- 9934e48
- Parents:
- 29eb947
- Location:
- src/sas/qtgui
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GuiManager.py
r811bec1 rb1e36a3 180 180 # Close the previous perspective 181 181 if self._current_perspective: 182 self._current_perspective.setClosable() 182 183 self._current_perspective.close() 183 184 # Default perspective -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r811bec1 rb1e36a3 42 42 self.tabCloseRequested.connect(self.tabCloses) 43 43 44 # Perspective window not allowed to close by default 45 self._allow_close = False 46 44 47 self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) 48 49 def setClosable(self, value=True): 50 """ 51 Allow outsiders close this widget 52 """ 53 assert isinstance(value, bool) 54 55 self._allow_close = value 56 57 def closeEvent(self, event): 58 """ 59 Overwrite QDialog close method to allow for custom widget close 60 """ 61 if self._allow_close: 62 # reset the closability flag 63 self.setClosable(value=False) 64 event.accept() 65 else: 66 event.ignore() 67 # Maybe we should just minimize 68 self.setWindowState(QtCore.Qt.WindowMinimized) 45 69 46 70 def addFit(self, data): -
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r7248d75d rb1e36a3 39 39 item_name = param.name 40 40 if param in multishell_parameters: 41 item_name = replaceShellName(param.name, 1) 41 continue 42 # item_name = replaceShellName(param.name, 1) 42 43 43 44 item1 = QtGui.QStandardItem(item_name) … … 127 128 for i in xrange(index): 128 129 for par in multishell_parameters: 129 param_name = replaceShellName(par.name, i+2) 130 # Create the name: <param>[<i>], e.g. "sld1" for parameter "sld[n]" 131 param_name = replaceShellName(par.name, i+1) 130 132 item1 = QtGui.QStandardItem(param_name) 131 133 item1.setCheckable(True) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r29eb947 rb1e36a3 79 79 self.communicate = self.parent.communicate 80 80 81 # Define bold font for use in various controls 82 self.boldFont=QtGui.QFont() 83 self.boldFont.setBold(True) 84 85 # Set data label 86 self.label.setFont(self.boldFont) 87 self.label.setText("No data loaded") 88 self.lblFilename.setText("") 89 81 90 # Set the main models 82 91 # We can't use a single model here, due to restrictions on flattening … … 116 125 self.cbCategory.setCurrentIndex(0) 117 126 118 self._index = data127 self._index = None 119 128 if data is not None: 120 129 self.data = data … … 136 145 # _index contains the QIndex with data 137 146 self._index = value 147 138 148 # Update logics with data items 139 149 self.logic.data = GuiUtils.dataFromItem(value[0]) … … 141 151 self.data_is_loaded = True 142 152 # Tag along functionality 153 self.label.setText("Data loaded from: ") 154 self.lblFilename.setText(self.logic.data.title) 143 155 self.updateQRange() 144 156 self.cmdFit.setEnabled(True) … … 151 163 """ Disable the combobox """ 152 164 self.cbModel.setEnabled(False) 153 self.l abel_3.setEnabled(False)165 self.lblModel.setEnabled(False) 154 166 155 167 def enableModelCombo(self): 156 168 """ Enable the combobox """ 157 169 self.cbModel.setEnabled(True) 158 self.l abel_3.setEnabled(True)170 self.lblModel.setEnabled(True) 159 171 160 172 def disableStructureCombo(self): 161 173 """ Disable the combobox """ 162 174 self.cbStructureFactor.setEnabled(False) 163 self.l abel_4.setEnabled(False)175 self.lblStructure.setEnabled(False) 164 176 165 177 def enableStructureCombo(self): 166 178 """ Enable the combobox """ 167 179 self.cbStructureFactor.setEnabled(True) 168 self.l abel_4.setEnabled(True)180 self.lblStructure.setEnabled(True) 169 181 170 182 def updateQRange(self): … … 271 283 models = [] 272 284 # Populate the models combobox 273 self.cbModel.addItems(sorted([model for (model, _) in model_list]))285 self.cbModel.addItems(sorted([model for (model, _) in model_list])) 274 286 275 287 def createDefaultDataset(self): … … 303 315 self.createDefaultDataset() 304 316 else: 305 self.calculate DataForModel()317 self.calculateQGridForModel() 306 318 307 319 def onSelectStructureFactor(self): … … 427 439 value = item.checkState() 428 440 else: 429 value = float(item.text()) 441 try: 442 value = float(item.text()) 443 except ValueError: 444 # Can't be converted properly, bring back the old value and exit 445 return 446 430 447 parameter_name = str(self._poly_model.data(name_index).toPyObject()) # "distribution of sld" etc. 431 448 if "Distribution of" in parameter_name: … … 506 523 if self.data is None or not self.data.is_data: 507 524 self.createDefaultDataset() 508 self.calculate DataForModel()525 self.calculateQGridForModel() 509 526 510 527 def onNpts(self, text): … … 515 532 try: 516 533 self.npts = int(text) 517 except: 534 except ValueError: 535 # TODO 536 # This will return the old value to model/view and return 537 # notifying the user about format available. 518 538 pass 519 539 … … 525 545 try: 526 546 self.q_range_min = float(text) 527 except: 528 pass 547 except ValueError: 548 # TODO 549 # This will return the old value to model/view and return 550 # notifying the user about format available. 551 return 529 552 # set Q range labels on the main tab 530 553 self.lblMinRangeDef.setText(str(self.q_range_min)) … … 550 573 return self.complete1D if isinstance(self.data, Data1D) else self.complete2D 551 574 552 def calculate DataForModel(self):575 def calculateQGridForModel(self): 553 576 """ 554 577 Prepare the fitting data object, based on current ModelModel … … 603 626 def calcException(self, etype, value, tb): 604 627 """ 605 Something horrible happened in the deferred. Cry me a river.628 Something horrible happened in the deferred. 606 629 """ 607 630 logging.error("".join(traceback.format_exception(etype, value, tb))) 608 msg = traceback.format_exception(etype, value, tb, limit=1)609 631 610 632 def setTableProperties(self, table): … … 624 646 625 647 header.ResizeMode(QtGui.QHeaderView.Interactive) 648 # Resize column 0 and 6 to content 626 649 header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents) 627 650 header.setResizeMode(6, QtGui.QHeaderView.ResizeToContents) … … 694 717 695 718 func = QtGui.QComboBox() 696 func.addItems([str(i+1) for i in xrange(param_length)]) 719 # Available range of shells displayed in the combobox 720 func.addItems([str(i) for i in xrange(param_length+1)]) 721 # Respond to index change 697 722 func.currentIndexChanged.connect(self.modifyShellsInList) 698 723 -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
r5236449 rb1e36a3 74 74 </item> 75 75 <item row="0" column="1"> 76 <widget class="QLabel" name="l abel_3">76 <widget class="QLabel" name="lblModel"> 77 77 <property name="text"> 78 78 <string>Model name</string> … … 81 81 </item> 82 82 <item row="0" column="2"> 83 <widget class="QLabel" name="l abel_4">83 <widget class="QLabel" name="lblStructure"> 84 84 <property name="text"> 85 85 <string>Structure factor</string> -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py
r7248d75d rb1e36a3 114 114 115 115 # Test the resulting model 116 self.assertEqual(model.rowCount(), 5)116 self.assertEqual(model.rowCount(), 3) 117 117 self.assertTrue(model.item(0).isCheckable()) 118 118 self.assertEqual(model.item(0).text(), "sld_core") 119 self.assertFalse(model.item(3).hasChildren())120 119 self.assertEqual(model.item(1).text(), "radius") 121 120 self.assertEqual(model.item(2).text(), "sld_solvent") 122 self.assertEqual(model.item(3).text(), "sld1")123 124 self.assertEqual(model.item(4).text(), "thickness1")125 self.assertTrue(model.item(4).hasChildren())126 121 127 122 def testAddSimpleParametersToModel(self): … … 139 134 140 135 # Test the resulting model 141 self.assertEqual(model.rowCount(), 5)136 self.assertEqual(model.rowCount(), 3) 142 137 self.assertTrue(model.item(0).isCheckable()) 143 138 self.assertEqual(model.item(0).text(), "sld_core") -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r351b53e rb1e36a3 165 165 166 166 # invoke the method by changing the index 167 self.widget.cbCategory.setCurrentIndex(1) 167 category_index = self.widget.cbCategory.findText("Shape-Independent") 168 self.widget.cbCategory.setCurrentIndex(category_index) 168 169 169 170 # test the model combo content … … 190 191 self.widget.show() 191 192 # Change the category index so we have some models 192 self.widget.cbCategory.setCurrentIndex(1) 193 category_index = self.widget.cbCategory.findText("Shape-Independent") 194 self.widget.cbCategory.setCurrentIndex(category_index) 193 195 194 196 # check the enablement of controls … … 202 204 self.widget.SASModelToQModel = MagicMock() 203 205 self.widget.createDefaultDataset = MagicMock() 204 self.widget.calculate DataForModel = MagicMock()206 self.widget.calculateQGridForModel = MagicMock() 205 207 # 206 208 # Now change the model … … 211 213 self.assertTrue(self.widget.createDefaultDataset.called) 212 214 self.assertTrue(self.widget.SASModelToQModel.called) 213 self.assertFalse(self.widget.calculate DataForModel.called)215 self.assertFalse(self.widget.calculateQGridForModel.called) 214 216 215 217 # Let's set a dummy index on widget … … 219 221 self.assertEqual(self.widget.cbModel.currentText(),'be_polyelectrolyte') 220 222 221 # Observe calculate DataForModel called222 self.assertTrue(self.widget.calculate DataForModel.called)223 # Observe calculateQGridForModel called 224 self.assertTrue(self.widget.calculateQGridForModel.called) 223 225 224 226 def testSelectFactor(self): … … 228 230 self.widget.show() 229 231 # Change the category index so we have some models 230 self.widget.cbCategory.setCurrentIndex(1) 232 category_index = self.widget.cbCategory.findText("Shape-Independent") 233 self.widget.cbCategory.setCurrentIndex(category_index) 231 234 # Change the model to one that supports structure factors 232 235 model_index = self.widget.cbModel.findText('fractal_core_shell') … … 296 299 # Check the index 297 300 298 def testCalculate DataForModel(self):301 def testCalculateQGridForModel(self): 299 302 """ 300 303 Check that the fitting 1D data object is ready … … 303 306 threads.deferToThread = MagicMock() 304 307 # Call the tested method 305 self.widget.calculate DataForModel()308 self.widget.calculateQGridForModel() 306 309 # Test the mock 307 310 self.assertTrue(threads.deferToThread.called) … … 328 331 self.widget.show() 329 332 # Change the category index so we have a model with no poly 330 self.widget.cbCategory.setCurrentIndex(1) 333 category_index = self.widget.cbCategory.findText("Shape-Independent") 334 self.widget.cbCategory.setCurrentIndex(category_index) 331 335 # Check the poly model 332 336 self.assertEqual(self.widget._poly_model.rowCount(), 0) … … 356 360 self.widget.show() 357 361 # Change the category index so we have a model available 358 self.widget.cbCategory.setCurrentIndex(2) 362 category_index = self.widget.cbCategory.findText("Shapes") 363 self.widget.cbCategory.setCurrentIndex(category_index) 359 364 360 365 # Check the magnetic model … … 384 389 self.widget.show() 385 390 # Change the model to multi shell 386 self.widget.cbCategory.setCurrentIndex(2) 387 self.widget.cbModel.setCurrentIndex(4) 391 category_index = self.widget.cbCategory.findText("Shapes") 392 self.widget.cbCategory.setCurrentIndex(category_index) 393 model_index = self.widget.cbModel.findText("core_multi_shell") 394 self.widget.cbModel.setCurrentIndex(model_index) 388 395 389 396 # Assure we have the combobox available -
src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py
r0979dfb rb1e36a3 78 78 self._data = None 79 79 self._path = "" 80 81 self._allow_close = False 80 82 81 83 # Mask file selector … … 106 108 self.setupMapper() 107 109 108 #def closeEvent(self, event): 109 # """ 110 # Overwrite the default close method of QWidget 111 # """ 112 # # No close on perspectives - one must always be active. 113 # event.ignore() 110 def setClosable(self, value=True): 111 """ 112 Allow outsiders close this widget 113 """ 114 assert isinstance(value, bool) 115 116 self._allow_close = value 117 118 def closeEvent(self, event): 119 """ 120 Overwrite QDialog close method to allow for custom widget close 121 """ 122 if self._allow_close: 123 # reset the closability flag 124 self.setClosable(value=False) 125 event.accept() 126 else: 127 event.ignore() 128 # Maybe we should just minimize 129 self.setWindowState(QtCore.Qt.WindowMinimized) 114 130 115 131 def communicator(self):
Note: See TracChangeset
for help on using the changeset viewer.