X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fthreadrecon.h;h=ff74bba9321bd3811c8cdfdd33030873c03db898;hp=53368fa94fd496724ede052095c63984e8e976ca;hb=f7ee98f7d964ed361068179f0e7ea4475ed1abdf;hpb=0730f9f3adbf326b9d4bac754634399ad688efd1 diff --git a/src/threadrecon.h b/src/threadrecon.h index 53368fa..ff74bba 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.1 2001/02/22 11:05:38 kevin Exp $ +** $Id$ ** ** 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 @@ -28,88 +28,123 @@ #ifndef _THREADRECON_H #define _THREADRECON_H +#ifdef HAVE_WXTHREADS + + #include #include #include #include "timer.h" +#include "backgroundsupr.h" class Reconstructor; class ImageFile; class ProjectionFileDocument; -class ReconstructionThread; +class ReconstructorWorker; class ProjectionFileView; +struct ReconstructionROI; + +class ReconstructorSupervisorThread : public SupervisorThread { +private: + 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 wxString m_strLabel; + ReconstructionROI m_reconROI; + const bool m_bRebinToParallel; + +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, wxChar const* pszLabel, + ReconstructionROI* pROI, bool bRebinToParallel); + + virtual wxThread::ExitCode Entry(); + + virtual void OnExit(); +}; + + -class ThreadedReconstructor : public wxEvtHandler { +class ReconstructorSupervisor : public BackgroundSupervisor { private: - DECLARE_DYNAMIC_CLASS(ThreadedReconstructor) - std::vector m_vecpReconstructor; std::vector m_vecpChildImageFile; - std::vector m_vecpThread; + const Projections* m_pProj; ProjectionFileView* m_pProjView; - wxProgressDialog* m_pDialogProgress; - - volatile bool m_bFail; - int m_iNumThreads; + ProjectionFileDocument* m_pProjDoc; + const int m_iImageNX; const int m_iImageNY; - volatile int m_iRunning; - volatile unsigned int m_iViewsDone; - volatile unsigned int m_iTotalViews; - wxCriticalSection m_criticalSection; - wxString m_strLabel; - Timer* m_pTimer; - bool m_bCancelled; - bool m_bCancelling; - bool m_bDone; -public: - ThreadedReconstructor (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); + 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 wxString m_strLabel; + ReconstructionROI* m_pReconROI; - ThreadedReconstructor () - : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0) - {} +public: + ReconstructorSupervisor (SupervisorThread* pMyThread, Projections* pProj, 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, wxChar const* pszLabel, ReconstructionROI* pReconROI); - ~ThreadedReconstructor (); + virtual BackgroundWorkerThread* createWorker (int iThread, int iStartUnit, int iNumUnits); - void OnThreadEvent (wxCommandEvent& event); - bool testDone(); - void cancel(); + virtual ~ReconstructorSupervisor (); void onDone(); - bool start(); - bool fail() const {return m_bFail;} - bool getDone() const {return m_bDone;} - ImageFile* getImageFile() const; + ImageFile* getImageFile(); - DECLARE_EVENT_TABLE() }; - -class ReconstructionThread : public wxThread { +class ReconstructorWorker : public BackgroundWorkerThread { private: - ThreadedReconstructor* m_pSupervisor; - Reconstructor* m_pReconstructor; - int m_iStartView; - int m_iNumViews; - int m_iThread; + const Projections* m_pProj; + ProjectionFileView* m_pProjView; + ImageFile* m_pImageFile; + 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; + ReconstructionROI* m_pReconROI; public: - ReconstructionThread (ThreadedReconstructor* pSupervisor, Reconstructor* pReconstructor, - int iThread, int iStartView, int iNumViews); + ReconstructorWorker (ReconstructorSupervisor* pSupervisor, int iThread, int iStartView, int iNumViews) + : BackgroundWorkerThread (pSupervisor, iThread, iStartView, iNumViews) + {} + + void SetParameters (const Projections* pProj, 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, ReconstructionROI* pROI); virtual wxThread::ExitCode Entry(); // thread execution starts here - // called when the thread exits - whether it terminates normally or is - // stopped with Delete() (but not when it is Kill()ed!) - virtual void OnExit(); + virtual void OnExit(); }; +#endif // HAVE_WXTHREADS +#endif // _THREADRECON_H_ -#endif