From e081109a4a541c8780aaa253b874acada5957200 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 22 Feb 2001 15:00:20 +0000 Subject: [PATCH] r572: no message --- msvc/ctsim/ctsim.plg | 83 ++++++++++-- src/backgroundmgr.cpp | 119 +++++++++++++++++ src/backgroundmgr.h | 95 +++++++++++++ src/ctsim.cpp | 14 +- src/ctsim.h | 12 +- src/dialogs.cpp | 14 +- src/dialogs.h | 6 +- src/threadrecon.cpp | 35 ++--- src/threadrecon.h | 20 ++- src/views.cpp | 304 +++++++++++++++--------------------------- 10 files changed, 465 insertions(+), 237 deletions(-) create mode 100644 src/backgroundmgr.cpp create mode 100644 src/backgroundmgr.h diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index 6fdda36..05c2239 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -3,10 +3,65 @@
 

Build Log

+--------------------Configuration: libctsim - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75C.tmp" with contents +[ +/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "..\..\..\wx2.2.5\src\png" /I "..\..\..\wx2.2.5\src\zlib" /I "..\..\INCLUDE" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /I "..\..\..\wx2.2.5\include" /D "_DEBUG" /D "HAVE_WXWIN" /D "HAVE_STRING_H" /D "HAVE_GETOPT_H" /D "WIN32" /D "_MBCS" /D "_LIB" /D "MSVC" /D "HAVE_FFTW" /D "HAVE_PNG" /D "HAVE_SGP" /D "HAVE_WXWINDOWS" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /FR"Debug/" /Fp"Debug/libctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\libctgraphics\dlgezplot.cpp" +"C:\ctsim\libctsim\globalvars.cpp" +"C:\ctsim\libctsupport\syserror.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75C.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75D.tmp" with contents +[ +/nologo /out:"Debug\libctsim.lib" +.\Debug\array2dfile.obj +.\Debug\backprojectors.obj +.\Debug\clip.obj +.\Debug\consoleio.obj +.\Debug\dlgezplot.obj +.\Debug\ezplot.obj +.\Debug\ezset.obj +.\Debug\ezsupport.obj +.\Debug\filter.obj +.\Debug\fnetorderstream.obj +.\Debug\fourier.obj +.\Debug\getopt.obj +.\Debug\getopt1.obj +.\Debug\globalvars.obj +.\Debug\hashtable.obj +.\Debug\imagefile.obj +.\Debug\interpolator.obj +.\Debug\mathfuncs.obj +.\Debug\phantom.obj +.\Debug\plotfile.obj +.\Debug\pol.obj +.\Debug\procsignal.obj +.\Debug\projections.obj +.\Debug\reconstruct.obj +.\Debug\scanner.obj +.\Debug\sgp.obj +.\Debug\strfuncs.obj +.\Debug\syserror.obj +.\Debug\trace.obj +.\Debug\transformmatrix.obj +.\Debug\xform.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75D.tmp" +

Output Window

+Compiling... +dlgezplot.cpp +Skipping... (no relevant changes detected) +globalvars.cpp +syserror.cpp +Creating library... +

--------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E6.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75E.tmp" with contents [ /nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /D CTSIMVERSION=\"3.0.0alpha5\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c "C:\ctsim\src\ctsim.cpp" @@ -14,15 +69,14 @@ Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E6.tmp" with conten "C:\ctsim\src\docs.cpp" "C:\ctsim\src\views.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E6.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E7.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75E.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75F.tmp" with contents [ /nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c "C:\ctsim\src\graph3dview.cpp" -"C:\ctsim\src\threadrecon.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E7.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E8.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP75F.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP760.tmp" with contents [ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib htmlhelp.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" .\Debug\ctsim.obj @@ -35,6 +89,7 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. .\Debug\ctsim.res .\Debug\tips.obj .\Debug\threadrecon.obj +.\Debug\backgroundmgr.obj \ctsim\msvc\libctsim\Debug\libctsim.lib "\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib" "\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib" @@ -45,19 +100,25 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. \wx2.2.5\lib\zlibd.lib \wx2.2.5\lib\tiffd.lib ] -Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP3E8.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP760.tmp"

Output Window

Compiling... ctsim.cpp -docs.cpp -Skipping... (no relevant changes detected) dialogs.cpp +docs.cpp views.cpp Compiling... -threadrecon.cpp -Skipping... (no relevant changes detected) graph3dview.cpp Linking... +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP763.tmp" with contents +[ +/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\src\backgroundmgr.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP763.tmp" +

Output Window

+Compiling... +backgroundmgr.cpp diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp new file mode 100644 index 0000000..12d337d --- /dev/null +++ b/src/backgroundmgr.cpp @@ -0,0 +1,119 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: backgroundmgr.cpp +** Purpose: Background manager class +** Programmer: Kevin Rosenberg +** Date Started: February 2001 +** +** This is part of the CTSim program +** Copyright (C) 1983-2001 Kevin Rosenberg +** +** $Id: backgroundmgr.cpp,v 1.1 2001/02/22 15:00:20 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 +******************************************************************************/ + +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include "ct.h" +#include "ctsim.h" +#include "docs.h" +#include "views.h" +#include "threadrecon.h" +#include "backgroundmgr.h" + + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + + +IMPLEMENT_DYNAMIC_CLASS(BackgroundManager, wxMiniFrame) +BEGIN_EVENT_TABLE(BackgroundManager, wxMiniFrame) +EVT_CLOSE(BackgroundManager::OnCloseWindow) +END_EVENT_TABLE() + +BackgroundManager::BackgroundManager () + : wxMiniFrame (theApp->getMainFrame(), -1, _T("Background Tasks"), wxPoint(0,0), wxSize(200, 100)) //, wxTHICK_FRAME) +{ + m_iNumTasks = 0; + m_pCanvas = new BackgroundManagerCanvas (this); + theApp->setIconForFrame (this); + + Show(true); + // if (m_iNumTasks == 0) + // Show(false); +} + + +void +BackgroundManager::OnCloseWindow (wxCloseEvent& event) +{ + if (theApp->getMainFrame()->getShuttingDown()) + wxMiniFrame::OnCloseWindow (event); + else + event.Veto(); +} + + +wxGauge* +BackgroundManager::addTask (BackgroundTask* pTask, int iNumUnits) +{ + wxSize size (50, 10); + wxPoint pos (4, 5); + + wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, pos, size); + m_vecpBackgroundTasks.push_back (pTask); + m_iNumTasks++; + return (pGauge); +} + + +void +BackgroundManager::taskDone (BackgroundTask* pTask) +{ + m_iNumTasks--; +} + +bool +BackgroundManager::isCancelling (BackgroundTask* pTask) +{ + return false; +} + + + +IMPLEMENT_DYNAMIC_CLASS(BackgroundManagerCanvas, wxPanel) +BEGIN_EVENT_TABLE(BackgroundManagerCanvas, wxPanel) +EVT_PAINT(BackgroundManagerCanvas::OnPaint) +END_EVENT_TABLE() + +BackgroundManagerCanvas::BackgroundManagerCanvas (BackgroundManager* pMgr) +: m_pBackgroundManager(pMgr), wxPanel (pMgr) +{ +} + + +void +BackgroundManagerCanvas::OnPaint (wxPaintEvent& event) +{ + wxPaintDC dc (this); +// dc.DrawLine (0, 0, 30, 30); +// dc.DrawLine (30,0, 0, 30); +} diff --git a/src/backgroundmgr.h b/src/backgroundmgr.h new file mode 100644 index 0000000..7e95fae --- /dev/null +++ b/src/backgroundmgr.h @@ -0,0 +1,95 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: backgroundmgr.h +** Purpose: Header file for background manager +** Programmer: Kevin Rosenberg +** Date Started: February 2001 +** +** This is part of the CTSim program +** Copyright (C) 1983-2001 Kevin Rosenberg +** +** $Id: backgroundmgr.h,v 1.1 2001/02/22 15:00:20 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 _BACKGROUND_MGR_H + + +#include "wx/wxprec.h" + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include "wx/minifram.h" +#include "wx/gauge.h" + +#include "ct.h" +#include "ctsim.h" +#include "docs.h" +#include "views.h" +#include "threadrecon.h" + +#include + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +class BackgroundManagerCanvas; + +#if CTSIM_MDI +//class BackgroundManager : public wxMDIChildFrame +//#else +class BackgroundManager : public wxMiniFrame +#endif +{ +private: + DECLARE_DYNAMIC_CLASS(BackgroundManager) + + BackgroundManagerCanvas* m_pCanvas; + int m_iNumTasks; + std::vector m_vecpBackgroundTasks; + std::vector m_vecpGauges; + + void OnCloseWindow(wxCloseEvent& event); + +public: + BackgroundManager (); + + wxGauge* addTask (BackgroundTask* pTask, int iNumUnits); + void taskDone (BackgroundTask* pTask); + bool isCancelling (BackgroundTask* pTask); + + DECLARE_EVENT_TABLE() +}; + + +class BackgroundManagerCanvas : public wxPanel { +private: + DECLARE_DYNAMIC_CLASS(BackgroundManagerCanvas) + BackgroundManager* m_pBackgroundManager; + +public: + BackgroundManagerCanvas (BackgroundManager* pBkgdMgr = NULL); + + void OnPaint (wxPaintEvent& event); + + DECLARE_EVENT_TABLE() +}; + + +#endif // _BACKGROUNDMGR_H + diff --git a/src/ctsim.cpp b/src/ctsim.cpp index 1155aac..c1283c0 100644 --- a/src/ctsim.cpp +++ b/src/ctsim.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: ctsim.cpp,v 1.87 2001/02/22 11:05:38 kevin Exp $ +** $Id: ctsim.cpp,v 1.88 2001/02/22 15:00:20 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 @@ -53,6 +53,7 @@ #include "views.h" #include "dialogs.h" #include "tips.h" +#include "backgroundmgr.h" #if defined(HAVE_CONFIG_H) #include "config.h" @@ -68,7 +69,7 @@ #endif #endif -static const char* rcsindent = "$Id: ctsim.cpp,v 1.87 2001/02/22 11:05:38 kevin Exp $"; +static const char* rcsindent = "$Id: ctsim.cpp,v 1.88 2001/02/22 15:00:20 kevin Exp $"; struct option CTSimApp::ctsimOptions[] = { @@ -82,7 +83,7 @@ IMPLEMENT_APP(CTSimApp) CTSimApp::CTSimApp() : m_bAdvancedOptions(false), m_bSetModifyNewDocs(true), m_bVerboseLogging(false), m_bShowStartupTips(true), - m_iCurrentTip(0), + m_iCurrentTip(0), m_bUseBackgroundTasks(false), m_docManager(NULL), m_pFrame(NULL), m_pLog(0), m_pLogDoc(0), m_pConfig(0) { theApp = this; @@ -228,6 +229,7 @@ CTSimApp::OnInit() if (getStartupTips()) ShowTips(); + m_pBackgroundMgr = new BackgroundManager; return true; } @@ -286,6 +288,7 @@ CTSimApp::openConfig() m_pConfig->Read ("VerboseLogging", &m_bVerboseLogging); m_pConfig->Read ("StartupTips", &m_bShowStartupTips); m_pConfig->Read ("CurrentTip", &m_iCurrentTip); + m_pConfig->Read ("UseBackgroundTasks", &m_bUseBackgroundTasks); } void @@ -296,6 +299,7 @@ CTSimApp::closeConfig() m_pConfig->Write ("VerboseLogging", m_bVerboseLogging); m_pConfig->Write ("StartupTips", m_bShowStartupTips); m_pConfig->Write ("CurrentTip", m_iCurrentTip); + m_pConfig->Write ("UseBackgroundTasks", m_bUseBackgroundTasks); delete m_pConfig; } @@ -854,12 +858,14 @@ void MainFrame::OnPreferences (wxCommandEvent& WXUNUSED(event) ) { DialogPreferences dlg (this, "CTSim Preferences", theApp->getAdvancedOptions(), - theApp->getAskDeleteNewDocs(), theApp->getVerboseLogging(), theApp->getStartupTips()); + theApp->getAskDeleteNewDocs(), theApp->getVerboseLogging(), theApp->getStartupTips(), + theApp->getUseBackgroundTasks()); if (dlg.ShowModal() == wxID_OK) { theApp->setAdvancedOptions (dlg.getAdvancedOptions()); theApp->setAskDeleteNewDocs (dlg.getAskDeleteNewDocs()); theApp->setVerboseLogging (dlg.getVerboseLogging()); theApp->setStartupTips (dlg.getStartupTips()); + theApp->setUseBackgroundTasks (dlg.getUseBackgroundTasks()); } } diff --git a/src/ctsim.h b/src/ctsim.h index 9768970..a4049f1 100644 --- a/src/ctsim.h +++ b/src/ctsim.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: ctsim.h,v 1.51 2001/02/22 11:05:38 kevin Exp $ +** $Id: ctsim.h,v 1.52 2001/02/22 15:00:20 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 @@ -62,6 +62,8 @@ class ProjectionFileDocument; class PhantomFileDocument; class PlotFileDocument; class TextFileDocument; +class BackgroundManager; + #if wxUSE_GLCANVAS class Graph3dFileDocument; #endif @@ -115,7 +117,7 @@ private: wxCHMHelpController m_winHelp; #endif wxHtmlHelpController m_htmlHelp; - + public: MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type); virtual ~MainFrame(); @@ -191,6 +193,7 @@ private: bool m_bVerboseLogging; bool m_bShowStartupTips; long m_iCurrentTip; + bool m_bUseBackgroundTasks; wxDocManager* m_docManager; MainFrame* m_pFrame; @@ -210,6 +213,7 @@ private: void usage (const char* program); void openConfig(); void closeConfig(); + BackgroundManager* m_pBackgroundMgr; public: CTSimApp(); @@ -238,6 +242,10 @@ public: void setVerboseLogging (bool bVerbose) { m_bVerboseLogging = bVerbose; } bool getStartupTips() const { return m_bShowStartupTips; } void setStartupTips(bool bTips) { m_bShowStartupTips = bTips; } + bool getUseBackgroundTasks() const { return m_bUseBackgroundTasks; } + void setUseBackgroundTasks(bool bBkgd) { m_bUseBackgroundTasks = bBkgd; } + + BackgroundManager* getBackgroundManager() {return m_pBackgroundMgr;} void ShowTips(); diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 8e25338..21b6f19 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: dialogs.cpp,v 1.40 2001/02/22 11:05:38 kevin Exp $ +** $Id: dialogs.cpp,v 1.41 2001/02/22 15:00:20 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 @@ -217,7 +217,7 @@ DialogGetComparisonImage::getMakeDifferenceImage() ///////////////////////////////////////////////////////////////////// DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTitle, - bool bAdvancedOptions, bool bAskDeleteNewDocs, bool bVerboseLogging, bool bStartupTips) + bool bAdvancedOptions, bool bAskDeleteNewDocs, bool bVerboseLogging, bool bStartupTips, bool bUseBackgroundTasks) : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); @@ -242,6 +242,10 @@ DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTi m_pCBStartupTips->SetValue (bStartupTips); pTopSizer->Add (m_pCBStartupTips, 0, wxALIGN_CENTER_VERTICAL); + m_pCBUseBackgroundTasks = new wxCheckBox (this, -1, "Put Tasks in Background", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBUseBackgroundTasks->SetValue (bStartupTips); + pTopSizer->Add (m_pCBUseBackgroundTasks, 0, wxALIGN_CENTER_VERTICAL); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); @@ -289,6 +293,12 @@ DialogPreferences::getStartupTips () return static_cast(m_pCBStartupTips->GetValue()); } +bool +DialogPreferences::getUseBackgroundTasks () +{ + return static_cast(m_pCBUseBackgroundTasks->GetValue()); +} + ///////////////////////////////////////////////////////////////////// // CLASS DiaglogGetMinMax Implementation diff --git a/src/dialogs.h b/src/dialogs.h index 2497562..22eccf5 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: dialogs.h,v 1.29 2001/02/22 00:56:50 kevin Exp $ +** $Id: dialogs.h,v 1.30 2001/02/22 15:00:20 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 @@ -113,19 +113,21 @@ class DialogPreferences : public wxDialog { public: DialogPreferences (wxWindow* pParent, const char* const pszTitle, bool bAdvanced, bool bAskNewDocs, - bool bVerboseLogging, bool bStartupTips); + bool bVerboseLogging, bool bStartupTips, bool bUseBackgroundTasks); virtual ~DialogPreferences (); bool getAdvancedOptions (); bool getAskDeleteNewDocs (); bool getVerboseLogging (); bool getStartupTips (); + bool getUseBackgroundTasks(); private: wxCheckBox* m_pCBAdvancedOptions; wxCheckBox* m_pCBAskDeleteNewDocs; wxCheckBox* m_pCBVerboseLogging; wxCheckBox* m_pCBStartupTips; + wxCheckBox* m_pCBUseBackgroundTasks; }; diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index aa9a7bb..e43299a 100644 --- a/src/threadrecon.cpp +++ b/src/threadrecon.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadrecon.cpp,v 1.1 2001/02/22 11:05:38 kevin Exp $ +** $Id: threadrecon.cpp,v 1.2 2001/02/22 15:00:20 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 @@ -36,14 +36,15 @@ #include "docs.h" #include "views.h" #include "threadrecon.h" +#include "backgroundmgr.h" #if defined(HAVE_CONFIG_H) #include "config.h" #endif -IMPLEMENT_DYNAMIC_CLASS(ThreadedReconstructor, wxEvtHandler) -BEGIN_EVENT_TABLE(ThreadedReconstructor, wxEvtHandler) +IMPLEMENT_DYNAMIC_CLASS(ThreadedReconstructor, BackgroundTask) +BEGIN_EVENT_TABLE(ThreadedReconstructor, BackgroundTask) EVT_MENU(RECONSTRUCTION_THREAD_EVENT, ThreadedReconstructor::OnThreadEvent) END_EVENT_TABLE() @@ -58,9 +59,9 @@ ThreadedReconstructor::ThreadedReconstructor (ProjectionFileView* pProjView, int iImageNX, int iImageNY, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam, const char* pszBackprojectName, const char* const pszLabel) - : m_pProjView(pProjView), m_pDialogProgress(NULL), m_bFail(false), m_iNumThreads(0), m_iImageNX(iImageNX), + : m_pProjView(pProjView), m_pDialogProgress(NULL), m_pGauge(NULL), m_bFail(false), m_iNumThreads(0), m_iImageNX(iImageNX), m_iImageNY(iImageNY), m_strLabel(pszLabel), m_pTimer(NULL), m_bCancelled(false), m_bCancelling(false), - m_bDone(false), wxEvtHandler() + m_bDone(false), BackgroundTask() { m_iNumThreads = theApp->getNumberCPU(); // ++m_iNumThreads; @@ -89,8 +90,6 @@ ThreadedReconstructor::ThreadedReconstructor (ProjectionFileView* pProjView, } } - m_pProjView->GetDocument()->addReconstructor (this); - // m_pDialogProgress = new wxProgressDialog (_T("Filtered Backprojection"), _T("Reconstruction Progress"), m_iTotalViews, pProjView->getFrame(), wxPD_CAN_ABORT | wxPD_AUTO_HIDE); } @@ -100,14 +99,18 @@ ThreadedReconstructor::start() if (m_bFail) return false; - // starting all threads + m_pProjView->GetDocument()->addReconstructor (this); + if (! theApp->getUseBackgroundTasks()) + m_pDialogProgress = new wxProgressDialog (_T("Filtered Backprojection"), _T("Reconstruction Progress"), m_iTotalViews, m_pProjView->getFrame(), wxPD_CAN_ABORT | wxPD_AUTO_HIDE); + else + m_pGauge = theApp->getBackgroundManager()->addTask (this, m_iTotalViews); + m_iRunning = m_iNumThreads; m_iViewsDone = 0; m_pTimer = new Timer; -// theApp->addBackgroundTask (this, m_iTotalViews); - int i; - for (i = 0; i < m_iNumThreads; i++) + // starting all threads + for (int i = 0; i < m_iNumThreads; i++) m_vecpThread[i]->Run(); @@ -140,7 +143,7 @@ ThreadedReconstructor::cancel() m_pProjView->GetDocument()->removeReconstructor (this); m_bCancelled = true; m_bDone = true; - // theApp->removeBackgroundTask (this); + theApp->getBackgroundManager()->taskDone (this); } void @@ -174,7 +177,7 @@ ThreadedReconstructor::onDone() wxIdleEvent event; theApp->OnIdle(event); m_bDone = true; - // theApp->removeBackgroundTask (this); + theApp->getBackgroundManager()->taskDone (this); // delete this; } @@ -196,8 +199,10 @@ ThreadedReconstructor::OnThreadEvent (wxCommandEvent& event) if (m_pDialogProgress) m_bCancelling = ! m_pDialogProgress->Update (m_iViewsDone - 1); - - // m_bCancelling = theApp->updateBackgroundTask (this, m_iViewsDone); + else if (m_pGauge) { + m_pGauge->SetValue (m_iViewsDone - 1); + m_bCancelling = theApp->getBackgroundManager()->isCancelling(this); + } if (m_iViewsDone == m_iTotalViews) { delete m_pDialogProgress; m_pDialogProgress = NULL; diff --git a/src/threadrecon.h b/src/threadrecon.h index 53368fa..0cb8c9a 100644 --- a/src/threadrecon.h +++ b/src/threadrecon.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: threadrecon.h,v 1.1 2001/02/22 11:05:38 kevin Exp $ +** $Id: threadrecon.h,v 1.2 2001/02/22 15:00:20 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 @@ -34,13 +34,26 @@ #include "timer.h" +class BackgroundTask : public wxEvtHandler { +public: + BackgroundTask() + : wxEvtHandler() + {} + + virtual ~BackgroundTask() + {} + + virtual void cancel() = 0; + virtual bool start() = 0; +}; + class Reconstructor; class ImageFile; class ProjectionFileDocument; class ReconstructionThread; class ProjectionFileView; -class ThreadedReconstructor : public wxEvtHandler { +class ThreadedReconstructor : public BackgroundTask { private: DECLARE_DYNAMIC_CLASS(ThreadedReconstructor) @@ -49,6 +62,7 @@ private: std::vector m_vecpThread; ProjectionFileView* m_pProjView; wxProgressDialog* m_pDialogProgress; + wxGauge* m_pGauge; volatile bool m_bFail; int m_iNumThreads; @@ -71,7 +85,7 @@ public: const char* pszBackprojectName, const char* const pszLabel); ThreadedReconstructor () - : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0) + : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0), BackgroundTask() {} ~ThreadedReconstructor (); diff --git a/src/views.cpp b/src/views.cpp index 60eda6a..b8404bd 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.cpp,v 1.112 2001/02/22 11:05:38 kevin Exp $ +** $Id: views.cpp,v 1.113 2001/02/22 15:00:20 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 @@ -49,8 +49,6 @@ #include "timer.h" #include "threadrecon.h" -#define CTSIM_THREADS 1 - #if defined(MSVC) || HAVE_SSTREAM #include #else @@ -385,7 +383,7 @@ ImageFileView::OnCompare (wxCommandEvent& event) return; } pDifferenceDoc->setImageFile (pDifferenceImage); - + wxString s = GetFrame()->GetTitle() + ": "; pDifferenceImage->labelsCopy (rIF, s.c_str()); s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; @@ -413,7 +411,7 @@ ImageFileView::OnInvertValues (wxCommandEvent& event) rIF.invertPixelValues (rIF); rIF.labelAdd ("Invert Pixel Values"); if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -424,7 +422,7 @@ ImageFileView::OnSquare (wxCommandEvent& event) rIF.square (rIF); rIF.labelAdd ("Square Pixel Values"); if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -435,7 +433,7 @@ ImageFileView::OnSquareRoot (wxCommandEvent& event) rIF.sqrt (rIF); rIF.labelAdd ("Square-root Pixel Values"); if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -446,7 +444,7 @@ ImageFileView::OnLog (wxCommandEvent& event) rIF.log (rIF); rIF.labelAdd ("Logrithm base-e Pixel Values"); if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -457,7 +455,7 @@ ImageFileView::OnExp (wxCommandEvent& event) rIF.exp (rIF); rIF.labelAdd ("Exponent base-e Pixel Values"); if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -636,7 +634,7 @@ ImageFileView::OnFFT (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -649,7 +647,7 @@ ImageFileView::OnIFFT (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -662,7 +660,7 @@ ImageFileView::OnFFTRows (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -675,7 +673,7 @@ ImageFileView::OnIFFTRows (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -688,7 +686,7 @@ ImageFileView::OnFFTCols (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -701,7 +699,7 @@ ImageFileView::OnIFFTCols (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } #endif @@ -716,7 +714,7 @@ ImageFileView::OnFourier (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -730,7 +728,7 @@ ImageFileView::OnInverseFourier (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -743,7 +741,7 @@ ImageFileView::OnShuffleNaturalToFourierOrder (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -756,7 +754,7 @@ ImageFileView::OnShuffleFourierToNaturalOrder (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } @@ -770,7 +768,7 @@ ImageFileView::OnMagnitude (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } } @@ -785,7 +783,7 @@ ImageFileView::OnPhase (wxCommandEvent& event) m_bMinSpecified = false; m_bMaxSpecified = false; if (theApp->getAskDeleteNewDocs()) - GetDocument()->Modify (true); + GetDocument()->Modify (true); GetDocument()->UpdateAllViews (this); } } @@ -936,7 +934,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) #else wxAcceleratorTable accelTable (4, accelEntries); #endif - + subframe->SetAcceleratorTable (accelTable); return subframe; @@ -1033,7 +1031,7 @@ ImageFileView::OnClose (bool deleteWindow) //GetDocumentManager()->ActivateView (this, false, true); if (! GetDocument() || ! GetDocument()->Close()) return false; - + Activate (false); if (m_pCanvas) { m_pCanvas->setView(NULL); @@ -1125,7 +1123,7 @@ ImageFileView::OnScaleSize (wxCommandEvent& event) rIF.scaleImage (rScaledIF); *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getAskDeleteNewDocs()) - pScaledDoc->Modify (true); + pScaledDoc->Modify (true); pScaledDoc->UpdateAllViews (this); pScaledDoc->getView()->OnUpdate (this, NULL); pScaledDoc->getView()->getFrame()->Show(true); @@ -1229,7 +1227,7 @@ ImageFileView::OnPlotRow (wxCommandEvent& event) delete pYMag; } if (theApp->getAskDeleteNewDocs()) - pPlotDoc->Modify (true); + pPlotDoc->Modify (true); pPlotDoc->UpdateAllViews (); pPlotDoc->getView()->OnUpdate (this, NULL); pPlotDoc->getView()->getFrame()->Show(true); @@ -1315,7 +1313,7 @@ ImageFileView::OnPlotCol (wxCommandEvent& event) delete pYMag; } if (theApp->getAskDeleteNewDocs()) - pPlotDoc->Modify (true); + pPlotDoc->Modify (true); pPlotDoc->UpdateAllViews (); pPlotDoc->getView()->OnUpdate (this, NULL); pPlotDoc->getView()->getFrame()->Show(true); @@ -1410,7 +1408,7 @@ ImageFileView::OnPlotFFTRow (wxCommandEvent& event) delete [] pcIn; if (theApp->getAskDeleteNewDocs()) - pPlotDoc->Modify (true); + pPlotDoc->Modify (true); pPlotDoc->UpdateAllViews (); pPlotDoc->getView()->OnUpdate (this, NULL); pPlotDoc->getView()->getFrame()->Show(true); @@ -1511,7 +1509,7 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event) delete [] pcIn; if (theApp->getAskDeleteNewDocs()) - pPlotDoc->Modify (true); + pPlotDoc->Modify (true); pPlotDoc->UpdateAllViews (); pPlotDoc->getView()->OnUpdate (this, NULL); pPlotDoc->getView()->getFrame()->Show(true); @@ -1794,7 +1792,7 @@ PhantomCanvas::GetBestSize() const { if (! m_pView) return wxSize(0,0); - + int xSize, ySize; theApp->getMainFrame()->GetClientSize (&xSize, &ySize); xSize = maxValue (xSize, ySize); @@ -1891,7 +1889,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) const Phantom& rPhantom = GetDocument()->getPhantom(); Projections* pProj = new Projections; Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, - m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio); + m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio); if (theScanner.fail()) { wxString msg = "Failed making scanner\n"; msg += theScanner.failMessage().c_str(); @@ -1984,12 +1982,12 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) m_dDefaultRasterViewRatio = 0; if (m_iDefaultRasterNX > 0 && m_iDefaultRasterNY > 0) { const Phantom& rPhantom = GetDocument()->getPhantom(); - + ImageFile* pImageFile = new ImageFile; pImageFile->setArraySize (m_iDefaultRasterNX, m_iDefaultRasterNY); wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), - pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT ); + pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT ); Timer timer; for (unsigned int i = 0; i < pImageFile->nx(); i++) { rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, @@ -1999,14 +1997,14 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) return; } } - + ImageFileDocument* pRasterDoc = theApp->newImageDoc(); if (! pRasterDoc) { sys_error (ERR_SEVERE, "Unable to create image file"); return; } pRasterDoc->setImageFile (pImageFile); - + if (theApp->getAskDeleteNewDocs()) pRasterDoc->Modify (true); pRasterDoc->UpdateAllViews (this); @@ -2323,7 +2321,7 @@ ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) m_iDefaultPolarNY = dialogPolar.getYSize(); m_iDefaultPolarZeropad = dialogPolar.getZeropad(); ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY); - + m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str()); if (! rProj.convertFFTPolar (*pIF, m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad)) { delete pIF; @@ -2354,7 +2352,12 @@ ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) void ProjectionFileView::OnReconstructFourier (wxCommandEvent& event) { -#if CTSIM_THREADS + wxMessageBox ("Fourier Reconstruction is not yet supported", "Unimplemented function"); +} + +void +ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) +{ DialogGetReconstructionParameters dialogReconstruction (getFrameForChild(), m_iDefaultNX, m_iDefaultNY, m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, @@ -2378,20 +2381,20 @@ ProjectionFileView::OnReconstructFourier (wxCommandEvent& event) wxString optBackprojectName = dialogReconstruction.getBackprojectName(); m_iDefaultBackprojector = Backprojector::convertBackprojectNameToID (optBackprojectName.c_str()); m_iDefaultTrace = dialogReconstruction.getTrace(); - + if (m_iDefaultNX > 0 && m_iDefaultNY > 0) { const Projections& rProj = GetDocument()->getProjections(); - ImageFile* pImageFile = new ImageFile; - pImageFile->setArraySize (m_iDefaultNX, m_iDefaultNY); std::ostringstream os; os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str(); Timer timerRecon; if (m_iDefaultTrace > Trace::TRACE_CONSOLE) { + ImageFile* pImageFile = new ImageFile; + pImageFile->setArraySize (m_iDefaultNX, m_iDefaultNY); Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), - m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), - optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); - + m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), + optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); + ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, *pImageFile, m_iDefaultTrace, getFrameForChild()); for (int iView = 0; iView < rProj.nView(); iView++) { ::wxYield(); @@ -2410,164 +2413,71 @@ ProjectionFileView::OnReconstructFourier (wxCommandEvent& event) } delete pDlgReconstruct; delete pReconstructor; - ImageFileDocument* pReconDoc = theApp->newImageDoc(); - if (! pReconDoc) { - sys_error (ERR_SEVERE, "Unable to create image file"); - return; - } - pReconDoc->setImageFile (pImageFile); - if (theApp->getAskDeleteNewDocs()) - pReconDoc->Modify (true); - pReconDoc->UpdateAllViews (this); - if (ImageFileView* rasterView = pReconDoc->getView()) { - rasterView->OnUpdate (rasterView, NULL); - rasterView->getFrame()->SetFocus(); - rasterView->getFrame()->Show(true); - } - *theApp->getLog() << os.str().c_str() << "\n"; - pImageFile->labelAdd (rProj.getLabel()); - pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); - - } else { -#if CTSIM_THREADS - ThreadedReconstructor* pReconstructor = new ThreadedReconstructor (this, - m_iDefaultNX, m_iDefaultNY, optFilterName.c_str(), - m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), - optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), os.str().c_str()); - if (! pReconstructor->start()) { - delete pImageFile; - delete pReconstructor; + ImageFileDocument* pReconDoc = theApp->newImageDoc(); + if (! pReconDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); return; } - delete pImageFile; - // delete pReconstructor; -#else - Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), - m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), - optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); - - wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, getFrameForChild(), wxPD_CAN_ABORT ); - for (int iView = 0; iView < rProj.nView(); iView++) { - pReconstructor->reconstructView (iView, 1); - if (! dlgProgress.Update (iView + 1)) { - delete pReconstructor; - delete pImageFile; - return; - } + pReconDoc->setImageFile (pImageFile); + if (theApp->getAskDeleteNewDocs()) + pReconDoc->Modify (true); + pReconDoc->UpdateAllViews (this); + if (ImageFileView* rasterView = pReconDoc->getView()) { + rasterView->OnUpdate (rasterView, NULL); + rasterView->getFrame()->SetFocus(); + rasterView->getFrame()->Show(true); } - delete pReconstructor; - ImageFileDocument* pReconDoc = theApp->newImageDoc(); - if (! pReconDoc) { - sys_error (ERR_SEVERE, "Unable to create image file"); - return; - } - pReconDoc->setImageFile (pImageFile); - if (theApp->getAskDeleteNewDocs()) - pReconDoc->Modify (true); - pReconDoc->UpdateAllViews (this); - if (ImageFileView* rasterView = pReconDoc->getView()) { - rasterView->OnUpdate (rasterView, NULL); - rasterView->getFrame()->SetFocus(); - rasterView->getFrame()->Show(true); - } - *theApp->getLog() << os.str().c_str() << "\n"; - pImageFile->labelAdd (rProj.getLabel()); - pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); -#endif - } - } - } -#else - wxMessageBox ("Fourier Reconstruction is not yet supported", "Unimplemented function"); -#endif -} - -void -ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) -{ - DialogGetReconstructionParameters dialogReconstruction (getFrameForChild(), m_iDefaultNX, m_iDefaultNY, - m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, - m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, - m_iDefaultTrace); - - int retVal = dialogReconstruction.ShowModal(); - if (retVal == wxID_OK) { - m_iDefaultNX = dialogReconstruction.getXSize(); - m_iDefaultNY = dialogReconstruction.getYSize(); - wxString optFilterName = dialogReconstruction.getFilterName(); - m_iDefaultFilter = SignalFilter::convertFilterNameToID (optFilterName.c_str()); - m_dDefaultFilterParam = dialogReconstruction.getFilterParam(); - wxString optFilterMethodName = dialogReconstruction.getFilterMethodName(); - m_iDefaultFilterMethod = ProcessSignal::convertFilterMethodNameToID(optFilterMethodName.c_str()); - m_iDefaultZeropad = dialogReconstruction.getZeropad(); - wxString optFilterGenerationName = dialogReconstruction.getFilterGenerationName(); - m_iDefaultFilterGeneration = ProcessSignal::convertFilterGenerationNameToID (optFilterGenerationName.c_str()); - wxString optInterpName = dialogReconstruction.getInterpName(); - m_iDefaultInterpolation = Backprojector::convertInterpNameToID (optInterpName.c_str()); - m_iDefaultInterpParam = dialogReconstruction.getInterpParam(); - wxString optBackprojectName = dialogReconstruction.getBackprojectName(); - m_iDefaultBackprojector = Backprojector::convertBackprojectNameToID (optBackprojectName.c_str()); - m_iDefaultTrace = dialogReconstruction.getTrace(); - - if (m_iDefaultNX > 0 && m_iDefaultNY > 0) { - const Projections& rProj = GetDocument()->getProjections(); - ImageFile* pImageFile = new ImageFile; - pImageFile->setArraySize (m_iDefaultNX, m_iDefaultNY); - - Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), - m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), - optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); - - Timer timerRecon; - if (m_iDefaultTrace > Trace::TRACE_CONSOLE) { - ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, *pImageFile, m_iDefaultTrace, getFrameForChild()); - for (int iView = 0; iView < rProj.nView(); iView++) { - ::wxYield(); - if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView, true)) { - delete pDlgReconstruct; + *theApp->getLog() << os.str().c_str() << "\n"; + pImageFile->labelAdd (rProj.getLabel()); + pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); + + } else { + if (theApp->getUseBackgroundTasks() || theApp->getNumberCPU() > 1) { + ThreadedReconstructor* pReconstructor = new ThreadedReconstructor (this, + m_iDefaultNX, m_iDefaultNY, optFilterName.c_str(), + m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), + optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), os.str().c_str()); + if (! pReconstructor->start()) { delete pReconstructor; - delete pImageFile; return; } - ::wxYield(); - ::wxYield(); - while (pDlgReconstruct->isPaused()) { - ::wxYield(); - ::wxUsleep(50); + // delete pReconstructor; // reconstructor is still running + } else { + ImageFile* pImageFile = new ImageFile; + pImageFile->setArraySize (m_iDefaultNX, m_iDefaultNY); + Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), + m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), + optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); + + wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, getFrameForChild(), wxPD_CAN_ABORT ); + for (int iView = 0; iView < rProj.nView(); iView++) { + pReconstructor->reconstructView (iView, 1); + if (! dlgProgress.Update (iView + 1)) { + delete pReconstructor; + delete pImageFile; + return; + } } - } - delete pDlgReconstruct; - } else { - wxProgressDialog dlgProgress (wxString("Reconstruction"), wxString("Reconstruction Progress"), rProj.nView() + 1, getFrameForChild(), wxPD_CAN_ABORT ); - for (int iView = 0; iView < rProj.nView(); iView++) { - pReconstructor->reconstructView (iView, 1); - if (! dlgProgress.Update (iView + 1)) { - delete pReconstructor; - delete pImageFile; + delete pReconstructor; + ImageFileDocument* pReconDoc = theApp->newImageDoc(); + if (! pReconDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); return; } + pReconDoc->setImageFile (pImageFile); + if (theApp->getAskDeleteNewDocs()) + pReconDoc->Modify (true); + pReconDoc->UpdateAllViews (this); + if (ImageFileView* rasterView = pReconDoc->getView()) { + rasterView->OnUpdate (rasterView, NULL); + rasterView->getFrame()->SetFocus(); + rasterView->getFrame()->Show(true); + } + *theApp->getLog() << os.str().c_str() << "\n"; + pImageFile->labelAdd (rProj.getLabel()); + pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); } } - delete pReconstructor; - ImageFileDocument* pReconDoc = theApp->newImageDoc(); - if (! pReconDoc) { - sys_error (ERR_SEVERE, "Unable to create image file"); - return; - } - pReconDoc->setImageFile (pImageFile); - if (theApp->getAskDeleteNewDocs()) - pReconDoc->Modify (true); - pReconDoc->UpdateAllViews (this); - if (ImageFileView* rasterView = pReconDoc->getView()) { - rasterView->OnUpdate (rasterView, NULL); - rasterView->getFrame()->SetFocus(); - rasterView->getFrame()->Show(true); - } - std::ostringstream os; - os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str(); - *theApp->getLog() << os.str().c_str() << "\n"; - pImageFile->labelAdd (rProj.getLabel()); - pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); } } } @@ -2634,10 +2544,8 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *reconstruct_menu = new wxMenu; reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection"); reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier"); -#ifndef CTSIM_THREADS reconstruct_menu->Enable (PJMENU_RECONSTRUCT_FOURIER, false); -#endif - + wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1"); help_menu->Append (MAINMENU_HELP_TIPS, "&Tips"); @@ -2777,7 +2685,7 @@ ProjectionFileView::OnClose (bool deleteWindow) if (GetDocument() && GetDocument()->getBadFileOpen()) ::wxYield(); // wxWindows bug workaround } - + return true; } @@ -3101,8 +3009,8 @@ PlotFileView::OnClose (bool deleteWindow) m_pFrame = NULL; if (GetDocument() && GetDocument()->getBadFileOpen()) ::wxYield(); // wxWindows bug workaround - } - + } + return true; } @@ -3169,7 +3077,7 @@ TextFileView::OnClose (bool deleteWindow) if (GetDocument() && GetDocument()->getBadFileOpen()) ::wxYield(); // wxWindows bug workaround } - + return TRUE; } @@ -3187,7 +3095,7 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view) #endif theApp->setIconForFrame (subframe); - m_pFileMenu = new wxMenu; + m_pFileMenu = new wxMenu; m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P"); m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F"); @@ -3221,7 +3129,7 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view) subframe->SetMenuBar(menu_bar); subframe->Centre(wxBOTH); - + return subframe; } -- 2.34.1