1 /*****************************************************************************
4 ** EZSET - Parameter control for EZPLOT
6 ** This is part of the CTSim program
7 ** Copyright (c) 1983-2009 Kevin Rosenberg
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License (version 2) as
11 ** published by the Free Software Foundation.
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ******************************************************************************/
23 #include "ctsupport.h"
29 EZPlot::ezset (const std::string& command)
31 return ezset (command.c_str());
35 EZPlot::ezset (const char* const command)
38 return ezcmd (command);
42 EZPlot::ezcmd (const char* const comm)
44 m_pol.usefile (POL::P_USE_STR, "");
45 m_pol.set_inputline (comm);
47 char str [POL::MAXTOK+1];
50 if (! m_pol.readUserToken (str, &code)) {
51 sys_error (ERR_WARNING, "Illegal EZSET command: %s", str);
56 retval = do_cmd (code);
58 m_pol.closefile(); /* close input string file */
64 EZPlot::do_cmd (int lx)
73 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
74 if (f >= 0.0 && f <= 1.0) {
88 m_pol.readText (strIn, sizeof(strIn));
92 m_pol.readText (strIn, sizeof(strIn));
93 if (m_iCurrentCurve >= 0)
94 setLegend (m_iCurrentCurve, strIn);
97 m_pol.readText (strIn, sizeof(strIn));
101 m_pol.readText (strIn, sizeof(strIn));
105 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
112 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
145 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
151 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
157 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
163 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
169 o_linestyle = SGP::LS_SOLID;
174 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
186 if (m_iCurrentCurve < 0)
189 setLinestyle (m_iCurrentCurve, ls);
192 o_linestyle = SGP::LS_NOLINE;
196 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
199 if (m_iCurrentCurve < 0)
202 setColor (m_iCurrentCurve, n);
204 bad_option("The color you picked");
220 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
221 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) {
234 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
235 if (f >= 0.0 && f < 1.0) {
241 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
242 if (f >= 0.0 && f < 1.0) {
248 if (m_pol.readWord("no", 2) == TRUE)
250 else if (m_pol.readWord("off", 2) == TRUE)
256 if (m_pol.readWord("inside", 2) == TRUE)
257 o_legendbox = INSIDE;
258 else if (m_pol.readWord("outside", 3) == TRUE)
259 o_legendbox = OUTSIDE;
260 else if (m_pol.readWord("none",2) == TRUE)
261 o_legendbox = NOLEGEND;
263 m_pol.readText (str, POL::MAXTOK);
268 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
270 if (f >= 0.0 && f < 1.0) {
279 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
281 if (f >= 0.0 && f < 1.0) {
290 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
291 if (n > 0 && n <= MAXSYMBOL) {
292 if (m_iCurrentCurve < 0)
295 setSymbol (m_iCurrentCurve, n);
298 if (m_pol.readWord("every",5) == TRUE) {
299 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
303 if (m_iCurrentCurve < 0)
306 setSymbolFreq (m_iCurrentCurve, sym);
308 } else if (m_pol.readWord ("none",4) == TRUE) {
314 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
316 m_iCurrentCurve = n - 1;
318 if (m_pol.readWord ("all",3) == TRUE)
319 m_iCurrentCurve = -1;
323 if (m_pol.readUserToken(str,&lx) == FALSE)
327 else if (lx == S_BELOW)
329 else if (lx == S_NOLABEL)
331 else if (lx == S_LABEL)
333 else if (lx == S_MAJOR) {
334 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
335 if (n > 1 && n < 100)
337 } else if (lx == S_MINOR)
338 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
339 if (n >= 0 && n < 100) {
345 if (m_pol.readUserToken(str,&lx) == FALSE)
349 else if (lx == S_LEFT)
351 else if (lx == S_NOLABEL)
353 else if (lx == S_LABEL)
355 else if (lx == S_MAJOR) {
356 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
357 if (n > 1 && n < 100) {
361 } else if (lx == S_MINOR)
362 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
363 if (n >= 0 && n < 100) {
369 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
378 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
388 fprintf (stderr, "Unimplemented EZPLOT command\n");
399 EZPlot::bad_option (const char *opt)
401 sys_error (ERR_WARNING, "INVALID option: %s", opt);
405 //----------------------------------------------------------------------
406 // KEYWORDS / CODES TABLE
407 //----------------------------------------------------------------------
408 const struct KeywordCodeTable EZPlot::m_sKeywords[] =
413 {"noline", S_NOLINE},
419 {"symbol", S_SYMBOL},
422 {"legend", S_LEGEND},
423 {"xlegend", S_XLEGEND},
424 {"ylegend", S_YLEGEND},
430 {"xlabel", S_XLABEL},
431 {"ylabel", S_YLABEL},
432 {"xlength", S_XLENGTH},
433 {"ylength", S_YLENGTH},
435 {"xticks", S_XTICKS},
436 {"yticks", S_YTICKS},
440 {"nolabel", S_NOLABEL},
444 {"xautoscale", S_XAUTOSCALE},
445 {"yautoscale", S_YAUTOSCALE},
450 {"lxfrac", S_LXFRAC},
451 {"lyfrac", S_LYFRAC},
452 {"xcross", S_XCROSS},
453 {"ycross", S_YCROSS},
454 {"noxaxis", S_NOXAXIS},
455 {"noyaxis", S_NOYAXIS},
456 {"xporigin", S_XPORIGIN},
457 {"yporigin", S_YPORIGIN},
459 {"xtitle", S_XTITLE},
460 {"ytitle", S_YTITLE},
462 {"replot", S_REPLOT},
465 {"restore", S_RESTORE},
468 {"inches", S_INCHES},
478 {"nogrid", S_NOGRID},
482 {"legendbox", S_LEGENDBOX},
486 {"textsize", S_TEXTSIZE},
489 const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable));
492 EZPlot::initKeywords ()
494 for (int i = 0; i < NKEYS; i++)
495 m_pol.addKeyword (m_sKeywords[i].keyword, m_sKeywords [i].code);