+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;
+}
+
+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;
+ }
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << "Read projection file " << filename << "\n";
+ SetFilename(filename, true);
+ Modify(false);
+ UpdateAllViews();
+ GetFirstView()->OnUpdate (GetFirstView(), NULL);
+ m_bBadFileOpen = false;
+
+ return true;
+}
+
+bool
+ProjectionFileDocument::IsModified(void) const
+{
+ return wxDocument::IsModified();
+}
+
+void
+ProjectionFileDocument::Modify(bool mod)
+{
+ wxDocument::Modify(mod);
+}
+
+
+ProjectionFileView*
+ProjectionFileDocument::getView() const
+{
+ return dynamic_cast<ProjectionFileView*>(GetFirstView());
+}
+
+// PhantomFileDocument
+
+IMPLEMENT_DYNAMIC_CLASS(PhantomFileDocument, BackgroundProcessingTask)
+
+PhantomFileDocument::~PhantomFileDocument()
+{
+ cancelRunningTasks();
+}
+
+bool
+PhantomFileDocument::OnOpenDocument(const wxString& filename)
+{
+ if (! OnSaveModified())
+ return false;
+
+ wxString myFilename = filename;
+ if (wxFile::Exists (myFilename)) {
+ m_phantom.createFromFile (myFilename);
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << "Read phantom file " << filename << "\n";
+ } else {
+ myFilename.Replace (".phm", "");
+ m_phantom.createFromPhantom (myFilename);
+ }
+ m_namePhantom = myFilename;
+ SetFilename (myFilename, true);
+ if (m_phantom.fail()) {
+ *theApp->getLog() << "Failure creating phantom " << myFilename << "\n";
+ m_bBadFileOpen = true;
+ return false;
+ }
+ m_idPhantom = m_phantom.id();
+ Modify(false);
+ UpdateAllViews();
+ GetFirstView()->OnUpdate (GetFirstView(), NULL);
+ m_bBadFileOpen = false;
+
+ return true;
+}
+
+bool
+PhantomFileDocument::OnSaveDocument(const wxString& filename)
+{
+ if (! m_phantom.fileWrite (filename.c_str())) {
+ *theApp->getLog() << "Unable to write phantom file " << filename << "\n";
+ return false;
+ }
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << "Wrote phantom file " << filename << "\n";
+ Modify(false);
+ return true;
+}
+
+bool
+PhantomFileDocument::IsModified(void) const
+{
+ return false;
+}