r460: 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.37 2001/01/28 19:10:18 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 (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 (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   ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
237
238   wxMenu* getFileMenu()  { return m_pFileMenu; }
239
240   ProjectionFileDocument* GetDocument() 
241   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
242   DECLARE_EVENT_TABLE()
243 };
244
245 class ProjectionFileCanvas: public wxScrolledWindow
246 {
247 private:
248   ProjectionFileView* m_pView;
249
250 public:  
251   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
252   virtual ~ProjectionFileCanvas() ;
253
254   virtual wxSize GetBestSize() const;
255   virtual void OnDraw(wxDC& dc);
256   void setView(ProjectionFileView* pView)
257   { m_pView = pView; }
258 };
259
260
261 class PhantomCanvas;
262 class PhantomFileView : public wxView
263 {
264 private:
265   DECLARE_DYNAMIC_CLASS(PhantomFileView)
266   DECLARE_EVENT_TABLE()
267     
268   PhantomCanvas *CreateCanvas (wxFrame* parent);
269 #if CTSIM_MDI
270   wxDocMDIChildFrame* m_pFrame;
271   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
272 #else
273   wxDocChildFrame* m_pFrame;
274   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
275 #endif
276   
277   PhantomCanvas *m_pCanvas;
278   wxMenu* m_pFileMenu;
279   
280   int m_iDefaultNDet;
281   int m_iDefaultNView;
282   int m_iDefaultNSample;
283   int m_iDefaultGeometry;
284   int m_iDefaultTrace;
285   double m_dDefaultRotation;
286   double m_dDefaultFocalLength;
287   double m_dDefaultFieldOfView;
288   
289   int m_iDefaultRasterNX;
290   int m_iDefaultRasterNY;
291   int m_iDefaultRasterNSamples;
292
293   wxWindow* getFrameForChild() 
294 #if CTSIM_MDI
295   { return theApp->getMainFrame(); }
296 #else
297   { return m_pFrame; }
298 #endif
299
300 public:
301   PhantomFileView();
302   virtual ~PhantomFileView();
303   void canvasClosed()
304   { m_pCanvas = NULL; m_pFrame = NULL; }
305   
306   bool OnCreate(wxDocument *doc, long flags);
307   void OnUpdate(wxView *sender, wxObject *hint = NULL);
308   bool OnClose (bool deleteWindow = true);
309   void OnDraw(wxDC* dc);
310   void OnProperties (wxCommandEvent& event);
311   void OnRasterize (wxCommandEvent& event);
312   void OnProjections (wxCommandEvent& event);
313   
314   PhantomFileDocument* GetDocument() 
315   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
316   
317   wxMenu* getFileMenu() { return m_pFileMenu; }
318 #if CTSIM_MDI
319   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
320 #else
321   wxDocChildFrame* getFrame() { return m_pFrame; }
322 #endif
323 };
324
325 class PhantomCanvas: public wxScrolledWindow
326 {
327 private:
328   PhantomFileView* m_pView;
329
330 public:  
331   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
332   virtual ~PhantomCanvas();
333
334   void setView(PhantomFileView* pView)
335   { m_pView = pView; }
336   virtual void OnDraw(wxDC& dc);
337 };
338
339 class PlotFileCanvas;
340 class PlotFileView : public wxView
341 {
342   DECLARE_DYNAMIC_CLASS(PlotFileView)
343     
344 private:
345 #if CTSIM_MDI
346   wxDocMDIChildFrame* m_pFrame;
347   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
348 #else
349   wxDocChildFrame* m_pFrame;
350   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
351 #endif
352   
353   PlotFileCanvas *m_pCanvas;
354   EZPlot* m_pEZPlot;
355   wxMenu* m_pFileMenu;
356   
357   bool m_bMinSpecified;
358   bool m_bMaxSpecified;
359   double m_dMinPixel;
360   double m_dMaxPixel;
361   double m_dAutoScaleFactor;
362   
363   PlotFileCanvas *CreateCanvas (wxFrame* parent);
364   wxWindow* getFrameForChild() 
365 #if CTSIM_MDI
366   { return theApp->getMainFrame(); }
367 #else
368   { return m_pFrame; }
369 #endif
370
371 public:
372   PlotFileView();
373   virtual ~PlotFileView();
374   void canvasClosed()
375   { m_pCanvas = NULL; m_pFrame = NULL; }
376   
377   bool OnCreate(wxDocument *doc, long flags);
378   void OnDraw(wxDC* dc);
379   void OnUpdate(wxView *sender, wxObject *hint = NULL);
380   bool OnClose (bool deleteWindow = true);
381
382   void OnProperties (wxCommandEvent& event);
383   void OnScaleMinMax (wxCommandEvent& event);
384   void OnScaleAuto (wxCommandEvent& event);
385   void OnScaleFull (wxCommandEvent& event);
386   
387 #if CTSIM_MDI
388   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
389 #else
390   wxDocChildFrame* getFrame() { return m_pFrame; }
391 #endif
392   
393   wxMenu* getFileMenu() { return m_pFileMenu; }
394   PlotFileDocument* GetDocument() 
395   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
396   
397   DECLARE_EVENT_TABLE()
398 };
399
400 class PlotFileCanvas: public wxScrolledWindow
401 {
402 private:
403   PlotFileView* m_pView;
404   
405 public:
406   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
407   virtual ~PlotFileCanvas();
408  
409   virtual void OnDraw(wxDC& dc);
410
411   void setView (PlotFileView* pView)
412   { m_pView = pView; }
413 };
414
415
416 class TextFileCanvas;
417 class TextFileView: public wxView
418 {
419 private:
420   DECLARE_DYNAMIC_CLASS(TextFileView)
421
422 #if CTSIM_MDI
423   wxDocMDIChildFrame* m_pFrame;
424   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
425 #else
426   wxDocChildFrame* m_pFrame;
427   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
428 #endif
429     wxMenu* m_pFileMenu;
430     TextFileCanvas *m_pCanvas;
431   
432 public:
433     TextFileView() 
434       : wxView() , m_pFrame(0), m_pCanvas(0)
435     {}
436     ~TextFileView();
437     void canvasClosed()
438     { m_pFrame = NULL; }
439
440     bool OnCreate (wxDocument *doc, long flags);
441     void OnDraw (wxDC *dc);
442     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
443     bool OnClose (bool deleteWindow = TRUE);
444
445     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
446     wxMenu* getFileMenu() { return m_pFileMenu; }
447 #if CTSIM_MDI
448   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
449 #else
450   wxDocChildFrame* getFrame() { return m_pFrame; }
451 #endif
452 };
453
454 class TextFileCanvas: public wxTextCtrl
455 {
456     TextFileView *m_pView;
457
458 public:    
459     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
460     ~TextFileCanvas ();
461 };
462
463
464 #endif
465