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.33 2002/06/06 22:50:24 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;
52 class ImageFileDocument: public wxDocument
55 DECLARE_DYNAMIC_CLASS(ImageFileDocument)
56 ImageFile* m_pImageFile;
60 virtual bool OnSaveDocument (const wxString& filename);
61 virtual bool OnOpenDocument (const wxString& filename);
62 virtual bool IsModified () const;
63 virtual bool Revert ();
64 virtual void Modify (bool mod);
67 : m_bBadFileOpen(false)
69 m_pImageFile = new ImageFile;
72 virtual ~ImageFileDocument ()
77 const ImageFile& getImageFile() const { return *m_pImageFile; }
78 ImageFile& getImageFile() { return *m_pImageFile; }
79 void setImageFile (ImageFile* pImageFile)
82 m_pImageFile = pImageFile;
85 ImageFileView* getView() const;
86 bool getBadFileOpen() const { return m_bBadFileOpen; }
87 void setBadFileOpen() { m_bBadFileOpen = true; }
91 class BackgroundProcessingDocument : public wxDocument
94 DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
96 typedef BackgroundSupervisor BackgroundObject;
97 typedef std::vector<BackgroundObject*> BackgroundContainer;
98 BackgroundContainer m_vecpBackgroundSupervisors;
99 wxCriticalSection m_criticalSection;
103 BackgroundProcessingDocument()
107 void cancelRunningTasks();
108 #ifdef HAVE_WXTHREADS
109 void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
110 void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
113 DECLARE_EVENT_TABLE()
116 class ProjectionFileDocument: public BackgroundProcessingDocument
119 DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
120 Projections* m_pProjectionFile;
124 virtual bool OnSaveDocument (const wxString& filename);
125 virtual bool OnOpenDocument (const wxString& filename);
126 virtual bool IsModified () const;
127 virtual void Modify (bool mod);
129 ProjectionFileDocument ()
130 : m_bBadFileOpen(false)
132 m_pProjectionFile = new Projections;
135 virtual ~ProjectionFileDocument ();
137 const Projections& getProjections () const { return *m_pProjectionFile; }
138 Projections& getProjections () { return *m_pProjectionFile; }
140 void setProjections (Projections* pProjections)
141 { delete m_pProjectionFile;
142 m_pProjectionFile = pProjections;
145 ProjectionFileView* getView() const;
146 bool getBadFileOpen() const { return m_bBadFileOpen; }
147 void setBadFileOpen() { m_bBadFileOpen = true; }
152 class PhantomFileDocument: public BackgroundProcessingDocument
155 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
158 wxString m_namePhantom;
162 PhantomFileDocument ()
163 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
166 virtual ~PhantomFileDocument ();
168 const int getPhantomID () const { return m_idPhantom; }
170 const wxString& getPhantomName () const { return m_namePhantom; }
172 const Phantom& getPhantom () const { return m_phantom; }
174 Phantom& getPhantom () { return m_phantom; }
176 virtual bool OnOpenDocument (const wxString& filename);
177 virtual bool OnSaveDocument (const wxString& filename);
178 virtual bool IsModified () const;
179 virtual void Modify (bool mod);
180 PhantomFileView* getView() const;
181 bool getBadFileOpen() const { return m_bBadFileOpen; }
182 void setBadFileOpen() { m_bBadFileOpen = true; }
187 class PlotFileDocument: public wxDocument
190 DECLARE_DYNAMIC_CLASS(PlotFileDocument)
197 : m_bBadFileOpen(false)
200 virtual ~PlotFileDocument ()
203 const wxString& getPlotName () const
204 { return m_namePlot; }
206 const PlotFile& getPlotFile () const
209 PlotFile& getPlotFile ()
212 virtual bool OnOpenDocument (const wxString& filename);
213 virtual bool OnSaveDocument (const wxString& filename);
214 virtual bool IsModified () const;
215 virtual void Modify (bool mod);
216 PlotFileView* getView() const;
217 bool getBadFileOpen() const { return m_bBadFileOpen; }
218 void setBadFileOpen() { m_bBadFileOpen = true; }
223 class TextFileDocument: public wxDocument
226 DECLARE_DYNAMIC_CLASS(TextFileDocument)
230 TextFileDocument(void)
231 : m_bBadFileOpen(false)
234 virtual ~TextFileDocument(void) {}
236 virtual bool OnSaveDocument(const wxString& filename);
237 virtual bool OnOpenDocument(const wxString& filename);
238 virtual bool IsModified(void) const;
240 wxTextCtrl* getTextCtrl();
242 TextFileView* getView() const;
243 bool getBadFileOpen() const { return m_bBadFileOpen; }
244 void setBadFileOpen() { m_bBadFileOpen = true; }
252 typedef GLfloat glTripleFloat[3];
254 class Graph3dFileDocument: public wxDocument
256 friend class Graph3dFileView;
259 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
262 glTripleFloat* m_pVertices;
263 glTripleFloat* m_pNormals;
266 ImageFileArray m_array;
269 Graph3dFileDocument(void);
270 virtual ~Graph3dFileDocument(void);
272 virtual bool OnSaveDocument (const wxString& filename);
273 virtual bool OnOpenDocument (const wxString& filename);
274 virtual bool IsModified () const;
276 Graph3dFileView* getView() const;
277 bool getBadFileOpen() const { return m_bBadFileOpen; }
278 void setBadFileOpen() { m_bBadFileOpen = true; }
279 bool createFromImageFile (const ImageFile& rImageFile);
281 int nx() const { return m_nx; }
282 int ny() const { return m_ny; }
283 ImageFileArray getArray() { return m_array; }
284 ImageFileArrayConst getArray() const { return m_array; }
287 #endif // wxUSE_GLCANVAS