[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Jul 14 01:12:01 CEST 2004


CVS commit by arwalker: 

Framework for display the parameter names of a fit. 

At present these names will not get translated as they reside in the plugin, which does not have access to Qt.

The parameter names are acquired through a function (rather than e.g. putting them in the xml) as some of the fits have a variable number of parameters, which depend on some input scalar. Thus, the parameter names must be calculated dynamically.


  M +13 -5     kstviewfitsdialog_i.cpp   1.8
  M +27 -1     plugin.cpp   1.19
  M +3 -2      plugin.h   1.22
  M +2 -1      pluginloader.cpp   1.11


--- kdeextragear-2/kst/kst/kstviewfitsdialog_i.cpp  #1.7:1.8
@@ -108,4 +108,5 @@ void KstViewFitsDialogI::fitChanged(cons
   KstFitCurvePtr fit;
   KstPluginPtr plugin;
+  QString strParameterName;
   double* pParams = NULL;
   double* pCovars = NULL;
@@ -155,9 +156,16 @@ void KstViewFitsDialogI::fitChanged(cons
 
   if( iNumParams > 0 ) {
-    tableFits->horizontalHeader()->setLabel( 0, i18n("Parameters") );
-    tableFits->horizontalHeader()->setLabel( 1, i18n("") );
-    tableFits->horizontalHeader()->setLabel( 2, i18n("Covariance") );
-    for( i=3; i<iNumParams+2; i++ ) {
-      tableFits->horizontalHeader()->setLabel( i, i18n("") );
+    tableFits->horizontalHeader()->setLabel( 0, i18n("Value") );
+    tableFits->horizontalHeader()->setLabel( 1, i18n("Covariance:") );
+
+    if (plugin) {
+      KstSharedPtr<Plugin> pluginBase = plugin->plugin();
+      if (pluginBase) {
+        for( i=0; i<iNumParams; i++ ) {
+          strParameterName = pluginBase->parameterName(i);
+          tableFits->horizontalHeader()->setLabel( i+2, strParameterName );
+          tableFits->verticalHeader()->setLabel( i, strParameterName );
+        }
+      }
     }
   }

--- kdeextragear-2/kst/kst/plugin.cpp  #1.18:1.19
@@ -20,4 +20,5 @@
 
 #include <klibloader.h>
+#include <klocale.h>
 #include <kdebug.h>
 
@@ -28,4 +29,5 @@ Plugin::Plugin() : KstShared() {
   _lib = 0L;
   _symbol = 0L;
+  _parameterName = 0L;
   //kdDebug() << "Creating Plugin: " << long(this) << endl;
 }
@@ -34,4 +36,5 @@ Plugin::Plugin() : KstShared() {
 Plugin::~Plugin() {
   _symbol = 0L;
+  _parameterName = 0L;
 
   if (_lib) {
@@ -104,4 +107,28 @@ int Plugin::filter(const double *const i
 
 
+QString Plugin::parameterName(int iIndex) {
+  QString strParameter;
+  char* pName = 0L;
+  
+  if (_data._isFit) {
+    if (_parameterName) {
+      if( ((int(*)(int, char** pName))_parameterName) (iIndex, &pName)) {
+        if (pName != 0L) {
+          strParameter = pName;
+
+          free( pName );
+        }
+      }
+    }
+  }
+
+  if (strParameter.isEmpty()) {
+    strParameter = i18n("Param%1").arg(iIndex);
+  }
+  
+  return strParameter;
+}
+
+
 const Plugin::Data& Plugin::data() const {
   return _data;

--- kdeextragear-2/kst/kst/plugin.h  #1.21:1.22
@@ -54,5 +54,5 @@ public:
              const double inScalars[], double *outArray[],
              int *outArrayLen, void **local) const;
-
+  QString parameterName(int iIndex);
 
   static const int CallError;
@@ -126,4 +126,5 @@ protected:
 
   void *_symbol;
+  void *_parameterName;
 
   // Related files

--- kdeextragear-2/kst/kst/pluginloader.cpp  #1.10:1.11
@@ -37,5 +37,5 @@ PluginLoader *PluginLoader::self() {
   }
 
-return _self;
+  return _self;
 }
 
@@ -72,4 +72,5 @@ Plugin *PluginLoader::loadPlugin(const Q
 
   plug->_symbol = plug->_lib->symbol(plug->_data._name.latin1());
+  plug->_parameterName = plug->_lib->symbol("parameterName");
 
   if (!plug->_symbol) {





More information about the Kst mailing list