Changeset 0d13814 in sasview for src/sas/qtgui/Perspectives/Fitting


Ignore:
Timestamp:
Jul 27, 2017 4:05:50 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
7adc2a8
Parents:
b00414d
Message:

SASVIEW-627 Fixed multishell parameters in all models/views

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

Legend:

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

    rb00414d r0d13814  
    167167        # Which shell is being currently displayed? 
    168168        self.current_shell_displayed = 0 
     169        # List of all shell-unique parameters 
     170        self.shell_names = [] 
    169171 
    170172        # Error column presence in parameter display 
     
    11371139        self.undo_supported = temp_undo_state 
    11381140 
     1141        self.shell_names = self.shellNamesList() 
     1142 
    11391143        # Update the QModel 
    11401144        new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D) 
     
    14191423        self._poly_model.clear() 
    14201424 
    1421         [self.setPolyModelParameters(row, param) for row, param in \ 
     1425        [self.setPolyModelParameters(param) for _, param in \ 
    14221426            enumerate(self.model_parameters.form_volume_parameters) if param.polydisperse] 
    14231427        FittingUtilities.addPolyHeadersToModel(self._poly_model) 
    14241428 
    1425     def setPolyModelParameters(self, row, param): 
    1426         """ 
    1427         Creates a checked row for a polydisperse parameter 
    1428         """ 
    1429         # Not suitable for multishell 
     1429    def setPolyModelParameters(self, param): 
     1430        """ 
     1431        Standard of multishell poly parameter driver 
     1432        """ 
     1433        param_name = param.name 
     1434        # see it the parameter is multishell 
    14301435        if '[' in param.name: 
    1431             return 
     1436            # Skip empty shells 
     1437            if self.current_shell_displayed == 0: 
     1438                return 
     1439            else: 
     1440                # Create as many entries as current shells 
     1441                for ishell in xrange(1, self.current_shell_displayed+1): 
     1442                    # Remove [n] and add the shell numeral 
     1443                    name = param_name[0:param_name.index('[')] + str(ishell) 
     1444                    self.addNameToPolyModel(name) 
     1445        else: 
     1446            # Just create a simple param entry 
     1447            self.addNameToPolyModel(param_name) 
     1448 
     1449    def addNameToPolyModel(self, param_name): 
     1450        """ 
     1451        Creates a checked row in the poly model with param_name 
     1452        """ 
    14321453        # Polydisp. values from the sasmodel 
    1433         width = self.kernel_module.getParam(param.name + '.width') 
    1434         npts = self.kernel_module.getParam(param.name + '.npts') 
    1435         nsigs = self.kernel_module.getParam(param.name + '.nsigmas') 
     1454        width = self.kernel_module.getParam(param_name + '.width') 
     1455        npts = self.kernel_module.getParam(param_name + '.npts') 
     1456        nsigs = self.kernel_module.getParam(param_name + '.nsigmas') 
     1457        _, min, max = self.kernel_module.details[param_name] 
    14361458 
    14371459        # Construct a row with polydisp. related variable. 
    14381460        # This will get added to the polydisp. model 
    14391461        # Note: last argument needs extra space padding for decent display of the control 
    1440         checked_list = ["Distribution of " + param.name, str(width), 
    1441                         str(param.limits[0]), str(param.limits[1]), 
     1462        checked_list = ["Distribution of " + param_name, str(width), 
     1463                        str(min), str(max), 
    14421464                        str(npts), str(nsigs), "gaussian      "] 
    14431465        FittingUtilities.addCheckedListToModel(self._poly_model, checked_list) 
     
    15361558        FittingUtilities.addHeadersToModel(self._magnet_model) 
    15371559 
     1560    def shellNamesList(self): 
     1561        """ 
     1562        Returns list of names of all multi-shell parameters 
     1563        E.g. for sld[n], radius[n], n=1..3 it will return 
     1564        [sld1, sld2, sld3, radius1, radius2, radius3] 
     1565        """ 
     1566        multi_names = [p.name[:p.name.index('[')] for p in self.model_parameters.iq_parameters if '[' in p.name] 
     1567        top_index = self.kernel_module.multiplicity_info.number 
     1568        shell_names = [] 
     1569        for i in xrange(1, top_index+1): 
     1570            for name in multi_names: 
     1571                shell_names.append(name+str(i)) 
     1572        return shell_names 
     1573 
    15381574    def addCheckedMagneticListToModel(self, param, model): 
    15391575        """ 
    15401576        Wrapper for model update with a subset of magnetic parameters 
    15411577        """ 
     1578        if param.name[param.name.index(':')+1:] in self.shell_names: 
     1579            # check if two-digit shell number 
     1580            try: 
     1581                shell_index = int(param.name[-2:]) 
     1582            except ValueError: 
     1583                shell_index = int(param.name[-1:]) 
     1584 
     1585            if shell_index > self.current_shell_displayed: 
     1586                return 
     1587 
    15421588        checked_list = [param.name, 
    15431589                        str(param.default), 
     
    16041650        FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index) 
    16051651        self.current_shell_displayed = index 
     1652 
     1653        # Update relevant models 
     1654        self.setPolyModel() 
     1655        self.setMagneticModel() 
    16061656 
    16071657    def readFitPage(self, fp): 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    • Property mode changed from 100755 to 100644
    rb00414d r0d13814  
    6161            editor.setValidator(validator) 
    6262            return editor 
     63        if index.column() in [self.PARAM_PROPERTY, self.PARAM_UNIT]: 
     64            # Set some columns uneditable 
     65            return None 
    6366 
    6467        return super(ModelViewDelegate, self).createEditor(widget, option, index) 
     
    226229        Overwrite generic painter for certain columns 
    227230        """ 
    228         if index.column() in (self.mag_min, self.mag_max): 
     231        if index.column() in (self.mag_min, self.mag_max, self.mag_unit): 
    229232            # Units - present in nice HTML 
    230233            options = QtGui.QStyleOptionViewItemV4(option) 
Note: See TracChangeset for help on using the changeset viewer.