r442: Fixes to application shutdown
[ctsim.git] / src / views.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          view.h
5 **   Purpose:       Header file for View & Canvas routines of CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: views.h,v 1.32 2001/01/26 23:23:00 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifdef __GNUG__
29 // #pragma interface
30 #endif
31
32 #ifndef __VIEWSH__
33 #define __VIEWSH__
34
35 #include "wx/wx.h"
36 #include "docs.h"
37 #include "imagefile.h"
38
39 class ImageFileCanvas;
40 class ImageFileView : public wxView
41 {
42 private:
43   DECLARE_DYNAMIC_CLASS(ImageFileView)
44     
45   wxMemoryDC m_memoryDC;
46   wxBitmap m_bitmap;
47   
48   ImageFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
49 #if CTSIM_MDI
50   wxDocMDIChildFrame* m_pFrame;
51   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
52 #else
53   wxDocChildFrame* m_pFrame;
54   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
55 #endif
56   wxMenu* m_pFileMenu;
57   
58   ImageFileCanvas *m_canvas;
59   bool m_bMinSpecified;
60   bool m_bMaxSpecified;
61   double m_dMinPixel;
62   double m_dMaxPixel;
63   double m_dAutoScaleFactor;
64   
65   int m_iDefaultExportFormatID;
66
67   wxWindow* getFrameForChild() 
68 #if CTSIM_MDI
69   { return theApp->getMainFrame()->GetClientWindow(); }
70 #else
71   { return m_pFrame; }
72 #endif
73
74 public:
75   ImageFileView();
76   virtual ~ImageFileView();
77   void canvasClosed()
78   { m_canvas = NULL; m_pFrame = NULL; }
79
80   wxMenu* getFileMenu()
81   { return m_pFileMenu; }
82
83   bool OnCreate(wxDocument *doc, long flags);
84   void OnDraw(wxDC* dc);
85   void OnUpdate(wxView *sender, wxObject *hint = NULL);
86   bool OnClose (bool deleteWindow = true);
87   
88   void OnScaleSize (wxCommandEvent& event);
89   void OnExport (wxCommandEvent& event);
90   
91   void OnProperties (wxCommandEvent& event);
92   void OnCompare (wxCommandEvent& event);
93   
94   void OnInvertValues (wxCommandEvent& event);
95   void OnSquare (wxCommandEvent& event);
96   void OnSquareRoot (wxCommandEvent& event);
97   void OnLog (wxCommandEvent& event);
98   void OnExp (wxCommandEvent& event);
99   void OnAdd (wxCommandEvent& event);
100   void OnSubtract (wxCommandEvent& event);
101   void OnMultiply (wxCommandEvent& event);
102   void OnDivide (wxCommandEvent& event);
103   void OnFourier (wxCommandEvent& event);
104   void OnInverseFourier (wxCommandEvent& event);
105   void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
106   void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
107   
108 #ifdef HAVE_FFT
109   void OnFFT (wxCommandEvent& event);
110   void OnIFFT (wxCommandEvent& event);
111   void OnFFTRows (wxCommandEvent& event);
112   void OnIFFTRows (wxCommandEvent& event);
113   void OnFFTCols (wxCommandEvent& event);
114   void OnIFFTCols (wxCommandEvent& event);
115 #endif
116   
117   void OnMagnitude (wxCommandEvent& event);
118   void OnPhase (wxCommandEvent& event);
119   
120   void OnScaleAuto (wxCommandEvent& event);
121   void OnScaleMinMax (wxCommandEvent& event);
122   void OnScaleFull (wxCommandEvent& event);
123   void OnPlotRow (wxCommandEvent& event);
124   void OnPlotCol (wxCommandEvent& event);
125 #if HAVE_FFT
126   void OnPlotFFTRow (wxCommandEvent& event);
127   void OnPlotFFTCol (wxCommandEvent& event);
128 #endif
129   void OnPlotHistogram (wxCommandEvent& event);
130   void OnCompareRow (wxCommandEvent& event);
131   void OnCompareCol (wxCommandEvent& event);
132   
133   wxFrame* getFrame()
134   { return m_pFrame; }
135   
136   ImageFileDocument* GetDocument() 
137   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
138   
139   DECLARE_EVENT_TABLE()
140 };
141
142 class ImageFileCanvas: public wxScrolledWindow
143 {
144 private:
145   
146   int m_xCursor;
147   int m_yCursor;
148   ImageFileView* m_pView;
149   
150 public:
151   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
152   virtual ~ImageFileCanvas();
153
154   virtual void OnDraw(wxDC& dc);
155   void OnMouseEvent(wxMouseEvent& event);
156   void DrawRubberBandCursor (wxDC& dc, int x, int y);
157   bool GetCurrentCursor (int& x, int& y);
158
159   virtual wxSize GetBestSize() const;
160   void setView(ImageFileView* pView)
161   { m_pView = pView; }
162
163
164   DECLARE_EVENT_TABLE()
165 };
166
167
168 class ProjectionFileCanvas;
169 class ProjectionFileView : public wxView
170 {
171   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
172     
173     wxMemoryDC m_memoryDC;
174   wxBitmap m_bitmap;
175   
176 private:
177   ProjectionFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
178 #if CTSIM_MDI
179   wxDocMDIChildFrame* m_pFrame;
180   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
181 #else
182   wxDocChildFrame* m_pFrame;
183   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
184 #endif
185   
186   ProjectionFileCanvas *m_canvas;
187   wxMenu* m_pFileMenu;
188   
189   int m_iDefaultNX;
190   int m_iDefaultNY;
191   int m_iDefaultFilter;
192   int m_iDefaultFilterMethod;
193   double m_dDefaultFilterParam;
194   int m_iDefaultFilterGeneration;
195   int m_iDefaultZeropad;
196   int m_iDefaultInterpolation;
197   int m_iDefaultInterpParam;
198   int m_iDefaultBackprojector;
199   int m_iDefaultTrace;
200   
201   int m_iDefaultPolarNX;
202   int m_iDefaultPolarNY;
203   int m_iDefaultPolarInterpolation;
204   int m_iDefaultPolarZeropad;
205
206   wxWindow* getFrameForChild() 
207 #if CTSIM_MDI
208   { return theApp->getMainFrame()->GetClientWindow(); }
209 #else
210   { return m_pFrame; }
211 #endif
212
213 public:
214   ProjectionFileView();
215   virtual ~ProjectionFileView();
216   void canvasClosed()
217   { m_canvas = NULL; m_pFrame = NULL; }
218   
219   bool OnCreate(wxDocument *doc, long flags);
220   void OnDraw(wxDC* dc);
221   void OnUpdate(wxView *sender, wxObject *hint = NULL);
222   bool OnClose (bool deleteWindow = true);
223   void OnProperties (wxCommandEvent& event);
224   void OnReconstructFBP (wxCommandEvent& event);
225   void OnReconstructFourier (wxCommandEvent& event);
226   void OnConvertPolar (wxCommandEvent& event);
227   void OnConvertFFTPolar (wxCommandEvent& event);
228   
229   wxFrame* getFrame ()   { return m_pFrame; }
230   
231   wxMenu* getFileMenu()  { return m_pFileMenu; }
232
233   ProjectionFileDocument* GetDocument() 
234   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
235   DECLARE_EVENT_TABLE()
236 };
237
238 class ProjectionFileCanvas: public wxScrolledWindow
239 {
240 private:
241   ProjectionFileView* m_pView;
242
243 public:  
244   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
245   virtual ~ProjectionFileCanvas() ;
246
247   virtual wxSize GetBestSize() const;
248   virtual void OnDraw(wxDC& dc);
249   void setView(ProjectionFileView* pView)
250   { m_pView = pView; }
251 };
252
253
254 class PhantomCanvas;
255 class PhantomFileView : public wxView
256 {
257 private:
258   DECLARE_DYNAMIC_CLASS(PhantomFileView)
259   DECLARE_EVENT_TABLE()
260     
261   PhantomCanvas *CreateCanvas(wxView *view, wxFrame *parent);
262 #if CTSIM_MDI
263   wxDocMDIChildFrame* m_pFrame;
264   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
265 #else
266   wxDocChildFrame* m_pFrame;
267   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
268 #endif
269   
270   PhantomCanvas *m_canvas;
271   wxMenu* m_pFileMenu;
272   
273   int m_iDefaultNDet;
274   int m_iDefaultNView;
275   int m_iDefaultNSample;
276   int m_iDefaultGeometry;
277   int m_iDefaultTrace;
278   double m_dDefaultRotation;
279   double m_dDefaultFocalLength;
280   double m_dDefaultFieldOfView;
281   
282   int m_iDefaultRasterNX;
283   int m_iDefaultRasterNY;
284   int m_iDefaultRasterNSamples;
285
286   wxWindow* getFrameForChild() 
287 #if CTSIM_MDI
288   { return theApp->getMainFrame()->GetClientWindow(); }
289 #else
290   { return m_pFrame; }
291 #endif
292
293 public:
294   PhantomFileView();
295   virtual ~PhantomFileView();
296   void canvasClosed()
297   { m_canvas = NULL; m_pFrame = NULL; }
298   
299   bool OnCreate(wxDocument *doc, long flags);
300   void OnUpdate(wxView *sender, wxObject *hint = NULL);
301   bool OnClose (bool deleteWindow = true);
302   void OnDraw(wxDC* dc);
303   void OnProperties (wxCommandEvent& event);
304   void OnRasterize (wxCommandEvent& event);
305   void OnProjections (wxCommandEvent& event);
306   
307   PhantomFileDocument* GetDocument() 
308   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
309   
310   wxMenu* getFileMenu() { return m_pFileMenu; }
311   wxFrame* getFrame() { return m_pFrame; }
312 };
313
314 class PhantomCanvas: public wxScrolledWindow
315 {
316 private:
317   PhantomFileView* m_pView;
318
319 public:  
320   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
321   virtual ~PhantomCanvas();
322
323   void setView(PhantomFileView* pView)
324   { m_pView = pView; }
325   virtual void OnDraw(wxDC& dc);
326 };
327
328 class PlotFileCanvas;
329 class PlotFileView : public wxView
330 {
331   DECLARE_DYNAMIC_CLASS(PlotFileView)
332     
333 private:
334   PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
335 #if CTSIM_MDI
336   wxDocMDIChildFrame* m_pFrame;
337   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
338 #else
339   wxDocChildFrame* m_pFrame;
340   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
341 #endif
342   
343   PlotFileCanvas *m_canvas;
344   wxMenu* m_pFileMenu;
345   EZPlot* m_pEZPlot;
346   
347   bool m_bMinSpecified;
348   bool m_bMaxSpecified;
349   double m_dMinPixel;
350   double m_dMaxPixel;
351   double m_dAutoScaleFactor;
352   
353   wxWindow* getFrameForChild() 
354 #if CTSIM_MDI
355   { return theApp->getMainFrame()->GetClientWindow(); }
356 #else
357   { return m_pFrame; }
358 #endif
359
360 public:
361   PlotFileView();
362   virtual ~PlotFileView();
363   void canvasClosed()
364   { m_canvas = NULL; m_pFrame = NULL; }
365   
366   bool OnCreate(wxDocument *doc, long flags);
367   void OnDraw(wxDC* dc);
368   void OnUpdate(wxView *sender, wxObject *hint = NULL);
369   bool OnClose (bool deleteWindow = true);
370
371   void OnProperties (wxCommandEvent& event);
372   void OnScaleMinMax (wxCommandEvent& event);
373   void OnScaleAuto (wxCommandEvent& event);
374   void OnScaleFull (wxCommandEvent& event);
375   
376   wxFrame* getFrame ()
377   { return m_pFrame; }
378   
379   wxMenu* getFileMenu() { return m_pFileMenu; }
380   PlotFileDocument* GetDocument() 
381   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
382   
383   DECLARE_EVENT_TABLE()
384 };
385
386 class PlotFileCanvas: public wxScrolledWindow
387 {
388 private:
389   PlotFileView* m_pView;
390   
391 public:
392   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
393   virtual ~PlotFileCanvas();
394  
395   virtual void OnDraw(wxDC& dc);
396
397   void setView (PlotFileView* pView)
398   { m_pView = pView; }
399 };
400
401
402 class TextFileCanvas;
403 class TextFileView: public wxView
404 {
405 private:
406   DECLARE_DYNAMIC_CLASS(TextFileView)
407
408 #if CTSIM_MDI
409   wxDocMDIChildFrame* m_pFrame;
410   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
411 #else
412   wxDocChildFrame* m_pFrame;
413   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
414 #endif
415     wxMenu* m_pFileMenu;
416     TextFileCanvas *m_pCanvas;
417   
418 public:
419     TextFileView() 
420       : wxView() , m_pFrame(0), m_pCanvas(0)
421     {}
422     ~TextFileView();
423     void canvasClosed()
424     { m_pFrame = NULL; }
425
426     bool OnCreate (wxDocument *doc, long flags);
427     void OnDraw (wxDC *dc);
428     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
429     bool OnClose (bool deleteWindow = TRUE);
430
431     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
432     wxFrame* getFrame() { return m_pFrame; }
433     wxMenu* getFileMenu() { return m_pFileMenu; }
434 };
435
436 class TextFileCanvas: public wxTextCtrl
437 {
438     TextFileView *m_pView;
439
440 public:    
441     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
442     ~TextFileCanvas ();
443 };
444
445
446 #endif
447