X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezplot.cpp;h=519b7f97396bd398cd710b4e03f841d8d1077090;hp=6ffd0b05b2f2fc9bc2b9f090b64987dd3cd26774;hb=c85a5b31119b4e0903144c55441717a7ad1e0b8b;hpb=711cae0ee02e046370fdb4d6c6f440596ff71980 diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 6ffd0b0..519b7f9 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.7 2000/07/28 08:28:08 kevin Exp $ +** $Id: ezplot.cpp,v 1.8 2000/07/28 10:51:31 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 @@ -41,16 +41,10 @@ EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n, int c x = new double [n]; y = new double [n]; -#if 1 - for (int i = 0; i < n; i++) { - x[i] = xData[i]; - y[i] = yData[i]; - } -#else int copyCount = n * sizeof(double); memcpy (x, xData, copyCount); memcpy (y, yData, copyCount); -#endif + m_iPointCount = n; m_iColor = color; m_iLineStyle = linestyle; @@ -88,6 +82,17 @@ EZPlot::addCurve (const float x[], const double y[], int num) addCurve (dx, y, num); } +void +EZPlot::addCurve (const double x[], const float y[], int num) +{ + double dy [num]; + + for (int i = 0; i < num; i++) + dy[i] = y[i]; + + addCurve (x, dy, num); +} + void EZPlot::addCurve (const double x[], const double y[], int num) @@ -95,21 +100,8 @@ EZPlot::addCurve (const double x[], const double y[], int num) if (num < 1) return; - int iNumCurves = m_vecCurves.size(); - - if (o_unknowncurves == FALSE && iNumCurves >= o_reqcurves) - clearCurves (); - - if (o_unknowncurves == TRUE || iNumCurves < o_reqcurves) { - EZPlotCurve* pCurve = new EZPlotCurve (x, y, num, o_color, o_linestyle, o_symbol, o_symfreq, c_legend); - m_vecCurves.push_back (pCurve); - } - - iNumCurves = m_vecCurves.size(); // recalculate - if (o_unknowncurves == FALSE && iNumCurves >= o_reqcurves) { - plot (); - clearCurves (); - } + EZPlotCurve* pCurve = new EZPlotCurve (x, y, num, o_color, o_linestyle, o_symbol, o_symfreq, c_legend); + m_vecCurves.push_back (pCurve); } @@ -122,13 +114,21 @@ EZPlot::~EZPlot () void EZPlot::clearCurves () { - for (EZPlotCurveIterator i = m_vecCurves.begin(); i != m_vecCurves.end(); i++) delete *i; + for (EZPlotCurveIterator i = m_vecCurves.begin(); i != m_vecCurves.end(); i++) + delete *i; m_vecCurves.erase (m_vecCurves.begin(), m_vecCurves.end()); + initPlotSettings(); } EZPlot::EZPlot (SGP& sgp) : rSGP (sgp) +{ + initPlotSettings(); +} + +void +EZPlot::initPlotSettings () { curveinteract = -1; @@ -140,9 +140,6 @@ EZPlot::EZPlot (SGP& sgp) c_title = ""; c_legend = ""; - o_reqcurves = 1; - o_unknowncurves = FALSE; - o_xporigin = 0.0; o_yporigin = 0.0; o_xlength = 1.0; @@ -192,16 +189,13 @@ EZPlot::EZPlot (SGP& sgp) /* NAME - * plot INTERNAL: Plots all curves collected by ezplot() + * plot Plots all curves collected by addCurves () * * SYNOPSIS * plot() * * DESCRIPTION - * This routine plots the curves that have stored by ezplot(). - * - * CALLED BY - * EZPLOT() only + * This routine plots the curves that have stored by addCurves(). * * CALLS * drawAxes() & make_numfmt() @@ -513,13 +507,11 @@ EZPlot::plot () /* Convert WC in graph boundary to axis boundary */ rSGP.setWindow (xgw_min, ygw_min, xgw_max, ygw_max); /* Graph boundary */ rSGP.setViewport (xgn_min, ygn_min, xgn_max, ygn_max); - double xminTemp = xa_min, xmaxTemp = xa_max; double yminTemp = ya_min, ymaxTemp = ya_max; rSGP.transformNDCtoMC (&xminTemp, &yminTemp); // calc WC to axis boundaries - rSGP.transformNDCtoMC (&yminTemp, &ymaxTemp); - - rSGP.setWindow (xminTemp, yminTemp, xmaxTemp, ymaxTemp); // Set window to axis boundaries + rSGP.transformNDCtoMC (&xmaxTemp, &ymaxTemp); + rSGP.setWindow (xminTemp, yminTemp, xmaxTemp, ymaxTemp); // Set window to axis boundaries rSGP.setViewport (xa_min, ya_min, xa_max, ya_max); symwidth = charwidth * (xgw_max - xgw_min);