r571: no message
[ctsim.git] / src / threadrecon.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          threadrecon.h
5 **   Purpose:       Header file for thread reconstructions
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  February 2001
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: threadrecon.h,v 1.1 2001/02/22 11:05:38 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifndef _THREADRECON_H
29 #define _THREADRECON_H
30
31 #include <vector>
32 #include <wx/thread.h>
33 #include <wx/progdlg.h>
34 #include "timer.h"
35
36
37 class Reconstructor;
38 class ImageFile;
39 class ProjectionFileDocument;
40 class ReconstructionThread;
41 class ProjectionFileView;
42
43 class ThreadedReconstructor : public wxEvtHandler {
44 private:
45   DECLARE_DYNAMIC_CLASS(ThreadedReconstructor)
46
47   std::vector<Reconstructor*> m_vecpReconstructor;
48   std::vector<ImageFile*> m_vecpChildImageFile;
49   std::vector<ReconstructionThread*> m_vecpThread;
50   ProjectionFileView* m_pProjView;
51   wxProgressDialog* m_pDialogProgress;
52   
53   volatile bool m_bFail;
54   int m_iNumThreads;
55   const int m_iImageNX;
56   const int m_iImageNY;
57   volatile int m_iRunning;
58   volatile unsigned int m_iViewsDone;
59   volatile unsigned int m_iTotalViews;
60   wxCriticalSection m_criticalSection;
61   wxString m_strLabel;
62   Timer* m_pTimer;
63   bool m_bCancelled;
64   bool m_bCancelling;
65   bool m_bDone;
66
67 public:
68    ThreadedReconstructor (ProjectionFileView* pProjView, 
69    int iNX, int iNY, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, 
70    int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam,
71    const char* pszBackprojectName, const char* const pszLabel);
72
73    ThreadedReconstructor ()
74      : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0)
75    {}
76
77    ~ThreadedReconstructor ();
78
79   void OnThreadEvent (wxCommandEvent& event);
80   bool testDone();
81   void cancel();
82
83   void onDone();
84   bool start();
85   bool fail() const {return m_bFail;}
86   bool getDone() const {return m_bDone;}
87
88   ImageFile* getImageFile() const;
89
90   DECLARE_EVENT_TABLE()
91 };
92
93
94
95 class ReconstructionThread : public wxThread {
96 private:
97   ThreadedReconstructor* m_pSupervisor;
98   Reconstructor* m_pReconstructor;
99   int m_iStartView;
100   int m_iNumViews;
101   int m_iThread;
102
103 public:
104   ReconstructionThread (ThreadedReconstructor* pSupervisor, Reconstructor* pReconstructor, 
105     int iThread, int iStartView, int iNumViews);
106
107   virtual wxThread::ExitCode Entry();      // thread execution starts here
108
109     // called when the thread exits - whether it terminates normally or is
110     // stopped with Delete() (but not when it is Kill()ed!)
111     virtual void OnExit();
112 };
113
114
115 #endif