Changeset 6052c02 in sasview
- Timestamp:
- Jul 9, 2018 10:13:03 AM (6 years ago)
- Branches:
- ESS_GUI_iss959
- Children:
- 085e3c9d
- Parents:
- 515c23df
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
re20870bc r6052c02 45 45 from sas.qtgui.Perspectives.Fitting.ViewDelegate import PolyViewDelegate 46 46 from sas.qtgui.Perspectives.Fitting.ViewDelegate import MagnetismViewDelegate 47 from sas.qtgui.Perspectives.Fitting.ViewDelegate import StructureViewDelegate 47 48 from sas.qtgui.Perspectives.Fitting.Constraint import Constraint 48 49 from sas.qtgui.Perspectives.Fitting.MultiConstraint import MultiConstraint … … 50 51 51 52 52 53 TAB_MAGNETISM = 4 54 TAB_POLY = 3 53 TAB_STRUCTURE = 3 54 TAB_POLY = 4 55 TAB_MAGNETISM = 5 56 55 57 CATEGORY_DEFAULT = "Choose category..." 56 58 CATEGORY_STRUCTURE = "Structure Factor" … … 195 197 # Enable/disable UI components 196 198 self.setEnablementOnDataLoad() 199 200 @property 201 def structureView(self): 202 return self.lstStructureOptions 197 203 198 204 def initializeGlobals(self): … … 307 313 self._poly_model = ToolTippedItemModel() 308 314 self._magnet_model = ToolTippedItemModel() 315 self._structure_model = ToolTippedItemModel() 309 316 310 317 # Param model displayed in param list … … 361 368 # Delegates for custom editing and display 362 369 self.lstMagnetic.setItemDelegate(MagnetismViewDelegate(self)) 370 371 # Structure factor options model (TEMPORARY EXAMPLE) 372 373 header_list = ["Property", "Value"] 374 num_cols = len(header_list) 375 self._structure_model.setHorizontalHeaderLabels(header_list) 376 377 self.structure_params = [ 378 "mixture", 379 "effective radius", 380 "volume fraction" 381 ] 382 383 # these are just an example 384 param_vals = [ 385 "P(Q)S(Q)", 386 "ER_mean_curvature", 387 "VR_something_or_other" 388 ] 389 390 num_SoQs = 3 391 for i in range(num_SoQs): 392 item_toplevel = QtGui.QStandardItem() 393 item_toplevel.setEditable(False) 394 item_toplevel.setText("S{}(Q)".format(i+1)) 395 396 for param, val in zip(self.structure_params, param_vals): 397 item1 = QtGui.QStandardItem() 398 item1.setEditable(False) 399 item1.setText(param) 400 401 item2 = QtGui.QStandardItem() 402 item2.setText(val) 403 404 item_toplevel.appendRow([item1, item2]) 405 406 row_toplevel = [item_toplevel] 407 for i in range(num_cols - 1): 408 item = QtGui.QStandardItem() 409 item.setEditable(False) 410 row_toplevel.append(item) 411 412 self._structure_model.appendRow(row_toplevel) 413 414 self.lstStructureOptions.setModel(self._structure_model) 415 self.lstStructureOptions.setItemDelegate(StructureViewDelegate(self)) 416 self.lstStructureOptions.setAlternatingRowColors(True) 417 self.lstStructureOptions.setStyleSheet(stylesheet) 363 418 364 419 def initializeCategoryCombo(self): -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
rd4dac80 r6052c02 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 680</width>9 <width>487</width> 10 10 <height>605</height> 11 11 </rect> … … 352 352 </attribute> 353 353 </widget> 354 <widget class="QWidget" name="tabStructure"> 355 <attribute name="title"> 356 <string>S(Q) Options</string> 357 </attribute> 358 <layout class="QGridLayout" name="gridLayout_7"> 359 <property name="leftMargin"> 360 <number>15</number> 361 </property> 362 <property name="topMargin"> 363 <number>15</number> 364 </property> 365 <property name="rightMargin"> 366 <number>15</number> 367 </property> 368 <property name="bottomMargin"> 369 <number>15</number> 370 </property> 371 <item row="0" column="0"> 372 <widget class="QTreeView" name="lstStructureOptions"/> 373 </item> 374 </layout> 375 </widget> 354 376 <widget class="QWidget" name="tab_4"> 355 377 <attribute name="title"> -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
rfde5bcd r6052c02 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 7 import logging 8 logger = logging.getLogger(__name__) 6 9 7 10 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): … … 102 105 return 103 106 QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 104 105 107 106 108 class PolyViewDelegate(QtWidgets.QStyledItemDelegate): … … 280 282 # Just the default paint 281 283 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 284 285 class StructureViewDelegate(QtWidgets.QStyledItemDelegate): 286 """ 287 Custom delegate for appearance and behaviour control of the structure 288 factor options view 289 """ 290 def __init__(self, parent=None): 291 """ 292 Override parent constructor 293 """ 294 295 super(StructureViewDelegate, self).__init__() 296 297 self.fittingWidget = parent 298 299 def paint(self, painter, option, index): 300 """ 301 Override generic painter 302 """ 303 # TODO override this with something useful ... ? 304 super(StructureViewDelegate, self).paint( 305 painter, option, index 306 ) 307 308 def createEditor(self, parent, option, index): 309 """ 310 Override generic createEditor -- certain elements have 311 combo boxes 312 """ 313 314 model = self.fittingWidget.structureView.model() 315 316 if not index.parent(): 317 # we only care about child items since we don't edit top-level 318 # items in this view anyway 319 return super(QtWidgets.QStyledItemDelegate, self).createEditor( 320 parent, option, index 321 ) 322 323 # navigate to the parameter name through the parent item (it'll be 324 # on the same row, but col. 0) 325 parent_item = model.itemFromIndex(index.parent()) 326 param_item = parent_item.child(index.row(), 0) 327 328 #item = model.itemFromIndex(index) 329 #print("item (row) [param]: \"{}\" ({}) [{}]".format( 330 # item.text(), index.row(), param_item.text()) 331 #) 332 333 if param_item.text() in ["effective radius", "volume fraction"]: 334 # we want a combo box for these 335 return QtWidgets.QComboBox(parent) 336 337 # return default otherwise 338 return super(StructureViewDelegate, self).createEditor( 339 parent, option, index 340 )
Note: See TracChangeset
for help on using the changeset viewer.