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

Barth Netterfield netterfield at astro.utoronto.ca
Fri Jan 6 20:44:25 UTC 2012


SVN commit 1272105 by netterfield:

Improve line drawing with antialiasing.


 M  +16 -12    curve.cpp  


--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #1272104:1272105
@@ -37,7 +37,7 @@
 #include <iostream>
 
 // #define DEBUG_VECTOR_CURVE
-// #define BENCHMARK
+#define BENCHMARK
 
 #ifndef KDE_IS_LIKELY
 #if __GNUC__ - 0 >= 3
@@ -846,7 +846,8 @@
 #ifdef BENCHMARK
                 ++numberOfLinesDrawn;
 #endif
-                _lines.append(QLineF(X2, minY, X2, maxY));
+                double fX2 = floor(X2);
+                _lines.append(QLineF(fX2, minY, fX2, maxY));
               }
             }
             overlap = false;
@@ -895,23 +896,24 @@
                     ++numberOfLinesDrawn;
 #endif
                   }
+                  double fX2 = floor(X2);
 
                   if (KDE_ISUNLIKELY(minY == maxY)) {
-                    points.append(QPointF(X2, maxY));
+                    points.append(QPointF(fX2, maxY));
                   } else if (KDE_ISUNLIKELY(Y2 == minY)) {
-                    points.append(QPointF(X2, maxY));
-                    points.append(QPointF(X2, minY));
+                    points.append(QPointF(fX2, maxY));
+                    points.append(QPointF(fX2, minY));
                   } else if (KDE_ISUNLIKELY(Y2 == maxY)) {
-                    points.append(QPointF(X2, minY));
-                    points.append(QPointF(X2, maxY));
+                    points.append(QPointF(fX2, minY));
+                    points.append(QPointF(fX2, maxY));
                   } else {
-                    points.append(QPointF(X2, minY));
-                    points.append(QPointF(X2, maxY));
+                    points.append(QPointF(fX2, minY));
+                    points.append(QPointF(fX2, maxY));
                     if (KDE_ISLIKELY(Y2 >= Ly && Y2 <= Hy)) {
-                      points.append(QPointF(X2, Y2));
+                      points.append(QPointF(fX2, Y2));
                     }
                   }
-                  lastPlottedX = X2;
+                  lastPlottedX = fX2;
                   lastPlottedY = Y2;
                 } else {
                   if (KDE_ISUNLIKELY(maxY > Hy && minY <= Hy)) {
@@ -931,10 +933,12 @@
 #ifdef BENCHMARK
   ++numberOfLinesDrawn;
 #endif
-                    _lines.append(QLineF(X2, minY, X2, maxY));
+                    double fX2 = floor(X2);
+                    _lines.append(QLineF(fX2, minY, fX2, maxY));
                   }
                 }
               }
+
               overlap = false;
             }
 


More information about the Kst mailing list