r2108: *** 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.58 2002/06/06 22:50:24 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   void setInitialClientSize();
155
156   wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
157
158   ImageFileDocument* GetDocument() 
159   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
160   
161   DECLARE_EVENT_TABLE()
162 };
163
164 class ImageFileCanvas: public wxScrolledWindow
165 {
166 private:
167   ImageFileView* m_pView;
168
169   int m_xCursor;
170   int m_yCursor;
171   
172 public:
173   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
174   virtual ~ImageFileCanvas();
175
176   virtual void OnDraw(wxDC& dc);
177   void OnChar(wxKeyEvent& event);
178   void OnMouseEvent(wxMouseEvent& event);
179   void DrawRubberBandCursor (wxDC& dc, int x, int y);
180   bool GetCurrentCursor (int& x, int& y);
181
182   virtual wxSize GetBestSize() const;
183   void setView(ImageFileView* pView)
184   { m_pView = pView; }
185
186
187   DECLARE_EVENT_TABLE()
188 };
189
190
191 class ProjectionFileCanvas;
192 class ProjectionFileView : public wxView
193 {
194 private:
195   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
196     
197   wxMemoryDC m_memoryDC;
198   wxBitmap m_bitmap;
199   
200   ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
201 #if CTSIM_MDI
202   wxDocMDIChildFrame* m_pFrame;
203   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
204 #else
205   wxDocChildFrame* m_pFrame;
206   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
207 #endif
208   
209   ProjectionFileCanvas *m_pCanvas;
210   wxMenu* m_pFileMenu;
211
212   int m_iDefaultNX;
213   int m_iDefaultNY;
214   int m_iDefaultFilter;
215   int m_iDefaultFilterMethod;
216   double m_dDefaultFilterParam;
217   int m_iDefaultFilterGeneration;
218   int m_iDefaultZeropad;
219   int m_iDefaultInterpolation;
220   int m_iDefaultInterpParam;
221   int m_iDefaultBackprojector;
222   int m_iDefaultTrace;
223   
224   int m_iDefaultPolarNX;
225   int m_iDefaultPolarNY;
226   int m_iDefaultPolarInterpolation;
227   int m_iDefaultPolarZeropad;
228
229   wxWindow* getFrameForChild() 
230 #if CTSIM_MDI
231   { return theApp->getMainFrame(); }
232 #else
233   { return m_pFrame; }
234 #endif
235
236 public:
237   ProjectionFileView();
238   virtual ~ProjectionFileView();
239   void canvasClosed()
240   { m_pCanvas = NULL; m_pFrame = NULL; }
241   
242   bool OnCreate(wxDocument *doc, long flags);
243   void OnDraw(wxDC* dc);
244   void OnUpdate(wxView *sender, wxObject *hint = NULL);
245   bool OnClose (bool deleteWindow = true);
246   void OnProperties (wxCommandEvent& event);
247   void OnReconstructFBP (wxCommandEvent& event);
248   void OnReconstructFBPRebin (wxCommandEvent& event);
249   void OnReconstructFourier (wxCommandEvent& event);
250   void OnConvertRectangular (wxCommandEvent& event);
251   void OnConvertPolar (wxCommandEvent& event);
252   void OnConvertFFTPolar (wxCommandEvent& event);
253   void OnPlotTThetaSampling (wxCommandEvent& event);
254   void OnPlotHistogram (wxCommandEvent& event);
255   void OnConvertParallel (wxCommandEvent& event);
256   void OnArtifactReduction (wxCommandEvent& event);
257
258   void doReconstructFBP (const Projections& rProj, bool bRebinToParallel);
259
260 #if CTSIM_MDI
261   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
262 #else
263   wxDocChildFrame* getFrame() { return m_pFrame; }
264 #endif
265   ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
266   void setInitialClientSize();
267
268   wxMenu* getFileMenu()  { return m_pFileMenu; }
269
270   ProjectionFileDocument* GetDocument() 
271   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
272   DECLARE_EVENT_TABLE()
273 };
274
275 class ProjectionFileCanvas: public wxScrolledWindow
276 {
277 private:
278   ProjectionFileView* m_pView;
279
280 public:  
281   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
282   virtual ~ProjectionFileCanvas() ;
283
284   virtual wxSize GetBestSize() const;
285   virtual void OnDraw(wxDC& dc);
286   void setView(ProjectionFileView* pView)
287   { m_pView = pView; }
288 };
289
290
291 class PhantomCanvas;
292 class PhantomFileView : public wxView
293 {
294 private:
295   DECLARE_DYNAMIC_CLASS(PhantomFileView)
296   DECLARE_EVENT_TABLE()
297     
298   PhantomCanvas *CreateCanvas (wxFrame* parent);
299 #if CTSIM_MDI
300   wxDocMDIChildFrame* m_pFrame;
301   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
302 #else
303   wxDocChildFrame* m_pFrame;
304   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
305 #endif
306   
307   PhantomCanvas *m_pCanvas;
308   wxMenu* m_pFileMenu;
309   
310   int m_iDefaultNDet;
311   int m_iDefaultNView;
312   int m_iDefaultOffsetView;
313   int m_iDefaultNSample;
314   int m_iDefaultGeometry;
315   int m_iDefaultTrace;
316   double m_dDefaultRotation;
317   double m_dDefaultFocalLength;
318   double m_dDefaultCenterDetectorLength;
319   double m_dDefaultViewRatio;
320   double m_dDefaultScanRatio;
321   
322   int m_iDefaultRasterNX;
323   int m_iDefaultRasterNY;
324   int m_iDefaultRasterNSamples;
325   double m_dDefaultRasterViewRatio;
326
327   wxWindow* getFrameForChild() 
328 #if CTSIM_MDI
329   { return theApp->getMainFrame(); }
330 #else
331   { return m_pFrame; }
332 #endif
333
334 public:
335   PhantomFileView();
336   virtual ~PhantomFileView();
337   void canvasClosed()
338   { m_pCanvas = NULL; m_pFrame = NULL; }
339   
340   bool OnCreate(wxDocument *doc, long flags);
341   void OnUpdate(wxView *sender, wxObject *hint = NULL);
342   bool OnClose (bool deleteWindow = true);
343   void OnDraw(wxDC* dc);
344   void OnProperties (wxCommandEvent& event);
345   void OnRasterize (wxCommandEvent& event);
346   void OnProjections (wxCommandEvent& event);
347   
348   PhantomFileDocument* GetDocument() 
349   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
350   
351   wxMenu* getFileMenu() { return m_pFileMenu; }
352 #if CTSIM_MDI
353   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
354 #else
355   wxDocChildFrame* getFrame() { return m_pFrame; }
356 #endif
357 };
358
359 class PhantomCanvas: public wxScrolledWindow
360 {
361 private:
362   PhantomFileView* m_pView;
363
364 public:  
365   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
366   virtual ~PhantomCanvas();
367
368   virtual wxSize GetBestSize() const;
369   void setView(PhantomFileView* pView)
370   { m_pView = pView; }
371   virtual void OnDraw(wxDC& dc);
372 };
373
374 class PlotFileCanvas;
375 class PlotFileView : public wxView
376 {
377   DECLARE_DYNAMIC_CLASS(PlotFileView)
378     
379 private:
380 #if CTSIM_MDI
381   wxDocMDIChildFrame* m_pFrame;
382   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
383 #else
384   wxDocChildFrame* m_pFrame;
385   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
386 #endif
387   
388   PlotFileCanvas *m_pCanvas;
389   EZPlot* m_pEZPlot;
390   wxMenu* m_pFileMenu;
391   
392   bool m_bMinSpecified;
393   bool m_bMaxSpecified;
394   double m_dMinPixel;
395   double m_dMaxPixel;
396   double m_dAutoScaleFactor;
397   
398   PlotFileCanvas *CreateCanvas (wxFrame* parent);
399   wxWindow* getFrameForChild() 
400 #if CTSIM_MDI
401   { return theApp->getMainFrame(); }
402 #else
403   { return m_pFrame; }
404 #endif
405
406 public:
407   PlotFileView();
408   virtual ~PlotFileView();
409   void canvasClosed()
410   { m_pCanvas = NULL; m_pFrame = NULL; }
411   
412   bool OnCreate(wxDocument *doc, long flags);
413   void OnDraw(wxDC* dc);
414   void OnUpdate(wxView *sender, wxObject *hint = NULL);
415   bool OnClose (bool deleteWindow = true);
416
417   void OnProperties (wxCommandEvent& event);
418   void OnScaleMinMax (wxCommandEvent& event);
419   void OnScaleAuto (wxCommandEvent& event);
420   void OnScaleFull (wxCommandEvent& event);
421   
422 #if CTSIM_MDI
423   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
424 #else
425   wxDocChildFrame* getFrame() { return m_pFrame; }
426 #endif
427   
428   void setInitialClientSize();
429   wxMenu* getFileMenu() { return m_pFileMenu; }
430   PlotFileDocument* GetDocument() 
431   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
432   
433   DECLARE_EVENT_TABLE()
434 };
435
436 class PlotFileCanvas: public wxScrolledWindow
437 {
438 private:
439   PlotFileView* m_pView;
440   
441 public:
442   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
443   virtual ~PlotFileCanvas();
444  
445   virtual void OnDraw(wxDC& dc);
446   virtual wxSize GetBestSize() const;
447
448   void setView (PlotFileView* pView)
449   { m_pView = pView; }
450 };
451
452
453 class TextFileCanvas;
454 class TextFileView: public wxView
455 {
456 private:
457   DECLARE_DYNAMIC_CLASS(TextFileView)
458
459 #if CTSIM_MDI
460   wxDocMDIChildFrame* m_pFrame;
461   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
462 #else
463   wxDocChildFrame* m_pFrame;
464   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
465 #endif
466     wxMenu* m_pFileMenu;
467     TextFileCanvas *m_pCanvas;
468   
469 public:
470     TextFileView() 
471       : wxView() , m_pFrame(0), m_pCanvas(0)
472     {}
473     ~TextFileView();
474     void canvasClosed()
475     { m_pFrame = NULL; }
476
477     bool OnCreate (wxDocument *doc, long flags);
478     void OnDraw (wxDC *dc);
479     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
480     bool OnClose (bool deleteWindow = TRUE);
481
482     TextFileDocument* GetDocument() 
483     { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
484   
485     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
486     wxMenu* getFileMenu() { return m_pFileMenu; }
487 #if CTSIM_MDI
488   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
489 #else
490   wxDocChildFrame* getFrame() { return m_pFrame; }
491 #endif
492 };
493
494 class TextFileCanvas: public wxTextCtrl
495 {
496     TextFileView *m_pView;
497
498 public:    
499     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
500     ~TextFileCanvas ();
501     virtual wxSize GetBestSize() const;
502 };
503
504
505 #endif
506