** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: threadrecon.h,v 1.7 2001/02/23 21:58:32 kevin Exp $
+** $Id: threadrecon.h,v 1.12 2001/03/05 19:14:40 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
#ifndef _THREADRECON_H
#define _THREADRECON_H
+#ifdef HAVE_WXTHREADS
+
+
#include <vector>
#include <wx/thread.h>
#include <wx/progdlg.h>
#include "timer.h"
-
-// This thread creates a SupervisorTask event handler object
-// The thread is detached and terminates when SupervisorTask terminates
-class SupervisorTaskThread : public wxThread {
-private:
-
-public:
- SupervisorTaskThread();
-
- virtual wxThread::ExitCode Entry() = 0;
-
- // called when the thread exits - whether it terminates normally or is stopped with Delete()
- virtual void OnExit();
-};
-
-
-class ReconstructorSupervisorThread : public SupervisorTaskThread {
-private:
-public:
-};
+#include "backgroundsupr.h"
-// Pure virtual class for BackgroundSupervisor that can communication
-// with BackgroundManager via messages
+class Reconstructor;
+class ImageFile;
+class ProjectionFileDocument;
+class ReconstructorWorker;
+class ProjectionFileView;
-class BackgroundSupervisor : public wxEvtHandler {
+class ReconstructorSupervisorThread : public SupervisorThread {
private:
- bool m_bDone;
+ ProjectionFileView* m_pProjView;
+ ImageFile* m_pImageFile;
+ const int m_iNX;
+ const int m_iNY;
+ const std::string m_strFilterName;
+ const double m_dFilterParam;
+ const std::string m_strFilterMethod;
+ const int m_iZeropad;
+ const std::string m_strFilterGenerationName;
+ const std::string m_strInterpName;
+ const int m_iInterpParam;
+ const std::string m_strBackprojectName;
+ const std::string m_strLabel;
public:
+ ReconstructorSupervisorThread(ProjectionFileView* pProjView, int iNX, int iNY, 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);
- enum {
- MSG_BACKGROUND_SUPERVISOR_ADD = 7500, // sends to BackgroundManager and Document
- MSG_BACKGROUND_SUPERVISOR_REMOVE = 7501, // sends to BackgroundManager and Document
- MSG_BACKGROUND_SUPERVISOR_UNIT_TICK = 7502, // sends to BackgroundManager for progress bars
- MSG_BACKGROUND_SUPERVISOR_CANCEL = 7503, // *sent* to Supervisor to cancel process
-
- MSG_WORKER_THREAD_UNIT_TICK = 7504,
- MSG_WORKER_THREAD_DONE = 7505,
- MSG_WORKER_THREAD_FAIL = 7506, // sent by workers when they fail
- };
+ virtual wxThread::ExitCode Entry();
- BackgroundSupervisor()
- : m_bDone(false), wxEvtHandler()
- {}
-
- virtual ~BackgroundSupervisor()
- {}
-
- 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);
+ virtual void OnExit();
};
-class Reconstructor;
-class ImageFile;
-class ProjectionFileDocument;
-class ReconstructorWorker;
-class ProjectionFileView;
class ReconstructorSupervisor : public BackgroundSupervisor {
private:
- DECLARE_DYNAMIC_CLASS(ReconstructorSupervisor)
- wxCriticalSection m_critsectThreadContainer;
std::vector<ImageFile*> m_vecpChildImageFile;
- typedef std::vector<ReconstructorWorker*> ThreadContainer;
- ThreadContainer m_vecpThread;
- ProjectionFileDocument* m_pProjDoc;
ProjectionFileView* m_pProjView;
- wxProgressDialog* m_pDialogProgress;
+ ProjectionFileDocument* m_pProjDoc;
- volatile bool m_bFail;
- int m_iNumThreads;
const int m_iImageNX;
const int m_iImageNY;
- volatile int m_iRunning;
- volatile unsigned int m_iViewsDone;
- volatile unsigned int m_iTotalViews;
- wxString m_strLabel;
- Timer* m_pTimer;
- bool m_bCancelled;
- bool m_bCancelling;
+
+ const char* const m_pszFilterName;
+ const double m_dFilterParam;
+ const char* const m_pszFilterMethod;
+ const int m_iZeropad;
+ const char* const m_pszFilterGenerationName;
+ const char* const m_pszInterpName;
+ const int m_iInterpParam;
+ const char* const m_pszBackprojectName;
+ const char* const m_pszLabel;
public:
- ReconstructorSupervisor (ProjectionFileView* pProjView,
- int iNX, int iNY, 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);
+ ReconstructorSupervisor (SupervisorThread* pMyThread, ProjectionFileView* pProjView, int iNX, int iNY, 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);
- ReconstructorSupervisor ()
- : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0),
- BackgroundSupervisor()
- {}
+ virtual BackgroundWorkerThread* createWorker (int iThread, int iStartUnit, int iNumUnits);
- ~ReconstructorSupervisor ();
+ virtual ~ReconstructorSupervisor ();
void onDone();
- bool start();
- bool fail() const {return m_bFail;}
- bool testDone();
- void cleanUp();
- virtual void OnWorkerFail(wxCommandEvent& event);
- virtual void OnWorkerUnitTick(wxCommandEvent& event);
- virtual void OnWorkerDone(wxCommandEvent& event);
- virtual void OnCancel(wxCommandEvent& event);
ImageFile* getImageFile();
- DECLARE_EVENT_TABLE()
};
-class ReconstructorWorker : public wxThread {
+
+class ReconstructorWorker : public BackgroundWorkerThread {
private:
- ReconstructorSupervisor* m_pSupervisor;
- int m_iStartView;
- int m_iNumViews;
- int m_iThread;
ProjectionFileView* m_pProjView;
ImageFile* m_pImageFile;
- const std::string m_strFilterName;
- const double m_dFilterParam;
- const std::string m_strFilterMethod;
- const int m_iZeropad;
- const std::string m_strFilterGenerationName;
- const std::string m_strInterpName;
- const int m_iInterpParam;
- const std::string m_strBackprojectName;
+ const char* m_pszFilterName;
+ double m_dFilterParam;
+ const char* m_pszFilterMethod;
+ int m_iZeropad;
+ const char* m_pszFilterGenerationName;
+ const char* m_pszInterpName;
+ int m_iInterpParam;
+ const char* m_pszBackprojectName;
public:
- ReconstructorWorker (ReconstructorSupervisor* pSupervisor,
- ProjectionFileView* pProjFile, ImageFile* pImageFile,
- int iThread, int iStartView, int iNumViews,
+ ReconstructorWorker (ReconstructorSupervisor* pSupervisor, int iThread, int iStartView, int iNumViews)
+ : BackgroundWorkerThread (pSupervisor, iThread, iStartView, iNumViews)
+ {}
+
+ 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);
virtual wxThread::ExitCode Entry(); // thread execution starts here
- // called when the thread exits - whether it terminates normally or is stopped with Delete()
virtual void OnExit();
};
-
-#endif
+#endif // HAVE_WXTHREADS
+#endif // _THREADRECON_H_