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