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