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
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 ******************************************************************************/
31 #include "wx/docview.h"
34 #include "imagefile.h"
36 #include "projections.h"
38 #include "threadrecon.h"
40 class ProjectionFileView;
41 class PhantomFileView;
45 class Graph3dFileView;
48 class ImageFileDocument: public wxDocument
51 DECLARE_DYNAMIC_CLASS(ImageFileDocument)
52 ImageFile* m_pImageFile;
56 virtual bool OnSaveDocument (const wxString& filename);
57 virtual bool OnOpenDocument (const wxString& filename);
58 virtual bool IsModified () const;
59 virtual bool Revert ();
60 virtual void Modify (bool mod);
63 : m_bBadFileOpen(false)
65 m_pImageFile = new ImageFile;
68 virtual ~ImageFileDocument ()
73 const ImageFile& getImageFile() const { return *m_pImageFile; }
74 ImageFile& getImageFile() { return *m_pImageFile; }
75 void setImageFile (ImageFile* pImageFile)
78 m_pImageFile = pImageFile;
81 ImageFileView* getView() const;
82 bool getBadFileOpen() const { return m_bBadFileOpen; }
83 void setBadFileOpen() { m_bBadFileOpen = true; }
87 class BackgroundProcessingDocument : public wxDocument
90 DECLARE_DYNAMIC_CLASS(BackgroundProcessingDocument)
92 typedef BackgroundSupervisor BackgroundObject;
93 typedef std::vector<BackgroundObject*> BackgroundContainer;
94 BackgroundContainer m_vecpBackgroundSupervisors;
95 wxCriticalSection m_criticalSection;
99 BackgroundProcessingDocument()
103 void cancelRunningTasks();
104 #ifdef HAVE_WXTHREADS
105 void addBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
106 void removeBackgroundSupervisor (BackgroundSupervisor* pSupervisor);
109 DECLARE_EVENT_TABLE()
112 class ProjectionFileDocument: public BackgroundProcessingDocument
115 DECLARE_DYNAMIC_CLASS(ProjectionFileDocument)
116 Projections* m_pProjectionFile;
120 virtual bool OnSaveDocument (const wxString& filename);
121 virtual bool OnOpenDocument (const wxString& filename);
122 virtual bool IsModified () const;
123 virtual void Modify (bool mod);
125 ProjectionFileDocument ()
126 : m_bBadFileOpen(false)
128 m_pProjectionFile = new Projections;
131 virtual ~ProjectionFileDocument ();
133 const Projections& getProjections () const { return *m_pProjectionFile; }
134 Projections& getProjections () { return *m_pProjectionFile; }
136 void setProjections (Projections* pProjections)
137 { delete m_pProjectionFile;
138 m_pProjectionFile = pProjections;
141 ProjectionFileView* getView() const;
142 bool getBadFileOpen() const { return m_bBadFileOpen; }
143 void setBadFileOpen() { m_bBadFileOpen = true; }
148 class PhantomFileDocument: public BackgroundProcessingDocument
151 DECLARE_DYNAMIC_CLASS(PhantomFileDocument)
154 wxString m_namePhantom;
158 PhantomFileDocument ()
159 : m_idPhantom(Phantom::PHM_INVALID), m_bBadFileOpen(false)
162 virtual ~PhantomFileDocument ();
164 const int getPhantomID () const { return m_idPhantom; }
166 const wxString& getPhantomName () const { return m_namePhantom; }
168 const Phantom& getPhantom () const { return m_phantom; }
170 Phantom& getPhantom () { return m_phantom; }
172 virtual bool OnOpenDocument (const wxString& filename);
173 virtual bool OnSaveDocument (const wxString& filename);
174 virtual bool IsModified () const;
175 virtual void Modify (bool mod);
176 PhantomFileView* getView() const;
177 bool getBadFileOpen() const { return m_bBadFileOpen; }
178 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; }
219 class TextFileDocument: public wxDocument
222 DECLARE_DYNAMIC_CLASS(TextFileDocument)
226 TextFileDocument(void)
227 : m_bBadFileOpen(false)
230 virtual ~TextFileDocument(void) {}
232 virtual bool OnSaveDocument(const wxString& filename);
233 virtual bool OnOpenDocument(const wxString& filename);
234 virtual bool IsModified(void) const;
236 wxTextCtrl* getTextCtrl();
238 TextFileView* getView() const;
239 bool getBadFileOpen() const { return m_bBadFileOpen; }
240 void setBadFileOpen() { m_bBadFileOpen = true; }
248 typedef GLfloat glTripleFloat[3];
250 class Graph3dFileDocument: public wxDocument
252 friend class Graph3dFileView;
255 DECLARE_DYNAMIC_CLASS(Graph3dFileDocument)
258 glTripleFloat* m_pVertices;
259 glTripleFloat* m_pNormals;
262 ImageFileArray m_array;
265 Graph3dFileDocument(void);
266 virtual ~Graph3dFileDocument(void);
268 virtual bool OnSaveDocument (const wxString& filename);
269 virtual bool OnOpenDocument (const wxString& filename);
270 virtual bool IsModified () const;
272 Graph3dFileView* getView() const;
273 bool getBadFileOpen() const { return m_bBadFileOpen; }
274 void setBadFileOpen() { m_bBadFileOpen = true; }
275 bool createFromImageFile (const ImageFile& rImageFile);
277 int nx() const { return m_nx; }
278 int ny() const { return m_ny; }
279 ImageFileArray getArray() { return m_array; }
280 ImageFileArrayConst getArray() const { return m_array; }
283 #endif // wxUSE_GLCANVAS