r150: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 18 Jul 2000 03:14:35 +0000 (03:14 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 18 Jul 2000 03:14:35 +0000 (03:14 +0000)
15 files changed:
ChangeLog
INSTALL
Makefile.am
NEWS
README
configure
configure.in
include/phantom.h
libctsim/phantom.cpp
src/Makefile.am
src/ctsim.h
src/dialogs.cpp [new file with mode: 0644]
src/dialogs.h [new file with mode: 0644]
src/views.cpp
src/views.h

index b6451cb6b81adc438c406c4d3ae7d658007606f7..ddf2ee59f60f6fad635ee4bcd5615ad63af0b74f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2.0.0-b5 - 7/20/00
+   Added capabilities to graphical ctsim program
+       
 2.0.0-b4 - 7/13/00
    Fixed compiler warnings at -Wall level
    Began work on CTSim program to be graphical front-end of all functions
diff --git a/INSTALL b/INSTALL
index 4b46c7576bfb93f088dc274a00e48c14184d782a..ad4661686f6d93abf80c8466abb098b41f4b4b21 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -13,16 +13,17 @@ libpng (ftp://ftp.uu.net/graphics/png/src)
   not work.
 
 fftw (http://www.fftw.org)
-  Fastest Fourier Transform in the West. Currently, the only FFT
-  routines used by CTSim.
+  Fastest Fourier Transform in the West. Currently, this library is the 
+  only FFT routines used by CTSim.
 
 wxWindows (http://www.wxwindows.org)
-  Used by CTSim (src/*) graphic front-end
+  Used by CTSim (src/*) graphic front-end. Platform independent for
+  UNIX and Windows
 
 g2 (http://g2.sourceforge.net)
   Currently, used partially by SGP (Simple Graphics Package) for 
-graphical display by command-line tools (tools/*). This library
-will likely be deprecated in favor of wxWindows.
+  graphical display by command-line tools (tools/*). This library
+  will likely be deprecated in favor of wxWindows.
 
 lam (http://www.mpi.nd.edu/lam/)
   There is support is MPI clustering. I use this code at home for my
@@ -62,13 +63,15 @@ FreeBSD v4.0, BSD/OS v3.0, and Solaris v8 (gcc 32-bit), and IA64 (gcc)
 
 Visual C++ Installation
 -----------------------
-Run make.bat from the root directory (Note, make.bat is out of date)
+Run make.bat from the root directory (Note, make.bat is out of date
+and is currently broken)
 
 CYGWIN v1.1.0
 -------------
 The file /usr/i686-pc-wygwin/include/cygwin/in.h has a bug. The line
       struct in_addr6 sin6_addr;
 should be deleted.
+
 getopt_long appears broken, configure.in checks for cygwin to use
 bundled version of getopt_long.
 
index c1c153a3dd91279b45159c719ff4d9c31fd6bb26..682436f983aaeaf02c4b4b7cb5b9c2bbe46d748f 100644 (file)
@@ -16,7 +16,7 @@ else
 EXTRA_DIRS3=
 endif
 
-SUBDIRS=$(EXTRA_DIRS1) $(EXTRA_DIRS2) libctsupport libctsim man html cgi-bin include tools $(EXTRA_DIRS3)
+SUBDIRS=$(EXTRA_DIRS1) $(EXTRA_DIRS2) libctsupport libctsim man doc html cgi-bin include tools $(EXTRA_DIRS3)
 EXTRA_DIST=acsite.m4 make.bat
 
 
diff --git a/NEWS b/NEWS
index c6a1599cfe374e647488b24b078408b6f298d69f..5048b7920c2ca69ddf562c2fe942b822b3a961be 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,13 +3,15 @@ Version 2.0 of CTSim is near completion!
 
 New Features of CTSim version 2.0:
 
-- Entire code-base, except for SGP & EZPlot, cleaned up and
-  re-written. All code converted to C++.
+- Entire code-base, except for SGP & EZPlot, cleaned up,
+  re-written, and converted from C to C++.
 
 - Integrated G2 library for graphical display from command line tools
+  (UNIX only)
 
 - Graphic front-end (ctsim) initial implemention. Can display
-  projection and image files.
+  projection and image files. Uses platform-independent wxWindows
+  so can run on UNIX and Windows platforms.
 
 - Added frequency-based filtering. Can provide significant speed-up
   in reconstructions compared to convolution-based filtering.
diff --git a/README b/README
index e552c45d84a42ccd556874c648be8d8fb99e8b24..43e859f8aa6a3248775d7c589a98ba039de5eb16 100644 (file)
--- a/README
+++ b/README
@@ -52,6 +52,9 @@ image data.
 THE PROGRAMS
 ============
 
+ctsim - a graphical user interface for all functions. Currently, this is
+still under development and incomplete compared to command-line tools.
+
 phm2if - generates an image file of a phantom object
 
 phm2pj - Simulates the collection of CT data, or projections, of a phantom
@@ -71,6 +74,14 @@ ifinfo - Show statistics and history labels of SDF files
 TYPICAL USAGE
 =============
 
+Graphical User Interface
+------------------------
+
+Use ctsim, but most functions are not yet incorporated.
+
+Command Line Interface
+----------------------
+
 When evaluating CT simulation, in general, these steps are followed:
 
 Create a phantom image and viewable image file
index a445002ce71e05d3883cd8908709849b9d30ce74..806487ccee5cd9f031f4fc8224debe24e31eee20 100755 (executable)
--- a/configure
+++ b/configure
@@ -4268,7 +4268,7 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile doc/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -4398,7 +4398,7 @@ EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile doc/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
index 42d68276848eb5cf1c8b0bb91a96f637f71d7abb..c8bc7f463d64459050d00682676f5912fe3f48f2 100644 (file)
@@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
 AC_INIT(src/ctsim.cpp)
-AM_INIT_AUTOMAKE(ctsim,2.0.0-b4)
+AM_INIT_AUTOMAKE(ctsim,2.0.0-b5)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
@@ -339,4 +339,4 @@ fi
 
 CXXFLAGS="$CFLAGS"
 
-AC_OUTPUT(Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile)
+AC_OUTPUT(Makefile libctgraphics/Makefile libctsupport/Makefile libctsim/Makefile Makefile man/Makefile doc/Makefile cgi-bin/ctsim.cgi cgi-bin/Makefile html/simulate.html html/Makefile include/Makefile getopt/Makefile tools/sample-ctsim.sh cgi-bin/ctsim.conf tools/Makefile src/Makefile)
index ad8b0f8c8bc81dcff9c5128dc0f5d7c16e56afc3..489c4eee98a6812c8da1f774d7f2d52c14932d00 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phantom.h,v 1.6 2000/07/15 08:36:13 kevin Exp $
+**  $Id: phantom.h,v 1.7 2000/07/18 03:14: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
@@ -56,7 +56,7 @@ class PhantomElement
 
     ~PhantomElement (void);
 
-    bool isPointInside (double x, double y, const CoordType coord_type);
+    bool isPointInside (double x, double y, const CoordType coord_type) const;
 
     bool clipLineNormalizedCoords (double& x1, double& y1, double& x2, double& y2) const;
  
index 7acfc3fc9ccba40168f889867ed5b404b04bd299..d07b6a32eae0035242d8c467b5838a55e066655f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: phantom.cpp,v 1.7 2000/07/15 08:36:13 kevin Exp $
+**  $Id: phantom.cpp,v 1.8 2000/07/18 03:14: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
@@ -451,19 +451,24 @@ Phantom::convertToImagefile (ImageFile& im, const int in_nsample, const int trac
 
   ImageFileArray v = im.getArray();
 
+  for (int ix = 0; ix < colCount; ix++)
+      for (int iy = 0; iy < ny; iy++)
+         v[ix][iy] = 0;
+
   double x_start = xmin + (colStart * xinc);
   for (PElemConstIterator pelem = m_listPElem.begin(); pelem != m_listPElem.end(); pelem++) {
-    double x, y, xi, yi;
-    int ix, iy, kx, ky;
-    for (ix = 0, x = x_start; ix < colCount; ix++, x += xinc) {
-      for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) {
-       for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) {
-         for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc)
-           if ((*pelem)->isPointInside (xi, yi, PHM_COORD) == TRUE)
-             v[ix][iy] += (*pelem)->atten();
-       } // for kx
-      } /* for iy */
-    }  /* for ix */
+      const PhantomElement& rPElem = **pelem;
+      double x, y, xi, yi;
+      int ix, iy, kx, ky;
+      for (ix = 0, x = x_start; ix < colCount; ix++, x += xinc) {
+         for (iy = 0, y = ymin; iy < ny; iy++, y += yinc) {
+             for (kx = 0, xi = x + kxofs; kx < nsample; kx++, xi += kxinc) {
+                 for (ky = 0, yi = y + kyofs; ky < nsample; ky++, yi += kyinc)
+                     if (rPElem.isPointInside (xi, yi, PHM_COORD) == TRUE)
+                         v[ix][iy] += rPElem.atten();
+             } // for kx
+         } /* for iy */
+      }  /* for ix */
   }  /* for pelem */
   
 
@@ -822,7 +827,7 @@ PhantomElement::clipLineNormalizedCoords (double& x1, double& y1, double& x2, do
 //    false if point lies outside of pelem
 
 bool
-PhantomElement::isPointInside (double x, double y, const CoordType coord_type)
+PhantomElement::isPointInside (double x, double y, const CoordType coord_type) const
 {
   if (coord_type == PHM_COORD) {
     xform_mtx2 (m_xformPhmToObj, x, y);
index 4e820088a14fc2af9fda45158d5dbdfa2144118e..71303775f15a1a18e6cb11839814320b383b2639 100644 (file)
@@ -1,6 +1,6 @@
 bin_PROGRAMS=ctsim
 
-ctsim_SOURCES=ctsim.cpp docs.cpp views.cpp ctsim.h docs.h views.h
+ctsim_SOURCES=ctsim.cpp docs.cpp views.cpp dialogs.cpp ctsim.h docs.h views.h dialogs.h
 ctsim_DEPENDENCIES=../libctgraphics/libctgraphics.a ../libctsupport/libctsupport.a ../libctsim/libctsim.a ../include/ct.h
 ctsim_LDADD=-L../libctgraphics -L../libctsupport -L../libctsim @wxlibs@
 
index bbba38edd0e446b82fc219b3df303d98517c67e4..c240096c80db8082419bcbc5c53cd32e19ba4d95 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsim.h,v 1.2 2000/07/15 08:36:13 kevin Exp $
+**  $Id: ctsim.h,v 1.3 2000/07/18 03:14: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
@@ -93,6 +93,7 @@ enum {
     PHMMENU_FILE_PROPERTIES,
     PJMENU_PROCESS_RECONSTRUCT,
     IFMENU_VIEW_WINDOW_AUTO,
+    IFMENU_VIEW_WINDOW_MINMAX,
     PHMMENU_PROCESS_RASTERIZE,
     PHMMENU_PROCESS_PROJECTIONS,
 };
diff --git a/src/dialogs.cpp b/src/dialogs.cpp
new file mode 100644 (file)
index 0000000..4c8d967
--- /dev/null
@@ -0,0 +1,122 @@
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          dialogs.cpp
+**   Purpose:       Dialog routines for CTSim program
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  July 2000
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: dialogs.cpp,v 1.1 2000/07/18 03:14: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
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+#ifdef __GNUG__
+// #pragma implementation
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#if !wxUSE_DOC_VIEW_ARCHITECTURE
+#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
+#endif
+
+#include "wx/statline.h"
+#include "wx/sizer.h"
+#include "dialogs.h"
+#include <sstream>
+
+DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.)
+    : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCAPTION), m_pTopSizer(NULL), m_pTextCtrlMin(NULL), m_pTextCtrlMax(NULL), m_pButtonSizer(NULL), m_pButtonOk(NULL), m_pButtonCancel(NULL), m_dDefaultMin(dDefaultMin), m_dDefaultMax(dDefaultMax)
+{
+  wxBoxSizer* m_pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+  m_pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
+                  
+  ostringstream os;
+  os << dDefaultMin;
+  m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+  ostringstream osMax;
+  osMax << dDefaultMax;
+  m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+
+  wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5);
+  pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
+  m_pTopSizer->Add (pGridSizer, 1, wxALL, 10);
+
+  m_pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+
+  m_pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
+  m_pButtonOk = new wxButton (this, wxID_OK, "Okay");
+  m_pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
+  m_pButtonSizer->Add (m_pButtonOk, 0, wxEXPAND | wxALL, 10);
+  m_pButtonSizer->Add (m_pButtonCancel, 0, wxEXPAND | wxALL, 10);
+
+  m_pTopSizer->Add (m_pButtonSizer, 0, wxALIGN_CENTER);
+
+  SetAutoLayout (true);
+  SetSizer (m_pTopSizer);
+  m_pTopSizer->Fit (this);
+  m_pTopSizer->SetSizeHints (this);
+}
+
+DialogGetImageMinMax::~DialogGetImageMinMax (void)
+{
+#if 0
+  delete m_pTopSizer;
+  delete m_pTextCtrlMin;
+  delete m_pTextCtrlMax;
+  delete m_pButtonSizer;
+  delete m_pButtonOk;
+  delete m_pButtonCancel;
+#endif
+}
+
+double
+DialogGetImageMinMax::getMinimum (void)
+{
+    wxString strCtrl = m_pTextCtrlMin->GetValue();
+    double dValue;
+    if (strCtrl.ToDouble (&dValue))
+       return dValue;
+    else
+       return (m_dDefaultMin);
+}
+
+double
+DialogGetImageMinMax::getMaximum (void)
+{
+    wxString strCtrl = m_pTextCtrlMax->GetValue();
+    double dValue;
+    if (strCtrl.ToDouble (&dValue))
+       return dValue;
+    else
+       return (m_dDefaultMax);
+}
+
diff --git a/src/dialogs.h b/src/dialogs.h
new file mode 100644 (file)
index 0000000..03582ac
--- /dev/null
@@ -0,0 +1,57 @@
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          dialogs.h
+**   Purpose:       Header file for Dialogs of CTSim program
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  July 2000
+**
+**  This is part of the CTSim program
+**  Copyright (C) 1983-2000 Kevin Rosenberg
+**
+**  $Id: dialogs.h,v 1.1 2000/07/18 03:14: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
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+
+#ifndef __DIALOGSH__
+#define __DIALOGSH__
+
+#include "wx/wx.h"
+
+class ImageFile;
+class DialogGetImageMinMax : public wxDialog
+{
+ public:
+    DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.);
+    ~DialogGetImageMinMax (void);
+
+    double getMinimum (void);
+    double getMaximum (void);
+
+ private:
+    wxBoxSizer* m_pTopSizer;
+    wxTextCtrl* m_pTextCtrlMin;
+    wxTextCtrl* m_pTextCtrlMax;
+    wxBoxSizer* m_pButtonSizer;
+    wxButton* m_pButtonOk;
+    wxButton* m_pButtonCancel;
+
+    double m_dDefaultMin;
+    double m_dDefaultMax;
+};
+
+#endif
+
index 21fc80a15b5a19370761d784b3c63313d7fcad93..66770686c5010bd830ae0eb371ba50888b7dd281 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.2 2000/07/15 08:36:13 kevin Exp $
+**  $Id: views.cpp,v 1.3 2000/07/18 03:14: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
@@ -50,8 +50,8 @@
 #include "ctsim.h"
 #include "docs.h"
 #include "views.h"
+#include "dialogs.h"
 #include <sstream>
-#include "ct.h"
 
 // ImageFileCanvas
 
@@ -106,8 +106,9 @@ ImageFileCanvas::OnMouseEvent(wxMouseEvent& event)
 IMPLEMENT_DYNAMIC_CLASS(ImageFileView, wxView)
 
 BEGIN_EVENT_TABLE(ImageFileView, wxView)
-    EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
-    EVT_MENU(IFMENU_VIEW_WINDOW_AUTO, ImageFileView::OnWindowAuto)
+  EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
+  EVT_MENU(IFMENU_VIEW_WINDOW_MINMAX, ImageFileView::OnWindowMinMax)
+  EVT_MENU(IFMENU_VIEW_WINDOW_AUTO, ImageFileView::OnWindowAuto)
 END_EVENT_TABLE()
 
 ImageFileView::ImageFileView(void) 
@@ -130,7 +131,7 @@ ImageFileView::OnProperties (wxCommandEvent& event)
     const string& rFilename = rIF.getFilename();
     rIF.statistics (min, max, mean, mode, median, stddev);
     ostringstream os;
-    os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmode: "<<mode<<"\nstddev: "<<stddev;
+    os << "file: " << rFilename << "\nmin: "<<min<<"\nmax: "<<max<<"\nmean: "<<mean<<"\nmode: "<<mode<<"\nstddev: "<<stddev << "\n";
     *theApp->getLog() << os.str().c_str();
   }
 }
@@ -139,11 +140,30 @@ void
 ImageFileView::OnWindowAuto (wxCommandEvent& event)
 {
     *theApp->getLog() << "ImageFile: Window Auto\n";
-    m_minPixel = .2;
-    m_maxPixel = .22;
-    m_bMinSpecified = true;
-    m_bMaxSpecified = true;
-    OnUpdate(this, NULL);
+}
+
+void 
+ImageFileView::OnWindowMinMax (wxCommandEvent& event)
+{
+    const ImageFile& rIF = GetDocument()->getImageFile();
+    double min, max;
+    if (! m_bMinSpecified && ! m_bMaxSpecified)
+      rIF.getMinMax (min, max);
+
+    if (m_bMinSpecified)
+      min = m_dMinPixel;
+    if (m_bMaxSpecified)
+      max = m_dMaxPixel;
+
+    DialogGetImageMinMax dialogMinMax (m_frame, rIF, min, max);
+    int retVal = dialogMinMax.ShowModal();
+    if (retVal == wxID_OK) {
+      m_bMinSpecified = true;
+      m_bMaxSpecified = true;
+      m_dMinPixel = dialogMinMax.getMinimum();
+      m_dMaxPixel = dialogMinMax.getMaximum();
+      OnUpdate (this, NULL);
+    }
 }
 
 
@@ -185,6 +205,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
     
     wxMenu *view_menu = new wxMenu;
     view_menu->Append(IFMENU_VIEW_WINDOW_AUTO, "&Window auto");
+    view_menu->Append(IFMENU_VIEW_WINDOW_MINMAX, "&Set Window Min/Max");
     
     wxMenu *help_menu = new wxMenu;
     help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
@@ -248,16 +269,16 @@ ImageFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
            double min, max;
            rIF.getMinMax (min, max);
            if (! m_bMinSpecified)
-               m_minPixel = min;
+               m_dMinPixel = min;
            if (! m_bMaxSpecified)
-               m_maxPixel = max;
+               m_dMaxPixel = max;
        }
-       double scaleWidth = m_maxPixel - m_minPixel;
+       double scaleWidth = m_dMaxPixel - m_dMinPixel;
     
        unsigned char imageData [nx * ny * 3];
        for (int ix = 0; ix < nx; ix++) {
            for (int iy = 0; iy < ny; iy++) {
-               double scaleValue = ((v[ix][iy] - m_minPixel) / scaleWidth) * 255;
+               double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255;
                int intensity = static_cast<int>(scaleValue + 0.5);
                intensity = clamp (intensity, 0, 255);
                int baseAddr = ((ny - 1 - iy) * nx + ix) * 3;
@@ -268,20 +289,8 @@ ImageFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
        m_bitmap = image.ConvertToBitmap();
     } 
 
-    if (m_canvas) {
+    if (m_canvas)
        m_canvas->Refresh();
-    }
-
-#ifdef __WXMSW__
-  if (m_canvas)
-    m_canvas->Refresh();
-#else
-  if (m_canvas) {
-    wxClientDC dc(m_canvas);
-    dc.Clear();
-    OnDraw (&dc);
-  }
-#endif
 }
 
 bool 
@@ -351,8 +360,8 @@ PhantomView::OnProperties (wxCommandEvent& event)
   ostringstream os;
   os << "Phantom " << namePhantom << " (" << static_cast<int>(idPhantom) << ")\n";
   *theApp->getLog() << os.str().c_str();
-  const Phantom& rPhantom = GetDocument()->getPhantom();
 #if DEBUG
+  const Phantom& rPhantom = GetDocument()->getPhantom();
   rPhantom.print();
 #endif
 }
@@ -361,6 +370,14 @@ PhantomView::OnProperties (wxCommandEvent& event)
 void
 PhantomView::OnProjections (wxCommandEvent& event)
 {
+  const Phantom& rPhantom = GetDocument()->getPhantom();
+  ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));
+  Projections& rProj = pProjectionDoc->getProjections();
+  Scanner theScanner (rPhantom, "parallel", 367, 320, 2, PI);
+  rProj.initFromScanner (theScanner);
+  theScanner.collectProjections (rProj, rPhantom, 0, TRACE_NONE);
+  pProjectionDoc->Modify(true);
+  pProjectionDoc->UpdateAllViews(this);
 }
 
 
@@ -371,7 +388,6 @@ PhantomView::OnRasterize (wxCommandEvent& event)
   ImageFileDocument* pRasterDoc = dynamic_cast<ImageFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT));
   ImageFile& imageFile = pRasterDoc->getImageFile();
   imageFile.setArraySize (256, 256);
-  imageFile.arrayDataClear();
   rPhantom.convertToImagefile (imageFile, 1, TRACE_NONE);
   pRasterDoc->Modify(true);
   pRasterDoc->UpdateAllViews(this);
@@ -467,20 +483,8 @@ PhantomView::OnDraw (wxDC* dc)
 void 
 PhantomView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
 {
-    if (m_canvas) {
+    if (m_canvas)
        m_canvas->Refresh();
-    }
-
-#ifdef __WXMSW__
-  if (m_canvas)
-    m_canvas->Refresh();
-#else
-  if (m_canvas) {
-    wxClientDC dc(m_canvas);
-    dc.Clear();
-    OnDraw (&dc);
-  }
-#endif
 }
 
 bool 
@@ -662,50 +666,40 @@ ProjectionFileView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)
     const Projections& rProj = GetDocument()->getProjections();
     const int nDet = rProj.nDet();
     const int nView = rProj.nView();
-    const DetectorArray& detarray = rProj.getDetectorArray(0);
-    const DetectorValue* detval = detarray.detValues();
-    double min = detval[0];
-    double max = detval[0];
-    for (int iy = 0; iy < nView; iy++) {
-      const DetectorArray& detarray = rProj.getDetectorArray(iy);
-      const DetectorValue* detval = detarray.detValues();
-      for (int ix = 0; ix < nDet; ix++) {
-       if (min > detval[ix])
-         min = detval[ix];
-       else if (max < detval[ix])
-         max = detval[ix];
-      }
-    }
+    if (nDet != 0 && nView != 0) {
+       const DetectorArray& detarray = rProj.getDetectorArray(0);
+       const DetectorValue* detval = detarray.detValues();
+       double min = detval[0];
+       double max = detval[0];
+       for (int iy = 0; iy < nView; iy++) {
+           const DetectorArray& detarray = rProj.getDetectorArray(iy);
+           const DetectorValue* detval = detarray.detValues();
+           for (int ix = 0; ix < nDet; ix++) {
+               if (min > detval[ix])
+                   min = detval[ix];
+               else if (max < detval[ix])
+                   max = detval[ix];
+           }
+       }
 
-    unsigned char imageData [nDet * nView * 3];
-    double scale = (max - min) / 255;
-    for (int iy = 0; iy < nView; iy++) {
-      const DetectorArray& detarray = rProj.getDetectorArray(iy);
-      const DetectorValue* detval = detarray.detValues();
-      for (int ix = 0; ix < nDet; ix++) {
-       int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
-       intensity = clamp(intensity, 0, 255);
-       int baseAddr = (iy * nDet + ix) * 3;
-       imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
-      }
-    }
-    wxImage image (nDet, nView, imageData, true);
-    m_bitmap = image.ConvertToBitmap();
-    
-    if (m_canvas) {
-       m_canvas->Refresh();
+       unsigned char imageData [nDet * nView * 3];
+       double scale = (max - min) / 255;
+       for (int iy = 0; iy < nView; iy++) {
+           const DetectorArray& detarray = rProj.getDetectorArray(iy);
+           const DetectorValue* detval = detarray.detValues();
+           for (int ix = 0; ix < nDet; ix++) {
+               int intensity = static_cast<int>(((detval[ix] - min) / scale) + 0.5);
+               intensity = clamp(intensity, 0, 255);
+               int baseAddr = (iy * nDet + ix) * 3;
+               imageData[baseAddr] = imageData[baseAddr+1] = imageData[baseAddr+2] = intensity;
+           }
+       }
+       wxImage image (nDet, nView, imageData, true);
+       m_bitmap = image.ConvertToBitmap();
     }
 
-#ifdef __WXMSW__
-  if (m_canvas)
-    m_canvas->Refresh();
-#else
-  if (m_canvas) {
-    wxClientDC dc(m_canvas);
-    dc.Clear();
-    OnDraw (&dc);
-  }
-#endif
+    if (m_canvas)
+       m_canvas->Refresh();
 }
 
 bool 
index ee3fdda86342e36807de290c4b4077a34516a61c..96de20e311782c07788cb5272bd78c43bcfbaba4 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.h,v 1.2 2000/07/15 08:36:13 kevin Exp $
+**  $Id: views.h,v 1.3 2000/07/18 03:14: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
@@ -52,8 +52,8 @@ private:
     wxFrame *m_frame;
     bool m_bMinSpecified;
     bool m_bMaxSpecified;
-    double m_minPixel;
-    double m_maxPixel;
+    double m_dMinPixel;
+    double m_dMaxPixel;
 
 public:
     ImageFileView(void);
@@ -65,6 +65,7 @@ public:
     bool OnClose (bool deleteWindow = true);
     void OnProperties (wxCommandEvent& event);
     void OnWindowAuto (wxCommandEvent& event);
+    void OnWindowMinMax (wxCommandEvent& event);
 
     ImageFileDocument* GetDocument(void) 
        { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }