r589: Added threaded rasterizer
[ctsim.git] / src / threadraster.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          threadraster.h
5 **   Purpose:       Header file for threaded rasterizations
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: threadraster.h,v 1.1 2001/02/27 03:59:30 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 _THREADRASTER_H
29 #define _THREADRASTER_H
30
31 #include <vector>
32 #include <wx/thread.h>
33 #include <wx/progdlg.h>
34 #include "timer.h"
35 #include "backgroundsupr.h"
36
37
38 class Reconstructor;
39 class ImageFile;
40 class PhantomFileDocument;
41 class RasterizerWorker;
42 class ImageFileView;
43
44 class RasterizerSupervisorThread : public SupervisorThread {
45 private:
46   PhantomFileView* m_pPhantomView;
47   const int m_iNX;
48   const int m_iNY;
49   const int m_iNSample;
50   const double m_dViewRatio;
51   const std::string m_strLabel;
52
53 public:
54   RasterizerSupervisorThread(PhantomFileView* pProjView, int iNX, int iNY, int iNSample, double dViewRatio, const char* const pszLabel);
55
56   virtual wxThread::ExitCode Entry();
57
58   virtual void OnExit();
59 };
60
61
62
63 class RasterizerSupervisor : public BackgroundSupervisor {
64 private:
65
66   std::vector<ImageFile*> m_vecpChildImageFiles;
67   PhantomFileDocument* m_pPhantomDoc;
68   PhantomFileView* m_pPhantomView;
69   
70   const int m_iNX;
71   const int m_iNY;
72   const int m_iNSample;
73   const double m_dViewRatio;
74   const char* const m_pszLabel;
75
76
77 public:
78    RasterizerSupervisor (SupervisorThread* pThread, PhantomFileView* pProjView, int iNX, int iNY, 
79    int iNSample, double dViewRatio, const char* const pszLabel);
80
81    virtual BackgroundWorkerThread* createWorker (int iThread, int iStartUnit, int iNumUnits);
82
83    virtual ~RasterizerSupervisor ();
84
85   void onDone();
86
87   ImageFile* getImageFile();
88
89 };
90
91
92
93
94 class RasterizerWorker : public BackgroundWorkerThread {
95 private:
96   PhantomFileView* m_pPhantomView;
97   ImageFile* m_pImageFile;
98   int m_iNX;
99   int m_iNY;
100   int m_iNSample;
101   double m_dViewRatio;
102
103
104 public:
105   RasterizerWorker (RasterizerSupervisor* pSupervisor, int iThread, int iStartView, int iNumViews) 
106     : BackgroundWorkerThread (pSupervisor, iThread, iStartView, iNumViews)
107   {}
108   
109   void SetParameters (PhantomFileView* pPhantomFile, ImageFile* pImageFile, int iNX, int iY, 
110    int iNSample, double dViewRatio);
111
112   virtual wxThread::ExitCode Entry();      // thread execution starts here
113
114   virtual void OnExit();
115 };
116
117
118 #endif
119