X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezplot.cpp;h=cb4e0ece37358d9e6a15a0210936f18f9d787abc;hp=099eff5ded8d050d0d067b225adfce18823b4429;hb=f13a8c004b8f182b42d9e4df2bcd7c7f030bf1ad;hpb=1a050c98763fbbc0662731b0b76953acede6f5d7 diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 099eff5..cb4e0ec 100644 --- a/libctgraphics/ezplot.cpp +++ b/libctgraphics/ezplot.cpp @@ -1,12 +1,10 @@ /***************************************************************************** ** FILE IDENTIFICATION ** -** EZPLOT +** ezplot.cpp ** ** This is part of the CTSim program -** Copyright (c) 1983-2001 Kevin Rosenberg -** -** $Id$ +** Copyright (c) 1983-2009 Kevin Rosenberg ** ** 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 @@ -1161,10 +1159,19 @@ EZPlot::symbol (int sym, double symwidth, double symheight) int EZPlot::axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp) { - if (min >= max || nint < 1) { - sys_error (ERR_WARNING, "Invalid params: min=%lf, max=%lf, num intervals=%d [axis_scale]", min, max, nint); + if (nint < 1) { + sys_error (ERR_WARNING, "No intervals to plot: num intervals=%d [axis_scale]", nint); return (FALSE); } + if (min >= max) { + double scaled = fabs(max) / 10; + if (scaled == 0) + scaled = 0.1; + *minp = min - scaled; + *maxp = max + scaled; + *nintp = 2; + return (TRUE); + } double eps = 0.025; double a = fabs(min);