r187: *** empty log message ***
[ctsim.git] / libctgraphics / ezplot.cpp
index 348dd3f170d4fd06892c50d73b4e9bea8422f9cd..fb823b505f15feb1c7f0bbdee9ec052fab08190b 100644 (file)
@@ -6,7 +6,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ezplot.cpp,v 1.10 2000/08/19 22:59:06 kevin Exp $
+**  $Id: ezplot.cpp,v 1.13 2000/09/02 05:10:39 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
@@ -71,6 +71,18 @@ EZPlot::addCurve (const double *y, int n)
 }
 
 
+void 
+EZPlot::addCurve (const float *y, int n)
+{
+  double yDouble [n];
+
+  for (int i = 0; i < n; i++)
+    yDouble[i] = y[i];
+
+  addCurve (yDouble, n);
+}
+
+
 void
 EZPlot::addCurve (const float x[], const double y[], int num)
 {
@@ -300,7 +312,8 @@ EZPlot::plot ()
   xtl_wid = x_fldwid * charwidth;              /* calc size of tick labels */
   ytl_wid = y_fldwid * charwidth;
   tl_height = charheight;
-  
+
+  //  rSGP.getViewport (xp_min, yp_min, xp_max, yp_max);
   /* calculate the extent of the plot frame */
   xp_min = o_xporigin;
   yp_min = o_yporigin;
@@ -320,7 +333,7 @@ EZPlot::plot ()
   /* adjust frame for title */
   if (c_title.length() > 0)
     ya_max -= 2.5 * charheight;
-  title_row = ya_max + 0.5 * charheight;
+  title_row = ya_max + charheight;
 
   /* calculate legend box boundaries */
   int max_leg = 0;                     /* longest legend in characters */
@@ -574,7 +587,9 @@ EZPlot::drawAxes(void)
   rSGP.setViewport (xp_min, yp_min, xp_max, yp_max);
   
   if (c_title.length() > 0) {
-    rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - c_title.length()*charwidth, title_row);
+    double wText, hText;
+    rSGP.getTextExtent (c_title.c_str(), &wText, &hText);
+    rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - wText/2, title_row);
     rSGP.setTextSize (charheight * 2.0);
     rSGP.setTextColor (clr_title, -1);
     rSGP.drawText (c_title);
@@ -827,7 +842,7 @@ int
 EZPlot::axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp)
 {
   if (min >= max || nint < 1) {
-    sys_error (ERR_WARNING, "Invalid params: min=%lf, min=%lf, num intervals=%d [axis_scale]", min, max, nint);
+    sys_error (ERR_WARNING, "Invalid params: min=%lf, max=%lf, num intervals=%d [axis_scale]", min, max, nint);
     return (FALSE);
   }