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