[Kst] extragear/graphics/kst/src/libkstmath

George Staikos staikos at kde.org
Tue May 9 14:00:59 CEST 2006


SVN commit 538957 by staikos:

Follow the coding style, and remove an unnecessary map lookup


 M  +8 -11     kstvcurve.cpp  


--- trunk/extragear/graphics/kst/src/libkstmath/kstvcurve.cpp #538956:538957
@@ -1615,14 +1615,12 @@
 double KstVCurve::distanceToPoint(double xpos, double dx, double ypos) const {
 // find the y distance between the curve and a point.
   KstVectorPtr xv = *_inputVectors.find(COLOR_XVECTOR);
-  KstVectorPtr yv = *_inputVectors.find(COLOR_YVECTOR);
-  if (!xv || !yv) {
+  if (!xv) {
     return 0; // anything better we can do?
   }
 
-  if(hasLines() && xv->isRising())
+  if (hasLines() && xv->isRising()) {
   // if hasLines then we should find the distance between the curve and the point, not the data and the point. if isRising because it is (probably) to slow to use this technique if the data is unordered.
-  {
     // borrowed from indexNearX. use binary search to find the indices immediately above and below our xpos.
     int i_top = NS - 1;
     int i_bot = 0;
@@ -1640,16 +1638,14 @@
     // end borrowed
 
     double x_bot, y_bot, x_top, y_top;
-    point(i_bot,x_bot,y_bot);
-    point(i_top,x_top,y_top);
+    point(i_bot, x_bot, y_bot);
+    point(i_top, x_top, y_top);
 
-    double near_y = (y_top-y_bot)*(xpos-x_bot) + y_bot; // calculate y value for line segment between x_bot and x_top.
+    double near_y = (y_top - y_bot) * (xpos - x_bot) + y_bot; // calculate y value for line segment between x_bot and x_top.
 
-    return( fabs(ypos - near_y) );
-  }
-  else
+    return fabs(ypos - near_y);
+  } else {
   // !hasLines- find the distance between the data and the point.
-  {
     int i_near_x = getIndexNearXY(xpos, dx, ypos);
     double near_x, near_y;
     point(i_near_x, near_x, near_y);
@@ -1657,6 +1653,7 @@
   }
 }
 
+
 void KstVCurve::paintLegendSymbol(KstPainter *p, const QRect& bound) {
   p->save();
   if (hasLines()) {


More information about the Kst mailing list