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