[Kst] branches/work/kst/portto4/kst/src/plugins/filters/cumulativesum

Nicolas Brisset nicolas.brisset at eurocopter.com
Thu Sep 13 23:53:11 UTC 2012


SVN commit 1316195 by brisset:

Some changes to the cumulative sum plugin:
- set default value to 1.0, which makes much more sense than 0
- change the algorithm so that the resulting vector has the right number of points, as discussed on the list
- do not make it a filter plugin so that it appears under the "Standard Plugin" menu, which is where I would expect it

During some testing I noticed the following bugs. Barth, let me know if you can fix them easily (i.e. before we forget) or if I should open a 
report to keep track of them:
1) we have two almost identical copies of the differentiation plugin. One is enough, I think the one in src/plugins/filters is the good one 
but it should also be made "Generic", not "Filter" type. I can make that change (i.e. remove the second one) if nobody minds. One issue could 
have been existing .kst files with different parameter names, but see next point => it should not be an issue.
2) (*BAD*) cumulative sum and differentiation plugins are not properly saved to the .kst file and are lost upon reloading. Try to read any 
vector, add one of those plugins, create a new curve in a new plot, save and reload the saved file: plugins are gone! This has to be fixed!! I 
actually fear it is the case we other plugins (I tried only low pass, but it also gets lost)
3) when using a filter plugin from the Create menu (not the RMB contextual menu), a curve gets created in a new plot with a completely wrong x 
axis. The behavior is not consistent with other plugins created from the menu, for which no curve is created. And if a curve gets created, it 
should at least try to figure out the right X vector (to make it simple: use that of the first input vector). Or even better: also include the 
curve creation/placement part of the dialog when the plugin is called from the menu


 M  +4 -4      cumulativesum.cpp  
 M  +1 -1      cumulativesum.h  


--- branches/work/kst/portto4/kst/src/plugins/filters/cumulativesum/cumulativesum.cpp #1316194:1316195
@@ -33,7 +33,7 @@
       _store = store; 
       _vector->setObjectStore(store); 
       _scalarStep->setObjectStore(store);
-      _scalarStep->setDefaultValue(0);
+      _scalarStep->setDefaultValue(1.0);
     }
 
     void setupSlots(QWidget* dialog) {
@@ -171,11 +171,11 @@
 
 
   /* Memory allocation */
-  outputVector->resize(inputVector->length()+1, true);
+  outputVector->resize(inputVector->length(), true);
 
-  outputVector->value()[0] = 0.0;
+  outputVector->value()[0] = inputVector->value()[0];
 
-  for (int i = 0; i < inputVector->length(); i++) {
+  for (int i = 0; i < inputVector->length()-1; i++) {
     outputVector->value()[i+1] = inputVector->value()[i]*inputScalar->value() + outputVector->value()[i];
   }
 
--- branches/work/kst/portto4/kst/src/plugins/filters/cumulativesum/cumulativesum.h #1316194:1316195
@@ -65,7 +65,7 @@
     virtual QString pluginName() const;
     virtual QString pluginDescription() const;
 
-    virtual DataObjectPluginInterface::PluginTypeID pluginType() const { return Filter; }
+    virtual DataObjectPluginInterface::PluginTypeID pluginType() const { return Generic; }
 
     virtual bool hasConfigWidget() const { return true; }
 


More information about the Kst mailing list