r475: 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-2001 Kevin Rosenberg
11 **
12 **  $Id: views.h,v 1.44 2001/01/31 01:01:22 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 #if wxUSE_GLCANVAS
40 #include "graph3dview.h"
41 #endif
42
43 class ImageFileCanvas;
44 class ImageFileView : public wxView
45 {
46 private:
47   DECLARE_DYNAMIC_CLASS(ImageFileView)
48     
49   wxMemoryDC m_memoryDC;
50   wxBitmap m_bitmap;
51   wxMenu* m_pMenuAnalyze;
52   
53   ImageFileCanvas *CreateCanvas (wxFrame* parent);
54 #if CTSIM_MDI
55   wxDocMDIChildFrame* m_pFrame;
56   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
57 #else
58   wxDocChildFrame* m_pFrame;
59   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
60 #endif
61   
62   ImageFileCanvas *m_pCanvas;
63   wxMenu* m_pFileMenu;
64   bool m_bMinSpecified;
65   bool m_bMaxSpecified;
66   double m_dMinPixel;
67   double m_dMaxPixel;
68   double m_dAutoScaleFactor;
69   
70   int m_iDefaultExportFormatID;
71
72   wxWindow* getFrameForChild() 
73 #if CTSIM_MDI
74   { return theApp->getMainFrame(); }
75 #else
76   { return m_pFrame; }
77 #endif
78
79 public:
80   ImageFileView();
81   virtual ~ImageFileView();
82   void canvasClosed()
83   { m_pCanvas = NULL; m_pFrame = NULL; }
84
85   wxMenu* getFileMenu()
86   { return m_pFileMenu; }
87
88   bool OnCreate(wxDocument *doc, long flags);
89   void OnDraw(wxDC* dc);
90   void OnUpdate(wxView *sender, wxObject *hint = NULL);
91   bool OnClose (bool deleteWindow = true);
92   
93   void OnRevert (wxCommandEvent& event);
94   void OnExport (wxCommandEvent& event);  
95   void OnProperties (wxCommandEvent& event);
96
97   void OnCompare (wxCommandEvent& event);  
98   void OnScaleSize (wxCommandEvent& event);
99   void OnInvertValues (wxCommandEvent& event);
100   void OnSquare (wxCommandEvent& event);
101   void OnSquareRoot (wxCommandEvent& event);
102   void OnLog (wxCommandEvent& event);
103   void OnExp (wxCommandEvent& event);
104   void OnAdd (wxCommandEvent& event);
105   void OnSubtract (wxCommandEvent& event);
106   void OnMultiply (wxCommandEvent& event);
107   void OnDivide (wxCommandEvent& event);
108   void OnFourier (wxCommandEvent& event);
109   void OnInverseFourier (wxCommandEvent& event);
110   void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
111   void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
112 #if wxUSE_GLCANVAS
113   void OnConvert3d (wxCommandEvent& event);
114 #endif
115
116 #ifdef HAVE_FFT
117   void OnFFT (wxCommandEvent& event);
118   void OnIFFT (wxCommandEvent& event);
119   void OnFFTRows (wxCommandEvent& event);
120   void OnIFFTRows (wxCommandEvent& event);
121   void OnFFTCols (wxCommandEvent& event);
122   void OnIFFTCols (wxCommandEvent& event);
123 #endif
124   
125   void OnMagnitude (wxCommandEvent& event);
126   void OnPhase (wxCommandEvent& event);
127   
128   void OnScaleAuto (wxCommandEvent& event);
129   void OnScaleMinMax (wxCommandEvent& event);
130   void OnScaleFull (wxCommandEvent& event);
131   void OnPlotRow (wxCommandEvent& event);
132   void OnPlotCol (wxCommandEvent& event);
133 #if HAVE_FFT
134   void OnPlotFFTRow (wxCommandEvent& event);
135   void OnPlotFFTCol (wxCommandEvent& event);
136 #endif
137   void OnPlotHistogram (wxCommandEvent& event);
138   void OnCompareRow (wxCommandEvent& event);
139   void OnCompareCol (wxCommandEvent& event);
140   
141 #if CTSIM_MDI
142   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
143 #else
144   wxDocChildFrame* getFrame() { return m_pFrame; }
145 #endif
146
147   wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
148
149   ImageFileDocument* GetDocument() 
150   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
151   
152   DECLARE_EVENT_TABLE()
153 };
154
155 class ImageFileCanvas: public wxScrolledWindow
156 {
157 private:
158   ImageFileView* m_pView;
159
160   int m_xCursor;
161   int m_yCursor;
162   
163 public:
164   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
165   virtual ~ImageFileCanvas();
166
167   virtual void OnDraw(wxDC& dc);
168   void OnChar(wxKeyEvent& event);
169   void OnMouseEvent(wxMouseEvent& event);
170   void DrawRubberBandCursor (wxDC& dc, int x, int y);
171   bool GetCurrentCursor (int& x, int& y);
172
173   virtual wxSize GetBestSize() const;
174   void setView(ImageFileView* pView)
175   { m_pView = pView; }
176
177
178   DECLARE_EVENT_TABLE()
179 };
180
181
182 class ProjectionFileCanvas;
183 class ProjectionFileView : public wxView
184 {
185   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
186     
187     wxMemoryDC m_memoryDC;
188   wxBitmap m_bitmap;
189   
190 private:
191   ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
192 #if CTSIM_MDI
193   wxDocMDIChildFrame* m_pFrame;
194   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
195 #else
196   wxDocChildFrame* m_pFrame;
197   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
198 #endif
199   
200   ProjectionFileCanvas *m_pCanvas;
201   wxMenu* m_pFileMenu;
202   
203   int m_iDefaultNX;
204   int m_iDefaultNY;
205   int m_iDefaultFilter;
206   int m_iDefaultFilterMethod;
207   double m_dDefaultFilterParam;
208   int m_iDefaultFilterGeneration;
209   int m_iDefaultZeropad;
210   int m_iDefaultInterpolation;
211   int m_iDefaultInterpParam;
212   int m_iDefaultBackprojector;
213   int m_iDefaultTrace;
214   
215   int m_iDefaultPolarNX;
216   int m_iDefaultPolarNY;
217   int m_iDefaultPolarInterpolation;
218   int m_iDefaultPolarZeropad;
219
220   wxWindow* getFrameForChild() 
221 #if CTSIM_MDI
222   { return theApp->getMainFrame(); }
223 #else
224   { return m_pFrame; }
225 #endif
226
227 public:
228   ProjectionFileView();
229   virtual ~ProjectionFileView();
230   void canvasClosed()
231   { m_pCanvas = NULL; m_pFrame = NULL; }
232   
233   bool OnCreate(wxDocument *doc, long flags);
234   void OnDraw(wxDC* dc);
235   void OnUpdate(wxView *sender, wxObject *hint = NULL);
236   bool OnClose (bool deleteWindow = true);
237   void OnProperties (wxCommandEvent& event);
238   void OnReconstructFBP (wxCommandEvent& event);
239   void OnReconstructFourier (wxCommandEvent& event);
240   void OnConvertPolar (wxCommandEvent& event);
241   void OnConvertFFTPolar (wxCommandEvent& event);
242   
243 #if CTSIM_MDI
244   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
245 #else
246   wxDocChildFrame* getFrame() { return m_pFrame; }
247 #endif
248   ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
249
250   wxMenu* getFileMenu()  { return m_pFileMenu; }
251
252   ProjectionFileDocument* GetDocument() 
253   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
254   DECLARE_EVENT_TABLE()
255 };
256
257 class ProjectionFileCanvas: public wxScrolledWindow
258 {
259 private:
260   ProjectionFileView* m_pView;
261
262 public:  
263   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
264   virtual ~ProjectionFileCanvas() ;
265
266   virtual wxSize GetBestSize() const;
267   virtual void OnDraw(wxDC& dc);
268   void setView(ProjectionFileView* pView)
269   { m_pView = pView; }
270 };
271
272
273 class PhantomCanvas;
274 class PhantomFileView : public wxView
275 {
276 private:
277   DECLARE_DYNAMIC_CLASS(PhantomFileView)
278   DECLARE_EVENT_TABLE()
279     
280   PhantomCanvas *CreateCanvas (wxFrame* parent);
281 #if CTSIM_MDI
282   wxDocMDIChildFrame* m_pFrame;
283   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
284 #else
285   wxDocChildFrame* m_pFrame;
286   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
287 #endif
288   
289   PhantomCanvas *m_pCanvas;
290   wxMenu* m_pFileMenu;
291   
292   int m_iDefaultNDet;
293   int m_iDefaultNView;
294   int m_iDefaultNSample;
295   int m_iDefaultGeometry;
296   int m_iDefaultTrace;
297   double m_dDefaultRotation;
298   double m_dDefaultFocalLength;
299   double m_dDefaultFieldOfView;
300   
301   int m_iDefaultRasterNX;
302   int m_iDefaultRasterNY;
303   int m_iDefaultRasterNSamples;
304
305   wxWindow* getFrameForChild() 
306 #if CTSIM_MDI
307   { return theApp->getMainFrame(); }
308 #else
309   { return m_pFrame; }
310 #endif
311
312 public:
313   PhantomFileView();
314   virtual ~PhantomFileView();
315   void canvasClosed()
316   { m_pCanvas = NULL; m_pFrame = NULL; }
317   
318   bool OnCreate(wxDocument *doc, long flags);
319   void OnUpdate(wxView *sender, wxObject *hint = NULL);
320   bool OnClose (bool deleteWindow = true);
321   void OnDraw(wxDC* dc);
322   void OnProperties (wxCommandEvent& event);
323   void OnRasterize (wxCommandEvent& event);
324   void OnProjections (wxCommandEvent& event);
325   
326   PhantomFileDocument* GetDocument() 
327   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
328   
329   wxMenu* getFileMenu() { return m_pFileMenu; }
330 #if CTSIM_MDI
331   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
332 #else
333   wxDocChildFrame* getFrame() { return m_pFrame; }
334 #endif
335 };
336
337 class PhantomCanvas: public wxScrolledWindow
338 {
339 private:
340   PhantomFileView* m_pView;
341
342 public:  
343   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
344   virtual ~PhantomCanvas();
345
346   void setView(PhantomFileView* pView)
347   { m_pView = pView; }
348   virtual void OnDraw(wxDC& dc);
349 };
350
351 class PlotFileCanvas;
352 class PlotFileView : public wxView
353 {
354   DECLARE_DYNAMIC_CLASS(PlotFileView)
355     
356 private:
357 #if CTSIM_MDI
358   wxDocMDIChildFrame* m_pFrame;
359   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
360 #else
361   wxDocChildFrame* m_pFrame;
362   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
363 #endif
364   
365   PlotFileCanvas *m_pCanvas;
366   EZPlot* m_pEZPlot;
367   wxMenu* m_pFileMenu;
368   
369   bool m_bMinSpecified;
370   bool m_bMaxSpecified;
371   double m_dMinPixel;
372   double m_dMaxPixel;
373   double m_dAutoScaleFactor;
374   
375   PlotFileCanvas *CreateCanvas (wxFrame* parent);
376   wxWindow* getFrameForChild() 
377 #if CTSIM_MDI
378   { return theApp->getMainFrame(); }
379 #else
380   { return m_pFrame; }
381 #endif
382
383 public:
384   PlotFileView();
385   virtual ~PlotFileView();
386   void canvasClosed()
387   { m_pCanvas = NULL; m_pFrame = NULL; }
388   
389   bool OnCreate(wxDocument *doc, long flags);
390   void OnDraw(wxDC* dc);
391   void OnUpdate(wxView *sender, wxObject *hint = NULL);
392   bool OnClose (bool deleteWindow = true);
393
394   void OnProperties (wxCommandEvent& event);
395   void OnScaleMinMax (wxCommandEvent& event);
396   void OnScaleAuto (wxCommandEvent& event);
397   void OnScaleFull (wxCommandEvent& event);
398   
399 #if CTSIM_MDI
400   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
401 #else
402   wxDocChildFrame* getFrame() { return m_pFrame; }
403 #endif
404   
405   wxMenu* getFileMenu() { return m_pFileMenu; }
406   PlotFileDocument* GetDocument() 
407   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
408   
409   DECLARE_EVENT_TABLE()
410 };
411
412 class PlotFileCanvas: public wxScrolledWindow
413 {
414 private:
415   PlotFileView* m_pView;
416   
417 public:
418   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
419   virtual ~PlotFileCanvas();
420  
421   virtual void OnDraw(wxDC& dc);
422
423   void setView (PlotFileView* pView)
424   { m_pView = pView; }
425 };
426
427
428 class TextFileCanvas;
429 class TextFileView: public wxView
430 {
431 private:
432   DECLARE_DYNAMIC_CLASS(TextFileView)
433
434 #if CTSIM_MDI
435   wxDocMDIChildFrame* m_pFrame;
436   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
437 #else
438   wxDocChildFrame* m_pFrame;
439   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
440 #endif
441     wxMenu* m_pFileMenu;
442     TextFileCanvas *m_pCanvas;
443   
444 public:
445     TextFileView() 
446       : wxView() , m_pFrame(0), m_pCanvas(0)
447     {}
448     ~TextFileView();
449     void canvasClosed()
450     { m_pFrame = NULL; }
451
452     bool OnCreate (wxDocument *doc, long flags);
453     void OnDraw (wxDC *dc);
454     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
455     bool OnClose (bool deleteWindow = TRUE);
456
457     TextFileDocument* GetDocument() 
458     { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
459   
460     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
461     wxMenu* getFileMenu() { return m_pFileMenu; }
462 #if CTSIM_MDI
463   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
464 #else
465   wxDocChildFrame* getFrame() { return m_pFrame; }
466 #endif
467 };
468
469 class TextFileCanvas: public wxTextCtrl
470 {
471     TextFileView *m_pView;
472
473 public:    
474     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
475     ~TextFileCanvas ();
476 };
477
478
479 #endif
480