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