Ignore:
Timestamp:
Sep 8, 2018 7:41:07 AM (6 years ago)
Author:
GitHub <noreply@…>
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:
c0de493
Parents:
5181e9b (diff), c8536d6c (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.
git-author:
Torin Cooper-Bennun <40573959+tcbennun@…> (09/08/18 07:41:07)
git-committer:
GitHub <noreply@…> (09/08/18 07:41:07)
Message:

Merge branch 'ESS_GUI' into ESS_GUI_iss1033

File:
1 edited

Legend:

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

    r254199c rf3e5956  
    4848from sas.qtgui.Perspectives.Fitting.ReportPageLogic import ReportPageLogic 
    4949 
    50  
    5150TAB_MAGNETISM = 4 
    5251TAB_POLY = 3 
     
    188187 
    189188        # Overwrite data type descriptor 
     189 
    190190        self.is2D = True if isinstance(self.logic.data, Data2D) else False 
    191191 
     
    563563        When clicked on white space: model description 
    564564        """ 
    565         rows = [s.row() for s in self.lstParams.selectionModel().selectedRows()] 
     565        rows = [s.row() for s in self.lstParams.selectionModel().selectedRows() 
     566                if self.isCheckable(s.row())] 
    566567        menu = self.showModelDescription() if not rows else self.modelContextMenu(rows) 
    567568        try: 
     
    799800    def getConstraintForRow(self, row): 
    800801        """ 
    801         For the given row, return its constraint, if any 
    802         """ 
    803         if self.isCheckable(row): 
    804             item = self._model_model.item(row, 1) 
    805             try: 
    806                 return item.child(0).data() 
    807             except AttributeError: 
    808                 # return none when no constraints 
    809                 pass 
    810         return None 
     802        For the given row, return its constraint, if any (otherwise None) 
     803        """ 
     804        if not self.isCheckable(row): 
     805            return None 
     806        item = self._model_model.item(row, 1) 
     807        try: 
     808            return item.child(0).data() 
     809        except AttributeError: 
     810            return None 
    811811 
    812812    def rowHasConstraint(self, row): 
     
    814814        Finds out if row of the main model has a constraint child 
    815815        """ 
    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 
     816        if not self.isCheckable(row): 
     817            return False 
     818        item = self._model_model.item(row, 1) 
     819        if not item.hasChildren(): 
     820            return False 
     821        c = item.child(0).data() 
     822        if isinstance(c, Constraint): 
     823            return True 
    822824        return False 
    823825 
     
    826828        Finds out if row of the main model has an active constraint child 
    827829        """ 
    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 
     830        if not self.isCheckable(row): 
     831            return False 
     832        item = self._model_model.item(row, 1) 
     833        if not item.hasChildren(): 
     834            return False 
     835        c = item.child(0).data() 
     836        if isinstance(c, Constraint) and c.active: 
     837            return True 
    834838        return False 
    835839 
     
    838842        Finds out if row of the main model has an active, nontrivial constraint child 
    839843        """ 
    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 
     844        if not self.isCheckable(row): 
     845            return False 
     846        item = self._model_model.item(row, 1) 
     847        if not item.hasChildren(): 
     848            return False 
     849        c = item.child(0).data() 
     850        if isinstance(c, Constraint) and c.func and c.active: 
     851            return True 
    846852        return False 
    847853 
     
    10531059            # Show constraint, if present 
    10541060            row = rows[0].row() 
    1055             if self.rowHasConstraint(row): 
    1056                 func = self.getConstraintForRow(row).func 
    1057                 if func is not None: 
    1058                     self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
     1061            if not self.rowHasConstraint(row): 
     1062                return 
     1063            func = self.getConstraintForRow(row).func 
     1064            if func is not None: 
     1065                self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
    10591066 
    10601067    def replaceConstraintName(self, old_name, new_name=""): 
     
    18071814        # Force data recalculation so existing charts are updated 
    18081815        self.showPlot() 
     1816        # This is an important processEvent. 
     1817        # This allows charts to be properly updated in order 
     1818        # of plots being applied. 
     1819        QtWidgets.QApplication.processEvents() 
    18091820        self.recalculatePlotData() 
    18101821 
     
    20912102            return 
    20922103 
     2104        product_params = None 
     2105 
    20932106        if self.kernel_module is None: 
    20942107            # Structure factor is the only selected model; build it and show all its params 
     
    20962109            s_params = self.kernel_module._model_info.parameters 
    20972110            s_params_orig = s_params 
    2098  
    20992111        else: 
    21002112            s_kernel = self.models[structure_factor]() 
     
    21132125            if "radius_effective_mode" in all_param_names: 
    21142126                # Show all parameters 
     2127                # In this case, radius_effective is NOT pruned by sasmodels.product 
    21152128                s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len]) 
    21162129                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters) 
     2130                product_params = modelinfo.ParameterTable( 
     2131                        self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 
    21172132            else: 
    21182133                # Ensure radius_effective is not displayed 
    21192134                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 
    21202135                if "radius_effective" in all_param_names: 
     2136                    # In this case, radius_effective is NOT pruned by sasmodels.product 
    21212137                    s_params = modelinfo.ParameterTable(all_params[p_pars_len+1:p_pars_len+s_pars_len]) 
     2138                    product_params = modelinfo.ParameterTable( 
     2139                            self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 
    21222140                else: 
     2141                    # In this case, radius_effective is pruned by sasmodels.product 
    21232142                    s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 
     2143                    product_params = modelinfo.ParameterTable( 
     2144                            self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len-1:]) 
    21242145 
    21252146        # Add heading row 
     
    21292150        # Any renamed parameters are stored as data in the relevant item, for later handling 
    21302151        FittingUtilities.addSimpleParametersToModel( 
    2131                 s_params, 
    2132                 self.is2D, 
    2133                 s_params_orig, 
    2134                 self._model_model, 
    2135                 self.lstParams) 
     2152                parameters=s_params, 
     2153                is2D=self.is2D, 
     2154                parameters_original=s_params_orig, 
     2155                model=self._model_model, 
     2156                view=self.lstParams) 
     2157 
     2158        # Insert product-only params into QModel 
     2159        if product_params: 
     2160            prod_rows = FittingUtilities.addSimpleParametersToModel( 
     2161                    parameters=product_params, 
     2162                    is2D=self.is2D, 
     2163                    parameters_original=None, 
     2164                    model=self._model_model, 
     2165                    view=self.lstParams, 
     2166                    row_num=2) 
     2167 
     2168            # Since this all happens after shells are dealt with and we've inserted rows, fix this counter 
     2169            self._n_shells_row += len(prod_rows) 
    21362170 
    21372171    def haveParamsToFit(self): 
     
    28002834        self.current_shell_displayed = index 
    28012835 
     2836        # Change 'n' in the parameter model, thereby updating the underlying model 
     2837        self._model_model.item(self._n_shells_row, 1).setText(str(index)) 
     2838 
    28022839        # Update relevant models 
    28032840        self.setPolyModel() 
     
    33103347        self._poly_model.blockSignals(False) 
    33113348 
     3349 
     3350 
Note: See TracChangeset for help on using the changeset viewer.