Revert "Update package dependency from libwxgtk3.0-dev to libwxgtk3.0-gtk3-dev for...
[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-2009 Kevin Rosenberg
11 **
12 **  This program is free software; you can redistribute it and/or modify
13 **  it under the terms of the GNU General Public License (version 2) as
14 **  published by the Free Software Foundation.
15 **
16 **  This program is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 **  GNU General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with this program; if not, write to the Free Software
23 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 ******************************************************************************/
25
26 #ifndef __DOCSH__
27 #define __DOCSH__
28
29 #include "wx/docview.h"
30
31 // #include "views.h"
32 #include "imagefile.h"
33 #include "phantom.h"
34 #include "projections.h"
35 #include "plotfile.h"
36 #include "threadrecon.h"
37
38 class ProjectionFileView;
39 class PhantomFileView;
40 class ImageFileView;
41 class PlotFileView;
42 class TextFileView;
43 class Graph3dFileView;
44
45
46 class ImageFileDocument: public wxDocument
47 {
48 private:
49     DECLARE_DYNAMIC_CLASS(ImageFileDocument)
50     ImageFile* m_pImageFile;
51     bool m_bBadFileOpen;
52
53 public:
54     virtual bool OnSaveDocument (const wxString& filename);
55     virtual bool OnOpenDocument (const wxString& filename);
56     virtual bool IsModified () const;
57     virtual bool Revert ();
58     virtual void Modify (bool mod);
59
60     ImageFileDocument ()
61       : m_bBadFileOpen(false)
62     {
63       m_pImageFile = new ImageFile;
64     }
65
66     virtual ~ImageFileDocument ()
67     {
68       delete m_pImageFile;
69     }
70
71     const ImageFile& getImageFile() const { return *m_pImageFile; }
72     ImageFile& getImageFile() { return *m_pImageFile; }
73     void setImageFile (ImageFile* pImageFile)
74     {
75       delete m_pImageFile;
76       m_pImageFile = pImageFile;
77     }
78
79     ImageFileView* getView() const;
80     bool getBadFileOpen() const { return m_bBadFileOpen; }
81     void setBadFileOpen() { m_bBadFileOpen = true; }
82     void Activate();
83 };
84
85 class BackgroundProcessingDocument : public wxDocument
86 {
87 private:
88     DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
89 #ifdef HAVE_WXTHREADS
90     typedef BackgroundSupervisor BackgroundObject;
91     typedef std::vector<BackgroundObject*> BackgroundContainer;
92     BackgroundContainer m_vecpBackgroundSupervisors;
93     wxCriticalSection m_criticalSection;
94 #endif
95
96 public:
97   BackgroundProcessingDocument()
98     : wxDocument()
99       {}
100
101   void cancelRunningTasks();
102 #ifdef HAVE_WXTHREADS
103   void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
104   void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
105 #endif
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     void Activate();
143 };
144
145
146 class PhantomFileDocument: public BackgroundProcessingDocument
147 {
148 private:
149     DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
150     Phantom m_phantom;
151     int m_idPhantom;
152     wxString m_namePhantom;
153     bool m_bBadFileOpen;
154
155 public:
156     PhantomFileDocument ()
157         : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
158     {}
159
160     virtual ~PhantomFileDocument ();
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     void Activate();
178 };
179
180
181 class PlotFileDocument: public wxDocument
182 {
183 private:
184     DECLARE_DYNAMIC_CLASS(PlotFileDocument)
185     PlotFile m_plot;
186     wxString m_namePlot;
187     bool m_bBadFileOpen;
188
189 public:
190     PlotFileDocument ()
191       : m_bBadFileOpen(false)
192     {}
193
194     virtual ~PlotFileDocument ()
195         {}
196
197     const wxString& getPlotName () const
198         { return m_namePlot; }
199
200     const PlotFile& getPlotFile () const
201         { return m_plot; }
202
203     PlotFile& getPlotFile ()
204         { return m_plot; }
205
206     virtual bool OnOpenDocument (const wxString& filename);
207     virtual bool OnSaveDocument (const wxString& filename);
208     virtual bool IsModified () const;
209     virtual void Modify (bool mod);
210     PlotFileView* getView() const;
211     bool getBadFileOpen() const { return m_bBadFileOpen; }
212     void setBadFileOpen() { m_bBadFileOpen = true; }
213     void Activate();
214 };
215
216
217 class TextFileDocument: public wxDocument
218 {
219  private:
220   DECLARE_DYNAMIC_CLASS(TextFileDocument)
221   bool m_bBadFileOpen;
222
223  public:
224   TextFileDocument(void)
225         : m_bBadFileOpen(false)
226   {}
227
228   virtual ~TextFileDocument(void) {}
229
230   virtual bool OnSaveDocument(const wxString& filename);
231   virtual bool OnOpenDocument(const wxString& filename);
232   virtual bool IsModified(void) const;
233
234   wxTextCtrl* getTextCtrl();
235
236   TextFileView* getView() const;
237   bool getBadFileOpen() const { return m_bBadFileOpen; }
238   void setBadFileOpen() { m_bBadFileOpen = true; }
239 };
240
241
242 #if wxUSE_GLCANVAS
243 #include <GL/gl.h>
244 #include <GL/glu.h>
245
246 typedef GLfloat glTripleFloat[3];
247
248 class Graph3dFileDocument: public wxDocument
249 {
250   friend class Graph3dFileView;
251
252  private:
253   DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
254   bool m_bBadFileOpen;
255   GLint m_nVertices;
256   glTripleFloat* m_pVertices;
257   glTripleFloat* m_pNormals;
258   unsigned int m_nx;
259   unsigned int m_ny;
260   ImageFileArray m_array;
261
262  public:
263   Graph3dFileDocument(void);
264   virtual ~Graph3dFileDocument(void);
265
266   virtual bool OnSaveDocument (const wxString& filename);
267   virtual bool OnOpenDocument (const wxString& filename);
268   virtual bool IsModified () const;
269
270   Graph3dFileView* getView() const;
271   bool getBadFileOpen() const { return m_bBadFileOpen; }
272   void setBadFileOpen()       { m_bBadFileOpen = true; }
273   bool createFromImageFile (const ImageFile& rImageFile);
274
275   int nx() const  { return m_nx; }
276   int ny() const { return m_ny; }
277   ImageFileArray getArray() { return m_array; }
278   ImageFileArrayConst getArray() const { return m_array; }
279   void Activate();
280 };
281 #endif // wxUSE_GLCANVAS
282
283
284 #endif