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.4 2000/12/16 06:12:47 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!
56 IMPLEMENT_DYNAMIC_CLASS(ImageFileDocument, wxDocument)
58 bool ImageFileDocument::OnSaveDocument(const wxString& filename)
60 if (! m_imageFile.fileWrite (filename)) {
61 *theApp->getLog() << "Unable to write image file " << filename << "\n";
64 *theApp->getLog() << "Wrote image file " << filename << "\n";
69 bool ImageFileDocument::OnOpenDocument(const wxString& filename)
71 if (filename == "untitled.if") {
72 wxString untitledFilename = theApp->getUntitledFilename();
73 SetFilename (untitledFilename, true);
75 if (! m_imageFile.fileRead (filename)) {
76 *theApp->getLog() << "Unable to read image file " << filename << "\n";
79 *theApp->getLog() << "Read image file " << filename << "\n";
80 SetFilename(filename, true);
87 bool ImageFileDocument::IsModified(void) const
89 return wxDocument::IsModified();
92 void ImageFileDocument::Modify(bool mod)
94 wxDocument::Modify(mod);
97 bool ImageFileDocument::OnCloseDocument ()
99 bool bReturn = wxDocument::OnCloseDocument();
103 // ProjectionFileDocument
105 IMPLEMENT_DYNAMIC_CLASS(ProjectionFileDocument, wxDocument)
107 bool ProjectionFileDocument::OnSaveDocument(const wxString& filename)
109 if (! m_projectionFile.write (filename)) {
110 *theApp->getLog() << "Unable to write projection file " << filename << "\n";
113 *theApp->getLog() << "Wrote projection file " << filename << "\n";
118 bool ProjectionFileDocument::OnOpenDocument(const wxString& filename)
120 if (filename == "untitled.pj") {
121 wxString untitledFilename = theApp->getUntitledFilename();
122 SetFilename (untitledFilename, true);
124 if (! m_projectionFile.read (filename)) {
125 *theApp->getLog() << "Unable to read projection file " << filename << "\n";
128 *theApp->getLog() << "Read projection file " << filename << "\n";
129 SetFilename(filename, true);
136 bool ProjectionFileDocument::IsModified(void) const
138 return wxDocument::IsModified();
141 void ProjectionFileDocument::Modify(bool mod)
143 wxDocument::Modify(mod);
147 bool ProjectionFileDocument::OnCloseDocument ()
149 bool bReturn = wxDocument::OnCloseDocument();
155 IMPLEMENT_DYNAMIC_CLASS(PhantomDocument, wxDocument)
157 bool PhantomDocument::OnOpenDocument(const wxString& filename)
159 wxString myFilename = filename;
160 if (wxFile::Exists (myFilename)) {
161 m_phantom.createFromFile (myFilename);
162 *theApp->getLog() << "Read phantom file " << filename << "\n";
164 myFilename.Replace (".phm", "");
165 m_phantom.createFromPhantom (myFilename);
167 m_namePhantom = myFilename;
168 SetFilename (myFilename, true);
169 if (m_phantom.fail()) {
170 *theApp->getLog() << "Failure creating phantom " << myFilename << "\n";
173 m_idPhantom = m_phantom.id();
179 bool PhantomDocument::OnCloseDocument ()
181 bool bReturn = wxDocument::OnCloseDocument();
185 bool PhantomDocument::IsModified(void) const
187 return wxDocument::IsModified();
190 void PhantomDocument::Modify(bool mod)
192 wxDocument::Modify(mod);