[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Mon Aug 8 20:57:05 CEST 2005
SVN commit 444091 by staikos:
support for indexed vectors
M +40 -5 enodes.cpp
M +1 -0 enodes.h
--- trunk/extragear/graphics/kst/kst/enodes.cpp #444090:444091
@@ -26,6 +26,7 @@
#include <klocale.h>
#include <qmutex.h>
+#include <qregexp.h>
#include "enodes.h"
#include "kstdatacollection.h"
@@ -758,13 +759,20 @@
: Node(), _isEquation(false), _equation(0L) {
//printf("%p: New Data Object: [%s]\n", (void*)this, name);
if (name[0] == '=') {
- _tagName = &name[1];
+ _tagName = QString(&name[1]).stripWhiteSpace();
_isEquation = true;
- } else if (_tagName.contains('[')) {
- _tagName = name;
- // FIXME
+ } else if (strchr(name, '[')) {
+ _tagName = QString(name).stripWhiteSpace();
+ QRegExp re("(.*)\\[(.*)\\]");
+ int hit = re.search(_tagName);
+ if (hit > -1 && re.numCaptures() == 2) {
+ _vector = *KST::vectorList.findTag(re.cap(1));
+ if (_vector) {
+ _vectorIndex = re.cap(2);
+ }
+ }
} else {
- _tagName = name;
+ _tagName = QString(name).stripWhiteSpace();
_vector = *KST::vectorList.findTag(_tagName);
if (!_vector) {
_scalar = *KST::scalarList.findTag(_tagName);
@@ -800,11 +808,38 @@
} else {
ParsedEquation = 0L;
mutex().unlock();
+ _isEquation = false;
return ctx->noPoint;
}
}
return _equation->value(ctx);
} else if (_vector) {
+ if (!_equation && !_vectorIndex.isEmpty()) {
+ mutex().lock();
+ yy_scan_string(_vectorIndex.latin1());
+ int rc = yyparse();
+ if (rc == 0 && ParsedEquation) {
+ _equation = static_cast<Equation::Node*>(ParsedEquation);
+ ParsedEquation = 0L;
+ mutex().unlock();
+ Equation::Context ctx;
+ ctx.sampleCount = 2;
+ ctx.noPoint = KST::NOPOINT;
+ ctx.x = 0.0;
+ ctx.xVector = 0L;
+ Equation::FoldVisitor vis(&ctx, &_equation);
+ } else {
+ ParsedEquation = 0L;
+ mutex().unlock();
+ _vectorIndex = QString::null;
+ _vector = 0L;
+ return ctx->noPoint;
+ }
+ }
+ if (_equation) {
+ // Note: should we use a fresh context here?
+ return _vector->value(int(_equation->value(ctx)));
+ }
return _vector->interpolate(ctx->i, ctx->sampleCount);
} else if (_scalar) {
return _scalar->value();
--- trunk/extragear/graphics/kst/kst/enodes.h #444090:444091
@@ -196,6 +196,7 @@
KstScalarPtr _scalar;
bool _isEquation;
Node *_equation;
+ QString _vectorIndex;
};
class NodeVisitor {
More information about the Kst
mailing list