r384: Added first vesion of EZPlotDialog
[ctsim.git] / libctgraphics / ezplot.cpp
index 260d5badbc68b295c84a7f4b7bbc169526614bf4..be1c5d257309c0033e482dd5cfa1d530966035dd 100644 (file)
@@ -6,7 +6,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ezplot.cpp,v 1.27 2001/01/02 09:58:11 kevin Exp $
+**  $Id: ezplot.cpp,v 1.29 2001/01/12 16:41:56 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -723,18 +723,20 @@ EZPlot::plot (SGP* pSGP)
   if (o_yaxis == NOAXIS || o_ytlabel == FALSE)
     ytl_ofs = 0.0;
   else if (o_yticks == LEFT) {
-    double xExtent, yExtent;
+    double xExtentMin, xExtentMax, yExtent;
     char s[1024];
-    snprintf (s, sizeof(s), y_numfmt, 0);
-    m_pSGP->getTextExtent (s, &xExtent, &yExtent);
-    ytl_ofs = -2.0 * charwidth - xExtent;
+    snprintf (s, sizeof(s), y_numfmt, ymin);
+    m_pSGP->getTextExtent (s, &xExtentMin, &yExtent);
+    snprintf (s, sizeof(s), y_numfmt, ymax);
+    m_pSGP->getTextExtent (s, &xExtentMax, &yExtent);
+    if (xExtentMin > xExtentMax)
+      xExtentMax = xExtentMin;
+    ytl_ofs = -xExtentMax;
   } else if (o_yticks == RIGHT)
     ytl_ofs = 1.5 * charwidth;
   
   xa_max -= 0.7 * x_fldwid * charwidth; // make room for last x tick label
 
-
-
   xt_min = xa_min;
   yt_min = ya_min;
   xt_max = xa_max;
@@ -754,11 +756,11 @@ EZPlot::plot (SGP* pSGP)
   
   if (ytl_ofs != 0.0 && s_xcross == FALSE) {
     if (o_yticks == LEFT) {
-      xa_min += (2 + y_fldwid) * charwidth;
+      xa_min += 2*charwidth - ytl_ofs; // (2 + y_fldwid) * charwidth;
       xt_min = xa_min;
     } else if (o_yticks == RIGHT) {
       xa_min += 0.0;
-      xt_min = xa_min + ytl_ofs + y_fldwid * charwidth;
+      xt_min = xa_min + ytl_ofs; // + y_fldwid * charwidth;
     }
   } else
     xt_min = xa_min;
@@ -886,8 +888,7 @@ EZPlot::plot (SGP* pSGP)
           }
         }
     }
-  }
-  
+  }  
 }