** EZPLOT
**
** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
+** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.27 2001/01/02 09:58:11 kevin Exp $
+** $Id: ezplot.cpp,v 1.31 2001/02/20 04:48:45 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
EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n)
-: x(NULL), y(NULL)
+: x(new double[n]), y(new double[n])
{
- x = new double [n];
- y = new double [n];
-
- int copyCount = n * sizeof(double);
- memcpy (x, xData, copyCount);
- memcpy (y, yData, copyCount);
+ for (int i = 0; i < n; i++) {
+ x[i] = xData[i];
+ y[i] = yData[i];
+ }
m_iPointCount = n;
}
}
void
-EZPlot::addCurve (const double x[], const float y[], int num)
+EZPlot::addCurve (const double* const x, const float* const y, int num)
{
double* dy = new double [num];
void
-EZPlot::addCurve (const double x[], const double y[], int num)
+EZPlot::addCurve (const double* const x, const double* const y, int num)
{
if (num < 1)
return;
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;
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;
}
}
}
- }
-
+ }
}