r571: 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.22 2001/02/22 11:05:38 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     std::vector<ThreadedReconstructor*> m_vecpActiveReconstructors;
97     wxCriticalSection m_criticalSection;
98     
99 public:
100     virtual bool OnSaveDocument (const wxString& filename);
101     virtual bool OnOpenDocument (const wxString& filename);
102     virtual bool IsModified () const;
103     virtual void Modify (bool mod);
104     
105     ProjectionFileDocument () 
106           : m_bBadFileOpen(false)
107     {
108       m_pProjectionFile = new Projections;
109     }
110
111     virtual ~ProjectionFileDocument ();
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     void addReconstructor (ThreadedReconstructor* pRecon);
125     void removeReconstructor (ThreadedReconstructor* pRecon);
126 };
127
128
129 class PhantomFileDocument: public wxDocument
130 {
131 private:
132     DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
133     Phantom m_phantom;
134     int m_idPhantom;
135     wxString m_namePhantom;
136     bool m_bBadFileOpen;
137
138 public:
139     PhantomFileDocument () 
140         : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
141     {}
142
143     virtual ~PhantomFileDocument () 
144     {}
145
146     const int getPhantomID () const { return m_idPhantom; }
147
148     const wxString& getPhantomName () const { return m_namePhantom; }
149
150     const Phantom& getPhantom () const  { return m_phantom; }
151
152     Phantom& getPhantom ()      { return m_phantom; }
153
154     virtual bool OnOpenDocument (const wxString& filename);
155     virtual bool OnSaveDocument (const wxString& filename);
156     virtual bool IsModified () const;
157     virtual void Modify (bool mod);
158     PhantomFileView* getView() const;
159     bool getBadFileOpen() const { return m_bBadFileOpen; }
160     void setBadFileOpen() { m_bBadFileOpen = true; }
161 };
162
163
164 class PlotFileDocument: public wxDocument
165 {
166 private:
167     DECLARE_DYNAMIC_CLASS(PlotFileDocument)
168     PlotFile m_plot;
169     wxString m_namePlot;
170     bool m_bBadFileOpen;
171
172 public:
173     PlotFileDocument () 
174       : m_bBadFileOpen(false)
175     {}
176
177     virtual ~PlotFileDocument () 
178         {}
179
180     const wxString& getPlotName () const
181         { return m_namePlot; }
182
183     const PlotFile& getPlotFile () const
184         { return m_plot; }
185
186     PlotFile& getPlotFile ()
187         { return m_plot; }
188
189     virtual bool OnOpenDocument (const wxString& filename);
190     virtual bool OnSaveDocument (const wxString& filename);
191     virtual bool IsModified () const;
192     virtual void Modify (bool mod);
193     PlotFileView* getView() const;
194     bool getBadFileOpen() const { return m_bBadFileOpen; }
195     void setBadFileOpen() { m_bBadFileOpen = true; }
196 };
197
198
199 class TextFileDocument: public wxDocument
200 {
201  private:
202   DECLARE_DYNAMIC_CLASS(TextFileDocument)
203   bool m_bBadFileOpen;
204
205  public:
206   TextFileDocument(void) 
207         : m_bBadFileOpen(false)
208   {}
209
210   virtual ~TextFileDocument(void) {}
211
212   virtual bool OnSaveDocument(const wxString& filename);
213   virtual bool OnOpenDocument(const wxString& filename);
214   virtual bool IsModified(void) const;
215
216   wxTextCtrl* getTextCtrl();
217
218   TextFileView* getView() const;
219   bool getBadFileOpen() const { return m_bBadFileOpen; }
220   void setBadFileOpen() { m_bBadFileOpen = true; }
221 };
222
223
224 #if wxUSE_GLCANVAS
225 #include <GL/gl.h>
226 #include <GL/glu.h>
227
228 typedef GLfloat glTripleFloat[3];
229
230 class Graph3dFileDocument: public wxDocument
231 {
232   friend Graph3dFileView;
233
234  private:
235   DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
236   bool m_bBadFileOpen;
237   GLint m_nVertices;
238   glTripleFloat* m_pVertices;
239   glTripleFloat* m_pNormals;
240   unsigned int m_nx;
241   unsigned int m_ny;
242   ImageFileArray m_array;
243
244  public:
245   Graph3dFileDocument(void);
246   virtual ~Graph3dFileDocument(void); 
247  
248   virtual bool OnSaveDocument (const wxString& filename);
249   virtual bool OnOpenDocument (const wxString& filename);
250   virtual bool IsModified () const;
251
252   Graph3dFileView* getView() const;
253   bool getBadFileOpen() const { return m_bBadFileOpen; }
254   void setBadFileOpen()       { m_bBadFileOpen = true; }
255   bool createFromImageFile (const ImageFile& rImageFile);
256
257   int nx() const  { return m_nx; }
258   int ny() const { return m_ny; }
259   ImageFileArray getArray() { return m_array; }
260   ImageFileArrayConst getArray() const { return m_array; }
261 };
262 #endif // wxUSE_GLCANVAS
263
264
265 #endif