1 /*****************************************************************************
4 ** EZSET - Parameter control for EZPLOT
6 ** This is part of the CTSim program
7 ** Copyright (c) 1983-2001 Kevin Rosenberg
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License (version 2) as
13 ** published by the Free Software Foundation.
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU General Public License for more details.
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ******************************************************************************/
25 #include "ctsupport.h"
31 EZPlot::ezset (const std::string& command)
33 return ezset (command.c_str());
37 EZPlot::ezset (const char* const command)
40 return ezcmd (command);
44 EZPlot::ezcmd (const char* const comm)
46 m_pol.usefile (POL::P_USE_STR, "");
47 m_pol.set_inputline (comm);
49 char str [POL::MAXTOK+1];
52 if (! m_pol.readUserToken (str, &code)) {
53 sys_error (ERR_WARNING, "Illegal EZSET command: %s", str);
58 retval = do_cmd (code);
60 m_pol.closefile(); /* close input string file */
66 EZPlot::do_cmd (int lx)
75 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
76 if (f >= 0.0 && f <= 1.0) {
90 m_pol.readText (strIn, sizeof(strIn));
94 m_pol.readText (strIn, sizeof(strIn));
95 if (m_iCurrentCurve >= 0)
96 setLegend (m_iCurrentCurve, strIn);
99 m_pol.readText (strIn, sizeof(strIn));
103 m_pol.readText (strIn, sizeof(strIn));
107 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
114 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
147 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
153 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
159 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
165 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
171 o_linestyle = SGP::LS_SOLID;
176 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
188 if (m_iCurrentCurve < 0)
191 setLinestyle (m_iCurrentCurve, ls);
194 o_linestyle = SGP::LS_NOLINE;
198 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
201 if (m_iCurrentCurve < 0)
204 setColor (m_iCurrentCurve, n);
206 bad_option("The color you picked");
222 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
223 if (f > 0.0 && f <= 1.0)
227 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
228 if (f > 0.0 && f <= 1.0)
232 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
233 if (f >= 0.0 && f < 1.0)
237 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
238 if (f >= 0.0 && f < 1.0)
242 if (m_pol.readWord("no", 2) == TRUE)
244 else if (m_pol.readWord("off", 2) == TRUE)
250 if (m_pol.readWord("inside", 2) == TRUE)
251 o_legendbox = INSIDE;
252 else if (m_pol.readWord("outside", 3) == TRUE)
253 o_legendbox = OUTSIDE;
254 else if (m_pol.readWord("none",2) == TRUE)
255 o_legendbox = NOLEGEND;
257 m_pol.readText (str, POL::MAXTOK);
262 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
264 if (f >= 0.0 && f < 1.0) {
273 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
275 if (f >= 0.0 && f < 1.0) {
284 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
285 if (n > 0 && n <= MAXSYMBOL) {
286 if (m_iCurrentCurve < 0)
289 setSymbol (m_iCurrentCurve, n);
292 if (m_pol.readWord("every",5) == TRUE) {
293 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
297 if (m_iCurrentCurve < 0)
300 setSymbolFreq (m_iCurrentCurve, sym);
302 } else if (m_pol.readWord ("none",4) == TRUE) {
308 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
310 m_iCurrentCurve = n - 1;
312 if (m_pol.readWord ("all",3) == TRUE)
313 m_iCurrentCurve = -1;
317 if (m_pol.readUserToken(str,&lx) == FALSE)
321 else if (lx == S_BELOW)
323 else if (lx == S_NOLABEL)
325 else if (lx == S_LABEL)
327 else if (lx == S_MAJOR) {
328 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
329 if (n > 1 && n < 100)
331 } else if (lx == S_MINOR)
332 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
333 if (n >= 0 && n < 100)
337 if (m_pol.readUserToken(str,&lx) == FALSE)
341 else if (lx == S_LEFT)
343 else if (lx == S_NOLABEL)
345 else if (lx == S_LABEL)
347 else if (lx == S_MAJOR) {
348 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
349 if (n > 1 && n < 100)
351 } else if (lx == S_MINOR)
352 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
353 if (n >= 0 && n < 100)
357 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
366 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
376 fprintf (stderr, "Unimplemented EZPLOT command\n");
387 EZPlot::bad_option (char *opt)
389 sys_error (ERR_WARNING, "INVALID option: %s", opt);
393 //----------------------------------------------------------------------
394 // KEYWORDS / CODES TABLE
395 //----------------------------------------------------------------------
396 const struct KeywordCodeTable EZPlot::m_sKeywords[] =
401 {"noline", S_NOLINE},
407 {"symbol", S_SYMBOL},
410 {"legend", S_LEGEND},
411 {"xlegend", S_XLEGEND},
412 {"ylegend", S_YLEGEND},
418 {"xlabel", S_XLABEL},
419 {"ylabel", S_YLABEL},
420 {"xlength", S_XLENGTH},
421 {"ylength", S_YLENGTH},
423 {"xticks", S_XTICKS},
424 {"yticks", S_YTICKS},
428 {"nolabel", S_NOLABEL},
432 {"xautoscale", S_XAUTOSCALE},
433 {"yautoscale", S_YAUTOSCALE},
438 {"lxfrac", S_LXFRAC},
439 {"lyfrac", S_LYFRAC},
440 {"xcross", S_XCROSS},
441 {"ycross", S_YCROSS},
442 {"noxaxis", S_NOXAXIS},
443 {"noyaxis", S_NOYAXIS},
444 {"xporigin", S_XPORIGIN},
445 {"yporigin", S_YPORIGIN},
447 {"xtitle", S_XTITLE},
448 {"ytitle", S_YTITLE},
450 {"replot", S_REPLOT},
453 {"restore", S_RESTORE},
456 {"inches", S_INCHES},
466 {"nogrid", S_NOGRID},
470 {"legendbox", S_LEGENDBOX},
474 {"textsize", S_TEXTSIZE},
477 const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable));
480 EZPlot::initKeywords ()
482 for (int i = 0; i < NKEYS; i++)
483 m_pol.addKeyword (m_sKeywords[i].keyword, m_sKeywords [i].code);