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