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