[Kst] branches/work/kst/1.6/kst/src/libkstmath
Andrew Walker
arwalker at sumusltd.com
Tue Dec 11 01:21:49 CET 2007
SVN commit 747080 by arwalker:
BUG:153154 correct several problems with changing names of vectors and scalars that are used in existing equations
M +15 -16 enodes.cpp
M +20 -13 kstequation.cpp
M +2 -6 kstequation.h
--- branches/work/kst/1.6/kst/src/libkstmath/enodes.cpp #747079:747080
@@ -147,7 +147,8 @@
bool BinaryNode::takeVectorsAndScalars(const KstVectorMap& vm, const KstScalarMap& sm) {
bool rc = _left->takeVectorsAndScalars(vm, sm);
- rc = _right->takeVectorsAndScalars(vm, sm) && rc;
+ rc = _right->takeVectorsAndScalars(vm, sm) || rc;
+
return rc;
}
@@ -831,7 +832,7 @@
bool ArgumentList::takeVectorsAndScalars(const KstVectorMap& vm, const KstScalarMap& sm) {
bool rc = true;
for (Node *i = _args.first(); i; i = _args.next()) {
- rc = i->takeVectorsAndScalars(vm, sm) && rc;
+ rc = i->takeVectorsAndScalars(vm, sm) || rc;
}
return rc;
}
@@ -1033,9 +1034,9 @@
_equation->collectObjects(v, s, t);
}
} else if (_vector && !v.contains(_tagName)) {
- v.insert(_tagName, _vector);
+ v.insert(_vector->tag().displayString(), _vector);
} else if (_scalar && !s.contains(_tagName)) {
- s.insert(_tagName, _scalar);
+ s.insert(_scalar->tag().displayString(), _scalar);
} else if (!_scalar && !_vector) {
KstDebug::self()->log(i18n("Equation has unknown object [%1].").arg(_tagName), KstDebug::Error);
return false;
@@ -1045,36 +1046,34 @@
bool Data::takeVectorsAndScalars(const KstVectorMap& vm, const KstScalarMap& sm) {
+ bool val = false;
+
if (_isEquation) {
if (_equation) {
- return _equation->takeVectorsAndScalars(vm, sm);
+ _equation->takeVectorsAndScalars(vm, sm);
+ val = true;
}
- return false;
- }
-
- if (_vector) {
+ } else if (_vector) {
if (vm.contains(_tagName)) {
_vector = vm[_tagName];
- } else {
- return false;
+ val = true;
}
} else if (_scalar) {
if (sm.contains(_tagName)) {
_scalar = sm[_tagName];
- } else {
- return false;
+ val = true;
}
} else {
if (vm.contains(_tagName)) {
_vector = vm[_tagName];
+ val = true;
} else if (sm.contains(_tagName)) {
_scalar = sm[_tagName];
- } else {
- return false;
+ val = true;
}
}
- return true;
+ return val;
}
--- branches/work/kst/1.6/kst/src/libkstmath/kstequation.cpp #747079:747080
@@ -241,8 +241,15 @@
int rc = yyparse();
Equation::Node *en = static_cast<Equation::Node*>(ParsedEquation);
if (rc == 0 && en) {
- if (en->takeVectorsAndScalars(VectorsUsed, ScalarsUsed)) {
+ if (en->takeVectorsAndScalars(_vectorsUsed, _scalarsUsed)) {
_equation = en->text();
+
+ KstStringMap sm;
+ _vectorsUsed.clear();
+ _scalarsUsed.clear();
+
+ en->collectObjects(_vectorsUsed, _scalarsUsed, sm);
+
setupConnections();
} else {
kstdWarning() << "Equation [" << _equation << "] failed to find its vectors/scalars when re-parsing." << endl;
@@ -270,7 +277,7 @@
Equation::Node *en = static_cast<Equation::Node*>(ParsedEquation);
if (rc == 0 && en) {
QString etext;
- if (en->takeVectorsAndScalars(VectorsUsed, ScalarsUsed)) {
+ if (en->takeVectorsAndScalars(_vectorsUsed, _scalarsUsed)) {
etext = en->text();
} else {
kstdWarning() << "Equation [" << _equation << "] failed to find its vectors/scalars when saving. The resulting Kst file may have issues." << endl;
@@ -298,8 +305,8 @@
_equation = in_fn;
setRecursed(false);
- VectorsUsed.clear();
- ScalarsUsed.clear();
+ _vectorsUsed.clear();
+ _scalarsUsed.clear();
_ns = 2; // reset the updating
delete _pe;
@@ -318,7 +325,7 @@
Equation::FoldVisitor vis(&ctx, &_pe);
KstStringMap sm;
- if (_pe->collectObjects(VectorsUsed, ScalarsUsed, sm)) {
+ if (_pe->collectObjects(_vectorsUsed, _scalarsUsed, sm)) {
setupConnections();
_pe->update(-1, &ctx);
} else {
@@ -389,7 +396,7 @@
// determine value of Interp
if (_doInterp) {
ns = (*_xInVector)->length();
- for (KstVectorMap::ConstIterator i = VectorsUsed.begin(); i != VectorsUsed.end(); ++i) {
+ for (KstVectorMap::ConstIterator i = _vectorsUsed.begin(); i != _vectorsUsed.end(); ++i) {
if (i.data()->length() > ns) {
ns = i.data()->length();
}
@@ -426,7 +433,7 @@
v_shift = (*_xInVector)->numShift();
v_new = (*_xInVector)->numNew();
- for (KstVectorMap::ConstIterator i = VectorsUsed.begin(); i != VectorsUsed.end(); ++i) {
+ for (KstVectorMap::ConstIterator i = _vectorsUsed.begin(); i != _vectorsUsed.end(); ++i) {
if (v_shift != i.data()->numShift()) {
v_shift = _ns;
}
@@ -486,7 +493,7 @@
if (_pe && rc == 0) {
Equation::FoldVisitor vis(&ctx, &_pe);
KstStringMap sm;
- _pe->collectObjects(VectorsUsed, ScalarsUsed, sm);
+ _pe->collectObjects(_vectorsUsed, _scalarsUsed, sm);
setupConnections();
ParsedEquation = 0L;
} else {
@@ -631,9 +638,9 @@
bool KstEquation::uses(KstObjectPtr p) const {
- // check VectorsUsed in addition to _input*'s
+ // check _vectorsUsed in addition to _input*'s
if (KstVectorPtr vect = kst_cast<KstVector>(p)) {
- for (KstVectorMap::ConstIterator j = VectorsUsed.begin(); j != VectorsUsed.end(); ++j) {
+ for (KstVectorMap::ConstIterator j = _vectorsUsed.begin(); j != _vectorsUsed.end(); ++j) {
if (j.data() == vect) {
return true;
}
@@ -641,7 +648,7 @@
} else if (KstDataObjectPtr obj = kst_cast<KstDataObject>(p) ) {
// check all connections from this expression to p
for (KstVectorMap::Iterator j = obj->outputVectors().begin(); j != obj->outputVectors().end(); ++j) {
- for (KstVectorMap::ConstIterator k = VectorsUsed.begin(); k != VectorsUsed.end(); ++k) {
+ for (KstVectorMap::ConstIterator k = _vectorsUsed.begin(); k != _vectorsUsed.end(); ++k) {
if (j.data() == k.data()) {
return true;
}
@@ -653,11 +660,11 @@
void KstEquation::setupConnections() {
- for (KstScalarMap::iterator i = ScalarsUsed.begin(); i != ScalarsUsed.end(); ++i) {
+ for (KstScalarMap::iterator i = _scalarsUsed.begin(); i != _scalarsUsed.end(); ++i) {
disconnect(i.data(), SIGNAL(tagChanged()), this, SLOT(reparse()));
connect(i.data(), SIGNAL(tagChanged()), this, SLOT(reparse()));
}
- for (KstVectorMap::iterator i = VectorsUsed.begin(); i != VectorsUsed.end(); ++i) {
+ for (KstVectorMap::iterator i = _vectorsUsed.begin(); i != _vectorsUsed.end(); ++i) {
disconnect(i.data(), SIGNAL(tagChanged()), this, SLOT(reparse()));
connect(i.data(), SIGNAL(tagChanged()), this, SLOT(reparse()));
}
--- branches/work/kst/1.6/kst/src/libkstmath/kstequation.h #747079:747080
@@ -15,9 +15,6 @@
* *
***************************************************************************/
-/** A class for handling equations for kst
- *@author C. Barth Netterfield
- */
#ifndef KSTEQUATION_H
#define KSTEQUATION_H
@@ -83,8 +80,8 @@
private:
KstVectorMap::Iterator _xInVector, _xOutVector, _yOutVector;
Equation::Node *_pe;
- KstVectorMap VectorsUsed;
- KstScalarMap ScalarsUsed;
+ KstVectorMap _vectorsUsed;
+ KstScalarMap _scalarsUsed;
QString _equation;
bool _isValid : 1;
bool _doInterp : 1;
@@ -103,4 +100,3 @@
typedef KstObjectList<KstEquationPtr> KstEquationList;
#endif
-// vim: ts=2 sw=2 et
More information about the Kst
mailing list