From c85a5b31119b4e0903144c55441717a7ad1e0b8b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 28 Jul 2000 10:51:31 +0000 Subject: [PATCH] r163: *** empty log message *** --- ChangeLog | 4 ++- include/ezplot.h | 13 ++++---- libctgraphics/ezplot.cpp | 64 ++++++++++++++++++---------------------- libctgraphics/ezset.cpp | 10 +++---- libctgraphics/sgp.cpp | 9 ++++-- libctsim/phantom.cpp | 12 ++++---- libctsim/projections.cpp | 8 +++-- tools/if-2.cpp | 56 +++++++++++++++++++---------------- 8 files changed, 88 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3609c14..8f16a4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,9 @@ 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 diff --git a/include/ezplot.h b/include/ezplot.h index 06601db..13e35e9 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.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 @@ -130,12 +130,6 @@ class EZPlot { 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 */ @@ -211,8 +205,10 @@ class EZPlot { 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; @@ -223,6 +219,7 @@ class EZPlot { 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); diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 6ffd0b0..519b7f9 100644 --- a/libctgraphics/ezplot.cpp +++ b/libctgraphics/ezplot.cpp @@ -6,7 +6,7 @@ ** 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 @@ -41,16 +41,10 @@ EZPlotCurve::EZPlotCurve (const double* xData, const double* yData, int n, int c 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; @@ -88,6 +82,17 @@ EZPlot::addCurve (const float x[], const double y[], int num) 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) @@ -95,21 +100,8 @@ 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); } @@ -122,13 +114,21 @@ EZPlot::~EZPlot () 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; @@ -140,9 +140,6 @@ EZPlot::EZPlot (SGP& sgp) c_title = ""; c_legend = ""; - o_reqcurves = 1; - o_unknowncurves = FALSE; - o_xporigin = 0.0; o_yporigin = 0.0; o_xlength = 1.0; @@ -192,16 +189,13 @@ EZPlot::EZPlot (SGP& sgp) /* 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() @@ -513,13 +507,11 @@ EZPlot::plot () /* 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); diff --git a/libctgraphics/ezset.cpp b/libctgraphics/ezset.cpp index 6623513..c28c761 100644 --- a/libctgraphics/ezset.cpp +++ b/libctgraphics/ezset.cpp @@ -6,7 +6,7 @@ ** 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 @@ -297,15 +297,15 @@ EZPlot::do_cmd (int lx) // 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(NULL), static_cast(NULL), 0); // i_plotimmediate = FALSE; - } + // } } break; case S_SYMBOL: diff --git a/libctgraphics/sgp.cpp b/libctgraphics/sgp.cpp index e1a1142..4d70f8c 100644 --- a/libctgraphics/sgp.cpp +++ b/libctgraphics/sgp.cpp @@ -7,7 +7,7 @@ ** 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 @@ -83,8 +83,11 @@ SGP::SGP (const SGPDriver& driver) void SGP::stylusNDC (double x, double y, bool beam) { - int xp = static_cast(x * m_iPhysicalXSize + 0.5); - int yp = static_cast(y * m_iPhysicalYSize + 0.5); + int xp = static_cast(x * (m_iPhysicalXSize - 1) + 0.5); + int yp = static_cast(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); diff --git a/libctsim/phantom.cpp b/libctsim/phantom.cpp index f8b1278..d16bf5b 100644 --- a/libctsim/phantom.cpp +++ b/libctsim/phantom.cpp @@ -9,7 +9,7 @@ ** 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 @@ -331,13 +331,13 @@ Phantom::draw (SGP& sgp) const 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()); @@ -374,7 +374,7 @@ void 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 @@ -409,7 +409,7 @@ void 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); } diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index 35d8418..e5d19a3 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -8,7 +8,7 @@ ** 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 @@ -531,6 +531,7 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi EZPlot ezplot (sgp); ezplot.addCurve (plot_xaxis, filter.getFilter(), nVecFilter); + ezplot.plot(); cio_put_str ("Press any key to continue"); cio_kb_getc (); } @@ -569,7 +570,8 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi 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 "); @@ -578,7 +580,7 @@ Projections::reconstruct (ImageFile& im, const char* const filterName, double fi 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(); } diff --git a/tools/if-2.cpp b/tools/if-2.cpp index 2558360..9fee32a 100644 --- a/tools/if-2.cpp +++ b/tools/if-2.cpp @@ -9,7 +9,7 @@ ** 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 @@ -79,7 +79,7 @@ if2_main (int argc, char *const argv[]) 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; @@ -94,26 +94,28 @@ if2_main (int argc, char *const argv[]) 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; @@ -231,15 +233,16 @@ if2_main (int argc, char *const argv[]) 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 @@ -256,23 +259,24 @@ if2_main (int argc, char *const argv[]) 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 -- 2.34.1