+IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, BackgroundProcessingDocument)
+
+bool
+ProjectionFileDocument::OnSaveDocument(const wxString& filename)
+{
+ if (! m_pProjectionFile->write (filename.mb_str(wxConvUTF8))) {
+ *theApp->getLog() << _T("Unable to write projection file ") << filename << _T("\n");
+ return false;
+ }
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << _T("Wrote projection file ") << filename << _T("\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.mb_str(wxConvUTF8))) {
+ *theApp->getLog() << _T("Unable to read projection file ") << filename << _T("\n");
+ m_bBadFileOpen = true;
+ return false;
+ }
+ m_bBadFileOpen = false;
+
+ if (theApp->getVerboseLogging() && filename != _T(""))
+ *theApp->getLog() << _T("Read projection file ") << filename << _T("\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, BackgroundProcessingDocument)
+
+PhantomFileDocument::~PhantomFileDocument()
+{
+ cancelRunningTasks();
+}
+
+bool
+PhantomFileDocument::OnOpenDocument(const wxString& constFilename)
+{
+ if (! OnSaveModified())
+ return false;
+
+ wxString filename (constFilename);
+
+ if (wxFile::Exists (filename)) {
+ m_phantom.createFromFile (filename.mb_str(wxConvUTF8));
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << _T("Read phantom file ") << filename << _T("\n");
+ } else {
+ filename.Replace (_T(".phm"), _T(""));
+ m_phantom.createFromPhantom (filename.mb_str(wxConvUTF8));
+ }
+ m_namePhantom = filename;
+ SetFilename (filename, true);
+ if (m_phantom.fail()) {
+ *theApp->getLog() << _T("Failure creating phantom ") << filename << _T("\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.mb_str(wxConvUTF8))) {
+ *theApp->getLog() << _T("Unable to write phantom file ") << filename << _T("\n");
+ return false;
+ }
+ if (theApp->getVerboseLogging())
+ *theApp->getLog() << _T("Wrote phantom file ") << filename << _T("\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