r163: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 28 Jul 2000 10:51:31 +0000 (10:51 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 28 Jul 2000 10:51:31 +0000 (10:51 +0000)
ChangeLog
include/ezplot.h
libctgraphics/ezplot.cpp
libctgraphics/ezset.cpp
libctgraphics/sgp.cpp
libctsim/phantom.cpp
libctsim/projections.cpp
tools/if-2.cpp

index 3609c14562e6a7b1087c66564e3fb6bb37a47c44..8f16a4df42bbf23cda685d8fb52e315ec5d5e4b8 100644 (file)
--- 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 
index 06601db5515413c006fab7e8a9b21121bff585e6..13e35e9b9f1f679c85c0e2bf255e1e6f94e32972 100644 (file)
@@ -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);
 
index 6ffd0b05b2f2fc9bc2b9f090b64987dd3cd26774..519b7f97396bd398cd710b4e03f841d8d1077090 100644 (file)
@@ -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);
index 662351306231d995146a163b8c2a0e63cf6dd3c4..c28c76180ac131390c8da4c2b9e875671e772d28 100644 (file)
@@ -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<double*>(NULL), static_cast<double*>(NULL), 0);
        //      i_plotimmediate = FALSE;
-      }
+      // }
     }
     break;
   case S_SYMBOL:
index e1a1142e8448a476252010fe899b8cb4614eb8c9..4d70f8cfe965f265f99f06d723542bd7d8603883 100644 (file)
@@ -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<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);
index f8b1278cef478037b28352f45537e8e8185b22ce..d16bf5bb42e8d2e7d35a93cec3fc925f081c1aaa 100644 (file)
@@ -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);
 }
 
 
index 35d8418a070edd3029684246f8e8eea645d1ffff..e5d19a37cceafc09cfafb3bd37df7bbd225052bc 100644 (file)
@@ -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();
     }
index 2558360f32341352d12a4ab612fbc93ae4405d76..9fee32a01286ede9aeb9783f203fa985003a1b89 100644 (file)
@@ -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