Applied initial patches for wx2.8 compatibility
[ctsim.git] / src / threadrecon.h
index e9ab35ee508f627b5ef3b96d56469d05f3b7be6e..ff74bba9321bd3811c8cdfdd33030873c03db898 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2001 Kevin Rosenberg
 **
-**  $Id: threadrecon.h,v 1.4 2001/02/23 02:06:02 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
 #ifndef _THREADRECON_H
 #define _THREADRECON_H
 
+#ifdef HAVE_WXTHREADS
+
+
 #include <vector>
 #include <wx/thread.h>
 #include <wx/progdlg.h>
 #include "timer.h"
+#include "backgroundsupr.h"
+
+
+class Reconstructor;
+class ImageFile;
+class ProjectionFileDocument;
+class ReconstructorWorker;
+class ProjectionFileView;
+struct ReconstructionROI;
 
-// This thread creates a BackgroundTask event handler object
-// The thread is detached and terminates when BackgroundTask terminates
-class BackgroundTaskThread : public wxThread {
+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:
-  BackgroundTaskThread();
+  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();
 
-  // called when the thread exits - whether it terminates normally or is stopped with Delete()
   virtual void OnExit();
 };
 
 
-class BackgroundTask : public wxEvtHandler {
-private:
-  bool m_bDone;
-
-public:
-  BackgroundTask()
-    : m_bDone(false), wxEvtHandler()
-  {}
-
-  virtual ~BackgroundTask()
-  {}
-
-  virtual void cancel() = 0;
-  virtual bool start() = 0;
-  virtual bool testDone() = 0;
-
-  bool isDone() const {return m_bDone;}
-  void setDone() { m_bDone = true; }
-};
-
-class Reconstructor;
-class ImageFile;
-class ProjectionFileDocument;
-class ReconstructionThread;
-class ProjectionFileView;
 
-class ThreadedReconstructor : public BackgroundTask {
+class ReconstructorSupervisor : public BackgroundSupervisor {
 private:
-  DECLARE_DYNAMIC_CLASS(ThreadedReconstructor)
 
-  std::vector<Reconstructor*> m_vecpReconstructor;
   std::vector<ImageFile*> m_vecpChildImageFile;
-  std::vector<ReconstructionThread*> m_vecpThread;
+  const Projections* m_pProj;
   ProjectionFileView* m_pProjView;
-  wxProgressDialog* m_pDialogProgress;
-  wxGauge* m_pGauge;
-  
-  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;
 
-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), BackgroundTask()
-   {}
+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);
-  void cancel();
+   virtual ~ReconstructorSupervisor ();
 
   void onDone();
-  bool start();
-  bool fail() const {return m_bFail;}
-  bool testDone();
-  void cleanUp();
 
   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()
   virtual void OnExit();
 };
 
+#endif // HAVE_WXTHREADS
+#endif // _THREADRECON_H_
 
-#endif