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