r3851: *** 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.59 2003/01/23 23:35:58 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 #ifndef __VIEWSH__
29 #define __VIEWSH__
30
31 #include "wx/wx.h"
32 #include "docs.h"
33 #include "imagefile.h"
34 #include "threadrecon.h"
35
36 #if wxUSE_GLCANVAS
37 #include "graph3dview.h"
38 #endif
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   wxMenu* m_pFilterMenu;
62   bool m_bMinSpecified;
63   bool m_bMaxSpecified;
64   double m_dMinPixel;
65   double m_dMaxPixel;
66   double m_dAutoScaleFactor;
67   
68   int m_iDefaultExportFormatID;
69
70   wxWindow* getFrameForChild() 
71 #if CTSIM_MDI
72   { return theApp->getMainFrame(); }
73 #else
74   { return m_pFrame; }
75 #endif
76
77 public:
78   ImageFileView();
79   virtual ~ImageFileView();
80   void canvasClosed()
81   { m_pCanvas = NULL; m_pFrame = NULL; }
82
83   wxMenu* getFileMenu()
84   { return m_pFileMenu; }
85
86   bool OnCreate(wxDocument *doc, long flags);
87   void OnDraw(wxDC* dc);
88   void OnUpdate(wxView *sender, wxObject *hint = NULL);
89   bool OnClose (bool deleteWindow = true);
90   
91   void OnEditCopy (wxCommandEvent& event);
92   void OnEditCut (wxCommandEvent& event);
93   void OnEditPaste (wxCommandEvent& event);
94
95   void OnRevert (wxCommandEvent& event);
96   void OnExport (wxCommandEvent& event);  
97   void OnProperties (wxCommandEvent& event);
98
99   void OnCompare (wxCommandEvent& event);  
100   void OnScaleSize (wxCommandEvent& event);
101   void OnInvertValues (wxCommandEvent& event);
102   void OnSquare (wxCommandEvent& event);
103   void OnSquareRoot (wxCommandEvent& event);
104   void OnLog (wxCommandEvent& event);
105   void OnExp (wxCommandEvent& event);
106   void OnAdd (wxCommandEvent& event);
107   void OnSubtract (wxCommandEvent& event);
108   void OnMultiply (wxCommandEvent& event);
109   void OnDivide (wxCommandEvent& event);
110   void OnFourier (wxCommandEvent& event);
111   void OnInverseFourier (wxCommandEvent& event);
112   void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
113   void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
114 #if wxUSE_GLCANVAS
115   void OnConvert3d (wxCommandEvent& event);
116 #endif
117
118 #ifdef HAVE_FFT
119   void OnFFT (wxCommandEvent& event);
120   void OnIFFT (wxCommandEvent& event);
121   void OnFFTRows (wxCommandEvent& event);
122   void OnIFFTRows (wxCommandEvent& event);
123   void OnFFTCols (wxCommandEvent& event);
124   void OnIFFTCols (wxCommandEvent& event);
125 #endif
126   
127   void OnMagnitude (wxCommandEvent& event);
128   void OnPhase (wxCommandEvent& event);
129   void OnReal (wxCommandEvent& event);
130   void OnImaginary (wxCommandEvent& event);
131   
132   void OnScaleAuto (wxCommandEvent& event);
133   void OnScaleMinMax (wxCommandEvent& event);
134   void OnScaleFull (wxCommandEvent& event);
135   void OnPlotRow (wxCommandEvent& event);
136   void OnPlotCol (wxCommandEvent& event);
137 #if HAVE_FFT
138   void OnPlotFFTRow (wxCommandEvent& event);
139   void OnPlotFFTCol (wxCommandEvent& event);
140 #endif
141   void OnPlotHistogram (wxCommandEvent& event);
142   void OnCompareRow (wxCommandEvent& event);
143   void OnCompareCol (wxCommandEvent& event);
144   
145 #if CTSIM_MDI
146   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
147 #else
148   wxDocChildFrame* getFrame() { return m_pFrame; }
149 #endif
150   void setInitialClientSize();
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 OnConvertRectangular (wxCommandEvent& event);
247   void OnConvertPolar (wxCommandEvent& event);
248   void OnConvertFFTPolar (wxCommandEvent& event);
249   void OnPlotTThetaSampling (wxCommandEvent& event);
250   void OnPlotHistogram (wxCommandEvent& event);
251   void OnConvertParallel (wxCommandEvent& event);
252   void OnArtifactReduction (wxCommandEvent& event);
253
254   void doReconstructFBP (const Projections& rProj, bool bRebinToParallel);
255
256 #if CTSIM_MDI
257   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
258 #else
259   wxDocChildFrame* getFrame() { return m_pFrame; }
260 #endif
261   ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
262   void setInitialClientSize();
263
264   wxMenu* getFileMenu()  { return m_pFileMenu; }
265
266   ProjectionFileDocument* GetDocument() 
267   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
268   DECLARE_EVENT_TABLE()
269 };
270
271 class ProjectionFileCanvas: public wxScrolledWindow
272 {
273 private:
274   ProjectionFileView* m_pView;
275
276 public:  
277   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
278   virtual ~ProjectionFileCanvas() ;
279
280   virtual wxSize GetBestSize() const;
281   virtual void OnDraw(wxDC& dc);
282   void setView(ProjectionFileView* pView)
283   { m_pView = pView; }
284 };
285
286
287 class PhantomCanvas;
288 class PhantomFileView : public wxView
289 {
290 private:
291   DECLARE_DYNAMIC_CLASS(PhantomFileView)
292   DECLARE_EVENT_TABLE()
293     
294   PhantomCanvas *CreateCanvas (wxFrame* parent);
295 #if CTSIM_MDI
296   wxDocMDIChildFrame* m_pFrame;
297   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
298 #else
299   wxDocChildFrame* m_pFrame;
300   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
301 #endif
302   
303   PhantomCanvas *m_pCanvas;
304   wxMenu* m_pFileMenu;
305   
306   int m_iDefaultNDet;
307   int m_iDefaultNView;
308   int m_iDefaultOffsetView;
309   int m_iDefaultNSample;
310   int m_iDefaultGeometry;
311   int m_iDefaultTrace;
312   double m_dDefaultRotation;
313   double m_dDefaultFocalLength;
314   double m_dDefaultCenterDetectorLength;
315   double m_dDefaultViewRatio;
316   double m_dDefaultScanRatio;
317   
318   int m_iDefaultRasterNX;
319   int m_iDefaultRasterNY;
320   int m_iDefaultRasterNSamples;
321   double m_dDefaultRasterViewRatio;
322
323   wxWindow* getFrameForChild() 
324 #if CTSIM_MDI
325   { return theApp->getMainFrame(); }
326 #else
327   { return m_pFrame; }
328 #endif
329
330 public:
331   PhantomFileView();
332   virtual ~PhantomFileView();
333   void canvasClosed()
334   { m_pCanvas = NULL; m_pFrame = NULL; }
335   
336   bool OnCreate(wxDocument *doc, long flags);
337   void OnUpdate(wxView *sender, wxObject *hint = NULL);
338   bool OnClose (bool deleteWindow = true);
339   void OnDraw(wxDC* dc);
340   void OnProperties (wxCommandEvent& event);
341   void OnRasterize (wxCommandEvent& event);
342   void OnProjections (wxCommandEvent& event);
343   
344   PhantomFileDocument* GetDocument() 
345   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
346   
347   wxMenu* getFileMenu() { return m_pFileMenu; }
348 #if CTSIM_MDI
349   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
350 #else
351   wxDocChildFrame* getFrame() { return m_pFrame; }
352 #endif
353 };
354
355 class PhantomCanvas: public wxScrolledWindow
356 {
357 private:
358   PhantomFileView* m_pView;
359
360 public:  
361   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
362   virtual ~PhantomCanvas();
363
364   virtual wxSize GetBestSize() const;
365   void setView(PhantomFileView* pView)
366   { m_pView = pView; }
367   virtual void OnDraw(wxDC& dc);
368 };
369
370 class PlotFileCanvas;
371 class PlotFileView : public wxView
372 {
373   DECLARE_DYNAMIC_CLASS(PlotFileView)
374     
375 private:
376 #if CTSIM_MDI
377   wxDocMDIChildFrame* m_pFrame;
378   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
379 #else
380   wxDocChildFrame* m_pFrame;
381   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
382 #endif
383   
384   PlotFileCanvas *m_pCanvas;
385   EZPlot* m_pEZPlot;
386   wxMenu* m_pFileMenu;
387   
388   bool m_bMinSpecified;
389   bool m_bMaxSpecified;
390   double m_dMinPixel;
391   double m_dMaxPixel;
392   double m_dAutoScaleFactor;
393   
394   PlotFileCanvas *CreateCanvas (wxFrame* parent);
395   wxWindow* getFrameForChild() 
396 #if CTSIM_MDI
397   { return theApp->getMainFrame(); }
398 #else
399   { return m_pFrame; }
400 #endif
401
402 public:
403   PlotFileView();
404   virtual ~PlotFileView();
405   void canvasClosed()
406   { m_pCanvas = NULL; m_pFrame = NULL; }
407   
408   bool OnCreate(wxDocument *doc, long flags);
409   void OnDraw(wxDC* dc);
410   void OnUpdate(wxView *sender, wxObject *hint = NULL);
411   bool OnClose (bool deleteWindow = true);
412
413   void OnProperties (wxCommandEvent& event);
414   void OnScaleMinMax (wxCommandEvent& event);
415   void OnScaleAuto (wxCommandEvent& event);
416   void OnScaleFull (wxCommandEvent& event);
417   
418 #if CTSIM_MDI
419   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
420 #else
421   wxDocChildFrame* getFrame() { return m_pFrame; }
422 #endif
423   
424   void setInitialClientSize();
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   virtual wxSize GetBestSize() const;
443
444   void setView (PlotFileView* pView)
445   { m_pView = pView; }
446 };
447
448
449 class TextFileCanvas;
450 class TextFileView: public wxView
451 {
452 private:
453   DECLARE_DYNAMIC_CLASS(TextFileView)
454
455 #if CTSIM_MDI
456   wxDocMDIChildFrame* m_pFrame;
457   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
458 #else
459   wxDocChildFrame* m_pFrame;
460   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
461 #endif
462     wxMenu* m_pFileMenu;
463     TextFileCanvas *m_pCanvas;
464   
465 public:
466     TextFileView() 
467       : wxView() , m_pFrame(0), m_pCanvas(0)
468     {}
469     ~TextFileView();
470     void canvasClosed()
471     { m_pFrame = NULL; }
472
473     bool OnCreate (wxDocument *doc, long flags);
474     void OnDraw (wxDC *dc);
475     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
476     bool OnClose (bool deleteWindow = TRUE);
477
478     TextFileDocument* GetDocument() 
479     { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
480   
481     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
482     wxMenu* getFileMenu() { return m_pFileMenu; }
483 #if CTSIM_MDI
484   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
485 #else
486   wxDocChildFrame* getFrame() { return m_pFrame; }
487 #endif
488 };
489
490 class TextFileCanvas: public wxTextCtrl
491 {
492     TextFileView *m_pView;
493
494 public:    
495     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
496     ~TextFileCanvas ();
497     virtual wxSize GetBestSize() const;
498 };
499
500
501 #endif
502