Applied initial patches for wx2.8 compatibility
[ctsim.git] / src / threadrecon.h
index 9c1e5e26783b274ca43eabfe13cf579049555c41..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.6 2001/02/23 18:56:56 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"
-
-// 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;
+struct ReconstructionROI;
 
-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 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);
 
-  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
+  virtual wxThread::ExitCode Entry();
 
-    MSG_WORKER_THREAD_UNIT_TICK = 7504,
-    MSG_WORKER_THREAD_DONE = 7505,
-    MSG_WORKER_THREAD_FAIL = 7506,   // sent by workers when they fail
-  };
-
-  BackgroundSupervisor()
-    : m_bDone(false), wxEvtHandler()
-  {}
-
-  virtual ~BackgroundSupervisor()
-  {}
-
-  virtual void cancel() = 0;
-  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;
-
-  bool isDone() const {return m_bDone;}
-  void setDone() { m_bDone = true; }
+  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;
+  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;
-  wxString m_strLabel;
-  Timer* m_pTimer;
-  bool m_bCancelled;
-  bool m_bCancelling;
 
-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);
+  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;
 
-   ReconstructorSupervisor ()
-     : m_bFail(true), m_iNumThreads(0), m_iImageNX(0), m_iImageNY(0), m_iTotalViews(0), 
-     BackgroundSupervisor()
-   {}
+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);
 
-   ~ReconstructorSupervisor ();
+   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();
-  virtual void OnWorkerFail(wxCommandEvent& event);
-  virtual void OnWorkerUnitTick(wxCommandEvent& event);
-  virtual void OnWorkerDone(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;
+  const Projections* m_pProj;
   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;
+  ReconstructionROI* m_pReconROI;
 
 public:
-  ReconstructorWorker (ReconstructorSupervisor* pSupervisor, 
-    ProjectionFileView* pProjFile, ImageFile* pImageFile, 
-    int iThread, int iStartView, int iNumViews,
-   const char* const pszFilterName, double dFilterParam, const char* const pszFilterMethod, 
+  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);
+   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
-