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.3 2000/09/07 01:28:33 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 bool ImageFileDocument::OnCloseDocument ()
100 bool bReturn = wxDocument::OnCloseDocument();
104 // ProjectionFileDocument
106 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, wxDocument)
108 bool ProjectionFileDocument::OnSaveDocument(const wxString& filename)
110 if (! m_projectionFile.write (filename)) {
111 *theApp->getLog() << "Unable to write projection file " << filename << "\n";
114 *theApp->getLog() << "Wrote projection file " << filename << "\n";
119 bool ProjectionFileDocument::OnOpenDocument(const wxString& filename)
121 if (filename == "untitled.pj") {
122 wxString untitledFilename = theApp->getUntitledFilename();
123 SetFilename (untitledFilename, true);
125 if (! m_projectionFile.read (filename)) {
126 *theApp->getLog() << "Unable to read projection file " << filename << "\n";
129 *theApp->getLog() << "Read projection file " << filename << "\n";
130 SetFilename(filename, true);
137 bool ProjectionFileDocument::IsModified(void) const
139 return wxDocument::IsModified();
142 void ProjectionFileDocument::Modify(bool mod)
144 wxDocument::Modify(mod);
148 bool ProjectionFileDocument::OnCloseDocument ()
150 bool bReturn = wxDocument::OnCloseDocument();
156 IMPLEMENT_DYNAMIC_CLASS(PhantomDocument, wxDocument)
158 bool PhantomDocument::OnOpenDocument(const wxString& filename)
160 wxString myFilename = filename;
161 if (wxFile::Exists (myFilename)) {
162 m_phantom.createFromFile (myFilename);
163 *theApp->getLog() << "Read phantom file " << filename << "\n";
165 myFilename.Replace (".phm", "");
166 m_phantom.createFromPhantom (myFilename);
168 m_namePhantom = myFilename;
169 SetFilename (myFilename, true);
170 if (m_phantom.fail()) {
171 *theApp->getLog() << "Failure creating phantom " << myFilename << "\n";
174 m_idPhantom = m_phantom.id();
180 bool PhantomDocument::OnCloseDocument ()
182 bool bReturn = wxDocument::OnCloseDocument();
186 bool PhantomDocument::IsModified(void) const
188 return wxDocument::IsModified();
191 void PhantomDocument::Modify(bool mod)
193 wxDocument::Modify(mod);