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