Ignore:
Timestamp:
Sep 7, 2018 10:25:19 AM (6 years ago)
Author:
Laura Forster <Awork@…>
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:
2f14b5d, 0101c9f
Parents:
339e22b (diff), f0365a2e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' of https://github.com/SasView/sasview into ESS_GUI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r339e22b r12db2db6  
    9090    fittingFinishedSignal = QtCore.pyqtSignal(tuple) 
    9191    batchFittingFinishedSignal = QtCore.pyqtSignal(tuple) 
    92     Calc1DFinishedSignal = QtCore.pyqtSignal(tuple) 
    93     Calc2DFinishedSignal = QtCore.pyqtSignal(tuple) 
     92    Calc1DFinishedSignal = QtCore.pyqtSignal(dict) 
     93    Calc2DFinishedSignal = QtCore.pyqtSignal(dict) 
    9494 
    9595    def __init__(self, parent=None, data=None, tab_id=1): 
     
    219219        # Utility variable to enable unselectable option in category combobox 
    220220        self._previous_category_index = 0 
    221         # Utility variable for multishell display 
    222         self._last_model_row = 0 
     221        # Utility variables for multishell display 
     222        self._n_shells_row = 0 
     223        self._num_shell_params = 0 
    223224        # Dictionary of {model name: model class} for the current category 
    224225        self.models = {} 
     
    247248        # copy of current kernel model 
    248249        self.kernel_module_copy = None 
     250 
     251        # dictionaries of current params 
     252        self.poly_params = {} 
     253        self.magnet_params = {} 
    249254 
    250255        # Page id for fitting 
     
    672677        Return list of all parameters for the current model 
    673678        """ 
    674         return [self._model_model.item(row).text() for row in range(self._model_model.rowCount())] 
     679        return [self._model_model.item(row).text() 
     680                for row in range(self._model_model.rowCount()) 
     681                if self.isCheckable(row)] 
    675682 
    676683    def modifyViewOnRow(self, row, font=None, brush=None): 
     
    700707        assert isinstance(constraint, Constraint) 
    701708        assert 0 <= row <= self._model_model.rowCount() 
     709        assert self.isCheckable(row) 
    702710 
    703711        item = QtGui.QStandardItem() 
     
    720728        max_col = self.lstParams.itemDelegate().param_max 
    721729        for row in self.selectedParameters(): 
     730            assert(self.isCheckable(row)) 
    722731            param = self._model_model.item(row, 0).text() 
    723732            value = self._model_model.item(row, 1).text() 
     
    762771        max_col = self.lstParams.itemDelegate().param_max 
    763772        for row in range(self._model_model.rowCount()): 
     773            if not self.isCheckable(row): 
     774                continue 
    764775            if not self.rowHasConstraint(row): 
    765776                continue 
     
    790801        For the given row, return its constraint, if any 
    791802        """ 
    792         try: 
     803        if self.isCheckable(row): 
    793804            item = self._model_model.item(row, 1) 
    794             return item.child(0).data() 
    795         except AttributeError: 
    796             # return none when no constraints 
    797             return None 
     805            try: 
     806                return item.child(0).data() 
     807            except AttributeError: 
     808                # return none when no constraints 
     809                pass 
     810        return None 
    798811 
    799812    def rowHasConstraint(self, row): 
     
    801814        Finds out if row of the main model has a constraint child 
    802815        """ 
    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 
     816        if self.isCheckable(row): 
     817            item = self._model_model.item(row, 1) 
     818            if item.hasChildren(): 
     819                c = item.child(0).data() 
     820                if isinstance(c, Constraint): 
     821                    return True 
    808822        return False 
    809823 
     
    812826        Finds out if row of the main model has an active constraint child 
    813827        """ 
    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 
     828        if self.isCheckable(row): 
     829            item = self._model_model.item(row, 1) 
     830            if item.hasChildren(): 
     831                c = item.child(0).data() 
     832                if isinstance(c, Constraint) and c.active: 
     833                    return True 
    819834        return False 
    820835 
     
    823838        Finds out if row of the main model has an active, nontrivial constraint child 
    824839        """ 
    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 
     840        if self.isCheckable(row): 
     841            item = self._model_model.item(row, 1) 
     842            if item.hasChildren(): 
     843                c = item.child(0).data() 
     844                if isinstance(c, Constraint) and c.func and c.active: 
     845                    return True 
    830846        return False 
    831847 
     
    11861202            # Update the sasmodel 
    11871203            # PD[ratio] -> width, npts -> npts, nsigs -> nsigmas 
    1188             self.kernel_module.setParam(parameter_name + '.' + delegate.columnDict()[model_column], value) 
     1204            #self.kernel_module.setParam(parameter_name + '.' + delegate.columnDict()[model_column], value) 
     1205            key = parameter_name + '.' + delegate.columnDict()[model_column] 
     1206            self.poly_params[key] = value 
    11891207 
    11901208            # Update plot 
     
    11951213            row = self.getRowFromName(parameter_name) 
    11961214            param_item = self._model_model.item(row) 
     1215            self._model_model.blockSignals(True) 
    11971216            param_item.child(0).child(0, model_column).setText(item.text()) 
     1217            self._model_model.blockSignals(False) 
    11981218 
    11991219    def onMagnetModelChange(self, item): 
     
    12241244            # Unparsable field 
    12251245            return 
    1226  
    1227         property_index = self._magnet_model.headerData(1, model_column)-1 # Value, min, max, etc. 
    1228  
    1229         # Update the parameter value - note: this supports +/-inf as well 
    1230         self.kernel_module.params[parameter_name] = value 
    1231  
    1232         # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 
    1233         self.kernel_module.details[parameter_name][property_index] = value 
    1234  
    1235         # Force the chart update when actual parameters changed 
    1236         if model_column == 1: 
     1246        delegate = self.lstMagnetic.itemDelegate() 
     1247 
     1248        if model_column > 1: 
     1249            if model_column == delegate.mag_min: 
     1250                pos = 1 
     1251            elif model_column == delegate.mag_max: 
     1252                pos = 2 
     1253            elif model_column == delegate.mag_unit: 
     1254                pos = 0 
     1255            else: 
     1256                raise AttributeError("Wrong column in magnetism table.") 
     1257            # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 
     1258            self.kernel_module.details[parameter_name][pos] = value 
     1259        else: 
     1260            self.magnet_params[parameter_name] = value 
     1261            #self.kernel_module.setParam(parameter_name) = value 
     1262            # Force the chart update when actual parameters changed 
    12371263            self.recalculatePlotData() 
    12381264 
     
    14811507        # update charts 
    14821508        self.onPlot() 
     1509        #self.recalculatePlotData() 
     1510 
    14831511 
    14841512        # Read only value - we can get away by just printing it here 
     
    14951523        # Data going in 
    14961524        data = self.logic.data 
    1497         model = self.kernel_module 
     1525        model = copy.deepcopy(self.kernel_module) 
    14981526        qmin = self.q_range_min 
    14991527        qmax = self.q_range_max 
     1528        # add polydisperse/magnet parameters if asked 
     1529        self.updateKernelModelWithExtraParams(model) 
    15001530 
    15011531        params_to_fit = self.main_params_to_fit 
     
    15611591            # internal so can use closure for param_dict 
    15621592            param_name = str(self._model_model.item(row, 0).text()) 
    1563             if param_name not in list(param_dict.keys()): 
     1593            if not self.isCheckable(row) or param_name not in list(param_dict.keys()): 
    15641594                return 
    15651595            # modify the param value 
    15661596            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    15671597            self._model_model.item(row, 1).setText(param_repr) 
     1598            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    15681599            if self.has_error_column: 
    15691600                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
     
    15731604            # Utility function for updateof polydispersity part of the main model 
    15741605            param_name = str(self._model_model.item(row, 0).text())+'.width' 
    1575             if param_name not in list(param_dict.keys()): 
     1606            if not self.isCheckable(row) or param_name not in list(param_dict.keys()): 
    15761607                return 
    15771608            # modify the param value 
     
    16071638            poly_item.insertColumn(2, [QtGui.QStandardItem("")]) 
    16081639 
    1609         # block signals temporarily, so we don't end up 
    1610         # updating charts with every single model change on the end of fitting 
    1611         self._model_model.blockSignals(True) 
    1612  
    16131640        if not self.has_error_column: 
    16141641            # create top-level error column 
     
    16171644            self.iterateOverModel(createErrorColumn) 
    16181645 
    1619             # we need to enable signals for this, otherwise the final column mysteriously disappears (don't ask, I don't 
    1620             # know) 
    1621             self._model_model.blockSignals(False) 
    16221646            self._model_model.insertColumn(2, error_column) 
    1623             self._model_model.blockSignals(True) 
    16241647 
    16251648            FittingUtilities.addErrorHeadersToModel(self._model_model) 
     
    16301653            self.has_error_column = True 
    16311654 
     1655        # block signals temporarily, so we don't end up 
     1656        # updating charts with every single model change on the end of fitting 
     1657        self._model_model.itemChanged.disconnect() 
    16321658        self.iterateOverModel(updateFittedValues) 
    16331659        self.iterateOverModel(updatePolyValues) 
    1634  
    1635         self._model_model.blockSignals(False) 
     1660        self._model_model.itemChanged.connect(self.onMainParamsChange) 
    16361661 
    16371662        # Adjust the table cells width. 
     
    16681693            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    16691694            self._poly_model.item(row_i, 1).setText(param_repr) 
     1695            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    16701696            if self.has_poly_error_column: 
    16711697                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
    16721698                self._poly_model.item(row_i, 2).setText(error_repr) 
    1673  
    16741699 
    16751700        def createErrorColumn(row_i): 
     
    16921717        # block signals temporarily, so we don't end up 
    16931718        # updating charts with every single model change on the end of fitting 
    1694         self._poly_model.blockSignals(True) 
     1719        self._poly_model.itemChanged.disconnect() 
    16951720        self.iterateOverPolyModel(updateFittedValues) 
    1696         self._poly_model.blockSignals(False) 
     1721        self._poly_model.itemChanged.connect(self.onPolyModelChange) 
    16971722 
    16981723        if self.has_poly_error_column: 
     
    17041729 
    17051730        # switch off reponse to model change 
    1706         self._poly_model.blockSignals(True) 
    17071731        self._poly_model.insertColumn(2, error_column) 
    1708         self._poly_model.blockSignals(False) 
    17091732        FittingUtilities.addErrorPolyHeadersToModel(self._poly_model) 
    17101733 
     
    17391762            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    17401763            self._magnet_model.item(row, 1).setText(param_repr) 
     1764            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    17411765            if self.has_magnet_error_column: 
    17421766                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
     
    17581782        # block signals temporarily, so we don't end up 
    17591783        # updating charts with every single model change on the end of fitting 
    1760         self._magnet_model.blockSignals(True) 
     1784        self._magnet_model.itemChanged.disconnect() 
    17611785        self.iterateOverMagnetModel(updateFittedValues) 
    1762         self._magnet_model.blockSignals(False) 
     1786        self._magnet_model.itemChanged.connect(self.onMagnetModelChange) 
    17631787 
    17641788        if self.has_magnet_error_column: 
     
    17701794 
    17711795        # switch off reponse to model change 
    1772         self._magnet_model.blockSignals(True) 
    17731796        self._magnet_model.insertColumn(2, error_column) 
    1774         self._magnet_model.blockSignals(False) 
    17751797        FittingUtilities.addErrorHeadersToModel(self._magnet_model) 
    17761798 
     
    17841806        self.cmdPlot.setText("Show Plot") 
    17851807        # Force data recalculation so existing charts are updated 
     1808        self.showPlot() 
    17861809        self.recalculatePlotData() 
    1787         self.showPlot() 
    17881810 
    17891811    def onSmearingOptionsUpdate(self): 
     
    19501972        # Crete/overwrite model items 
    19511973        self._model_model.clear() 
    1952  
    1953         # First, add parameters from the main model 
    1954         if model_name is not None: 
     1974        self._poly_model.clear() 
     1975        self._magnet_model.clear() 
     1976 
     1977        if model_name is None: 
     1978            if structure_factor not in (None, "None"): 
     1979                # S(Q) on its own, treat the same as a form factor 
     1980                self.kernel_module = None 
     1981                self.fromStructureFactorToQModel(structure_factor) 
     1982            else: 
     1983                # No models selected 
     1984                return 
     1985        else: 
    19551986            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: 
     1987            self.addExtraShells() 
     1988 
    19641989            # Allow the SF combobox visibility for the given sasmodel 
    19651990            self.enableStructureFactorControl(structure_factor) 
     1991         
     1992            # Add S(Q) 
    19661993            if self.cbStructureFactor.isEnabled(): 
    19671994                structure_factor = self.cbStructureFactor.currentText() 
    19681995                self.fromStructureFactorToQModel(structure_factor) 
    19691996 
    1970         # Then, add multishells 
    1971         if model_name is not None: 
    1972             # Multishell models need additional treatment 
    1973             self.addExtraShells() 
    1974  
    1975         # Add polydispersity to the model 
    1976         self.setPolyModel() 
    1977         # Add magnetic parameters to the model 
    1978         self.setMagneticModel() 
     1997            # Add polydispersity to the model 
     1998            self.poly_params = {} 
     1999            self.setPolyModel() 
     2000            # Add magnetic parameters to the model 
     2001            self.magnet_params = {} 
     2002            self.setMagneticModel() 
    19792003 
    19802004        # Adjust the table cells width 
     
    20492073        self.shell_names = self.shellNamesList() 
    20502074 
     2075        # Add heading row 
     2076        FittingUtilities.addHeadingRowToModel(self._model_model, model_name) 
     2077 
    20512078        # Update the QModel 
    2052         new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D) 
    2053  
    2054         for row in new_rows: 
    2055             self._model_model.appendRow(row) 
    2056         # Update the counter used for multishell display 
    2057         self._last_model_row = self._model_model.rowCount() 
     2079        FittingUtilities.addParametersToModel( 
     2080                self.model_parameters, 
     2081                self.kernel_module, 
     2082                self.is2D, 
     2083                self._model_model, 
     2084                self.lstParams) 
    20582085 
    20592086    def fromStructureFactorToQModel(self, structure_factor): 
     
    20632090        if structure_factor is None or structure_factor=="None": 
    20642091            return 
    2065         structure_module = generate.load_kernel_module(structure_factor) 
    2066         structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 
    2067  
    2068         structure_kernel = self.models[structure_factor]() 
    2069         form_kernel = self.kernel_module 
    2070  
    2071         self.kernel_module = MultiplicationModel(form_kernel, structure_kernel) 
    2072  
    2073         new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) 
    2074         for row in new_rows: 
    2075             self._model_model.appendRow(row) 
    2076             # disable fitting of parameters not listed in self.kernel_module (probably radius_effective) 
    2077             if row[0].text() not in self.kernel_module.params.keys(): 
    2078                 row_num = self._model_model.rowCount() - 1 
    2079                 FittingUtilities.markParameterDisabled(self._model_model, row_num) 
    2080  
    2081         # Update the counter used for multishell display 
    2082         self._last_model_row = self._model_model.rowCount() 
     2092 
     2093        if self.kernel_module is None: 
     2094            # Structure factor is the only selected model; build it and show all its params 
     2095            self.kernel_module = self.models[structure_factor]() 
     2096            s_params = self.kernel_module._model_info.parameters 
     2097            s_params_orig = s_params 
     2098 
     2099        else: 
     2100            s_kernel = self.models[structure_factor]() 
     2101            p_kernel = self.kernel_module 
     2102 
     2103            p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 
     2104            s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) 
     2105 
     2106            self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 
     2107            all_params = self.kernel_module._model_info.parameters.kernel_parameters 
     2108            all_param_names = [param.name for param in all_params] 
     2109 
     2110            # S(Q) params from the product model are not necessarily the same as those from the S(Q) model; any 
     2111            # conflicting names with P(Q) params will cause a rename 
     2112 
     2113            if "radius_effective_mode" in all_param_names: 
     2114                # Show all parameters 
     2115                s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len]) 
     2116                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters) 
     2117            else: 
     2118                # Ensure radius_effective is not displayed 
     2119                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 
     2120                if "radius_effective" in all_param_names: 
     2121                    s_params = modelinfo.ParameterTable(all_params[p_pars_len+1:p_pars_len+s_pars_len]) 
     2122                else: 
     2123                    s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 
     2124 
     2125        # Add heading row 
     2126        FittingUtilities.addHeadingRowToModel(self._model_model, structure_factor) 
     2127 
     2128        # Get new rows for QModel 
     2129        # Any renamed parameters are stored as data in the relevant item, for later handling 
     2130        FittingUtilities.addSimpleParametersToModel( 
     2131                s_params, 
     2132                self.is2D, 
     2133                s_params_orig, 
     2134                self._model_model, 
     2135                self.lstParams) 
    20832136 
    20842137    def haveParamsToFit(self): 
     
    21062159        model_row = item.row() 
    21072160        name_index = self._model_model.index(model_row, 0) 
     2161        name_item = self._model_model.itemFromIndex(name_index) 
    21082162 
    21092163        # Extract changed value. 
     
    21142168            return 
    21152169 
    2116         parameter_name = str(self._model_model.data(name_index)) # sld, background etc. 
     2170        # if the item has user data, this is the actual parameter name (e.g. to handle duplicate names) 
     2171        if name_item.data(QtCore.Qt.UserRole): 
     2172            parameter_name = str(name_item.data(QtCore.Qt.UserRole)) 
     2173        else: 
     2174            parameter_name = str(self._model_model.data(name_index)) 
    21172175 
    21182176        # Update the parameter value - note: this supports +/-inf as well 
     
    22372295        return self.completed1D if isinstance(self.data, Data1D) else self.completed2D 
    22382296 
     2297    def updateKernelModelWithExtraParams(self, model=None): 
     2298        """ 
     2299        Updates kernel model 'model' with extra parameters from 
     2300        the polydisp and magnetism tab, if the tabs are enabled 
     2301        """ 
     2302        if model is None: return 
     2303        if not hasattr(model, 'setParam'): return 
     2304 
     2305        # add polydisperse parameters if asked 
     2306        if self.chkPolydispersity.isChecked(): 
     2307            for key, value in self.poly_params.items(): 
     2308                model.setParam(key, value) 
     2309        # add magnetic params if asked 
     2310        if self.chkMagnetism.isChecked(): 
     2311            for key, value in self.magnet_params.items(): 
     2312                model.setParam(key, value) 
     2313 
    22392314    def calculateQGridForModelExt(self, data=None, model=None, completefn=None, use_threads=True): 
    22402315        """ 
     
    22442319            data = self.data 
    22452320        if model is None: 
    2246             model = self.kernel_module 
     2321            model = copy.deepcopy(self.kernel_module) 
     2322            self.updateKernelModelWithExtraParams(model) 
     2323 
    22472324        if completefn is None: 
    22482325            completefn = self.methodCompleteForData() 
     
    23292406            new_plots.append(sq_data) 
    23302407 
     2408        for plot in new_plots: 
     2409            self.communicate.plotUpdateSignal.emit([plot]) 
     2410 
     2411    def complete2D(self, return_data): 
     2412        """ 
     2413        Plot the current 2D data 
     2414        """ 
     2415        fitted_data = self.logic.new2DPlot(return_data) 
     2416        residuals = self.calculateResiduals(fitted_data) 
     2417        self.model_data = fitted_data 
     2418        new_plots = [fitted_data] 
     2419        if residuals is not None: 
     2420            new_plots.append(residuals) 
     2421 
    23312422        # Update/generate plots 
    23322423        for plot in new_plots: 
    23332424            self.communicate.plotUpdateSignal.emit([plot]) 
    2334  
    2335     def complete2D(self, return_data): 
    2336         """ 
    2337         Plot the current 2D data 
    2338         """ 
    2339         fitted_data = self.logic.new2DPlot(return_data) 
    2340         self.calculateResiduals(fitted_data) 
    2341         self.model_data = fitted_data 
    23422425 
    23432426    def calculateResiduals(self, fitted_data): 
     
    24702553        _, min, max = self.kernel_module.details[param_name] 
    24712554 
     2555        # Update local param dict 
     2556        self.poly_params[param_name + '.width'] = width 
     2557        self.poly_params[param_name + '.npts'] = npts 
     2558        self.poly_params[param_name + '.nsigmas'] = nsigs 
     2559 
    24722560        # Construct a row with polydisp. related variable. 
    24732561        # This will get added to the polydisp. model 
     
    25172605        def updateFunctionCaption(row): 
    25182606            # Utility function for update of polydispersity function name in the main model 
     2607            if not self.isCheckable(row): 
     2608                return 
     2609            self._model_model.blockSignals(True) 
    25192610            param_name = str(self._model_model.item(row, 0).text()) 
     2611            self._model_model.blockSignals(False) 
    25202612            if param_name !=  param.name: 
    25212613                return 
    25222614            # Modify the param value 
     2615            self._model_model.blockSignals(True) 
    25232616            if self.has_error_column: 
    25242617                # err column changes the indexing 
     
    25262619            else: 
    25272620                self._model_model.item(row, 0).child(0).child(0,4).setText(combo_string) 
     2621            self._model_model.blockSignals(False) 
    25282622 
    25292623        if combo_string == 'array': 
     
    26442738                        param.units] 
    26452739 
     2740        self.magnet_params[param.name] = param.default 
     2741 
    26462742        FittingUtilities.addCheckedListToModel(model, checked_list) 
    26472743 
     
    26832779 
    26842780        self.lstParams.setIndexWidget(shell_index, func) 
    2685         self._last_model_row = self._model_model.rowCount() 
     2781        self._n_shells_row = shell_row - 1 
    26862782 
    26872783        # Set the index to the state-kept value 
     
    26942790        """ 
    26952791        # Find row location of the combobox 
    2696         last_row = self._last_model_row 
    2697         remove_rows = self._model_model.rowCount() - last_row 
     2792        first_row = self._n_shells_row + 1 
     2793        remove_rows = self._num_shell_params 
    26982794 
    26992795        if remove_rows > 1: 
    2700             self._model_model.removeRows(last_row, remove_rows) 
    2701  
    2702         FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index) 
     2796            self._model_model.removeRows(first_row, remove_rows) 
     2797 
     2798        new_rows = FittingUtilities.addShellsToModel( 
     2799                self.model_parameters, 
     2800                self._model_model, 
     2801                index, 
     2802                first_row, 
     2803                self.lstParams) 
     2804 
     2805        self._num_shell_params = len(new_rows) 
    27032806        self.current_shell_displayed = index 
    27042807 
Note: See TracChangeset for help on using the changeset viewer.