Changeset 906e0c7 in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Aug 28, 2018 12:12:01 PM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- f2530048
- Parents:
- 4fd19be
- git-author:
- Torin Cooper-Bennun <torin.cooper-bennun@…> (08/28/18 12:11:56)
- git-committer:
- Torin Cooper-Bennun <torin.cooper-bennun@…> (08/28/18 12:12:01)
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r54492dc r906e0c7 1124 1124 parameter_name = parameter_name.rsplit()[-1] 1125 1125 1126 delegate = self.lstPoly.itemDelegate() 1127 1126 1128 # Extract changed value. 1127 if model_column == self.lstPoly.itemDelegate().poly_parameter:1129 if model_column == delegate.poly_parameter: 1128 1130 # Is the parameter checked for fitting? 1129 1131 value = item.checkState() … … 1135 1137 self.parameters_to_fit.remove(parameter_name) 1136 1138 self.cmdFit.setEnabled(self.parameters_to_fit != [] and self.logic.data_is_loaded) 1137 return 1138 elif model_column in [ self.lstPoly.itemDelegate().poly_min, self.lstPoly.itemDelegate().poly_max]:1139 1140 elif model_column in [delegate.poly_min, delegate.poly_max]: 1139 1141 try: 1140 1142 value = GuiUtils.toDouble(item.text()) … … 1144 1146 1145 1147 current_details = self.kernel_module.details[parameter_name] 1146 current_details[model_column-1] = value 1147 elif model_column == self.lstPoly.itemDelegate().poly_function: 1148 if self.has_poly_error_column: 1149 # err column changes the indexing 1150 current_details[model_column-2] = value 1151 else: 1152 current_details[model_column-1] = value 1153 1154 elif model_column == delegate.poly_function: 1148 1155 # name of the function - just pass 1149 return 1156 pass 1157 1150 1158 else: 1151 1159 try: … … 1157 1165 # Update the sasmodel 1158 1166 # PD[ratio] -> width, npts -> npts, nsigs -> nsigmas 1159 self.kernel_module.setParam(parameter_name + '.' + \ 1160 self.lstPoly.itemDelegate().columnDict()[model_column], value) 1167 self.kernel_module.setParam(parameter_name + '.' + delegate.columnDict()[model_column], value) 1161 1168 1162 1169 # Update plot 1163 1170 self.updateData() 1171 1172 # update in param model 1173 if model_column in [delegate.poly_pd, delegate.poly_error, delegate.poly_min, delegate.poly_max]: 1174 row = self.getRowFromName(parameter_name) 1175 param_item = self._model_model.item(row) 1176 param_item.child(0).child(0, model_column).setText(item.text()) 1164 1177 1165 1178 def onMagnetModelChange(self, item): … … 1544 1557 param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 1545 1558 self._model_model.item(row, 0).child(0).child(0,1).setText(param_repr) 1559 # modify the param error 1560 if self.has_error_column: 1561 error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 1562 self._model_model.item(row, 0).child(0).child(0,2).setText(error_repr) 1546 1563 1547 1564 def createErrorColumn(row): … … 1558 1575 error_column.append(item) 1559 1576 1577 def createPolyErrorColumn(row): 1578 # Utility function for error column update in the polydispersity sub-rows 1579 # NOTE: only creates empty items; updatePolyValues adds the error value 1580 item = self._model_model.item(row, 0) 1581 if not item.hasChildren(): 1582 return 1583 poly_item = item.child(0) 1584 if not poly_item.hasChildren(): 1585 return 1586 poly_item.insertColumn(2, [QtGui.QStandardItem("")]) 1587 1560 1588 # block signals temporarily, so we don't end up 1561 1589 # updating charts with every single model change on the end of fitting 1562 1590 self._model_model.blockSignals(True) 1591 1592 if not self.has_error_column: 1593 # create top-level error column 1594 error_column = [] 1595 self.lstParams.itemDelegate().addErrorColumn() 1596 self.iterateOverModel(createErrorColumn) 1597 1598 # we need to enable signals for this, otherwise the final column mysteriously disappears (don't ask, I don't 1599 # know) 1600 self._model_model.blockSignals(False) 1601 self._model_model.insertColumn(2, error_column) 1602 self._model_model.blockSignals(True) 1603 1604 FittingUtilities.addErrorHeadersToModel(self._model_model) 1605 1606 # create error column in polydispersity sub-rows 1607 self.iterateOverModel(createPolyErrorColumn) 1608 1609 self.has_error_column = True 1610 1563 1611 self.iterateOverModel(updateFittedValues) 1564 1612 self.iterateOverModel(updatePolyValues) 1613 1565 1614 self._model_model.blockSignals(False) 1566 1615 1567 if self.has_error_column:1568 return1569 1570 error_column = []1571 self.lstParams.itemDelegate().addErrorColumn()1572 self.iterateOverModel(createErrorColumn)1573 1574 # switch off reponse to model change1575 self._model_model.insertColumn(2, error_column)1576 FittingUtilities.addErrorHeadersToModel(self._model_model)1577 1616 # Adjust the table cells width. 1578 1617 # TODO: find a way to dynamically adjust column width while resized expanding … … 1581 1620 self.lstParams.resizeColumnToContents(5) 1582 1621 self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 1583 1584 self.has_error_column = True1585 1622 1586 1623 def iterateOverPolyModel(self, func): … … 2432 2469 return 2433 2470 # Modify the param value 2434 self._model_model.item(row, 0).child(0).child(0,4).setText(combo_string) 2471 if self.has_error_column: 2472 # err column changes the indexing 2473 self._model_model.item(row, 0).child(0).child(0,5).setText(combo_string) 2474 else: 2475 self._model_model.item(row, 0).child(0).child(0,4).setText(combo_string) 2435 2476 2436 2477 if combo_string == 'array': -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r97df8a9 r906e0c7 129 129 self.poly_parameter = 0 130 130 self.poly_pd = 1 131 self.poly_error = None 131 132 self.poly_min = 2 132 133 self.poly_max = 3 … … 153 154 self.poly_parameter = 0 154 155 self.poly_pd = 1 156 self.poly_error = 2 155 157 self.poly_min = 3 156 158 self.poly_max = 4
Note: See TracChangeset
for help on using the changeset viewer.