X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezplot.cpp;h=8d7b516bb3dd495c98932cebdbe99437f39e4881;hp=965ef102ed7d32052b6b03f7d10c1da768bea019;hb=ee0105d74fec9d6bfd236e22e9e1d315e46c568e;hpb=806adf54f5b8d061662696b3b498bfab3cd8b2e6 diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 965ef10..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.15 2000/09/09 09:31:12 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 @@ -64,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; } @@ -338,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; } } @@ -521,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); @@ -908,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)