1 /*****************************************************************************
5 ** Purpose: Document routines for CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: docs.cpp,v 1.2 2000/07/15 08:36:13 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
29 // #pragma implementation
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
42 #include "wx/txtstrm.h"
45 #if !wxUSE_DOC_VIEW_ARCHITECTURE
46 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
57 IMPLEMENT_DYNAMIC_CLASS(ImageFileDocument, wxDocument)
59 bool ImageFileDocument::OnSaveDocument(const wxString& filename)
61 if (! m_imageFile.fileWrite (filename)) {
62 *theApp->getLog() << "Unable to write image file " << filename << "\n";
65 *theApp->getLog() << "Wrote image file " << filename << "\n";
70 bool ImageFileDocument::OnOpenDocument(const wxString& filename)
72 if (filename == "untitled.if") {
73 wxString untitledFilename = theApp->getUntitledFilename();
74 SetFilename (untitledFilename, true);
76 if (! m_imageFile.fileRead (filename)) {
77 *theApp->getLog() << "Unable to read image file " << filename << "\n";
80 *theApp->getLog() << "Read image file " << filename << "\n";
81 SetFilename(filename, true);
88 bool ImageFileDocument::IsModified(void) const
90 return wxDocument::IsModified();
93 void ImageFileDocument::Modify(bool mod)
95 wxDocument::Modify(mod);
98 // ProjectionFileDocument
100 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, wxDocument)
102 bool ProjectionFileDocument::OnSaveDocument(const wxString& filename)
104 if (! m_projectionFile.write (filename)) {
105 *theApp->getLog() << "Unable to write projection file " << filename << "\n";
108 *theApp->getLog() << "Wrote projection file " << filename << "\n";
113 bool ProjectionFileDocument::OnOpenDocument(const wxString& filename)
115 if (filename == "untitled.pj") {
116 wxString untitledFilename = theApp->getUntitledFilename();
117 SetFilename (untitledFilename, true);
119 if (! m_projectionFile.read (filename)) {
120 *theApp->getLog() << "Unable to read projection file " << filename << "\n";
123 *theApp->getLog() << "Read projection file " << filename << "\n";
124 SetFilename(filename, true);
131 bool ProjectionFileDocument::IsModified(void) const
133 return wxDocument::IsModified();
136 void ProjectionFileDocument::Modify(bool mod)
138 wxDocument::Modify(mod);
144 IMPLEMENT_DYNAMIC_CLASS(PhantomDocument, wxDocument)
146 bool PhantomDocument::OnOpenDocument(const wxString& filename)
148 wxString myFilename = filename;
149 if (wxFile::Exists (myFilename)) {
150 m_phantom.createFromFile (myFilename);
152 myFilename.Replace (".phm", "");
153 m_phantom.createFromPhantom (myFilename);
155 m_namePhantom = myFilename;
156 SetFilename (myFilename, true);
157 if (m_phantom.fail()) {
158 *theApp->getLog() << "Failure creating phantom " << myFilename << "\n";
161 m_idPhantom = m_phantom.id();
167 bool PhantomDocument::IsModified(void) const
169 return wxDocument::IsModified();
172 void PhantomDocument::Modify(bool mod)
174 wxDocument::Modify(mod);