** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.15 2000/09/09 09:31:12 kevin Exp $
+** $Id: ezplot.cpp,v 1.19 2000/12/18 06:32:13 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
// Defaults
static const double TICKRATIO = 0.4; // ratio of minor to major tick lengths
static const int MAXNUMFMT = 15; // maximum length of a numeric format
-static const double DEF_CHARHEIGHT = (1./43.); //size of characters in NDC
-static const double DEF_CHARWIDTH = (1./80.); // size of characters in NDC
static const int DEF_CURVE_CLR = C_RED;
-EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n, int color, int linestyle, int symbol, int symfreq, const string& legend)
+EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n, int color, int linestyle, int symbol, int symfreq, const std::string& legend)
: x(NULL), y(NULL), m_sLegend (legend)
{
x = new double [n];
void
EZPlot::addCurve (const double *y, int n)
{
- double x [n];
+ double* x = new double [n];
for (int i = 0; i < n; i++)
x[i] = i;
addCurve (x, y, n);
+ delete x;
}
void
EZPlot::addCurve (const float *y, int n)
{
- double yDouble [n];
+ double* yDouble = new double [n];
for (int i = 0; i < n; i++)
yDouble[i] = y[i];
addCurve (yDouble, n);
+ delete yDouble;
}
void
EZPlot::addCurve (const float x[], const double y[], int num)
{
- double dx [num];
+ double* dx = new double [num];
for (int i = 0; i < num; i++)
dx[i] = x[i];
addCurve (dx, y, num);
+ delete dx;
}
void
EZPlot::addCurve (const double x[], const float y[], int num)
{
- double dy [num];
+ double* dy = new double [num];
for (int i = 0; i < num; i++)
dy[i] = y[i];
addCurve (x, dy, num);
+
+ delete dy;
}
void
EZPlot::initPlotSettings ()
{
- charheight = DEF_CHARHEIGHT;
- charwidth = DEF_CHARWIDTH;
+ charheight = rSGP.getCharHeight();
+ charwidth = rSGP.getCharWidth();
c_xlabel = "";
c_ylabel = "";
// calculate legend box boundaries
int max_leg = 0; // longest legend in characters
int num_leg = 0; // number of legend titles
- for (EZPlotCurveConstIterator iterCurve = m_vecCurves.begin(); iterCurve != m_vecCurves.end(); iterCurve++) {
- const EZPlotCurve& curve = **iterCurve;
+ for (EZPlotCurveConstIterator iterCurve2 = m_vecCurves.begin(); iterCurve2 != m_vecCurves.end(); iterCurve2++) {
+ const EZPlotCurve& curve = **iterCurve2;
int nLegend = curve.m_sLegend.length();
if (nLegend > 0) {
++num_leg;
- max_leg = max (max_leg, nLegend);
+ if (nLegend > max_leg)\r
+ nLegend = max_leg;
}
}
double symwidth = charwidth;
double symheight = charheight;
- for (EZPlotCurveIterator iterCurve = m_vecCurves.begin(); iterCurve != m_vecCurves.end(); iterCurve++) {
- const EZPlotCurve& curve = **iterCurve;
+ for (EZPlotCurveIterator iterCurve3 = m_vecCurves.begin(); iterCurve3 != m_vecCurves.end(); iterCurve3++) {
+ const EZPlotCurve& curve = **iterCurve3;
rSGP.setColor (curve.m_iColor);
if (o_ytlabel == TRUE && axis_near == FALSE) {
snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
rSGP.moveAbs (yaxispos + ytl_ofs, y + 0.5 * charheight);
- rSGP.setTextColor (clr_number, -1);
+ rSGP.setTextColor (clr_number, -1);\r
+ rSGP.setTextAngle(HALFPI);
rSGP.drawText (str);
+ rSGP.setTextAngle(0.);\r
}
}
} // Y - Axis
double delta = (maxval - minval) / nint;
double absmin = fabs(minval);
- double absmax = fabs(maxval);
- double logt = log10( max(absmin, absmax) );
+ double absmax = fabs(maxval);\r
+ if (absmin > absmax)\r
+ absmax = absmin;
+ double logt = log10( absmax );
if (fabs(logt) >= 6) { // use exponential format
if (fabs(logt) > 99)