X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezplot.cpp;h=8d7b516bb3dd495c98932cebdbe99437f39e4881;hp=29f2c7ff0e6d6a2203d9a4072438c72e1b898210;hb=ee0105d74fec9d6bfd236e22e9e1d315e46c568e;hpb=3147cd44cff6132e51eac1a179c1fc3d405faacc diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 29f2c7f..8d7b516 100644 --- a/libctgraphics/ezplot.cpp +++ b/libctgraphics/ezplot.cpp @@ -6,7 +6,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ezplot.cpp,v 1.14 2000/09/04 09:06:46 kevin Exp $ +** $Id: ezplot.cpp,v 1.16 2000/12/06 01:46:43 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 @@ -25,6 +25,9 @@ #include "ezplot.h" #include +#ifdef __GNUWIN32__ +int snprintf (char *, size_t, const char*, ...); +#endif // Defaults static const double TICKRATIO = 0.4; // ratio of minor to major tick lengths @@ -61,47 +64,52 @@ EZPlotCurve::~EZPlotCurve () 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; } @@ -335,12 +343,13 @@ EZPlot::plot () // 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) + nLegend = max_leg; } } @@ -518,8 +527,8 @@ EZPlot::plot () 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); @@ -905,8 +914,10 @@ EZPlot::make_numfmt (char *fmtstr, int *fldwid, int *nfrac, double minval, doubl double delta = (maxval - minval) / nint; double absmin = fabs(minval); - double absmax = fabs(maxval); - double logt = log10( max(absmin, absmax) ); + double absmax = fabs(maxval); + if (absmin > absmax) + absmax = absmin; + double logt = log10( absmax ); if (fabs(logt) >= 6) { // use exponential format if (fabs(logt) > 99)