1 /*****************************************************************************
5 ** Purpose: Header file for thread reconstructions
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: February 2001
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2001 Kevin Rosenberg
12 ** $Id: threadrecon.h,v 1.4 2001/02/23 02:06:02 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
28 #ifndef _THREADRECON_H
29 #define _THREADRECON_H
32 #include <wx/thread.h>
33 #include <wx/progdlg.h>
36 // This thread creates a BackgroundTask event handler object
37 // The thread is detached and terminates when BackgroundTask terminates
38 class BackgroundTaskThread : public wxThread {
42 BackgroundTaskThread();
44 virtual wxThread::ExitCode Entry();
46 // called when the thread exits - whether it terminates normally or is stopped with Delete()
47 virtual void OnExit();
51 class BackgroundTask : public wxEvtHandler {
57 : m_bDone(false), wxEvtHandler()
60 virtual ~BackgroundTask()
63 virtual void cancel() = 0;
64 virtual bool start() = 0;
65 virtual bool testDone() = 0;
67 bool isDone() const {return m_bDone;}
68 void setDone() { m_bDone = true; }
73 class ProjectionFileDocument;
74 class ReconstructionThread;
75 class ProjectionFileView;
77 class ThreadedReconstructor : public BackgroundTask {
79 DECLARE_DYNAMIC_CLASS(ThreadedReconstructor)
81 std::vector<Reconstructor*> m_vecpReconstructor;
82 std::vector<ImageFile*> m_vecpChildImageFile;
83 std::vector<ReconstructionThread*> m_vecpThread;
84 ProjectionFileView* m_pProjView;
85 wxProgressDialog* m_pDialogProgress;
88 volatile bool m_bFail;
92 volatile int m_iRunning;
93 volatile unsigned int m_iViewsDone;
94 volatile unsigned int m_iTotalViews;
95 //wxCriticalSection m_criticalSection;
102 ThreadedReconstructor (ProjectionFileView* pProjView,
103 int iNX, int iNY, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod,
104 int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam,
105 const char* pszBackprojectName, const char* const pszLabel);
107 ThreadedReconstructor ()
108 : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0), BackgroundTask()
111 ~ThreadedReconstructor ();
113 void OnThreadEvent (wxCommandEvent& event);
118 bool fail() const {return m_bFail;}
122 ImageFile* getImageFile();
124 DECLARE_EVENT_TABLE()
129 class ReconstructionThread : public wxThread {
131 ThreadedReconstructor* m_pSupervisor;
132 Reconstructor* m_pReconstructor;
138 ReconstructionThread (ThreadedReconstructor* pSupervisor, Reconstructor* pReconstructor,
139 int iThread, int iStartView, int iNumViews);
141 virtual wxThread::ExitCode Entry(); // thread execution starts here
143 // called when the thread exits - whether it terminates normally or is stopped with Delete()
144 virtual void OnExit();