** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: threadrecon.cpp,v 1.1 2001/02/22 11:05:38 kevin Exp $
+** $Id: threadrecon.cpp,v 1.2 2001/02/22 15:00:20 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
#include "docs.h"
#include "views.h"
#include "threadrecon.h"
+#include "backgroundmgr.h"
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
-IMPLEMENT_DYNAMIC_CLASS(ThreadedReconstructor, wxEvtHandler)
-BEGIN_EVENT_TABLE(ThreadedReconstructor, wxEvtHandler)
+IMPLEMENT_DYNAMIC_CLASS(ThreadedReconstructor, BackgroundTask)
+BEGIN_EVENT_TABLE(ThreadedReconstructor, BackgroundTask)
EVT_MENU(RECONSTRUCTION_THREAD_EVENT, ThreadedReconstructor::OnThreadEvent)
END_EVENT_TABLE()
int iImageNX, int iImageNY, 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)
- : m_pProjView(pProjView), m_pDialogProgress(NULL), m_bFail(false), m_iNumThreads(0), m_iImageNX(iImageNX),
+ : m_pProjView(pProjView), m_pDialogProgress(NULL), m_pGauge(NULL), m_bFail(false), m_iNumThreads(0), m_iImageNX(iImageNX),
m_iImageNY(iImageNY), m_strLabel(pszLabel), m_pTimer(NULL), m_bCancelled(false), m_bCancelling(false),
- m_bDone(false), wxEvtHandler()
+ m_bDone(false), BackgroundTask()
{
m_iNumThreads = theApp->getNumberCPU();
// ++m_iNumThreads;
}
}
- m_pProjView->GetDocument()->addReconstructor (this);
- // m_pDialogProgress = new wxProgressDialog (_T("Filtered Backprojection"), _T("Reconstruction Progress"), m_iTotalViews, pProjView->getFrame(), wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
}
if (m_bFail)
return false;
- // starting all threads
+ m_pProjView->GetDocument()->addReconstructor (this);
+ if (! theApp->getUseBackgroundTasks())
+ m_pDialogProgress = new wxProgressDialog (_T("Filtered Backprojection"), _T("Reconstruction Progress"), m_iTotalViews, m_pProjView->getFrame(), wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
+ else
+ m_pGauge = theApp->getBackgroundManager()->addTask (this, m_iTotalViews);
+
m_iRunning = m_iNumThreads;
m_iViewsDone = 0;
m_pTimer = new Timer;
-// theApp->addBackgroundTask (this, m_iTotalViews);
- int i;
- for (i = 0; i < m_iNumThreads; i++)
+ // starting all threads
+ for (int i = 0; i < m_iNumThreads; i++)
m_vecpThread[i]->Run();
m_pProjView->GetDocument()->removeReconstructor (this);
m_bCancelled = true;
m_bDone = true;
- // theApp->removeBackgroundTask (this);
+ theApp->getBackgroundManager()->taskDone (this);
}
void
wxIdleEvent event;
theApp->OnIdle(event);
m_bDone = true;
- // theApp->removeBackgroundTask (this);
+ theApp->getBackgroundManager()->taskDone (this);
// delete this;
}
if (m_pDialogProgress)
m_bCancelling = ! m_pDialogProgress->Update (m_iViewsDone - 1);
-
- // m_bCancelling = theApp->updateBackgroundTask (this, m_iViewsDone);
+ else if (m_pGauge) {
+ m_pGauge->SetValue (m_iViewsDone - 1);
+ m_bCancelling = theApp->getBackgroundManager()->isCancelling(this);
+ }
if (m_iViewsDone == m_iTotalViews) {
delete m_pDialogProgress;
m_pDialogProgress = NULL;