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