- sys_error (ERR_SEVERE, "Could not find background task [ProjectionFileDocument::removeBackgroundTask");
-
- wxCommandEvent ackEvent (wxEVT_COMMAND_MENU_SELECTED, BackgroundSupervisor::MSG_DOCUMENT_ACK_REMOVE);
- wxPostEvent (pSupervisor, ackEvent);
+ sys_error (ERR_SEVERE, "Could not find background task [OnRemoveBackground]");
+}
+#endif
+
+void
+BackgroundProcessingDocument::cancelRunningTasks()
+{
+#ifdef HAVE_WXTHREADS
+ m_criticalSection.Enter();
+ for (BackgroundContainer::iterator i = m_vecpBackgroundSupervisors.begin();
+ i != m_vecpBackgroundSupervisors.end(); i++)
+ (*i)->onCancel();
+ m_criticalSection.Leave();
+
+ while (m_vecpBackgroundSupervisors.size() > 0) {
+ ::wxYield();
+ ::wxUsleep(50);
+ }
+#endif
+}
+
+
+// ProjectionFileDocument
+
+IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, BackgroundProcessingTask)
+
+bool
+ProjectionFileDocument::OnSaveDocument(const wxString& filename)
+{
+ if (! m_pProjectionFile->write (filename.c_str())) {
+ *theApp->getLog() << "Unable to write projection file " << filename << "\n";
+ return false;
+ }
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << "Wrote projection file " << filename << "\n";
+ Modify(false);
+ return true;
+}
+
+ProjectionFileDocument::~ProjectionFileDocument()
+{
+ cancelRunningTasks();
+
+ delete m_pProjectionFile;