+
+ while (m_vecpBackgroundSupervisors.size() > 0)
+ ::wxYield();
+
+ delete m_pProjectionFile;
+}
+
+void
+ProjectionFileDocument::OnAddBackground (wxCommandEvent& event)
+{
+ BackgroundSupervisor* pSupervisor = reinterpret_cast<BackgroundSupervisor*>(event.GetClientData());
+ wxASSERT (pSupervisor != NULL);
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ if (pSupervisor)
+ m_vecpBackgroundSupervisors.push_back (pSupervisor);
+}
+
+void
+ProjectionFileDocument::OnRemoveBackground (wxCommandEvent& event)
+{
+ BackgroundSupervisor* pSupervisor = reinterpret_cast<BackgroundSupervisor*>(event.GetClientData());
+ wxASSERT (pSupervisor != NULL);
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ bool bFound = false;
+ for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin();
+ i != m_vecpBackgroundSupervisors.end();
+ i++)
+ if (*i == pSupervisor) {
+ m_vecpBackgroundSupervisors.erase(i);
+ bFound = true;
+ break;
+ }
+ if (! bFound)
+ sys_error (ERR_SEVERE, "Could not find background task [ProjectionFileDocument::removeBackgroundTask");
+}
+
+bool
+ProjectionFileDocument::OnOpenDocument(const wxString& filename)
+{
+ if (! OnSaveModified())
+ return false;
+
+ if (! m_pProjectionFile->read (filename.c_str())) {
+ *theApp->getLog() << "Unable to read projection file " << filename << "\n";
+ m_bBadFileOpen = true;
+ return false;