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