X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezset.cpp;h=efef8c162d9c8e98a8c7475ee24e35ed9d0f29db;hp=222b3cd5a77c08d1986847f7b0be87cf9002a160;hb=88fd1492afba7c103e2bedbaac0d69fb9bf3cf66;hpb=5c6b29ab4885308cc3381af6e0a68f4804956d2e diff --git a/libctgraphics/ezset.cpp b/libctgraphics/ezset.cpp index 222b3cd..efef8c1 100644 --- a/libctgraphics/ezset.cpp +++ b/libctgraphics/ezset.cpp @@ -1,12 +1,12 @@ /***************************************************************************** ** FILE IDENTIFICATION ** -** EZSET - Parameter control for EZPLOT +** EZSET - Parameter control for EZPLOT ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg +** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: ezset.cpp,v 1.15 2000/12/29 15:45:06 kevin Exp $ +** $Id$ ** ** 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 @@ -26,26 +26,26 @@ #include "ezplot.h" #include "pol.h" - -bool -EZPlot::ezset (const std::string& command) -{ - return ezset (command.c_str()); -} -bool +bool +EZPlot::ezset (const std::string& command) +{ + return ezset (command.c_str()); +} + +bool EZPlot::ezset (const char* const command) { - + return ezcmd (command); } -bool +bool EZPlot::ezcmd (const char* const comm) { m_pol.usefile (POL::P_USE_STR, ""); m_pol.set_inputline (comm); - + char str [POL::MAXTOK+1]; int code; bool retval = true; @@ -56,8 +56,8 @@ EZPlot::ezcmd (const char* const comm) } else retval = do_cmd (code); - - m_pol.closefile(); /* close input string file */ + + m_pol.closefile(); /* close input string file */ return (retval); } @@ -69,7 +69,7 @@ EZPlot::do_cmd (int lx) char strIn [1024]; int n; double f; - + switch (lx) { case S_TEXTSIZE: if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) { @@ -91,8 +91,8 @@ EZPlot::do_cmd (int lx) c_title = strIn; break; case S_LEGEND: - m_pol.readText (strIn, sizeof(strIn)); - if (m_iCurrentCurve >= 0) + m_pol.readText (strIn, sizeof(strIn)); + if (m_iCurrentCurve >= 0) setLegend (m_iCurrentCurve, strIn); break; case S_XLABEL: @@ -171,24 +171,24 @@ EZPlot::do_cmd (int lx) o_linestyle = SGP::LS_SOLID; break; case S_DASH: - int ls; - ls = SGP::LS_DASH1; - if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { + int ls; + ls = SGP::LS_DASH1; + if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { if (n == 1) ls = SGP::LS_DASH1; else if (n == 2) ls = SGP::LS_DASH2; else if (n == 3) ls = SGP::LS_DASH3; - else if (n == 4) - ls = SGP::LS_DASH4; - else if (n == 5) - ls = SGP::LS_DOTTED; - } - if (m_iCurrentCurve < 0) - o_linestyle = ls; - else - setLinestyle (m_iCurrentCurve, ls); + else if (n == 4) + ls = SGP::LS_DASH4; + else if (n == 5) + ls = SGP::LS_DOTTED; + } + if (m_iCurrentCurve < 0) + o_linestyle = ls; + else + setLinestyle (m_iCurrentCurve, ls); break; case S_NOLINE: o_linestyle = SGP::LS_NOLINE; @@ -197,11 +197,11 @@ EZPlot::do_cmd (int lx) case S_COLOR: if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { - if (n >= 0) { + if (n >= 0) { if (m_iCurrentCurve < 0) - o_color = n; - else - setColor (m_iCurrentCurve, n); + o_color = n; + else + setColor (m_iCurrentCurve, n); } else bad_option("The color you picked"); } @@ -283,36 +283,36 @@ EZPlot::do_cmd (int lx) case S_SYMBOL: if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { if (n > 0 && n <= MAXSYMBOL) { - if (m_iCurrentCurve < 0) - o_symbol = n; - else - setSymbol (m_iCurrentCurve, n); - } + if (m_iCurrentCurve < 0) + o_symbol = n; + else + setSymbol (m_iCurrentCurve, n); + } } else { if (m_pol.readWord("every",5) == TRUE) { - if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { + if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { int sym = 1; - if (n > 0) - sym = n; - if (m_iCurrentCurve < 0) - o_symfreq = sym; - else - setSymbolFreq (m_iCurrentCurve, sym); + if (n > 0) + sym = n; + if (m_iCurrentCurve < 0) + o_symfreq = sym; + else + setSymbolFreq (m_iCurrentCurve, sym); } } else if (m_pol.readWord ("none",4) == TRUE) { o_symbol = -1; } } break; - case S_CURVE: - if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { - if (n > 0) - m_iCurrentCurve = n - 1; - } else { - if (m_pol.readWord ("all",3) == TRUE) - m_iCurrentCurve = -1; - } - break; + case S_CURVE: + if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) { + if (n > 0) + m_iCurrentCurve = n - 1; + } else { + if (m_pol.readWord ("all",3) == TRUE) + m_iCurrentCurve = -1; + } + break; case S_XTICKS: if (m_pol.readUserToken(str,&lx) == FALSE) break; @@ -376,107 +376,107 @@ EZPlot::do_cmd (int lx) fprintf (stderr, "Unimplemented EZPLOT command\n"); break; } - + m_pol.reader (); return (true); } - -void -EZPlot::bad_option (char *opt) + +void +EZPlot::bad_option (const char *opt) { sys_error (ERR_WARNING, "INVALID option: %s", opt); } - + //---------------------------------------------------------------------- -// KEYWORDS / CODES TABLE +// KEYWORDS / CODES TABLE //---------------------------------------------------------------------- -const struct KeywordCodeTable EZPlot::m_sKeywords[] = -{ - {"solid", S_SOLID}, - {"dash", S_DASH}, +const struct KeywordCodeTable EZPlot::m_sKeywords[] = +{ + {"solid", S_SOLID}, + {"dash", S_DASH}, {"curve", S_CURVE}, - {"noline", S_NOLINE}, - {"black", S_BLACK}, - {"red", S_RED}, - {"blue", S_BLUE}, - {"green", S_GREEN}, - {"pen", S_PEN}, - {"symbol", S_SYMBOL}, - {"every", S_EVERY}, - {"none", S_NONE}, - {"legend", S_LEGEND}, - {"xlegend", S_XLEGEND}, - {"ylegend", S_YLEGEND}, - - {"xlin", S_XLIN}, - {"ylin", S_YLIN}, - {"xlog", S_XLOG}, - {"ylog", S_YLOG}, - {"xlabel", S_XLABEL}, - {"ylabel", S_YLABEL}, - {"xlength", S_XLENGTH}, - {"ylength", S_YLENGTH}, - - {"xticks", S_XTICKS}, - {"yticks", S_YTICKS}, - {"above", S_ABOVE}, - {"label", S_LABEL}, - {"below", S_BELOW}, - {"nolabel", S_NOLABEL}, - {"right", S_RIGHT}, - {"left", S_LEFT}, - - {"xautoscale", S_XAUTOSCALE}, - {"yautoscale", S_YAUTOSCALE}, - {"xmin", S_XMIN}, - {"ymin", S_YMIN}, - {"xmax", S_XMAX}, - {"ymax", S_YMAX}, - {"lxfrac", S_LXFRAC}, - {"lyfrac", S_LYFRAC}, - {"xcross", S_XCROSS}, - {"ycross", S_YCROSS}, - {"noxaxis", S_NOXAXIS}, - {"noyaxis", S_NOYAXIS}, - {"xporigin", S_XPORIGIN}, - {"yporigin", S_YPORIGIN}, - {"title", S_TITLE}, - {"xtitle", S_XTITLE}, - {"ytitle", S_YTITLE}, - - {"replot", S_REPLOT}, - {"clear", S_CLEAR}, - {"store", S_STORE}, - {"restore", S_RESTORE}, - {"amark", S_AMARK}, - {"units", S_UNITS}, - {"inches", S_INCHES}, - {"user", S_USER}, - - {"data", S_DATA}, - {"help", S_HELP}, - {"exit", S_EXIT}, - - {"box", S_BOX}, - {"nobox", S_NOBOX}, - {"grid", S_GRID}, - {"nogrid", S_NOGRID}, - {"major", S_MAJOR}, - {"minor", S_MINOR}, - {"color", S_COLOR}, - {"legendbox", S_LEGENDBOX}, - - {"no", S_NO}, - - {"textsize", S_TEXTSIZE}, + {"noline", S_NOLINE}, + {"black", S_BLACK}, + {"red", S_RED}, + {"blue", S_BLUE}, + {"green", S_GREEN}, + {"pen", S_PEN}, + {"symbol", S_SYMBOL}, + {"every", S_EVERY}, + {"none", S_NONE}, + {"legend", S_LEGEND}, + {"xlegend", S_XLEGEND}, + {"ylegend", S_YLEGEND}, + + {"xlin", S_XLIN}, + {"ylin", S_YLIN}, + {"xlog", S_XLOG}, + {"ylog", S_YLOG}, + {"xlabel", S_XLABEL}, + {"ylabel", S_YLABEL}, + {"xlength", S_XLENGTH}, + {"ylength", S_YLENGTH}, + + {"xticks", S_XTICKS}, + {"yticks", S_YTICKS}, + {"above", S_ABOVE}, + {"label", S_LABEL}, + {"below", S_BELOW}, + {"nolabel", S_NOLABEL}, + {"right", S_RIGHT}, + {"left", S_LEFT}, + + {"xautoscale", S_XAUTOSCALE}, + {"yautoscale", S_YAUTOSCALE}, + {"xmin", S_XMIN}, + {"ymin", S_YMIN}, + {"xmax", S_XMAX}, + {"ymax", S_YMAX}, + {"lxfrac", S_LXFRAC}, + {"lyfrac", S_LYFRAC}, + {"xcross", S_XCROSS}, + {"ycross", S_YCROSS}, + {"noxaxis", S_NOXAXIS}, + {"noyaxis", S_NOYAXIS}, + {"xporigin", S_XPORIGIN}, + {"yporigin", S_YPORIGIN}, + {"title", S_TITLE}, + {"xtitle", S_XTITLE}, + {"ytitle", S_YTITLE}, + + {"replot", S_REPLOT}, + {"clear", S_CLEAR}, + {"store", S_STORE}, + {"restore", S_RESTORE}, + {"amark", S_AMARK}, + {"units", S_UNITS}, + {"inches", S_INCHES}, + {"user", S_USER}, + + {"data", S_DATA}, + {"help", S_HELP}, + {"exit", S_EXIT}, + + {"box", S_BOX}, + {"nobox", S_NOBOX}, + {"grid", S_GRID}, + {"nogrid", S_NOGRID}, + {"major", S_MAJOR}, + {"minor", S_MINOR}, + {"color", S_COLOR}, + {"legendbox", S_LEGENDBOX}, + + {"no", S_NO}, + + {"textsize", S_TEXTSIZE}, }; - + const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable)); -void +void EZPlot::initKeywords () { for (int i = 0; i < NKEYS; i++)