+TODO
+ Read PlotFile's.
+
+ Fix display of ylabel.
+
+ Review old ezset.c and add in concept of curve number. Add to ezset
+ std::vector for individual curve parameters such as color, linestyle,
+ symbol. Read these vectors during plot generation
+
+ 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 being able to write Phantom files as text
+
3.0alpha1 - Released 12/30/00
- * Added PlotFile class to system, used by if2 and ctsim
+ * Added PlotFile class to system, used by if2 and ctsim for row
+ and column plots and comparison plots
* ctsim: Added image comparison statistics and image subtraction
plotfile classes.
* imagefile.cpp: Fixed scaling bug when rasterizing Phantom with
- nsamples > 2. Added image math functions.
+ nsamples > 2. Added generic mage math functions, moved from
+ if1.cpp and if2.cpp to imagefile.cpp
+ * if1: Updated to handle error conditions, such as sqrt of a
+ negative number.
+
* if2: Updated to output plot files and use new ImageFile class
math functions
+
+ * if1: Updated to use new ImageFile class math functions
+
+ * ezplot.h: Updated to more C++ conventions
2.5.0 - 12/18/00
First Microsoft Windows GUI version
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.h,v 1.19 2000/12/20 14:39:09 kevin Exp $
+** $Id: ezplot.h,v 1.20 2000/12/23 18:12:35 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
class EZPlotCurve {
- public:
- double *x;
- double *y;
- int m_iPointCount;
- int m_iLineStyle;
- int m_iSymbol;
- int m_iSymbolFreq;
- int m_iColor;
- std::string m_sLegend;
-
- EZPlotCurve (const double* x, const double* y, int n, int color, int linestyle, int symbol, int sumbolFreq, const std::string& legend);
-
- ~EZPlotCurve();
+public:
+ double *x;
+ double *y;
+ int m_iPointCount;
+ int m_iLineStyle;
+ int m_iSymbol;
+ int m_iSymbolFreq;
+ int m_iColor;
+ std::string m_sLegend;
+
+ EZPlotCurve (const double* x, const double* y, int n, int color, int linestyle, int symbol, int sumbolFreq, const std::string& legend);
+
+ ~EZPlotCurve();
};
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// axis definitions
-#define LINEAR 1 // linear axis
-#define LOG 2 // logrithmic axis
-#define NOAXIS 3 // don't plot axis
+enum {\r
+ LINEAR = 1, // linear axis
+ LOG, // logrithmic axis
+ NOAXIS, // don't plot axis \r
+};
// tick definitions
-#define ABOVE 1
-#define BELOW 2
-#define RIGHT 4
-#define LEFT 8
+enum {\r
+ ABOVE = 1,
+ BELOW,
+ RIGHT,
+ LEFT,\r
+};
-// line types
-#define NOLINE 0
-#define SOLID 1
-#define DASH 2
-#define DASH1 10
-#define DASH2 11
-#define DASH3 12
-#define DASH4 13
+// line types \r
+enum {
+ NOLINE = 0,
+ SOLID,
+ DASH,
+ DASH1,
+ DASH2,
+ DASH3,
+ DASH4,\r
+};\r
// symbol definitions
-#define SB_CROSS 1
-#define SB_PLUS 2
-#define SB_BOX 3
-#define SB_CIRCLE 4
-#define SB_ERRORBAR 5
-#define MAXSYMBOL 5
-
-#define INSIDE 1 // values of o_legendbox
-#define OUTSIDE 2
-#define NOLEGEND 3
+enum {\r
+ SB_CROSS = 1,
+ SB_PLUS,
+ SB_BOX,
+ SB_CIRCLE,
+ SB_ERRORBAR,
+ MAXSYMBOL,\r
+};
+enum {\r
+ INSIDE = 1, // values of o_legendbox
+ OUTSIDE,
+ NOLEGEND,\r
+};\r
+\r
+
+struct KeywordCodeTable {\r
+ char* keyword;\r
+ int code;\r
+};\r
+\r
/*-----------------------------------------------------------------------------
- * GLOBAL VARIABLES
- *
- * Naming Convention:
- * i_ Internal variable
- * Not user changable
- * o_ Option variable
- * Normal variable that is user modifiable
- * These variables must always have a valid value
- * d_ Device variable
- * Variables controlling devices
- * clr_ Color variable
- * Holds a color value
- * c_ Character string variable
- * Contains a character string
- * v_ Value variable
- * User modifiable variable associated with the set variable (s_)
- * These variables do not always have a valid value
- * These variables change assumption EZPLOT makes about the plot
- * s_ Set variable.
- * TRUE if associated value variable (v_) has been set by the user
- *---------------------------------------------------------------------------*/
+* GLOBAL VARIABLES
+*
+* Naming Convention:
+* i_ Internal variable
+* Not user changable
+* o_ Option variable
+* Normal variable that is user modifiable
+* These variables must always have a valid value
+* d_ Device variable
+* Variables controlling devices
+* clr_ Color variable
+* Holds a color value
+* c_ Character string variable
+* Contains a character string
+* v_ Value variable
+* User modifiable variable associated with the set variable (s_)
+* These variables do not always have a valid value
+* These variables change assumption EZPLOT makes about the plot
+* s_ Set variable.
+* TRUE if associated value variable (v_) has been set by the user
+*---------------------------------------------------------------------------*/
#include <vector>
class SGP;
class EZPlot {
- private:
- std::vector<class EZPlotCurve*> m_vecCurves;
-
- // Colors
- int clr_axis; // color of all axis lines
- int clr_title; // color of main title
- int clr_label; // color of axis labels
- int clr_legend; // color of legend box
- int clr_grid; // color of grid lines
- int clr_number; // color of axis number labels
-
- // Options
- double o_xporigin, o_yporigin; // origin of plot frame in NDC
- double o_xlength, o_ylength; // length of plot frame in NDC
-
- std::string c_xlabel; // label for x axis
- std::string c_ylabel; // label for y axis
- std::string c_title; // title to print above graph
- std::string c_legend;; // current legend specified
-
- int o_linestyle, o_color; // style to use for curves all subsequent curves to EZPLOT
- int o_xaxis, o_yaxis; // Specifies where axis & labels are drawn
- bool o_grid; // Flag to draw a grid at major ticks
- bool o_box; // Flag to draw a box around the graph
-
- int o_xticks, o_yticks; // direction to draw tick marks
- bool o_xtlabel, o_ytlabel; // TRUE if label tick marks
-
- int o_xmajortick, o_ymajortick; // number of major ticks to draw
- int o_xminortick, o_yminortick; // number of minor ticks between major ticks
-
- int o_symbol; // Symbol type, (0 = no symbol)
- int o_symfreq; // frequency to draw symbols at curve points
-
- int o_legendbox; // controls whether legend is inside or outside of the axis extents
- int o_tag; // controls whether to draw tag at end of axes
-
- // VALUE & SET variables
- double v_xmin, v_xmax, v_ymin, v_ymax; // user supplied axis endpoints
- bool s_xmin, s_xmax, s_ymin, s_ymax; // TRUE is endpoint has been set
- double v_xtitle, v_ytitle; // NDC position to plot title
- bool s_xtitle, s_ytitle; // TRUE if set position for title
- double v_xcross, v_ycross; // position that axes cross
- bool s_xcross, s_ycross; // TRUE if set axes cross position
- double v_xlegend, v_ylegend; // upper-left position of legend box in NDC
- bool s_xlegend, s_ylegend; // TRUE if set position of legend box
- int v_lxfrac, v_lyfrac; // number of digits to right of decimal place
- bool s_lxfrac, s_lyfrac; // TRUE if set number of fractional digits
- double v_textsize; // size of text in NDC
- bool s_textsize; // TRUE if user set size of text
-
- // Global variables
- double charheight; // Height of characters in NDC
- double charwidth; // Height of characters in NDC
- double xp_min, xp_max, yp_min, yp_max; // boundry of plot frame in NDC
- double xa_min, xa_max, ya_min, ya_max; // extent of axes in NDC
- double xgw_min, xgw_max, ygw_min, ygw_max; // boundary of graph in input coords
- double xgn_min, xgn_max, ygn_min, ygn_max; // boundy of graph in NDC
- double xt_min, xt_max, yt_min, yt_max; // boundary of axis ticks
- double xl_min, xl_max, yl_min, yl_max; // boundary of legend box
- double title_row; // y-coord of title row
- double xtl_ofs; // Offset y-coord of x tick labels from axis
- double ytl_ofs; // Offset x-coord of y tick labels from axis
- double xlbl_row; // row of x label in world coord
- double ylbl_col; // column of y label in world coord
- double xw_tickinc, yw_tickinc; // increment between major ticks in WC
- double xn_tickinc, yn_tickinc; // increment between major ticks in NDC
- int x_nint, y_nint; // number of intervals along x & y axes
- int x_fldwid, x_frac; // numeric field sizes & number of digits
- int y_fldwid, y_frac; // in fraction of number, used for printf()
- double xtl_wid, ytl_wid; // length of ticks labels in NDC
- double tl_height; // height of tick labels in NDC
- char x_numfmt[20]; // format to print x tick labels
- char y_numfmt[20]; // format to print y tick labels
-
- double m_dVP_xmin, m_dVP_ymin;
- double m_dVP_xmax, m_dVP_ymax;
- double m_dVP_xscale, m_dVP_yscale;
- double m_xWorldScale, m_yWorldScale;
-
- void drawAxes(void);
- void symbol (int sym, double symwidth, double symheight);
- void make_numfmt(char *fmtstr, int *fldwid, int *nfrac, double min, double max, int nint);
- int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);
-
- SGP& rSGP;
-
- void clearCurves ();
-
- bool ezcmd (const char const *comm);\r
- bool do_cmd(int lx);
- void bad_option(char *opt);
- void initPlotSettings();
-
- static void initkw(void);
-
- static bool ezset_initialized;
-
- double convertWorldToNDC_X (double x)
- { return xgn_min + (x - xgw_min) * m_xWorldScale; }
-
- double convertWorldToNDC_Y (double y)
- { return ygn_min + (y - ygw_min) * m_yWorldScale; }
-
+private:
+ //----------------------------------------------------------------------
+ // POL Codes
+ //----------------------------------------------------------------------
+
+ enum {
+ S_DATA = 2,
+ S_HELP,
+ S_EXIT,
+ S_SOLID,
+ S_DASH,
+ S_NOLINE,
+ S_BLACK,
+ S_RED,
+ S_GREEN,
+ S_BLUE,\r
+ S_SYMBOL,
+ S_PEN,
+ S_EVERY,
+ S_NONE,
+ S_LEGEND,
+ S_XLEGEND,
+ S_YLEGEND,
+ S_XLIN,
+ S_YLIN,
+ S_XLOG,
+ S_YLOG,
+ S_XLABEL,
+ S_YLABEL,
+ S_XLENGTH,
+ S_YLENGTH,
+ S_XTICKS,
+ S_YTICKS,
+ S_ABOVE,
+ S_LABEL,
+ S_BELOW,
+ S_NOLABEL,
+ S_RIGHT,
+ S_LEFT,
+ S_XAUTOSCALE,
+ S_YAUTOSCALE,
+ S_XMIN,
+ S_YMIN,
+ S_XMAX,
+ S_YMAX,
+ S_LXFRAC,
+ S_LYFRAC,
+ S_XCROSS,
+ S_YCROSS,
+ S_NOXAXIS,
+ S_NOYAXIS,
+ S_XPORIGIN,
+ S_YPORIGIN,
+ S_TITLE,
+ S_XTITLE,
+ S_YTITLE,
+ S_REPLOT,
+ S_CLEAR,
+ S_STORE,
+ S_RESTORE,
+ S_AMARK,
+ S_NO,
+ S_INTERACTIVE,
+ S_UNITS,
+ S_INCHES,
+ S_USER,
+ S_BOX,
+ S_NOBOX,
+ S_GRID,
+ S_NOGRID,
+ S_MAJOR,
+ S_MINOR,
+ S_COLOR,
+ S_LEGENDBOX,
+ S_TAG,
+ S_TEXTSIZE,
+ };
+ \r
+ static const struct KeywordCodeTable m_sKeywords[];\r
+ static const int NKEYS;\r
+
+ std::vector<class EZPlotCurve*> m_vecCurves;
+
+ // Colors
+ int clr_axis; // color of all axis lines
+ int clr_title; // color of main title
+ int clr_label; // color of axis labels
+ int clr_legend; // color of legend box
+ int clr_grid; // color of grid lines
+ int clr_number; // color of axis number labels
+
+ // Options
+ double o_xporigin, o_yporigin; // origin of plot frame in NDC
+ double o_xlength, o_ylength; // length of plot frame in NDC
+
+ std::string c_xlabel; // label for x axis
+ std::string c_ylabel; // label for y axis
+ std::string c_title; // title to print above graph
+ std::string c_legend;; // current legend specified
+
+ int o_linestyle, o_color; // style to use for curves all subsequent curves to EZPLOT
+ int o_xaxis, o_yaxis; // Specifies where axis & labels are drawn
+ bool o_grid; // Flag to draw a grid at major ticks
+ bool o_box; // Flag to draw a box around the graph
+
+ int o_xticks, o_yticks; // direction to draw tick marks
+ bool o_xtlabel, o_ytlabel; // TRUE if label tick marks
+
+ int o_xmajortick, o_ymajortick; // number of major ticks to draw
+ int o_xminortick, o_yminortick; // number of minor ticks between major ticks
+
+ int o_symbol; // Symbol type, (0 = no symbol)
+ int o_symfreq; // frequency to draw symbols at curve points
+
+ int o_legendbox; // controls whether legend is inside or outside of the axis extents
+ int o_tag; // controls whether to draw tag at end of axes
+
+ // VALUE & SET variables
+ double v_xmin, v_xmax, v_ymin, v_ymax; // user supplied axis endpoints
+ bool s_xmin, s_xmax, s_ymin, s_ymax; // TRUE is endpoint has been set
+ double v_xtitle, v_ytitle; // NDC position to plot title
+ bool s_xtitle, s_ytitle; // TRUE if set position for title
+ double v_xcross, v_ycross; // position that axes cross
+ bool s_xcross, s_ycross; // TRUE if set axes cross position
+ double v_xlegend, v_ylegend; // upper-left position of legend box in NDC
+ bool s_xlegend, s_ylegend; // TRUE if set position of legend box
+ int v_lxfrac, v_lyfrac; // number of digits to right of decimal place
+ bool s_lxfrac, s_lyfrac; // TRUE if set number of fractional digits
+ double v_textsize; // size of text in NDC
+ bool s_textsize; // TRUE if user set size of text
+
+ // Global variables
+ double charheight; // Height of characters in NDC
+ double charwidth; // Height of characters in NDC
+ double xp_min, xp_max, yp_min, yp_max; // boundry of plot frame in NDC
+ double xa_min, xa_max, ya_min, ya_max; // extent of axes in NDC
+ double xgw_min, xgw_max, ygw_min, ygw_max; // boundary of graph in input coords
+ double xgn_min, xgn_max, ygn_min, ygn_max; // boundy of graph in NDC
+ double xt_min, xt_max, yt_min, yt_max; // boundary of axis ticks
+ double xl_min, xl_max, yl_min, yl_max; // boundary of legend box
+ double title_row; // y-coord of title row
+ double xtl_ofs; // Offset y-coord of x tick labels from axis
+ double ytl_ofs; // Offset x-coord of y tick labels from axis
+ double xlbl_row; // row of x label in world coord
+ double ylbl_col; // column of y label in world coord
+ double xw_tickinc, yw_tickinc; // increment between major ticks in WC
+ double xn_tickinc, yn_tickinc; // increment between major ticks in NDC
+ int x_nint, y_nint; // number of intervals along x & y axes
+ int x_fldwid, x_frac; // numeric field sizes & number of digits
+ int y_fldwid, y_frac; // in fraction of number, used for printf()
+ double xtl_wid, ytl_wid; // length of ticks labels in NDC
+ double tl_height; // height of tick labels in NDC
+ char x_numfmt[20]; // format to print x tick labels
+ char y_numfmt[20]; // format to print y tick labels
+
+ double m_dVP_xmin, m_dVP_ymin;
+ double m_dVP_xmax, m_dVP_ymax;
+ double m_dVP_xscale, m_dVP_yscale;
+ double m_xWorldScale, m_yWorldScale;
+
+ void drawAxes(void);
+ void symbol (int sym, double symwidth, double symheight);
+ void make_numfmt(char *fmtstr, int *fldwid, int *nfrac, double min, double max, int nint);
+ int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);
+
+ SGP& rSGP;
+
+ void clearCurves ();
+
+ bool ezcmd (const char const *comm);\r
+ bool do_cmd(int lx);
+ void bad_option(char *opt);
+ void initPlotSettings();
+
+ static void initkw(void);
+
+ static bool ezset_initialized;
+
+ double convertWorldToNDC_X (double x)
+ { return xgn_min + (x - xgw_min) * m_xWorldScale; }
+
+ double convertWorldToNDC_Y (double y)
+ { return ygn_min + (y - ygw_min) * m_yWorldScale; }
+
public:
- EZPlot (SGP& sgp);
- ~EZPlot ();
-
- bool ezset (const std::string& command);\r
- 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);
- void addCurve (const double* x, const double* y, int num);
- void addCurve (const double* y, int n);
- void addCurve (const float* y, int n);
-
- void plot ();
+ EZPlot (SGP& sgp);
+ ~EZPlot ();
+
+ bool ezset (const std::string& command);\r
+ 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);
+ void addCurve (const double* x, const double* y, int num);
+ void addCurve (const double* y, int n);
+ void addCurve (const float* y, int n);
+
+ void plot ();
};
-//----------------------------------------------------------------------
-// Codes from LEX
-//----------------------------------------------------------------------
-
-#define S_DATA 2
-#define S_HELP 3
-#define S_EXIT 4
-
-#define S_SOLID -10
-#define S_DASH -11
-#define S_NOLINE -12
-#define S_BLACK -13
-#define S_RED -14
-#define S_BLUE -15
-#define S_GREEN -16
-#define S_PEN -17
-#define S_SYMBOL -18
-#define S_EVERY -19
-#define S_NONE -20
-#define S_LEGEND -24
-#define S_XLEGEND -25
-#define S_YLEGEND -26
-#define S_XLIN -27
-#define S_YLIN -28
-#define S_XLOG -29
-#define S_YLOG -30
-#define S_XLABEL -31
-#define S_YLABEL -32
-#define S_XLENGTH -33
-#define S_YLENGTH -34
-#define S_XTICKS -35
-#define S_YTICKS -36
-#define S_ABOVE -37
-#define S_LABEL -38
-#define S_BELOW -39
-#define S_NOLABEL -40
-#define S_RIGHT -41
-#define S_LEFT -42
-#define S_XAUTOSCALE -43
-#define S_YAUTOSCALE -44
-#define S_XMIN -45
-#define S_YMIN -46
-#define S_XMAX -47
-#define S_YMAX -48
-#define S_LXFRAC -49
-#define S_LYFRAC -50
-#define S_XCROSS -51
-#define S_YCROSS -52
-#define S_NOXAXIS -53
-#define S_NOYAXIS -54
-#define S_XPORIGIN -55
-#define S_YPORIGIN -56
-#define S_TITLE -57
-#define S_XTITLE -58
-#define S_YTITLE -59
-#define S_REPLOT -60
-#define S_CLEAR -61
-#define S_STORE -62
-#define S_RESTORE -63
-#define S_AMARK -66
-#define S_NO -67
-#define S_INTERACTIVE -68
-#define S_UNITS -69
-#define S_INCHES -70
-#define S_USER -71
-
-#define S_BOX -100
-#define S_NOBOX -101
-#define S_GRID -102
-#define S_NOGRID -103
-#define S_MAJOR -104
-#define S_MINOR -105
-#define S_COLOR -106
-#define S_LEGENDBOX -107
-#define S_TAG -108
-
-#define S_TEXTSIZE -120
-
-
#endif
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: plotfile.h,v 1.3 2000/12/20 20:08:48 kevin Exp $
+** $Id: plotfile.h,v 1.4 2000/12/23 18:12:35 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 <iostream>
#include <vector>
#include "ctsupport.h"
-#include "plotfile.h"
+#include "plotfile.h"\r
+
// Plotfile structure:
// 1. Lines that begin with # are comments
// 2. ASCII file format
// 3. Header lines begin with <tags> and end with </tags>
-// 4. Valid headers
-// <header> (signifies beginning of headers)
-// <description> (multiple instances may be present)
-// <date>
-// <title>
-// <xlabel>
-// <ylabel>
-// <filetype>plotfile</filetype> (required)
-// <ncolumns> (required)
-// <nrecords> (required)
-// </header> (required, signifies end of headers)
+// 4. Valid headers\r
+// <plotfile ncolumns nrecords> (signifies beginning of plotfile)
+// <description> (beginning of description lines)\r
+// <ezset> (signifies beginning of ezset commands)\r
+// <columns> Beginning of data columns
// 5. Data is ASCII file format, one record per line
// Number of columns is variable and is set by ncolumns header
-// 6. Data begins with <plotdata> and ends with </plotdata>
+\r
class PlotFile
{
private:
std::string m_strFilename;
- std::string m_strTitle;
- std::string m_strXLabel;
- std::string m_strYLabel;
std::string m_strDate;
- std::vector<std::string> m_vecStrDescriptions;
+ std::vector<std::string> m_vecStrDescriptions;\r
+ std::vector<std::string> m_vecStrEzsetCommands;
std::vector<double> m_vecCurves;
int m_iNumColumns;
int m_iNumRecords;
PlotFile (void);
~PlotFile ();
- void setTitle (const std::string& title)
- { m_strTitle = title; }
- \r
- void setTitle (const char* const title)\r
- { m_strTitle = title; }\r
-
- void setXLabel (const std::string& label)
- { m_strXLabel = label; }
- \r
- void setXLabel (const char* const label)\r
- { m_strXLabel = label; }\r
-
- void setYLabel (const std::string& label)
- { m_strYLabel = label; }
-
- void setYLabel (const char* const label)\r
- { m_strYLabel = label; }\r
-\r
void setCurveSize (int iNCurves, int iNRecords);
- void addDescription (const char* const pszDesc)
- { m_vecStrDescriptions.push_back (pszDesc); }
-
+ void addDescription (const char* const pszDesc)\r
+ { m_vecStrDescriptions.push_back (pszDesc); }\r
+\r
+ void addEzsetCommand (const char* const pszCmd)\r
+ { m_vecStrEzsetCommands.push_back (pszCmd); }\r
+
bool addColumn (int iCol, const double* const pdColumn);
bool addColumn (int iCol, const float* const pdColumn);\r
\r
void getColumn (int iCol, double *pdColumnData) const;\r
\r
- const std::string& getTitle () const
- { return m_strTitle; }
-
- const std::string& getXLabel () const
- { return m_strXLabel; }
-
- const std::string& getYLabel () const
- { return m_strXLabel; }
-
const std::string& getDate () const
{ return m_strDate; }
const std::string& getDescription (int iDescIndex) const
{ return m_vecStrDescriptions[iDescIndex]; }
+ unsigned int getNumEzsetCommands (void) const\r
+ { return m_vecStrEzsetCommands.size(); }\r
+\r
+ const std::string& getEzsetCommand (int iIndex) const\r
+ { return m_vecStrEzsetCommands[iIndex]; }\r
+\r
bool fileRead (const char* const filename);
bool fileWrite (const char* const filename);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.20 2000/12/20 20:08:48 kevin Exp $
+** $Id: ezplot.cpp,v 1.21 2000/12/23 18:12:35 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
EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n, int color, int linestyle, int symbol, int symfreq, const std::string& legend)
- : x(NULL), y(NULL), m_sLegend (legend)
+: x(NULL), y(NULL), m_sLegend (legend)
{
x = new double [n];
y = new double [n];
-
+
int copyCount = n * sizeof(double);
memcpy (x, xData, copyCount);
memcpy (y, yData, copyCount);
-
+
m_iPointCount = n;
m_iColor = color;
m_iLineStyle = linestyle;
EZPlot::addCurve (const double *y, int n)
{
double* x = new double [n];
-
+
for (int i = 0; i < n; i++)
x[i] = i;
-
+
addCurve (x, y, n);
delete x;
}
EZPlot::addCurve (const float *y, int n)
{
double* yDouble = new double [n];
-
+
for (int i = 0; i < n; i++)
yDouble[i] = y[i];
-
+
addCurve (yDouble, n);
delete yDouble;
}
EZPlot::addCurve (const float x[], const double y[], int num)
{
double* dx = new double [num];
-
+
for (int i = 0; i < num; i++)
dx[i] = x[i];
-
+
addCurve (dx, y, num);
delete dx;
}
EZPlot::addCurve (const double x[], const float y[], int num)
{
double* dy = new double [num];
-
+
for (int i = 0; i < num; i++)
dy[i] = y[i];
-
+
addCurve (x, dy, num);
-
+
delete dy;
}
{
if (num < 1)
return;
-
+
EZPlotCurve* pCurve = new EZPlotCurve (x, y, num, o_color, o_linestyle, o_symbol, o_symfreq, c_legend);
m_vecCurves.push_back (pCurve);
}
EZPlot::EZPlot (SGP& sgp)
- : rSGP (sgp)
+: rSGP (sgp)
{
- initPlotSettings();
+ initPlotSettings();
}
void
{
charheight = rSGP.getCharHeight();
charwidth = rSGP.getCharWidth();
-
+
c_xlabel = "";
c_ylabel = "";
c_title = "";
/* NAME
- * plot Plots all curves collected by addCurves ()
- *
- * SYNOPSIS
- * plot()
- *
- * DESCRIPTION
- * This routine plots the curves that have stored by addCurves().
- *
- * CALLS
- * drawAxes() & make_numfmt()
- */
+* plot Plots all curves collected by addCurves ()
+*
+* SYNOPSIS
+* plot()
+*
+* DESCRIPTION
+* This routine plots the curves that have stored by addCurves().
+*
+* CALLS
+* drawAxes() & make_numfmt()
+*/
void
EZPlot::plot ()
-{
+{\r
+#if 0\r
+ wxFont* myFont = new wxFont (12, wxMODERN, wxNORMAL, wxNORMAL);\r
+ rSGP.getDriver().idWX()->SetFont (*myFont);\r
+#endif
if (m_vecCurves.size() <= 0)
return;
-
+
rSGP.setWindow (0., 0., 1., 1.);
-
+
if (s_textsize == TRUE) {
charheight = v_textsize;
charwidth = rSGP.getCharWidth();
for (int ip = 0; ip < curve.m_iPointCount; ip++) {
if (curve.x[ip] > xmax)
- xmax = curve.x[ip];
+ xmax = curve.x[ip];
else if (curve.x[ip] < xmin)
- xmin = curve.x[ip];
+ xmin = curve.x[ip];
if (curve.y[ip] > ymax)
- ymax = curve.y[ip];
+ ymax = curve.y[ip];
else if (curve.y[ip] < ymin)
- ymin = curve.y[ip];
+ ymin = curve.y[ip];
}
}
else if (v_xcross > xmax)
xmax = v_xcross;
}
-
+
if (s_ycross == TRUE) {
if (v_ycross < ymin)
ymin = v_ycross;
else if (v_ycross > ymax)
ymax = v_ycross;
}
-
+
// find nice endpoints for axes
if (! axis_scale (xmin, xmax, o_xmajortick - 1, &xgw_min, &xgw_max, &x_nint) || ! axis_scale (ymin, ymax, o_ymajortick - 1, &ygw_min, &ygw_max, &y_nint))
return;
-
+
// check if user set x-axis extents
if (s_xmin == TRUE) {
xgw_min = v_xmin;
ygw_max = v_ymax;
y_nint = o_ymajortick - 1;
}
-
+
// calculate increment between major axis in world coordinates
xw_tickinc = (xgw_max - xgw_min) / x_nint;
yw_tickinc = (ygw_max - ygw_min) / y_nint;
-
+
// we have now calcuated xgw_min, xyw_max, ygw_min, & ygw_max
// set the number of decimal point to users' setting or default
x_frac = v_lxfrac;
else
x_frac = -1;
-
+
if (s_lyfrac == TRUE)
y_frac = v_lyfrac;
else
y_frac = -1;
-
+
make_numfmt (x_numfmt, &x_fldwid, &x_frac, xgw_min, xgw_max, x_nint);
make_numfmt (y_numfmt, &y_fldwid, &y_frac, ygw_min, ygw_max, y_nint);
-
+
xtl_wid = x_fldwid * charwidth; // calc size of tick labels
ytl_wid = y_fldwid * charwidth;
tl_height = charheight;
-
+
// calculate the extent of the plot frame
xp_min = o_xporigin;
yp_min = o_yporigin;
xp_max = xp_min + o_xlength;
yp_max = yp_min + o_ylength;
-
+
xp_min = clamp (xp_min, 0., 1.);
xp_max = clamp (xp_max, 0., 1.);
yp_min = clamp (yp_min, 0., 1.);
xa_max = xp_max;
ya_min = yp_min;
ya_max = yp_max;
-
+
// adjust frame for title
if (c_title.length() > 0)
ya_max -= 2 * charheight;
title_row = ya_max + 2 * charheight;
-
+
// calculate legend box boundaries
int max_leg = 0; // longest legend in characters
int num_leg = 0; // number of legend titles
if (nLegend > 0) {
++num_leg;
if (nLegend > max_leg)\r
- nLegend = max_leg;
+ nLegend = max_leg;
}
}
-
+
if (num_leg > 0 && o_legendbox != NOLEGEND) {
double leg_width = (max_leg + 2) * charwidth; // size of legend box
double leg_height = num_leg * 3 * charheight;
else {
xl_max = xa_max;
if (o_legendbox == OUTSIDE)
- xa_max -= (leg_width + 0.5 * charwidth);
+ xa_max -= (leg_width + 0.5 * charwidth);
}
xl_min = xl_max - leg_width;
yl_max = ya_max;
yl_min = yl_max - leg_height;
-
+
rSGP.setColor (clr_legend);
rSGP.drawRect (xl_min, yl_min, xl_max, yl_max);
-
+
int iLegend = 0; // current legend position
for (EZPlotCurveIterator iterCurve = m_vecCurves.begin(); iterCurve != m_vecCurves.end(); iterCurve++) {
- const EZPlotCurve& curve = **iterCurve;
-
- if (curve.m_sLegend.length() == 0)
- continue;
-
- double xmin = xl_min + 1.0 * charwidth;
- double xmax = xl_max - 1.0 * charwidth;
- double y = yl_max - (2.0 + iLegend * 3) * charheight;
-
- rSGP.moveAbs (xmin, y + 0.5 * charheight);
- rSGP.drawText (curve.m_sLegend);
- rSGP.setColor (curve.m_iColor);
- if (curve.m_iLineStyle != SGP::LS_NOLINE) {
- rSGP.setLineStyle (curve.m_iLineStyle);
- rSGP.moveAbs (xmin, y);
- rSGP.lineAbs (xmax, y);
- }
- if (curve.m_iSymbol > 0) {
- double xinc = (xmax - xmin) / (5 - 1);
- rSGP.setLineStyle (SGP::LS_SOLID);
- for (int j = 0; j < 5; j++) {
- rSGP.moveAbs (xmin + j * xinc, y);
- symbol(curve.m_iSymbol, 0.5 * charwidth, 0.5 * charheight);
- }
- }
- ++iLegend; // move to next legend position
+ const EZPlotCurve& curve = **iterCurve;
+
+ if (curve.m_sLegend.length() == 0)
+ continue;
+
+ double xmin = xl_min + 1.0 * charwidth;
+ double xmax = xl_max - 1.0 * charwidth;
+ double y = yl_max - (2.0 + iLegend * 3) * charheight;
+
+ rSGP.moveAbs (xmin, y + 0.5 * charheight);
+ rSGP.drawText (curve.m_sLegend);
+ rSGP.setColor (curve.m_iColor);
+ if (curve.m_iLineStyle != SGP::LS_NOLINE) {
+ rSGP.setLineStyle (curve.m_iLineStyle);
+ rSGP.moveAbs (xmin, y);
+ rSGP.lineAbs (xmax, y);
+ }
+ if (curve.m_iSymbol > 0) {
+ double xinc = (xmax - xmin) / (5 - 1);
+ rSGP.setLineStyle (SGP::LS_SOLID);
+ for (int j = 0; j < 5; j++) {
+ rSGP.moveAbs (xmin + j * xinc, y);
+ symbol(curve.m_iSymbol, 0.5 * charwidth, 0.5 * charheight);
+ }
+ }
+ ++iLegend; // move to next legend position
}
} // end legend printing
-
+
// calculate the extent of the axes
-
+
/*-------------------------*/
/* adjust frame for labels */
/*-------------------------*/
if (c_xlabel.length() > 0)
ya_min += 3.0 * charheight;
xlbl_row = xp_min; // put x-label on bottom of plot frame
-
+
// Y-Label
if (c_ylabel.length() > 0)
xa_min += 3.0 * charwidth; // reverse rSGP.setTextSize because writing text sideways
ylbl_col = xp_min + 2 * charwidth;
-
+
/*------------------------------*/
/* adjust frame for tick labels */
/*------------------------------*/
-
+
// Calc offset of tick labels from axes
if (o_xaxis == NOAXIS || o_xtlabel == FALSE)
xtl_ofs = 0.0;
ytl_ofs = -(1 + y_fldwid) * charwidth;
else if (o_yticks == RIGHT)
ytl_ofs = 1.5 * charwidth;
-
+
xt_min = xa_min;
yt_min = ya_min;
xt_max = xa_max;
yt_max = ya_max;
-
+
// see if need to shrink axis extents and/or tick extents
if (xtl_ofs != 0.0 && s_ycross == FALSE) {
if (o_xticks == BELOW) {
}
} 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 = -1; // number of tick spaces added to axis
- double y_added_ticks = -1;
+ double x_added_ticks = 0; // number of tick spaces added to axis
+ double y_added_ticks = 0;
if (o_xaxis == NOAXIS || o_xtlabel == FALSE)
x_added_ticks = 0;
if (o_yaxis == NOAXIS || o_ytlabel == FALSE)
xgn_max = xt_max;
ygn_min = yt_min;
ygn_max = yt_max;
-
+
//------------------------------------------------------------------------
m_xWorldScale = (xgn_max - xgn_min) / (xgw_max - xgw_min);
m_yWorldScale = (ygn_max - ygn_min) / (ygw_max - ygw_min);
-
+
// PLOT CURVES
rSGP.setLineStyle (SGP::LS_SOLID);
drawAxes();
-
+
// size of symbol in NDC
double symwidth = charwidth;
double symheight = charheight;
-
- for (EZPlotCurveIterator iterCurve3 = m_vecCurves.begin(); iterCurve3 != m_vecCurves.end(); iterCurve3++) {
- const EZPlotCurve& curve = **iterCurve3;
-
- rSGP.setColor (curve.m_iColor);
+ \r
+ double clipRect[4];\r
+ clipRect[0] = xgn_min; clipRect[1] = ygn_min; clipRect[2] = xgn_max; clipRect[3] = ygn_max;\r
- if (curve.m_iLineStyle != SGP::LS_NOLINE) {
- rSGP.setLineStyle (curve.m_iLineStyle);
- double x = convertWorldToNDC_X (curve.x[0]);
- double y = convertWorldToNDC_Y (curve.y[0]);
- rSGP.moveAbs (x, y);
- for (int i = 1; i < curve.m_iPointCount; i++) {
- x = convertWorldToNDC_X (curve.x[i]);
- y = convertWorldToNDC_Y (curve.y[i]);
- rSGP.lineAbs (x, y);
- }
- }
- if (curve.m_iSymbol > 0) {
- rSGP.setLineStyle (SGP::LS_SOLID);
- double x = convertWorldToNDC_X (curve.x[0]);
- double y = convertWorldToNDC_Y (curve.y[0]);
- rSGP.moveAbs (x, y);
- symbol (curve.m_iSymbol, symwidth, symheight);
- for (int i = 1; i < curve.m_iPointCount; i++)
- if (i % curve.m_iSymbolFreq == 0 || i == curve.m_iPointCount - 1) {
- x = convertWorldToNDC_X (curve.x[i]);
- y = convertWorldToNDC_Y (curve.y[i]);
- rSGP.moveAbs (x, y);
- symbol (curve.m_iSymbol, symwidth, symheight);
- }
- }
+ for (EZPlotCurveIterator iterCurve3 = m_vecCurves.begin(); iterCurve3 != m_vecCurves.end(); iterCurve3++) {
+ const EZPlotCurve& curve = **iterCurve3;
+
+ rSGP.setColor (curve.m_iColor);
+ \r
+ bool bOutside = false;
+ if (curve.m_iLineStyle != SGP::LS_NOLINE) {
+ rSGP.setLineStyle (curve.m_iLineStyle);
+ double x1 = convertWorldToNDC_X (curve.x[0]);
+ double y1 = convertWorldToNDC_Y (curve.y[0]);\r
+ for (int i = 1; i < curve.m_iPointCount; i++) {
+ double x2 = convertWorldToNDC_X (curve.x[i]);
+ double y2 = convertWorldToNDC_Y (curve.y[i]);\r
+ double x2Clip = x2;\r
+ double y2Clip = y2;\r
+ if (clip_rect (x1, y1, x2Clip, y2Clip, clipRect)) {\r
+ rSGP.moveAbs (x1, y1);\r
+ rSGP.lineAbs (x2Clip, y2Clip);\r
+ }\r
+ x1 = x2;\r
+ y1 = y2;\r
+ }
+ }
+ if (curve.m_iSymbol > 0) {
+ rSGP.setLineStyle (SGP::LS_SOLID);
+ double x = convertWorldToNDC_X (curve.x[0]);
+ double y = convertWorldToNDC_Y (curve.y[0]);
+ rSGP.moveAbs (x, y);
+ symbol (curve.m_iSymbol, symwidth, symheight);
+ for (int i = 1; i < curve.m_iPointCount; i++)
+ if (i % curve.m_iSymbolFreq == 0 || i == curve.m_iPointCount - 1) {
+ x = convertWorldToNDC_X (curve.x[i]);
+ y = convertWorldToNDC_Y (curve.y[i]);\r
+ if (y >= ygn_min && y <= ygn_max) {
+ rSGP.moveAbs (x, y);
+ symbol (curve.m_iSymbol, symwidth, symheight);\r
+ }
+ }
+ }
}
-
+
}
/* NAME
- * drawAxes INTERNAL routine to draw axis & label them
- *
- * SYNOPSIS
- * drawAxes()
- */
+* drawAxes INTERNAL routine to draw axis & label them
+*
+* SYNOPSIS
+* drawAxes()
+*/
void
if (o_grid == TRUE) {
rSGP.setColor (clr_grid);
for (i = 0; i <= x_nint; i++) {
- rSGP.moveAbs (xt_min + xn_tickinc * i, ya_max);
- rSGP.lineAbs (xt_min + xn_tickinc * i, ya_min);
+ rSGP.moveAbs (xt_min + xn_tickinc * i, ya_max);
+ rSGP.lineAbs (xt_min + xn_tickinc * i, ya_min);
}
}
- rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - c_xlabel.length()*charwidth, xlbl_row);
- rSGP.setTextSize (charheight * 2.0);
+ rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - c_xlabel.length()*charwidth * 1.5, xlbl_row + charheight * 1.5);
+ rSGP.setTextSize (charheight * 1.5);
rSGP.setTextColor (clr_label, -1);
rSGP.drawText (c_xlabel);
rSGP.setTextSize (charheight);
minorinc = xn_tickinc / (o_xminortick + 1);
-
+
for (i = 0; i <= x_nint; i++) {
x = xt_min + xn_tickinc * i;
rSGP.setColor (clr_axis);
rSGP.moveAbs (x, xaxispos);
rSGP.lineAbs (x, xaxispos + xticklen);
if (i != x_nint)
- for (j = 1; j <= o_xminortick; j++) {
- x2 = x + minorinc * j;
- rSGP.moveAbs (x2, xaxispos);
- rSGP.lineAbs (x2, xaxispos + TICKRATIO * xticklen);
- }
- axis_near = FALSE;
- if (xaxispos + xtl_ofs > ya_min && o_yaxis != NOAXIS) {
- double xw = xgw_min + i * xw_tickinc;
- double x = convertWorldToNDC_X (xw);
- double d = x - yaxispos;
- if (o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
- axis_near = TRUE;
- if (o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
- axis_near = TRUE;
- }
-
- if (o_xtlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
- numstr = str_skip_head (str, " ");
- rSGP.moveAbs (x-strlen(numstr)*charwidth/2, xaxispos + xtl_ofs);
- rSGP.setTextColor (clr_number, -1);
- rSGP.drawText (numstr);
- }
+ for (j = 1; j <= o_xminortick; j++) {
+ x2 = x + minorinc * j;
+ rSGP.moveAbs (x2, xaxispos);
+ rSGP.lineAbs (x2, xaxispos + TICKRATIO * xticklen);
+ }
+ axis_near = FALSE;
+ if (xaxispos + xtl_ofs > ya_min && o_yaxis != NOAXIS) {
+ double xw = xgw_min + i * xw_tickinc;
+ double x = convertWorldToNDC_X (xw);
+ double d = x - yaxispos;
+ if (o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
+ axis_near = TRUE;
+ if (o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
+ axis_near = TRUE;
+ }
+
+ if (o_xtlabel == TRUE && axis_near == FALSE) {
+ snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
+ numstr = str_skip_head (str, " ");
+ rSGP.moveAbs (x-strlen(numstr)*charwidth/2, xaxispos + xtl_ofs);
+ rSGP.setTextColor (clr_number, -1);
+ rSGP.drawText (numstr);
+ }
}
} // X - Axis
if (o_grid == TRUE) {
rSGP.setColor (clr_grid);
for (i = 0; i <= y_nint; i++) {
- y = yt_min + yn_tickinc * i;
- rSGP.moveAbs (xa_max, y);
- rSGP.lineAbs (xa_min, y);
+ y = yt_min + yn_tickinc * i;
+ rSGP.moveAbs (xa_max, y);
+ rSGP.lineAbs (xa_min, y);
}
}
- rSGP.moveAbs (ylbl_col, ya_min + (ya_max-ya_min)/2 - c_ylabel.length()*charheight);
+ rSGP.moveAbs (ylbl_col, ya_min + (ya_max-ya_min)/2 - c_ylabel.length()*charheight*1.5);\r
+ rSGP.getDriver().idWX()->SetFont(*wxSWISS_FONT);
rSGP.setTextAngle (HALFPI);
- rSGP.setTextSize (2 * charheight);
+ rSGP.setTextSize (1.5 * charheight);
rSGP.setTextColor (clr_label, -1);
- rSGP.drawText (c_ylabel);
rSGP.setTextAngle (0.0);
rSGP.setTextSize (charheight);
minorinc = yn_tickinc / (o_yminortick + 1);
rSGP.moveAbs (yaxispos, y);
rSGP.lineAbs (yaxispos + yticklen, y);
if (i != y_nint)
- for (j = 1; j <= o_yminortick; j++) {
- y2 = y + minorinc * j;
- rSGP.moveAbs (yaxispos, y2);
- rSGP.lineAbs (yaxispos + TICKRATIO * yticklen, y2);
- }
- axis_near = FALSE;
- if (yaxispos + ytl_ofs > xa_min && o_xaxis != NOAXIS) {
- double yw = ygw_min + i * yw_tickinc;
- double y = convertWorldToNDC_Y (yw);
- double d = y - xaxispos;
- if (o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
- axis_near = TRUE;
- if (o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
- 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);
- rSGP.setTextColor (clr_number, -1);\r
- rSGP.drawText (str);
- }
+ for (j = 1; j <= o_yminortick; j++) {
+ y2 = y + minorinc * j;
+ rSGP.moveAbs (yaxispos, y2);
+ rSGP.lineAbs (yaxispos + TICKRATIO * yticklen, y2);
+ }
+ axis_near = FALSE;
+ if (yaxispos + ytl_ofs > xa_min && o_xaxis != NOAXIS) {
+ double yw = ygw_min + i * yw_tickinc;
+ double y = convertWorldToNDC_Y (yw);
+ double d = y - xaxispos;
+ if (o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
+ axis_near = TRUE;
+ if (o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
+ 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);
+ rSGP.setTextColor (clr_number, -1);\r
+ rSGP.drawText (str);
+ }
}
} // Y - Axis
}
/* NAME
- * axis_scale calculates graph axis scaling
- *
- * SYNOPSIS:
- * retval = axis_scale (min, max, nint, minp, maxp, nintp,
- * rec_total, rec_frac)
- *
- * INPUT:
- * double min Smallest value to plot
- * double max Largest value to plot
- * int nint Number of intervals desired
- *
- * OUTPUT:
- * int retval FALSE if illegal parameters, else TRUE
- * double *minp Minimum graph value
- * double *maxp Maximum graph value
- * int *nintp Number of intervals for graph
- * int *rec_total Recommended field width for printing out the number
- * int *rec_frac Recommended number of digits for print fraction
- */
+* axis_scale calculates graph axis scaling
+*
+* SYNOPSIS:
+* retval = axis_scale (min, max, nint, minp, maxp, nintp,
+* rec_total, rec_frac)
+*
+* INPUT:
+* double min Smallest value to plot
+* double max Largest value to plot
+* int nint Number of intervals desired
+*
+* OUTPUT:
+* int retval FALSE if illegal parameters, else TRUE
+* double *minp Minimum graph value
+* double *maxp Maximum graph value
+* int *nintp Number of intervals for graph
+* int *rec_total Recommended field width for printing out the number
+* int *rec_frac Recommended number of digits for print fraction
+*/
int
EZPlot::axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp)
if (fabs(min) < fabs(max))
a = fabs(max);
double scale = pow (10.0, floor(log10(a)));
- loop:
+loop:
double mina = min / scale;
double maxa = max / scale;
double d = (maxa - mina) / nint;
v = 5.0;
double wdt = v * pow (10.0, e);
double g = floor (mina / wdt);
- if (fabs(g + 1 - mina / wdt) < j)
- g = g + 1;
-#if 1
- g++;
+ if (fabs(g + 1 - mina / wdt) < j)
+ g = g + 1;
+#undef TEST1\r
+#ifdef TEST1
+ g++;
#endif
*minp = wdt * g;
double h = floor (maxa / wdt) + 1.0;
if (fabs(maxa / wdt + 1 - h) < j)
- h = h - 1;
-#if 1
- h--;
+ h = h - 1;
+#ifdef TEST1
+ h--;
#endif
*maxp = wdt * h;
*nintp = static_cast<int>(h - g);
/* NAME
- * make_numfmt Make a numeric format string
- *
- * SYNOPSIS
- * make_numfmt (fmtstr, fldwid, nfrac, min, max, nint)
- * char *fmtstr Returned format string for printf()
- * int *fldwid Returned field width
- * int *nfrac If < 0, then calculate best number of
- * fraction places & return that value
- * If >= 0, then use that number of places
- * double min Minimum value
- * double max Maximum value
- * int nint Number of intervals between min & max
- *
- * DESCRIPTION
- * This routine is written as an INTERNAL routine for EZPLOT
- */
+* make_numfmt Make a numeric format string
+*
+* SYNOPSIS
+* make_numfmt (fmtstr, fldwid, nfrac, min, max, nint)
+* char *fmtstr Returned format string for printf()
+* int *fldwid Returned field width
+* int *nfrac If < 0, then calculate best number of
+* fraction places & return that value
+* If >= 0, then use that number of places
+* double min Minimum value
+* double max Maximum value
+* int nint Number of intervals between min & max
+*
+* DESCRIPTION
+* This routine is written as an INTERNAL routine for EZPLOT
+*/
static inline double
trunc (double x)
EZPlot::make_numfmt (char *fmtstr, int *fldwid, int *nfrac, double minval, double maxval, int nint)
{
int wid, frac, expon;
-
+
double delta = (maxval - minval) / nint;
double absmin = fabs(minval);
double absmax = fabs(maxval);\r
if (absmin > absmax)\r
- absmax = absmin;
+ absmax = absmin;
double logt = log10( absmax );
-
+
if (fabs(logt) >= 6) { // use exponential format
if (fabs(logt) > 99)
expon = 5; // E+102
delta /= pow (10., floor(logt)); // scale delta
frac = static_cast<int>(fabs(trunc(log10(delta)))) + 1;
if (frac < 1)
- frac = 1; // to be safe, add decimal pt
+ frac = 1; // to be safe, add decimal pt
} else // use users' frac
frac = *nfrac;
if (*nfrac < 0) { // calculate frac
if (delta >= 0.999999)
- frac = 1; // add a decimal pt to be safe
+ frac = 1; // add a decimal pt to be safe
else
- frac = static_cast<int>(fabs(trunc(log10(delta)))) + 1;
+ frac = static_cast<int>(fabs(trunc(log10(delta)))) + 1;
} else // use users' frac
frac = *nfrac;
wid += 1 + frac;
sprintf (fmtstr, "%s%d%s%d%s", "%", wid, ".", frac, "f");
}
-
+
*fldwid = wid;
*nfrac = frac;
}
** 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 $
+** $Id: ezset.cpp,v 1.11 2000/12/23 18:12:35 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
sys_error (ERR_WARNING, "INVALID option: %s", opt);
}
-/*----------------------------------------------------------------------*/
-/* LEXIGRAPHICAL CODES */
-/*----------------------------------------------------------------------*/
-static struct key {
- char *keyword;
- int code;
-} keytab[] = {
- {"solid", S_SOLID},
+//----------------------------------------------------------------------
+// KEYWORDS / CODES TABLE
+//----------------------------------------------------------------------
+const struct KeywordCodeTable EZPlot::m_sKeywords[] =\r
+{\r
+ {"solid", S_SOLID},
{"dash", S_DASH},
{"noline", S_NOLINE},
{"black", S_BLACK},
{"textsize", S_TEXTSIZE},
};
-
-static const unsigned int NKEYS=(sizeof(keytab) / sizeof(struct key));
+\r
+const int EZPlot::NKEYS = (sizeof(EZPlot::m_sKeywords) / sizeof (struct KeywordCodeTable));
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]");
+ if (! pol_install (m_sKeywords[i].keyword, m_sKeywords [i].code))
+ sys_error(ERR_SEVERE, "error installing ezset keywords [EZPlot::initkw]");
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: plotfile.cpp,v 1.4 2000/12/21 03:40:58 kevin Exp $
+** $Id: plotfile.cpp,v 1.5 2000/12/23 18:12:35 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
PlotFile::PlotFile (int nCurves, int nRecords)
{
- initHeaders ();
- setCurveSize (nCurves, nRecords);
+ initHeaders ();
+ setCurveSize (nCurves, nRecords);
}
PlotFile::PlotFile ()
void
PlotFile::initHeaders ()
{
- m_iNumColumns = 0;
- m_iNumRecords = 0;
- m_strTitle = "";
- m_strXLabel = "";
- m_strYLabel = "";
- m_strDate = "";
- m_vecStrDescriptions.clear();
+ m_iNumColumns = 0;
+ m_iNumRecords = 0;
+ m_strDate = "";
+ m_vecStrDescriptions.clear();\r
+ m_vecStrEzsetCommands.clear();
}
void
PlotFile::setCurveSize (int nCols, int nRecords)
{
- m_iNumColumns = nCols;
- m_iNumRecords = nRecords;
- m_vecCurves.clear();
- m_vecCurves.reserve (m_iNumColumns * m_iNumRecords);
+ m_iNumColumns = nCols;
+ m_iNumRecords = nRecords;
+ m_vecCurves.clear();
+ m_vecCurves.reserve (m_iNumColumns * m_iNumRecords);
}
\r
// Storage format\r
sys_error (ERR_SEVERE, "Illegal column number %d [PlotFile::addColumn]", iCol);
return (false);
}
-
+
for (int iRec = 0; iRec < m_iNumRecords; iRec++)
m_vecCurves[ iRec + (iCol * m_iNumRecords) ] = pdColData [iRec];
-
+
return true;
}
sys_error (ERR_SEVERE, "Illegal column number %d [PlotFile::addColumn]", iCol);\r
return (false);\r
}\r
-\r
+ \r
for (int iRec = 0; iRec < m_iNumRecords; iRec++)\r
m_vecCurves[ iRec + (iCol * m_iNumRecords) ] = pdColData [iRec];\r
-\r
+ \r
return true;\r
}\r
\r
sys_error (ERR_SEVERE, "Illegal column number %d [PlotFile::addColumn]", iCol);\r
return;\r
}\r
-\r
+ \r
for (int iRec = 0; iRec < m_iNumRecords; iRec++)\r
pdColData[iRec] = m_vecCurves[ iRec + (iCol * m_iNumRecords) ];\r
-\r
+ \r
}\r
\r
bool\r
PlotFile::getMinMax (int iStartingCol, double& dMin, double& dMax) const\r
{\r
- if (iStartingCol >= m_iNumColumns) {\r
- sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
- return false;\r
- }\r
-\r
- int iOffset = iStartingCol * m_iNumRecords;\r
- dMin = m_vecCurves[ 0 + iOffset ];\r
- dMax = dMin;\r
-\r
- for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
- int iOffset = iCol * m_iNumRecords;\r
- for (int iRec = 0; iRec < m_iNumRecords; iRec++) {\r
- double dVal = m_vecCurves[ iRec + iOffset ];\r
- if (dVal < dMin)\r
- dMin = dVal;\r
- else if (dVal > dMax)\r
- dMax = dVal;\r
- }\r
- }\r
-\r
- return true;\r
+ if (iStartingCol >= m_iNumColumns) {\r
+ sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
+ return false;\r
+ }\r
+ \r
+ int iOffset = iStartingCol * m_iNumRecords;\r
+ dMin = m_vecCurves[ 0 + iOffset ];\r
+ dMax = dMin;\r
+ \r
+ for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
+ int iOffset = iCol * m_iNumRecords;\r
+ for (int iRec = 0; iRec < m_iNumRecords; iRec++) {\r
+ double dVal = m_vecCurves[ iRec + iOffset ];\r
+ if (dVal < dMin)\r
+ dMin = dVal;\r
+ else if (dVal > dMax)\r
+ dMax = dVal;\r
+ }\r
+ }\r
+ \r
+ return true;\r
}\r
\r
bool \r
PlotFile::statistics (int iStartingCol, double& min, double& max, double& mean, double& mode, double& median, double &stddev) const\r
{\r
- if (iStartingCol >= m_iNumColumns) {\r
- sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
- return false;\r
- }\r
-\r
- int iOffset = iStartingCol * m_iNumRecords;\r
- int iNPoints = (m_iNumColumns - iStartingCol) * m_iNumRecords;\r
- std::vector<double> vec;\r
- vec.resize (iNPoints);\r
-\r
- int iVec = 0;\r
- for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
- int iOffset = iCol * m_iNumRecords;\r
- for (int iRec = 0; iRec < m_iNumRecords; iRec++)\r
- vec[iVec++] = m_vecCurves[ iRec + iOffset ];\r
- }\r
-\r
- vectorNumericStatistics (vec, iNPoints, min, max, mean, mode, median, stddev);\r
-\r
- return true;\r
+ if (iStartingCol >= m_iNumColumns) {\r
+ sys_error (ERR_WARNING, "iStartingCol >= iNumColumns");\r
+ return false;\r
+ }\r
+ \r
+ int iOffset = iStartingCol * m_iNumRecords;\r
+ int iNPoints = (m_iNumColumns - iStartingCol) * m_iNumRecords;\r
+ std::vector<double> vec;\r
+ vec.resize (iNPoints);\r
+ \r
+ int iVec = 0;\r
+ for (int iCol = iStartingCol; iCol < m_iNumColumns; iCol++) {\r
+ int iOffset = iCol * m_iNumRecords;\r
+ for (int iRec = 0; iRec < m_iNumRecords; iRec++)\r
+ vec[iVec++] = m_vecCurves[ iRec + iOffset ];\r
+ }\r
+ \r
+ vectorNumericStatistics (vec, iNPoints, min, max, mean, mode, median, stddev);\r
+ \r
+ return true;\r
}\r
\r
bool
PlotFile::fileWrite (const char* const filename)
{
- m_strFilename = filename;
-
- fstream fs (m_strFilename.c_str(), std::ios::out | std::ios::trunc);
- if (fs.fail()) {
- sys_error (ERR_WARNING, "Error opening file %s for writing [fileCreate]", m_strFilename.c_str());
- return false;
- }
-
- if (! headerWrite(fs) || ! columnsWrite (fs))
- return false;
-
- return true;
+ m_strFilename = filename;
+
+ fstream fs (m_strFilename.c_str(), std::ios::out | std::ios::trunc);
+ if (fs.fail()) {
+ sys_error (ERR_WARNING, "Error opening file %s for writing [fileCreate]", m_strFilename.c_str());
+ return false;
+ }
+
+ if (! headerWrite(fs) || ! columnsWrite (fs))
+ return false;
+
+ return true;
}
bool
PlotFile::fileRead (const char* const filename)
{
- m_strFilename = filename;
-
+ m_strFilename = filename;
+
#ifdef MSVC
- fstream fs (m_strFilename.c_str(), std::ios::in);
+ fstream fs (m_strFilename.c_str(), std::ios::in);
#else
- fstream fs (m_strFilename.c_str(), std::ios::in | std::ios::nocreate);
+ fstream fs (m_strFilename.c_str(), std::ios::in | std::ios::nocreate);
#endif
-
- if (fs.fail()) {
- sys_error (ERR_WARNING, "Unable to open file %s [fileRead]", m_strFilename.c_str());
- return false;
- }
-
- if (! headerRead(fs))
- return false;
-
- setCurveSize (m_iNumColumns, m_iNumRecords);
-
- if (! columnsRead(fs))
- return false;;
-
- return true;
+
+ if (fs.fail()) {
+ sys_error (ERR_WARNING, "Unable to open file %s [fileRead]", m_strFilename.c_str());
+ return false;
+ }
+
+ if (! headerRead(fs))
+ return false;
+
+ setCurveSize (m_iNumColumns, m_iNumRecords);
+
+ if (! columnsRead(fs))
+ return false;;
+
+ return true;
}
bool
sys_error (ERR_WARNING, "Tried to read header with file closed [headerRead]");
return false;
}
-
- fs.seekg (0);
-
- initHeaders();
- bool bInHeaders = true;
-// while (bInHeaders) {
- //}
+
+ initHeaders();\r
+ fs.seekg (0);\r
+ bool bFinishedHeaders = false;\r
+\r
+ while (! bFinishedHeaders && ! fs.eof() && ! fs.fail()) {\r
+ char line[1024];\r
+ fs.getline (line, sizeof(line));\r
+ if (strstr (line, "<datapoints>") != NULL)\r
+ bFinishedHeaders = true;\r
+ }\r
return ! fs.fail();
}
sys_error (ERR_WARNING, "Tried to write header with ! fs");
return false;
}
-
+
fs.seekp (0);
fs << "<plotfile>\n";\r
- fs << "<header>\n";
+ fs << "<ncolumns>" << m_iNumColumns << "</ncolumns>\n";\r
+ fs << "<nrecords>" << m_iNumRecords << "</nrecords>\n";\r
+ int iNEzset = m_vecStrEzsetCommands.size();\r
+ if (iNEzset > 0) {\r
+ fs << "<ezset>\n";\r
+ for (int i = 0; i < iNEzset; i++)\r
+ fs << m_vecStrEzsetCommands[i] << "\n";\r
+ fs << "</ezset>\n";\r
+ }\r
+ \r
if (! m_strDate.empty())
fs << "<date>" << m_strDate << "</date>\n";
-
- if (! m_strTitle.empty())
- fs << "<title>" << m_strTitle << "</title>\n";
-
- if (! m_strXLabel.empty())
- fs << "<xlabel>" << m_strXLabel << "</xlabel>\n";
-
- if (! m_strYLabel.empty())
- fs << "<ylabel>" << m_strYLabel << "</ylabel>\n";
-
- int iNDesc = m_vecStrDescriptions.size();
- for (int i = 0; i < iNDesc; i++)
- fs << "<description>" << m_vecStrDescriptions[i] << "</description>\n";
-
- fs << "</header>\n";
-
+
+ int iNDesc = m_vecStrDescriptions.size();\r
+ if (iNDesc > 0) {\r
+ fs << "<description>\n";
+ for (int i = 0; i < iNDesc; i++)
+ fs << m_vecStrDescriptions[i] << "\n";\r
+ fs << "</description>\n";\r
+ }
+
return ! fs.fail();
}
sys_error (ERR_WARNING, "Tried to columnWrite with !fs");
return false;
}
-
+
fs << "<datapoints>\n";
-
+
int iStride = m_iNumRecords;
for (int iRec = 0; iRec < m_iNumRecords; iRec++) {
for (int iCol = 0; iCol < m_iNumColumns; iCol++)
fs << m_vecCurves [iRec + (iCol * iStride)] << " ";
fs << "\n";
}
-
+
fs << "</datapoints>\n";
-\r
+ \r
fs << "</plotfile>\n";\r
-
+
return ! fs.fail();
}
sys_error (ERR_WARNING, "Tried to arrayDataRead with ! fs");
return false;
}
-
+
return ! fs.fail();
-
+
if (m_iNumColumns == 0 || m_iNumRecords == 0) {
sys_error (ERR_WARNING, "Called PlotFile::columnsRead with 0 columns or records");
return false;
}
-
- return true;
+\r
+ bool bTerminateEarly = false;\r
+ for (int iRec = 0; iRec < m_iNumRecords; iRec++) {\r
+ for (int iCol = 0; iCol < m_iNumColumns; iCol++) {\r
+ if (fs.eof()) {\r
+ bTerminateEarly = true;\r
+ break;\r
+ }\r
+ if (fs.fail())\r
+ break;\r
+ double d;\r
+ fs >> d;\r
+ m_vecCurves[ iRec + (iCol * m_iNumRecords) ] = d;\r
+ }\r
+ }\r
+
+ return ! (bTerminateEarly || fs.fail());
}
<pre>\r
<h1>Build Log</h1>\r
<h3>\r
---------------------Configuration: ctsim - Win32 Debug--------------------\r
+--------------------Configuration: libctsim - Win32 Debug--------------------\r
</h3>\r
<h3>Command Lines</h3>\r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP432.tmp" with contents\r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPFC.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
+/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\libctgraphics\ezplot.cpp"\r
]\r
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP432.tmp" \r
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP433.tmp" with contents\r
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPFC.tmp" \r
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPFD.tmp" with contents\r
+[\r
+/nologo /out:"Debug\libctsim.lib" \r
+".\Debug\array2dfile.obj"\r
+".\Debug\backprojectors.obj"\r
+".\Debug\clip.obj"\r
+".\Debug\consoleio.obj"\r
+".\Debug\ezplot.obj"\r
+".\Debug\ezset.obj"\r
+".\Debug\ezsupport.obj"\r
+".\Debug\filter.obj"\r
+".\Debug\fnetorderstream.obj"\r
+".\Debug\getopt.obj"\r
+".\Debug\getopt1.obj"\r
+".\Debug\imagefile.obj"\r
+".\Debug\mathfuncs.obj"\r
+".\Debug\phantom.obj"\r
+".\Debug\plotfile.obj"\r
+".\Debug\pol.obj"\r
+".\Debug\procsignal.obj"\r
+".\Debug\projections.obj"\r
+".\Debug\reconstruct.obj"\r
+".\Debug\scanner.obj"\r
+".\Debug\sgp.obj"\r
+".\Debug\strfuncs.obj"\r
+".\Debug\syserror.obj"\r
+".\Debug\trace.obj"\r
+".\Debug\transformmatrix.obj"\r
+".\Debug\xform.obj"\r
+]\r
+Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPFD.tmp"\r
+<h3>Output Window</h3>\r
+Compiling...\r
+ezplot.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\RSPFE.tmp" with contents\r
[\r
comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libctsim/Debug/libctsim.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\lpng108\msvc\win32\libpng\lib_dbg\libpng.lib ..\..\..\lpng108\msvc\win32\zlib\lib_dbg\zlib.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib ../../../wx2/lib/wxd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrtd.lib" /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"..\..\..\lpng108\msvc\win32\libpng\lib" /libpath:"..\..\..\lpng108\msvc\win32\zlib\lib" \r
".\Debug\ctsim.obj"\r
"\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib"\r
"\wx2\lib\wxd.lib"\r
]\r
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP433.tmp"\r
+Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPFE.tmp"\r
<h3>Output Window</h3>\r
-Compiling...\r
-ctsim.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
-BSCMAKE: warning BK4503 : minor error in .SBR file '.\Debug\ctsim.sbr' ignored\r
-<h3>Output Window</h3>\r
\r
\r
\r
<h3>Results</h3>\r
-ctsim.exe - 0 error(s), 1 warning(s)\r
+ctsim.exe - 0 error(s), 0 warning(s)\r
</pre>\r
</body>\r
</html>\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: views.cpp,v 1.36 2000/12/22 04:18:00 kevin Exp $
+** $Id: views.cpp,v 1.37 2000/12/23 18:12:35 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
sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
} else {\r
PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
- std::ostringstream title;\r
- title << "Row " << yCursor;\r
- rPlotFile.setTitle(title.str());\r
- rPlotFile.setXLabel("Column");\r
- rPlotFile.setYLabel("Pixel Value");\r
+ std::ostringstream os;\r
+ os << "Row " << yCursor;\r
+ std::string title("title ");\r
+ title += os.str();\r
+ rPlotFile.addEzsetCommand (title.c_str());\r
+ rPlotFile.addEzsetCommand ("xlabel Column");\r
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("box");\r
+ rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
rPlotFile.addColumn (0, pX);\r
rPlotFile.addColumn (1, pY);\r
sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
} else {\r
PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
- std::ostringstream title;\r
- title << "Column " << xCursor;\r
- rPlotFile.setTitle(title.str());\r
- rPlotFile.setXLabel("Row");\r
- rPlotFile.setYLabel("Pixel Value");\r
+ std::ostringstream os;\r
+ os << "Column " << xCursor;\r
+ std::string title("title ");\r
+ title += os.str();\r
+ rPlotFile.addEzsetCommand (title.c_str());\r
+ rPlotFile.addEzsetCommand ("xlabel Row");\r
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("box");\r
+ rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (2, nx);\r
rPlotFile.addColumn (0, pX);\r
rPlotFile.addColumn (1, pY);\r
\r
std::vector<ImageFileDocument*> vecIFDoc;\r
theApp->getCompatibleImages (GetDocument(), vecIFDoc);\r
- \r
+ if (vecIFDoc.size() == 0) {\r
+ wxMessageBox ("No compatible images for Column Comparison", "Error");\r
+ return;\r
+ }\r
DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false);\r
\r
if (dialogGetCompare.ShowModal() == wxID_OK) {\r
sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
} else {\r
PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
- std::ostringstream title;\r
- title << "Comparison of Column " << xCursor;\r
- rPlotFile.setTitle(title.str());\r
- rPlotFile.setXLabel("Row");\r
- rPlotFile.setYLabel("Pixel Value");\r
+ std::ostringstream os;\r
+ os << "Column " << xCursor << " Comparison";\r
+ std::string title("title ");\r
+ title += os.str();\r
+ rPlotFile.addEzsetCommand (title.c_str());\r
+ rPlotFile.addEzsetCommand ("xlabel Row");\r
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("box");\r
+ rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (3, nx);\r
rPlotFile.addColumn (0, pX);\r
rPlotFile.addColumn (1, pY1);\r
std::vector<ImageFileDocument*> vecIFDoc;\r
theApp->getCompatibleImages (GetDocument(), vecIFDoc);\r
\r
+ if (vecIFDoc.size() == 0) {\r
+ wxMessageBox ("No compatible images for Row Comparison", "Error");\r
+ return;\r
+ }\r
+\r
DialogGetComparisonImage dialogGetCompare (m_frame, "Get Comparison Image", vecIFDoc, false);\r
\r
if (dialogGetCompare.ShowModal() == wxID_OK) {\r
sys_error (ERR_SEVERE, "Internal error: unable to create Plot file");\r
} else {\r
PlotFile& rPlotFile = pPlotDoc->getPlotFile();\r
- std::ostringstream title;\r
- title << "Comparison of Row " << yCursor;\r
- rPlotFile.setTitle(title.str());\r
- rPlotFile.setXLabel("Column");\r
- rPlotFile.setYLabel("Pixel Value");\r
+ std::ostringstream os;\r
+ os << "Row " << yCursor << " Comparison";\r
+ std::string title("title ");\r
+ title += os.str();\r
+ rPlotFile.addEzsetCommand (title.c_str());\r
+ rPlotFile.addEzsetCommand ("xlabel Column");\r
+ rPlotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ rPlotFile.addEzsetCommand ("box");\r
+ rPlotFile.addEzsetCommand ("grid");\r
rPlotFile.setCurveSize (3, ny);\r
rPlotFile.addColumn (0, pX);\r
rPlotFile.addColumn (1, pY1);\r
m_iDefaultTrace = dialogReconstruction.getTrace();
if (m_iDefaultNX > 0 && m_iDefaultNY > 0) {
ImageFileDocument* pReconDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));\r
- if (pReconDoc) {\r
+ if (! pReconDoc) {\r
sys_error (ERR_SEVERE, "Unable to create image file");\r
return;\r
}
SGP sgp (driver);\r
const PlotFile& rPhantom = GetDocument()->getPlotFile();\r
EZPlot plot (sgp);\r
- \r
- if (! rPlotFile.getTitle().empty()) {\r
- std::string s("title ");\r
- s += rPlotFile.getTitle();\r
- plot.ezset (s);\r
- }\r
- if (! rPlotFile.getXLabel().empty()) {\r
- std::string s("xlabel ");\r
- s += rPlotFile.getXLabel();\r
- plot.ezset (s);\r
- }\r
- if (! rPlotFile.getYLabel().empty()) {\r
- std::string s("ylabel ");\r
- s += rPlotFile.getYLabel();\r
- plot.ezset (s);\r
- }\r
- \r
+\r
+ for (int iEzset = 0; iEzset < rPlotFile.getNumEzsetCommands(); iEzset++)\r
+ plot.ezset (rPlotFile.getEzsetCommand (iEzset));\r
+\r
if (m_bMinSpecified) {\r
std::ostringstream os;\r
os << "ymin " << m_dMinPixel;\r
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if1.cpp,v 1.1 2000/12/18 00:24:28 kevin Exp $
+** $Id: if1.cpp,v 1.2 2000/12/23 18:12:35 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
{0, 0, 0, 0}
};
-static const char* g_szIdStr = "$Id: if1.cpp,v 1.1 2000/12/18 00:24:28 kevin Exp $";
+static const char* g_szIdStr = "$Id: if1.cpp,v 1.2 2000/12/23 18:12:35 kevin Exp $";
void
if1_usage (const char *program)
}
if (opt_log) {
for (ix = 0; ix < nx; ix++)
- for (iy = 0; iy < ny; iy++)
- vOut[ix][iy] = log (vIn[ix][iy]);
- histString = "Log transformation";
+ for (iy = 0; iy < ny; iy++)\r
+ if (vIn[ix][iy] < 0)\r
+ vOut[ix][iy] = 0;
+ else\r
+ vOut[ix][iy] = log (vIn[ix][iy]);
+ histString = "Logrithmic transformation";
}
if (opt_exp) {
for (ix = 0; ix < nx; ix++)
for (iy = 0; iy < ny; iy++)
vOut[ix][iy] = exp (vIn[ix][iy]);
- histString = "Exp transformation";
+ histString = "Exponential transformation";
}
if (opt_sqr) {
for (ix = 0; ix < nx; ix++)
for (iy = 0; iy < ny; iy++)
vOut[ix][iy] = vIn[ix][iy] * vIn[ix][iy];
- histString = "Sqr transformation";
+ histString = "Square transformation";
}
if (opt_sqrt) {
for (ix = 0; ix < nx; ix++)
- for (iy = 0; iy < ny; iy++)
- vOut[ix][iy] = sqrt (vIn[ix][iy]);
- histString = "Sqrt transformation";
+ for (iy = 0; iy < ny; iy++)\r
+ if (vIn[ix][iy] < 0)
+ vOut[ix][iy] = sqrt (-vIn[ix][iy]);\r
+ else\r
+ vOut[ix][iy] = sqrt (vIn[ix][iy]);\r
+ histString = "Square root transformation";
}
im_out->labelsCopy (*im_in);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if2.cpp,v 1.4 2000/12/22 04:18:00 kevin Exp $
+** $Id: if2.cpp,v 1.5 2000/12/23 18:12:35 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
{0, 0, 0, 0}
};
-static const char* g_szIdStr = "$Id: if2.cpp,v 1.4 2000/12/22 04:18:00 kevin Exp $";
+static const char* g_szIdStr = "$Id: if2.cpp,v 1.5 2000/12/23 18:12:35 kevin Exp $";
void
if2_usage (const char *program)
plotFile.addColumn (0, plot_xaxis);\r
plotFile.addColumn (1, v1[opt_columnPlot]);\r
plotFile.addColumn (2, v2[opt_columnPlot]);\r
- plotFile.setTitle ("Column Plot");\r
- plotFile.setXLabel ("Column");\r
- plotFile.setYLabel ("Pixel Value");\r
- \r
+ std::ostringstream os;\r
+ os << "Column " << opt_columnPlot << " Comparison";\r
+ plotFile.addDescription (os.str().c_str());\r
+ std::string title("title ");\r
+ title += os.str();\r
+ plotFile.addEzsetCommand (title.c_str());\r
+ plotFile.addEzsetCommand ("xlabel Column");\r
+ plotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ plotFile.addEzsetCommand ("box");\r
+ plotFile.addEzsetCommand ("grid");\r
+ plotFile.addEzsetCommand ("xticks major 5");\r
+\r
plotFile.fileWrite (strOutFile.c_str());\r
\r
#if HAVE_SGP
plotFile.addColumn (0, plot_xaxis);
plotFile.addColumn (1, v1Row);
plotFile.addColumn (2, v2Row);
- plotFile.setTitle ("Row Plot");
- plotFile.setXLabel ("Row");
- plotFile.setYLabel ("Pixel Value");
+ std::ostringstream os;\r
+ os << "Row " << opt_rowPlot << " Comparison";\r
+ plotFile.addDescription (os.str().c_str());\r
+ std::string title("title ");\r
+ title += os.str();\r
+ plotFile.addEzsetCommand (title.c_str());\r
+ plotFile.addEzsetCommand ("xlabel Row");\r
+ plotFile.addEzsetCommand ("ylabel Pixel Value");\r
+ plotFile.addEzsetCommand ("box");\r
+ plotFile.addEzsetCommand ("grid");\r
+ plotFile.addEzsetCommand ("xticks major 5");\r
plotFile.fileWrite (strOutFile.c_str());