From df521cfe14a9e0b47bdcd98d1f67d03acf242162 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 25 Feb 2001 10:52:55 +0000 Subject: [PATCH] r582: no message --- msvc/ctsim/ctsim.plg | 15 +-- src/Makefile.am | 2 +- src/backgroundmgr.cpp | 17 +-- src/backgroundmgr.h | 5 +- src/ctsim.cpp | 7 +- src/docs.cpp | 89 +++++++------- src/docs.h | 35 ++++-- src/threadproj.cpp | 266 ++++++++++++++++++++++++++++++++++++++++++ src/threadproj.h | 135 +++++++++++++++++++++ src/threadrecon.cpp | 3 +- src/threadrecon.h | 4 +- src/views.cpp | 18 +-- 12 files changed, 511 insertions(+), 85 deletions(-) create mode 100644 src/threadproj.cpp create mode 100644 src/threadproj.h diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index e0371fb..9364534 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -6,7 +6,7 @@ --------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP28E.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E5.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" @@ -14,8 +14,8 @@ Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP28E.tmp" with conten "C:\ctsim\src\threadrecon.cpp" "C:\ctsim\src\backgroundsupr.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP28E.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP28F.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E5.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E6.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" @@ -23,8 +23,8 @@ Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP28F.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\RSP28F.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP290.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E6.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E7.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\backgroundmgr.obj @@ -39,6 +39,7 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. .\Debug\views.obj .\Debug\ctsim.res .\Debug\backgroundsupr.obj +.\Debug\threadproj.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" @@ -49,7 +50,7 @@ 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\RSP290.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP2E7.tmp"

Output Window

Compiling... threadrecon.cpp @@ -58,11 +59,11 @@ backgroundmgr.cpp graph3dview.cpp backgroundsupr.cpp Compiling... +views.cpp Skipping... (no relevant changes detected) ctsim.cpp dialogs.cpp docs.cpp -views.cpp Linking... diff --git a/src/Makefile.am b/src/Makefile.am index a06eee2..c1cfdf4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS=ctsim -ctsim_SOURCES=ctsim.cpp docs.cpp views.cpp dialogs.cpp ctsim.h docs.h views.h dialogs.h dlgprojections.cpp dlgprojections.h dlgreconstruct.cpp dlgreconstruct.h graph3dview.cpp graph3dview.h ctsim-map.h ctsim.xpm splash.xpm tips.cpp tips.h threadrecon.cpp threadrecon.h backgroundmgr.cpp backgroundmgr.h +ctsim_SOURCES=ctsim.cpp docs.cpp views.cpp dialogs.cpp ctsim.h docs.h views.h dialogs.h dlgprojections.cpp dlgprojections.h dlgreconstruct.cpp dlgreconstruct.h graph3dview.cpp graph3dview.h ctsim-map.h ctsim.xpm splash.xpm tips.cpp tips.h threadrecon.cpp threadrecon.h backgroundmgr.cpp backgroundmgr.h backgroundsupr.cpp backgroundsupr.h threadproj.cpp threadproj.h ctsim_DEPENDENCIES=../libctgraphics/libctgraphics.a ../libctsupport/libctsupport.a ../libctsim/libctsim.a ../include/ct.h ctsim_LDADD=-L../libctgraphics -L../libctsupport -L../libctsim @ctlibs@ diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp index 34f568b..5e19879 100644 --- a/src/backgroundmgr.cpp +++ b/src/backgroundmgr.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundmgr.cpp,v 1.7 2001/02/25 07:36:26 kevin Exp $ +** $Id: backgroundmgr.cpp,v 1.8 2001/02/25 10:52:55 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 @@ -64,7 +64,8 @@ BackgroundManager::BackgroundManager () m_sizeLabel.Set (140, 20); m_sizeBorder.Set (4, 4); m_sizeCellSpacing.Set (3, 3); - m_sizeButton.Set (70, 20); + //m_sizeButton.Set (70, 20); + m_sizeButton.Set (0, 0); m_sizeCell.Set (m_sizeGauge.x + m_sizeLabel.x + m_sizeCellSpacing.x + m_sizeButton.x, 25); @@ -130,14 +131,14 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) wxPoint posButton (m_sizeBorder.x + m_sizeGauge.x + m_sizeLabel.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y); wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, posGauge, m_sizeGauge); wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, pszTaskName, posLabel, m_sizeLabel); - wxButton* pCancelButton = new wxButton (m_pCanvas, iFirstUnusedPos, _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT); +// wxButton* pCancelButton = new wxButton (m_pCanvas, iFirstUnusedPos, _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT); m_vecpBackgroundTasks.push_back (pTask); m_vecpGauges.push_back (pGauge); m_vecpNames.push_back (new std::string (pszTaskName)); m_vecpPositions.push_back (iFirstUnusedPos); m_vecpLabels.push_back (pLabel); - m_vecpCancelButtons.push_back (pCancelButton); + //m_vecpCancelButtons.push_back (pCancelButton); m_iNumTasks++; resizeWindow(); @@ -162,19 +163,19 @@ BackgroundManager::OnRemoveTask (wxCommandEvent& event) GaugeContainer::iterator iGauge = m_vecpGauges.begin(); PositionContainer::iterator iPosition = m_vecpPositions.begin(); LabelContainer::iterator iLabel = m_vecpLabels.begin(); - ButtonContainer::iterator iCancelButton = m_vecpCancelButtons.begin(); + //ButtonContainer::iterator iCancelButton = m_vecpCancelButtons.begin(); for (TaskContainer::iterator iTask = m_vecpBackgroundTasks.begin(); iTask != m_vecpBackgroundTasks.end(); iTask++) { if (*iTask == pTask) { delete *iName; delete *iGauge; delete *iLabel; - delete *iCancelButton; + //delete *iCancelButton; m_vecpBackgroundTasks.erase (iTask); m_vecpGauges.erase (iGauge); m_vecpNames.erase (iName); m_vecpPositions.erase (iPosition); m_vecpLabels.erase (iLabel); - m_vecpCancelButtons.erase (iCancelButton); + //m_vecpCancelButtons.erase (iCancelButton); m_iNumTasks--; break; } @@ -182,7 +183,7 @@ BackgroundManager::OnRemoveTask (wxCommandEvent& event) iGauge++; iPosition++; iLabel++; - iCancelButton++; + //iCancelButton++; } resizeWindow(); diff --git a/src/backgroundmgr.h b/src/backgroundmgr.h index 0366594..b6e668a 100644 --- a/src/backgroundmgr.h +++ b/src/backgroundmgr.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundmgr.h,v 1.6 2001/02/25 07:36:26 kevin Exp $ +** $Id: backgroundmgr.h,v 1.7 2001/02/25 10:52:55 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,9 +52,8 @@ class BackgroundManagerCanvas; #if CTSIM_MDI //class BackgroundManager : public wxMDIChildFrame -//#else -class BackgroundManager : public wxMiniFrame #endif +class BackgroundManager : public wxMiniFrame { private: DECLARE_DYNAMIC_CLASS(BackgroundManager) diff --git a/src/ctsim.cpp b/src/ctsim.cpp index c1283c0..0d459ad 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.88 2001/02/22 15:00:20 kevin Exp $ +** $Id: ctsim.cpp,v 1.89 2001/02/25 10:52:55 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 @@ -69,7 +69,7 @@ #endif #endif -static const char* rcsindent = "$Id: ctsim.cpp,v 1.88 2001/02/22 15:00:20 kevin Exp $"; +static const char* rcsindent = "$Id: ctsim.cpp,v 1.89 2001/02/25 10:52:55 kevin Exp $"; struct option CTSimApp::ctsimOptions[] = { @@ -556,7 +556,8 @@ MainFrame::OnCreateFilter (wxCommandEvent& WXUNUSED(event)) rIF.setArraySize (m_iDefaultFilterXSize, m_iDefaultFilterYSize); rIF.filterResponse (strDomain.c_str(), m_dDefaultFilterBandwidth, strFilter.c_str(), m_dDefaultFilterParam, m_dDefaultFilterInputScale, m_dDefaultFilterOutputScale); rIF.labelAdd (os.str().c_str()); - pFilterDoc->Modify (true); + if (theApp->getAskDeleteNewDocs()) + pFilterDoc->Modify (true); pFilterDoc->UpdateAllViews(); pFilterDoc->GetFirstView()->OnUpdate (NULL, NULL); pFilterDoc->getView()->getFrame()->SetClientSize(m_iDefaultFilterXSize, m_iDefaultFilterYSize); diff --git a/src/docs.cpp b/src/docs.cpp index 16462d7..99e6a56 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.cpp,v 1.28 2001/02/25 06:32:12 kevin Exp $ +** $Id: docs.cpp,v 1.29 2001/02/25 10:52:55 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 @@ -126,45 +126,16 @@ ImageFileDocument::Revert () return true; } -// ProjectionFileDocument +// BackgroundProcessingDocument - Base Class -IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, wxDocument) -BEGIN_EVENT_TABLE(ProjectionFileDocument, wxDocument) -EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_ADD, ProjectionFileDocument::OnAddBackground) -EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_REMOVE, ProjectionFileDocument::OnRemoveBackground) +IMPLEMENT_DYNAMIC_CLASS(BackgroundProcessingDocument, wxDocument) +BEGIN_EVENT_TABLE(BackgroundProcessingDocument, wxDocument) +EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_ADD, BackgroundProcessingDocument::OnAddBackground) +EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_REMOVE, BackgroundProcessingDocument::OnRemoveBackground) END_EVENT_TABLE() -bool -ProjectionFileDocument::OnSaveDocument(const wxString& filename) -{ - if (! m_pProjectionFile->write (filename.c_str())) { - *theApp->getLog() << "Unable to write projection file " << filename << "\n"; - return false; - } - if (theApp->getVerboseLogging()) - *theApp->getLog() << "Wrote projection file " << filename << "\n"; - Modify(false); - return true; -} - -ProjectionFileDocument::~ProjectionFileDocument() -{ - m_criticalSection.Enter(); - for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); - i != m_vecpBackgroundSupervisors.end(); i++) - BackgroundSupervisor::cancelSupervisor(*i); - m_criticalSection.Leave(); - - while (m_vecpBackgroundSupervisors.size() > 0) { - ::wxUsleep(50); - ::wxYield(); - } - - delete m_pProjectionFile; -} - void -ProjectionFileDocument::OnAddBackground (wxCommandEvent& event) +BackgroundProcessingDocument::OnAddBackground (wxCommandEvent& event) { BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); wxASSERT (pSupervisor != NULL); @@ -175,7 +146,7 @@ ProjectionFileDocument::OnAddBackground (wxCommandEvent& event) } void -ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event) +BackgroundProcessingDocument::OnRemoveBackground (wxCommandEvent& event) { BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); wxASSERT (pSupervisor != NULL); @@ -193,12 +164,52 @@ ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event) m_criticalSection.Leave(); if (! bFound) - sys_error (ERR_SEVERE, "Could not find background task [ProjectionFileDocument::removeBackgroundTask"); + sys_error (ERR_SEVERE, "Could not find background task [OnRemoveBackground]"); wxCommandEvent ackEvent (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_DOCUMENT_ACK_REMOVE); wxPostEvent (pSupervisor, ackEvent); } +void +BackgroundProcessingDocument::cancelRunningTasks() +{ + m_criticalSection.Enter(); + for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); + i != m_vecpBackgroundSupervisors.end(); i++) + BackgroundSupervisor::cancelSupervisor(*i); + m_criticalSection.Leave(); + + while (m_vecpBackgroundSupervisors.size() > 0) { + ::wxUsleep(50); + ::wxYield(); + } +} + + +// ProjectionFileDocument + +IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, BackgroundProcessingTask) + +bool +ProjectionFileDocument::OnSaveDocument(const wxString& filename) +{ + if (! m_pProjectionFile->write (filename.c_str())) { + *theApp->getLog() << "Unable to write projection file " << filename << "\n"; + return false; + } + if (theApp->getVerboseLogging()) + *theApp->getLog() << "Wrote projection file " << filename << "\n"; + Modify(false); + return true; +} + +ProjectionFileDocument::~ProjectionFileDocument() +{ + cancelRunningTasks(); + + delete m_pProjectionFile; +} + bool ProjectionFileDocument::OnOpenDocument(const wxString& filename) { @@ -242,7 +253,7 @@ ProjectionFileDocument::getView() const // PhantomFileDocument -IMPLEMENT_DYNAMIC_CLASS(PhantomFileDocument, wxDocument) +IMPLEMENT_DYNAMIC_CLASS(PhantomFileDocument, BackgroundProcessingTask) bool PhantomFileDocument::OnOpenDocument(const wxString& filename) diff --git a/src/docs.h b/src/docs.h index 6c0e0fe..f841bcd 100644 --- a/src/docs.h +++ b/src/docs.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: docs.h,v 1.24 2001/02/23 21:58:31 kevin Exp $ +** $Id: docs.h,v 1.25 2001/02/25 10:52:55 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 @@ -86,17 +86,33 @@ public: void setBadFileOpen() { m_bBadFileOpen = true; } }; +class BackgroundProcessingDocument : public wxDocument +{ +private: + DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument) + typedef BackgroundSupervisor BackgroundObject; + typedef std::vector BackgroundContainer; + BackgroundContainer m_vecpBackgroundSupervisors; + wxCriticalSection m_criticalSection; + +public: + BackgroundProcessingDocument() + : wxDocument() + {} + + void cancelRunningTasks(); + void OnAddBackground (wxCommandEvent& event); + void OnRemoveBackground (wxCommandEvent& event); -class ProjectionFileDocument: public wxDocument + DECLARE_EVENT_TABLE() +}; + +class ProjectionFileDocument: public BackgroundProcessingDocument { private: DECLARE_DYNAMIC_CLASS(ProjectionFileDocument) Projections* m_pProjectionFile; bool m_bBadFileOpen; - typedef BackgroundSupervisor BackgroundObject; - typedef std::vector BackgroundContainer ; - BackgroundContainer m_vecpBackgroundSupervisors; - wxCriticalSection m_criticalSection; public: virtual bool OnSaveDocument (const wxString& filename); @@ -123,15 +139,10 @@ public: ProjectionFileView* getView() const; bool getBadFileOpen() const { return m_bBadFileOpen; } void setBadFileOpen() { m_bBadFileOpen = true; } - - void OnAddBackground (wxCommandEvent& event); - void OnRemoveBackground (wxCommandEvent& event); - - DECLARE_EVENT_TABLE() }; -class PhantomFileDocument: public wxDocument +class PhantomFileDocument: public BackgroundProcessingDocument { private: DECLARE_DYNAMIC_CLASS(PhantomFileDocument) diff --git a/src/threadproj.cpp b/src/threadproj.cpp new file mode 100644 index 0000000..dc96cee --- /dev/null +++ b/src/threadproj.cpp @@ -0,0 +1,266 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: threadproj.cpp +** Purpose: Threaded projection class +** Programmer: Kevin Rosenberg +** Date Started: February 2001 +** +** This is part of the CTSim program +** Copyright (C) 1983-2001 Kevin Rosenberg +** +** $Id: threadproj.cpp,v 1.1 2001/02/25 10:52:55 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 "threadproj.h" +#include "backgroundmgr.h" +#include "backgroundsupr.h" + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + + + +///////////////////////////////////////////////////////////////////// +// +// Class ProjectorSupervisorThread -- Thread for Background Supervisor +// +///////////////////////////////////////////////////////////////////// + +ProjectorSupervisorThread::ProjectorSupervisorThread (PhantomFileView* pProjView, int iNDet, int iNView, + const char* pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio, const char* const pszLabel) +: m_pPhantomView(pProjView), m_iNDet(iNDet), m_iNView(iNView), m_strGeometry(pszGeometry), + m_iNSample(iNSample), m_dRotation(dRotation), m_dFocalLength(dFocalLength), m_dViewRatio(dViewRatio), + m_dScanRatio(dScanRatio), m_strLabel(pszLabel), + SupervisorThread() +{ +} + +wxThread::ExitCode +ProjectorSupervisorThread::Entry() +{ + ProjectorSupervisor projSupervisor (m_pPhantomView, m_iNDet, m_iNView, + m_strGeometry.c_str(), m_iNSample, m_dRotation, m_dFocalLength, m_dViewRatio, m_dScanRatio, m_strLabel.c_str()); + + projSupervisor.start(); + while (! projSupervisor.isDone() && ! projSupervisor.fail()) { + Sleep(50); + Yield(); + } + if (projSupervisor.fail()) + { + wxString msg ("Error starting Projector supervisor: "); + msg += projSupervisor.getFailMessage().c_str(); + msg += "\n"; + wxCommandEvent eventLog (wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + eventLog.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event + } + + while (! projSupervisor.workersDeleted()) { + Sleep(50); + projSupervisor.ProcessPendingEvents(); + } + + return reinterpret_cast(0); +} + +void +ProjectorSupervisorThread::OnExit() +{ +} + + +///////////////////////////////////////////////////////////////////// +// +// Class ProjectorSupervisor -- A Background Supervisor +// +///////////////////////////////////////////////////////////////////// + +ProjectorSupervisor::ProjectorSupervisor (PhantomFileView* pPhantomView, int iNDet, int iNView, + const char* pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio, const char* const pszLabel) + : m_pPhantomView(pPhantomView), m_pPhantomDoc(pPhantomView->GetDocument()), + m_iNDet(iNDet), m_iNView(iNView), + m_pszGeometry(pszGeometry), m_iNSample(iNSample), m_dRotation(dRotation), m_dFocalLength(dFocalLength), + m_dViewRatio(dViewRatio), m_dScanRatio(dScanRatio), m_pszLabel(pszLabel), + BackgroundSupervisor (pPhantomView->GetFrame(), pPhantomView->GetDocument(), "Projecting", iNView) +{ + m_vecpChildProjections.reserve (getNumWorkers()); + for (unsigned int iThread = 0; iThread < getNumWorkers(); iThread++) { + m_vecpChildProjections[iThread] = new Projections (m_iNDet, m_iNView); + } + +} + +ProjectorSupervisor::~ProjectorSupervisor() +{ + for (int i = 0; i < getNumWorkers(); i++) { + delete m_vecpChildProjections[i]; + m_vecpChildProjections[i] = NULL; + } +} + +BackgroundWorkerThread* +ProjectorSupervisor::createWorker (int iThread, int iStartUnit, int iNumUnits) +{ + ProjectorWorker* pThread = new ProjectorWorker (this, iThread, iStartUnit, iNumUnits); + pThread->SetParameters (m_pPhantomView, m_vecpChildProjections[iThread], m_iNDet, m_iNView, + m_pszGeometry, m_iNSample, m_dRotation, m_dFocalLength, m_dViewRatio, m_dScanRatio); + + return pThread; +} + +void +ProjectorSupervisor::onDone() +{ + wxCriticalSection doneSection; + wxCriticalSectionLocker critsect (doneSection); + + ProjectionFileDocument* pProjDoc = theApp->newProjectionDoc(); + if (! pProjDoc) { + sys_error (ERR_SEVERE, "Unable to create projection file"); + return; + } + + Projections* pProjections = getProjections(); + pProjDoc->setProjections (pProjections); + if (theApp->getAskDeleteNewDocs()) + pProjDoc->Modify (true); + pProjDoc->UpdateAllViews (NULL); + if (ProjectionFileView* projView = pProjDoc->getView()) { + projView->OnUpdate (projView, NULL); + projView->getFrame()->SetFocus(); + projView->getFrame()->Show(true); + } + *theApp->getLog() << m_pszLabel << "\n"; + pProjections->setRemark (m_pszLabel); + pProjections->setCalcTime (getTimerEnd()); + + setDone(); +} + + +Projections* +ProjectorSupervisor::getProjections() +{ + Projections* pProjections = new Projections (m_iNDet, m_iNView); +#if 0 + ImageFileArray pArray = pImageFile->getArray(); + + int i; + for (i = 0; i < getNumWorkers(); i++) { + ImageFileArrayConst pChildArray = m_vecpChildImageFile[i]->getArray(); + for (int ix = 0; ix < m_iImageNX; ix++) + for (int iy = 0; iy < m_iImageNY; iy++) + pArray[ix][iy] += pChildArray[ix][iy]; + } +#endif + return (pProjections); +} + + +///////////////////////////////////////////////////////////////////// +// +// Class ProjectorWorker -- A worker thread +// +///////////////////////////////////////////////////////////////////// + +void +ProjectorWorker::SetParameters (PhantomFileView* pPhantomView, Projections* pProjections, int iNDet, int iView, + const char* pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio) +{ + m_pPhantomView = pPhantomView; + m_pProjections = pProjections; + m_pszGeometry = pszGeometry; + m_iNSample = iNSample; + m_dFocalLength = dFocalLength; + m_dViewRatio = dViewRatio; + m_dScanRatio = dScanRatio; +} + +wxThread::ExitCode +ProjectorWorker::Entry () +{ + const Phantom& rPhantom = m_pPhantomView->GetDocument()->getPhantom(); + Scanner* pScanner = new Scanner (rPhantom, m_pszGeometry, m_iNDet, + m_iNView, m_iNSample, m_dRotation, m_dFocalLength, m_dViewRatio, m_dScanRatio); + + bool bFail = pScanner->fail(); + wxString failMsg; + if (bFail) { + failMsg = "Unable to make Projector: "; + failMsg += pScanner->failMessage().c_str(); + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + event.SetString( failMsg ); + wxPostEvent( theApp->getMainFrame(), event ); + } + else + { + wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_UNIT_TICK); + for (int iUnit = 0; iUnit < m_iNumUnits; iUnit++) { + if (TestDestroy()) { +#ifdef DEBUG + if (theApp->getVerboseLogging()) { + wxString msg; + msg.Printf("Worker thread: Received destroy message at work unit #%d\n", iUnit); + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + event.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), event ); + } +#endif + break; + } + pScanner->collectProjections (*m_pProjections, rPhantom, iUnit + m_iStartUnit, 1, true, Trace::TRACE_NONE); + wxPostEvent (m_pSupervisor, eventProgress); + } + } + delete pScanner; + + if (bFail) { + wxCommandEvent eventFail (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_FAIL); + eventFail.SetInt (m_iThread); // Send back thread# that has finished + eventFail.SetString (failMsg); + wxPostEvent (m_pSupervisor, eventFail); + } else { + wxCommandEvent eventDone (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_WORKER_THREAD_DONE); + eventDone.SetInt (m_iThread); // Send back thread# that has finished + wxPostEvent (m_pSupervisor, eventDone); + } + + while (! TestDestroy()) + Sleep(100); + + return reinterpret_cast(0); +} + +void +ProjectorWorker::OnExit () +{ +} diff --git a/src/threadproj.h b/src/threadproj.h new file mode 100644 index 0000000..02afffd --- /dev/null +++ b/src/threadproj.h @@ -0,0 +1,135 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: threadproj.h +** Purpose: Header file for thread reconstructions +** Programmer: Kevin Rosenberg +** Date Started: February 2001 +** +** This is part of the CTSim program +** Copyright (C) 1983-2001 Kevin Rosenberg +** +** $Id: threadproj.h,v 1.1 2001/02/25 10:52:55 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 _THREADPROJ_H +#define _THREADPROJ_H + +#include +#include +#include +#include "timer.h" +#include "backgroundsupr.h" + + +class Reconstructor; +class ImageFile; +class PhantomFileDocument; +class ProjectorWorker; +class ProjectionFileView; + +class ProjectorSupervisorThread : public SupervisorThread { +private: + PhantomFileView* m_pPhantomView; + const int m_iNDet; + const int m_iNView; + const std::string m_strGeometry; + const int m_iNSample; + const double m_dRotation; + const double m_dFocalLength; + const double m_dViewRatio; + const double m_dScanRatio; + const std::string m_strLabel; + +public: + ProjectorSupervisorThread(PhantomFileView* pProjView, int iNDet, int iNView, + const char* pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio, const char* const pszLabel); + + virtual wxThread::ExitCode Entry(); + + virtual void OnExit(); +}; + + + +class ProjectorSupervisor : public BackgroundSupervisor { +private: + + std::vector m_vecpChildProjections; + PhantomFileDocument* m_pPhantomDoc; + PhantomFileView* m_pPhantomView; + + const int m_iNDet; + const int m_iNView; + const char* const m_pszGeometry; + const int m_iNSample; + const double m_dRotation; + const double m_dFocalLength; + const double m_dViewRatio; + const double m_dScanRatio; + const char* const m_pszLabel; + + +public: + ProjectorSupervisor (PhantomFileView* pProjView, int iNDet, int iNView, + const char* pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio, const char* const pszLabel); + + virtual BackgroundWorkerThread* createWorker (int iThread, int iStartUnit, int iNumUnits); + + virtual ~ProjectorSupervisor (); + + void onDone(); + + Projections* getProjections(); + +}; + + + + +class ProjectorWorker : public BackgroundWorkerThread { +private: + PhantomFileView* m_pPhantomView; + Projections* m_pProjections; + int m_iNDet; + int m_iNView; + const char* m_pszGeometry; + int m_iNSample; + double m_dRotation; + double m_dFocalLength; + double m_dViewRatio; + double m_dScanRatio; + + +public: + ProjectorWorker (ProjectorSupervisor* pSupervisor, int iThread, int iStartView, int iNumViews) + : BackgroundWorkerThread (pSupervisor, iThread, iStartView, iNumViews) + {} + + void SetParameters (PhantomFileView* pPhantomFile, Projections* pProjections, int iNDet, int iView, + const char* const pszGeometry, int iNSample, double dRotation, double dFocalLength, double dViewRatio, + double dScanRatio); + + virtual wxThread::ExitCode Entry(); // thread execution starts here + + virtual void OnExit(); +}; + + +#endif + diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 53d1ef4..51b930d 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.11 2001/02/25 08:43:03 kevin Exp $ +** $Id: threadrecon.cpp,v 1.12 2001/02/25 10:52:55 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 @@ -196,6 +196,7 @@ ReconstructorSupervisor::getImageFile() // ///////////////////////////////////////////////////////////////////// +void ReconstructorWorker::SetParameters (ProjectionFileView* pProjView, ImageFile* pImageFile, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam, diff --git a/src/threadrecon.h b/src/threadrecon.h index f4f9105..cbb2ea9 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.8 2001/02/25 06:32:12 kevin Exp $ +** $Id: threadrecon.h,v 1.9 2001/02/25 10:52:55 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 @@ -125,7 +125,7 @@ public: : BackgroundWorkerThread (pSupervisor, iThread, iStartView, iNumViews) {} - SetParameters (ProjectionFileView* pProjFile, ImageFile* pImageFile, + void SetParameters (ProjectionFileView* pProjFile, ImageFile* pImageFile, const char* const pszFilterName, double dFilterParam, const char* const pszFilterMethod, int iZeropad, const char* const pszFilterGenerationName, const char* const pszInterpName, int iInterpParam, const char* pszBackprojectName); diff --git a/src/views.cpp b/src/views.cpp index 1e28647..a4826e0 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.117 2001/02/25 06:32:12 kevin Exp $ +** $Id: views.cpp,v 1.118 2001/02/25 10:52:55 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 @@ -1902,6 +1902,13 @@ PhantomFileView::OnProjections (wxCommandEvent& event) wxMessageBox (msg, "Error"); return; } + std::ostringstream os; + os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet + << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample + << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength + << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio + << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << + convertRadiansToDegrees (theScanner.fanBeamAngle()); pProj->initFromScanner (theScanner); m_dDefaultRotation /= TWOPI; // convert back to fraction of a circle @@ -1931,15 +1938,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event) } } - std::ostringstream os; - os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet - << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample - << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength - << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio - << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << - convertRadiansToDegrees (theScanner.fanBeamAngle()); - pProj->setCalcTime (timer.timerEnd()); pProj->setRemark (os.str()); + pProj->setCalcTime (timer.timerEnd()); *theApp->getLog() << os.str().c_str() << "\n"; ::wxYield(); -- 2.34.1