Ignore:
Timestamp:
Apr 6, 2017 12:47:31 PM (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:
9c391946
Parents:
2155824
Message:

Minor improvements to the fitting widget

File:
1 edited

Legend:

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

    r454670d rd7ff531  
    143143        if data is not None: 
    144144            self.data = data 
    145         # Update Q Ranges 
    146         #self.updateQRange() 
    147145 
    148146    @property 
     
    166164        self.updateQRange() 
    167165        self.cmdFit.setEnabled(True) 
    168         print "set to ", self.cmdFit.isEnabled() 
    169166 
    170167    def acceptsData(self): 
     
    259256        # Reset parameters to fit 
    260257        self.parameters_to_fit = None 
     258        self.has_error_column = False 
    261259 
    262260        # SasModel -> QModel 
     
    397395 
    398396        #disable the Fit button 
    399         self.cmdFit.setText("Calculating...") 
     397        self.cmdFit.setText('Calculating...') 
     398        self.communicate.statusBarUpdateSignal.emit('Fitting started...') 
    400399        self.cmdFit.setEnabled(False) 
    401400 
     
    414413        self.cmdFit.setText("Fit") 
    415414        self.cmdFit.setEnabled(True) 
     415 
     416        assert result is not None 
     417 
    416418        res_list = result[0] 
    417419        res = res_list[0] 
     
    440442        self.updateModelFromList(param_dict) 
    441443 
     444        # update charts 
     445        self.onPlot() 
     446 
    442447        # Read only value - we can get away by just printing it here 
    443448        chi2_repr = GuiUtils.formatNumber(fitness, high=True) 
    444449        self.lblChi2Value.setText(chi2_repr) 
    445450 
    446         # Generate charts 
    447  
    448451    def iterateOverModel(self, func): 
    449452        """ 
     
    462465            return 
    463466 
    464         def updateValues(row_i): 
     467        def updateFittedValues(row_i): 
    465468            # Utility function for main model update 
     469            # internal so can use closure for param_dict 
    466470            param_name = str(self._model_model.item(row_i, 0).text()) 
    467471            if param_name not in param_dict.keys(): 
     
    474478                self._model_model.item(row_i, 2).setText(error_repr) 
    475479 
    476         def createColumn(row_i): 
     480        def createErrorColumn(row_i): 
    477481            # Utility function for error column update 
    478482            item = QtGui.QStandardItem() 
     
    484488            error_column.append(item) 
    485489 
    486         self.iterateOverModel(updateValues) 
     490        self.iterateOverModel(updateFittedValues) 
    487491 
    488492        if self.has_error_column: 
     
    490494 
    491495        error_column = [] 
    492         self.iterateOverModel(createColumn) 
     496        self.iterateOverModel(createErrorColumn) 
     497 
     498        # switch off reponse to model change 
     499        self._model_model.blockSignals(True) 
     500        self._model_model.insertColumn(2, error_column) 
     501        self._model_model.blockSignals(False) 
     502        FittingUtilities.addErrorHeadersToModel(self._model_model) 
     503        # Adjust the table cells width. 
     504        # TODO: find a way to dynamically adjust column width while resized expanding 
     505        self.lstParams.resizeColumnToContents(0) 
     506        self.lstParams.resizeColumnToContents(4) 
     507        self.lstParams.resizeColumnToContents(5) 
     508        self.lstParams.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 
    493509 
    494510        self.has_error_column = True 
    495         self._model_model.insertColumn(2, error_column) 
    496         FittingUtilities.addErrorHeadersToModel(self._model_model) 
    497511 
    498512    def onPlot(self): 
     
    710724 
    711725        self.kernel_module.params[parameter_name] = value 
     726        print "UPDATED %s / %s with %0.3f." %(parameter_name, property_name, value) 
    712727 
    713728        # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 
     
    715730        # multishell params in self.kernel_module.details[??] = value 
    716731 
    717         # Force the chart update 
    718         self.onPlot() 
     732        # Force the chart update when actual parameters changed 
     733        if model_column == 1: 
     734            self.onPlot() 
    719735 
    720736    def checkboxSelected(self, item): 
     
    860876        # Update the control 
    861877        chi2_repr = "---" if chi2 is None else GuiUtils.formatNumber(chi2, high=True) 
    862         #self.lblChi2Value.setText(GuiUtils.formatNumber(chi2, high=True)) 
    863878        self.lblChi2Value.setText(chi2_repr) 
    864879 
Note: See TracChangeset for help on using the changeset viewer.