r315: Coverted POL to C++ class
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 27 Dec 2000 03:16:02 +0000 (03:16 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 27 Dec 2000 03:16:02 +0000 (03:16 +0000)
13 files changed:
ChangeLog
include/ezplot.h
include/pol.h
libctgraphics/ezplot.cpp
libctgraphics/ezset.cpp
libctgraphics/pol.cpp
libctsupport/plotfile.cpp
msvc/ctsim/ctsim.plg
src/ctsim.cpp
src/dialogs.cpp
src/docs.cpp
src/docs.h
src/views.cpp

index b8cd410aeb6fb799913232ee225fc2837a2fe5b4..894573e2ec55892cce0d498458d6326d231f82ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,7 @@ TODO
        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.
@@ -37,8 +37,11 @@ TODO
        * 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 
index a7559da265de0bfc90bc32a5cb27117581a1d4a1..b2512aab987e21ec0aa43b3c1408b65651bf7ae7 100644 (file)
@@ -7,7 +7,7 @@
 **  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
@@ -32,7 +32,8 @@
 #include <cmath>
 #include <stddef.h>
 #include "ctsupport.h"
-#include "sgp.h"
+#include "sgp.h"\r
+#include "pol.h"
 
 
 class EZPlotCurve {
@@ -319,6 +320,7 @@ private:
   int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);
   
   SGP& rSGP;
+  POL m_pol;\r
   
   void clearCurves ();
   
@@ -327,10 +329,8 @@ private:
   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; }
   
index 54ff9f01435fe8f7dc4f6977dc718084bbb16960..7ac752595ec83979195bc31d836c8073ccf4501b 100644 (file)
@@ -2,7 +2,7 @@
 **  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
 
index eab8cc37bebda290d0428b3b64a9a5ca98ab66e2..383136105a76a91ec5bdf119aec638bf1f3f191c 100644 (file)
@@ -6,7 +6,7 @@
 **  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
@@ -137,7 +137,22 @@ EZPlot::clearCurves ()
 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
@@ -544,17 +559,19 @@ EZPlot::plot ()
   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;
@@ -563,18 +580,18 @@ EZPlot::plot ()
   // 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;
@@ -582,7 +599,7 @@ EZPlot::plot ()
     }
   } 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 
@@ -713,9 +730,9 @@ EZPlot::drawAxes()
   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;
@@ -884,8 +901,8 @@ EZPlot::drawAxes()
             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);
         }
index b380e9a00ff4f021eef71ff1d5d030c421dd056b..69131447e5e0da40c8c49475a03c14fe4f2cfc8f 100644 (file)
@@ -6,7 +6,7 @@
 **  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
@@ -26,8 +26,6 @@
 #include "ezplot.h"
 #include "pol.h"
 
-bool EZPlot::ezset_initialized = false;
-\r
 \r
 bool\r
 EZPlot::ezset (const std::string& command)\r
@@ -38,45 +36,28 @@ EZPlot::ezset (const std::string& command)
 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);
 }
 
@@ -91,7 +72,7 @@ EZPlot::do_cmd (int lx)
   
   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;
@@ -106,31 +87,31 @@ EZPlot::do_cmd (int lx)
     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
@@ -163,25 +144,25 @@ EZPlot::do_cmd (int lx)
     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;
     }
@@ -192,7 +173,7 @@ EZPlot::do_cmd (int lx)
   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)
@@ -214,7 +195,7 @@ EZPlot::do_cmd (int lx)
     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)
@@ -238,47 +219,47 @@ EZPlot::do_cmd (int lx)
     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;
@@ -289,7 +270,7 @@ EZPlot::do_cmd (int lx)
     }
     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;
@@ -300,7 +281,7 @@ EZPlot::do_cmd (int lx)
     }
     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
@@ -308,8 +289,8 @@ EZPlot::do_cmd (int lx)
           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
@@ -318,22 +299,22 @@ EZPlot::do_cmd (int lx)
           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;
@@ -344,16 +325,16 @@ EZPlot::do_cmd (int lx)
     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;
@@ -364,16 +345,16 @@ EZPlot::do_cmd (int lx)
     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;
@@ -382,7 +363,7 @@ EZPlot::do_cmd (int lx)
       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;
@@ -396,7 +377,7 @@ EZPlot::do_cmd (int lx)
     break;
   }
   
-  pol_reader ();
+  m_pol.reader ();
   return (true);
 }
 
@@ -499,6 +480,6 @@ void
 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]");
 }
index 5ba490028b29b371648ef806fd5e714d14798457..f3ef311a614dccad8c07b1a51251f4b010e462fe 100644 (file)
@@ -6,7 +6,7 @@
 **  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,},
@@ -106,33 +54,22 @@ static struct key cmdlist[] = {
   {    "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;
@@ -157,41 +94,40 @@ void pol_init (void)
        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)
        {
@@ -209,9 +145,9 @@ pol_install (char *str, int code)
  */
 
 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);
 
@@ -222,8 +158,8 @@ pol_word (char *search, int nlet)
            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
@@ -231,9 +167,9 @@ pol_word (char *search, int nlet)
  *                  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);
@@ -255,9 +191,9 @@ pol_usertok (char *str, int *code)
 */
  
 int 
-pol_string (char *str)
+POL::string (char *str)
 {
-       pol_tok (&token);
+       tok (&token);
 
        if (token.type == TT_STRING) {
            strcpy (str, token.tokstr);
@@ -267,7 +203,7 @@ pol_string (char *str)
            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
@@ -278,9 +214,9 @@ pol_string (char *str)
  * 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);
@@ -302,10 +238,10 @@ pol_integer (int *n, int typecode, int boundcode, int bb1, int bb2)
        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);
@@ -328,13 +264,14 @@ pol_float (double *n, double typecode, double boundcode, double bb1, double bb2)
 }
 
 /*----------------------------------------------------------------------*/
-/* 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 */
 
@@ -348,9 +285,10 @@ int pol_skip(void)
        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 */
@@ -364,10 +302,10 @@ void pol_reader(void)
  * 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))
@@ -378,27 +316,27 @@ skiptok (char term[])
        }
 }
 
-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;
 
@@ -427,15 +365,15 @@ nexttok:
                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);
            }
        }
@@ -460,7 +398,8 @@ nexttok:
 }
 
 
-static int getcmd(void)
+int 
+POL::getcmd()
 {
        int tt, found;
        char str[MAXTOK+1];
@@ -470,12 +409,12 @@ static int getcmd(void)
        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;
@@ -491,7 +430,7 @@ static int getcmd(void)
                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;
@@ -548,26 +487,26 @@ static int getcmd(void)
                        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;
@@ -587,7 +526,7 @@ gettok (TOKEN *tok)
            tok->tokstr[0] = EOS;
            toktype = TT_EOF;
        } else {
-           c = pol_inchar();
+           c = inchar();
            tok->tokstr[0] = c;
            tok->tokstr[1] = EOS;
            toktype = TT_SPECLCHAR;
@@ -607,40 +546,40 @@ gettok (TOKEN *tok)
 }
 
 
-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.");
@@ -652,18 +591,18 @@ getalpha (char *s, int toksiz)
 
 /* 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
@@ -671,7 +610,7 @@ getescape ( /* reads up to delim */
 {
        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;
@@ -681,12 +620,12 @@ getescape (       /* reads up to delim */
                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;
        }
@@ -694,26 +633,27 @@ getescape (       /* reads up to delim */
 }
 
 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 */
@@ -730,7 +670,7 @@ getnumber (
        *inum = 0;
        str[0] = EOS;
 
-       c = pol_inchar();
+       c = inchar();
        if (c == HYPHEN) {
            str[sp++] = c;
            isSigned = TRUE;
@@ -740,24 +680,24 @@ getnumber (
            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);
@@ -769,12 +709,12 @@ getnumber (
        }
 
        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;
@@ -788,8 +728,8 @@ getnumber (
            return (TT_INT);
        }
 
-       if (pol_lookchar() == PERIOD) {
-           pol_inchar();
+       if (lookchar() == PERIOD) {
+           inchar();
            if (sp < strsize)
                str[sp++] = PERIOD;
        }
@@ -797,23 +737,23 @@ getnumber (
        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;
@@ -823,19 +763,19 @@ getnumber (
                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:
@@ -850,8 +790,8 @@ getnumexit:
        return (TT_REAL);
 }
 
-static void 
-eatline (void)
+void 
+POL::eatline ()
 {
        char term [2];
 
@@ -860,10 +800,9 @@ eatline (void)
        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);
@@ -883,8 +822,8 @@ type (              /* return type of ASCII character */
  *     clear symbol table
 */
 
-static void 
-inittable (SYMBOL *table[])
+void 
+POL::inittable (SYMBOL *table[])
 {
        int i;
 
@@ -896,8 +835,8 @@ inittable (SYMBOL *table[])
  *     free all memory allocated to table, then clear table
  */
 
-static void 
-freetable (SYMBOL *table[])
+void 
+POL::freetable (SYMBOL *table[])
 {
        int i;
        SYMBOL *p, *np;
@@ -913,10 +852,9 @@ freetable (SYMBOL *table[])
        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;
 
@@ -926,8 +864,8 @@ hash (              /* form hash value of string s */
 }
 
 /* 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;
@@ -941,8 +879,8 @@ lookup ( SYMBOL *table[], char *s )
     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;
@@ -968,29 +906,12 @@ install (SYMBOL *table[], char *name, int def)
     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
@@ -999,7 +920,7 @@ static int buf[BUFSIZE];    /* pushed back input characters */
 */
 
 void 
-pol_usefile (int source, char *fn)
+POL::usefile (int source, char *fn)
 {
        FILE *fp;
 
@@ -1027,7 +948,8 @@ pol_usefile (int source, char *fn)
        }
 }
 
-void pol_closefile(void)
+void 
+POL::closefile()
 {
        if (currentf >= 0) {
            if (filep[currentf] != NULL)
@@ -1041,24 +963,26 @@ void pol_closefile(void)
 /*-----------------------------*/
 
 
-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);
@@ -1069,8 +993,8 @@ int pol_inchar(void)
 /*        if fp == NULL, then get character from inputline     */
 /*--------------------------------------------------------------*/
 
-static int 
-pol_getch (FILE *fp)
+int 
+POL::getch (FILE *fp)
 {
        int c;
 
@@ -1092,17 +1016,17 @@ pol_getch (FILE *fp)
 
 /* 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;
@@ -1113,7 +1037,7 @@ get_inputline (FILE *fp)
 }
 
 void 
-set_inputline (const char* const line)
+POL::set_inputline (const char* const line)
 {
        lineptr = 0;
        bp = 0;
index b05705aed89f03356a3ea8740cd20ddb487a0d7a..706fce1d352bcd367e22e257965c7ea4c3ebbb2b 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -242,9 +242,7 @@ PlotFile::headerWrite (std::iostream& fs)
   }
   
   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
index c6fc5148a341630ba873db9f0f29d3b017c2daa5..427763314aa1346607ff3228126aa582f84f008c 100644 (file)
@@ -6,13 +6,26 @@
 --------------------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
@@ -42,16 +55,40 @@ Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2A4.tmp" with conten
 ".\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
@@ -66,9 +103,19 @@ comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib w
 "\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
index b128641a90be1fa3bffc42bc206995b4af14ec2e..06c91ea444c332ae36889539eb8fbcc4beedd65b 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -61,7 +61,7 @@
 #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;
 
@@ -292,16 +292,13 @@ CTSimApp::getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<Imag
   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
index 7d8c0ecab7e7dbf3fd526e644476806382a40e6f..4a4473559838ef02954f4e1e1f48bd28578853b0 100644 (file)
@@ -9,7 +9,7 @@
 **  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
index c3fd4892fd8747a0eb08adda81880eb0936f2703..ac7e3a69c08b3c156767ecf13c70f3127e16b205 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -201,6 +201,18 @@ void PhantomDocument::Modify(bool mod)
 
 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") {
@@ -212,7 +224,8 @@ bool PlotFileDocument::OnOpenDocument(const wxString& filename)
       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
index 116347ccdd2fe3198d5072d654b7eb68c1c2af9f..3729ce4b7211809888fc4332bf760426338bdd77 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -147,7 +147,8 @@ public:
     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);
index 9188b34714abb25b48898c89476271b96d76c679..465990360c18f9dc160ff598a4e48bca40db67ac 100644 (file)
@@ -9,7 +9,7 @@
 **  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
@@ -91,9 +91,10 @@ ImageFileCanvas::DrawRubberBandCursor (wxDC& dc, int x, int y)
   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
@@ -121,38 +122,33 @@ ImageFileCanvas::OnMouseEvent(wxMouseEvent& event)
   
   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
 }
@@ -501,6 +497,7 @@ ImageFileView::OnPlotRow (wxCommandEvent& event)
       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
@@ -548,6 +545,7 @@ ImageFileView::OnPlotCol (wxCommandEvent& event)
       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
@@ -609,6 +607,7 @@ ImageFileView::OnCompareCol (wxCommandEvent& event)
         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
@@ -680,6 +679,7 @@ ImageFileView::OnCompareRow (wxCommandEvent& event)
         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
@@ -1540,7 +1540,6 @@ PlotFileView::OnDraw (wxDC* dc)
     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