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.10 2000/12/20 14:39:09 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)
96 if (f >= 0.0 && f <= 1.0) {
110 gettext (strIn, sizeof(strIn));
114 gettext (strIn, sizeof(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;
193 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
195 o_linestyle = SGP::LS_DASH1;
197 o_linestyle = SGP::LS_DASH2;
199 o_linestyle = SGP::LS_DASH3;
201 o_linestyle = SGP::LS_DASH4;
203 o_linestyle = SGP::LS_DASH1;
205 o_linestyle = SGP::LS_DASH1;
208 o_linestyle = SGP::LS_NOLINE;
212 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
217 bad_option("The color you picked");
233 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
234 if (f > 0.0 && f <= 1.0)
238 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
239 if (f > 0.0 && f <= 1.0)
243 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
244 if (f >= 0.0 && f < 1.0)
248 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
249 if (f >= 0.0 && f < 1.0)
253 if (pol_word("no", 2) == TRUE)
255 else if (pol_word("off", 2) == TRUE)
261 if (pol_word("inside", 2) == TRUE)
262 o_legendbox = INSIDE;
263 else if (pol_word("outside", 3) == TRUE)
264 o_legendbox = OUTSIDE;
265 else if (pol_word("none",2) == TRUE)
266 o_legendbox = NOLEGEND;
268 gettext (str, MAXTOK);
273 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
275 if (f >= 0.0 && f < 1.0) {
284 if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
286 if (f >= 0.0 && f < 1.0) {
295 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
296 if (n > 0 && n <= MAXSYMBOL)
301 if (pol_word("every",5) == TRUE) {
302 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
308 } else if (pol_word ("none",4) == TRUE) {
314 if (pol_usertok(str,&lx) == FALSE)
318 else if (lx == S_BELOW)
320 else if (lx == S_NOLABEL)
322 else if (lx == S_LABEL)
324 else if (lx == S_MAJOR) {
325 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
326 if (n > 1 && n < 100)
328 } else if (lx == S_MINOR)
329 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
330 if (n >= 0 && n < 100)
334 if (pol_usertok(str,&lx) == FALSE)
338 else if (lx == S_LEFT)
340 else if (lx == S_NOLABEL)
342 else if (lx == S_LABEL)
344 else if (lx == S_MAJOR) {
345 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
346 if (n > 1 && n < 100)
348 } else if (lx == S_MINOR)
349 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
350 if (n >= 0 && n < 100)
354 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
363 if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
373 fprintf (stderr, "Unimplemented EZPLOT command\n");
384 EZPlot::bad_option (char *opt)
386 sys_error (ERR_WARNING, "INVALID option: %s", opt);
389 /*----------------------------------------------------------------------*/
390 /* LEXIGRAPHICAL CODES */
391 /*----------------------------------------------------------------------*/
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 static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key));
480 for (unsigned int i = 0; i < NKEYS; i++)
481 if (! pol_install(keytab[i].keyword, keytab[i].code))
482 sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]");