- Timestamp:
- Aug 25, 2017 6:37:30 AM (7 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:
- 4d1eff2
- Parents:
- b2a5042
- git-author:
- Piotr Rozyczko <rozyczko@…> (08/25/17 06:31:37)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (08/25/17 06:37:30)
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r689222c re43fc91 159 159 model.setHeaderData(5, QtCore.Qt.Horizontal, QtCore.QVariant("Nsigs")) 160 160 model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant("Function")) 161 model.setHeaderData(7, QtCore.Qt.Horizontal, QtCore.QVariant("Filename")) 161 162 162 163 def addErrorPolyHeadersToModel(model): … … 172 173 model.setHeaderData(6, QtCore.Qt.Horizontal, QtCore.QVariant("Nsigs")) 173 174 model.setHeaderData(7, QtCore.Qt.Horizontal, QtCore.QVariant("Function")) 175 model.setHeaderData(8, QtCore.Qt.Horizontal, QtCore.QVariant("Filename")) 174 176 175 177 def addShellsToModel(parameters, model, index): -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r457d961 re43fc91 286 286 # Polydispersity function combo response 287 287 self.lstPoly.itemDelegate().combo_updated.connect(self.onPolyComboIndexChange) 288 self.lstPoly.itemDelegate().filename_updated.connect(self.onPolyFilenameChange) 288 289 289 290 # Magnetism model displayed in magnetism list … … 566 567 # name of the function - just pass 567 568 return 569 elif model_column == self.lstPoly.itemDelegate().poly_filename: 570 # filename for array - just pass 571 return 568 572 else: 569 573 try: … … 1488 1492 1489 1493 header.ResizeMode(QtGui.QHeaderView.Interactive) 1490 # Resize column 0 and 6to content1494 # Resize column 0 and 7 to content 1491 1495 header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents) 1492 header.setResizeMode( 6, QtGui.QHeaderView.ResizeToContents)1496 header.setResizeMode(7, QtGui.QHeaderView.ResizeToContents) 1493 1497 1494 1498 def setPolyModel(self): … … 1500 1504 self._poly_model.clear() 1501 1505 1502 [self.setPolyModelParameters( param) for _, param in \1506 [self.setPolyModelParameters(i, param) for i, param in \ 1503 1507 enumerate(self.model_parameters.form_volume_parameters) if param.polydisperse] 1504 1508 FittingUtilities.addPolyHeadersToModel(self._poly_model) 1505 1509 1506 def setPolyModelParameters(self, param):1510 def setPolyModelParameters(self, i, param): 1507 1511 """ 1508 1512 Standard of multishell poly parameter driver … … 1519 1523 # Remove [n] and add the shell numeral 1520 1524 name = param_name[0:param_name.index('[')] + str(ishell) 1521 self.addNameToPolyModel( name)1525 self.addNameToPolyModel(i, name) 1522 1526 else: 1523 1527 # Just create a simple param entry 1524 self.addNameToPolyModel( param_name)1525 1526 def addNameToPolyModel(self, param_name):1528 self.addNameToPolyModel(i, param_name) 1529 1530 def addNameToPolyModel(self, i, param_name): 1527 1531 """ 1528 1532 Creates a checked row in the poly model with param_name … … 1539 1543 checked_list = ["Distribution of " + param_name, str(width), 1540 1544 str(min), str(max), 1541 str(npts), str(nsigs), "gaussian " ]1545 str(npts), str(nsigs), "gaussian ",''] 1542 1546 FittingUtilities.addCheckedListToModel(self._poly_model, checked_list) 1543 1547 … … 1545 1549 func = QtGui.QComboBox() 1546 1550 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.iterkeys()]) 1547 # set the default index1551 # Set the default index 1548 1552 func.setCurrentIndex(func.findText(DEFAULT_POLYDISP_FUNCTION)) 1553 ind = self._poly_model.index(i,self.lstPoly.itemDelegate().poly_function) 1554 self.lstPoly.setIndexWidget(ind, func) 1555 func.currentIndexChanged.connect(lambda: self.onPolyComboIndexChange(str(func.currentText()), i)) 1556 1557 def onPolyFilenameChange(self, row_index): 1558 """ 1559 Respond to filename_updated signal from the delegate 1560 """ 1561 # For the given row, invoke the "array" combo handler 1562 array_caption = 'array' 1563 self.onPolyComboIndexChange(array_caption, row_index) 1564 # Get the combo box reference 1565 ind = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_function) 1566 widget = self.lstPoly.indexWidget(ind) 1567 # Update the combo box so it displays "array" 1568 widget.blockSignals(True) 1569 widget.setCurrentIndex(self.lstPoly.itemDelegate().POLYDISPERSE_FUNCTIONS.index(array_caption)) 1570 widget.blockSignals(False) 1549 1571 1550 1572 def onPolyComboIndexChange(self, combo_string, row_index): … … 1554 1576 # Get npts/nsigs for current selection 1555 1577 param = self.model_parameters.form_volume_parameters[row_index] 1578 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_function) 1579 combo_box = self.lstPoly.indexWidget(file_index) 1580 orig_index = combo_box.currentIndex() 1556 1581 1557 1582 def updateFunctionCaption(row): … … 1565 1590 if combo_string == 'array': 1566 1591 try: 1567 self.loadPolydispArray( )1592 self.loadPolydispArray(row_index) 1568 1593 # Update main model for display 1569 1594 self.iterateOverModel(updateFunctionCaption) 1570 except (ValueError, IOError): 1571 # Don't do anything if file lookup failed 1595 # disable the row 1596 lo = self.lstPoly.itemDelegate().poly_pd 1597 hi = self.lstPoly.itemDelegate().poly_function 1598 [self._poly_model.item(row_index, i).setEnabled(False) for i in xrange(lo, hi)] 1572 1599 return 1573 # disable the row 1574 [self._poly_model.item(row_index, i).setEnabled(False) for i in xrange(6)] 1575 return 1600 except IOError: 1601 combo_box.setCurrentIndex(orig_index) 1602 # Pass for cancel/bad read 1603 pass 1576 1604 1577 1605 # Enable the row in case it was disabled by Array 1578 1606 self._poly_model.blockSignals(True) 1579 [self._poly_model.item(row_index, i).setEnabled(True) for i in xrange(6)] 1607 max_range = self.lstPoly.itemDelegate().poly_filename 1608 [self._poly_model.item(row_index, i).setEnabled(True) for i in xrange(7)] 1609 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1610 self._poly_model.setData(file_index, QtCore.QVariant("")) 1580 1611 self._poly_model.blockSignals(False) 1581 1612 … … 1591 1622 self.iterateOverModel(updateFunctionCaption) 1592 1623 1593 def loadPolydispArray(self ):1624 def loadPolydispArray(self, row_index): 1594 1625 """ 1595 1626 Show the load file dialog and loads requested data into state … … 1599 1630 None, QtGui.QFileDialog.DontUseNativeDialog) 1600 1631 1601 if datafile is None :1632 if datafile is None or str(datafile)=='': 1602 1633 logging.info("No weight data chosen.") 1603 1634 raise IOError … … 1623 1654 self.disp_model = POLYDISPERSITY_MODELS['array']() 1624 1655 self.disp_model.set_weights(np.array(values), np.array(weights)) 1656 # + update the cell with filename 1657 fname = os.path.basename(str(datafile)) 1658 fname_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1659 self._poly_model.setData(fname_index, QtCore.QVariant(fname)) 1625 1660 1626 1661 def setMagneticModel(self): -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r377ade1 re43fc91 85 85 Custom delegate for appearance and behavior control of the polydispersity view 86 86 """ 87 #POLYDISPERSE_FUNCTIONS = ['rectangle', 'array', 'lognormal', 'gaussian', 'schulz']88 POLYDISPERSE_FUNCTIONS = ['rectangle', 'lognormal', 'gaussian', 'schulz']87 POLYDISPERSE_FUNCTIONS = ['rectangle', 'array', 'lognormal', 'gaussian', 'schulz'] 88 #POLYDISPERSE_FUNCTIONS = ['rectangle', 'lognormal', 'gaussian', 'schulz'] 89 89 90 90 combo_updated = QtCore.pyqtSignal(str, int) 91 filename_updated = QtCore.pyqtSignal(int) 91 92 92 93 def __init__(self, parent=None): … … 103 104 self.poly_nsigs = 5 104 105 self.poly_function = 6 106 self.poly_filename = 7 105 107 106 108 def editableParameters(self): … … 126 128 self.poly_nsigs = 6 127 129 self.poly_function = 7 130 self.poly_filename = 8 128 131 129 132 def createEditor(self, widget, option, index): 130 133 # Remember the current choice 131 current_text = index.data().toString()132 134 if not index.isValid(): 133 135 return 0 134 if index.column() == self.poly_function: 135 editor = QtGui.QComboBox(widget) 136 for function in self.POLYDISPERSE_FUNCTIONS: 137 editor.addItem(function) 138 current_index = editor.findText(current_text) 139 editor.setCurrentIndex(current_index if current_index>-1 else 3) 140 editor.currentIndexChanged.connect(lambda: self.combo_updated.emit(str(editor.currentText()), index.row())) 141 return editor 136 elif index.column() == self.poly_filename: 137 # Notify the widget that we want to change the filename 138 self.filename_updated.emit(index.row()) 139 return None 142 140 elif index.column() in self.editableParameters(): 143 editor = QtGui.QLineEdit(widget)141 self.editor = QtGui.QLineEdit(widget) 144 142 validator = QtGui.QDoubleValidator() 145 editor.setValidator(validator)146 return editor143 self.editor.setValidator(validator) 144 return self.editor 147 145 else: 148 146 QtGui.QStyledItemDelegate.createEditor(self, widget, option, index)
Note: See TracChangeset
for help on using the changeset viewer.