1 /*****************************************************************************
4 ** EZSET - Parameter control for EZPLOT
6 ** This is part of the CTSim program
7 ** Copyright (C) 1983-2000 Kevin Rosenberg
9 ** $Id: ezset.cpp,v 1.12 2000/12/25 21:54:26 kevin Exp $
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"
29 bool EZPlot::ezset_initialized = false;
33 EZPlot::ezset (const std::string& command)
\r
35 return ezset (command.c_str());
\r
39 EZPlot::ezset (const char* const command)
41 if (! ezset_initialized) {
44 pol_skpword ("please");
50 pol_skpword ("equals");
53 pol_usefile (P_USE_STR,"");
54 set_inputline ("!eoc ,");
57 ezset_initialized = true;
59 return ezcmd (command);
63 EZPlot::ezcmd (const char* const comm)
65 pol_usefile (P_USE_STR, "");
71 if (! pol_usertok (str, &code)) {
72 sys_error(ERR_WARNING, "Illegal EZSET command: %s", str);
77 retval = do_cmd (code);
79 pol_closefile(); /* close input string file */
85 EZPlot::do_cmd (int lx)
94 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
95 if (f >= 0.0 && f <= 1.0) {
109 gettext (strIn, sizeof(strIn));
113 gettext (strIn, sizeof(strIn));
\r
114 if (m_iCurrentCurve >= 0)
\r
115 setLegend (m_iCurrentCurve, strIn);
118 gettext (strIn, sizeof(strIn));
122 gettext (strIn, sizeof(strIn));
126 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
133 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
166 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
172 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
178 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
184 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
190 o_linestyle = SGP::LS_SOLID;
194 ls = SGP::LS_DASH1;
\r
195 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
\r
203 ls = SGP::LS_DASH4;
\r
205 ls = SGP::LS_DOTTED;
\r
207 if (m_iCurrentCurve < 0)
\r
210 setLinestyle (m_iCurrentCurve, ls);
\r
213 o_linestyle = SGP::LS_NOLINE;
217 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
220 if (m_iCurrentCurve < 0)
223 setColor (m_iCurrentCurve, n);
\r
225 bad_option("The color you picked");
241 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
242 if (f > 0.0 && f <= 1.0)
246 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
247 if (f > 0.0 && f <= 1.0)
251 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
252 if (f >= 0.0 && f < 1.0)
256 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
257 if (f >= 0.0 && f < 1.0)
261 if (pol_word("no", 2) == TRUE)
263 else if (pol_word("off", 2) == TRUE)
269 if (pol_word("inside", 2) == TRUE)
270 o_legendbox = INSIDE;
271 else if (pol_word("outside", 3) == TRUE)
272 o_legendbox = OUTSIDE;
273 else if (pol_word("none",2) == TRUE)
274 o_legendbox = NOLEGEND;
276 gettext (str, MAXTOK);
281 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
283 if (f >= 0.0 && f < 1.0) {
292 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
294 if (f >= 0.0 && f < 1.0) {
303 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
304 if (n > 0 && n <= MAXSYMBOL) {
305 if (m_iCurrentCurve < 0)
\r
308 setSymbol (m_iCurrentCurve, n);
\r
311 if (pol_word("every",5) == TRUE) {
312 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
\r
316 if (m_iCurrentCurve < 0)
\r
319 setSymbolFreq (m_iCurrentCurve, sym);
\r
321 } else if (pol_word ("none",4) == TRUE) {
327 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
\r
329 m_iCurrentCurve = n - 1;
\r
331 if (pol_word ("all",3) == TRUE)
\r
332 m_iCurrentCurve = -1;
\r
336 if (pol_usertok(str,&lx) == FALSE)
340 else if (lx == S_BELOW)
342 else if (lx == S_NOLABEL)
344 else if (lx == S_LABEL)
346 else if (lx == S_MAJOR) {
347 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
348 if (n > 1 && n < 100)
350 } else if (lx == S_MINOR)
351 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
352 if (n >= 0 && n < 100)
356 if (pol_usertok(str,&lx) == FALSE)
360 else if (lx == S_LEFT)
362 else if (lx == S_NOLABEL)
364 else if (lx == S_LABEL)
366 else if (lx == S_MAJOR) {
367 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
368 if (n > 1 && n < 100)
370 } else if (lx == S_MINOR)
371 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
372 if (n >= 0 && n < 100)
376 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
385 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
395 fprintf (stderr, "Unimplemented EZPLOT command\n");
406 EZPlot::bad_option (char *opt)
408 sys_error (ERR_WARNING, "INVALID option: %s", opt);
412 //----------------------------------------------------------------------
413 // KEYWORDS / CODES TABLE
414 //----------------------------------------------------------------------
415 const struct KeywordCodeTable EZPlot::m_sKeywords[] =
\r
420 {"noline", S_NOLINE},
426 {"symbol", S_SYMBOL},
429 {"legend", S_LEGEND},
430 {"xlegend", S_XLEGEND},
431 {"ylegend", S_YLEGEND},
437 {"xlabel", S_XLABEL},
438 {"ylabel", S_YLABEL},
439 {"xlength", S_XLENGTH},
440 {"ylength", S_YLENGTH},
442 {"xticks", S_XTICKS},
443 {"yticks", S_YTICKS},
447 {"nolabel", S_NOLABEL},
451 {"xautoscale", S_XAUTOSCALE},
452 {"yautoscale", S_YAUTOSCALE},
457 {"lxfrac", S_LXFRAC},
458 {"lyfrac", S_LYFRAC},
459 {"xcross", S_XCROSS},
460 {"ycross", S_YCROSS},
461 {"noxaxis", S_NOXAXIS},
462 {"noyaxis", S_NOYAXIS},
463 {"xporigin", S_XPORIGIN},
464 {"yporigin", S_YPORIGIN},
466 {"xtitle", S_XTITLE},
467 {"ytitle", S_YTITLE},
469 {"replot", S_REPLOT},
472 {"restore", S_RESTORE},
475 {"inches", S_INCHES},
485 {"nogrid", S_NOGRID},
489 {"legendbox", S_LEGENDBOX},
493 {"textsize", S_TEXTSIZE},
496 const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable));
499 EZPlot::initKeywords ()
501 for (int i = 0; i < NKEYS; i++)
502 if (! pol_install (m_sKeywords[i].keyword, m_sKeywords [i].code))
503 sys_error(ERR_SEVERE, "error installing ezset keywords [EZPlot::initKeywords]");