r473: no message
[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.19 2001/01/30 10:58:13 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 class Graph3dFileView;
49
50 class ImageFileDocument: public wxDocument
51 {
52 private:
53     DECLARE_DYNAMIC_CLASS(ImageFileDocument)
54     ImageFile* m_pImageFile;
55     bool m_bBadFileOpen;
56
57 public:
58     virtual bool OnSaveDocument (const wxString& filename);
59     virtual bool OnOpenDocument (const wxString& filename);
60     virtual bool IsModified () const;
61     virtual bool Revert ();
62     virtual void Modify (bool mod);
63     
64     ImageFileDocument () 
65       : m_bBadFileOpen(false)
66     {
67       m_pImageFile = new ImageFile;
68     }
69
70     virtual ~ImageFileDocument () 
71     {
72       delete m_pImageFile;
73     }
74
75     const ImageFile& getImageFile() const { return *m_pImageFile; }
76     ImageFile& getImageFile() { return *m_pImageFile; }
77     void setImageFile (ImageFile* pImageFile)
78     { 
79       delete m_pImageFile;
80       m_pImageFile = pImageFile;
81     }
82
83     ImageFileView* getView() const;
84     bool getBadFileOpen() const { return m_bBadFileOpen; }
85     void setBadFileOpen() { m_bBadFileOpen = true; }
86 };
87
88
89 class ProjectionFileDocument: public wxDocument
90 {
91 private:
92     DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
93     Projections* m_pProjectionFile;
94     bool m_bBadFileOpen;
95
96 public:
97     virtual bool OnSaveDocument (const wxString& filename);
98     virtual bool OnOpenDocument (const wxString& filename);
99     virtual bool IsModified () const;
100     virtual void Modify (bool mod);
101     
102     ProjectionFileDocument () 
103           : m_bBadFileOpen(false)
104     {
105       m_pProjectionFile = new Projections;
106     }
107
108     virtual ~ProjectionFileDocument () 
109     {
110       delete m_pProjectionFile;
111     }
112
113     const Projections& getProjections () const  { return *m_pProjectionFile; }
114     Projections& getProjections ()      { return *m_pProjectionFile; }
115
116     void setProjections (Projections* pProjections)
117     { delete m_pProjectionFile;
118       m_pProjectionFile = pProjections;
119     }
120
121     ProjectionFileView* getView() const;
122     bool getBadFileOpen() const { return m_bBadFileOpen; }
123     void setBadFileOpen() { m_bBadFileOpen = true; }
124 };
125
126
127 class PhantomFileDocument: public wxDocument
128 {
129 private:
130     DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
131     Phantom m_phantom;
132     int m_idPhantom;
133     wxString m_namePhantom;
134     bool m_bBadFileOpen;
135
136 public:
137     PhantomFileDocument () 
138         : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
139     {}
140
141     virtual ~PhantomFileDocument () 
142     {}
143
144     const int getPhantomID () const { return m_idPhantom; }
145
146     const wxString& getPhantomName () const { return m_namePhantom; }
147
148     const Phantom& getPhantom () const  { return m_phantom; }
149
150     Phantom& getPhantom ()      { return m_phantom; }
151
152     virtual bool OnOpenDocument (const wxString& filename);
153     virtual bool OnSaveDocument (const wxString& filename);
154     virtual bool IsModified () const;
155     virtual void Modify (bool mod);
156     PhantomFileView* getView() const;
157     bool getBadFileOpen() const { return m_bBadFileOpen; }
158     void setBadFileOpen() { m_bBadFileOpen = true; }
159 };
160
161
162 class PlotFileDocument: public wxDocument
163 {
164 private:
165     DECLARE_DYNAMIC_CLASS(PlotFileDocument)
166     PlotFile m_plot;
167     wxString m_namePlot;
168     bool m_bBadFileOpen;
169
170 public:
171     PlotFileDocument () 
172       : m_bBadFileOpen(false)
173     {}
174
175     virtual ~PlotFileDocument () 
176         {}
177
178     const wxString& getPlotName () const
179         { return m_namePlot; }
180
181     const PlotFile& getPlotFile () const
182         { return m_plot; }
183
184     PlotFile& getPlotFile ()
185         { return m_plot; }
186
187     virtual bool OnOpenDocument (const wxString& filename);
188     virtual bool OnSaveDocument (const wxString& filename);
189     virtual bool IsModified () const;
190     virtual void Modify (bool mod);
191     PlotFileView* getView() const;
192     bool getBadFileOpen() const { return m_bBadFileOpen; }
193     void setBadFileOpen() { m_bBadFileOpen = true; }
194 };
195
196
197 class TextFileDocument: public wxDocument
198 {
199  private:
200   DECLARE_DYNAMIC_CLASS(TextFileDocument)
201   bool m_bBadFileOpen;
202
203  public:
204   TextFileDocument(void) 
205         : m_bBadFileOpen(false)
206   {}
207
208   virtual ~TextFileDocument(void) {}
209
210   virtual bool OnSaveDocument(const wxString& filename);
211   virtual bool OnOpenDocument(const wxString& filename);
212   virtual bool IsModified(void) const;
213
214   wxTextCtrl* getTextCtrl();
215
216   TextFileView* getView() const;
217   bool getBadFileOpen() const { return m_bBadFileOpen; }
218   void setBadFileOpen() { m_bBadFileOpen = true; }
219 };
220
221
222
223 #include <GL/gl.h>
224 #include <GL/glu.h>
225
226 typedef GLfloat glTripleFloat[3];
227
228 class Graph3dFileDocument: public wxDocument
229 {
230   friend Graph3dFileView;
231
232  private:
233   DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
234   bool m_bBadFileOpen;
235   GLint m_nVertices;
236   glTripleFloat* m_pVertices;
237   glTripleFloat* m_pNormals;
238   unsigned int m_nx;
239   unsigned int m_ny;
240   ImageFileArray m_array;
241
242  public:
243   Graph3dFileDocument(void);
244   virtual ~Graph3dFileDocument(void); 
245  
246   virtual bool OnSaveDocument (const wxString& filename);
247   virtual bool OnOpenDocument (const wxString& filename);
248   virtual bool IsModified () const;
249
250   Graph3dFileView* getView() const;
251   bool getBadFileOpen() const { return m_bBadFileOpen; }
252   void setBadFileOpen()       { m_bBadFileOpen = true; }
253   bool createFromImageFile (const ImageFile& rImageFile);
254 };
255
256 #endif