[Kst] kdeextragear-2/kst
George Staikos
staikos at kde.org
Sat Dec 20 07:36:26 CET 2003
CVS commit by staikos:
bug fixes, a small change to the API for filters needed to make them work, and
add the code to support sets of > 1 filter.
M +45 -2 kst/kstfilter.cpp 1.5
M +1 -7 kst/kstfilter.h 1.9
M +2 -0 kst/kstplugin.cpp 1.41
M +2 -2 kst/plugin.cpp 1.13
M +1 -1 kst/plugin.h 1.13
M +3 -3 plugins/filters/scalarfilter.c 1.3
--- kdeextragear-2/kst/kst/kstfilter.cpp #1.4:1.5
@@ -17,4 +17,5 @@
#include "kstfilter.h"
+#include "kstdatacollection.h"
#include <kdebug.h>
@@ -60,9 +61,9 @@ void KstFilter::apply(const KstVectorPtr
- int rc = plugin()->filter(in->value(), in->length(), inScalars, outVector, &outLen);
+ int rc = _plugin->filter(in->value(), in->length(), inScalars, &outVector, &outLen);
vectorRealloced(out, outVector, outLen);
- delete inScalars;
+ delete[] inScalars;
}
@@ -74,3 +75,45 @@ bool KstFilter::setPlugin(KSharedPtr<Plu
}
+
+void KstFilterSet::apply(const KstVectorPtr in, KstVectorPtr out) {
+ int left = KstObjectList<KstFilterPtr>::count();
+
+ if (left < 1) {
+ out->resize(in->length());
+ memcpy(out->value(), in->value(), in->length() * sizeof(double));
+ return;
+ }
+
+ KstVector *tmpVector1, *tmpVector2;
+
+ Iterator it = begin();
+ if (left == 1) {
+ (*it)->apply(in, out);
+ return;
+ }
+
+ tmpVector1 = new KstVector;
+ tmpVector2 = new KstVector;
+ (*it)->apply(in, tmpVector1);
+ ++it;
+ --left;
+
+ for (; it != end(); ++it) {
+ if (--left == 0) {
+ (*it)->apply(tmpVector1, out);
+ } else {
+ (*it)->apply(tmpVector1, tmpVector2);
+ }
+
+ // Swap the vectors
+ KstVector *tmp = tmpVector1;
+ tmpVector1 = tmpVector2;
+ tmpVector2 = tmp;
+ }
+
+ // this will delete them
+ KST::vectorList.remove(tmpVector1);
+ KST::vectorList.remove(tmpVector2);
+}
+
// vim: ts=2 sw=2 et
--- kdeextragear-2/kst/kst/kstfilter.h #1.8:1.9
@@ -41,11 +41,5 @@ class KstFilterSet : public KstObjectLis
virtual ~KstFilterSet() {}
- virtual void apply(const KstVectorPtr in, KstVectorPtr out) {
- for (Iterator it = begin(); it != end(); ++it) {
- // FIXME: must use temps here
- (*it)->apply(in, out);
- }
- }
-
+ virtual void apply(const KstVectorPtr in, KstVectorPtr out);
const QString& name() const { return _name; }
void setName(const QString& n) { _name = n; }
--- kdeextragear-2/kst/kst/kstplugin.cpp #1.40:1.41
@@ -279,4 +279,6 @@ QString KstPlugin::propertyString() cons
bool KstPlugin::setPlugin(KSharedPtr<Plugin> plugin) {
+ kdDebug() << "KstPlugin::setPlugin" << endl;
+
if (plugin == _plugin) {
return true;
--- kdeextragear-2/kst/kst/plugin.cpp #1.12:1.13
@@ -69,5 +69,5 @@ int Plugin::call(const double *const inA
int Plugin::filter(const double *const inArray, int inArrayLen,
- const double inScalars[], double outArray[],
+ const double inScalars[], double *outArray[],
int *outArrayLen) const {
if (!_symbol || !_data._filter) {
@@ -75,5 +75,5 @@ int Plugin::filter(const double *const i
}
- return ((int(*)(const double *const, int, const double[], double[], int*))_symbol) (inArray, inArrayLen, inScalars, outArray, outArrayLen);
+ return ((int(*)(const double *const, int, const double[], double*[], int*))_symbol) (inArray, inArrayLen, inScalars, outArray, outArrayLen);
}
--- kdeextragear-2/kst/kst/plugin.h #1.12:1.13
@@ -45,5 +45,5 @@ public:
double outScalars[]) const;
int filter(const double *const inArray, int inArrayLen,
- const double inScalars[], double outArray[],
+ const double inScalars[], double *outArray[],
int *outArrayLen) const;
--- kdeextragear-2/kst/plugins/filters/scalarfilter.c #1.2:1.3
@@ -4,15 +4,15 @@
int scalarfilter(const double *const inArray, int inArrayLen,
const double inScalars[],
- double outArray[], int *outArrayLen)
+ double *outArray[], int *outArrayLen)
{
int j;
if (*outArrayLen != inArrayLen) {
- outArray = realloc(outArray, inArrayLen*sizeof(double));
+ *outArray = realloc(*outArray, inArrayLen*sizeof(double));
*outArrayLen = inArrayLen;
}
for (j = 0; j < inArrayLen; j++) {
- outArray[j] = inScalars[0]*inArray[j];
+ (*outArray)[j] = inScalars[0]*inArray[j];
}
More information about the Kst
mailing list