--------------------Configuration: ctsim - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1681.tmp" with contents
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP45.tmp" with contents
[
-/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /I "\dicom\ctn\include" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.1.0\" /D "HAVE_CTN_DICOM" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX"ctsim.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
-"D:\ctsim\src\backgroundmgr.cpp"
+/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /I "\dicom\ctn\include" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.1.0\" /D "HAVE_CTN_DICOM" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
+"C:\ctsim\src\backgroundmgr.cpp"
]
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1681.tmp"
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1682.tmp" with contents
+Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP45.tmp"
+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP46.tmp" with contents
[
winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib htmlhelp.lib ctn_lib.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" /libpath:"\dicom\ctn\winctn\ctn_lib\Debug"
.\Debug\backgroundmgr.obj
\wx2.2.5\lib\zlibd.lib
\wx2.2.5\lib\tiffd.lib
]
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP1682.tmp"
+Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP46.tmp"
<h3>Output Window</h3>
Compiling...
backgroundmgr.cpp
** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: backgroundmgr.cpp,v 1.14 2001/03/09 18:50:46 kevin Exp $
+** $Id: backgroundmgr.cpp,v 1.15 2001/03/09 21:31:51 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
#ifdef HAVE_WXTHREADS
+int BackgroundManager::s_iNextButtonID = 0;
IMPLEMENT_DYNAMIC_CLASS(BackgroundManager, wxMiniFrame)
BEGIN_EVENT_TABLE(BackgroundManager, wxMiniFrame)
EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_REMOVE, BackgroundManager::OnRemoveTask)
EVT_MENU(BackgroundSupervisor::MSG_BACKGROUND_SUPERVISOR_UNIT_TICK, BackgroundManager::OnUnitTick)
EVT_CLOSE(BackgroundManager::OnCloseWindow)
-EVT_COMMAND_RANGE(0, 1000, wxEVT_COMMAND_BUTTON_CLICKED, BackgroundManager::OnCancelButton)
+EVT_COMMAND_RANGE(0, 30000, wxEVT_COMMAND_BUTTON_CLICKED, BackgroundManager::OnCancelButton)
END_EVENT_TABLE()
m_sizeBorder.Set (4, 4);
m_sizeCellSpacing.Set (3, 3);
m_sizeButton.Set (70, 20);
- m_sizeButton.Set (0, 0);
m_sizeCell.Set (m_sizeGauge.x + m_sizeLabel.x + m_sizeCellSpacing.x + m_sizeButton.x, 25);
wxPoint posButton (m_sizeBorder.x + m_sizeGauge.x + m_sizeLabel.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y);
wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, posGauge, m_sizeGauge);
wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, pszTaskName, posLabel, m_sizeLabel);
- wxButton* pButton = NULL; // new wxButton (m_pCanvas, reinterpret_cast<wxWindowID>(pSupervisor), _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT);
+ wxButton* pButton = new wxButton (m_pCanvas, s_iNextButtonID, _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT);
- BackgroundManagerTask* pTask = new BackgroundManagerTask (pSupervisor, pszTaskName, iFirstUnusedPos, pGauge, pLabel, pButton);
+ BackgroundManagerTask* pTask = new BackgroundManagerTask (pSupervisor, pszTaskName,
+ iFirstUnusedPos, pGauge, pLabel, pButton, s_iNextButtonID);
m_vecpTasks.push_back (pTask);
m_iNumTasks++;
+ s_iNextButtonID++;
resizeWindow();
if (m_iNumTasks == 1) {
bool bFound = false;
for (TaskContainer::iterator iTask = m_vecpTasks.begin(); iTask != m_vecpTasks.end(); iTask++) {
if ((*iTask)->supervisor() == pSupervisor) {
- delete (*iTask)->gauge();
- delete (*iTask)->label();
- delete (*iTask)->button();
+ delete (*iTask)->gauge();
+ delete (*iTask)->label();
+ delete (*iTask)->button();
delete *iTask;
m_vecpTasks.erase (iTask);
m_iNumTasks--;
- bFound = true;
+ bFound = true;
break;
}
}
- if (! bFound)
+ if (! bFound) {
sys_error (ERR_SEVERE, "Unable to find supervisor [BackgroundManager::OnRemoveTask]");
-
+ return;
+ }
+ pSupervisor->ackRemoveBackgroundManager();
resizeWindow();
if (m_iNumTasks <= 0)
Show(false);
void
BackgroundManager::OnCancelButton (wxCommandEvent& event)
{
+ BackgroundManagerTask* pTask = lookupTask (event.GetId());
+ if (! pTask) {
+ sys_error (ERR_SEVERE, "Unable to lookup task for button");
+ return;
+ }
+
+ pTask->supervisor()->onCancel();
}
BackgroundManagerTask*
return pTask;
}
+BackgroundManagerTask*
+BackgroundManager::lookupTask (int iButtonID)
+{
+ BackgroundManagerTask* pTask = NULL;
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ for (TaskContainer::iterator iTask = m_vecpTasks.begin(); iTask != m_vecpTasks.end(); iTask++) {
+ if ((*iTask)->buttonID() == iButtonID) {
+ pTask = *iTask;
+ break;
+ }
+ }
+
+ return pTask;
+}
+
void
BackgroundManager::resizeWindow()
{
** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: backgroundmgr.h,v 1.10 2001/03/09 18:50:46 kevin Exp $
+** $Id: backgroundmgr.h,v 1.11 2001/03/09 21:31:51 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
void resizeWindow();
BackgroundManagerTask* lookupTask (BackgroundSupervisor* pSupervisor);
+ BackgroundManagerTask* lookupTask (int iButtonID);
+
+ static int s_iNextButtonID;
wxSize m_sizeGauge;
wxSize m_sizeLabel;
wxSize m_sizeBorder;
wxSize m_sizeCellSpacing;
wxSize m_sizeButton;
-
+
public:
BackgroundManager ();
~BackgroundManager();
class BackgroundSupervisor;
class BackgroundManagerTask {
private:
- const BackgroundSupervisor* m_pSupervisor;
+ BackgroundSupervisor* m_pSupervisor;
const std::string m_strName;
const int m_iPosition;
wxGauge* m_pGauge;
wxStaticText* m_pLabel;
wxButton* m_pButton;
+ const int m_iButtonID;
public:
BackgroundManagerTask (BackgroundSupervisor* pSupervisor, const char* const pszName, int iPos,
- wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton)
- : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge), m_pLabel(pLabel), m_pButton(pButton)
+ wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton, int iButtonID)
+ : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge),
+ m_pLabel(pLabel), m_pButton(pButton), m_iButtonID(iButtonID)
{}
int position() const {return m_iPosition;}
const std::string& name() const {return m_strName;}
- const BackgroundSupervisor* supervisor() const {return m_pSupervisor;}
+ BackgroundSupervisor* supervisor() {return m_pSupervisor;}
wxGauge* gauge() {return m_pGauge;}
wxStaticText* label() {return m_pLabel;}
wxButton* button() {return m_pButton;}
+ int buttonID() const {return m_iButtonID;}
};
** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: backgroundsupr.cpp,v 1.17 2001/03/09 02:40:17 kevin Exp $
+** $Id: backgroundsupr.cpp,v 1.18 2001/03/09 21:31:51 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
BackgroundSupervisor::BackgroundSupervisor (SupervisorThread* pMyThread, wxFrame* pParentFrame, BackgroundProcessingDocument* pDocument, const char* const pszProcessTitle, int iTotalUnits)
: wxEvtHandler(), m_pMyThread(pMyThread), m_pParentFrame(pParentFrame), m_pDocument(pDocument), m_strProcessTitle(pszProcessTitle),
m_iTotalUnits(iTotalUnits), m_iNumThreads(0), m_bDone(false), m_bFail(false), m_bCancelled(false), m_iRunning(0),
- m_pTimer(NULL), m_bWorkersDeleted(false)
+ m_pTimer(NULL), m_bWorkersDeleted(false), m_bBackgroundManagerAdded(false)
{
m_iNumThreads = theApp->getNumberCPU();
// ++m_iNumThreads;
BackgroundSupervisor::~BackgroundSupervisor()
{
-#ifdef USE_BKGMGR
- wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE);
- doneEvent.SetClientData (this);
- wxPostEvent (theApp->getBackgroundManager(), doneEvent);
-#endif
-
m_pDocument->removeBackgroundSupervisor (this);
delete m_pTimer;
if (m_vecpThreads[i])
m_vecpThreads[i]->Delete(); // send Destroy message to workers
- while (m_iRunning > 0)
+#ifdef USE_BKGMGR
+ wxCommandEvent doneEvent (wxEVT_COMMAND_MENU_SELECTED, MSG_BACKGROUND_SUPERVISOR_REMOVE);
+ doneEvent.SetClientData (this);
+ wxPostEvent (theApp->getBackgroundManager(), doneEvent);
+#endif
+
+ while (m_iRunning > 0 || m_bBackgroundManagerAdded)
m_pMyThread->Sleep(50);
m_bWorkersDeleted = true;
}
+void
+BackgroundSupervisor::ackRemoveBackgroundManager()
+{
+ m_bBackgroundManagerAdded = false;
+}
+
bool
BackgroundSupervisor::start()
{
#endif
m_pDocument->addBackgroundSupervisor (this);
-
+ m_bBackgroundManagerAdded = true;
+
m_iRunning = m_iNumThreads;
m_iUnitsDone = 0;
** This is part of the CTSim program
** Copyright (C) 1983-2001 Kevin Rosenberg
**
-** $Id: backgroundsupr.h,v 1.10 2001/03/09 02:40:17 kevin Exp $
+** $Id: backgroundsupr.h,v 1.11 2001/03/09 21:31:51 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
class BackgroundSupervisor : public wxEvtHandler {
private:
DECLARE_DYNAMIC_CLASS(BackgroundSupervisor)
-
+
SupervisorThread* m_pMyThread;
wxFrame* m_pParentFrame;
BackgroundProcessingDocument* m_pDocument;
volatile unsigned int m_iUnitsDone;
Timer* m_pTimer;
volatile bool m_bWorkersDeleted;
+ volatile bool m_bBackgroundManagerAdded;
typedef std::vector<BackgroundWorkerThread*> ThreadContainer;
ThreadContainer m_vecpThreads;
virtual void onWorkerDone(int iThread);
void deleteWorkers();
+ void ackRemoveBackgroundManager();
bool workersDone() const { return m_iRunning == 0; }
bool workersDeleted() const { return m_bWorkersDeleted; }
bool isDone() const {return m_bDone;}