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