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)
225 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
226 if (f > 0.0 && f <= 1.0)
230 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
231 if (f >= 0.0 && f < 1.0)
235 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
236 if (f >= 0.0 && f < 1.0)
240 if (m_pol.readWord("no", 2) == TRUE)
242 else if (m_pol.readWord("off", 2) == TRUE)
248 if (m_pol.readWord("inside", 2) == TRUE)
249 o_legendbox = INSIDE;
250 else if (m_pol.readWord("outside", 3) == TRUE)
251 o_legendbox = OUTSIDE;
252 else if (m_pol.readWord("none",2) == TRUE)
253 o_legendbox = NOLEGEND;
255 m_pol.readText (str, POL::MAXTOK);
260 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
262 if (f >= 0.0 && f < 1.0) {
271 if (m_pol.readFloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
273 if (f >= 0.0 && f < 1.0) {
282 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
283 if (n > 0 && n <= MAXSYMBOL) {
284 if (m_iCurrentCurve < 0)
287 setSymbol (m_iCurrentCurve, n);
290 if (m_pol.readWord("every",5) == TRUE) {
291 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
295 if (m_iCurrentCurve < 0)
298 setSymbolFreq (m_iCurrentCurve, sym);
300 } else if (m_pol.readWord ("none",4) == TRUE) {
306 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
308 m_iCurrentCurve = n - 1;
310 if (m_pol.readWord ("all",3) == TRUE)
311 m_iCurrentCurve = -1;
315 if (m_pol.readUserToken(str,&lx) == FALSE)
319 else if (lx == S_BELOW)
321 else if (lx == S_NOLABEL)
323 else if (lx == S_LABEL)
325 else if (lx == S_MAJOR) {
326 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
327 if (n > 1 && n < 100)
329 } else if (lx == S_MINOR)
330 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
331 if (n >= 0 && n < 100)
335 if (m_pol.readUserToken(str,&lx) == FALSE)
339 else if (lx == S_LEFT)
341 else if (lx == S_NOLABEL)
343 else if (lx == S_LABEL)
345 else if (lx == S_MAJOR) {
346 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
347 if (n > 1 && n < 100)
349 } else if (lx == S_MINOR)
350 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
351 if (n >= 0 && n < 100)
355 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
364 if (m_pol.readInteger (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
374 fprintf (stderr, "Unimplemented EZPLOT command\n");
385 EZPlot::bad_option (const char *opt)
387 sys_error (ERR_WARNING, "INVALID option: %s", opt);
391 //----------------------------------------------------------------------
392 // KEYWORDS / CODES TABLE
393 //----------------------------------------------------------------------
394 const struct KeywordCodeTable EZPlot::m_sKeywords[] =
399 {"noline", S_NOLINE},
405 {"symbol", S_SYMBOL},
408 {"legend", S_LEGEND},
409 {"xlegend", S_XLEGEND},
410 {"ylegend", S_YLEGEND},
416 {"xlabel", S_XLABEL},
417 {"ylabel", S_YLABEL},
418 {"xlength", S_XLENGTH},
419 {"ylength", S_YLENGTH},
421 {"xticks", S_XTICKS},
422 {"yticks", S_YTICKS},
426 {"nolabel", S_NOLABEL},
430 {"xautoscale", S_XAUTOSCALE},
431 {"yautoscale", S_YAUTOSCALE},
436 {"lxfrac", S_LXFRAC},
437 {"lyfrac", S_LYFRAC},
438 {"xcross", S_XCROSS},
439 {"ycross", S_YCROSS},
440 {"noxaxis", S_NOXAXIS},
441 {"noyaxis", S_NOYAXIS},
442 {"xporigin", S_XPORIGIN},
443 {"yporigin", S_YPORIGIN},
445 {"xtitle", S_XTITLE},
446 {"ytitle", S_YTITLE},
448 {"replot", S_REPLOT},
451 {"restore", S_RESTORE},
454 {"inches", S_INCHES},
464 {"nogrid", S_NOGRID},
468 {"legendbox", S_LEGENDBOX},
472 {"textsize", S_TEXTSIZE},
475 const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable));
478 EZPlot::initKeywords ()
480 for (int i = 0; i < NKEYS; i++)
481 m_pol.addKeyword (m_sKeywords[i].keyword, m_sKeywords [i].code);