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.9 2000/12/06 15:17:51 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 sys_error(ERR_WARNING, "Illegal EZSET command: %s", str);
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) {
289 if (n > 0 && n <= MAXSYMBOL)
294 if (pol_word("every",5) == TRUE) {
295 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
301 } else if (pol_word ("none",4) == TRUE) {
307 if (pol_usertok(str,&lx) == FALSE)
311 else if (lx == S_BELOW)
313 else if (lx == S_NOLABEL)
315 else if (lx == S_LABEL)
317 else if (lx == S_MAJOR) {
318 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
319 if (n > 1 && n < 100)
321 } else if (lx == S_MINOR)
322 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
323 if (n >= 0 && n < 100)
327 if (pol_usertok(str,&lx) == FALSE)
331 else if (lx == S_LEFT)
333 else if (lx == S_NOLABEL)
335 else if (lx == S_LABEL)
337 else if (lx == S_MAJOR) {
338 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
339 if (n > 1 && n < 100)
341 } else if (lx == S_MINOR)
342 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
343 if (n >= 0 && n < 100)
347 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
356 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
366 fprintf (stderr, "Unimplemented EZPLOT command\n");
377 EZPlot::bad_option (char *opt)
379 sys_error (ERR_WARNING, "INVALID option: %s", opt);
382 /*----------------------------------------------------------------------*/
383 /* LEXIGRAPHICAL CODES */
384 /*----------------------------------------------------------------------*/
392 {"noline", S_NOLINE},
398 {"symbol", S_SYMBOL},
401 {"legend", S_LEGEND},
402 {"xlegend", S_XLEGEND},
403 {"ylegend", S_YLEGEND},
409 {"xlabel", S_XLABEL},
410 {"ylabel", S_YLABEL},
411 {"xlength", S_XLENGTH},
412 {"ylength", S_YLENGTH},
414 {"xticks", S_XTICKS},
415 {"yticks", S_YTICKS},
419 {"nolabel", S_NOLABEL},
423 {"xautoscale", S_XAUTOSCALE},
424 {"yautoscale", S_YAUTOSCALE},
429 {"lxfrac", S_LXFRAC},
430 {"lyfrac", S_LYFRAC},
431 {"xcross", S_XCROSS},
432 {"ycross", S_YCROSS},
433 {"noxaxis", S_NOXAXIS},
434 {"noyaxis", S_NOYAXIS},
435 {"xporigin", S_XPORIGIN},
436 {"yporigin", S_YPORIGIN},
438 {"xtitle", S_XTITLE},
439 {"ytitle", S_YTITLE},
441 {"replot", S_REPLOT},
444 {"restore", S_RESTORE},
447 {"inches", S_INCHES},
457 {"nogrid", S_NOGRID},
461 {"legendbox", S_LEGENDBOX},
465 {"textsize", S_TEXTSIZE},
468 static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key));
473 for (unsigned int i = 0; i < NKEYS; i++)
474 if (! pol_install(keytab[i].keyword, keytab[i].code))
475 sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]");