[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Jul 14 02:56:00 CEST 2004


CVS commit by arwalker: 

Display the chi^2/nu value in the fit results.


  M +18 -12    kstfittable.cpp   1.4
  M +2 -1      kstfittable.h   1.4
  M +14 -1     kstviewfitsdialog_i.cpp   1.9


--- kdeextragear-2/kst/kst/kstfittable.cpp  #1.3:1.4
@@ -28,4 +28,5 @@ KstFitTable::KstFitTable( QWidget * pare
   _iNumParams = 0;
   _iNumCovars = 0;
+  _dChi2Nu    = 0.0;
 }
 
@@ -40,5 +41,5 @@ KstFitTable::~KstFitTable( )
 }
 
-void KstFitTable::setParameters(double* pParams, int iNumParams, double* pCovars, int iNumCovars) {
+void KstFitTable::setParameters(double* pParams, int iNumParams, double* pCovars, int iNumCovars, double dChi2Nu) {
   if (_pdParams != NULL) {
     delete _pdParams;
@@ -51,6 +52,7 @@ void KstFitTable::setParameters(double* 
   _iNumCovars = iNumCovars;
   _pdCovars   = pCovars;
+  _dChi2Nu    = dChi2Nu;
 
-  setNumRows(iNumParams+0);
+  setNumRows(iNumParams+2);
   setNumCols(iNumParams+2);
 }
@@ -69,4 +71,5 @@ void KstFitTable::paintCell( QPainter* p
   }
 
+  if( row < _iNumParams ) {
   if( col == 0 ) {
     if( _pdParams != NULL && row <= _iNumParams ) {
@@ -78,4 +81,7 @@ void KstFitTable::paintCell( QPainter* p
     }
   }
+  } else if( row == _iNumParams+1 && col == 0 ) {
+    str.setNum( _dChi2Nu, 'g', 6 );
+  }    
     
   painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str);

--- kdeextragear-2/kst/kst/kstfittable.h  #1.3:1.4
@@ -25,5 +25,5 @@ public:
    ~KstFitTable( );
 
-    void          setParameters(double* pParams, int iNumParams, double* pCovars, int iNumCovars);
+    void          setParameters(double* pParams, int iNumParams, double* pCovars, int iNumCovars, double dChi2Nu);
     void          paintCell( QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg );
     
@@ -40,4 +40,5 @@ private:
     double*       _pdParams;
     double*       _pdCovars;
+    double        _dChi2Nu;
     int           _iNumParams;
     int           _iNumCovars;

--- kdeextragear-2/kst/kst/kstviewfitsdialog_i.cpp  #1.8:1.9
@@ -34,4 +34,5 @@
 #include "kstfittable.h"
 #include "kstrvector.h"
+#include "kstscalar.h"
 #include "kstdatacollection.h"
 #include "kstviewfitsdialog_i.h"
@@ -111,4 +112,5 @@ void KstViewFitsDialogI::fitChanged(cons
   double* pParams = NULL;
   double* pCovars = NULL;
+  double dChi2Nu = 0.0;
   int iNumParams = 0;
   int iNumCovars = 0;
@@ -121,7 +123,15 @@ void KstViewFitsDialogI::fitChanged(cons
     if (plugin) {
       KstVectorMap vectors;
+      KstScalarMap scalars;
+      KstScalarPtr scalarChi2Nu;
       KstVectorPtr vectorParam;
       KstVectorPtr vectorCovar;
 
+      scalars = plugin->outputScalars( );
+      scalarChi2Nu = scalars["chi^2/nu"];
+      if (scalarChi2Nu) {
+        dChi2Nu = scalarChi2Nu->value();
+      }
+      
       vectors = plugin->outputVectors( );
       vectorParam = vectors["Parameters"];
@@ -153,5 +163,5 @@ void KstViewFitsDialogI::fitChanged(cons
   }
 
-  tableFits->setParameters( pParams, iNumParams, pCovars, iNumCovars );
+  tableFits->setParameters( pParams, iNumParams, pCovars, iNumCovars, dChi2Nu );
 
   if( iNumParams > 0 ) {
@@ -159,4 +169,7 @@ void KstViewFitsDialogI::fitChanged(cons
     tableFits->horizontalHeader()->setLabel( 1, i18n("Covariance:") );
 
+    tableFits->verticalHeader()->setLabel( iNumParams+0, "---" );
+    tableFits->verticalHeader()->setLabel( iNumParams+1, i18n("Chi^2/Nu") );
+
     if (plugin) {
       KstSharedPtr<Plugin> pluginBase = plugin->plugin();





More information about the Kst mailing list