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.26 2001/02/25 16:21:36 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 class ImageFileDocument: public wxDocument
54 DECLARE_DYNAMIC_CLASS(ImageFileDocument)
55 ImageFile* m_pImageFile;
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);
66 : m_bBadFileOpen(false)
68 m_pImageFile = new ImageFile;
71 virtual ~ImageFileDocument ()
76 const ImageFile& getImageFile() const { return *m_pImageFile; }
77 ImageFile& getImageFile() { return *m_pImageFile; }
78 void setImageFile (ImageFile* pImageFile)
81 m_pImageFile = pImageFile;
84 ImageFileView* getView() const;
85 bool getBadFileOpen() const { return m_bBadFileOpen; }
86 void setBadFileOpen() { m_bBadFileOpen = true; }
89 class BackgroundProcessingDocument : public wxDocument
92 DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
93 typedef BackgroundSupervisor BackgroundObject;
94 typedef std::vector<BackgroundObject*> BackgroundContainer;
95 BackgroundContainer m_vecpBackgroundSupervisors;
96 wxCriticalSection m_criticalSection;
99 BackgroundProcessingDocument()
103 void cancelRunningTasks();
104 void OnAddBackground (wxCommandEvent& event);
105 void OnRemoveBackground (wxCommandEvent& event);
107 DECLARE_EVENT_TABLE()
110 class ProjectionFileDocument: public BackgroundProcessingDocument
113 DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
114 Projections* m_pProjectionFile;
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);
123 ProjectionFileDocument ()
124 : m_bBadFileOpen(false)
126 m_pProjectionFile = new Projections;
129 virtual ~ProjectionFileDocument ();
131 const Projections& getProjections () const { return *m_pProjectionFile; }
132 Projections& getProjections () { return *m_pProjectionFile; }
134 void setProjections (Projections* pProjections)
135 { delete m_pProjectionFile;
136 m_pProjectionFile = pProjections;
139 ProjectionFileView* getView() const;
140 bool getBadFileOpen() const { return m_bBadFileOpen; }
141 void setBadFileOpen() { m_bBadFileOpen = true; }
145 class PhantomFileDocument: public BackgroundProcessingDocument
148 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
151 wxString m_namePhantom;
155 PhantomFileDocument ()
156 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
159 virtual ~PhantomFileDocument ();
161 const int getPhantomID () const { return m_idPhantom; }
163 const wxString& getPhantomName () const { return m_namePhantom; }
165 const Phantom& getPhantom () const { return m_phantom; }
167 Phantom& getPhantom () { return m_phantom; }
169 virtual bool OnOpenDocument (const wxString& filename);
170 virtual bool OnSaveDocument (const wxString& filename);
171 virtual bool IsModified () const;
172 virtual void Modify (bool mod);
173 PhantomFileView* getView() const;
174 bool getBadFileOpen() const { return m_bBadFileOpen; }
175 void setBadFileOpen() { m_bBadFileOpen = true; }
179 class PlotFileDocument: public wxDocument
182 DECLARE_DYNAMIC_CLASS(PlotFileDocument)
189 : m_bBadFileOpen(false)
192 virtual ~PlotFileDocument ()
195 const wxString& getPlotName () const
196 { return m_namePlot; }
198 const PlotFile& getPlotFile () const
201 PlotFile& getPlotFile ()
204 virtual bool OnOpenDocument (const wxString& filename);
205 virtual bool OnSaveDocument (const wxString& filename);
206 virtual bool IsModified () const;
207 virtual void Modify (bool mod);
208 PlotFileView* getView() const;
209 bool getBadFileOpen() const { return m_bBadFileOpen; }
210 void setBadFileOpen() { m_bBadFileOpen = true; }
214 class TextFileDocument: public wxDocument
217 DECLARE_DYNAMIC_CLASS(TextFileDocument)
221 TextFileDocument(void)
222 : m_bBadFileOpen(false)
225 virtual ~TextFileDocument(void) {}
227 virtual bool OnSaveDocument(const wxString& filename);
228 virtual bool OnOpenDocument(const wxString& filename);
229 virtual bool IsModified(void) const;
231 wxTextCtrl* getTextCtrl();
233 TextFileView* getView() const;
234 bool getBadFileOpen() const { return m_bBadFileOpen; }
235 void setBadFileOpen() { m_bBadFileOpen = true; }
243 typedef GLfloat glTripleFloat[3];
245 class Graph3dFileDocument: public wxDocument
247 friend Graph3dFileView;
250 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
253 glTripleFloat* m_pVertices;
254 glTripleFloat* m_pNormals;
257 ImageFileArray m_array;
260 Graph3dFileDocument(void);
261 virtual ~Graph3dFileDocument(void);
263 virtual bool OnSaveDocument (const wxString& filename);
264 virtual bool OnOpenDocument (const wxString& filename);
265 virtual bool IsModified () const;
267 Graph3dFileView* getView() const;
268 bool getBadFileOpen() const { return m_bBadFileOpen; }
269 void setBadFileOpen() { m_bBadFileOpen = true; }
270 bool createFromImageFile (const ImageFile& rImageFile);
272 int nx() const { return m_nx; }
273 int ny() const { return m_ny; }
274 ImageFileArray getArray() { return m_array; }
275 ImageFileArrayConst getArray() const { return m_array; }
277 #endif // wxUSE_GLCANVAS