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