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