Fixed bug in SignalFilter::convertFilterMethodNameToID()
Rewrote SGP & EZPlot to use C++ object-oriented. SGP can now write to
G2 windows and well as WXWindows.
- Now, "Create Phantom" in ctsim shows phantom object
+ ctsim program: "Create Phantom" now shows phantom object
+ Fixed row-plot bug in if-2
+ Reworked EZPlot's multiple plot operation
2.0.0-b6 - 7/22/00
ctsim program: improved initial size and scroll area for image
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.h,v 1.10 2000/07/28 08:28:08 kevin Exp $
+** $Id: ezplot.h,v 1.11 2000/07/28 10:51:31 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
int clr_number; /* color of axis number labels */
// Options
- int o_reqcurves; /* # of curves specified in CURVES command */
- /* default value is 1, so that a call to EZPLOT
- will force a plot */
- bool o_unknowncurves; /* TRUE when the user specifies that the
- number of curves is unknown */
-
double o_xporigin, o_yporigin; /* origin of plot frame in NDC */
double o_xlength, o_ylength; /* length of plot frame in NDC */
bool ezcmd (char *comm);
int do_cmd(int lx);
void bad_option(char *opt);
- static void initkw(void);
+ void initPlotSettings();
+ static void initkw(void);
+
int curveinteract;
static bool ezset_initialized;
int ezset (char *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);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ezplot.cpp,v 1.7 2000/07/28 08:28:08 kevin Exp $
+** $Id: ezplot.cpp,v 1.8 2000/07/28 10:51:31 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
x = new double [n];
y = new double [n];
-#if 1
- for (int i = 0; i < n; i++) {
- x[i] = xData[i];
- y[i] = yData[i];
- }
-#else
int copyCount = n * sizeof(double);
memcpy (x, xData, copyCount);
memcpy (y, yData, copyCount);
-#endif
+
m_iPointCount = n;
m_iColor = color;
m_iLineStyle = linestyle;
addCurve (dx, y, num);
}
+void
+EZPlot::addCurve (const double x[], const float y[], int num)
+{
+ double dy [num];
+
+ for (int i = 0; i < num; i++)
+ dy[i] = y[i];
+
+ addCurve (x, dy, num);
+}
+
void
EZPlot::addCurve (const double x[], const double y[], int num)
if (num < 1)
return;
- int iNumCurves = m_vecCurves.size();
-
- if (o_unknowncurves == FALSE && iNumCurves >= o_reqcurves)
- clearCurves ();
-
- if (o_unknowncurves == TRUE || iNumCurves < o_reqcurves) {
- EZPlotCurve* pCurve = new EZPlotCurve (x, y, num, o_color, o_linestyle, o_symbol, o_symfreq, c_legend);
- m_vecCurves.push_back (pCurve);
- }
-
- iNumCurves = m_vecCurves.size(); // recalculate
- if (o_unknowncurves == FALSE && iNumCurves >= o_reqcurves) {
- plot ();
- clearCurves ();
- }
+ EZPlotCurve* pCurve = new EZPlotCurve (x, y, num, o_color, o_linestyle, o_symbol, o_symfreq, c_legend);
+ m_vecCurves.push_back (pCurve);
}
void
EZPlot::clearCurves ()
{
- for (EZPlotCurveIterator i = m_vecCurves.begin(); i != m_vecCurves.end(); i++) delete *i;
+ for (EZPlotCurveIterator i = m_vecCurves.begin(); i != m_vecCurves.end(); i++)
+ delete *i;
m_vecCurves.erase (m_vecCurves.begin(), m_vecCurves.end());
+ initPlotSettings();
}
EZPlot::EZPlot (SGP& sgp)
: rSGP (sgp)
+{
+ initPlotSettings();
+}
+
+void
+EZPlot::initPlotSettings ()
{
curveinteract = -1;
c_title = "";
c_legend = "";
- o_reqcurves = 1;
- o_unknowncurves = FALSE;
-
o_xporigin = 0.0;
o_yporigin = 0.0;
o_xlength = 1.0;
/* NAME
- * plot INTERNAL: Plots all curves collected by ezplot()
+ * plot Plots all curves collected by addCurves ()
*
* SYNOPSIS
* plot()
*
* DESCRIPTION
- * This routine plots the curves that have stored by ezplot().
- *
- * CALLED BY
- * EZPLOT() only
+ * This routine plots the curves that have stored by addCurves().
*
* CALLS
* drawAxes() & make_numfmt()
/* Convert WC in graph boundary to axis boundary */
rSGP.setWindow (xgw_min, ygw_min, xgw_max, ygw_max); /* Graph boundary */
rSGP.setViewport (xgn_min, ygn_min, xgn_max, ygn_max);
-
double xminTemp = xa_min, xmaxTemp = xa_max;
double yminTemp = ya_min, ymaxTemp = ya_max;
rSGP.transformNDCtoMC (&xminTemp, &yminTemp); // calc WC to axis boundaries
- rSGP.transformNDCtoMC (&yminTemp, &ymaxTemp);
-
- rSGP.setWindow (xminTemp, yminTemp, xmaxTemp, ymaxTemp); // Set window to axis boundaries
+ rSGP.transformNDCtoMC (&xmaxTemp, &ymaxTemp);
+ rSGP.setWindow (xminTemp, yminTemp, xmaxTemp, ymaxTemp); // Set window to axis boundaries
rSGP.setViewport (xa_min, ya_min, xa_max, ya_max);
symwidth = charwidth * (xgw_max - xgw_min);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
- ** $Id: ezset.cpp,v 1.5 2000/07/28 08:28:08 kevin Exp $
+ ** $Id: ezset.cpp,v 1.6 2000/07/28 10:51:31 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
// o_reqcurves = n;
// }
} else {
- if (pol_word ("unknown", 7) == TRUE)
- o_unknowncurves = TRUE;
- else if (pol_word ("end", 3) == TRUE) {
+ // if (pol_word ("unknown", 7) == TRUE)
+ // o_unknowncurves = TRUE;
+ // else if (pol_word ("end", 3) == TRUE) {
// o_unknowncurves = FALSE;
// o_reqcurves = i_numcurves;
// i_plotimmediate = TRUE;
// ezplot (static_cast<double*>(NULL), static_cast<double*>(NULL), 0);
// i_plotimmediate = FALSE;
- }
+ // }
}
break;
case S_SYMBOL:
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: sgp.cpp,v 1.5 2000/07/28 08:28:08 kevin Exp $
+** $Id: sgp.cpp,v 1.6 2000/07/28 10:51:31 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
void
SGP::stylusNDC (double x, double y, bool beam)
{
- int xp = static_cast<int>(x * m_iPhysicalXSize + 0.5);
- int yp = static_cast<int>(y * m_iPhysicalYSize + 0.5);
+ int xp = static_cast<int>(x * (m_iPhysicalXSize - 1) + 0.5);
+ int yp = static_cast<int>(y * (m_iPhysicalYSize - 1) + 0.5);
+ if (m_driver.isWX())
+ yp = m_iPhysicalYSize - yp;
+
if (beam) {
if (m_driver.isWX())
m_driver.idWX()->DrawLine (m_iCurrentPhysicalX, m_iCurrentPhysicalY, xp, yp);
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phantom.cpp,v 1.11 2000/07/28 08:28:08 kevin Exp $
+** $Id: phantom.cpp,v 1.12 2000/07/28 10:51:31 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
double xmin = m_xmin;
double ymin = m_ymin;
- if ((m_ymax - m_ymin) > wsize)
+ if ((m_ymax - m_ymin) > wsize)
wsize = m_ymax - m_ymin;
- wsize *= 1.1;
+ wsize *= 1.01;
double xmax = xmin + wsize;
double ymax = ymin + wsize;
-
+
sgp.setWindow (xmin, ymin, xmax, ymax);
for (PElemIterator i = m_listPElem.begin(); i != m_listPElem.end(); i++)
sgp.polylineAbs ((*i)->xOutline(), (*i)->yOutline(), (*i)->nOutlinePoints());
Phantom::addStdRowlandBordered ()
{
addStdRowland ();
- addPElem ("ellipse", 0.000, 0.0000, 0.7500, 1.000, 0.0, 0.00);
+ addPElem ("rectangle", 0.000, 0.0000, 0.7500, 1.000, 0.0, 0.00);
}
/* NAME
Phantom::addStdHermanBordered ()
{
addStdHerman();
- addPElem ("ellipse", 0.000, 0.000, 8.650, 8.650, 0.00, 0.000);
+ addPElem ("rectangle", 0.000, 0.000, 8.650, 8.650, 0.00, 0.000);
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: projections.cpp,v 1.16 2000/07/28 08:28:08 kevin Exp $
+** $Id: projections.cpp,v 1.17 2000/07/28 10:51:31 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
EZPlot ezplot (sgp);
ezplot.addCurve (plot_xaxis, filter.getFilter(), nVecFilter);
+ ezplot.plot();
cio_put_str ("Press any key to continue");
cio_kb_getc ();
}
ezplotProj.ezset ("box.");
ezplotProj.ezset ("grid.");
ezplotProj.addCurve (detval, plot_xaxis, m_nDet);
- ezplotProj.ezset ("clear.");
+ ezplotProj.plot();
+ ezplotProj.ezset ("clear");
ezplotProj.ezset ("xticks major 5.");
ezplotProj.ezset ("xlabel ");
ezplotProj.ezset ("ylabel ");
ezplotProj.ezset ("box");
ezplotProj.ezset ("grid");
ezplotProj.addCurve (filteredProj, plot_xaxis, n_filteredProj);
- ezplotProj.plot ();
+ ezplotProj.plot();
cout << "Press enter to continue\n";
cio_kb_getc();
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: if-2.cpp,v 1.2 2000/07/28 08:28:08 kevin Exp $
+** $Id: if-2.cpp,v 1.3 2000/07/28 10:51:31 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
int opt_sub = 0;
int opt_mul = 0;
int opt_comp = 0;
- int opt_outputFile = 0;
+ bool opt_outputFile = false;
int opt_rowPlot = -1;
int opt_columnPlot = -1;
Timer timerProgram;
switch (c) {
case O_ADD:
opt_add = 1;
- opt_outputFile = 1;
+ opt_outputFile = true;
break;
case O_SUB :
opt_sub = 1;
- opt_outputFile = 1;
+ opt_outputFile = true;
break;
case O_MUL:
opt_mul = 1;
- opt_outputFile = 1;
+ opt_outputFile = true;
break;
case O_ROW_PLOT:
opt_rowPlot = strtol(optarg, &endptr, 10);
if (endptr != optarg + strlen(optarg)) {
if2_usage(argv[0]);
}
+ break;
case O_COLUMN_PLOT:
opt_columnPlot = strtol(optarg, &endptr, 10);
if (endptr != optarg + strlen(optarg)) {
if2_usage(argv[0]);
}
+ break;
case O_COMP:
opt_comp = 1;
break;
SGPDriver driver ("Column Plot");
SGP sgp (driver);
EZPlot ezplot (sgp);
- ezplot.ezset ("clear.");
- ezplot.ezset ("xticks major 5.");
- ezplot.ezset ("xlabel Column");
- ezplot.ezset ("ylabel Pixel");
- ezplot.ezset ("curves 2");
- ezplot.ezset ("box.");
- ezplot.ezset ("grid.");
- ezplot.addCurve (v1[opt_columnPlot], plot_xaxis, im_in1.ny());
- ezplot.addCurve (v2[opt_columnPlot], plot_xaxis, im_in2.ny());
+ ezplot.ezset ("clear.");
+ ezplot.ezset ("xticks major 5.");
+ ezplot.ezset ("xlabel Column");
+ ezplot.ezset ("title Column Plot");
+ ezplot.ezset ("ylabel Pixel");
+ ezplot.ezset ("box.");
+ ezplot.ezset ("grid.");
+ ezplot.addCurve (plot_xaxis, v1[opt_columnPlot], im_in1.ny());
+ ezplot.addCurve (plot_xaxis, v2[opt_columnPlot], im_in2.ny());
+ ezplot.plot();
cout << "Press enter to continue" << flush;
cio_kb_getc();
#endif
for (int i = 0; i < ny; i++)
plot_xaxis[i] = i;
for (int i = 0; i < nx; i++)
- v1Row[i] = v1[opt_rowPlot][i];
+ v1Row[i] = v1[i][opt_rowPlot];
for (int i = 0; i < nx2; i++)
- v2Row[i] = v2[opt_rowPlot][i];
+ v2Row[i] = v2[i][opt_rowPlot];
#if HAVE_SGP
- SGPDriver driver ("Column Plot");
+ SGPDriver driver ("Row Plot");
SGP sgp (driver);
EZPlot ezplot (sgp);
- ezplot.ezset ("clear.");
- ezplot.ezset ("xticks major 5.");
- ezplot.ezset ("xlabel Column");
- ezplot.ezset ("ylabel Pixel");
- ezplot.ezset ("curves 2");
- ezplot.ezset ("box.");
- ezplot.ezset ("grid.");
- ezplot.addCurve (v1Row, plot_xaxis, im_in1.nx());
- ezplot.addCurve (v2Row, plot_xaxis, im_in2.nx());
+ ezplot.ezset ("clear.");
+ ezplot.ezset ("xticks major 5.");
+ ezplot.ezset ("title Row Plot");
+ ezplot.ezset ("xlabel Row");
+ ezplot.ezset ("ylabel Pixel");
+ ezplot.ezset ("box.");
+ ezplot.ezset ("grid.");
+ ezplot.addCurve (plot_xaxis, v1Row, im_in1.nx());
+ ezplot.addCurve (plot_xaxis, v2Row, im_in2.nx());
+ ezplot.plot();
cout << "Press enter to continue" << flush;
cio_kb_getc();
#endif