Ignore:
Timestamp:
Jan 16, 2018 2:50:31 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:
47d7d2d
Parents:
676f137
Message:

Context menus for tab and constraint list widgets.
Dynamic bindings of add/remove for FPs and the C&S widget

File:
1 edited

Legend:

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

    r676f137 rbe8f4b0  
    8282    Main widget for selecting form and structure factor models 
    8383    """ 
    84     #constraintAddedSignal = QtCore.pyqtSignal(list) 
     84    constraintAddedSignal = QtCore.pyqtSignal(list) 
     85    newModelSignal = QtCore.pyqtSignal() 
    8586    def __init__(self, parent=None, data=None, tab_id=1): 
    8687 
     
    574575        row = self.rowFromName(constraint.param) 
    575576        self._model_model.item(row, 1).setChild(0, item) 
    576         #self.constraintAddedSignal.emit([row]) 
     577        self.constraintAddedSignal.emit([row]) 
    577578 
    578579        # Show visual hints for the constraint 
     
    626627            max = self._model_model.item(row, max_col).text() 
    627628            # Create a Constraint object 
    628             constraint = Constraint(param=param, value=value, min=min, max=max) 
     629            constraint = Constraint(param=param, value=value, min=min, max=max, func=value) 
    629630            # Create a new item and add the Constraint object as a child 
    630631            item = QtGui.QStandardItem() 
     
    634635            self._model_model.item(row, min_col).setText(value) 
    635636            self._model_model.item(row, max_col).setText(value) 
    636             #self.constraintAddedSignal.emit([row]) 
     637            self.constraintAddedSignal.emit([row]) 
    637638            # Show visual hints for the constraint 
    638639            font = QtGui.QFont() 
     
    647648        Delete constraints from selected parameters. 
    648649        """ 
     650        self.deleteConstraintOnParameter(param=None) 
     651 
     652    def deleteConstraintOnParameter(self, param=None): 
     653        """ 
     654        Delete the constraint on model parameter 'param' 
     655        """ 
    649656        min_col = self.lstParams.itemDelegate().param_min 
    650657        max_col = self.lstParams.itemDelegate().param_max 
    651         for row in self.selectedParameters(): 
     658        for row in range(self._model_model.rowCount()): 
    652659            # Get the Constraint object from of the model item 
    653660            item = self._model_model.item(row, 1) 
     
    659666            if not isinstance(constraint, Constraint): 
    660667                continue 
     668            if param and constraint.param != param: 
     669                continue 
     670            # Now we got the right row. Delete the constraint and clean up 
    661671            # Retrieve old values and put them on the model 
    662672            if constraint.min is not None: 
     
    666676            # Remove constraint item 
    667677            item.removeRow(0) 
    668             #self.constraintAddedSignal.emit([row]) 
     678            self.constraintAddedSignal.emit([row]) 
    669679            self.modifyViewOnRow(row) 
     680            break 
     681 
    670682        self.communicate.statusBarUpdateSignal.emit('Constraint removed') 
    671683        pass 
     684 
    672685 
    673686    def getConstraintForRow(self, row): 
     
    687700        """ 
    688701        item = self._model_model.item(row,1) 
    689         return True if (item.hasChildren() and isinstance(item.child(0).data(), Constraint)) else False 
     702        if item.hasChildren(): 
     703            c = item.child(0).data() 
     704            if isinstance(c, Constraint) and c.func: 
     705                return True 
     706        return False 
     707        #return True if (item.hasChildren() and isinstance(item.child(0).data(), Constraint)) else False 
    690708 
    691709    def selectParameters(self): 
     
    726744        self.kernel_module.name = model_name 
    727745        param_number = self._model_model.rowCount() 
     746        def preamble(s): 
     747            func = self._model_model.item(s, 1).child(0).data().func 
     748            value = self._model_model.item(s, 1).child(0).data().value 
     749            if func == value: 
     750                return "" 
     751            return model_name + "." 
    728752        params = [(self._model_model.item(s, 0).text(), 
    729                     model_name+"."+self._model_model.item(s, 1).child(0).data().func) 
     753                    preamble(s) +self._model_model.item(s, 1).child(0).data().func) 
    730754                    for s in range(param_number) if self.rowHasConstraint(s)] 
    731755        return params 
     
    806830        # Update state stack 
    807831        self.updateUndo() 
     832 
     833        # Let others know 
     834        self.newModelSignal.emit() 
    808835 
    809836    def onSelectCategory(self): 
     
    15231550        # Now we claim the model has been loaded 
    15241551        self.model_is_loaded = True 
     1552        # Change the model name to a monicker 
     1553        self.kernel_module.name = self.modelName() 
    15251554 
    15261555        # (Re)-create headers 
Note: See TracChangeset for help on using the changeset viewer.