r355: Polar conversions of projections
[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.26 2001/01/06 15:33:15 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   DECLARE_DYNAMIC_CLASS(ImageFileView)
43     
44     wxMemoryDC m_memoryDC;
45   wxBitmap m_bitmap;
46   
47 private:
48   ImageFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
49   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
50   
51   ImageFileCanvas *m_canvas;
52   wxFrame *m_frame;
53   bool m_bMinSpecified;
54   bool m_bMaxSpecified;
55   double m_dMinPixel;
56   double m_dMaxPixel;
57   double m_dAutoScaleFactor;
58   
59   int m_iDefaultExportFormatID;
60   
61 public:
62   ImageFileView(void);
63   virtual ~ImageFileView(void);
64   
65   bool OnCreate(wxDocument *doc, long flags);
66   void OnDraw(wxDC* dc);
67   void OnUpdate(wxView *sender, wxObject *hint = NULL);
68   bool OnClose (bool deleteWindow = true);
69   
70   void OnScaleSize (wxCommandEvent& event);
71   void OnExport (wxCommandEvent& event);
72   
73   void OnProperties (wxCommandEvent& event);
74   void OnCompare (wxCommandEvent& event);
75   
76   void OnInvertValues (wxCommandEvent& event);
77   void OnSquare (wxCommandEvent& event);
78   void OnSquareRoot (wxCommandEvent& event);
79   void OnLog (wxCommandEvent& event);
80   void OnExp (wxCommandEvent& event);
81   void OnAdd (wxCommandEvent& event);
82   void OnSubtract (wxCommandEvent& event);
83   void OnMultiply (wxCommandEvent& event);
84   void OnDivide (wxCommandEvent& event);
85   void OnFourier (wxCommandEvent& event);
86   void OnInverseFourier (wxCommandEvent& event);
87   void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
88   void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
89   
90 #ifdef HAVE_FFT
91   void OnFFT (wxCommandEvent& event);
92   void OnIFFT (wxCommandEvent& event);
93   void OnFFTRows (wxCommandEvent& event);
94   void OnIFFTRows (wxCommandEvent& event);
95   void OnFFTCols (wxCommandEvent& event);
96   void OnIFFTCols (wxCommandEvent& event);
97 #endif
98   
99   void OnMagnitude (wxCommandEvent& event);
100   void OnPhase (wxCommandEvent& event);
101   
102   void OnScaleAuto (wxCommandEvent& event);
103   void OnScaleMinMax (wxCommandEvent& event);
104   void OnScaleFull (wxCommandEvent& event);
105   void OnPlotRow (wxCommandEvent& event);
106   void OnPlotCol (wxCommandEvent& event);
107 #if HAVE_FFT
108   void OnPlotFFTRow (wxCommandEvent& event);
109   void OnPlotFFTCol (wxCommandEvent& event);
110 #endif
111   void OnPlotHistogram (wxCommandEvent& event);
112   void OnCompareRow (wxCommandEvent& event);
113   void OnCompareCol (wxCommandEvent& event);
114   
115   wxFrame* getFrame()
116   { return m_frame; }
117   
118   ImageFileDocument* GetDocument(void) 
119   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
120   
121   DECLARE_EVENT_TABLE()
122 };
123
124 class ImageFileCanvas: public wxScrolledWindow
125 {
126 private:
127   
128   int m_xCursor;
129   int m_yCursor;
130   
131 public:
132   ImageFileView* m_pView;
133   
134   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
135   virtual void OnDraw(wxDC& dc);
136   void OnMouseEvent(wxMouseEvent& event);
137   void DrawRubberBandCursor (wxDC& dc, int x, int y);
138   bool GetCurrentCursor (int& x, int& y);
139   
140   DECLARE_EVENT_TABLE()
141 };
142
143
144 class ProjectionFileCanvas;
145 class ProjectionFileView : public wxView
146 {
147   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
148     
149     wxMemoryDC m_memoryDC;
150   wxBitmap m_bitmap;
151   
152 private:
153   ProjectionFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
154   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
155   
156   ProjectionFileCanvas *m_canvas;
157   wxFrame *m_frame;
158   
159   int m_iDefaultNX;
160   int m_iDefaultNY;
161   int m_iDefaultFilter;
162   int m_iDefaultFilterMethod;
163   double m_dDefaultFilterParam;
164   int m_iDefaultFilterGeneration;
165   int m_iDefaultZeropad;
166   int m_iDefaultInterpolation;
167   int m_iDefaultInterpParam;
168   int m_iDefaultBackprojector;
169   int m_iDefaultTrace;
170   
171   int m_iDefaultPolarNX;
172   int m_iDefaultPolarNY;
173   int m_iDefaultPolarInterpolation;
174   int m_iDefaultPolarZeropad;
175
176 public:
177   ProjectionFileView(void);
178   virtual ~ProjectionFileView(void);
179   
180   bool OnCreate(wxDocument *doc, long flags);
181   void OnDraw(wxDC* dc);
182   void OnUpdate(wxView *sender, wxObject *hint = NULL);
183   bool OnClose (bool deleteWindow = true);
184   void OnProperties (wxCommandEvent& event);
185   void OnReconstructFBP (wxCommandEvent& event);
186   void OnReconstructFourier (wxCommandEvent& event);
187   void OnConvertPolar (wxCommandEvent& event);
188   void OnConvertFFTPolar (wxCommandEvent& event);
189   
190   wxFrame* getFrame ()
191   { return m_frame; }
192   
193   ProjectionFileDocument* GetDocument(void) 
194   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
195   DECLARE_EVENT_TABLE()
196 };
197
198 class ProjectionFileCanvas: public wxScrolledWindow
199 {
200 public:
201   ProjectionFileView* m_pView;
202   
203   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
204   virtual void OnDraw(wxDC& dc);
205 };
206
207
208 class PhantomCanvas;
209 class PhantomView : public wxView
210 {
211   DECLARE_DYNAMIC_CLASS(PhantomView)
212     
213 private:
214   PhantomCanvas *CreateCanvas(wxView *view, wxFrame *parent);
215   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
216   
217   PhantomCanvas *m_canvas;
218   wxFrame *m_frame;
219   
220   int m_iDefaultNDet;
221   int m_iDefaultNView;
222   int m_iDefaultNSample;
223   int m_iDefaultGeometry;
224   int m_iDefaultTrace;
225   double m_dDefaultRotation;
226   double m_dDefaultFocalLength;
227   double m_dDefaultFieldOfView;
228   
229   int m_iDefaultRasterNX;
230   int m_iDefaultRasterNY;
231   int m_iDefaultRasterNSamples;
232
233 public:
234   PhantomView(void);
235   virtual ~PhantomView(void);
236   
237   bool OnCreate(wxDocument *doc, long flags);
238   void OnUpdate(wxView *sender, wxObject *hint = NULL);
239   bool OnClose (bool deleteWindow = true);
240   void OnDraw(wxDC* dc);
241   void OnProperties (wxCommandEvent& event);
242   void OnRasterize (wxCommandEvent& event);
243   void OnProjections (wxCommandEvent& event);
244   
245   PhantomDocument* GetDocument(void) 
246   { return dynamic_cast<PhantomDocument*>(wxView::GetDocument()); }
247   
248   DECLARE_EVENT_TABLE()
249 };
250
251 class PhantomCanvas: public wxScrolledWindow
252 {
253 public:
254   PhantomView* m_pView;
255   
256   PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
257   virtual void OnDraw(wxDC& dc);
258 };
259
260 class PlotFileCanvas;
261 class PlotFileView : public wxView
262 {
263   DECLARE_DYNAMIC_CLASS(PlotFileView)
264     
265 private:
266   PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
267   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
268   
269   PlotFileCanvas *m_canvas;
270   wxFrame *m_frame;
271   EZPlot* m_pEZPlot;
272   
273   bool m_bMinSpecified;
274   bool m_bMaxSpecified;
275   double m_dMinPixel;
276   double m_dMaxPixel;
277   double m_dAutoScaleFactor;
278   
279 public:
280   PlotFileView(void);
281   virtual ~PlotFileView(void);
282   
283   bool OnCreate(wxDocument *doc, long flags);
284   void OnDraw(wxDC* dc);
285   void OnUpdate(wxView *sender, wxObject *hint = NULL);
286   bool OnClose (bool deleteWindow = true);
287
288   void OnProperties (wxCommandEvent& event);
289   void OnScaleMinMax (wxCommandEvent& event);
290   void OnScaleAuto (wxCommandEvent& event);
291   void OnScaleFull (wxCommandEvent& event);
292   
293   wxFrame* getFrame ()
294   { return m_frame; }
295   
296   PlotFileDocument* GetDocument(void) 
297   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
298   
299   DECLARE_EVENT_TABLE()
300 };
301
302 class PlotFileCanvas: public wxScrolledWindow
303 {
304 public:
305   PlotFileView* m_pView;
306   
307   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
308   virtual void OnDraw(wxDC& dc);
309 };
310
311
312 #endif
313