- Timestamp:
- Feb 28, 2017 9:50:42 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:
- 68c96d3
- Parents:
- 60af928
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r60af928 rf46f6dc 16 16 self.parent = parent 17 17 self._data = data 18 19 #r = raw_input("A")20 #r = 121 18 22 19 # List of active fits … … 40 37 # Deal with signals 41 38 self.tabCloseRequested.connect(self.tabCloses) 42 39 43 40 self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) 44 41 … … 58 55 page_name = "FitPage" + str(self.maxIndex) 59 56 return page_name 60 57 61 58 def tabCloses(self, index): 62 59 """ … … 70 67 self.removeTab(index) 71 68 69 def allowBatch(self): 70 """ 71 Tell the caller that we accept multiple data instances 72 """ 73 return True 74 75 def setData(self, data=None): 76 """ 77 Assign new dataset to the fitting instance 78 """ 79 assert(data is not None) 80 81 # find an unassigned tab. 82 # if none, open a new tab. 83 tab_to_send = None 84 for tab in self.tabs: 85 if tab.acceptsData(): 86 tab_to_send = tab 87 break 88 # send data 89 if tab_to_send is None: 90 self.addFit(data) 91 else: 92 tab_to_send.data = data 93 pass 94 72 95 if __name__ == "__main__": 73 96 app = QtGui.QApplication([]) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r60af928 rf46f6dc 18 18 class FittingWidget(QtGui.QWidget, Ui_FittingWidgetUI): 19 19 """ 20 Main wi ndowfor selecting form and structure factor models20 Main widget for selecting form and structure factor models 21 21 """ 22 name = "Fitting" # For displaying in the combo box in DataExplorer23 22 def __init__(self, manager=None, parent=None, data=None): 24 23 """ … … 34 33 self.is2D = False 35 34 self.modelHasShells = False 35 self.data_assigned = False 36 36 37 37 self.setupUi(self) … … 106 106 """ data setter """ 107 107 self._data = value 108 self.data_assigned = True 108 109 # TODO: update ranges, chi2 etc 110 111 def acceptsData(self): 112 """ Tells the caller this widget can accept new dataset """ 113 return not self.data_assigned 109 114 110 115 def selectCategory(self): … … 168 173 self.model_enabled_dict[model] = enabled 169 174 175 def checkMultiplicity(self, model): 176 """ 177 """ 178 iter_param = "" 179 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 187 return (iter_param, iter_length) 170 188 171 189 def setModelModel(self, model_name): … … 198 216 self._model_model.appendRow([item1, item2, item3, item4, item5]) 199 217 200 #TODO: iq_parameters are used here. If orientation paramateres or magnetic are needed kernel_paramters should be used instead 218 multishell_param_name, multishell_param_length = self.checkMultiplicity(self.model_parameters) 219 multishell_param_fullname = "[%s]" % multishell_param_name 220 #TODO: iq_parameters are used here. If orientation paramateres or magnetic are needed 221 # kernel_paramters should be used instead 201 222 #For orientation and magentic parameters param.type needs to be checked 202 223 for param in self.model_parameters.iq_parameters: 203 item1 = QtGui.QStandardItem(param.name) 224 # don't include shell parameters 225 if param.name == multishell_param_name: 226 continue 227 # Modify parameter name from <param>[n] to <param>1 228 item_name = param.name 229 if multishell_param_fullname in param.name: 230 item_name = self.replaceShellName(param.name, 1) 231 item1 = QtGui.QStandardItem(item_name) 204 232 item1.setCheckable(True) 205 233 item2 = QtGui.QStandardItem(str(param.default)) … … 215 243 self._model_model.setHeaderData(4, QtCore.Qt.Horizontal, QtCore.QVariant("[Units]")) 216 244 217 self.modelHasShells = True # Test 218 if self.modelHasShells: 219 self.addExtraShells() 245 self.addExtraShells() 220 246 221 247 self.setPolyModel() 222 248 self.setMagneticModel() 223 249 self.model_is_loaded = True 250 251 def replaceShellName(self, param_name, value): 252 """ 253 Updates parameter name from <param_name>[n_shell] to <param_name>value 254 """ 255 new_name = param_name[:param_name.index('[')]+str(value) 256 return new_name 224 257 225 258 def setTableProperties(self, table): … … 234 267 table.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 235 268 table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) 269 table.resizeColumnsToContents() 270 236 271 # Header 237 272 header = table.horizontalHeader() 238 header.setResizeMode(QtGui.QHeaderView.Stretch) 239 header.setStretchLastSection(True) 273 header.setResizeMode(QtGui.QHeaderView.ResizeToContents) 274 275 header.ResizeMode(QtGui.QHeaderView.Interactive) 276 header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents) 277 header.setResizeMode(6, QtGui.QHeaderView.ResizeToContents) 240 278 241 279 def setPolyModel(self): … … 270 308 self._poly_model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant("Function")) 271 309 272 self.lstPoly.resizeColumnsToContents()273 header = self.lstPoly.horizontalHeader()274 header.ResizeMode(QtGui.QHeaderView.Stretch)275 #header.setStretchLastSection(True)276 277 310 def setMagneticModel(self): 278 311 """ … … 306 339 self._magnet_model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant("Function")) 307 340 308 self.lstMagnetic.resizeColumnsToContents()309 header = self.lstMagnetic.horizontalHeader()310 header.ResizeMode(QtGui.QHeaderView.Stretch)311 header.setStretchLastSection(True)312 313 341 def addExtraShells(self): 314 342 """ 315 """ 343 Add a combobox for multiple shell display 344 """ 345 param_name, param_length = self.checkMultiplicity(self.model_parameters) 346 347 if param_length == 0: 348 return 349 350 item1 = QtGui.QStandardItem(param_name) 351 316 352 func = QtGui.QComboBox() 317 func.addItems([ 'No extra shell','Add 1 shell','Ad 2 shells'])318 319 item = QtGui.QStandardItem("")320 self._model_model.appendRow([item ])353 func.addItems([str(i+1) for i in xrange(param_length)]) 354 355 item2 = QtGui.QStandardItem() 356 self._model_model.appendRow([item1, item2]) 321 357 322 358 shell_row = self._model_model.rowCount() 323 shell_index = self._model_model.index(shell_row-1, 0)359 shell_index = self._model_model.index(shell_row-1, 1) 324 360 self.lstParams.setIndexWidget(shell_index, func) 325 self.lstParams.setSpan(shell_row-1, 1,1,4)361 self.lstParams.setSpan(shell_row-1,2,2,4) 326 362 327 363 def togglePoly(self, isChecked): … … 341 377 self.is2D = isChecked 342 378 343 if __name__ == "__main__":344 app = QtGui.QApplication([])345 dlg = FittingWidget()346 dlg.show()347 sys.exit(app.exec_()) -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
r60af928 rf46f6dc 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 680</width>9 <width>514</width> 10 10 <height>721</height> 11 11 </rect> … … 659 659 </widget> 660 660 </item> 661 <item row="2" column="1" colspan="2"> 661 <item row="2" column="3"> 662 <widget class="QPushButton" name="cmdPlot"> 663 <property name="sizePolicy"> 664 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 665 <horstretch>0</horstretch> 666 <verstretch>0</verstretch> 667 </sizepolicy> 668 </property> 669 <property name="minimumSize"> 670 <size> 671 <width>75</width> 672 <height>23</height> 673 </size> 674 </property> 675 <property name="text"> 676 <string>Show Plot</string> 677 </property> 678 </widget> 679 </item> 680 <item row="2" column="4"> 681 <widget class="QPushButton" name="cmdFit"> 682 <property name="sizePolicy"> 683 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 684 <horstretch>0</horstretch> 685 <verstretch>0</verstretch> 686 </sizepolicy> 687 </property> 688 <property name="minimumSize"> 689 <size> 690 <width>75</width> 691 <height>23</height> 692 </size> 693 </property> 694 <property name="text"> 695 <string>Fit</string> 696 </property> 697 </widget> 698 </item> 699 <item row="2" column="5"> 700 <widget class="QPushButton" name="cmdHelp"> 701 <property name="sizePolicy"> 702 <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 703 <horstretch>0</horstretch> 704 <verstretch>0</verstretch> 705 </sizepolicy> 706 </property> 707 <property name="minimumSize"> 708 <size> 709 <width>75</width> 710 <height>23</height> 711 </size> 712 </property> 713 <property name="text"> 714 <string>Help</string> 715 </property> 716 </widget> 717 </item> 718 <item row="2" column="0" colspan="3"> 662 719 <spacer name="horizontalSpacer"> 663 720 <property name="orientation"> … … 671 728 </property> 672 729 </spacer> 673 </item>674 <item row="2" column="3">675 <widget class="QPushButton" name="cmdPlot">676 <property name="text">677 <string>Show Plot</string>678 </property>679 </widget>680 </item>681 <item row="2" column="4">682 <widget class="QPushButton" name="cmdFit">683 <property name="text">684 <string>Fit</string>685 </property>686 </widget>687 </item>688 <item row="2" column="5">689 <widget class="QPushButton" name="cmdHelp">690 <property name="text">691 <string>Help</string>692 </property>693 </widget>694 730 </item> 695 731 </layout>
Note: See TracChangeset
for help on using the changeset viewer.