Changeset 5a96a72 in sasview
- Timestamp:
- Sep 8, 2018 11:17:59 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- e4041a2
- Parents:
- 5e0891b
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
r9ba91b7 r5a96a72 213 213 plots = [] 214 214 for name, result in return_data['intermediate_results'].items(): 215 if not isinstance(result, np.ndarray): 216 continue 215 217 plots.append(self._create1DPlot(tab_id, return_data['x'], result, 216 218 return_data['model'], return_data['data'], 217 219 component=name)) 218 220 return plots 221 222 def getScalarIntermediateResults(self, return_data): 223 """ 224 Returns a dict of scalar-only intermediate results from the return data. 225 """ 226 res = {} 227 for name, int_res in return_data["intermediate_results"].items(): 228 if isinstance(int_res, np.ndarray): 229 continue 230 res[name] = int_res 231 return res 219 232 220 233 def computeDataRange(self): -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r5e0891b r5a96a72 2229 2229 # TODO: multishell params in self.kernel_module.details[??] = value 2230 2230 2231 # handle display of effective radius parameter according to radius_effective_mode; pass ER into model if 2232 # necessary 2233 self.processEffectiveRadius() 2234 2231 2235 # Force the chart update when actual parameters changed 2232 2236 if model_column == 1: … … 2235 2239 # Update state stack 2236 2240 self.updateUndo() 2241 2242 def processEffectiveRadius(self): 2243 """ 2244 Checks the value of radius_effective_mode, if existent, and processes radius_effective as necessary. 2245 * mode == 0: This means 'unconstrained'; ensure use can specify ER. 2246 * mode > 0: This means it is constrained to a P(Q)-computed value in sasmodels; prevent user from editing ER. 2247 2248 Note: If ER has been computed, it is passed back to SasView as an intermediate result. That value must be 2249 displayed for the user; that is not dealt with here, but in complete1D. 2250 """ 2251 ER_row = self.getRowFromName("radius_effective") 2252 if ER_row is None: 2253 return 2254 2255 ER_mode_row = self.getRowFromName("radius_effective_mode") 2256 if ER_mode_row is None: 2257 return 2258 2259 try: 2260 ER_mode = int(self._model_model.item(ER_mode_row, 1).text()) 2261 except ValueError: 2262 logging.error("radius_effective_mode was set to an invalid value.") 2263 return 2264 2265 if ER_mode == 0: 2266 # ensure the ER value can be modified by user 2267 self.setParamEditableByRow(ER_row, True) 2268 elif ER_mode > 0: 2269 # ensure the ER value cannot be modified by user 2270 self.setParamEditableByRow(ER_row, False) 2271 else: 2272 logging.error("radius_effective_mode was set to an invalid value.") 2273 2274 def setParamEditableByRow(self, row, editable=True): 2275 """ 2276 Sets whether the user can edit a parameter in the table. If they cannot, the parameter name's font is changed, 2277 the value itself cannot be edited if clicked on, and the parameter may not be fitted. 2278 """ 2279 item_name = self._model_model.item(row, 0) 2280 item_value = self._model_model.item(row, 1) 2281 2282 item_value.setEditable(editable) 2283 2284 if editable: 2285 # reset font 2286 item_name.setFont(QtGui.QFont()) 2287 # reset colour 2288 item_name.setForeground(QtGui.QBrush()) 2289 # make checkable 2290 item_name.setCheckable(True) 2291 else: 2292 # change font 2293 font = QtGui.QFont() 2294 font.setItalic(True) 2295 item_name.setFont(font) 2296 # change colour 2297 item_name.setForeground(QtGui.QBrush(QtGui.QColor(50, 50, 50))) 2298 # make not checkable (and uncheck) 2299 item_name.setCheckState(QtCore.Qt.Unchecked) 2300 item_name.setCheckable(False) 2237 2301 2238 2302 def isCheckable(self, row): … … 2437 2501 self.communicate.plotUpdateSignal.emit([plot]) 2438 2502 2503 # Update radius_effective if relevant 2504 def updateRadiusEffective(): 2505 ER_mode_row = self.getRowFromName("radius_effective_mode") 2506 if ER_mode_row is None: 2507 return 2508 try: 2509 ER_mode = int(self._model_model.item(ER_mode_row, 1).text()) 2510 except ValueError: 2511 logging.error("radius_effective_mode was set to an invalid value.") 2512 return 2513 if ER_mode < 1: 2514 # does not need updating if it is not being computed 2515 return 2516 2517 ER_row = self.getRowFromName("radius_effective") 2518 if ER_row is None: 2519 return 2520 2521 scalar_results = self.logic.getScalarIntermediateResults(return_data) 2522 ER_value = scalar_results.get("effective_radius") # note name of key 2523 if ER_value is None: 2524 return 2525 # ensure the model does not recompute when updating the value 2526 self._model_model.blockSignals(True) 2527 self._model_model.item(ER_row, 1).setText(str(ER_value)) 2528 self._model_model.blockSignals(False) 2529 # ensure the view is updated immediately 2530 self._model_model.layoutChanged.emit() 2531 2532 updateRadiusEffective() 2533 2439 2534 def complete2D(self, return_data): 2440 2535 """
Note: See TracChangeset
for help on using the changeset viewer.