r640: no 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.52 2001/03/18 18:08:26 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 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
263   wxMenu* getFileMenu()  { return m_pFileMenu; }
264
265   ProjectionFileDocument* GetDocument() 
266   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
267   DECLARE_EVENT_TABLE()
268 };
269
270 class ProjectionFileCanvas: public wxScrolledWindow
271 {
272 private:
273   ProjectionFileView* m_pView;
274
275 public:  
276   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
277   virtual ~ProjectionFileCanvas() ;
278
279   virtual wxSize GetBestSize() const;
280   virtual void OnDraw(wxDC& dc);
281   void setView(ProjectionFileView* pView)
282   { m_pView = pView; }
283 };
284
285
286 class PhantomCanvas;
287 class PhantomFileView : public wxView
288 {
289 private:
290   DECLARE_DYNAMIC_CLASS(PhantomFileView)
291   DECLARE_EVENT_TABLE()
292     
293   PhantomCanvas *CreateCanvas (wxFrame* parent);
294 #if CTSIM_MDI
295   wxDocMDIChildFrame* m_pFrame;
296   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
297 #else
298   wxDocChildFrame* m_pFrame;
299   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
300 #endif
301   
302   PhantomCanvas *m_pCanvas;
303   wxMenu* m_pFileMenu;
304   
305   int m_iDefaultNDet;
306   int m_iDefaultNView;
307   int m_iDefaultNSample;
308   int m_iDefaultGeometry;
309   int m_iDefaultTrace;
310   double m_dDefaultRotation;
311   double m_dDefaultFocalLength;
312   double m_dDefaultCenterDetectorLength;
313   double m_dDefaultViewRatio;
314   double m_dDefaultScanRatio;
315   
316   int m_iDefaultRasterNX;
317   int m_iDefaultRasterNY;
318   int m_iDefaultRasterNSamples;
319   double m_dDefaultRasterViewRatio;
320
321   wxWindow* getFrameForChild() 
322 #if CTSIM_MDI
323   { return theApp->getMainFrame(); }
324 #else
325   { return m_pFrame; }
326 #endif
327
328 public:
329   PhantomFileView();
330   virtual ~PhantomFileView();
331   void canvasClosed()
332   { m_pCanvas = NULL; m_pFrame = NULL; }
333   
334   bool OnCreate(wxDocument *doc, long flags);
335   void OnUpdate(wxView *sender, wxObject *hint = NULL);
336   bool OnClose (bool deleteWindow = true);
337   void OnDraw(wxDC* dc);
338   void OnProperties (wxCommandEvent& event);
339   void OnRasterize (wxCommandEvent& event);
340   void OnProjections (wxCommandEvent& event);
341   
342   PhantomFileDocument* GetDocument() 
343   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
344   
345   wxMenu* getFileMenu() { return m_pFileMenu; }
346 #if CTSIM_MDI
347   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
348 #else
349   wxDocChildFrame* getFrame() { return m_pFrame; }
350 #endif
351 };
352
353 class PhantomCanvas: public wxScrolledWindow
354 {
355 private:
356   PhantomFileView* m_pView;
357
358 public:  
359   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
360   virtual ~PhantomCanvas();
361
362   virtual wxSize GetBestSize() const;
363   void setView(PhantomFileView* pView)
364   { m_pView = pView; }
365   virtual void OnDraw(wxDC& dc);
366 };
367
368 class PlotFileCanvas;
369 class PlotFileView : public wxView
370 {
371   DECLARE_DYNAMIC_CLASS(PlotFileView)
372     
373 private:
374 #if CTSIM_MDI
375   wxDocMDIChildFrame* m_pFrame;
376   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
377 #else
378   wxDocChildFrame* m_pFrame;
379   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
380 #endif
381   
382   PlotFileCanvas *m_pCanvas;
383   EZPlot* m_pEZPlot;
384   wxMenu* m_pFileMenu;
385   
386   bool m_bMinSpecified;
387   bool m_bMaxSpecified;
388   double m_dMinPixel;
389   double m_dMaxPixel;
390   double m_dAutoScaleFactor;
391   
392   PlotFileCanvas *CreateCanvas (wxFrame* parent);
393   wxWindow* getFrameForChild() 
394 #if CTSIM_MDI
395   { return theApp->getMainFrame(); }
396 #else
397   { return m_pFrame; }
398 #endif
399
400 public:
401   PlotFileView();
402   virtual ~PlotFileView();
403   void canvasClosed()
404   { m_pCanvas = NULL; m_pFrame = NULL; }
405   
406   bool OnCreate(wxDocument *doc, long flags);
407   void OnDraw(wxDC* dc);
408   void OnUpdate(wxView *sender, wxObject *hint = NULL);
409   bool OnClose (bool deleteWindow = true);
410
411   void OnProperties (wxCommandEvent& event);
412   void OnScaleMinMax (wxCommandEvent& event);
413   void OnScaleAuto (wxCommandEvent& event);
414   void OnScaleFull (wxCommandEvent& event);
415   
416 #if CTSIM_MDI
417   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
418 #else
419   wxDocChildFrame* getFrame() { return m_pFrame; }
420 #endif
421   
422   wxMenu* getFileMenu() { return m_pFileMenu; }
423   PlotFileDocument* GetDocument() 
424   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
425   
426   DECLARE_EVENT_TABLE()
427 };
428
429 class PlotFileCanvas: public wxScrolledWindow
430 {
431 private:
432   PlotFileView* m_pView;
433   
434 public:
435   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
436   virtual ~PlotFileCanvas();
437  
438   virtual void OnDraw(wxDC& dc);
439
440   void setView (PlotFileView* pView)
441   { m_pView = pView; }
442 };
443
444
445 class TextFileCanvas;
446 class TextFileView: public wxView
447 {
448 private:
449   DECLARE_DYNAMIC_CLASS(TextFileView)
450
451 #if CTSIM_MDI
452   wxDocMDIChildFrame* m_pFrame;
453   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
454 #else
455   wxDocChildFrame* m_pFrame;
456   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
457 #endif
458     wxMenu* m_pFileMenu;
459     TextFileCanvas *m_pCanvas;
460   
461 public:
462     TextFileView() 
463       : wxView() , m_pFrame(0), m_pCanvas(0)
464     {}
465     ~TextFileView();
466     void canvasClosed()
467     { m_pFrame = NULL; }
468
469     bool OnCreate (wxDocument *doc, long flags);
470     void OnDraw (wxDC *dc);
471     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
472     bool OnClose (bool deleteWindow = TRUE);
473
474     TextFileDocument* GetDocument() 
475     { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
476   
477     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
478     wxMenu* getFileMenu() { return m_pFileMenu; }
479 #if CTSIM_MDI
480   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
481 #else
482   wxDocChildFrame* getFrame() { return m_pFrame; }
483 #endif
484 };
485
486 class TextFileCanvas: public wxTextCtrl
487 {
488     TextFileView *m_pView;
489
490 public:    
491     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
492     ~TextFileCanvas ();
493 };
494
495
496 #endif
497