Ignore:
Timestamp:
Sep 4, 2018 3:51:03 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:
700b03b
Parents:
ef3494b3
git-author:
Torin Cooper-Bennun <torin.cooper-bennun@…> (07/25/18 10:01:03)
git-committer:
Torin Cooper-Bennun <torin.cooper-bennun@…> (09/04/18 03:51:03)
Message:

[CHERRY-PICK FROM 4f80a834f] put sub-heading creation into FittingUtilities?; fix a couple of caused issues; fix affected tests

File:
1 edited

Legend:

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

    ref3494b3 r00b7ddf0  
    669669        Return list of all parameters for the current model 
    670670        """ 
    671         return [self._model_model.item(row).text() for row in range(self._model_model.rowCount())] 
     671        return [self._model_model.item(row).text() 
     672                for row in range(self._model_model.rowCount()) 
     673                if self.isCheckable(row)] 
    672674 
    673675    def modifyViewOnRow(self, row, font=None, brush=None): 
     
    697699        assert isinstance(constraint, Constraint) 
    698700        assert 0 <= row <= self._model_model.rowCount() 
     701        assert self.isCheckable(row) 
    699702 
    700703        item = QtGui.QStandardItem() 
     
    717720        max_col = self.lstParams.itemDelegate().param_max 
    718721        for row in self.selectedParameters(): 
     722            assert(self.isCheckable(row)) 
    719723            param = self._model_model.item(row, 0).text() 
    720724            value = self._model_model.item(row, 1).text() 
     
    759763        max_col = self.lstParams.itemDelegate().param_max 
    760764        for row in range(self._model_model.rowCount()): 
     765            if not self.isCheckable(row): 
     766                continue 
    761767            if not self.rowHasConstraint(row): 
    762768                continue 
     
    787793        For the given row, return its constraint, if any 
    788794        """ 
    789         try: 
     795        if self.isCheckable(row): 
    790796            item = self._model_model.item(row, 1) 
    791             return item.child(0).data() 
    792         except AttributeError: 
    793             # return none when no constraints 
    794             return None 
     797            try: 
     798                return item.child(0).data() 
     799            except AttributeError: 
     800                # return none when no constraints 
     801                pass 
     802        return None 
    795803 
    796804    def rowHasConstraint(self, row): 
     
    798806        Finds out if row of the main model has a constraint child 
    799807        """ 
    800         item = self._model_model.item(row, 1) 
    801         if item.hasChildren(): 
    802             c = item.child(0).data() 
    803             if isinstance(c, Constraint): 
    804                 return True 
     808        if self.isCheckable(row): 
     809            item = self._model_model.item(row, 1) 
     810            if item.hasChildren(): 
     811                c = item.child(0).data() 
     812                if isinstance(c, Constraint): 
     813                    return True 
    805814        return False 
    806815 
     
    809818        Finds out if row of the main model has an active constraint child 
    810819        """ 
    811         item = self._model_model.item(row, 1) 
    812         if item.hasChildren(): 
    813             c = item.child(0).data() 
    814             if isinstance(c, Constraint) and c.active: 
    815                 return True 
     820        if self.isCheckable(row): 
     821            item = self._model_model.item(row, 1) 
     822            if item.hasChildren(): 
     823                c = item.child(0).data() 
     824                if isinstance(c, Constraint) and c.active: 
     825                    return True 
    816826        return False 
    817827 
     
    820830        Finds out if row of the main model has an active, nontrivial constraint child 
    821831        """ 
    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.func and c.active: 
    826                 return True 
     832        if self.isCheckable(row): 
     833            item = self._model_model.item(row, 1) 
     834            if item.hasChildren(): 
     835                c = item.child(0).data() 
     836                if isinstance(c, Constraint) and c.func and c.active: 
     837                    return True 
    827838        return False 
    828839 
     
    15561567            # internal so can use closure for param_dict 
    15571568            param_name = str(self._model_model.item(row, 0).text()) 
    1558             if param_name not in list(param_dict.keys()): 
     1569            if not self.isCheckable(row) or param_name not in list(param_dict.keys()): 
    15591570                return 
    15601571            # modify the param value 
     
    15681579            # Utility function for updateof polydispersity part of the main model 
    15691580            param_name = str(self._model_model.item(row, 0).text())+'.width' 
    1570             if param_name not in list(param_dict.keys()): 
     1581            if not self.isCheckable(row) or param_name not in list(param_dict.keys()): 
    15711582                return 
    15721583            # modify the param value 
     
    17111722        """ 
    17121723        for row_i in range(self._magnet_model.rowCount()): 
    1713             func(row_i) 
     1724            if self.isCheckable(row_i): 
     1725                func(row_i) 
    17141726 
    17151727    def updateMagnetModelFromList(self, param_dict): 
     
    20312043        self.shell_names = self.shellNamesList() 
    20322044 
    2033         # Add a header 
    2034         header_row = [QtGui.QStandardItem() for i in range(5)] 
    2035         header_row[0].setText(self.kernel_module.name) 
    2036         font = header_row[0].font() 
    2037         font.setBold(True) 
    2038         header_row[0].setFont(font) 
    2039         for item in header_row: 
    2040             item.setEditable(False) 
    2041             item.setCheckable(False) 
    2042             item.setSelectable(False) 
    2043  
    2044         self._model_model.appendRow(header_row) 
    2045  
    2046         # Update the QModel 
     2045        # Get new rows for QModel 
    20472046        new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D) 
    20482047 
     2048        # Add heading row 
     2049        FittingUtilities.addHeadingRowToModel(self._model_model, model_name) 
     2050 
     2051        # Update QModel 
    20492052        for row in new_rows: 
    20502053            self._model_model.appendRow(row) 
     
    20642067        self.kernel_module = MultiplicationModel(form_kernel, structure_kernel) 
    20652068 
    2066         # Add a header 
    2067         header_row = [QtGui.QStandardItem() for i in range(5)] 
    2068         header_row[0].setText(structure_kernel._model_info.name) 
    2069         font = header_row[0].font() 
    2070         font.setBold(True) 
    2071         header_row[0].setFont(font) 
    2072         for item in header_row: 
    2073             item.setEditable(False) 
    2074             item.setCheckable(False) 
    2075             item.setSelectable(False) 
    2076  
    2077         self._model_model.appendRow(header_row) 
    2078  
     2069        # Get new rows for QModel 
    20792070        new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) 
     2071 
     2072        # Add heading row 
     2073        FittingUtilities.addHeadingRowToModel(self._model_model, structure_factor) 
     2074 
     2075        # Update QModel 
    20802076        for row in new_rows: 
    20812077            self._model_model.appendRow(row) 
     
    25172513        def updateFunctionCaption(row): 
    25182514            # Utility function for update of polydispersity function name in the main model 
     2515            if not self.isCheckable(row): 
     2516                return 
    25192517            param_name = str(self._model_model.item(row, 0).text()) 
    25202518            if param_name !=  param.name: 
Note: See TracChangeset for help on using the changeset viewer.