From 6480e936da257519dd36840862ac995ca8c374da Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 23 Feb 2001 21:58:32 +0000 Subject: [PATCH] r577: no message --- ChangeLog | 10 +-- doc/Makefile.am | 11 ++- doc/{ctsim-appendix.tex => ctsim-sgp.tex} | 4 +- doc/ctsim.prj | 20 ++--- doc/ctsim.tex | 6 +- doc/{logo-huge.eps => logo.eps} | 0 doc/{logo-huge.gif => logo.gif} | Bin msvc/ctsim/ctsim.plg | 18 ++--- src/backgroundmgr.cpp | 87 +++++++++++++++++----- src/backgroundmgr.h | 18 +++-- src/docs.cpp | 29 ++++---- src/docs.h | 5 +- src/threadrecon.cpp | 87 +++++++++++----------- src/threadrecon.h | 12 +-- src/views.cpp | 10 ++- 15 files changed, 192 insertions(+), 125 deletions(-) rename doc/{ctsim-appendix.tex => ctsim-sgp.tex} (98%) rename doc/{logo-huge.eps => logo.eps} (100%) rename doc/{logo-huge.gif => logo.gif} (100%) diff --git a/ChangeLog b/ChangeLog index 00f074d..31ab14c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,16 +1,16 @@ 3.1.0 - Released - * ctsim: Added "Verbose Logging" and "Startup Tips" options - to Preferences. - * ctsim: Added tips to be displayed at startup and via the help menu. - * ctsim: Added accelerator key for File-Properties - * ctsim: Added threaded reconstructions for background processing as well as taking advantage of multiple-CPU's on SMP systems. + * ctsim: Added "Verbose Logging", "Startup Tips", and + "Background processes" options to Preferences dialog. + + * ctsim: Added accelerator key for File-Properties + 3.0.3 - Released 2/20/01 * ctsim: Fixed core dump on Linux with OpenGL diff --git a/doc/Makefile.am b/doc/Makefile.am index d6bdca3..eec3d5a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,7 +1,16 @@ -docs=ctsim.tex ctsim.bib texhelp.sty psbox.tex logo-huge.gif alphacalc.gif divergent.gif equiangular.gif equilinear.gif scangeometry.gif tex2rtf.ini ctsim.hpj bullet.bmp verbatim.sty mytitle.sty makeidx.sty mysober.sty fancyhea.sty ctsim.bib +docs=ctsim.tex ctsim.bib texhelp.sty psbox.tex logo.eps logo.gif \ +ctsim-sgp.tex ctsim-concepts.tex ctsim-gui.tex ctsim-install.tex \ +ctsim-textui.tex ctsim-web.tex \ +alphacalc.eps alphacalc.gif divergent.eps divergent.gif \ +equiangular.eps equiangular.gif equilinear.eps equilinear.gif \ +scangeometry.eps scangeometry.gif \ +tex2rtf.ini ctsim.hpj bullet.bmp verbatim.sty mytitle.sty makeidx.sty \ +mysober.sty fancyhea.sty ctsim.bib ctsim-latex.bib ctsim-tex2rtf.bib + EXTRA_DIST = ${docs} ctsim.htb dvi: ctsim.tex + latex ctsim bibtex ctsim cp ctsim-latex.bib ctsim.bib latex ctsim diff --git a/doc/ctsim-appendix.tex b/doc/ctsim-sgp.tex similarity index 98% rename from doc/ctsim-appendix.tex rename to doc/ctsim-sgp.tex index a826258..bdb70ff 100644 --- a/doc/ctsim-appendix.tex +++ b/doc/ctsim-sgp.tex @@ -1,6 +1,4 @@ -\appendix - -\chapter{Simple Graphics Package}\label{appendix}\index{Simple Graphics Package} +\chapter{Simple Graphics Package}\label{sgp}\index{Simple Graphics Package} \setheader{{\it Appendix \thechapter}}{}{}{\ctsimheadtitle}{}{{\it Appendix \thechapter}}% \ctsimfooter% diff --git a/doc/ctsim.prj b/doc/ctsim.prj index b763f7d..55b31df 100644 --- a/doc/ctsim.prj +++ b/doc/ctsim.prj @@ -5,16 +5,22 @@ 1 ctsim.tex 18 -3 -1 +5 +2 ctsim-gui.tex TeX -12282 0 290 27 0 1 176 176 1253 763 +12282 0 602 60 26 76 176 176 1253 763 +ctsim.tex +TeX +134230010 0 103 29 125 19 22 22 1099 609 +ctsim-appendix.tex +TeX +268447738 0 0 1 0 2 44 44 1121 631 ctsim-concepts.tex TeX -268447738 0 334 29 307 1 110 110 1187 697 +12282 0 334 29 307 1 110 110 1187 697 ctsim-textui.tex TeX 12282 0 38 45 38 46 198 198 1275 785 @@ -27,12 +33,6 @@ TeX ctsim-web.tex TeX 268447739 0 24 50 0 60 88 88 1165 675 -ctsim-appendix.tex -TeX -268447738 0 12 1 0 1 44 44 1121 631 -ctsim.tex -TeX -402665466 0 25 31 27 37 22 22 1099 609 tex2rtf.ini DATA 273777330 0 0 1 17 8 22 22 938 609 diff --git a/doc/ctsim.tex b/doc/ctsim.tex index 114fbb2..18cdb94 100644 --- a/doc/ctsim.tex +++ b/doc/ctsim.tex @@ -101,7 +101,7 @@ copyrighted head phantom for use in \ctsim. \ctsimfooter -\centerline{\image{3cm;3cm}{logo-huge.eps}} +\centerline{\image{3cm;3cm}{logo.eps}} Computed tomography is a technique for estimating the interior of an object from measurements of radiation collected around the object. This radiation can be either projected through or emitted from the @@ -121,7 +121,9 @@ I hope that you enjoy \ctsim! \include{ctsim-textui} \include{ctsim-web} \include{ctsim-install} -\include{ctsim-appendix} + +\appendix +\include{ctsim-sgp} \newpage diff --git a/doc/logo-huge.eps b/doc/logo.eps similarity index 100% rename from doc/logo-huge.eps rename to doc/logo.eps diff --git a/doc/logo-huge.gif b/doc/logo.gif similarity index 100% rename from doc/logo-huge.gif rename to doc/logo.gif diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index e4d6f21..85cc112 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -6,22 +6,19 @@ --------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP119.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19D.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" -"C:\ctsim\src\dialogs.cpp" "C:\ctsim\src\docs.cpp" -"C:\ctsim\src\views.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP119.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP11A.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19D.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19E.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\threadrecon.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP11A.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP11B.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19E.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19F.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 @@ -45,13 +42,10 @@ 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\RSP11B.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP19F.tmp"

Output Window

Compiling... -ctsim.cpp -dialogs.cpp docs.cpp -views.cpp Compiling... threadrecon.cpp Linking... diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp index c835b7b..ee789de 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.4 2001/02/23 18:56:56 kevin Exp $ +** $Id: backgroundmgr.cpp,v 1.5 2001/02/23 21:58:31 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -46,7 +46,11 @@ IMPLEMENT_DYNAMIC_CLASS(BackgroundManager, wxMiniFrame) BEGIN_EVENT_TABLE(BackgroundManager, wxMiniFrame) +EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_ADD, BackgroundManager::OnAddTask) +EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_REMOVE, BackgroundManager::OnRemoveTask) +EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_UNIT_TICK, BackgroundManager::OnUnitTick) EVT_CLOSE(BackgroundManager::OnCloseWindow) +EVT_COMMAND_RANGE(0, 1000, wxEVT_COMMAND_BUTTON_CLICKED, BackgroundManager::OnCancelButton) END_EVENT_TABLE() BackgroundManager::BackgroundManager () @@ -56,11 +60,14 @@ BackgroundManager::BackgroundManager () m_pCanvas = new BackgroundManagerCanvas (this); theApp->setIconForFrame (this); - m_sizeGauge.Set (50, 15); - m_sizeLabel.Set (140, 15); - m_sizeCell.Set (200, 25); + m_sizeGauge.Set (70, 20); + m_sizeLabel.Set (140, 20); m_sizeBorder.Set (4, 4); + m_sizeCellSpacing.Set (3, 3); + m_sizeButton.Set (70, 20); + m_sizeCell.Set (m_sizeGauge.x + m_sizeLabel.x + m_sizeCellSpacing.x + m_sizeButton.x, 25); + Show(false); } @@ -74,10 +81,30 @@ BackgroundManager::OnCloseWindow (wxCloseEvent& event) event.Veto(); } +void +BackgroundManager::OnUnitTick (wxCommandEvent& event) +{ + int iUnits = event.GetInt(); + BackgroundSupervisor* pTask = reinterpret_cast(event.GetClientData()); + if (pTask == NULL) { + sys_error (ERR_SEVERE, "Received NULL task [BackgroundManager::OnAddTask]"); + return; + } + if (wxGauge* pGauge = lookupGauge (pTask)) + pGauge->SetValue (iUnits); +} -wxGauge* -BackgroundManager::addTask (BackgroundSupervisor* pTask, int iNumUnits, const char* const pszTaskName) +void +BackgroundManager::OnAddTask (wxCommandEvent& event) { + int iNumUnits = event.GetInt(); + const char* const pszTaskName = event.GetString().c_str(); + BackgroundSupervisor* pTask = reinterpret_cast(event.GetClientData()); + if (pTask == NULL) { + sys_error (ERR_SEVERE, "Received NULL task [BackgroundManager::OnAddTask]"); + return; + } + wxCriticalSectionLocker locker (m_criticalSection); int iNumTasks = m_vecpBackgroundTasks.size(); std::vector vecPositionUsed (iNumTasks); @@ -100,41 +127,51 @@ BackgroundManager::addTask (BackgroundSupervisor* pTask, int iNumUnits, const ch wxPoint posGauge (m_sizeBorder.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y); wxPoint posLabel (m_sizeBorder.x + m_sizeGauge.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y); + 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); 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_iNumTasks++; resizeWindow(); Show(true); - return (pGauge); } - -void -BackgroundManager::taskDone (BackgroundSupervisor* pTask) +void +BackgroundManager::OnRemoveTask (wxCommandEvent& event) { + BackgroundSupervisor* pTask = reinterpret_cast(event.GetClientData()); + if (pTask == NULL) { + sys_error (ERR_SEVERE, "Received NULL task [BackgroundManager::OnAddTask]"); + return; + } + wxCriticalSectionLocker locker (m_criticalSection); StringContainer::iterator iName = m_vecpNames.begin(); GaugeContainer::iterator iGauge = m_vecpGauges.begin(); PositionContainer::iterator iPosition = m_vecpPositions.begin(); LabelContainer::iterator iLabel = m_vecpLabels.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; 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_iNumTasks--; break; } @@ -142,12 +179,33 @@ BackgroundManager::taskDone (BackgroundSupervisor* pTask) iGauge++; iPosition++; iLabel++; + iCancelButton++; } resizeWindow(); if (m_iNumTasks <= 0) Show(false); - // delete pTask; +} + +void +BackgroundManager::OnCancelButton (wxCommandEvent& event) +{ +} + +wxGauge* +BackgroundManager::lookupGauge (BackgroundSupervisor* pTask) +{ + wxGauge* pGauge = NULL; + int i = 0; + for (TaskContainer::iterator iTask = m_vecpBackgroundTasks.begin(); iTask != m_vecpBackgroundTasks.end(); iTask++) { + if (*iTask == pTask) { + pGauge = m_vecpGauges[i]; + break; + } + i++; + } + + return pGauge; } void @@ -165,13 +223,6 @@ BackgroundManager::resizeWindow() } -bool -BackgroundManager::isCancelling (BackgroundSupervisor* pTask) -{ - return false; -} - - IMPLEMENT_DYNAMIC_CLASS(BackgroundManagerCanvas, wxPanel) BEGIN_EVENT_TABLE(BackgroundManagerCanvas, wxPanel) diff --git a/src/backgroundmgr.h b/src/backgroundmgr.h index 90bbf14..54bcd15 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.4 2001/02/23 18:56:56 kevin Exp $ +** $Id: backgroundmgr.h,v 1.5 2001/02/23 21:58:31 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -68,33 +68,39 @@ private: typedef std::vector StringContainer; typedef std::vector PositionContainer; typedef std::vector LabelContainer; + typedef std::vector ButtonContainer; TaskContainer m_vecpBackgroundTasks; GaugeContainer m_vecpGauges; StringContainer m_vecpNames; PositionContainer m_vecpPositions; LabelContainer m_vecpLabels; + ButtonContainer m_vecpCancelButtons; wxSize m_sizeGauge; wxSize m_sizeLabel; wxSize m_sizeCell; wxSize m_sizeBorder; + wxSize m_sizeCellSpacing; + wxSize m_sizeButton; void resizeWindow(); + wxGauge* lookupGauge(BackgroundSupervisor* pTask); public: BackgroundManager (); - wxGauge* addTask (BackgroundSupervisor* pTask, int iNumUnits, const char* const pszTaskName); - void taskDone (BackgroundSupervisor* pTask); - bool isCancelling (BackgroundSupervisor* pTask); - TaskContainer& getTasks() { return m_vecpBackgroundTasks;} GaugeContainer& getGauges() { return m_vecpGauges;} StringContainer& getNames() { return m_vecpNames;} PositionContainer& getPositions() { return m_vecpPositions;} LabelContainer& getLabels() { return m_vecpLabels;} + ButtonContainer& getCancelButtons() { return m_vecpCancelButtons;} + void OnAddTask (wxCommandEvent& event); + void OnRemoveTask (wxCommandEvent& event); + void OnUnitTick (wxCommandEvent& event); void OnCloseWindow(wxCloseEvent& event); - + void OnCancelButton(wxCommandEvent& event); + DECLARE_EVENT_TABLE() }; diff --git a/src/docs.cpp b/src/docs.cpp index b356033..bb8ec90 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.26 2001/02/23 18:56:56 kevin Exp $ +** $Id: docs.cpp,v 1.27 2001/02/23 21:58:31 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -151,39 +151,38 @@ ProjectionFileDocument::~ProjectionFileDocument() { for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); i != m_vecpBackgroundSupervisors.end(); i++) { - (*i)->cancel(); + BackgroundSupervisor::cancelSupervisor(*i); } - m_vecpBackgroundSupervisors.clear(); + while (m_vecpBackgroundSupervisors.size() > 0) + ::wxYield(); + delete m_pProjectionFile; } void ProjectionFileDocument::OnAddBackground (wxCommandEvent& event) { -} + BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); + wxASSERT (pSupervisor != NULL); -void -ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event) -{ -} - -void -ProjectionFileDocument::addReconstructor (BackgroundSupervisor* pRecon) -{ wxCriticalSectionLocker locker (m_criticalSection); - m_vecpBackgroundSupervisors.push_back (pRecon); + if (pSupervisor) + m_vecpBackgroundSupervisors.push_back (pSupervisor); } void -ProjectionFileDocument::removeReconstructor (BackgroundSupervisor* pRecon) +ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event) { + BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); + wxASSERT (pSupervisor != NULL); + wxCriticalSectionLocker locker (m_criticalSection); bool bFound = false; for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin(); i != m_vecpBackgroundSupervisors.end(); i++) - if (*i == pRecon) { + if (*i == pSupervisor) { m_vecpBackgroundSupervisors.erase(i); bFound = true; break; diff --git a/src/docs.h b/src/docs.h index 71ce6e3..6c0e0fe 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.23 2001/02/23 18:56:56 kevin Exp $ +** $Id: docs.h,v 1.24 2001/02/23 21:58:31 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -127,9 +127,6 @@ public: void OnAddBackground (wxCommandEvent& event); void OnRemoveBackground (wxCommandEvent& event); - void addReconstructor (BackgroundSupervisor* pRecon); - void removeReconstructor (BackgroundSupervisor* pRecon); - DECLARE_EVENT_TABLE() }; diff --git a/src/threadrecon.cpp b/src/threadrecon.cpp index 03d4d39..0fd94b2 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.6 2001/02/23 18:56:56 kevin Exp $ +** $Id: threadrecon.cpp,v 1.7 2001/02/23 21:58:32 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 @@ -45,7 +45,7 @@ IMPLEMENT_DYNAMIC_CLASS(ReconstructorSupervisor, BackgroundSupervisor) BEGIN_EVENT_TABLE(ReconstructorSupervisor, BackgroundSupervisor) -EVT_MENU(RECONSTRUCTION_THREAD_EVENT, ReconstructorSupervisor::OnThreadEvent) +EVT_MENU(MSG_BACKGROUND_SUPERVISOR_CANCEL, ReconstructorSupervisor::OnCancel) EVT_MENU(MSG_WORKER_THREAD_FAIL, ReconstructorSupervisor::OnWorkerFail) EVT_MENU(MSG_WORKER_THREAD_DONE, ReconstructorSupervisor::OnWorkerDone) EVT_MENU(MSG_WORKER_THREAD_UNIT_TICK, ReconstructorSupervisor::OnWorkerUnitTick) @@ -56,13 +56,13 @@ ReconstructorSupervisor::ReconstructorSupervisor (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_pGauge(NULL), m_bFail(false), m_iNumThreads(0), m_iImageNX(iImageNX), + : m_pDialogProgress(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), BackgroundSupervisor() { m_iNumThreads = theApp->getNumberCPU(); // ++m_iNumThreads; - m_iTotalViews = m_pProjView->GetDocument()->getProjections().nView(); + m_iTotalViews = pProjView->GetDocument()->getProjections().nView(); int iBaseViews = m_iTotalViews / m_iNumThreads; int iExtraViews = m_iTotalViews % m_iNumThreads; @@ -83,7 +83,16 @@ ReconstructorSupervisor::ReconstructorSupervisor (ProjectionFileView* pProjView, break; } } - + m_pProjView = pProjView; + m_pProjDoc = pProjView->GetDocument(); +} + +// Static function +void +BackgroundSupervisor::cancelSupervisor (BackgroundSupervisor* pSupervisor) +{ + wxCommandEvent cancelEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_CANCEL); + wxPostEvent (pSupervisor, cancelEvent); } @@ -93,13 +102,17 @@ ReconstructorSupervisor::start() if (m_bFail) return false; - 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 { std::string strLabel ("Reconstructing "); strLabel += m_pProjView->GetFrame()->GetTitle(); - m_pGauge = theApp->getBackgroundManager()->addTask (this, m_iTotalViews, strLabel.c_str()); + wxCommandEvent addTaskEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_ADD); + addTaskEvent.SetString (strLabel.c_str()); + addTaskEvent.SetInt (m_iTotalViews); + addTaskEvent.SetClientData (this); + wxPostEvent (theApp->getBackgroundManager(), addTaskEvent); + wxPostEvent (m_pProjDoc, addTaskEvent); } m_iRunning = m_iNumThreads; @@ -109,15 +122,12 @@ ReconstructorSupervisor::start() // starting all threads for (int i = 0; i < m_iNumThreads; i++) m_vecpThread[i]->Run(); - - if (m_bCancelled) - return false; - + return true; } void -ReconstructorSupervisor::cancel() +ReconstructorSupervisor::OnCancel(wxCommandEvent& event) { if (isDone() || m_bCancelled) return; @@ -138,23 +148,25 @@ ReconstructorSupervisor::cleanUp() m_vecpThread[i]->Pause(); m_vecpThread[i]->Delete(); } - m_critsectThreadContainer.Leave(); for (i = 0; i < m_iNumThreads; i++) { delete m_vecpChildImageFile[i]; m_vecpChildImageFile[i] = NULL; } + m_critsectThreadContainer.Leave(); m_iNumThreads = 0; m_iRunning = 0; delete m_pDialogProgress; delete m_pTimer; m_pDialogProgress = NULL; - m_pGauge = NULL; setDone(); - m_pProjView->GetDocument()->removeReconstructor (this); - theApp->getBackgroundManager()->taskDone (this); - + + wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE); + doneEvent.SetClientData (this); + wxPostEvent (theApp->getBackgroundManager(), doneEvent); + wxPostEvent (m_pProjDoc, doneEvent); + cleanSection.Leave(); } @@ -164,7 +176,7 @@ ReconstructorSupervisor::onDone() wxCriticalSection doneSection; doneSection.Enter(); - m_pProjView->GetDocument()->removeReconstructor (this); + ImageFileDocument* pReconDoc = theApp->newImageDoc(); if (! pReconDoc) { sys_error (ERR_SEVERE, "Unable to create image file"); @@ -202,32 +214,32 @@ ReconstructorSupervisor::OnWorkerUnitTick (wxCommandEvent& event) if (m_pDialogProgress) m_bCancelling = ! m_pDialogProgress->Update (m_iViewsDone - 1); - else if (m_pGauge) { - m_pGauge->SetValue (m_iViewsDone - 1); - m_bCancelling = theApp->getBackgroundManager()->isCancelling(this); - } - if (! isDone() && m_bCancelling) { - cancel(); - return; + else { + wxCommandEvent addTaskEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_UNIT_TICK); + addTaskEvent.SetInt (m_iViewsDone - 1); + addTaskEvent.SetClientData (this); + wxPostEvent (theApp->getBackgroundManager(), addTaskEvent); } } void ReconstructorSupervisor::OnWorkerDone (wxCommandEvent& event) { - if (isDone()) - return; - m_iRunning--; + wxASSERT (m_iRunning >= 0); m_critsectThreadContainer.Enter(); m_vecpThread[event.GetInt()] = NULL; m_critsectThreadContainer.Leave(); - wxString msg; - msg.Printf("Reconstructor Supervisor: Thread finished. Remaining threads: %d\n", m_iRunning); - wxCommandEvent eventLog (wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - eventLog.SetString( msg ); - wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event +#ifdef DEBUG + if (theApp->getVerboseLogging()) { + wxString msg; + msg.Printf("Reconstructor Supervisor: Thread finished. Remaining threads: %d\n", m_iRunning); + wxCommandEvent eventLog (wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + eventLog.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event + } +#endif if (m_iRunning <= 0) { onDone(); return; @@ -252,15 +264,6 @@ ReconstructorSupervisor::OnWorkerFail (wxCommandEvent& event) } -void -ReconstructorSupervisor::OnThreadEvent (wxCommandEvent& event) -{ - wxString msg; - msg.Printf("Reconstructor Supervisor: Received event #%d\n", event.GetInt()); - wxCommandEvent eventLog( wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); - eventLog.SetString( msg ); - wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event -} ImageFile* ReconstructorSupervisor::getImageFile() diff --git a/src/threadrecon.h b/src/threadrecon.h index 9c1e5e2..e96bb2d 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.6 2001/02/23 18:56:56 kevin Exp $ +** $Id: threadrecon.h,v 1.7 2001/02/23 21:58:32 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 @@ -81,15 +81,17 @@ public: virtual ~BackgroundSupervisor() {} - virtual void cancel() = 0; virtual bool start() = 0; virtual bool testDone() = 0; virtual void OnWorkerFail(wxCommandEvent& event) = 0; virtual void OnWorkerUnitTick(wxCommandEvent& event) = 0; virtual void OnWorkerDone(wxCommandEvent& event) = 0; + virtual void OnCancel(wxCommandEvent& event) = 0; bool isDone() const {return m_bDone;} void setDone() { m_bDone = true; } + + static void cancelSupervisor (BackgroundSupervisor* pSupervisor); }; class Reconstructor; @@ -107,9 +109,9 @@ private: std::vector m_vecpChildImageFile; typedef std::vector ThreadContainer; ThreadContainer m_vecpThread; + ProjectionFileDocument* m_pProjDoc; ProjectionFileView* m_pProjView; wxProgressDialog* m_pDialogProgress; - wxGauge* m_pGauge; volatile bool m_bFail; int m_iNumThreads; @@ -136,9 +138,6 @@ public: ~ReconstructorSupervisor (); - void OnThreadEvent (wxCommandEvent& event); - void cancel(); - void onDone(); bool start(); bool fail() const {return m_bFail;} @@ -147,6 +146,7 @@ public: virtual void OnWorkerFail(wxCommandEvent& event); virtual void OnWorkerUnitTick(wxCommandEvent& event); virtual void OnWorkerDone(wxCommandEvent& event); + virtual void OnCancel(wxCommandEvent& event); ImageFile* getImageFile(); diff --git a/src/views.cpp b/src/views.cpp index 888b9b4..8203cbc 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.115 2001/02/23 18:56:56 kevin Exp $ +** $Id: views.cpp,v 1.116 2001/02/23 21:58:32 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 @@ -1001,6 +1001,10 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) double scaleWidth = m_dMaxPixel - m_dMinPixel; unsigned char* imageData = new unsigned char [nx * ny * 3]; + if (! imageData) { + sys_error (ERR_SEVERE, "Unable to allocate memory for Image display"); + return; + } for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) { double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255; @@ -2637,6 +2641,10 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } unsigned char* imageData = new unsigned char [nDet * nView * 3]; + if (! imageData) { + sys_error (ERR_SEVERE, "Unable to allocate memory for image display"); + return; + } double scale = (max - min) / 255; for (int iy2 = 0; iy2 < nView; iy2++) { const DetectorArray& detarray = rProj.getDetectorArray (iy2); -- 2.34.1