Summary: | Equations do not always update | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Andrew Walker <arwalker> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Andrew Walker
2007-05-11 00:32:54 UTC
This is not a problem when the vector is read from file. The problem is directly caused by KstEquation::FillY(...) line 500: for (ctx.i = i0; ctx.i < _ns; ++ctx.i) { as i0 and _ns are the same value for KstSVector but different for KstRVector. Thus, the equation is recalculated in the latter case, but not the former. An effort is made to avoid recalculating the equation as much as possible, but for when using a KstRVector as the x-axis this optimisation is avoided - and so the equation is updated. In the case of a KstSVector though the optimisation is utilised - and nothing is recalculated. This optimisation is incorrect as it ignores the possibility that a scalar in the equation may have been updated. SVN commit 683027 by arwalker: BUG:145289 Ensure that equations always update by avoiding optimisation when necessary M +9 -5 kstequation.cpp M +9 -12 kstequation.h --- branches/work/kst/1.5/kst/src/libkstmath/kstequation.cpp #683026:683027 @@ -219,7 +219,7 @@ KstObject::UpdateType rc = NO_CHANGE; // if force, rc = UPDATE anyway. if (force || xUpdated || usedUpdated) { - _isValid = FillY(force); + _isValid = FillY(force, usedUpdated); rc = UPDATE; } v = *_yOutVector; @@ -381,9 +381,10 @@ /* Fill Y: Evaluates the equation */ /* */ /************************************************************************/ -bool KstEquation::FillY(bool force) { - int v_shift=0, v_new; - int i0=0; +bool KstEquation::FillY(bool force, bool usedUpdated) { + int v_shift = 0; + int v_new; + int i0 = 0; int ns; writeLockInputsAndOutputs(); @@ -409,7 +410,7 @@ if (!xv->resize(_ns)) { // FIXME: handle error? unlockInputsAndOutputs(); - return false; + return false; } if (!yv->resize(_ns)) { // FIXME: handle error? @@ -419,6 +420,9 @@ yv->zero(); i0 = 0; // other vectors may have diffent lengths, so start over v_shift = _ns; + } else if (usedUpdated) { + i0 = 0; + v_shift = _ns; } else { // calculate shift and new samples // only do shift optimization if all used vectors are same size and shift --- branches/work/kst/1.5/kst/src/libkstmath/kstequation.h #683026:683027 @@ -67,9 +67,9 @@ virtual QString yVTag() const { return (*_yOutVector)->tagName(); } const KstCurveHintList *curveHints() const; - + virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap); - + virtual void replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject); virtual void replaceDependency(KstVectorPtr oldVector, KstVectorPtr newVector); @@ -81,25 +81,22 @@ void reParse(); private: - QString _equation; - + KstVectorMap::Iterator _xInVector, _xOutVector, _yOutVector; + Equation::Node *_pe; KstVectorMap VectorsUsed; KstScalarMap ScalarsUsed; - void setupConnections(); - - void commonConstructor(const QString& in_tag, const QString& equation); - - bool FillY(bool force = false); + QString _equation; bool _isValid : 1; bool _doInterp : 1; - int _numNew, _numShifted, _interp, _ns; + void setupConnections(); + void commonConstructor(const QString& in_tag, const QString& equation); + bool FillY(bool force, bool usedUpdated); + static const QString XINVECTOR; static const QString XOUTVECTOR; static const QString YOUTVECTOR; - KstVectorMap::Iterator _xInVector, _xOutVector, _yOutVector; - Equation::Node *_pe; }; typedef KstSharedPtr<KstEquation> KstEquationPtr; |