Ignore:
Timestamp:
May 15, 2017 10:57:34 AM (8 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:
2a432e7
Parents:
2241130
Message:

Improvements to view delegates and model updates.

File:
1 edited

Legend:

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

    r2241130 r00b3b40  
    370370 
    371371        # Update state stack 
    372         if self.undo_supported: 
    373             state = self.currentState() 
    374             self.pushFitPage(state) 
     372        self.updateUndo() 
    375373 
    376374    def onSelectStructureFactor(self): 
     
    429427        name_index = self._poly_model.index(model_row, 0) 
    430428        # Extract changed value. Assumes proper validation by QValidator/Delegate 
    431         # Checkbox in column 0 
     429        # TODO: abstract away hardcoded column numbers 
    432430        if model_column == 0: 
     431            # Is the parameter checked for fitting? 
    433432            value = item.checkState() 
     433            # TODO: add the param to self.params_for_fitting 
     434        elif model_column == 6: 
     435            value = item.text() 
     436            # TODO: Modify Npts/Nsigs based on function choice 
    434437        else: 
    435438            try: 
     
    866869            return 
    867870        parameter_name = str(self._model_model.data(name_index).toPyObject()) # sld, background etc. 
    868         property_name = str(self._model_model.headerData(1, model_column).toPyObject()) # Value, min, max, etc. 
    869  
     871        property_index = self._model_model.headerData(1, model_column).toInt()[0]-1 # Value, min, max, etc. 
     872 
     873        # Update the parameter value - note: this supports +/-inf as well 
    870874        self.kernel_module.params[parameter_name] = value 
    871875 
    872         # TODO: update min/max based on property_name 
    873876        # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 
    874         # magnetic params in self.kernel_module.details['M0:parameter_name'] = value 
    875         # multishell params in self.kernel_module.details[??] = value 
     877        self.kernel_module.details[parameter_name][property_index] = value 
     878 
     879        # TODO: magnetic params in self.kernel_module.details['M0:parameter_name'] = value 
     880        # TODO: multishell params in self.kernel_module.details[??] = value 
    876881 
    877882        # Force the chart update when actual parameters changed 
     
    880885 
    881886        # Update state stack 
    882         if self.undo_supported: 
    883             state = self.currentState() 
    884             self.pushFitPage(state) 
     887        self.updateUndo() 
    885888 
    886889    def checkboxSelected(self, item): 
     
    943946        Update a QStandardModelIndex containing model data 
    944947        """ 
    945         if fitted_data.name is None: 
    946             name = self.nameForFittedData(self.logic.data.filename) 
    947             fitted_data.title = name 
    948             fitted_data.name = name 
    949         else: 
    950             name = fitted_data.name 
     948        name = self.nameFromData(fitted_data) 
    951949        # Make this a line if no other defined 
    952950        if hasattr(fitted_data, 'symbol') and fitted_data.symbol is None: 
     
    959957        Create a QStandardModelIndex containing model data 
    960958        """ 
     959        name = self.nameFromData(fitted_data) 
     960        # Notify the GUI manager so it can create the theory model in DataExplorer 
     961        new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(fitted_data), name=name) 
     962        self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 
     963 
     964    def nameFromData(self, fitted_data): 
     965        """ 
     966        Return name for the dataset. Terribly impure function. 
     967        """ 
    961968        if fitted_data.name is None: 
    962             name = self.nameForFittedData(self.kernel_module.name) 
     969            name = self.nameForFittedData(self.logic.data.filename) 
    963970            fitted_data.title = name 
    964971            fitted_data.name = name 
     
    966973        else: 
    967974            name = fitted_data.name 
    968         # Notify the GUI manager so it can create the theory model in DataExplorer 
    969         new_item = GuiUtils.createModelItemWithPlot(QtCore.QVariant(fitted_data), name=name) 
    970         self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 
     975        return name 
    971976 
    972977    def methodCalculateForData(self): 
     
    12581263        # TODO: add polidyspersity and magnetism 
    12591264 
     1265 
     1266    def updateUndo(self): 
     1267        """ 
     1268        Create a new state page and add it to the stack 
     1269        """ 
     1270        if self.undo_supported: 
     1271            self.pushFitPage(self.currentState()) 
     1272 
    12601273    def currentState(self): 
    12611274        """ 
Note: See TracChangeset for help on using the changeset viewer.