1 /*****************************************************************************
5 ** Purpose: Header file for Document routines of CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: docs.h,v 1.32 2002/06/04 19:19:40 kevin Exp $
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.
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.
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 ******************************************************************************/
35 #include "wx/docview.h"
38 #include "imagefile.h"
40 #include "projections.h"
42 #include "threadrecon.h"
44 class ProjectionFileView;
45 class PhantomFileView;
49 class Graph3dFileView;
51 extern const char szNEW_IMAGE_FILENAME[];
52 extern const char szNEW_PROJECTION_FILENAME[];
53 extern const char szNEW_GRAPH3D_FILENAME[];
54 extern const char szNEW_PLOT_FILENAME[];
57 class ImageFileDocument: public wxDocument
60 DECLARE_DYNAMIC_CLASS(ImageFileDocument)
61 ImageFile* m_pImageFile;
65 virtual bool OnSaveDocument (const wxString& filename);
66 virtual bool OnOpenDocument (const wxString& filename);
67 virtual bool IsModified () const;
68 virtual bool Revert ();
69 virtual void Modify (bool mod);
72 : m_bBadFileOpen(false)
74 m_pImageFile = new ImageFile;
77 virtual ~ImageFileDocument ()
82 const ImageFile& getImageFile() const { return *m_pImageFile; }
83 ImageFile& getImageFile() { return *m_pImageFile; }
84 void setImageFile (ImageFile* pImageFile)
87 m_pImageFile = pImageFile;
90 ImageFileView* getView() const;
91 bool getBadFileOpen() const { return m_bBadFileOpen; }
92 void setBadFileOpen() { m_bBadFileOpen = true; }
96 class BackgroundProcessingDocument : public wxDocument
99 DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
100 #ifdef HAVE_WXTHREADS
101 typedef BackgroundSupervisor BackgroundObject;
102 typedef std::vector<BackgroundObject*> BackgroundContainer;
103 BackgroundContainer m_vecpBackgroundSupervisors;
104 wxCriticalSection m_criticalSection;
108 BackgroundProcessingDocument()
112 void cancelRunningTasks();
113 #ifdef HAVE_WXTHREADS
114 void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
115 void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
118 DECLARE_EVENT_TABLE()
121 class ProjectionFileDocument: public BackgroundProcessingDocument
124 DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
125 Projections* m_pProjectionFile;
129 virtual bool OnSaveDocument (const wxString& filename);
130 virtual bool OnOpenDocument (const wxString& filename);
131 virtual bool IsModified () const;
132 virtual void Modify (bool mod);
134 ProjectionFileDocument ()
135 : m_bBadFileOpen(false)
137 m_pProjectionFile = new Projections;
140 virtual ~ProjectionFileDocument ();
142 const Projections& getProjections () const { return *m_pProjectionFile; }
143 Projections& getProjections () { return *m_pProjectionFile; }
145 void setProjections (Projections* pProjections)
146 { delete m_pProjectionFile;
147 m_pProjectionFile = pProjections;
150 ProjectionFileView* getView() const;
151 bool getBadFileOpen() const { return m_bBadFileOpen; }
152 void setBadFileOpen() { m_bBadFileOpen = true; }
157 class PhantomFileDocument: public BackgroundProcessingDocument
160 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
163 wxString m_namePhantom;
167 PhantomFileDocument ()
168 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
171 virtual ~PhantomFileDocument ();
173 const int getPhantomID () const { return m_idPhantom; }
175 const wxString& getPhantomName () const { return m_namePhantom; }
177 const Phantom& getPhantom () const { return m_phantom; }
179 Phantom& getPhantom () { return m_phantom; }
181 virtual bool OnOpenDocument (const wxString& filename);
182 virtual bool OnSaveDocument (const wxString& filename);
183 virtual bool IsModified () const;
184 virtual void Modify (bool mod);
185 PhantomFileView* getView() const;
186 bool getBadFileOpen() const { return m_bBadFileOpen; }
187 void setBadFileOpen() { m_bBadFileOpen = true; }
192 class PlotFileDocument: public wxDocument
195 DECLARE_DYNAMIC_CLASS(PlotFileDocument)
202 : m_bBadFileOpen(false)
205 virtual ~PlotFileDocument ()
208 const wxString& getPlotName () const
209 { return m_namePlot; }
211 const PlotFile& getPlotFile () const
214 PlotFile& getPlotFile ()
217 virtual bool OnOpenDocument (const wxString& filename);
218 virtual bool OnSaveDocument (const wxString& filename);
219 virtual bool IsModified () const;
220 virtual void Modify (bool mod);
221 PlotFileView* getView() const;
222 bool getBadFileOpen() const { return m_bBadFileOpen; }
223 void setBadFileOpen() { m_bBadFileOpen = true; }
228 class TextFileDocument: public wxDocument
231 DECLARE_DYNAMIC_CLASS(TextFileDocument)
235 TextFileDocument(void)
236 : m_bBadFileOpen(false)
239 virtual ~TextFileDocument(void) {}
241 virtual bool OnSaveDocument(const wxString& filename);
242 virtual bool OnOpenDocument(const wxString& filename);
243 virtual bool IsModified(void) const;
245 wxTextCtrl* getTextCtrl();
247 TextFileView* getView() const;
248 bool getBadFileOpen() const { return m_bBadFileOpen; }
249 void setBadFileOpen() { m_bBadFileOpen = true; }
257 typedef GLfloat glTripleFloat[3];
259 class Graph3dFileDocument: public wxDocument
261 friend class Graph3dFileView;
264 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
267 glTripleFloat* m_pVertices;
268 glTripleFloat* m_pNormals;
271 ImageFileArray m_array;
274 Graph3dFileDocument(void);
275 virtual ~Graph3dFileDocument(void);
277 virtual bool OnSaveDocument (const wxString& filename);
278 virtual bool OnOpenDocument (const wxString& filename);
279 virtual bool IsModified () const;
281 Graph3dFileView* getView() const;
282 bool getBadFileOpen() const { return m_bBadFileOpen; }
283 void setBadFileOpen() { m_bBadFileOpen = true; }
284 bool createFromImageFile (const ImageFile& rImageFile);
286 int nx() const { return m_nx; }
287 int ny() const { return m_ny; }
288 ImageFileArray getArray() { return m_array; }
289 ImageFileArrayConst getArray() const { return m_array; }
292 #endif // wxUSE_GLCANVAS