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-2009 Kevin Rosenberg
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.
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.
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 ******************************************************************************/
29 #include "wx/docview.h"
32 #include "imagefile.h"
34 #include "projections.h"
36 #include "threadrecon.h"
38 class ProjectionFileView;
39 class PhantomFileView;
43 class Graph3dFileView;
46 class ImageFileDocument: public wxDocument
49 DECLARE_DYNAMIC_CLASS(ImageFileDocument)
50 ImageFile* m_pImageFile;
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);
61 : m_bBadFileOpen(false)
63 m_pImageFile = new ImageFile;
66 virtual ~ImageFileDocument ()
71 const ImageFile& getImageFile() const { return *m_pImageFile; }
72 ImageFile& getImageFile() { return *m_pImageFile; }
73 void setImageFile (ImageFile* pImageFile)
76 m_pImageFile = pImageFile;
79 ImageFileView* getView() const;
80 bool getBadFileOpen() const { return m_bBadFileOpen; }
81 void setBadFileOpen() { m_bBadFileOpen = true; }
85 class BackgroundProcessingDocument : public wxDocument
88 DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
90 typedef BackgroundSupervisor BackgroundObject;
91 typedef std::vector<BackgroundObject*> BackgroundContainer;
92 BackgroundContainer m_vecpBackgroundSupervisors;
93 wxCriticalSection m_criticalSection;
97 BackgroundProcessingDocument()
101 void cancelRunningTasks();
102 #ifdef HAVE_WXTHREADS
103 void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
104 void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
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; }
146 class PhantomFileDocument: public BackgroundProcessingDocument
149 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
152 wxString m_namePhantom;
156 PhantomFileDocument ()
157 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
160 virtual ~PhantomFileDocument ();
162 const int getPhantomID () const { return m_idPhantom; }
164 const wxString& getPhantomName () const { return m_namePhantom; }
166 const Phantom& getPhantom () const { return m_phantom; }
168 Phantom& getPhantom () { return m_phantom; }
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; }
181 class PlotFileDocument: public wxDocument
184 DECLARE_DYNAMIC_CLASS(PlotFileDocument)
191 : m_bBadFileOpen(false)
194 virtual ~PlotFileDocument ()
197 const wxString& getPlotName () const
198 { return m_namePlot; }
200 const PlotFile& getPlotFile () const
203 PlotFile& getPlotFile ()
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; }
217 class TextFileDocument: public wxDocument
220 DECLARE_DYNAMIC_CLASS(TextFileDocument)
224 TextFileDocument(void)
225 : m_bBadFileOpen(false)
228 virtual ~TextFileDocument(void) {}
230 virtual bool OnSaveDocument(const wxString& filename);
231 virtual bool OnOpenDocument(const wxString& filename);
232 virtual bool IsModified(void) const;
234 wxTextCtrl* getTextCtrl();
236 TextFileView* getView() const;
237 bool getBadFileOpen() const { return m_bBadFileOpen; }
238 void setBadFileOpen() { m_bBadFileOpen = true; }
246 typedef GLfloat glTripleFloat[3];
248 class Graph3dFileDocument: public wxDocument
250 friend class Graph3dFileView;
253 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
256 glTripleFloat* m_pVertices;
257 glTripleFloat* m_pNormals;
260 ImageFileArray m_array;
263 Graph3dFileDocument(void);
264 virtual ~Graph3dFileDocument(void);
266 virtual bool OnSaveDocument (const wxString& filename);
267 virtual bool OnOpenDocument (const wxString& filename);
268 virtual bool IsModified () const;
270 Graph3dFileView* getView() const;
271 bool getBadFileOpen() const { return m_bBadFileOpen; }
272 void setBadFileOpen() { m_bBadFileOpen = true; }
273 bool createFromImageFile (const ImageFile& rImageFile);
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; }
281 #endif // wxUSE_GLCANVAS