[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sun Jun 15 18:58:57 CEST 2003


CVS commit by staikos: 

switch to using NaN for NOPOINT


  M +6 -5      kstequationcurve.cpp   1.23
  M +3 -3      kstplot.cpp   1.12
  M +6 -4      kstvector.cpp   1.20
  M +9 -1      kstvector.h   1.24


--- kdeextragear-2/kst/kst/kstequationcurve.cpp  #1.22:1.23
@@ -172,6 +172,4 @@ void KstEquationCurve::commonConstructor
                                          const QString &in_equation,
                                          const QColor &in_color) {
-  int i;
-
   _typeString = i18n("Equation");
   Equation = in_equation;
@@ -644,7 +642,10 @@ bool KstEquationCurve::FillY(bool force)
   }
 
+  double *rawv = _outputVectors[0]->value();
+  KstVectorPtr iv = _inputVectors[0];
+
   for(i = i0; i < NS; ++i) {
     //X = (float)i*x_step + MinX;
-    X = _inputVectors[0]->interpolate(i, NS);
+    X = iv->interpolate(i, NS);
     gq.rewind();
     numstack.reset();
@@ -776,7 +777,7 @@ bool KstEquationCurve::FillY(bool force)
     }
     if (MError == 'n') {
-      _outputVectors[0]->value()[i] = numstack.Pop();
+      rawv[i] = numstack.Pop();
     } else {
-      _outputVectors[0]->value()[i] = NOPOINT;
+      rawv[i] = KST::NOPOINT;
     }
     MError = 'n';

--- kdeextragear-2/kst/kst/kstplot.cpp  #1.11:1.12
@@ -994,7 +994,7 @@ void KstPlot::paint(QPainter &p, double 
         nopoint = false;
         c->getPoint(0, rX, rY);
-        if (rX == NOPOINT)
+        if (isnan(rX))
           nopoint = true;
-        if (rY==NOPOINT)
+        if (isnan(rY))
           nopoint = true;
         if (XLog) {
@@ -1030,5 +1030,5 @@ void KstPlot::paint(QPainter &p, double 
           nopoint = false;
           c->getPoint(i_pt, rX, rY);
-          while (((rX==NOPOINT) || (rY==NOPOINT)) && (i_pt<ns)) {
+          while ((isnan(rX) || isnan(rY)) && i_pt < ns) {
             nopoint = true;
             i_pt++;

--- kdeextragear-2/kst/kst/kstvector.cpp  #1.19:1.20
@@ -28,4 +28,6 @@
 #include "kstdoc.h"
 
+double KST::NOPOINT = 0.0/0.0; // NaN
+
 #define INITSIZE 1
 
@@ -88,6 +90,6 @@ double KstVector::interpolate(int in_i, 
   }
 
-  if (_v[j+1] == NOPOINT || _v[j] == NOPOINT) {
-    return NOPOINT;
+  if (isnan(_v[j+1]) || isnan(_v[j])) {
+    return KST::NOPOINT;
   }
 
@@ -175,5 +177,5 @@ KstObject::UpdateType KstVector::update(
     SSum->setValue(_v[0]);
     for (i = 1; i < _size; i++) {
-      if (_v[i] != NOPOINT) {
+      if (finite(_v[i])) {
         SSum->setValue(SSum->value() + _v[i]);
         if (SMax->value() < _v[i])
@@ -189,5 +191,5 @@ KstObject::UpdateType KstVector::update(
       SMinPos->setValue(SMax->value());
       for (i = 0; i < _size; i++) {
-        if (_v[i] != NOPOINT && SMinPos->value() > _v[i]) {
+        if (finite(_v[i]) && SMinPos->value() > _v[i]) {
           SMinPos->setValue(_v[i]);
         }

--- kdeextragear-2/kst/kst/kstvector.h  #1.23:1.24
@@ -25,7 +25,15 @@
 #include "kstscalarlist.h"
 
+#include <math.h>
+
 class KstScalar;
 
-#define NOPOINT (1.23E100)
+#define IS_POINT(x) (!isnan(x))
+#define NOT_POINT(x) (isnan(x))
+
+namespace KST {
+  // Do not compare against this, only assign it and use the helpers above.
+  extern double NOPOINT;
+};
 
 /**A class for handling data vectors for kst.




More information about the Kst mailing list