4463689350a0c146bef7d14e18f8881c4317a3dc
[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.24 2001/01/03 22:00:46 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_FFTW
91   void OnFFT (wxCommandEvent& event);
92   void OnIFFT (wxCommandEvent& event);
93 #endif
94   
95   void OnMagnitude (wxCommandEvent& event);
96   void OnPhase (wxCommandEvent& event);
97   
98   void OnScaleAuto (wxCommandEvent& event);
99   void OnScaleMinMax (wxCommandEvent& event);
100   void OnPlotRow (wxCommandEvent& event);
101   void OnPlotCol (wxCommandEvent& event);
102   void OnPlotHistogram (wxCommandEvent& event);
103   void OnCompareRow (wxCommandEvent& event);
104   void OnCompareCol (wxCommandEvent& event);
105   
106   wxFrame* getFrame()
107   { return m_frame; }
108   
109   ImageFileDocument* GetDocument(void) 
110   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
111   
112   DECLARE_EVENT_TABLE()
113 };
114
115 class ImageFileCanvas: public wxScrolledWindow
116 {
117 private:
118   
119   int m_xCursor;
120   int m_yCursor;
121   
122 public:
123   ImageFileView* m_pView;
124   
125   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
126   virtual void OnDraw(wxDC& dc);
127   void OnMouseEvent(wxMouseEvent& event);
128   void DrawRubberBandCursor (wxDC& dc, int x, int y);
129   bool GetCurrentCursor (int& x, int& y);
130   
131   DECLARE_EVENT_TABLE()
132 };
133
134
135 class ProjectionFileCanvas;
136 class ProjectionFileView : public wxView
137 {
138   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
139     
140     wxMemoryDC m_memoryDC;
141   wxBitmap m_bitmap;
142   
143 private:
144   ProjectionFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
145   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
146   
147   ProjectionFileCanvas *m_canvas;
148   wxFrame *m_frame;
149   
150   int m_iDefaultNX;
151   int m_iDefaultNY;
152   int m_iDefaultFilter;
153   int m_iDefaultFilterMethod;
154   double m_dDefaultFilterParam;
155   int m_iDefaultFilterGeneration;
156   int m_iDefaultZeropad;
157   int m_iDefaultInterpolation;
158   int m_iDefaultInterpParam;
159   int m_iDefaultBackprojector;
160   int m_iDefaultTrace;
161   
162 public:
163   ProjectionFileView(void);
164   virtual ~ProjectionFileView(void);
165   
166   bool OnCreate(wxDocument *doc, long flags);
167   void OnDraw(wxDC* dc);
168   void OnUpdate(wxView *sender, wxObject *hint = NULL);
169   bool OnClose (bool deleteWindow = true);
170   void OnProperties (wxCommandEvent& event);
171   void OnReconstructFBP (wxCommandEvent& event);
172   void OnReconstructFourier (wxCommandEvent& event);
173   void OnConvertPolar (wxCommandEvent& event);
174   void OnConvertFFTPolar (wxCommandEvent& event);
175   
176   wxFrame* getFrame ()
177   { return m_frame; }
178   
179   ProjectionFileDocument* GetDocument(void) 
180   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
181   DECLARE_EVENT_TABLE()
182 };
183
184 class ProjectionFileCanvas: public wxScrolledWindow
185 {
186 public:
187   ProjectionFileView* m_pView;
188   
189   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
190   virtual void OnDraw(wxDC& dc);
191 };
192
193
194 class PhantomCanvas;
195 class PhantomView : public wxView
196 {
197   DECLARE_DYNAMIC_CLASS(PhantomView)
198     
199 private:
200   PhantomCanvas *CreateCanvas(wxView *view, wxFrame *parent);
201   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
202   
203   PhantomCanvas *m_canvas;
204   wxFrame *m_frame;
205   
206   int m_iDefaultNDet;
207   int m_iDefaultNView;
208   int m_iDefaultNSample;
209   int m_iDefaultGeometry;
210   int m_iDefaultTrace;
211   double m_dDefaultRotation;
212   double m_dDefaultFocalLength;
213   double m_dDefaultFieldOfView;
214   
215 public:
216   PhantomView(void);
217   virtual ~PhantomView(void);
218   
219   bool OnCreate(wxDocument *doc, long flags);
220   void OnUpdate(wxView *sender, wxObject *hint = NULL);
221   bool OnClose (bool deleteWindow = true);
222   void OnDraw(wxDC* dc);
223   void OnProperties (wxCommandEvent& event);
224   void OnRasterize (wxCommandEvent& event);
225   void OnProjections (wxCommandEvent& event);
226   
227   PhantomDocument* GetDocument(void) 
228   { return dynamic_cast<PhantomDocument*>(wxView::GetDocument()); }
229   
230   DECLARE_EVENT_TABLE()
231 };
232
233 class PhantomCanvas: public wxScrolledWindow
234 {
235 public:
236   PhantomView* m_pView;
237   
238   PhantomCanvas (PhantomView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
239   virtual void OnDraw(wxDC& dc);
240 };
241
242 class PlotFileCanvas;
243 class PlotFileView : public wxView
244 {
245   DECLARE_DYNAMIC_CLASS(PlotFileView)
246     
247 private:
248   PlotFileCanvas *CreateCanvas(wxView *view, wxFrame *parent);
249   wxFrame *CreateChildFrame(wxDocument *doc, wxView *view);
250   
251   PlotFileCanvas *m_canvas;
252   wxFrame *m_frame;
253   EZPlot* m_pEZPlot;
254   
255   bool m_bMinSpecified;
256   bool m_bMaxSpecified;
257   double m_dMinPixel;
258   double m_dMaxPixel;
259   double m_dAutoScaleFactor;
260   
261 public:
262   PlotFileView(void);
263   virtual ~PlotFileView(void);
264   
265   bool OnCreate(wxDocument *doc, long flags);
266   void OnDraw(wxDC* dc);
267   void OnUpdate(wxView *sender, wxObject *hint = NULL);
268   bool OnClose (bool deleteWindow = true);
269   void OnProperties (wxCommandEvent& event);
270   void OnScaleAuto (wxCommandEvent& event);
271   void OnScaleMinMax (wxCommandEvent& event);
272   
273   wxFrame* getFrame ()
274   { return m_frame; }
275   
276   PlotFileDocument* GetDocument(void) 
277   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
278   
279   DECLARE_EVENT_TABLE()
280 };
281
282 class PlotFileCanvas: public wxScrolledWindow
283 {
284 public:
285   PlotFileView* m_pView;
286   
287   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
288   virtual void OnDraw(wxDC& dc);
289 };
290
291
292 #endif
293