[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Tue Jul 20 20:00:38 CEST 2004


CVS commit by arwalker: 

Keep the x-errors and y-errors within the plot.
Determine the x-axis ticks and y-axis ticks more efficiently.


  M +14 -14    kst2dplot.cpp   1.160


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.159:1.160
@@ -1088,6 +1088,5 @@ void Kst2DPlot::draw(QPainter &p, double
   if (_xLog) {
     /* Draw X Ticks */
-    for (i = -1; xtick_px * i + x_orig_px > xleft_bdr_px - 1; i--); // find starting i;
-    //i++;
+    i = (int)floor( 5.0 * ( xleft_bdr_px - 1.0 - x_orig_px ) / xtick_px );
     for (;xtick_px * i + x_orig_px < x_px - xright_bdr_px + 1; i++) {
       // draw major ticks
@@ -1124,6 +1123,5 @@ void Kst2DPlot::draw(QPainter &p, double
   } else {
     /* Draw X Ticks */
-    for (i = -1; xtick_px * i / 5.0 + x_orig_px > xleft_bdr_px - 1; i--); // find starting i
-    i++;
+    i = (int)ceil( 5.0 * ( xleft_bdr_px - 1.0 - x_orig_px ) / xtick_px );
     for (; xtick_px * i / 5 + x_orig_px < x_px - xright_bdr_px ; i++) {
       X1 = x_orig_px + (double)i * xtick_px / 5.0;
@@ -1153,6 +1151,5 @@ void Kst2DPlot::draw(QPainter &p, double
   /* Draw Y Ticks */
   if (_yLog) {
-    for (i = -1; ytick_px * i + y_orig_px > ytop_bdr_px - 1; i--);
-    //i++;
+    i = (int)floor( 5.0 * ( ytop_bdr_px - 1.0 - y_orig_px ) / ytick_px );
     for (; ytick_px * i + y_orig_px < y_px - ybot_bdr_px + 1; i++) {
       // draw major ticks
@@ -1185,6 +1182,5 @@ void Kst2DPlot::draw(QPainter &p, double
     }
   } else {
-    for (i = -1; ytick_px * i / 5 + y_orig_px > ytop_bdr_px - 1; i--);
-    i++;
+    i = (int)ceil( 5.0 * ( ytop_bdr_px - 1.0 - y_orig_px ) / ytick_px );
     for (; ytick_px * i / 5 + y_orig_px < y_px - ybot_bdr_px + 1; i++) {
       Y1 = y_orig_px + (double)i * ytick_px / 5.0;
@@ -1255,7 +1251,11 @@ void Kst2DPlot::draw(QPainter &p, double
       if (c->xIsRising()) {
         i0 = c->getIndexNearX(x_min);
-        if (i0>0) i0--;
+        if (i0>0) {
+          i0--;
+        }
         iN = c->getIndexNearX(x_max);
-        if (iN<c->sampleCount() - 1) iN++;
+        if (iN<c->sampleCount() - 1) {
+          iN++;
+        }
       } else {
         i0 = 0;
@@ -1443,5 +1443,5 @@ void Kst2DPlot::draw(QPainter &p, double
           do_high_flag = true;
           c->getEXPoint(i_pt, rX, rY, rEX);
-          EX = _m_X * rEX;
+          EX = fabs( _m_X * rEX );
           X1 = _m_X * rX + _b_X - EX;
           X2 = _m_X * rX + _b_X + EX;
@@ -1457,5 +1457,5 @@ void Kst2DPlot::draw(QPainter &p, double
 
           if (X1 >= Lx && X2 <= Hx && Y1 >= Ly && Y1 <= Hy) {
-            p.drawLine((int)X1, (int) Y1, (int) X2, (int) Y1);
+            p.drawLine((int)X1, (int)Y1, (int)X2, (int)Y1);
             if (do_low_flag) {
               p.drawLine((int)X1, (int)Y1 + c->Point.getDim(&p),
@@ -1478,5 +1478,5 @@ void Kst2DPlot::draw(QPainter &p, double
           do_high_flag = true;
           c->getEYPoint(i_pt, rX, rY, rEY);
-          EY = _m_Y * rEY;
+          EY = fabs( _m_Y * rEY );
           X1 = _m_X * rX + _b_X;
           Y1 = _m_Y * rY + _b_Y - EY;
@@ -1492,5 +1492,5 @@ void Kst2DPlot::draw(QPainter &p, double
 
           if (X1 >= Lx && X1 <= Hx && Y1 >= Ly && Y2 <= Hy) {
-            p.drawLine((int)X1, (int) Y1, (int) X1, (int) Y2);
+            p.drawLine((int)X1, (int)Y1, (int)X1, (int)Y2);
             if (do_low_flag) {
               p.drawLine((int)X1 + c->Point.getDim(&p), (int)Y1,





More information about the Kst mailing list