r458: no message
[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.36 2001/01/28 03:48:55 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   
57   ImageFileCanvas *m_pCanvas;
58   wxMenu* m_pFileMenu;
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(); }
70 #else
71   { return m_pFrame; }
72 #endif
73
74 public:
75   ImageFileView();
76   virtual ~ImageFileView();
77   void canvasClosed()
78   { m_pCanvas = 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 #if CTSIM_MDI
134   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
135 #else
136   wxDocChildFrame* getFrame() { return m_pFrame; }
137 #endif
138   
139   ImageFileDocument* GetDocument() 
140   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
141   
142   DECLARE_EVENT_TABLE()
143 };
144
145 class ImageFileCanvas: public wxScrolledWindow
146 {
147 private:
148   ImageFileView* m_pView;
149   int m_xCursor;
150   int m_yCursor;
151   
152 public:
153   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
154   virtual ~ImageFileCanvas();
155
156   virtual void OnDraw(wxDC& dc);
157   void OnMouseEvent(wxMouseEvent& event);
158   void DrawRubberBandCursor (wxDC& dc, int x, int y);
159   bool GetCurrentCursor (int& x, int& y);
160
161   virtual wxSize GetBestSize() const;
162   void setView(ImageFileView* pView)
163   { m_pView = pView; }
164
165
166   DECLARE_EVENT_TABLE()
167 };
168
169
170 class ProjectionFileCanvas;
171 class ProjectionFileView : public wxView
172 {
173   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
174     
175     wxMemoryDC m_memoryDC;
176   wxBitmap m_bitmap;
177   
178 private:
179   ProjectionFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
180 #if CTSIM_MDI
181   wxDocMDIChildFrame* m_pFrame;
182   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
183 #else
184   wxDocChildFrame* m_pFrame;
185   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
186 #endif
187   
188   ProjectionFileCanvas *m_pCanvas;
189   wxMenu* m_pFileMenu;
190   
191   int m_iDefaultNX;
192   int m_iDefaultNY;
193   int m_iDefaultFilter;
194   int m_iDefaultFilterMethod;
195   double m_dDefaultFilterParam;
196   int m_iDefaultFilterGeneration;
197   int m_iDefaultZeropad;
198   int m_iDefaultInterpolation;
199   int m_iDefaultInterpParam;
200   int m_iDefaultBackprojector;
201   int m_iDefaultTrace;
202   
203   int m_iDefaultPolarNX;
204   int m_iDefaultPolarNY;
205   int m_iDefaultPolarInterpolation;
206   int m_iDefaultPolarZeropad;
207
208   wxWindow* getFrameForChild() 
209 #if CTSIM_MDI
210   { return theApp->getMainFrame(); }
211 #else
212   { return m_pFrame; }
213 #endif
214
215 public:
216   ProjectionFileView();
217   virtual ~ProjectionFileView();
218   void canvasClosed()
219   { m_pCanvas = NULL; m_pFrame = NULL; }
220   
221   bool OnCreate(wxDocument *doc, long flags);
222   void OnDraw(wxDC* dc);
223   void OnUpdate(wxView *sender, wxObject *hint = NULL);
224   bool OnClose (bool deleteWindow = true);
225   void OnProperties (wxCommandEvent& event);
226   void OnReconstructFBP (wxCommandEvent& event);
227   void OnReconstructFourier (wxCommandEvent& event);
228   void OnConvertPolar (wxCommandEvent& event);
229   void OnConvertFFTPolar (wxCommandEvent& event);
230   
231 #if CTSIM_MDI
232   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
233 #else
234   wxDocChildFrame* getFrame() { return m_pFrame; }
235 #endif
236   wxMenu* getFileMenu()  { return m_pFileMenu; }
237
238   ProjectionFileDocument* GetDocument() 
239   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
240   DECLARE_EVENT_TABLE()
241 };
242
243 class ProjectionFileCanvas: public wxScrolledWindow
244 {
245 private:
246   ProjectionFileView* m_pView;
247
248 public:  
249   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
250   virtual ~ProjectionFileCanvas() ;
251
252   virtual wxSize GetBestSize() const;
253   virtual void OnDraw(wxDC& dc);
254   void setView(ProjectionFileView* pView)
255   { m_pView = pView; }
256 };
257
258
259 class PhantomCanvas;
260 class PhantomFileView : public wxView
261 {
262 private:
263   DECLARE_DYNAMIC_CLASS(PhantomFileView)
264   DECLARE_EVENT_TABLE()
265     
266   PhantomCanvas *CreateCanvas(wxView *view, wxFrame *parent);
267 #if CTSIM_MDI
268   wxDocMDIChildFrame* m_pFrame;
269   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
270 #else
271   wxDocChildFrame* m_pFrame;
272   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
273 #endif
274   
275   PhantomCanvas *m_pCanvas;
276   wxMenu* m_pFileMenu;
277   
278   int m_iDefaultNDet;
279   int m_iDefaultNView;
280   int m_iDefaultNSample;
281   int m_iDefaultGeometry;
282   int m_iDefaultTrace;
283   double m_dDefaultRotation;
284   double m_dDefaultFocalLength;
285   double m_dDefaultFieldOfView;
286   
287   int m_iDefaultRasterNX;
288   int m_iDefaultRasterNY;
289   int m_iDefaultRasterNSamples;
290
291   wxWindow* getFrameForChild() 
292 #if CTSIM_MDI
293   { return theApp->getMainFrame(); }
294 #else
295   { return m_pFrame; }
296 #endif
297
298 public:
299   PhantomFileView();
300   virtual ~PhantomFileView();
301   void canvasClosed()
302   { m_pCanvas = NULL; m_pFrame = NULL; }
303   
304   bool OnCreate(wxDocument *doc, long flags);
305   void OnUpdate(wxView *sender, wxObject *hint = NULL);
306   bool OnClose (bool deleteWindow = true);
307   void OnDraw(wxDC* dc);
308   void OnProperties (wxCommandEvent& event);
309   void OnRasterize (wxCommandEvent& event);
310   void OnProjections (wxCommandEvent& event);
311   
312   PhantomFileDocument* GetDocument() 
313   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
314   
315   wxMenu* getFileMenu() { return m_pFileMenu; }
316 #if CTSIM_MDI
317   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
318 #else
319   wxDocChildFrame* getFrame() { return m_pFrame; }
320 #endif
321 };
322
323 class PhantomCanvas: public wxScrolledWindow
324 {
325 private:
326   PhantomFileView* m_pView;
327
328 public:  
329   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
330   virtual ~PhantomCanvas();
331
332   void setView(PhantomFileView* pView)
333   { m_pView = pView; }
334   virtual void OnDraw(wxDC& dc);
335 };
336
337 class PlotFileCanvas;
338 class PlotFileView : public wxView
339 {
340   DECLARE_DYNAMIC_CLASS(PlotFileView)
341     
342 private:
343 #if CTSIM_MDI
344   wxDocMDIChildFrame* m_pFrame;
345   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
346 #else
347   wxDocChildFrame* m_pFrame;
348   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
349 #endif
350   
351   PlotFileCanvas *m_pCanvas;
352   EZPlot* m_pEZPlot;
353   wxMenu* m_pFileMenu;
354   
355   bool m_bMinSpecified;
356   bool m_bMaxSpecified;
357   double m_dMinPixel;
358   double m_dMaxPixel;
359   double m_dAutoScaleFactor;
360   
361   PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
362   wxWindow* getFrameForChild() 
363 #if CTSIM_MDI
364   { return theApp->getMainFrame(); }
365 #else
366   { return m_pFrame; }
367 #endif
368
369 public:
370   PlotFileView();
371   virtual ~PlotFileView();
372   void canvasClosed()
373   { m_pCanvas = NULL; m_pFrame = NULL; }
374   
375   bool OnCreate(wxDocument *doc, long flags);
376   void OnDraw(wxDC* dc);
377   void OnUpdate(wxView *sender, wxObject *hint = NULL);
378   bool OnClose (bool deleteWindow = true);
379
380   void OnProperties (wxCommandEvent& event);
381   void OnScaleMinMax (wxCommandEvent& event);
382   void OnScaleAuto (wxCommandEvent& event);
383   void OnScaleFull (wxCommandEvent& event);
384   
385 #if CTSIM_MDI
386   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
387 #else
388   wxDocChildFrame* getFrame() { return m_pFrame; }
389 #endif
390   
391   wxMenu* getFileMenu() { return m_pFileMenu; }
392   PlotFileDocument* GetDocument() 
393   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
394   
395   DECLARE_EVENT_TABLE()
396 };
397
398 class PlotFileCanvas: public wxScrolledWindow
399 {
400 private:
401   PlotFileView* m_pView;
402   
403 public:
404   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
405   virtual ~PlotFileCanvas();
406  
407   virtual void OnDraw(wxDC& dc);
408
409   void setView (PlotFileView* pView)
410   { m_pView = pView; }
411 };
412
413
414 class TextFileCanvas;
415 class TextFileView: public wxView
416 {
417 private:
418   DECLARE_DYNAMIC_CLASS(TextFileView)
419
420 #if CTSIM_MDI
421   wxDocMDIChildFrame* m_pFrame;
422   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
423 #else
424   wxDocChildFrame* m_pFrame;
425   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
426 #endif
427     wxMenu* m_pFileMenu;
428     TextFileCanvas *m_pCanvas;
429   
430 public:
431     TextFileView() 
432       : wxView() , m_pFrame(0), m_pCanvas(0)
433     {}
434     ~TextFileView();
435     void canvasClosed()
436     { m_pFrame = NULL; }
437
438     bool OnCreate (wxDocument *doc, long flags);
439     void OnDraw (wxDC *dc);
440     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
441     bool OnClose (bool deleteWindow = TRUE);
442
443     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
444     wxMenu* getFileMenu() { return m_pFileMenu; }
445 #if CTSIM_MDI
446   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
447 #else
448   wxDocChildFrame* getFrame() { return m_pFrame; }
449 #endif
450 };
451
452 class TextFileCanvas: public wxTextCtrl
453 {
454     TextFileView *m_pView;
455
456 public:    
457     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
458     ~TextFileCanvas ();
459 };
460
461
462 #endif
463