Changes in src/sas/qtgui/Perspectives/Fitting/FittingWidget.py [0109f2a:a758043] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r0109f2a ra758043 49 49 50 50 51 52 51 TAB_MAGNETISM = 4 53 52 TAB_POLY = 3 … … 61 60 62 61 logger = logging.getLogger(__name__) 63 64 62 65 63 class ToolTippedItemModel(QtGui.QStandardItemModel): … … 221 219 # Utility variable to enable unselectable option in category combobox 222 220 self._previous_category_index = 0 223 # Utility variables for multishell display 224 self._n_shells_row = 0 225 self._num_shell_params = 0 221 # Utility variable for multishell display 222 self._last_model_row = 0 226 223 # Dictionary of {model name: model class} for the current category 227 224 self.models = {} … … 268 265 self.has_magnet_error_column = False 269 266 267 # If the widget generated theory item, save it 268 self.theory_item = None 269 270 270 # signal communicator 271 271 self.communicate = self.parent.communicate … … 390 390 # Tag along functionality 391 391 self.label.setText("Data loaded from: ") 392 self.lblFilename.setText(self.logic.data.filename) 392 if self.logic.data.filename: 393 self.lblFilename.setText(self.logic.data.filename) 394 else: 395 self.lblFilename.setText(self.logic.data.name) 393 396 self.updateQRange() 394 397 # Switch off Data2D control … … 523 526 # Signals from separate tabs asking for replot 524 527 self.options_widget.plot_signal.connect(self.onOptionsUpdate) 525 self.options_widget.plot_signal.connect(self.onOptionsUpdate)526 528 527 529 # Signals from other widgets … … 670 672 Return list of all parameters for the current model 671 673 """ 672 return [self._model_model.item(row).text() 673 for row in range(self._model_model.rowCount()) 674 if self.isCheckable(row)] 674 return [self._model_model.item(row).text() for row in range(self._model_model.rowCount())] 675 675 676 676 def modifyViewOnRow(self, row, font=None, brush=None): … … 700 700 assert isinstance(constraint, Constraint) 701 701 assert 0 <= row <= self._model_model.rowCount() 702 assert self.isCheckable(row)703 702 704 703 item = QtGui.QStandardItem() … … 721 720 max_col = self.lstParams.itemDelegate().param_max 722 721 for row in self.selectedParameters(): 723 assert(self.isCheckable(row))724 722 param = self._model_model.item(row, 0).text() 725 723 value = self._model_model.item(row, 1).text() … … 764 762 max_col = self.lstParams.itemDelegate().param_max 765 763 for row in range(self._model_model.rowCount()): 766 if not self.isCheckable(row):767 continue768 764 if not self.rowHasConstraint(row): 769 765 continue … … 794 790 For the given row, return its constraint, if any 795 791 """ 796 if self.isCheckable(row):792 try: 797 793 item = self._model_model.item(row, 1) 798 try: 799 return item.child(0).data() 800 except AttributeError: 801 # return none when no constraints 802 pass 803 return None 794 return item.child(0).data() 795 except AttributeError: 796 # return none when no constraints 797 return None 804 798 805 799 def rowHasConstraint(self, row): … … 807 801 Finds out if row of the main model has a constraint child 808 802 """ 809 if self.isCheckable(row): 810 item = self._model_model.item(row, 1) 811 if item.hasChildren(): 812 c = item.child(0).data() 813 if isinstance(c, Constraint): 814 return True 803 item = self._model_model.item(row, 1) 804 if item.hasChildren(): 805 c = item.child(0).data() 806 if isinstance(c, Constraint): 807 return True 815 808 return False 816 809 … … 819 812 Finds out if row of the main model has an active constraint child 820 813 """ 821 if self.isCheckable(row): 822 item = self._model_model.item(row, 1) 823 if item.hasChildren(): 824 c = item.child(0).data() 825 if isinstance(c, Constraint) and c.active: 826 return True 814 item = self._model_model.item(row, 1) 815 if item.hasChildren(): 816 c = item.child(0).data() 817 if isinstance(c, Constraint) and c.active: 818 return True 827 819 return False 828 820 … … 831 823 Finds out if row of the main model has an active, nontrivial constraint child 832 824 """ 833 if self.isCheckable(row): 834 item = self._model_model.item(row, 1) 835 if item.hasChildren(): 836 c = item.child(0).data() 837 if isinstance(c, Constraint) and c.func and c.active: 838 return True 825 item = self._model_model.item(row, 1) 826 if item.hasChildren(): 827 c = item.child(0).data() 828 if isinstance(c, Constraint) and c.func and c.active: 829 return True 839 830 return False 840 831 … … 964 955 model = self.cbModel.currentText() 965 956 966 # empty combobox forced to be read 957 # Assure the control is active 958 if not self.cbModel.isEnabled(): 959 return 960 # Empty combobox forced to be read 967 961 if not model: 968 962 return 969 # Reset structure factor970 self.cbStructureFactor.setCurrentIndex(0)971 963 972 964 # Reset parameters to fit … … 975 967 self.has_poly_error_column = False 976 968 977 self.respondToModelStructure(model=model, structure_factor=None) 969 structure = None 970 if self.cbStructureFactor.isEnabled(): 971 structure = str(self.cbStructureFactor.currentText()) 972 self.respondToModelStructure(model=model, structure_factor=structure) 978 973 979 974 def onSelectBatchFilename(self, data_index): … … 1118 1113 self.disableModelCombo() 1119 1114 self.enableStructureCombo() 1115 # set the index to 0 1116 self.cbStructureFactor.setCurrentIndex(0) 1117 self.model_parameters = None 1120 1118 self._model_model.clear() 1121 1119 return … … 1142 1140 model_row = item.row() 1143 1141 name_index = self._poly_model.index(model_row, 0) 1144 parameter_name = str(name_index.data()) .lower()# "distribution of sld" etc.1145 if " distribution of" in parameter_name:1142 parameter_name = str(name_index.data()) # "distribution of sld" etc. 1143 if "istribution of" in parameter_name: 1146 1144 # just the last word 1147 1145 parameter_name = parameter_name.rsplit()[-1] … … 1509 1507 raise ValueError('Fitting requires at least one parameter to optimize.') 1510 1508 1511 # Potential smearing added1512 # Remember that smearing_min/max can be None ->1513 # deal with it until Python gets discriminated unions1514 self.addWeightingToData(data)1515 1516 1509 # Get the constraints. 1517 1510 constraints = self.getComplexConstraintsForModel() … … 1530 1523 data = GuiUtils.dataFromItem(fit_index) 1531 1524 # Potential weights added directly to data 1532 self.addWeightingToData(data)1525 weighted_data = self.addWeightingToData(data) 1533 1526 try: 1534 fitter_single.set_model(model, fit_id, params_to_fit, data= data,1527 fitter_single.set_model(model, fit_id, params_to_fit, data=weighted_data, 1535 1528 constraints=constraints) 1536 1529 except ValueError as ex: 1537 1530 raise ValueError("Setting model parameters failed with: %s" % ex) 1538 1531 1539 qmin, qmax, _ = self.logic.computeRangeFromData( data)1540 fitter_single.set_data(data= data, id=fit_id, smearer=smearer, qmin=qmin,1532 qmin, qmax, _ = self.logic.computeRangeFromData(weighted_data) 1533 fitter_single.set_data(data=weighted_data, id=fit_id, smearer=smearer, qmin=qmin, 1541 1534 qmax=qmax) 1542 1535 fitter_single.select_problem_for_fit(id=fit_id, value=1) … … 1568 1561 # internal so can use closure for param_dict 1569 1562 param_name = str(self._model_model.item(row, 0).text()) 1570 if not self.isCheckable(row) orparam_name not in list(param_dict.keys()):1563 if param_name not in list(param_dict.keys()): 1571 1564 return 1572 1565 # modify the param value … … 1580 1573 # Utility function for updateof polydispersity part of the main model 1581 1574 param_name = str(self._model_model.item(row, 0).text())+'.width' 1582 if not self.isCheckable(row) orparam_name not in list(param_dict.keys()):1575 if param_name not in list(param_dict.keys()): 1583 1576 return 1584 1577 # modify the param value … … 1929 1922 Adds weighting contribution to fitting data 1930 1923 """ 1924 new_data = copy.deepcopy(data) 1931 1925 # Send original data for weighting 1932 1926 weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 1933 1927 if self.is2D: 1934 data.err_data = weight1928 new_data.err_data = weight 1935 1929 else: 1936 data.dy = weight 1937 pass 1930 new_data.dy = weight 1931 1932 return new_data 1938 1933 1939 1934 def updateQRange(self): … … 1955 1950 # Crete/overwrite model items 1956 1951 self._model_model.clear() 1957 self._poly_model.clear() 1958 self._magnet_model.clear() 1959 1960 if model_name is None: 1961 if structure_factor not in (None, "None"): 1962 # S(Q) on its own, treat the same as a form factor 1963 self.kernel_module = None 1952 1953 # First, add parameters from the main model 1954 if model_name is not None: 1955 self.fromModelToQModel(model_name) 1956 1957 # Then, add structure factor derived parameters 1958 if structure_factor is not None and structure_factor != "None": 1959 if model_name is None: 1960 # Instantiate the current sasmodel for SF-only models 1961 self.kernel_module = self.models[structure_factor]() 1962 self.fromStructureFactorToQModel(structure_factor) 1963 else: 1964 # Allow the SF combobox visibility for the given sasmodel 1965 self.enableStructureFactorControl(structure_factor) 1966 if self.cbStructureFactor.isEnabled(): 1967 structure_factor = self.cbStructureFactor.currentText() 1964 1968 self.fromStructureFactorToQModel(structure_factor) 1965 else: 1966 # No models selected 1967 return 1968 else: 1969 self.fromModelToQModel(model_name) 1969 1970 # Then, add multishells 1971 if model_name is not None: 1972 # Multishell models need additional treatment 1970 1973 self.addExtraShells() 1971 1974 1972 if structure_factor not in (None, "None"): 1973 # add S(Q) 1974 self.fromStructureFactorToQModel(structure_factor) 1975 else: 1976 # enable selection of S(Q) 1977 self.enableStructureFactorControl(structure_factor) 1978 1979 # Add polydispersity to the model 1980 self.setPolyModel() 1981 # Add magnetic parameters to the model 1982 self.setMagneticModel() 1975 # Add polydispersity to the model 1976 self.setPolyModel() 1977 # Add magnetic parameters to the model 1978 self.setMagneticModel() 1983 1979 1984 1980 # Adjust the table cells width … … 2005 2001 """ 2006 2002 name = model_name 2003 kernel_module = None 2007 2004 if self.cbCategory.currentText() == CATEGORY_CUSTOM: 2008 2005 # custom kernel load requires full path … … 2010 2007 try: 2011 2008 kernel_module = generate.load_kernel_module(name) 2012 except ModuleNotFoundError: 2013 # maybe it's a recategorised custom model? 2014 name = os.path.join(ModelUtilities.find_plugins_dir(), model_name+".py") 2015 # If this rises, it's a valid problem. 2016 kernel_module = generate.load_kernel_module(name) 2009 except ModuleNotFoundError as ex: 2010 pass 2011 2012 if kernel_module is None: 2013 # mismatch between "name" attribute and actual filename. 2014 curr_model = self.models[model_name] 2015 name, _ = os.path.splitext(os.path.basename(curr_model.filename)) 2016 try: 2017 kernel_module = generate.load_kernel_module(name) 2018 except ModuleNotFoundError as ex: 2019 logging.error("Can't find the model "+ str(ex)) 2020 return 2017 2021 2018 2022 if hasattr(kernel_module, 'parameters'): … … 2045 2049 self.shell_names = self.shellNamesList() 2046 2050 2047 # Get new rows for QModel 2048 new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D) 2049 2050 # Add heading row 2051 FittingUtilities.addHeadingRowToModel(self._model_model, model_name) 2052 2053 # Update QModel 2054 for row in new_rows: 2055 self._model_model.appendRow(row) 2051 # Update the QModel 2052 FittingUtilities.addParametersToModel( 2053 self.model_parameters, 2054 self.kernel_module, 2055 self.is2D, 2056 self._model_model, 2057 self.lstParams) 2058 2059 # Update the counter used for multishell display 2060 self._last_model_row = self._model_model.rowCount() 2056 2061 2057 2062 def fromStructureFactorToQModel(self, structure_factor): … … 2059 2064 Setting model parameters into QStandardItemModel based on selected _structure factor_ 2060 2065 """ 2061 s_kernel = self.models[structure_factor]() 2062 p_kernel = self.kernel_module 2063 2064 if p_kernel is None: 2065 # Not a product model, just S(Q) 2066 self.kernel_module = s_kernel 2067 params = modelinfo.ParameterTable(self.kernel_module._model_info.parameters.kernel_parameters) 2068 new_rows = FittingUtilities.addSimpleParametersToModel(params, self.is2D) 2069 else: 2070 p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 2071 s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) 2072 2073 self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 2074 all_params = self.kernel_module._model_info.parameters.kernel_parameters 2075 all_param_names = [param.name for param in all_params] 2076 2077 # S(Q) params from the product model are not necessarily the same as those from the S(Q) model; any 2078 # conflicting names with P(Q) params will cause a rename; we also lose radius_effective (for now...) 2079 2080 # TODO: merge rest of beta approx implementation in 2081 # This is to ensure compatibility when we merge beta approx support in...! 2082 2083 # radius_effective is always s_params[0] 2084 2085 # if radius_effective_mode is in all_params, then all_params contains radius_effective and we want to 2086 # keep it in the model 2087 2088 # if radius_effective_mode is NOT in all_params, then radius_effective should NOT be kept, because the user 2089 # cannot specify it themselves; but, make sure we only remove it if it's actually there in the first place 2090 # (sasmodels master removes it already) 2091 if "radius_effective_mode" in all_param_names: 2092 # Show all parameters 2093 s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len]) 2094 s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters) 2095 else: 2096 # Ensure radius_effective is not displayed 2097 s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 2098 if "radius_effective" in all_param_names: 2099 s_params = modelinfo.ParameterTable(all_params[p_pars_len+1:p_pars_len+s_pars_len]) 2100 else: 2101 s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 2102 2103 # Get new rows for QModel 2104 # Any renamed parameters are stored as data in the relevant item, for later handling 2105 new_rows = FittingUtilities.addSimpleParametersToModel(s_params, self.is2D, s_params_orig) 2106 2107 # TODO: merge rest of beta approx implementation in 2108 # These parameters are not part of P(Q) nor S(Q), but are added only to the product model (e.g. specifying 2109 # structure factor calculation mode) 2110 # product_params = all_params[p_pars_len+s_pars_len:] 2111 2112 # Add heading row 2113 FittingUtilities.addHeadingRowToModel(self._model_model, structure_factor) 2114 2115 # Update QModel 2116 for row in new_rows: 2117 self._model_model.appendRow(row) 2118 # disable fitting of parameters not listed in self.kernel_module (probably radius_effective) 2119 # if row[0].text() not in self.kernel_module.params.keys(): 2120 # row_num = self._model_model.rowCount() - 1 2121 # FittingUtilities.markParameterDisabled(self._model_model, row_num) 2066 if structure_factor is None or structure_factor=="None": 2067 return 2068 structure_module = generate.load_kernel_module(structure_factor) 2069 structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 2070 2071 structure_kernel = self.models[structure_factor]() 2072 form_kernel = self.kernel_module 2073 2074 self.kernel_module = MultiplicationModel(form_kernel, structure_kernel) 2075 2076 # Update the QModel 2077 FittingUtilities.addSimpleParametersToModel( 2078 structure_parameters, 2079 self.is2D, 2080 self._model_model, 2081 self.lstParams) 2082 2083 # Any parameters removed from the structure factor when producing the product model, e.g. radius_effective, must 2084 # be disabled (greyed out, etc.) 2085 for r in range(self._last_model_row, self._model_model.rowCount()): 2086 param_name = self._model_model.item(r, 0).text() 2087 if param_name not in self.kernel_module.params.keys(): 2088 FittingUtilities.markParameterDisabled(self._model_model, r) 2089 2090 # Update the counter used for multishell display 2091 self._last_model_row = self._model_model.rowCount() 2122 2092 2123 2093 def haveParamsToFit(self): … … 2145 2115 model_row = item.row() 2146 2116 name_index = self._model_model.index(model_row, 0) 2147 name_item = self._model_model.itemFromIndex(name_index)2148 2117 2149 2118 # Extract changed value. … … 2154 2123 return 2155 2124 2156 # if the item has user data, this is the actual parameter name (e.g. to handle duplicate names) 2157 if name_item.data(QtCore.Qt.UserRole): 2158 parameter_name = str(name_item.data(QtCore.Qt.UserRole)) 2159 else: 2160 parameter_name = str(self._model_model.data(name_index)) 2125 parameter_name = str(self._model_model.data(name_index)) # sld, background etc. 2161 2126 2162 2127 # Update the parameter value - note: this supports +/-inf as well … … 2257 2222 name = self.nameFromData(fitted_data) 2258 2223 # Notify the GUI manager so it can create the theory model in DataExplorer 2259 new_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name)2260 self.communicate.updateTheoryFromPerspectiveSignal.emit( new_item)2224 self.theory_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name) 2225 self.communicate.updateTheoryFromPerspectiveSignal.emit(self.theory_item) 2261 2226 2262 2227 def nameFromData(self, fitted_data): … … 2292 2257 completefn = self.methodCompleteForData() 2293 2258 smearer = self.smearing_widget.smearer() 2259 weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 2260 2294 2261 # Awful API to a backend method. 2295 2262 calc_thread = self.methodCalculateForData()(data=data, … … 2300 2267 smearer=smearer, 2301 2268 state=None, 2302 weight= None,2269 weight=weight, 2303 2270 fid=None, 2304 2271 toggle_mode_on=False, … … 2348 2315 residuals = self.calculateResiduals(fitted_data) 2349 2316 self.model_data = fitted_data 2350 2351 new_plots = [fitted_data, residuals] 2317 new_plots = [fitted_data] 2318 if residuals is not None: 2319 new_plots.append(residuals) 2320 2321 if self.data_is_loaded: 2322 GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 2323 else: 2324 # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 2325 self.communicate.deleteIntermediateTheoryPlotsSignal.emit(self.kernel_module.id) 2352 2326 2353 2327 # Create plots for intermediate product data … … 2364 2338 new_plots.append(sq_data) 2365 2339 2366 if self.data_is_loaded: 2367 GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 2368 2369 # TODO: merge rest of beta approx implementation in 2370 # TODO: refactor 2371 # deal with constrained radius_effective 2372 # for row in range(self._model_model.rowCount()): 2373 # if self._model_model.item(row, 0).text() == "radius_effective_mode": 2374 # if GuiUtils.toDouble(self._model_model.item(row, 1).text()) == 0: 2375 # return 2376 # radius_effective = intermediate_ER() 2377 # if radius_effective: 2378 # for row in range(self._model_model.rowCount()): 2379 # if self._model_model.item(row, 0).text() == "radius_effective": 2380 # self._model_model.item(row, 1).setText(str(radius_effective)) 2381 # break 2382 2340 # Update/generate plots 2383 2341 for plot in new_plots: 2384 if hasattr(plot, "id") and "esidual" in plot.id: 2385 # TODO: fix updates to residuals plot 2386 pass 2387 elif plot is not None: 2388 self.communicate.plotUpdateSignal.emit([plot]) 2342 self.communicate.plotUpdateSignal.emit([plot]) 2389 2343 2390 2344 def complete2D(self, return_data): … … 2404 2358 2405 2359 # Modify fitted_data with weighting 2406 self.addWeightingToData(fitted_data)2407 2408 self.createNewIndex( fitted_data)2360 weighted_data = self.addWeightingToData(fitted_data) 2361 2362 self.createNewIndex(weighted_data) 2409 2363 # Calculate difference between return_data and logic.data 2410 self.chi2 = FittingUtilities.calculateChi2( fitted_data, self.logic.data)2364 self.chi2 = FittingUtilities.calculateChi2(weighted_data, self.logic.data) 2411 2365 # Update the control 2412 2366 chi2_repr = "---" if self.chi2 is None else GuiUtils.formatNumber(self.chi2, high=True) 2413 2367 self.lblChi2Value.setText(chi2_repr) 2414 2368 2415 # self.communicate.plotUpdateSignal.emit([fitted_data])2416 2417 2369 # Plot residuals if actual data 2418 2370 if not self.data_is_loaded: 2419 2371 return 2420 2372 2421 residuals_plot = FittingUtilities.plotResiduals(self.data, fitted_data)2373 residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 2422 2374 residuals_plot.id = "Residual " + residuals_plot.id 2423 2375 self.createNewIndex(residuals_plot) … … 2488 2440 self._poly_model.clear() 2489 2441 2442 parameters = self.model_parameters.form_volume_parameters 2443 if self.is2D: 2444 parameters += self.model_parameters.orientation_parameters 2445 2490 2446 [self.setPolyModelParameters(i, param) for i, param in \ 2491 enumerate(self.model_parameters.form_volume_parameters) if param.polydisperse] 2447 enumerate(parameters) if param.polydisperse] 2448 2492 2449 FittingUtilities.addPolyHeadersToModel(self._poly_model) 2493 2450 … … 2569 2526 def updateFunctionCaption(row): 2570 2527 # Utility function for update of polydispersity function name in the main model 2571 if not self.isCheckable(row):2572 return2573 2528 param_name = str(self._model_model.item(row, 0).text()) 2574 2529 if param_name != param.name: … … 2737 2692 2738 2693 self.lstParams.setIndexWidget(shell_index, func) 2739 self._ n_shells_row = shell_row - 12694 self._last_model_row = self._model_model.rowCount() 2740 2695 2741 2696 # Set the index to the state-kept value … … 2748 2703 """ 2749 2704 # Find row location of the combobox 2750 first_row = self._n_shells_row + 12751 remove_rows = self._ num_shell_params2705 last_row = self._last_model_row 2706 remove_rows = self._model_model.rowCount() - last_row 2752 2707 2753 2708 if remove_rows > 1: 2754 self._model_model.removeRows(first_row, remove_rows) 2755 2756 new_rows = FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index, first_row) 2757 self._num_shell_params = len(new_rows) 2709 self._model_model.removeRows(last_row, remove_rows) 2710 2711 FittingUtilities.addShellsToModel( 2712 self.model_parameters, 2713 self._model_model, 2714 index, 2715 self.lstParams) 2758 2716 2759 2717 self.current_shell_displayed = index … … 2876 2834 # TODO: add polidyspersity and magnetism 2877 2835 2878 2879 2836 def updateUndo(self): 2880 2837 """ … … 2913 2870 if self.all_data: 2914 2871 index = self.all_data[self.data_index] 2872 else: 2873 index = self.theory_item 2915 2874 report_logic = ReportPageLogic(self, 2916 2875 kernel_module=self.kernel_module, … … 3036 2995 # first - regular params 3037 2996 param_list = [] 2997 2998 param_list.append(['model_name', str(self.cbModel.currentText())]) 3038 2999 def gatherParams(row): 3039 3000 """ … … 3122 3083 if lines[0] != 'sasview_parameter_values': 3123 3084 return False 3124 for line in lines[1:-1]: 3085 3086 model = lines[1].split(',') 3087 3088 if model[0] != 'model_name': 3089 return False 3090 3091 context['model_name'] = [model[1]] 3092 for line in lines[2:-1]: 3125 3093 if len(line) != 0: 3126 3094 item = line.split(',') … … 3148 3116 except IndexError: 3149 3117 pass 3118 3119 if str(self.cbModel.currentText()) != str(context['model_name'][0]): 3120 msg = QtWidgets.QMessageBox() 3121 msg.setIcon(QtWidgets.QMessageBox.Information) 3122 msg.setText("The model in the clipboard is not the same as the currently loaded model. \ 3123 Not all parameters saved may paste correctly.") 3124 msg.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) 3125 result = msg.exec_() 3126 if result == QtWidgets.QMessageBox.Ok: 3127 pass 3128 else: 3129 return 3150 3130 3151 3131 self.updateFullModel(context) … … 3186 3166 param_repr = GuiUtils.formatNumber(param_dict[param_name][3+ioffset], high=True) 3187 3167 self._model_model.item(row, 3+ioffset).setText(param_repr) 3168 self.setFocus() 3169 3188 3170 3189 3171 # block signals temporarily, so we don't end up … … 3192 3174 self.iterateOverModel(updateFittedValues) 3193 3175 self._model_model.blockSignals(False) 3176 3194 3177 3195 3178 def updateFullPolyModel(self, param_dict): … … 3236 3219 param_repr = GuiUtils.formatNumber(param_dict[param_name][5+ioffset], high=True) 3237 3220 self._poly_model.item(row, 5+ioffset).setText(param_repr) 3221 self.setFocus() 3238 3222 3239 3223 # block signals temporarily, so we don't end up … … 3243 3227 self._poly_model.blockSignals(False) 3244 3228 3245
Note: See TracChangeset
for help on using the changeset viewer.