From: Kevin M. Rosenberg Date: Tue, 18 Jul 2000 03:14:35 +0000 (+0000) Subject: r150: *** empty log message *** X-Git-Tag: debian-4.5.3-3~867 X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=commitdiff_plain;h=4b18b0a7fed4e25130c6edf7929d0df50b8c24ea r150: *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index b6451cb..ddf2ee5 100644 --- 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 4b46c75..ad46616 100644 --- 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. diff --git a/Makefile.am b/Makefile.am index c1c153a..682436f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 c6a1599..5048b79 100644 --- 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 e552c45..43e859f 100644 --- 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 diff --git a/configure b/configure index a445002..806487c 100755 --- 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 <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/configure.in b/configure.in index 42d6827..c8bc7f4 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/include/phantom.h b/include/phantom.h index ad8b0f8..489c4ee 100644 --- a/include/phantom.h +++ b/include/phantom.h @@ -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; diff --git a/libctsim/phantom.cpp b/libctsim/phantom.cpp index 7acfc3f..d07b6a3 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.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); diff --git a/src/Makefile.am b/src/Makefile.am index 4e82008..7130377 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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@ diff --git a/src/ctsim.h b/src/ctsim.h index bbba38e..c240096 100644 --- a/src/ctsim.h +++ b/src/ctsim.h @@ -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 index 0000000..4c8d967 --- /dev/null +++ b/src/dialogs.cpp @@ -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 + +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 index 0000000..03582ac --- /dev/null +++ b/src/dialogs.h @@ -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 + diff --git a/src/views.cpp b/src/views.cpp index 21fc80a..6677068 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -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 -#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: "<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(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(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(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(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(((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(((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 diff --git a/src/views.h b/src/views.h index ee3fdda..96de20e 100644 --- a/src/views.h +++ b/src/views.h @@ -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(wxView::GetDocument()); }