r435: *** empty log 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.29 2001/01/26 00:45: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 PhantomView : public wxView
246 {
247 private:
248   DECLARE_DYNAMIC_CLASS(PhantomView)
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   PhantomView(void);
280   virtual ~PhantomView(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   PhantomDocument* GetDocument(void) 
293   { return dynamic_cast<PhantomDocument*>(wxView::GetDocument()); }
294   
295   wxMenu* getFileMenu() { return m_pFileMenu; }
296 };
297
298 class PhantomCanvas: public wxScrolledWindow
299 {
300 private:
301   PhantomView* m_pView;
302
303 public:  
304   PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
305   virtual ~PhantomCanvas();
306
307   void setView(PhantomView* pView)
308   { m_pView = pView; }
309   virtual void OnDraw(wxDC& dc);
310 };
311
312 class PlotFileCanvas;
313 class PlotFileView : public wxView
314 {
315   DECLARE_DYNAMIC_CLASS(PlotFileView)
316     
317 private:
318   PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
319   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
320   
321   PlotFileCanvas *m_canvas;
322   wxFrame *m_frame;
323   wxMenu* m_pFileMenu;
324   EZPlot* m_pEZPlot;
325   
326   bool m_bMinSpecified;
327   bool m_bMaxSpecified;
328   double m_dMinPixel;
329   double m_dMaxPixel;
330   double m_dAutoScaleFactor;
331   
332   wxWindow* getFrameForChild() 
333 #if CTSIM_MDI
334   { return theApp->getMainFrame()->GetClientWindow(); }
335 #else
336   { return m_frame; }
337 #endif
338
339 public:
340   PlotFileView(void);
341   virtual ~PlotFileView(void);
342   void canvasClosed()
343   { m_canvas = NULL; m_frame = NULL; }
344   
345   bool OnCreate(wxDocument *doc, long flags);
346   void OnDraw(wxDC* dc);
347   void OnUpdate(wxView *sender, wxObject *hint = NULL);
348   bool OnClose (bool deleteWindow = true);
349
350   void OnProperties (wxCommandEvent& event);
351   void OnScaleMinMax (wxCommandEvent& event);
352   void OnScaleAuto (wxCommandEvent& event);
353   void OnScaleFull (wxCommandEvent& event);
354   
355   wxFrame* getFrame ()
356   { return m_frame; }
357   
358   wxMenu* getFileMenu() { return m_pFileMenu; }
359   PlotFileDocument* GetDocument(void) 
360   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
361   
362   DECLARE_EVENT_TABLE()
363 };
364
365 class PlotFileCanvas: public wxScrolledWindow
366 {
367 private:
368   PlotFileView* m_pView;
369   
370 public:
371   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
372   virtual ~PlotFileCanvas();
373  
374   virtual void OnDraw(wxDC& dc);
375
376   void setView (PlotFileView* pView)
377   { m_pView = pView; }
378 };
379
380
381 class TextEditCanvas;
382 class TextEditView: public wxView
383 {
384 private:
385   DECLARE_DYNAMIC_CLASS(TextEditView)
386
387     wxFrame *m_pFrame;
388     wxMenu* m_pFileMenu;
389     TextEditCanvas *m_pCanvas;
390   
391 public:
392     TextEditView() 
393       : wxView() , m_pFrame(0), m_pCanvas(0)
394     {}
395     ~TextEditView();
396     void canvasClosed()
397     { m_pFrame = NULL; }
398
399    wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
400
401     bool OnCreate (wxDocument *doc, long flags);
402     void OnDraw (wxDC *dc);
403     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
404     bool OnClose (bool deleteWindow = TRUE);
405
406     TextEditCanvas* getTextCtrl() { return m_pCanvas; }
407
408   wxMenu* getFileMenu() { return m_pFileMenu; }
409 };
410
411 class TextEditCanvas: public wxTextCtrl
412 {
413     TextEditView *m_pView;
414
415 public:    
416     TextEditCanvas (TextEditView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
417     ~TextEditCanvas ();
418 };
419
420
421 #endif
422