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