From 739e435359d44546dd812fff8c86b815a214d587 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 20 Dec 2000 14:39:09 +0000 Subject: [PATCH] r307: additions for plotfile --- include/ezplot.h | 7 +- include/plotfile.h | 15 +- include/pol.h | 40 +- libctgraphics/ezset.cpp | 863 +++++++++++++++++++------------------- libctgraphics/pol.cpp | 4 +- libctsupport/plotfile.cpp | 15 +- msvc/ctsim/ctsim.plg | 33 +- src/ctsim.cpp | 6 +- src/docs.h | 8 +- src/views.cpp | 122 +++--- src/views.h | 17 +- 11 files changed, 592 insertions(+), 538 deletions(-) diff --git a/include/ezplot.h b/include/ezplot.h index 31291bd..67c6e31 100644 --- a/include/ezplot.h +++ b/include/ezplot.h @@ -7,7 +7,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ezplot.h,v 1.18 2000/12/16 06:12:47 kevin Exp $ +** $Id: ezplot.h,v 1.19 2000/12/20 14:39:09 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 @@ -206,7 +206,7 @@ class EZPlot { void clearCurves (); - bool ezcmd (char *comm); + bool ezcmd (const char const *comm); bool do_cmd(int lx); void bad_option(char *opt); void initPlotSettings(); @@ -225,7 +225,8 @@ class EZPlot { EZPlot (SGP& sgp); ~EZPlot (); - int ezset (char *command); + bool ezset (const std::string& command); + bool ezset (const char const *command); void addCurve (const float* x, const double* y, int num); void addCurve (const double* x, const float* y, int num); diff --git a/include/plotfile.h b/include/plotfile.h index 35c7f9f..af627b4 100644 --- a/include/plotfile.h +++ b/include/plotfile.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: plotfile.h,v 1.1 2000/12/19 21:37:10 kevin Exp $ +** $Id: plotfile.h,v 1.2 2000/12/20 14:39:09 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 @@ -93,13 +93,22 @@ public: void setTitle (const std::string& title) { m_strTitle = title; } + + void setTitle (const char* const title) + { m_strTitle = title; } void setXLabel (const std::string& label) { m_strXLabel = label; } + + void setXLabel (const char* const label) + { m_strXLabel = label; } void setYLabel (const std::string& label) { m_strYLabel = label; } + void setYLabel (const char* const label) + { m_strYLabel = label; } + void setCurveSize (int iNCurves, int iNRecords); void addDescription (const char* const pszDesc) @@ -109,6 +118,8 @@ public: bool addColumn (int iCol, const float* const pdColumn); + void getColumn (int iCol, double *pdColumnData) const; + const std::string& getTitle () const { return m_strTitle; } @@ -118,7 +129,7 @@ public: const std::string& getYLabel () const { return m_strXLabel; } - const std::string& getData () const + const std::string& getDate () const { return m_strDate; } int getNumColumns () const diff --git a/include/pol.h b/include/pol.h index 49a45c2..cf5d8e0 100644 --- a/include/pol.h +++ b/include/pol.h @@ -2,7 +2,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: pol.h,v 1.4 2000/06/13 16:20:31 kevin Exp $ +** $Id: pol.h,v 1.5 2000/12/20 14:39:09 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 @@ -88,24 +88,24 @@ struct token_st { typedef struct token_st TOKEN; /* 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(char *line); +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 diff --git a/libctgraphics/ezset.cpp b/libctgraphics/ezset.cpp index 4e68671..ed396aa 100644 --- a/libctgraphics/ezset.cpp +++ b/libctgraphics/ezset.cpp @@ -1,372 +1,379 @@ /***************************************************************************** - ** FILE IDENTIFICATION - ** - ** EZSET - Parameter control for EZPLOT - ** - ** This is part of the CTSim program - ** Copyright (C) 1983-2000 Kevin Rosenberg - ** - ** $Id: ezset.cpp,v 1.9 2000/12/06 15:17:51 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 - ** published by the Free Software Foundation. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program; if not, write to the Free Software - ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ******************************************************************************/ +** FILE IDENTIFICATION +** +** EZSET - Parameter control for EZPLOT +** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: ezset.cpp,v 1.10 2000/12/20 14:39:09 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 +** published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +******************************************************************************/ #include "ctsupport.h" #include "ezplot.h" #include "pol.h" bool EZPlot::ezset_initialized = false; + + +bool +EZPlot::ezset (const std::string& command) +{ + return ezset (command.c_str()); +} -int -EZPlot::ezset (char *command) +bool +EZPlot::ezset (const char const *command) { - if (! ezset_initialized) { - pol_init(); - initkw(); - 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)); + if (! ezset_initialized) { + pol_init(); + initkw(); + 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); } bool -EZPlot::ezcmd (char *comm) +EZPlot::ezcmd (const char const *comm) { - pol_usefile (P_USE_STR, ""); - set_inputline (comm); - - char str[MAXTOK+1]; - int code; - bool retval = true; - if (! pol_usertok (str, &code)) { - sys_error(ERR_WARNING, "Illegal EZSET command: %s", str); - pol_reader(); - retval = false; - } - else - retval = do_cmd (code); - - pol_closefile(); /* close input string file */ - return (retval); + pol_usefile (P_USE_STR, ""); + set_inputline (comm); + + char str[MAXTOK+1]; + int code; + bool retval = true; + if (! pol_usertok (str, &code)) { + sys_error(ERR_WARNING, "Illegal EZSET command: %s", str); + pol_reader(); + retval = false; + } + else + retval = do_cmd (code); + + pol_closefile(); /* close input string file */ + return (retval); } bool EZPlot::do_cmd (int lx) { - char str [1024]; - char strIn [1024]; - int n; - double f; - - switch (lx) { - case S_TEXTSIZE: - if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) - { - if (f >= 0.0 && f <= 1.0) { - v_textsize = f; - s_textsize = TRUE; - } else - s_textsize = FALSE; - } - break; - case S_REPLOT: - plot (); - break; - case S_CLEAR: - clearCurves (); - break; - case S_TITLE: - gettext (strIn, sizeof(strIn)); - c_title = strIn; - break; - case S_LEGEND: - gettext (strIn, sizeof(strIn)); - c_legend = strIn; - break; - case S_XLABEL: - gettext (strIn, sizeof(strIn)); - c_xlabel = strIn; - break; - case S_YLABEL: - gettext (strIn, sizeof(strIn)); - c_ylabel = strIn; - break; - case S_XCROSS: - if (pol_float (&f, 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) { - v_ycross = f; - s_ycross = TRUE; - } else - s_ycross = FALSE; - break; - case S_NOXAXIS: - o_xaxis = NOAXIS; - break; - case S_NOYAXIS: - o_yaxis = NOAXIS; - break; - case S_XLIN: - o_xaxis = LINEAR; - break; - case S_YLIN: - o_yaxis = LINEAR; - break; - case S_XLOG: - o_xaxis = LOG; - break; - case S_YLOG: - o_yaxis = LOG; - break; - case S_XAUTOSCALE: - s_xmin = FALSE; - s_xmax = FALSE; - break; - case S_YAUTOSCALE: - s_ymin = FALSE; - s_ymax = FALSE; - break; - case S_XMIN: - if (pol_float (&f, 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) { - v_xmax = f; - s_xmax = TRUE; - } - break; - case S_YMIN: - if (pol_float (&f, 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) { - v_ymax = f; - s_ymax = TRUE; - } - break; - case S_SOLID: - o_linestyle = SGP::LS_SOLID; - break; - case S_DASH: - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { - if (n == 1) - o_linestyle = SGP::LS_DASH1; - else if (n == 2) - o_linestyle = SGP::LS_DASH2; - else if (n == 3) - o_linestyle = SGP::LS_DASH3; - else if (n == 4) - o_linestyle = SGP::LS_DASH4; - else - o_linestyle = SGP::LS_DASH1; - } else - o_linestyle = SGP::LS_DASH1; - break; - case S_NOLINE: - o_linestyle = SGP::LS_NOLINE; - break; - case S_PEN: - case S_COLOR: - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) - { - if (n >= 0) - o_color = n; - else - bad_option("The color you picked"); - } - break; - case S_BOX: - o_box = TRUE; - break; - case S_NOBOX: - o_box = FALSE; - break; - case S_GRID: - o_grid = TRUE; - break; - case S_NOGRID: - o_grid = FALSE; - break; - case S_XLENGTH: - if (pol_float (&f, 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 (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 (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 (f >= 0.0 && f < 1.0) - o_yporigin = f; - break; - case S_TAG: - if (pol_word("no", 2) == TRUE) - o_tag = FALSE; - else if (pol_word("off", 2) == TRUE) - o_tag = FALSE; - else - o_tag = TRUE; - break; - case S_LEGENDBOX: - if (pol_word("inside", 2) == TRUE) - o_legendbox = INSIDE; - else if (pol_word("outside", 3) == TRUE) - o_legendbox = OUTSIDE; - else if (pol_word("none",2) == TRUE) - o_legendbox = NOLEGEND; - else { - gettext (str, MAXTOK); - bad_option(str); - } - break; - case S_XLEGEND: - if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) - { - if (f >= 0.0 && f < 1.0) { - v_xlegend = f; - s_xlegend = TRUE; - } - else - s_xlegend = FALSE; - } - break; - case S_YLEGEND: - if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) - { - if (f >= 0.0 && f < 1.0) { - v_ylegend = f; - s_ylegend = TRUE; - } - else - s_ylegend = FALSE; - } - break; - case S_SYMBOL: - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { - if (n > 0 && n <= MAXSYMBOL) - o_symbol = n; - else - o_symbol = 1; - } else { - if (pol_word("every",5) == TRUE) { - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { - if (n > 0) - o_symfreq = n; - else - o_symfreq = 1; - } - } else if (pol_word ("none",4) == TRUE) { - o_symbol = -1; - } - } - break; - case S_XTICKS: - if (pol_usertok(str,&lx) == FALSE) - break; - if (lx == S_ABOVE) - o_xticks = ABOVE; - else if (lx == S_BELOW) - o_xticks = BELOW; - else if (lx == S_NOLABEL) - o_xtlabel = FALSE; - else if (lx == S_LABEL) - o_xtlabel = TRUE; - else if (lx == S_MAJOR) { - if (pol_integer (&n, 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 (n >= 0 && n < 100) - o_xminortick = n; - break; - case S_YTICKS: - if (pol_usertok(str,&lx) == FALSE) - break; - if (lx == S_RIGHT) - o_yticks = RIGHT; - else if (lx == S_LEFT) - o_yticks = LEFT; - else if (lx == S_NOLABEL) - o_ytlabel = FALSE; - else if (lx == S_LABEL) - o_ytlabel = TRUE; - else if (lx == S_MAJOR) { - if (pol_integer (&n, 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 (n >= 0 && n < 100) - o_yminortick = n; - break; - case S_LXFRAC: - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { - if (n >= 0) { - v_lxfrac = n; - s_lxfrac = TRUE; - } - } else - s_lxfrac = FALSE; - break; - case S_LYFRAC: - if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { - if (n >= 0) { - v_lyfrac = n; - s_lyfrac = TRUE; - } - } else - s_lyfrac = FALSE; - break; - break; - default: - fprintf (stderr, "Unimplemented EZPLOT command\n"); - break; + char str [1024]; + char strIn [1024]; + int n; + double f; + + switch (lx) { + case S_TEXTSIZE: + if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) + { + if (f >= 0.0 && f <= 1.0) { + v_textsize = f; + s_textsize = TRUE; + } else + s_textsize = FALSE; + } + break; + case S_REPLOT: + plot (); + break; + case S_CLEAR: + clearCurves (); + break; + case S_TITLE: + gettext (strIn, sizeof(strIn)); + c_title = strIn; + break; + case S_LEGEND: + gettext (strIn, sizeof(strIn)); + c_legend = strIn; + break; + case S_XLABEL: + gettext (strIn, sizeof(strIn)); + c_xlabel = strIn; + break; + case S_YLABEL: + gettext (strIn, sizeof(strIn)); + c_ylabel = strIn; + break; + case S_XCROSS: + if (pol_float (&f, 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) { + v_ycross = f; + s_ycross = TRUE; + } else + s_ycross = FALSE; + break; + case S_NOXAXIS: + o_xaxis = NOAXIS; + break; + case S_NOYAXIS: + o_yaxis = NOAXIS; + break; + case S_XLIN: + o_xaxis = LINEAR; + break; + case S_YLIN: + o_yaxis = LINEAR; + break; + case S_XLOG: + o_xaxis = LOG; + break; + case S_YLOG: + o_yaxis = LOG; + break; + case S_XAUTOSCALE: + s_xmin = FALSE; + s_xmax = FALSE; + break; + case S_YAUTOSCALE: + s_ymin = FALSE; + s_ymax = FALSE; + break; + case S_XMIN: + if (pol_float (&f, 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) { + v_xmax = f; + s_xmax = TRUE; + } + break; + case S_YMIN: + if (pol_float (&f, 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) { + v_ymax = f; + s_ymax = TRUE; + } + break; + case S_SOLID: + o_linestyle = SGP::LS_SOLID; + break; + case S_DASH: + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { + if (n == 1) + o_linestyle = SGP::LS_DASH1; + else if (n == 2) + o_linestyle = SGP::LS_DASH2; + else if (n == 3) + o_linestyle = SGP::LS_DASH3; + else if (n == 4) + o_linestyle = SGP::LS_DASH4; + else + o_linestyle = SGP::LS_DASH1; + } else + o_linestyle = SGP::LS_DASH1; + break; + case S_NOLINE: + o_linestyle = SGP::LS_NOLINE; + break; + case S_PEN: + case S_COLOR: + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) + { + if (n >= 0) + o_color = n; + else + bad_option("The color you picked"); + } + break; + case S_BOX: + o_box = TRUE; + break; + case S_NOBOX: + o_box = FALSE; + break; + case S_GRID: + o_grid = TRUE; + break; + case S_NOGRID: + o_grid = FALSE; + break; + case S_XLENGTH: + if (pol_float (&f, 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 (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 (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 (f >= 0.0 && f < 1.0) + o_yporigin = f; + break; + case S_TAG: + if (pol_word("no", 2) == TRUE) + o_tag = FALSE; + else if (pol_word("off", 2) == TRUE) + o_tag = FALSE; + else + o_tag = TRUE; + break; + case S_LEGENDBOX: + if (pol_word("inside", 2) == TRUE) + o_legendbox = INSIDE; + else if (pol_word("outside", 3) == TRUE) + o_legendbox = OUTSIDE; + else if (pol_word("none",2) == TRUE) + o_legendbox = NOLEGEND; + else { + gettext (str, MAXTOK); + bad_option(str); + } + break; + case S_XLEGEND: + if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) + { + if (f >= 0.0 && f < 1.0) { + v_xlegend = f; + s_xlegend = TRUE; + } + else + s_xlegend = FALSE; + } + break; + case S_YLEGEND: + if (pol_float (&f, TT_REAL, FALSE, 0.0, 0.0) == TRUE) + { + if (f >= 0.0 && f < 1.0) { + v_ylegend = f; + s_ylegend = TRUE; + } + else + s_ylegend = FALSE; + } + break; + case S_SYMBOL: + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { + if (n > 0 && n <= MAXSYMBOL) + o_symbol = n; + else + o_symbol = 1; + } else { + if (pol_word("every",5) == TRUE) { + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { + if (n > 0) + o_symfreq = n; + else + o_symfreq = 1; + } + } else if (pol_word ("none",4) == TRUE) { + o_symbol = -1; + } + } + break; + case S_XTICKS: + if (pol_usertok(str,&lx) == FALSE) + break; + if (lx == S_ABOVE) + o_xticks = ABOVE; + else if (lx == S_BELOW) + o_xticks = BELOW; + else if (lx == S_NOLABEL) + o_xtlabel = FALSE; + else if (lx == S_LABEL) + o_xtlabel = TRUE; + else if (lx == S_MAJOR) { + if (pol_integer (&n, 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 (n >= 0 && n < 100) + o_xminortick = n; + break; + case S_YTICKS: + if (pol_usertok(str,&lx) == FALSE) + break; + if (lx == S_RIGHT) + o_yticks = RIGHT; + else if (lx == S_LEFT) + o_yticks = LEFT; + else if (lx == S_NOLABEL) + o_ytlabel = FALSE; + else if (lx == S_LABEL) + o_ytlabel = TRUE; + else if (lx == S_MAJOR) { + if (pol_integer (&n, 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 (n >= 0 && n < 100) + o_yminortick = n; + break; + case S_LXFRAC: + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { + if (n >= 0) { + v_lxfrac = n; + s_lxfrac = TRUE; + } + } else + s_lxfrac = FALSE; + break; + case S_LYFRAC: + if (pol_integer (&n, TT_REAL, FALSE, 0, 0) == TRUE) { + if (n >= 0) { + v_lyfrac = n; + s_lyfrac = TRUE; + } + } else + s_lyfrac = FALSE; + break; + break; + default: + fprintf (stderr, "Unimplemented EZPLOT command\n"); + break; } - + pol_reader (); return (true); } @@ -376,7 +383,7 @@ EZPlot::do_cmd (int lx) void EZPlot::bad_option (char *opt) { - sys_error (ERR_WARNING, "INVALID option: %s", opt); + sys_error (ERR_WARNING, "INVALID option: %s", opt); } /*----------------------------------------------------------------------*/ @@ -384,93 +391,93 @@ EZPlot::bad_option (char *opt) /*----------------------------------------------------------------------*/ static struct key { - char *keyword; - int code; + char *keyword; + int code; } keytab[] = { {"solid", S_SOLID}, {"dash", S_DASH}, - {"noline", S_NOLINE}, - {"black", S_BLACK}, - {"red", S_RED}, - {"blue", S_BLUE}, - {"green", S_GREEN}, + {"noline", S_NOLINE}, + {"black", S_BLACK}, + {"red", S_RED}, + {"blue", S_BLUE}, + {"green", S_GREEN}, {"pen", S_PEN}, - {"symbol", S_SYMBOL}, - {"every", S_EVERY}, - {"none", S_NONE}, - {"legend", S_LEGEND}, - {"xlegend", S_XLEGEND}, - {"ylegend", S_YLEGEND}, - - {"xlin", S_XLIN}, + {"symbol", S_SYMBOL}, + {"every", S_EVERY}, + {"none", S_NONE}, + {"legend", S_LEGEND}, + {"xlegend", S_XLEGEND}, + {"ylegend", S_YLEGEND}, + + {"xlin", S_XLIN}, {"ylin", S_YLIN}, - {"xlog", S_XLOG}, - {"ylog", S_YLOG}, - {"xlabel", S_XLABEL}, - {"ylabel", S_YLABEL}, - {"xlength", S_XLENGTH}, - {"ylength", S_YLENGTH}, - - {"xticks", S_XTICKS}, - {"yticks", S_YTICKS}, - {"above", S_ABOVE}, - {"label", S_LABEL}, - {"below", S_BELOW}, - {"nolabel", S_NOLABEL}, - {"right", S_RIGHT}, - {"left", S_LEFT}, - - {"xautoscale", S_XAUTOSCALE}, - {"yautoscale", S_YAUTOSCALE}, - {"xmin", S_XMIN}, - {"ymin", S_YMIN}, - {"xmax", S_XMAX}, - {"ymax", S_YMAX}, - {"lxfrac", S_LXFRAC}, - {"lyfrac", S_LYFRAC}, - {"xcross", S_XCROSS}, - {"ycross", S_YCROSS}, - {"noxaxis", S_NOXAXIS}, - {"noyaxis", S_NOYAXIS}, - {"xporigin", S_XPORIGIN}, - {"yporigin", S_YPORIGIN}, - {"title", S_TITLE}, - {"xtitle", S_XTITLE}, - {"ytitle", S_YTITLE}, - - {"replot", S_REPLOT}, - {"clear", S_CLEAR}, - {"store", S_STORE}, - {"restore", S_RESTORE}, - {"amark", S_AMARK}, - {"units", S_UNITS}, - {"inches", S_INCHES}, - {"user", S_USER}, - - {"data", S_DATA}, - {"help", S_HELP}, - {"exit", S_EXIT}, - - {"box", S_BOX}, - {"nobox", S_NOBOX}, - {"grid", S_GRID}, - {"nogrid", S_NOGRID}, - {"major", S_MAJOR}, - {"minor", S_MINOR}, - {"color", S_COLOR}, - {"legendbox", S_LEGENDBOX}, - - {"no", S_NO}, - - {"textsize", S_TEXTSIZE}, - }; + {"xlog", S_XLOG}, + {"ylog", S_YLOG}, + {"xlabel", S_XLABEL}, + {"ylabel", S_YLABEL}, + {"xlength", S_XLENGTH}, + {"ylength", S_YLENGTH}, + + {"xticks", S_XTICKS}, + {"yticks", S_YTICKS}, + {"above", S_ABOVE}, + {"label", S_LABEL}, + {"below", S_BELOW}, + {"nolabel", S_NOLABEL}, + {"right", S_RIGHT}, + {"left", S_LEFT}, + + {"xautoscale", S_XAUTOSCALE}, + {"yautoscale", S_YAUTOSCALE}, + {"xmin", S_XMIN}, + {"ymin", S_YMIN}, + {"xmax", S_XMAX}, + {"ymax", S_YMAX}, + {"lxfrac", S_LXFRAC}, + {"lyfrac", S_LYFRAC}, + {"xcross", S_XCROSS}, + {"ycross", S_YCROSS}, + {"noxaxis", S_NOXAXIS}, + {"noyaxis", S_NOYAXIS}, + {"xporigin", S_XPORIGIN}, + {"yporigin", S_YPORIGIN}, + {"title", S_TITLE}, + {"xtitle", S_XTITLE}, + {"ytitle", S_YTITLE}, + + {"replot", S_REPLOT}, + {"clear", S_CLEAR}, + {"store", S_STORE}, + {"restore", S_RESTORE}, + {"amark", S_AMARK}, + {"units", S_UNITS}, + {"inches", S_INCHES}, + {"user", S_USER}, + + {"data", S_DATA}, + {"help", S_HELP}, + {"exit", S_EXIT}, + + {"box", S_BOX}, + {"nobox", S_NOBOX}, + {"grid", S_GRID}, + {"nogrid", S_NOGRID}, + {"major", S_MAJOR}, + {"minor", S_MINOR}, + {"color", S_COLOR}, + {"legendbox", S_LEGENDBOX}, + + {"no", S_NO}, + + {"textsize", S_TEXTSIZE}, +}; static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key)); void EZPlot::initkw(void) { - for (unsigned int i = 0; i < NKEYS; i++) - if (! pol_install(keytab[i].keyword, keytab[i].code)) - sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]"); + for (unsigned int i = 0; i < NKEYS; i++) + if (! pol_install(keytab[i].keyword, keytab[i].code)) + sys_error(ERR_SEVERE, "error installing ezset keywords [initkw]"); } diff --git a/libctgraphics/pol.cpp b/libctgraphics/pol.cpp index 035f323..d4a162f 100644 --- a/libctgraphics/pol.cpp +++ b/libctgraphics/pol.cpp @@ -6,7 +6,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: pol.cpp,v 1.3 2000/12/04 05:36:57 kevin Exp $ +** $Id: pol.cpp,v 1.4 2000/12/20 14:39:09 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 @@ -1118,7 +1118,7 @@ get_inputline (FILE *fp) } void -set_inputline (char *line) +set_inputline (const char const *line) { lineptr = 0; bp = 0; diff --git a/libctsupport/plotfile.cpp b/libctsupport/plotfile.cpp index 588c014..b874451 100644 --- a/libctsupport/plotfile.cpp +++ b/libctsupport/plotfile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: plotfile.cpp,v 1.1 2000/12/19 21:37:10 kevin Exp $ +** $Id: plotfile.cpp,v 1.2 2000/12/20 14:39:09 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 @@ -104,6 +104,19 @@ PlotFile::addColumn (int iCol, const float* const pdColData) return true; } +void +PlotFile::getColumn (int iCol, double* pdColData) const +{ + if (iCol < 0 || iCol >= m_iNumColumns) { + sys_error (ERR_SEVERE, "Illegal column number %d [PlotFile::addColumn]", iCol); + return; + } + + for (int iRec = 0; iRec < m_iNumRecords; iRec++) + pdColData[iRec] = m_vecCurves[ iRec + (iCol * m_iNumRecords) ]; + +} + bool PlotFile::fileWrite (const char* const filename) { diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index e7655cf..0ac5c94 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -6,7 +6,13 @@ --------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP70.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPD3.tmp" with contents +[ +/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 +"C:\ctsim-2.0.6\src\views.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPD3.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPD4.tmp" with contents [ 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" ".\Debug\ctsim.obj" @@ -21,14 +27,35 @@ 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" "\wx2\lib\wxd.lib" ] -Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP70.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPD4.tmp"

Output Window

+Compiling... +views.cpp +c:\program files\microsoft visual studio\vc98\include\vector(48) : warning C4786: '??0?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QAE@IABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@ABV?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@1@@Z' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(61) : warning C4786: '??0?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QAE@PBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@0ABV?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@1@@Z' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(103) : warning C4786: '?rbegin@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QAE?AV?$reverse_iterator@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@AAV12@PAV12@H@2@XZ' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(105) : warning C4786: '?rbegin@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QBE?AV?$reverse_iterator@PBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@ABV12@PBV12@H@2@XZ' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(107) : warning C4786: '?rend@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QAE?AV?$reverse_iterator@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@AAV12@PAV12@H@2@XZ' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(108) : warning C4786: '?rend@?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QBE?AV?$reverse_iterator@PBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@ABV12@PBV12@H@2@XZ' : identifier was truncated to '255' characters in the browser information + c:\ctsim-2.0.6\include\plotfile.h(74) : see reference to class template instantiation 'std::vector,class std::allocator >,class std::allocator,class std::allocator > > >' being compiled +c:\program files\microsoft visual studio\vc98\include\vector(114) : warning C4786: 'std::reverse_iterator,std::allocator > const *,std::basic_string,std::allocator >,std::basic_string,std::allocator > const &,std::basic_string,std::allocator > const *,int>' : identifier was truncated to '255' characters in the debug information + c:\program files\microsoft visual studio\vc98\include\vector(114) : while compiling class-template member function 'unsigned int __thiscall std::vector,std::allocator >,std::allocator,std::allocator > > >::size(void) const' +c:\program files\microsoft visual studio\vc98\include\vector(114) : warning C4786: 'std::reverse_iterator,std::allocator > *,std::basic_string,std::allocator >,std::basic_string,std::allocator > &,std::basic_string,std::allocator > *,int>' : identifier was truncated to '255' characters in the debug information + c:\program files\microsoft visual studio\vc98\include\vector(114) : while compiling class-template member function 'unsigned int __thiscall std::vector,std::allocator >,std::allocator,std::allocator > > >::size(void) const' Linking... +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"" +Creating browse info file... +

Output Window

Results

-ctsim.exe - 0 error(s), 0 warning(s) +ctsim.exe - 0 error(s), 8 warning(s) diff --git a/src/ctsim.cpp b/src/ctsim.cpp index 0c09001..bdd8a59 100644 --- a/src/ctsim.cpp +++ b/src/ctsim.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctsim.cpp,v 1.18 2000/12/19 21:37:51 kevin Exp $ +** $Id: ctsim.cpp,v 1.19 2000/12/20 14:39:09 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 -static const char* rcsindent = "$Id: ctsim.cpp,v 1.18 2000/12/19 21:37:51 kevin Exp $"; +static const char* rcsindent = "$Id: ctsim.cpp,v 1.19 2000/12/20 14:39:09 kevin Exp $"; class CTSimApp* theApp = NULL; @@ -128,7 +128,7 @@ CTSimApp::OnInit() new wxDocTemplate (m_docManager, "PhantomFile", "*.phm", "", "phm", "Phantom doc", "Phantom View", CLASSINFO(PhantomDocument), CLASSINFO(PhantomView)); - new wxDocTemplate (m_docManager, "PlotFile", "*.plt", "", "plot", "Plot doc", "Plot View", CLASSINFO(PlotFileDocument), CLASSINFO(PlotFileView)); + new wxDocTemplate (m_docManager, "PlotFile", "*.plt", "", "plt", "Plot doc", "Plot View", CLASSINFO(PlotFileDocument), CLASSINFO(PlotFileView)); //// Create the main frame window m_pFrame = new MainFrame(m_docManager, (wxFrame *) NULL, -1, "CTSim", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE); diff --git a/src/docs.h b/src/docs.h index 5afcf63..7b337bb 100644 --- a/src/docs.h +++ b/src/docs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: docs.h,v 1.6 2000/12/19 21:37:51 kevin Exp $ +** $Id: docs.h,v 1.7 2000/12/20 14:39:09 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 @@ -143,9 +143,9 @@ public: const PlotFile& getPlotFile () const { return m_plot; } - PlotFile& getPlot () - { return m_plot; } - + PlotFile& getPlotFile () + { return m_plot; } + virtual bool OnOpenDocument (const wxString& filename); virtual bool OnCloseDocument (); virtual bool IsModified () const; diff --git a/src/views.cpp b/src/views.cpp index 81eb051..d3827f0 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.cpp,v 1.31 2000/12/19 21:37:51 kevin Exp $ +** $Id: views.cpp,v 1.32 2000/12/20 14:39:09 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 @@ -406,36 +406,12 @@ ImageFileView::OnClose (bool deleteWindow) #include "wx/plot.h" -class VectorPlotCurve : wxPlotCurve { -private: - int m_nPoints; - std::vector m_points; - -public: - VectorPlotCurve (const double* const points, int n, double minVal, double maxVal) - : wxPlotCurve (minVal, minVal, maxVal) - { - for (int i = 0; i < n; i++) - m_points.push_back(points[i]); - } - - wxInt32 GetStartX () - { return 0; } - - wxInt32 GetEndX () - { return m_nPoints - 1; } - - double GetY (wxInt32 x) - { return m_points[x]; } -}; - - void ImageFileView::OnPlotRow (wxCommandEvent& event) { int xCursor, yCursor; if (! m_canvas->GetCurrentCursor (xCursor, yCursor)) { - // os << "No row selected. Please use left mouse button on image to select row\n"; + *theApp->getLog() << "No row selected. Please use left mouse button on image to select row\n"; return; } @@ -445,21 +421,26 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) int ny = rIF.ny(); if (v != NULL && yCursor < ny) { - double* pVec = new double [nx]; - double minVal = v[0][yCursor]; - double maxVal = minVal; + double* pX = new double [nx]; + double* pY = new double [nx]; for (int i = 0; i < nx; i++) { - pVec[i] = v[i][yCursor]; - if (pVec[i] < minVal) - minVal = pVec[i]; - else if (pVec[i] > maxVal) - maxVal = pVec[i]; + pX[i] = i; + pY[i] = v[i][yCursor]; + } + PlotFileDocument* pPlotDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.plt", wxDOC_SILENT)); + if (! pPlotDoc) { + sys_error (ERR_SEVERE, "Internal error: unable to create Plot file"); + } else { + PlotFile& rPlot = pPlotDoc->getPlotFile(); + rPlot.setTitle("Row Plot"); + rPlot.setXLabel("Column"); + rPlot.setYLabel("Pixel Value"); + rPlot.setCurveSize (2, nx); + rPlot.addColumn (0, pX); + rPlot.addColumn (1, pY); + delete pX; + delete pY; } - VectorPlotCurve* plotCurve = new VectorPlotCurve (pVec, nx, minVal, maxVal); - wxPlotWindow* plotWindow = new wxPlotWindow (m_canvas, NULL, wxPoint(0,0), wxSize(500,300)); - plotWindow->Add (reinterpret_cast(plotCurve)); - plotWindow->Enable(TRUE); - plotWindow->Show(); } } @@ -489,10 +470,6 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) maxVal = v[xCursor][i]; pVec[i] = v[xCursor][i]; } - - VectorPlotCurve* plotCurve = new VectorPlotCurve (pVec, ny, minVal, maxVal); - wxPlotWindow plotWindow (m_canvas, NULL, wxPoint(0,0), wxSize(500,300)); - plotWindow.Add (reinterpret_cast(plotCurve)); } } @@ -1126,7 +1103,6 @@ ProjectionFileView::OnClose (bool deleteWindow) // PlotFileCanvas - PlotFileCanvas::PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style) : wxScrolledWindow(frame, -1, pos, size, style) { @@ -1160,7 +1136,7 @@ PlotFileView::~PlotFileView(void) void PlotFileView::OnProperties (wxCommandEvent& event) { - const PlotFile& rProj = GetDocument()->getPlot(); + const PlotFile& rProj = GetDocument()->getPlotFile(); std::ostringstream os; os << "Columns: " << rProj.getNumColumns() << ", Records: " << rProj.getNumRecords() << "\n"; *theApp->getLog() << os.str().c_str(); @@ -1249,23 +1225,57 @@ PlotFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) void PlotFileView::OnDraw (wxDC* dc) { - if (m_bitmap.Ok()) - dc->DrawBitmap (m_bitmap, 0, 0, false); + const PlotFile& rPlot = GetDocument()->getPlotFile(); + const int iNColumns = rPlot.getNumColumns(); + const int iNRecords = rPlot.getNumRecords(); + + if (iNColumns > 0 && iNRecords > 0) { + int xsize, ysize; + m_canvas->GetClientSize (&xsize, &ysize); + SGPDriver driver (dc, xsize, ysize); + SGP sgp (driver); + const PlotFile& rPhantom = GetDocument()->getPlotFile(); + EZPlot plot (sgp); + + if (! rPlot.getTitle().empty()) { + std::string s("title "); + s += rPlot.getTitle(); + plot.ezset (s); + } + if (! rPlot.getXLabel().empty()) { + std::string s("xlabel "); + s += rPlot.getXLabel(); + plot.ezset (s); + } + if (! rPlot.getYLabel().empty()) { + std::string s("ylabel "); + s += rPlot.getYLabel(); + plot.ezset (s); + } + + plot.ezset("box"); + plot.ezset("grid"); + + double* pdXaxis = new double [iNRecords]; + rPlot.getColumn (0, pdXaxis); + + double* pdY = new double [iNRecords]; + for (int iCol = 1; iCol < iNColumns; iCol++) { + rPlot.getColumn (iCol, pdY); + plot.addCurve (pdXaxis, pdY, iNRecords); + } + + delete pdXaxis; + delete pdY; + + plot.plot(); + } } void PlotFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) { - const PlotFile& rPlot = GetDocument()->getPlotFile(); - const int iNColumns = rPlot.getNumColumns(); - const int iNRecords = rPlot.getNumRecords(); - if (iNColumns > 0 && iNRecords > 0) { -// int xSize, ySize; -// m_frame->SetClientSize (xSize, ySize); -// m_canvas->SetScrollbars (20, 20, nDet/20, nView/20); - } - if (m_canvas) m_canvas->Refresh(); } diff --git a/src/views.h b/src/views.h index 34d140d..8a9bd79 100644 --- a/src/views.h +++ b/src/views.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.h,v 1.12 2000/12/19 21:37:51 kevin Exp $ +** $Id: views.h,v 1.13 2000/12/20 14:39:09 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 @@ -210,9 +210,6 @@ class PlotFileView : public wxView { DECLARE_DYNAMIC_CLASS(PlotFileView) - wxMemoryDC m_memoryDC; - wxBitmap m_bitmap; - private: PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent); wxFrame *CreateChildFrame(wxDocument *doc, wxView *view); @@ -220,18 +217,6 @@ private: PlotFileCanvas *m_canvas; wxFrame *m_frame; - int m_iDefaultNX; - int m_iDefaultNY; - int m_iDefaultFilter; - int m_iDefaultFilterMethod; - double m_dDefaultFilterParam; - int m_iDefaultFilterGeneration; - int m_iDefaultZeropad; - int m_iDefaultInterpolation; - int m_iDefaultInterpParam; - int m_iDefaultBackprojector; - int m_iDefaultTrace; - public: PlotFileView(void); virtual ~PlotFileView(void); -- 2.34.1