[Kst] branches/work/kst/portto4/kst/src

George Staikos staikos at kde.org
Fri Sep 28 21:31:07 CEST 2007


SVN commit 718468 by staikos:

libkstmath now builds and almost links


 M  +4 -0      libkst/kstmath.h  
 M  +7 -0      libkstmath/enodes.cpp  
 M  +4 -1      libkstmath/kstbasicplugin.cpp  
 M  +1 -2      libkstmath/kstcolorsequence.cpp  
 M  +1 -1      libkstmath/kstimage.cpp  
 M  +6 -4      libkstmath/psdcalculator.cpp  


--- branches/work/kst/portto4/kst/src/libkst/kstmath.h #718467:718468
@@ -88,7 +88,11 @@
 #ifdef Q_WS_WIN32
 #define isnan _isnan
 #define finite _finite
+#ifndef M_PI
+#define M_PI 3.14159265358979323
 #endif
+#define isinf !_finite
+#endif
 
 inline double logXLo(double x, double base = 10.0) {
   if (base == 10.0) {
--- branches/work/kst/portto4/kst/src/libkstmath/enodes.cpp #718467:718468
@@ -19,7 +19,12 @@
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
+#include <qnamespace.h>
+#ifndef Q_WS_WIN32
 #include <unistd.h>
+#else
+#define strcasecmp _stricmp
+#endif
 
 #include "kst_i18n.h"
 
@@ -379,7 +384,9 @@
   {"acos", &acos},
   {"asin", &asin},
   {"atan", &atan},
+#ifndef Q_WS_WIN32
   {"cbrt", &cbrt},
+#endif
   {"cos",  &cos},
   {"cosh", &cosh},
   {"cot",  &cot},
--- branches/work/kst/portto4/kst/src/libkstmath/kstbasicplugin.cpp #718467:718468
@@ -16,10 +16,13 @@
  ***************************************************************************/
 
 #include <stdlib.h>
-#include <unistd.h>
 
 #include <QTextDocument>
 
+#ifndef Q_WS_WIN32
+#include <unistd.h>
+#endif
+
 #include "kst_i18n.h"
 
 #include "kstdebug.h"
--- branches/work/kst/portto4/kst/src/libkstmath/kstcolorsequence.cpp #718467:718468
@@ -15,13 +15,12 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <math.h>
-
 // application specific includes
 #include "kstcolorsequence.h"
 #include "kstsettings.h"
 #include <QVector>
 #include <qapplication.h>
+#include <kstmath.h>
 
 // Default palette that is used if "Kst Colors" is not found.
 static const char *const colors[] = { "red",
--- branches/work/kst/portto4/kst/src/libkstmath/kstimage.cpp #718467:718468
@@ -824,7 +824,7 @@
     int l = bound.left(), r = bound.right(), t = bound.top(), b = bound.bottom();
     // draw the color palette
     for (int i = l; i <= r; i++) {
-      int index = (int)floor(((i - l) * (_pal.count() - 1)) / (r - l));
+      int index = (int)floor(static_cast<double>(((i - l) * (_pal.count() - 1))) / (r - l));
       QColor sliceColor = _pal.value(index).rgb();
       p->setPen(QPen(sliceColor, 0));
       p->drawLine(i, t, i, b);
--- branches/work/kst/portto4/kst/src/libkstmath/psdcalculator.cpp #718467:718468
@@ -19,7 +19,6 @@
 */
 
 #include <assert.h>
-#include <math.h>
 
 #include "kst_i18n.h"
 
@@ -27,6 +26,9 @@
 #include "psdcalculator.h"
 #include "kstvector.h"
 
+#include <qnamespace.h>
+#include <kstmath.h>
+
 extern "C" void rdft(int n, int isgn, double *a);
 
 #define PSDMINLEN 2
@@ -88,7 +90,7 @@
     case WindowConnes: 
       for (int i = 0; i < _awLen; ++i) {
         x = i - a;
-        _w[i] = pow(1.0 - (x * x) / (a * a), 2.0);
+        _w[i] = pow(static_cast<double>(1.0 - (x * x) / (a * a)), 2);
         sW += _w[i] * _w[i];
       }
       break;
@@ -119,7 +121,7 @@
     case WindowHann:
       for (int i = 0; i < _awLen; ++i) {
         x = i - a;
-        _w[i] = pow(cos(M_PI * x/(2.0 * a)), 2.0);
+        _w[i] = pow(static_cast<double>(cos(M_PI * x/(2.0 * a))), 2);
         sW += _w[i] * _w[i];
       }
       break;
@@ -327,7 +329,7 @@
     psdloglen = PSDMAXLEN;
   }
 
-  return int(pow(2, psdloglen - 1));
+  return int(pow(2.0, psdloglen - 1));
 }
 
 // vim: ts=2 sw=2 et


More information about the Kst mailing list