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