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