54fa2a4ed3107e6fa41176c3b56d038d14c93425
[ctsim.git] / src / docs.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          docs.h
5 **   Purpose:       Header file for Document routines of CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: docs.h,v 1.17 2001/01/30 05:05:41 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifdef __GNUG__
29 // #pragma interface
30 #endif
31
32 #ifndef __DOCSH__
33 #define __DOCSH__
34
35 #include "wx/docview.h"
36
37 // #include "views.h"
38 #include "imagefile.h"
39 #include "phantom.h"
40 #include "projections.h"
41 #include "plotfile.h"
42
43 class ProjectionFileView;
44 class PhantomFileView;
45 class ImageFileView;
46 class PlotFileView;
47 class TextFileView;
48
49 class ImageFileDocument: public wxDocument
50 {
51 private:
52     DECLARE_DYNAMIC_CLASS(ImageFileDocument)
53     ImageFile* m_pImageFile;
54     bool m_bBadFileOpen;
55
56 public:
57     virtual bool OnSaveDocument (const wxString& filename);
58     virtual bool OnOpenDocument (const wxString& filename);
59     virtual bool IsModified () const;
60     virtual bool Revert ();
61     virtual void Modify (bool mod);
62     
63     ImageFileDocument () 
64       : m_bBadFileOpen(false)
65     {
66       m_pImageFile = new ImageFile;
67     }
68
69     virtual ~ImageFileDocument () 
70     {
71       delete m_pImageFile;
72     }
73
74     const ImageFile& getImageFile() const { return *m_pImageFile; }
75     ImageFile& getImageFile() { return *m_pImageFile; }
76     void setImageFile (ImageFile* pImageFile)
77     { 
78       delete m_pImageFile;
79       m_pImageFile = pImageFile;
80     }
81
82     ImageFileView* getView() const;
83     bool getBadFileOpen() const { return m_bBadFileOpen; }
84     void setBadFileOpen() { m_bBadFileOpen = true; }
85 };
86
87
88 class ProjectionFileDocument: public wxDocument
89 {
90 private:
91     DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
92     Projections* m_pProjectionFile;
93     bool m_bBadFileOpen;
94
95 public:
96     virtual bool OnSaveDocument (const wxString& filename);
97     virtual bool OnOpenDocument (const wxString& filename);
98     virtual bool IsModified () const;
99     virtual void Modify (bool mod);
100     
101     ProjectionFileDocument () 
102           : m_bBadFileOpen(false)
103     {
104       m_pProjectionFile = new Projections;
105     }
106
107     virtual ~ProjectionFileDocument () 
108     {
109       delete m_pProjectionFile;
110     }
111
112     const Projections& getProjections () const  { return *m_pProjectionFile; }
113     Projections& getProjections ()      { return *m_pProjectionFile; }
114
115     void setProjections (Projections* pProjections)
116     { delete m_pProjectionFile;
117       m_pProjectionFile = pProjections;
118     }
119
120     ProjectionFileView* getView() const;
121     bool getBadFileOpen() const { return m_bBadFileOpen; }
122     void setBadFileOpen() { m_bBadFileOpen = true; }
123 };
124
125
126 class PhantomFileDocument: public wxDocument
127 {
128 private:
129     DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
130     Phantom m_phantom;
131     int m_idPhantom;
132     wxString m_namePhantom;
133     bool m_bBadFileOpen;
134
135 public:
136     PhantomFileDocument () 
137         : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
138     {}
139
140     virtual ~PhantomFileDocument () 
141     {}
142
143     const int getPhantomID () const { return m_idPhantom; }
144
145     const wxString& getPhantomName () const { return m_namePhantom; }
146
147     const Phantom& getPhantom () const  { return m_phantom; }
148
149     Phantom& getPhantom ()      { return m_phantom; }
150
151     virtual bool OnOpenDocument (const wxString& filename);
152     virtual bool OnSaveDocument (const wxString& filename);
153     virtual bool IsModified () const;
154     virtual void Modify (bool mod);
155     PhantomFileView* getView() const;
156     bool getBadFileOpen() const { return m_bBadFileOpen; }
157     void setBadFileOpen() { m_bBadFileOpen = true; }
158 };
159
160
161 class PlotFileDocument: public wxDocument
162 {
163 private:
164     DECLARE_DYNAMIC_CLASS(PlotFileDocument)
165     PlotFile m_plot;
166     wxString m_namePlot;
167     bool m_bBadFileOpen;
168
169 public:
170     PlotFileDocument () 
171       : m_bBadFileOpen(false)
172     {}
173
174     virtual ~PlotFileDocument () 
175         {}
176
177     const wxString& getPlotName () const
178         { return m_namePlot; }
179
180     const PlotFile& getPlotFile () const
181         { return m_plot; }
182
183     PlotFile& getPlotFile ()
184         { return m_plot; }
185
186     virtual bool OnOpenDocument (const wxString& filename);
187     virtual bool OnSaveDocument (const wxString& filename);
188     virtual bool IsModified () const;
189     virtual void Modify (bool mod);
190     PlotFileView* getView() const;
191     bool getBadFileOpen() const { return m_bBadFileOpen; }
192     void setBadFileOpen() { m_bBadFileOpen = true; }
193 };
194
195
196 class TextFileDocument: public wxDocument
197 {
198  private:
199   DECLARE_DYNAMIC_CLASS(TextFileDocument)
200   bool m_bBadFileOpen;
201
202  public:
203   TextFileDocument(void) 
204         : m_bBadFileOpen(false)
205   {}
206
207   virtual ~TextFileDocument(void) {}
208
209   virtual bool OnSaveDocument(const wxString& filename);
210   virtual bool OnOpenDocument(const wxString& filename);
211   virtual bool IsModified(void) const;
212
213   wxTextCtrl* getTextCtrl();
214
215   TextFileView* getView() const;
216   bool getBadFileOpen() const { return m_bBadFileOpen; }
217   void setBadFileOpen() { m_bBadFileOpen = true; }
218 };
219
220
221 #endif