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.6 2000/07/28 10:51:31 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;
32 EZPlot::ezset (char *command)
34 if (! ezset_initialized) {
37 pol_skpword ("please");
43 pol_skpword ("equals");
46 pol_usefile (P_USE_STR,"");
47 set_inputline ("!eoc ,");
50 ezset_initialized = true;
52 return (ezcmd (command));
56 EZPlot::ezcmd (char *comm)
58 pol_usefile (P_USE_STR, "");
64 if (! pol_usertok (str, &code)) {
65 cerr << "Illegal EZSET command: " << str << endl;
70 retval = do_cmd (code);
72 pol_closefile(); /* close input string file */
78 EZPlot::do_cmd (int lx)
87 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
89 if (f >= 0.0 && f <= 1.0) {
103 gettext (strIn, sizeof(strIn));
107 gettext (strIn, sizeof(strIn));
111 gettext (strIn, sizeof(strIn));
115 gettext (strIn, sizeof(strIn));
119 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
126 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
159 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
165 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
171 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
177 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
183 o_linestyle = SGP::LS_SOLID;
186 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
188 o_linestyle = SGP::LS_DASH1;
190 o_linestyle = SGP::LS_DASH2;
192 o_linestyle = SGP::LS_DASH3;
194 o_linestyle = SGP::LS_DASH4;
196 o_linestyle = SGP::LS_DASH1;
198 o_linestyle = SGP::LS_DASH1;
201 o_linestyle = SGP::LS_NOLINE;
205 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
210 bad_option("The color you picked");
226 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
227 if (f > 0.0 && f <= 1.0)
231 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
232 if (f > 0.0 && f <= 1.0)
236 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
237 if (f >= 0.0 && f < 1.0)
241 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
242 if (f >= 0.0 && f < 1.0)
246 if (pol_word("no", 2) == TRUE)
248 else if (pol_word("off", 2) == TRUE)
254 if (pol_word("inside", 2) == TRUE)
255 o_legendbox = INSIDE;
256 else if (pol_word("outside", 3) == TRUE)
257 o_legendbox = OUTSIDE;
258 else if (pol_word("none",2) == TRUE)
259 o_legendbox = NOLEGEND;
261 gettext (str, MAXTOK);
266 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
268 if (f >= 0.0 && f < 1.0) {
277 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
279 if (f >= 0.0 && f < 1.0) {
288 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
291 // if (modeinteract == TRUE) {
292 // curveinteract = n - 1;
293 // if (o_unknowncurves == FALSE && o_reqcurves < n)
300 // if (pol_word ("unknown", 7) == TRUE)
301 // o_unknowncurves = TRUE;
302 // else if (pol_word ("end", 3) == TRUE) {
303 // o_unknowncurves = FALSE;
304 // o_reqcurves = i_numcurves;
305 // i_plotimmediate = TRUE;
306 // ezplot (static_cast<double*>(NULL), static_cast<double*>(NULL), 0);
307 // i_plotimmediate = FALSE;
312 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
313 if (n > 0 && n <= MAXSYMBOL)
317 // if (modeinteract == TRUE && curveinteract >= 0)
318 // curve[curveinteract].symbol = o_symbol;
320 if (pol_word("every",5) == TRUE) {
321 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
326 // if (modeinteract == TRUE && curveinteract >= 0)
327 // curve[curveinteract].symfreq = o_symfreq;
329 } else if (pol_word ("none",4) == TRUE) {
331 // if (modeinteract == TRUE && curveinteract >= 0)
332 // curve[curveinteract].symbol = o_symbol;
337 if (pol_usertok(str,&lx) == FALSE)
341 else if (lx == S_BELOW)
343 else if (lx == S_NOLABEL)
345 else if (lx == S_LABEL)
347 else if (lx == S_MAJOR) {
348 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
349 if (n > 1 && n < 100)
351 } else if (lx == S_MINOR)
352 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
353 if (n >= 0 && n < 100)
357 if (pol_usertok(str,&lx) == FALSE)
361 else if (lx == S_LEFT)
363 else if (lx == S_NOLABEL)
365 else if (lx == S_LABEL)
367 else if (lx == S_MAJOR) {
368 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
369 if (n > 1 && n < 100)
371 } else if (lx == S_MINOR)
372 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
373 if (n >= 0 && n < 100)
377 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
386 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
396 fprintf (stderr, "Unimplemented EZPLOT command\n");
407 EZPlot::bad_option (char *opt)
409 cerr << opt << " is an INVALID option\n";
412 /*----------------------------------------------------------------------*/
413 /* LEXIGRAPHICAL CODES */
414 /*----------------------------------------------------------------------*/
422 {"noline", S_NOLINE},
428 {"symbol", S_SYMBOL},
429 /* "every", S_EVERY, */
430 /* "none", S_NONE, */
432 {"curves", S_CURVES},
434 /* "unknown", S_UNKNOWN, */
437 {"legend", S_LEGEND},
438 {"xlegend", S_XLEGEND},
439 {"ylegend", S_YLEGEND},
445 {"xlabel", S_XLABEL},
446 {"ylabel", S_YLABEL},
447 {"xlength", S_XLENGTH},
448 {"ylength", S_YLENGTH},
450 {"xticks", S_XTICKS},
451 {"yticks", S_YTICKS},
455 {"nolabel", S_NOLABEL},
459 {"xautoscale", S_XAUTOSCALE},
460 {"yautoscale", S_YAUTOSCALE},
465 {"lxfrac", S_LXFRAC},
466 {"lyfrac", S_LYFRAC},
467 {"xcross", S_XCROSS},
468 {"ycross", S_YCROSS},
469 {"noxaxis", S_NOXAXIS},
470 {"noyaxis", S_NOYAXIS},
471 {"xporigin", S_XPORIGIN},
472 {"yporigin", S_YPORIGIN},
474 {"xtitle", S_XTITLE},
475 {"ytitle", S_YTITLE},
477 {"replot", S_REPLOT},
480 {"restore", S_RESTORE},
482 {"interactive", S_INTERACTIVE},
484 {"inches", S_INCHES},
494 {"nogrid", S_NOGRID},
498 {"legendbox", S_LEGENDBOX},
502 {"textsize", S_TEXTSIZE},
505 static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key));
510 for (unsigned int i = 0; i < NKEYS; i++)
511 if (pol_install(keytab[i].keyword, keytab[i].code) == FALSE)
512 sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]");