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.28 2001/03/05 17:26:46 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)
94 typedef BackgroundSupervisor BackgroundObject;
95 typedef std::vector<BackgroundObject*> BackgroundContainer;
96 BackgroundContainer m_vecpBackgroundSupervisors;
97 wxCriticalSection m_criticalSection;
101 BackgroundProcessingDocument()
105 void cancelRunningTasks();
106 #ifdef HAVE_WXTHREADS
107 void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
108 void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
111 DECLARE_EVENT_TABLE()
114 class ProjectionFileDocument: public BackgroundProcessingDocument
117 DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
118 Projections* m_pProjectionFile;
122 virtual bool OnSaveDocument (const wxString& filename);
123 virtual bool OnOpenDocument (const wxString& filename);
124 virtual bool IsModified () const;
125 virtual void Modify (bool mod);
127 ProjectionFileDocument ()
128 : m_bBadFileOpen(false)
130 m_pProjectionFile = new Projections;
133 virtual ~ProjectionFileDocument ();
135 const Projections& getProjections () const { return *m_pProjectionFile; }
136 Projections& getProjections () { return *m_pProjectionFile; }
138 void setProjections (Projections* pProjections)
139 { delete m_pProjectionFile;
140 m_pProjectionFile = pProjections;
143 ProjectionFileView* getView() const;
144 bool getBadFileOpen() const { return m_bBadFileOpen; }
145 void setBadFileOpen() { m_bBadFileOpen = true; }
149 class PhantomFileDocument: public BackgroundProcessingDocument
152 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
155 wxString m_namePhantom;
159 PhantomFileDocument ()
160 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
163 virtual ~PhantomFileDocument ();
165 const int getPhantomID () const { return m_idPhantom; }
167 const wxString& getPhantomName () const { return m_namePhantom; }
169 const Phantom& getPhantom () const { return m_phantom; }
171 Phantom& getPhantom () { return m_phantom; }
173 virtual bool OnOpenDocument (const wxString& filename);
174 virtual bool OnSaveDocument (const wxString& filename);
175 virtual bool IsModified () const;
176 virtual void Modify (bool mod);
177 PhantomFileView* getView() const;
178 bool getBadFileOpen() const { return m_bBadFileOpen; }
179 void setBadFileOpen() { m_bBadFileOpen = true; }
183 class PlotFileDocument: public wxDocument
186 DECLARE_DYNAMIC_CLASS(PlotFileDocument)
193 : m_bBadFileOpen(false)
196 virtual ~PlotFileDocument ()
199 const wxString& getPlotName () const
200 { return m_namePlot; }
202 const PlotFile& getPlotFile () const
205 PlotFile& getPlotFile ()
208 virtual bool OnOpenDocument (const wxString& filename);
209 virtual bool OnSaveDocument (const wxString& filename);
210 virtual bool IsModified () const;
211 virtual void Modify (bool mod);
212 PlotFileView* getView() const;
213 bool getBadFileOpen() const { return m_bBadFileOpen; }
214 void setBadFileOpen() { m_bBadFileOpen = true; }
218 class TextFileDocument: public wxDocument
221 DECLARE_DYNAMIC_CLASS(TextFileDocument)
225 TextFileDocument(void)
226 : m_bBadFileOpen(false)
229 virtual ~TextFileDocument(void) {}
231 virtual bool OnSaveDocument(const wxString& filename);
232 virtual bool OnOpenDocument(const wxString& filename);
233 virtual bool IsModified(void) const;
235 wxTextCtrl* getTextCtrl();
237 TextFileView* getView() const;
238 bool getBadFileOpen() const { return m_bBadFileOpen; }
239 void setBadFileOpen() { m_bBadFileOpen = true; }
247 typedef GLfloat glTripleFloat[3];
249 class Graph3dFileDocument: public wxDocument
251 friend Graph3dFileView;
254 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
257 glTripleFloat* m_pVertices;
258 glTripleFloat* m_pNormals;
261 ImageFileArray m_array;
264 Graph3dFileDocument(void);
265 virtual ~Graph3dFileDocument(void);
267 virtual bool OnSaveDocument (const wxString& filename);
268 virtual bool OnOpenDocument (const wxString& filename);
269 virtual bool IsModified () const;
271 Graph3dFileView* getView() const;
272 bool getBadFileOpen() const { return m_bBadFileOpen; }
273 void setBadFileOpen() { m_bBadFileOpen = true; }
274 bool createFromImageFile (const ImageFile& rImageFile);
276 int nx() const { return m_nx; }
277 int ny() const { return m_ny; }
278 ImageFileArray getArray() { return m_array; }
279 ImageFileArrayConst getArray() const { return m_array; }
281 #endif // wxUSE_GLCANVAS