+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;
+ }
+ m_bBadFileOpen = false;
+
+ if (theApp->getVerboseLogging() && filename != "")
+ *theApp->getLog() << "Read projection file " << filename << "\n";
+
+ SetFilename(filename, true);
+ Modify(false);
+ getView()->setInitialClientSize();
+ UpdateAllViews();
+
+ 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());
+}
+
+void
+ProjectionFileDocument::Activate()
+{
+#if CTSIM_MDI
+ getView()->getFrame()->Activate();
+#endif
+};
+
+// PhantomFileDocument
+
+IMPLEMENT_DYNAMIC_CLASS(PhantomFileDocument, BackgroundProcessingTask)
+
+PhantomFileDocument::~PhantomFileDocument()
+{
+ cancelRunningTasks();
+}
+
+bool
+PhantomFileDocument::OnOpenDocument(const wxString& constFilename)
+{
+ if (! OnSaveModified())
+ return false;
+
+ wxString filename (constFilename);
+
+ if (wxFile::Exists (filename)) {
+ m_phantom.createFromFile (filename);
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << "Read phantom file " << filename << "\n";
+ } else {
+ filename.Replace (".phm", "");
+ m_phantom.createFromPhantom (filename);
+ }
+ m_namePhantom = filename;
+ SetFilename (filename, true);
+ if (m_phantom.fail()) {
+ *theApp->getLog() << "Failure creating phantom " << filename << "\n";
+ m_bBadFileOpen = true;
+ return false;
+ }
+ m_idPhantom = m_phantom.id();
+ Modify(false);
+ UpdateAllViews();
+ 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;
+}
+
+void
+PhantomFileDocument::Modify(bool mod)
+{
+ wxDocument::Modify(mod);
+}
+
+
+PhantomFileView*
+PhantomFileDocument::getView() const
+{
+ return dynamic_cast<PhantomFileView*>(GetFirstView());
+}
+
+void
+PhantomFileDocument::Activate()
+{
+#if CTSIM_MDI
+ getView()->getFrame()->Activate();
+#endif
+};
+
+// PlotFileDocument
+
+IMPLEMENT_DYNAMIC_CLASS(PlotFileDocument, wxDocument)