Add help button onto dialog's for reconstruction & projections.
Consider use of wxWindows help file classes.
- Consider changing POL into a Class. Consider making it read tag tokens.
+ Consider changing POL to to read tag tokens.
Consider being able to write Phantom files as text and view as
text in ctsim.
* if1: Updated to use new ImageFile class math functions
* ezplot: Reworked to better store colors/linestyles/symbols with
- Individual curves. Updated to more C++ conventions.
+ individual curves. Improved display of labels and ticks. Updated
+ to use POL class member variable. Updated to more C++ conventions.
+ * pol: converted to C++ class
+
* sgp: Added linestyle settings
2.5.0 - 12/18/00
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.h,v 1.21 2000/12/25 21:54:26 kevin Exp $
+** $Id: ezplot.h,v 1.22 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include <cmath>
#include <stddef.h>
#include "ctsupport.h"
-#include "sgp.h"
+#include "sgp.h"\r
+#include "pol.h"
class EZPlotCurve {
int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);
SGP& rSGP;
+ POL m_pol;\r
void clearCurves ();
void bad_option(char *opt);
void initPlotSettings();
- static void initKeywords ();
-
- static bool ezset_initialized;
-
+ void initKeywords ();
+
double convertWorldToNDC_X (double x)
{ return xgn_min + (x - xgw_min) * m_xWorldScale; }
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: pol.h,v 1.6 2000/12/25 21:54:26 kevin Exp $
+** $Id: pol.h,v 1.7 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
******************************************************************************/
#ifndef __H_POL
#define __H_POL
-\r
-// codes for pol_usefile
-enum {\r
- P_USE_STR = 1, // use string as input source
- P_USE_FILE, // use file as input source \r
-};
-// codes for pol_int and pol_float
-// if in reject catagory, get new number from terminal
-enum {
- P_FLTINT = 1, // get a real or integer number
- P_BFLTINT, // get a real or integer number, clip against bounds
- P_CBFLTINT, // get real or int, reject if outside bounds
- P_FLT, // get a real number
- P_BFLT, // get a real, clip against bounds
- P_CBFLT, // get a floating, reject if outside bounds
- P_INT, // get a integer number
- P_BINT, // get a integer, clip against bounds
- P_CBINT, // get a integer, reject if outside bounds
-};\r
+class POL {
+
+ public:
+
+ // codes for pol_usefile \r
+ enum {\r
+ P_USE_STR = 1, // use string as input source \r
+ P_USE_FILE, // use file as input source \r
+ };\r
\r
-
-#define LETTER 'a'
-#define DIGIT '0'
-
-#define MAXTOK 200 /* maximum length of a token */
-#define MAXLINE 255
-#define MAXIDENT 20
-#define MAXSKIPWORD 20
-#define MAXSKIPCHAR 20
-
-#define MIN_INT -32768
-#define MAX_INT 32767
+ \r
+ POL();
+ ~POL();
+
+ void init ();
+ void skpword (char *w);
+ void skpchar (char *s);
+ int installKeyword (char *str, int code);
+ int word (char *search, int nlet);
+ int usertok (char *str, int *code);
+ int string (char *str);
+ int integer (int *n, int typecode, int boundcode, int bb1, int bb2);
+ bool readfloat (double *n, double typecode, double boundcode, double bb1, double bb2);
+ int skip ();
+ void reader ();
+ void gettext (char *str, int lim);
+ void usefile (int source, char *fn);
+ void closefile ();
+ int lookchar ();
+ int inchar ();
+ void ungetch (int c);
+ int get_inputline (FILE *fp);
+ void set_inputline (const char* const line);
+
\r
-
-// token types
-enum {
- TT_STRING = 1, // string token
- TT_INT, // integer token
- TT_REAL, // floating point token
- TT_ALPHA, // alphabetic token
- TT_ALPNUM, // alphanumeric token
- TT_NUMALPHA,
- TT_SPECLCHAR,
- TT_EOF, // end of file reached
- TT_ERROR, // error in token, caused by call to wrong type of token reader
- TT_BLANK, // white space token. pol_tok() skips these
- TT_USERTOK, // user defined token
-};\r
+ enum {\r
+ MAXTOK = 200, // maximum length of a token \r
+ MAXLINE = 1024, // maximum line length\r
+ MAXIDENT = 20,\r
+ MAXSKIPWORD = 20,\r
+ MAXSKIPCHAR = 20,\r
+ MIN_INT = -2000000000,\r
+ MAX_INT = 2000000000,\r
+ };\r
+ \r
+ // token types \r
+ enum {\r
+ TT_STRING = 1, // string token \r
+ TT_INT, // integer token \r
+ TT_REAL, // floating point token \r
+ TT_ALPHA, // alphabetic token \r
+ TT_ALPNUM, // alphanumeric token \r
+ TT_NUMALPHA,\r
+ TT_SPECLCHAR,\r
+ TT_EOF, // end of file reached \r
+ TT_ERROR, // error in token, caused by call to wrong type of token reader \r
+ TT_BLANK, // white space token. pol_tok() skips these \r
+ TT_USERTOK, // user defined token \r
+ };\r
\r
-
-struct symlist {
- char *name;
- int code;
- struct symlist *next;
+ \r
+private:\r
+ \r
+ // codes for pol_int and pol_float \r
+ // if in reject catagory, get new number from terminal \r
+ enum {\r
+ P_FLTINT = 1, // get a real or integer number \r
+ P_BFLTINT, // get a real or integer number, clip against bounds \r
+ P_CBFLTINT, // get real or int, reject if outside bounds \r
+ P_FLT, // get a real number \r
+ P_BFLT, // get a real, clip against bounds \r
+ P_CBFLT, // get a floating, reject if outside bounds \r
+ P_INT, // get a integer number \r
+ P_BINT, // get a integer, clip against bounds \r
+ P_CBINT, // get a integer, reject if outside bounds \r
+ };\r
+ \r
+#define LETTER 'a'\r
+#define DIGIT '0'\r
+ \r
+ \r
+// typedef std::map<std::string,int> KeywordCodeList;\r
+ \r
+ struct symlist {\r
+ char *name;\r
+ int code;\r
+ struct symlist *next;\r
+ };\r
+ typedef struct symlist SYMBOL;\r
+ \r
+ struct token_st {\r
+ int ready; // TRUE if token is ready \r
+ // std::string tokstr; // token string \r
+ char tokstr[MAXTOK+1];\r
+ int type; // type of token 'TT_' \r
+ int code; // holds code for user defined tokens \r
+ double fnum; // real value of token \r
+ int inum; // integer value of token \r
+ };\r
+ typedef struct token_st TOKEN;\r
+ \r
+ \r
+ struct token_st token; // current token \r
+ enum {\r
+ HASHSIZE = 100,\r
+ };\r
+ \r
+ // Tables words stored with install() & found with lookup() \r
+ SYMBOL *skiptable[HASHSIZE]; // words to ignore and skip \r
+ SYMBOL *cmdtable[HASHSIZE]; // pol parameter commands \r
+ SYMBOL *usertable[HASHSIZE]; // user defined symbols \r
+ \r
+ struct metachar {\r
+ char eoc; /* end of command character */\r
+ char str; /* string delimiter */\r
+ char com; /* comment character */\r
+ char cmd; /* pol parameter command character */\r
+ char prg; /* program load character */\r
+ char con; /* continuation across newline character */\r
+ char out; /* character that delimits output to terminal */\r
+ char ter; /* character indicates insertion of input from terminal */\r
+ char inb; /* input from graphics device */\r
+ } meta;\r
+ \r
+ \r
+ // current pol state \r
+ struct pol_st {\r
+ char skipchars[MAXSKIPCHAR]; // characters to skip \r
+ int nl_eoc; // TRUE if newline character ends a command \r
+ int trace; // TRUE if trace is on \r
+ };\r
+ \r
+ struct pol_st pol;\r
+ \r
+ struct KeywordCodeList {\r
+ char *keyword;\r
+ int code;\r
+ };\r
+ \r
+ static const struct KeywordCodeList cmdlist[];\r
+ static const int NUMCMD;\r
+ \r
+ // Internal codes for pol commands \r
+ enum {\r
+ PC_EOC = 1,\r
+ PC_STR,\r
+ PC_COM,\r
+ PC_CMD,\r
+ PC_PRG,\r
+ PC_CON, \r
+ PC_OUT,\r
+ PC_TER,\r
+ PC_INB, \r
+ PC_NL_EOC,\r
+ PC_NL_NEOC,\r
+ PC_TRON,\r
+ PC_TROFF,\r
+ PC_FILE,\r
+ PC_DUMP,\r
+ };\r
+ \r
+ enum {\r
+ MAXFILE = 8,\r
+ };\r
+ \r
+ int currentf; /* pointer to current fp */\r
+ FILE *filep[MAXFILE]; /* == NULL for string input */\r
+ char *fname[MAXFILE]; /* pointer to filename */\r
+ \r
+ char inputline[MAXLINE]; /* current input line */\r
+ int lineptr; /* current position in inputline */\r
+ \r
+ enum {\r
+ BUFSIZE = 100,\r
+ };\r
+ int bp; // pointer to next free position \r
+ int buf[BUFSIZE]; // pushed back input characters \r
+ \r
+ int skiptok(char term[]);\r
+ int tok(struct token_st *token);\r
+ void dumptok(struct token_st *token);\r
+ \r
+ \r
+ int getpol_tok(struct token_st *token);\r
+ int getcmd();\r
+ int gettok (TOKEN *tok);\r
+ void getblank(char *s, int toksiz);\r
+ int getalpha(char *s, int toksiz);\r
+ void getquote(char *qs, int toksiz);\r
+ void getescape(char *s, int delim, int toksiz);\r
+ int getnumber (char str[], int strsize, double *fnum, int *inum);\r
+ void eatline();\r
+ int type(int c);\r
+ void inittable(SYMBOL *table[]);\r
+ void freetable(SYMBOL *table[]);\r
+ int hash(char *s);\r
+ SYMBOL *lookup(SYMBOL *table[], char *s);\r
+ SYMBOL *install(SYMBOL *table[], char *s, int def);\r
+ int getch(FILE *fp);\r
+ \r
};
-typedef struct symlist SYMBOL;
-
-struct token_st {
- int ready; // TRUE if token is ready
- char tokstr[MAXTOK+1]; // token string
- int type; // type of token 'TT_'
- int code; // holds code for user defined tokens
- double fnum; // real value of token
- int inum; // integer value of token
-};
-
-typedef struct token_st TOKEN;
-
-\r
-/* pol.c */
-void pol_init (void);
-void pol_skpword (char *w);
-void pol_skpchar (char *s);
-int pol_install (char *str, int code);
-int pol_word (char *search, int nlet);
-int pol_usertok (char *str, int *code);
-int pol_string (char *str);
-int pol_integer (int *n, int typecode, int boundcode, int bb1, int bb2);
-int pol_float (double *n, double typecode, double boundcode, double bb1, double bb2);
-int pol_skip (void);
-void pol_reader (void);
-void gettext (char *str, int lim);
-void pol_usefile (int source, char *fn);
-void pol_closefile (void);
-int pol_lookchar (void);
-int pol_inchar (void);
-void pol_ungetch (int c);
-int get_inputline (FILE *fp);
-void set_inputline (const char* const line);
-
-#endif\r
+#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.23 2000/12/26 21:13:15 kevin Exp $
+** $Id: ezplot.cpp,v 1.24 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
EZPlot::EZPlot (SGP& sgp)
: rSGP (sgp)
{
- initPlotSettings();
+ initKeywords();\r
+ m_pol.skpword ("please");\r
+ m_pol.skpword ("use");\r
+ m_pol.skpword ("are");\r
+ m_pol.skpword ("and");\r
+ m_pol.skpword ("is");\r
+ m_pol.skpword ("the");\r
+ m_pol.skpword ("equals");\r
+ m_pol.skpchar ("=");\r
+ \r
+ m_pol.usefile (POL::P_USE_STR,"");\r
+ m_pol.set_inputline ("!eoc ,");\r
+ m_pol.reader ();\r
+ m_pol.closefile ();\r
+\r
+ initPlotSettings();
}
void
if (o_xaxis == NOAXIS || o_xtlabel == FALSE)
xtl_ofs = 0.0;
else if (o_xticks == BELOW)
- xtl_ofs = -1.5 * charheight;
+ xtl_ofs = -0.5 * charheight;
else if (o_xticks == ABOVE)
- xtl_ofs = 1.5 * charheight;
+ xtl_ofs = 0.5 * charheight;
if (o_yaxis == NOAXIS || o_ytlabel == FALSE)
ytl_ofs = 0.0;
else if (o_yticks == LEFT)
- ytl_ofs = -(1 + y_fldwid) * charwidth;
+ ytl_ofs = -(2 + y_fldwid) * charwidth;
else if (o_yticks == RIGHT)
ytl_ofs = 1.5 * charwidth;
+ xa_max -= 0.7 * x_fldwid * charwidth; // make room for last x tick label\r
+\r
xt_min = xa_min;
yt_min = ya_min;
xt_max = xa_max;
// see if need to shrink axis extents and/or tick extents
if (xtl_ofs != 0.0 && s_ycross == FALSE) {
if (o_xticks == BELOW) {
- ya_min += 2.5 * charheight;
+ ya_min += 1.5 * charheight;
yt_min = ya_min;
} else if (o_xticks == ABOVE) {
ya_min += 0.0;
- yt_min = ya_min + 2.5 * charheight;
+ yt_min = ya_min + 1.5 * charheight;
}
} else // noaxis, no t-labels, or user set cross
yt_min = ya_min;
if (ytl_ofs != 0.0 && s_xcross == FALSE) {
if (o_yticks == LEFT) {
- xa_min += (1 + y_fldwid) * charwidth;
+ xa_min += (2 + y_fldwid) * charwidth;
xt_min = xa_min;
} else if (o_yticks == RIGHT) {
xa_min += 0.0;
}
} else
xt_min = xa_min;
-
+
// decrease size of graph, if necessary, to accommadate space
// between axis boundary and boundary of ticks
double x_added_ticks = 0; // number of tick spaces added to axis
rSGP.setTextColor (1, -1);
if (o_xticks == ABOVE)
- xticklen = charheight;
+ xticklen = 0.5 * charheight;
else if (o_xticks == BELOW)
- xticklen = -charheight;
+ xticklen = -0.5 * charheight;
if (o_yticks == RIGHT)
yticklen = charwidth;
axis_near = TRUE;
}
if (o_ytlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
- rSGP.moveAbs (yaxispos + ytl_ofs, y + 0.5 * charheight);
+ snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);\r
+ rSGP.moveAbs (yaxispos + ytl_ofs, y + 0.5 * charheight);\r
rSGP.setTextColor (clr_number, -1);\r
rSGP.drawText (str);
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezset.cpp,v 1.12 2000/12/25 21:54:26 kevin Exp $
+** $Id: ezset.cpp,v 1.13 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "ezplot.h"
#include "pol.h"
-bool EZPlot::ezset_initialized = false;
-\r
\r
bool\r
EZPlot::ezset (const std::string& command)\r
bool
EZPlot::ezset (const char* const command)
{
- if (! ezset_initialized) {
- pol_init();
- initKeywords();
- pol_skpword ("please");
- pol_skpword ("use");
- pol_skpword ("are");
- pol_skpword ("and");
- pol_skpword ("is");
- pol_skpword ("the");
- pol_skpword ("equals");
- pol_skpchar ("=");
-
- pol_usefile (P_USE_STR,"");
- set_inputline ("!eoc ,");
- pol_reader ();
- pol_closefile ();
- ezset_initialized = true;
- }
- return ezcmd (command);
+\r
+ return ezcmd (command);
}
bool
EZPlot::ezcmd (const char* const comm)
{
- pol_usefile (P_USE_STR, "");
- set_inputline (comm);
+ m_pol.usefile (POL::P_USE_STR, "");
+ m_pol.set_inputline (comm);
- char str[MAXTOK+1];
+ char str [POL::MAXTOK+1];
int code;
bool retval = true;
- if (! pol_usertok (str, &code)) {
- sys_error(ERR_WARNING, "Illegal EZSET command: %s", str);
- pol_reader();
+ if (! m_pol.usertok (str, &code)) {
+ sys_error (ERR_WARNING, "Illegal EZSET command: %s", str);
+ m_pol.reader();
retval = false;
}
else
retval = do_cmd (code);
- pol_closefile(); /* close input string file */
+ m_pol.closefile(); /* close input string file */
return (retval);
}
switch (lx) {
case S_TEXTSIZE:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
if (f >= 0.0 && f <= 1.0) {
v_textsize = f;
s_textsize = TRUE;
clearCurves ();
break;
case S_TITLE:
- gettext (strIn, sizeof(strIn));
+ m_pol.gettext (strIn, sizeof(strIn));
c_title = strIn;
break;
case S_LEGEND:
- gettext (strIn, sizeof(strIn));\r
+ m_pol.gettext (strIn, sizeof(strIn));\r
if (m_iCurrentCurve >= 0)\r
setLegend (m_iCurrentCurve, strIn);
break;
case S_XLABEL:
- gettext (strIn, sizeof(strIn));
+ m_pol.gettext (strIn, sizeof(strIn));
c_xlabel = strIn;
break;
case S_YLABEL:
- gettext (strIn, sizeof(strIn));
+ m_pol.gettext (strIn, sizeof(strIn));
c_ylabel = strIn;
break;
case S_XCROSS:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_xcross = f;
s_xcross = TRUE;
} else
s_xcross = FALSE;
break;
case S_YCROSS:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_ycross = f;
s_ycross = TRUE;
} else
s_ymax = FALSE;
break;
case S_XMIN:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_xmin = f;
s_xmin = TRUE;
}
break;
case S_XMAX:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_xmax = f;
s_xmax = TRUE;
}
break;
case S_YMIN:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_ymin = f;
s_ymin = TRUE;
}
break;
case S_YMAX:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE) {
v_ymax = f;
s_ymax = TRUE;
}
case S_DASH:
int ls;\r
ls = SGP::LS_DASH1;\r
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {\r
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {\r
if (n == 1)
ls = SGP::LS_DASH1;
else if (n == 2)
break;
case S_PEN:
case S_COLOR:
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
{
if (n >= 0) {\r
if (m_iCurrentCurve < 0)
o_grid = FALSE;
break;
case S_XLENGTH:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
if (f > 0.0 && f <= 1.0)
o_xlength = f;
break;
case S_YLENGTH:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
if (f > 0.0 && f <= 1.0)
o_ylength = f;
break;
case S_XPORIGIN:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
if (f >= 0.0 && f < 1.0)
o_xporigin = f;
break;
case S_YPORIGIN:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
if (f >= 0.0 && f < 1.0)
o_yporigin = f;
break;
case S_TAG:
- if (pol_word("no", 2) == TRUE)
+ if (m_pol.word("no", 2) == TRUE)
o_tag = FALSE;
- else if (pol_word("off", 2) == TRUE)
+ else if (m_pol.word("off", 2) == TRUE)
o_tag = FALSE;
else
o_tag = TRUE;
break;
case S_LEGENDBOX:
- if (pol_word("inside", 2) == TRUE)
+ if (m_pol.word("inside", 2) == TRUE)
o_legendbox = INSIDE;
- else if (pol_word("outside", 3) == TRUE)
+ else if (m_pol.word("outside", 3) == TRUE)
o_legendbox = OUTSIDE;
- else if (pol_word("none",2) == TRUE)
+ else if (m_pol.word("none",2) == TRUE)
o_legendbox = NOLEGEND;
else {
- gettext (str, MAXTOK);
+ m_pol.gettext (str, POL::MAXTOK);
bad_option(str);
}
break;
case S_XLEGEND:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
{
if (f >= 0.0 && f < 1.0) {
v_xlegend = f;
}
break;
case S_YLEGEND:
- if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE)
+ if (m_pol.readfloat (&f, POL::TT_REAL, FALSE, 0.0, 0.0) == TRUE)
{
if (f >= 0.0 && f < 1.0) {
v_ylegend = f;
}
break;
case S_SYMBOL:
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
if (n > 0 && n <= MAXSYMBOL) {
if (m_iCurrentCurve < 0)\r
o_symbol = n;\r
setSymbol (m_iCurrentCurve, n);\r
}\r
} else {
- if (pol_word("every",5) == TRUE) {
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {\r
+ if (m_pol.word("every",5) == TRUE) {
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {\r
int sym = 1;
if (n > 0)\r
sym = n;\r
else \r
setSymbolFreq (m_iCurrentCurve, sym);\r
}
- } else if (pol_word ("none",4) == TRUE) {
+ } else if (m_pol.word ("none",4) == TRUE) {
o_symbol = -1;
}
}
break;
case S_CURVE:\r
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {\r
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {\r
if (n > 0)\r
m_iCurrentCurve = n - 1;\r
} else {\r
- if (pol_word ("all",3) == TRUE) \r
+ if (m_pol.word ("all",3) == TRUE) \r
m_iCurrentCurve = -1;\r
}\r
break;\r
case S_XTICKS:
- if (pol_usertok(str,&lx) == FALSE)
+ if (m_pol.usertok(str,&lx) == FALSE)
break;
if (lx == S_ABOVE)
o_xticks = ABOVE;
else if (lx == S_LABEL)
o_xtlabel = TRUE;
else if (lx == S_MAJOR) {
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
if (n > 1 && n < 100)
o_xmajortick = n;
} else if (lx == S_MINOR)
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
if (n >= 0 && n < 100)
o_xminortick = n;
break;
case S_YTICKS:
- if (pol_usertok(str,&lx) == FALSE)
+ if (m_pol.usertok(str,&lx) == FALSE)
break;
if (lx == S_RIGHT)
o_yticks = RIGHT;
else if (lx == S_LABEL)
o_ytlabel = TRUE;
else if (lx == S_MAJOR) {
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
if (n > 1 && n < 100)
o_ymajortick = n;
} else if (lx == S_MINOR)
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE)
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE)
if (n >= 0 && n < 100)
o_yminortick = n;
break;
case S_LXFRAC:
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
if (n >= 0) {
v_lxfrac = n;
s_lxfrac = TRUE;
s_lxfrac = FALSE;
break;
case S_LYFRAC:
- if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) {
+ if (m_pol.integer (&n, POL::TT_REAL, FALSE, 0, 0) == TRUE) {
if (n >= 0) {
v_lyfrac = n;
s_lyfrac = TRUE;
break;
}
- pol_reader ();
+ m_pol.reader ();
return (true);
}
EZPlot::initKeywords ()
{
for (int i = 0; i < NKEYS; i++)
- if (! pol_install (m_sKeywords[i].keyword, m_sKeywords [i].code))
- sys_error(ERR_SEVERE, "error installing ezset keywords [EZPlot::initKeywords]");
+ if (! m_pol.installKeyword (m_sKeywords[i].keyword, m_sKeywords [i].code))
+ sys_error (ERR_SEVERE, "error installing ezset keywords [EZPlot::initKeywords]");
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: pol.cpp,v 1.5 2000/12/25 21:54:26 kevin Exp $
+** $Id: pol.cpp,v 1.6 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "pol.h"
-static const int HASHSIZE=100;
-// Tables words stored with install() & found with lookup()
-static SYMBOL *skiptable[HASHSIZE]; // words to ignore and skip
-static SYMBOL *cmdtable[HASHSIZE]; // pol parameter commands
-static SYMBOL *usertable[HASHSIZE]; // user defined symbols
-static struct token_st token; // current token
-\r
-
-static struct metachar {
- char eoc; /* end of command character */
- char str; /* string delimiter */
- char com; /* comment character */
- char cmd; /* pol parameter command character */
- char prg; /* program load character */
- char con; /* continuation across newline character */
- char out; /* character that delimits output to terminal */
- char ter; /* character indicates insertion of input from terminal */
- char inb; /* input from graphics device */
-} meta;
-
-\r
-// current pol state
-static struct pol_st {
- char skipchars[MAXSKIPCHAR]; // characters to skip
- int nl_eoc; // TRUE if newline character ends a command
- int trace; // TRUE if trace is on
-} pol;
-
-struct key {
- char *keyword;
- int code;
-};
-
-// Internal codes for pol commands
-enum {\r
- PC_EOC = 1,
- PC_STR,
- PC_COM,
- PC_CMD,
- PC_PRG,
- PC_CON,
- PC_OUT,
- PC_TER,
- PC_INB,
- PC_NL_EOC,
- PC_NL_NEOC,
- PC_TRON,
- PC_TROFF,
- PC_FILE,
- PC_DUMP,
-};
-\r
-static struct key cmdlist[] = {
+const struct POL::KeywordCodeList POL::cmdlist[] = {
{ "eoc", PC_EOC,},
{ "str", PC_STR,},
{ "com", PC_COM,},
{ "dump", PC_DUMP,},
};
-const int NUMCMD = (sizeof(cmdlist) / sizeof (struct key));
+const int POL::NUMCMD = (sizeof(POL::cmdlist) / sizeof (struct POL::KeywordCodeList));
\r
-static int skiptok(char term[]);
-static int pol_tok(struct token_st *token);
-static void dumptok(struct token_st *token);
-
-
-static int getpol_tok(struct token_st *token);
-static int getcmd(void);
-static int gettok (TOKEN *tok);
-static void getblank(char *s, int toksiz);
-static int getalpha(char *s, int toksiz);
-static void getquote(char *qs, int toksiz);
-static void getescape(char *s, int delim, int toksiz);
-static int getnumber (char str[], int strsize, double *fnum, int *inum);
-static void eatline(void);
-static int type(int c);
-static void inittable(SYMBOL *table[]);
-static void freetable(SYMBOL *table[]);
-static int hash(char *s);
-static SYMBOL *lookup(SYMBOL *table[], char *s);
-static SYMBOL *install(SYMBOL *table[], char *s, int def);
-static int pol_getch(FILE *fp);
-
-
-void pol_init (void)
+POL::POL()
+{
+ bp = 0;
+ currentf = -1;
+ init();
+}
+
+POL::~POL()
+{
+}
+
+void
+POL::init ()
{
meta.eoc = SEMICOL;
meta.str = DQUOTE;
token.ready = FALSE; /* no token read yet */
}
-/* pol_skpword (w)
+/* skpword (w)
*
* char *w - word for pol to ignore and skip over in input
*
- * pol_tok() compares all tokens to words given to this routine. If it finds it,
+ * tok() compares all tokens to words given to this routine. If it finds it,
* it will immediately read another token.
*/
void
-pol_skpword (char *w)
+POL::skpword (char *w)
{
if (install (skiptable, w, 0) == NULL)
sys_error (ERR_SEVERE, "Too many skip words defined");
}
-/* pol_skpchar (s)
+/* skpchar (s)
*
* skip all characters that appear in string s
*/
void
-pol_skpchar (char *s)
+POL::skpchar (char *s)
{
strncpy (pol.skipchars, s, MAXSKIPCHAR);
}
-/* pol_install (str, code)
- *
- * char *str - token string to install
- * int code - code to return for token
- *
- * pol_tok() looks for these user defined tokens. If it finds one,
- * it stores the tokens code in the token structure and returns TT_USERTOK
- */
+// installKeyword (str, code)
+//
+// char *str - token string to install
+// int code - code to return for token
+//
+// tok() looks for these user defined tokens. If it finds one,
+// it stores the tokens code in the token structure and returns TT_USERTOK
int
-pol_install (char *str, int code)
+POL::installKeyword (char *str, int code)
{
if (install (usertable, str, code) == NULL)
{
*/
int
-pol_word (char *search, int nlet)
+POL::word (char *search, int nlet)
{
- pol_tok (&token);
+ tok (&token);
if (pol.trace == TRUE)
printf ("matching current token %s against word %s\n", token.tokstr, search);
return (FALSE);
}
-/* pol_usertok (str,code)
- * see if current token is a user defined token set with pol_install()
+/* usertok (str,code)
+ * see if current token is a user defined token set with install()
*
* char *str - token string as read from input
* int *code - returned code for user defined symbol
* FALSE if current token is not user defined
*/
int
-pol_usertok (char *str, int *code)
+POL::usertok (char *str, int *code)
{
- pol_tok (&token);
+ tok (&token);
if (pol.trace == TRUE)
printf ("checking if current token '%s' is user defined\n", token.tokstr);
*/
int
-pol_string (char *str)
+POL::string (char *str)
{
- pol_tok (&token);
+ tok (&token);
if (token.type == TT_STRING) {
strcpy (str, token.tokstr);
return (FALSE);
}
-/* pol_integer - test for an integer
+/* integer - test for an integer
*
* int *n: returned integer value
* int typecode = TT_INT if accept only integer values
* int bb2: upper bound
*/
int
-pol_integer (int *n, int typecode, int boundcode, int bb1, int bb2)
+POL::integer (int *n, int typecode, int boundcode, int bb1, int bb2)
{
- pol_tok (&token);
+ tok (&token);
if (pol.trace == TRUE)
printf ("checking if current token %s is an integer\n", token.tokstr);
return (FALSE);
}
-int
-pol_float (double *n, double typecode, double boundcode, double bb1, double bb2)
+bool\r
+POL::readfloat (double *n, double typecode, double boundcode, double bb1, double bb2)
{
- pol_tok (&token);
+ tok (&token);
if (pol.trace == TRUE)
printf ("checking if current token %s is an floating point number\n", token.tokstr);
}
/*----------------------------------------------------------------------*/
-/* pol_skip() - skip over any token except for end of command sequence */
+/* skip() - skip over any token except for end of command sequence */
/* */
/* returns TRUE if succesful skip */
/* returns FALSE if already at end of command or EOF */
/*----------------------------------------------------------------------*/
-int pol_skip(void)
+int
+POL::skip()
{
char term[5]; /* string of characters not to skip */
return (skiptok (term));
}
-void pol_reader(void)
+void \r
+POL::reader()
{
- while (pol_skip() == TRUE)
+ while (skip() == TRUE)
;
dumptok (&token); /* skip end of command token */
* returns (FALSE) if didn't skip, read termination character or TT_EOF
*/
-static int
-skiptok (char term[])
+int
+POL::skiptok (char term[])
{
- pol_tok (&token);
+ tok (&token);
if (token.type == TT_EOF
|| (token.type == TT_SPECLCHAR && strchr(term, token.tokstr[0]) != NULL))
}
}
-static int
-pol_tok (struct token_st *token)
+int
+POL::tok (struct token_st *token)
{
if (token->ready == FALSE)
getpol_tok(token);
else
- if (token->type == TT_EOF && pol_lookchar() != EOF)
+ if (token->type == TT_EOF && lookchar() != EOF)
getpol_tok(token);
return (token->type);
}
-static void
-dumptok (struct token_st *token)
+void
+POL::dumptok (struct token_st *token)
{
if (token->ready == FALSE)
getpol_tok(token);
token->ready = FALSE;
}
-static int
-getpol_tok (struct token_st *token)
+int
+POL::getpol_tok (struct token_st *token)
{
SYMBOL *sym;
goto nexttok;
}
if (token->tokstr[0] == meta.con) { /* continuation across NEWLINE */
- while (pol_lookchar() == BLANK || pol_lookchar() == TAB)
- pol_inchar();
- if (pol_lookchar() == NEWLINE)
- pol_inchar();
+ while (lookchar() == BLANK || lookchar() == TAB)
+ inchar();
+ if (lookchar() == NEWLINE)
+ inchar();
}
if (token->tokstr[0] == meta.ter) { /* get input from terminal */
- pol_usefile (P_USE_FILE, "");
- pol_tok (token);
- pol_closefile();
+ usefile (P_USE_FILE, "");
+ tok (token);
+ closefile();
return (token->type);
}
}
}
-static int getcmd(void)
+int
+POL::getcmd()
{
int tt, found;
char str[MAXTOK+1];
tt = getalpha (str, MAXTOK);
if (tt == TT_ERROR) {
sys_error (ERR_WARNING, "Error in POL parameter command");
- pol_reader();
+ reader();
return(FALSE);
}
if ((cmd = lookup (cmdtable,str)) == NULL) {
sys_error (ERR_WARNING, "POL: Unrecognized command %s", cmd);
- pol_reader();
+ reader();
return (FALSE);
} else {
found = FALSE;
case PC_FILE:
found = TRUE;
tt = gettok (&tok);
- pol_usefile (P_USE_FILE, tok.tokstr);
+ usefile (P_USE_FILE, tok.tokstr);
break;
case PC_NL_EOC:
found = TRUE;
break;
} /* switch (tok->type) */
} /* if (found == FALSE) */
- pol_reader(); /* clean up command */
+ reader(); /* clean up command */
} /* if legal command */
return (TRUE);
}
-static int
-gettok (TOKEN *tok)
+int
+POL::gettok (TOKEN *tok)
{
int c, toktype;
int inum;
double fnum;
int toksiz = MAXTOK; /* maximum length of token string */
- while ((c = pol_inchar()) == BLANK || c == TAB)
+ while ((c = inchar()) == BLANK || c == TAB)
;
- pol_ungetch (c);
+ ungetch (c);
- c = pol_lookchar();
+ c = lookchar();
toktype = type(c);
fnum = 0.0;
tok->tokstr[0] = EOS;
toktype = TT_EOF;
} else {
- c = pol_inchar();
+ c = inchar();
tok->tokstr[0] = c;
tok->tokstr[1] = EOS;
toktype = TT_SPECLCHAR;
}
-static void
-getblank (char *s, int toksiz)
+void
+POL::getblank (char *s, int toksiz)
{
int c;
- while ((c = pol_inchar()) == BLANK || c == TAB)
+ while ((c = inchar()) == BLANK || c == TAB)
;
- pol_ungetch(c);
+ ungetch(c);
s[0] = BLANK;
s[1] = EOS;
}
-static int
-getalpha (char *s, int toksiz)
+int
+POL::getalpha (char *s, int toksiz)
{
int i, chartype, alphatype;
- if (type(pol_lookchar()) != LETTER) {
+ if (type(lookchar()) != LETTER) {
s[0] = EOS;
return (TT_ERROR);
}
alphatype = TT_ALPHA;
for (i = 0; i < toksiz; i++) { /* get alphanumeric token */
- s[i] = pol_inchar();
+ s[i] = inchar();
chartype = type (s[i]);
if (chartype != LETTER && chartype != DIGIT)
break;
if (chartype == DIGIT)
alphatype = TT_ALPNUM;
}
- pol_ungetch(s[i]);
+ ungetch(s[i]);
if (i >= toksiz)
sys_error (ERR_SEVERE, "POL token too long.");
/* getquote - get quoted string from file */
/* have already gotten delimiter in qs[0] */
-static void
-getquote (char *qs, int toksiz)
+void
+POL::getquote (char *qs, int toksiz)
{
int delim;
- delim = pol_inchar(); /* char = delimiter */
+ delim = inchar(); /* char = delimiter */
getescape(qs, delim, toksiz);
}
-static void
-getescape ( /* reads up to delim */
+void
+POL::getescape ( /* reads up to delim */
char *s,
int delim,
int toksiz
{
int i, c;
- for (i = 0; (c = pol_inchar()) != delim; i++) {
+ for (i = 0; (c = inchar()) != delim; i++) {
if (c == NEWLINE) {
sys_error (ERR_WARNING, "Missing closing delimiter.");
break;
break;
}
if (c == EOF) {
- pol_ungetch(c);
+ ungetch(c);
sys_error (ERR_SEVERE, "end of file inside quotation");
break;
} else if (c == BSLASH) { /* escape character */
s[i++] = c;
- c = pol_inchar(); /* get escaped character */
+ c = inchar(); /* get escaped character */
}
s[i] = c;
}
}
void
-gettext (char *str, int lim)
+POL::gettext (char *str, int lim)
{
int c, i;
- while ((c = pol_inchar()) == BLANK || c == TAB)
+ while ((c = inchar()) == BLANK || c == TAB)
;
- pol_ungetch (c);
+ ungetch (c);
- for (i = 0; i < lim && (c = pol_inchar()) != EOF && c != NEWLINE; i++)
+ for (i = 0; i < lim && (c = inchar()) != EOF && c != NEWLINE; i++)
str[i] = c;
- pol_ungetch (c);
+ ungetch (c);
str[i] = EOS;
}
-/*----------------------------------------------*/
-/* Get a number for gettok() */
-/*----------------------------------------------*/
+//----------------------------------------------
+// Get a number for gettok()
+//----------------------------------------------
-static int
-getnumber (
+int
+POL::getnumber
+(
char str[], /* string to return token in */
int strsize, /* maximum length of token string */
double *fnum, /* floating point value of number read */
*inum = 0;
str[0] = EOS;
- c = pol_inchar();
+ c = inchar();
if (c == HYPHEN) {
str[sp++] = c;
isSigned = TRUE;
isSigned = TRUE;
sign = 1.0;
} else if (c == PERIOD) {
- if (type(pol_lookchar()) != DIGIT) {
+ if (type(lookchar()) != DIGIT) {
str[0] = PERIOD;
str[1] = EOS;
return (TT_SPECLCHAR);
} else
- pol_ungetch (PERIOD);
+ ungetch (PERIOD);
} else if (type(c) != DIGIT) {
- pol_ungetch (c);
+ ungetch (c);
return (TT_ERROR);
} else
- pol_ungetch (c);
+ ungetch (c);
if (isSigned == TRUE) {
- c = pol_lookchar();
+ c = lookchar();
if (c == PERIOD) {
- pol_inchar(); /* get period */
- c = pol_lookchar(); /* look at character past period */
- pol_ungetch (PERIOD); /* put back period */
+ inchar(); /* get period */
+ c = lookchar(); /* look at character past period */
+ ungetch (PERIOD); /* put back period */
if (type(c) != DIGIT) {
str[sp] = EOS;
return (TT_SPECLCHAR);
}
whole = 0.0;
- while (type(c = pol_inchar()) == DIGIT) {
+ while (type(c = inchar()) == DIGIT) {
if (sp < strsize)
str[sp++] = c;
whole = 10.0 * whole + (c - '0');
}
- pol_ungetch (c); /* put back non-numeric character */
+ ungetch (c); /* put back non-numeric character */
if (c != PERIOD && tolower(c) != 'e') {
str[sp] = EOS;
return (TT_INT);
}
- if (pol_lookchar() == PERIOD) {
- pol_inchar();
+ if (lookchar() == PERIOD) {
+ inchar();
if (sp < strsize)
str[sp++] = PERIOD;
}
frac = 0.0;
powerof10 = 10.0;
- while (type(c = pol_inchar()) == DIGIT) {
+ while (type(c = inchar()) == DIGIT) {
if (sp < strsize)
str[sp++] = c;
frac += (double) (c - '0') / powerof10;
powerof10 *= 10.0;
}
- pol_ungetch (c);
+ ungetch (c);
exp = 0.0;
expsign = 1.0;
- c = pol_inchar();
+ c = inchar();
if (tolower(c) != 'e')
- pol_ungetch (c);
+ ungetch (c);
else {
if (sp < strsize)
str[sp++] = c;
- if ((c = pol_inchar()) == PLUS) {
+ if ((c = inchar()) == PLUS) {
if (sp < strsize)
str[sp++] = c;
expsign = 1.0;
expsign = -1.0;
} else if (type(c) != DIGIT) {
--sp; /* erase 'e' */
- pol_ungetch (c);
- pol_ungetch ('e');
+ ungetch (c);
+ ungetch ('e');
goto getnumexit;
} else
- pol_ungetch(c);
+ ungetch(c);
exp = 0;
- while (type(c = pol_inchar()) == DIGIT) {
+ while (type(c = inchar()) == DIGIT) {
if (sp < strsize)
str[sp++] = c;
exp = 10 * exp + (c - '0');
}
- pol_ungetch (c);
+ ungetch (c);
}
getnumexit:
return (TT_REAL);
}
-static void
-eatline (void)
+void
+POL::eatline ()
{
char term [2];
skiptok (term);
}
-static int
-type ( /* return type of ASCII character */
- int c
-)
+// return type of ASCII character
+int
+POL::type (int c)
{
if (isalpha(c) || c == UNDERLIN)
return (LETTER);
* clear symbol table
*/
-static void
-inittable (SYMBOL *table[])
+void
+POL::inittable (SYMBOL *table[])
{
int i;
* free all memory allocated to table, then clear table
*/
-static void
-freetable (SYMBOL *table[])
+void
+POL::freetable (SYMBOL *table[])
{
int i;
SYMBOL *p, *np;
inittable (table);
}
-static int
-hash ( /* form hash value of string s */
- char *s
-)
+// form hash value of string s
+int
+POL::hash (char *s)
{
int hashval;
}
/* Look for s in hash table */
-static SYMBOL *
-lookup ( SYMBOL *table[], char *s )
+POL::SYMBOL *
+POL::lookup ( SYMBOL *table[], char *s )
{
SYMBOL *np;
SYMBOL *found = NULL;
return (found);
}
-static SYMBOL *
-install (SYMBOL *table[], char *name, int def)
+POL::SYMBOL *
+POL::install (SYMBOL *table[], char *name, int def)
{
static char installerr[] = "install: out of memory";
SYMBOL *np;
return (np);
}
-/*----------------------------------------------------------------------*/
-/* POL OUTPUT */
-/*----------------------------------------------------------------------*/
-
-#define MAXFILE 8
-
-static int currentf = -1; /* pointer to current fp */
-static FILE *filep[MAXFILE]; /* == NULL for string input */
-static char *fname[MAXFILE]; /* pointer to filename */
-
-static char inputline[MAXLINE]; /* current input line */
-static int lineptr; /* current position in inputline */
-
-
//----------------------------------------------------------------------
// POL INPUT
//----------------------------------------------------------------------
-#define BUFSIZE 100
-static int bp = 0; /* pointer to next free position */
-static int buf[BUFSIZE]; /* pushed back input characters */
-/* pol_usefile - set source of POL input
+/* usefile - set source of POL input
*
* int source - source of input
* P_USE_STR - have POL use strings as input
*/
void
-pol_usefile (int source, char *fn)
+POL::usefile (int source, char *fn)
{
FILE *fp;
}
}
-void pol_closefile(void)
+void
+POL::closefile()
{
if (currentf >= 0) {
if (filep[currentf] != NULL)
/*-----------------------------*/
-int pol_lookchar(void)
+int
+POL::lookchar()
{
int c;
- c = pol_inchar();
- pol_ungetch (c);
+ c = inchar();
+ ungetch (c);
return (c);
}
-int pol_inchar(void)
+int
+POL::inchar()
{
int c = 0;
if (currentf < 0)
return (EOF);
- while (currentf >= 0 && (c = pol_getch(filep[currentf])) == EOF && filep[currentf] != NULL) {
- pol_closefile ();
+ while (currentf >= 0 && (c = getch(filep[currentf])) == EOF && filep[currentf] != NULL) {
+ closefile ();
}
return (c);
/* if fp == NULL, then get character from inputline */
/*--------------------------------------------------------------*/
-static int
-pol_getch (FILE *fp)
+int
+POL::getch (FILE *fp)
{
int c;
/* push character back on input */
void
-pol_ungetch (int c)
+POL::ungetch (int c)
{
if (bp > BUFSIZE)
- sys_error (ERR_SEVERE, "too many characters pushed back [pol_ungetch]");
+ sys_error (ERR_SEVERE, "too many characters pushed back [ungetch]");
else
buf[bp++] = c;
}
int
-get_inputline (FILE *fp)
+POL::get_inputline (FILE *fp)
{
lineptr = 0;
bp = 0;
}
void
-set_inputline (const char* const line)
+POL::set_inputline (const char* const line)
{
lineptr = 0;
bp = 0;
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: plotfile.cpp,v 1.5 2000/12/23 18:12:35 kevin Exp $
+** $Id: plotfile.cpp,v 1.6 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
}
fs.seekp (0);
- fs << "<plotfile>\n";\r
- fs << "<ncolumns>" << m_iNumColumns << "</ncolumns>\n";\r
- fs << "<nrecords>" << m_iNumRecords << "</nrecords>\n";\r
+ fs << "<plotfile " << m_iNumColumns << " " << m_iNumRecords << " >\n";\r
int iNEzset = m_vecStrEzsetCommands.size();\r
if (iNEzset > 0) {\r
--------------------Configuration: libctsim - Win32 Debug--------------------\r
</h3>\r
<h3>Command Lines</h3>\r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A3.tmp" with contents\r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP42.tmp" with contents\r
[\r
/nologo /G6 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\..\..\zlib" /I "..\..\INCLUDE" /I "..\..\getopt" /I "..\..\..\lpng108" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /I "..\..\..\wx2\include" /D "_DEBUG" /D "HAVE_WXWIN" /D "HAVE_STRING_H" /D "HAVE_GETOPT_H" /D "WIN32" /D "_MBCS" /D "_LIB" /D "MSVC" /D "HAVE_FFTW" /D "HAVE_PNG" /D "HAVE_SGP" /D "HAVE_WXWINDOWS" /D "__WXMSW__" /FR"Debug/" /Fp"Debug/libctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c \r
+"C:\ctsim-2.0.6\libctsim\backprojectors.cpp"\r
"C:\ctsim-2.0.6\libctgraphics\ezplot.cpp"\r
+"C:\ctsim-2.0.6\libctgraphics\ezset.cpp"\r
+"C:\ctsim-2.0.6\libctgraphics\ezsupport.cpp"\r
+"C:\ctsim-2.0.6\libctsim\filter.cpp"\r
+"C:\ctsim-2.0.6\libctsim\imagefile.cpp"\r
+"C:\ctsim-2.0.6\libctsim\phantom.cpp"\r
+"C:\ctsim-2.0.6\libctsupport\plotfile.cpp"\r
+"C:\ctsim-2.0.6\libctgraphics\pol.cpp"\r
+"C:\ctsim-2.0.6\libctsim\procsignal.cpp"\r
+"C:\ctsim-2.0.6\libctsim\projections.cpp"\r
+"C:\ctsim-2.0.6\libctsim\reconstruct.cpp"\r
+"C:\ctsim-2.0.6\libctsim\scanner.cpp"\r
+"C:\ctsim-2.0.6\libctsim\trace.cpp"\r
]\r
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A3.tmp" \r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A4.tmp" with contents\r
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP42.tmp" \r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP43.tmp" with contents\r
[\r
/nologo /out:"Debug\libctsim.lib" \r
".\Debug\array2dfile.obj"\r
".\Debug\transformmatrix.obj"\r
".\Debug\xform.obj"\r
]\r
-Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A4.tmp"\r
+Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP43.tmp"\r
<h3>Output Window</h3>\r
Compiling...\r
+backprojectors.cpp\r
ezplot.cpp\r
+ezset.cpp\r
+ezsupport.cpp\r
+filter.cpp\r
+imagefile.cpp\r
+phantom.cpp\r
+plotfile.cpp\r
+pol.cpp\r
+procsignal.cpp\r
+projections.cpp\r
+reconstruct.cpp\r
+scanner.cpp\r
+trace.cpp\r
Creating library...\r
<h3>\r
--------------------Configuration: ctsim - Win32 Debug--------------------\r
</h3>\r
<h3>Command Lines</h3>\r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A5.tmp" with contents\r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP44.tmp" with contents\r
+[\r
+/nologo /G6 /MTd /W3 /Gm /GR /GX /ZI /Od /I "\wx2\include" /I "." /I "..\..\include" /I "..\..\getopt" /I "..\..\..\lpng108" /I "..\..\..\zlib" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"2.5.0\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"2.5.0\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c \r
+"C:\ctsim-2.0.6\src\ctsim.cpp"\r
+"C:\ctsim-2.0.6\src\dialogs.cpp"\r
+"C:\ctsim-2.0.6\src\dlgprojections.cpp"\r
+"C:\ctsim-2.0.6\src\dlgreconstruct.cpp"\r
+"C:\ctsim-2.0.6\src\docs.cpp"\r
+"C:\ctsim-2.0.6\src\views.cpp"\r
+]\r
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP44.tmp" \r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP45.tmp" with contents\r
[\r
comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libctsim/Debug/libctsim.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\lpng108\msvc\win32\libpng\lib_dbg\libpng.lib ..\..\..\lpng108\msvc\win32\zlib\lib_dbg\zlib.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib ../../../wx2/lib/wxd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrtd.lib" /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"..\..\..\lpng108\msvc\win32\libpng\lib" /libpath:"..\..\..\lpng108\msvc\win32\zlib\lib" \r
".\Debug\ctsim.obj"\r
"\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib"\r
"\wx2\lib\wxd.lib"\r
]\r
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A5.tmp"\r
+Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP45.tmp"\r
<h3>Output Window</h3>\r
+Compiling...\r
+ctsim.cpp\r
+dialogs.cpp\r
+dlgprojections.cpp\r
+dlgreconstruct.cpp\r
+docs.cpp\r
+views.cpp\r
Linking...\r
+Creating command line "bscmake.exe /nologo /o"Debug/ctsim.bsc" ".\Debug\ctsim.sbr" ".\Debug\dialogs.sbr" ".\Debug\dlgprojections.sbr" ".\Debug\dlgreconstruct.sbr" ".\Debug\docs.sbr" ".\Debug\views.sbr""\r
+Creating browse info file...\r
+<h3>Output Window</h3>\r
\r
\r
\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsim.cpp,v 1.20 2000/12/22 04:18:00 kevin Exp $
+** $Id: ctsim.cpp,v 1.21 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#endif
#endif
\r
-static const char* rcsindent = "$Id: ctsim.cpp,v 1.20 2000/12/22 04:18:00 kevin Exp $";
+static const char* rcsindent = "$Id: ctsim.cpp,v 1.21 2000/12/27 03:16:02 kevin Exp $";
class CTSimApp* theApp = NULL;
int nx = rIF.nx();\r
int ny = rIF.ny();\r
wxList& rListDocs = m_docManager->GetDocuments();\r
- std::vector<std::string> vecFilename;\r
for (wxNode* pNode = rListDocs.GetFirst(); pNode != NULL; pNode = pNode->GetNext()) {\r
wxDocument* pDoc = reinterpret_cast<wxDocument*>(pNode->GetData());\r
ImageFileDocument* pIFCompareDoc = dynamic_cast<ImageFileDocument*>(pDoc);\r
if (pIFCompareDoc && (pIFDoc != pIFCompareDoc)) {\r
const ImageFile& rCompareIF = pIFCompareDoc->getImageFile();\r
- if (rCompareIF.nx() == nx && rCompareIF.ny() == ny) {\r
- std::string strFilename = pDoc->GetFilename();\r
+ if (rCompareIF.nx() == nx && rCompareIF.ny() == ny)\r
vecIF.push_back (pIFCompareDoc);\r
- }\r
}\r
}\r
}\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: dialogs.cpp,v 1.20 2000/12/22 04:18:00 kevin Exp $
+** $Id: dialogs.cpp,v 1.21 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "wx/statline.h"
#include "wx/sizer.h"
#include "dialogs.h"
-#include "ctsupport.h"
#include "ctsim.h"
-#include "scanner.h"
-#include "phantom.h"
-#include "filter.h"
-#include "backprojectors.h"
+#include "ct.h"\r
+//#include "ctsupport.h"\r
+//#include "scanner.h"
+//#include "phantom.h"
+//#include "filter.h"
+//#include "backprojectors.h"
#include "docs.h"\r
#include "views.h"\r
#include "imagefile.h"\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: docs.cpp,v 1.7 2000/12/19 21:37:51 kevin Exp $
+** $Id: docs.cpp,v 1.8 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
IMPLEMENT_DYNAMIC_CLASS(PlotFileDocument, wxDocument)
+bool PlotFileDocument::OnSaveDocument(const wxString& filename)\r
+{\r
+ m_namePlot = filename.c_str();\r
+ if (! m_plot.fileWrite (filename)) {\r
+ *theApp->getLog() << "Unable to write plot file " << filename << "\n";\r
+ return false;\r
+ }\r
+ *theApp->getLog() << "Wrote plot file " << filename << "\n";\r
+ Modify(false);\r
+ return true;\r
+}\r
+\r
bool PlotFileDocument::OnOpenDocument(const wxString& filename)
{
if (filename == "untitled.plt") {
return false;
}
*theApp->getLog() << "Read plot file " << filename << "\n";
- SetFilename(filename, true);
+ SetFilename(filename, true);\r
+ m_namePlot = filename.c_str();
}
Modify(false);
UpdateAllViews();\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: docs.h,v 1.8 2000/12/22 04:18:00 kevin Exp $
+** $Id: docs.h,v 1.9 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
PlotFile& getPlotFile ()\r
{ return m_plot; }\r
\r
- virtual bool OnOpenDocument (const wxString& filename);
+ virtual bool OnOpenDocument (const wxString& filename);\r
+ virtual bool OnSaveDocument (const wxString& filename);\r
virtual bool OnCloseDocument ();
virtual bool IsModified () const;
virtual void Modify (bool mod);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.38 2000/12/25 21:54:26 kevin Exp $
+** $Id: views.cpp,v 1.39 2000/12/27 03:16:02 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
int nx = rIF.nx();\r
int ny = rIF.ny();\r
\r
+ int yPt = ny - y - 1;\r
dc.SetLogicalFunction (wxINVERT);\r
dc.SetPen (*wxGREEN_PEN);\r
- dc.DrawLine (0, y, nx, y);\r
+ dc.DrawLine (0, yPt, nx, yPt);\r
dc.DrawLine (x, 0, x, ny);\r
dc.SetLogicalFunction (wxCOPY);\r
}\r
wxPoint pt(event.GetLogicalPosition(dc));
\r
+ const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
+ ImageFileArrayConst v = rIF.getArray();\r
+ int nx = rIF.nx();\r
+ int ny = rIF.ny();\r
+ const int yPt = ny - 1 - pt.y;\r
if (event.RightIsDown()) {\r
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
- ImageFileArrayConst v = rIF.getArray();\r
- int nx = rIF.nx();\r
- int ny = rIF.ny();\r
- \r
if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
std::ostringstream os;\r
- os << "Image value (" << pt.x << "," << pt.y << ") = " << v[pt.x][ny - 1 - pt.y] << "\n";\r
+ os << "Image value (" << pt.x << "," << yPt << ") = " << v[pt.x][yPt] << "\n";\r
*theApp->getLog() << os.str().c_str();\r
} else\r
- *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+ *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";\r
}\r
- else if (event.LeftIsDown() || event.LeftUp()) {\r
- const ImageFile& rIF = m_pView->GetDocument()->getImageFile();\r
- ImageFileArrayConst v = rIF.getArray();\r
- int nx = rIF.nx();\r
- int ny = rIF.ny();\r
- \r
+ else if (event.LeftIsDown() || event.LeftUp() || event.RightUp()) {\r
if (pt.x >= 0 && pt.x < nx && pt.y >= 0 && pt.y < ny) {\r
if (m_xCursor >= 0 && m_yCursor >= 0) {\r
DrawRubberBandCursor (dc, m_xCursor, m_yCursor);\r
}\r
- DrawRubberBandCursor (dc, pt.x, pt.y);\r
+ DrawRubberBandCursor (dc, pt.x, yPt);\r
m_xCursor = pt.x;\r
- m_yCursor = pt.y;\r
+ m_yCursor = yPt;\r
} else\r
- *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << pt.y << ")\n";\r
+ *theApp->getLog() << "Mouse out of image range (" << pt.x << "," << yPt << ")\n";\r
}\r
if (event.LeftUp()) {\r
std::ostringstream os;\r
- os << "Selected column " << pt.x << " , row " << pt.y << "\n";\r
+ os << "Selected column " << pt.x << " , row " << yPt << "\n";\r
*theApp->getLog() << os.str().c_str();\r
}\r
}
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Column");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("box");\r
rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Row");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("box");\r
rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Row");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("curve 1");\r
rPlotFile.addEzsetCommand ("color 2");\r
rPlotFile.addEzsetCommand ("curve 2");\r
rPlotFile.addEzsetCommand (title.c_str());\r
rPlotFile.addEzsetCommand ("xlabel Column");\r
rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("lxfrac 0");\r
rPlotFile.addEzsetCommand ("curve 1");\r
rPlotFile.addEzsetCommand ("color 2");\r
rPlotFile.addEzsetCommand ("curve 2");\r
m_canvas->GetClientSize (&xsize, &ysize);\r
SGPDriver driver (dc, xsize, ysize);\r
SGP sgp (driver);\r
- const PlotFile& rPhantom = GetDocument()->getPlotFile();\r
EZPlot plot (sgp);\r
\r
for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++)\r