Changeset 70f4458 in sasview for src


Ignore:
Timestamp:
Sep 7, 2018 5:57:38 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
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:
3fbd77b
Parents:
f3a19ad
Message:

shell parameters appear in P(Q) section correctly

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
2 edited

Legend:

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

    rc7809a9 r70f4458  
    259259    model.header_tooltips = copy.copy(poly_header_error_tooltips) 
    260260 
    261 def addShellsToModel(parameters, model, index): 
    262     """ 
    263     Find out multishell parameters and update the model with the requested number of them 
     261def addShellsToModel(parameters, model, index, row_num=None): 
     262    """ 
     263    Find out multishell parameters and update the model with the requested number of them. 
     264    Inserts them after the row at row_num, if not None; otherwise, appends to end. 
     265    Returns a list of lists of QStandardItem objects. 
    264266    """ 
    265267    multishell_parameters = getIterParams(parameters) 
    266268 
     269    rows = [] 
    267270    for i in range(index): 
    268271        for par in multishell_parameters: 
     
    291294            item4 = QtGui.QStandardItem(str(par.limits[1])) 
    292295            item5 = QtGui.QStandardItem(par.units) 
    293             model.appendRow([item1, item2, item3, item4, item5]) 
     296            row = [item1, item2, item3, item4, item5] 
     297            rows.append(row) 
     298 
     299            if row_num is None: 
     300                model.appendRow(row) 
     301            else: 
     302                model.insertRow(row_num, row) 
     303                row_num += 1 
     304 
     305    return rows 
    294306 
    295307def calculateChi2(reference_data, current_data): 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rf3a19ad r70f4458  
    221221        # Utility variable to enable unselectable option in category combobox 
    222222        self._previous_category_index = 0 
    223         # Utility variable for multishell display 
    224         self._last_model_row = 0 
     223        # Utility variables for multishell display 
     224        self._n_shells_row = 0 
     225        self._num_shell_params = 0 
    225226        # Dictionary of {model name: model class} for the current category 
    226227        self.models = {} 
     
    19681969        else: 
    19691970            self.fromModelToQModel(model_name) 
     1971            self.addExtraShells() 
     1972 
    19701973            if structure_factor not in (None, "None"): 
    19711974                # add S(Q) 
     
    19741977                # enable selection of S(Q) 
    19751978                self.enableStructureFactorControl(structure_factor) 
     1979 
    19761980            # Add polydispersity to the model 
    19771981            self.setPolyModel() 
    19781982            # Add magnetic parameters to the model 
    19791983            self.setMagneticModel() 
    1980  
    1981         # Then, add multishells 
    1982         if model_name is not None: 
    1983             # Multishell models need additional treatment 
    1984             self.addExtraShells() 
    19851984 
    19861985        # Adjust the table cells width 
     
    20562055        for row in new_rows: 
    20572056            self._model_model.appendRow(row) 
    2058         # Update the counter used for multishell display 
    2059         self._last_model_row = self._model_model.rowCount() 
    20602057 
    20612058    def fromStructureFactorToQModel(self, structure_factor): 
     
    21242121            #     row_num = self._model_model.rowCount() - 1 
    21252122            #     FittingUtilities.markParameterDisabled(self._model_model, row_num) 
    2126  
    2127         # Update the counter used for multishell display 
    2128         self._last_model_row = self._model_model.rowCount() 
    21292123 
    21302124    def haveParamsToFit(self): 
     
    27442738 
    27452739        self.lstParams.setIndexWidget(shell_index, func) 
    2746         self._last_model_row = self._model_model.rowCount() 
     2740        self._n_shells_row = shell_row - 1 
    27472741 
    27482742        # Set the index to the state-kept value 
     
    27552749        """ 
    27562750        # Find row location of the combobox 
    2757         last_row = self._last_model_row 
    2758         remove_rows = self._model_model.rowCount() - last_row 
     2751        first_row = self._n_shells_row + 1 
     2752        remove_rows = self._num_shell_params 
    27592753 
    27602754        if remove_rows > 1: 
    2761             self._model_model.removeRows(last_row, remove_rows) 
    2762  
    2763         FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index) 
     2755            self._model_model.removeRows(first_row, remove_rows) 
     2756 
     2757        new_rows = FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index, first_row) 
     2758        self._num_shell_params = len(new_rows) 
     2759 
    27642760        self.current_shell_displayed = index 
    27652761 
Note: See TracChangeset for help on using the changeset viewer.