Revert "Update package dependency from libwxgtk3.0-dev to libwxgtk3.0-gtk3-dev for...
[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-2009 Kevin Rosenberg
11 **
12 **  This program is free software; you can redistribute it and/or modify
13 **  it under the terms of the GNU General Public License (version 2) as
14 **  published by the Free Software Foundation.
15 **
16 **  This program is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 **  GNU General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with this program; if not, write to the Free Software
23 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 ******************************************************************************/
25
26 #ifndef __VIEWSH__
27 #define __VIEWSH__
28
29 #include "wx/wx.h"
30 #include "docs.h"
31 #include "imagefile.h"
32 #include "threadrecon.h"
33
34 #if wxUSE_GLCANVAS
35 #include "graph3dview.h"
36 #endif
37
38 class ImageFileCanvas;
39 class ImageFileView : public wxView
40 {
41 private:
42   DECLARE_DYNAMIC_CLASS(ImageFileView)
43
44   wxMemoryDC m_memoryDC;
45   wxBitmap* m_pBitmap;
46   wxMenu* m_pMenuAnalyze;
47
48   ImageFileCanvas *CreateCanvas (wxFrame* parent);
49 #if CTSIM_MDI
50   wxDocMDIChildFrame* m_pFrame;
51   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
52 #else
53   wxDocChildFrame* m_pFrame;
54   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
55 #endif
56
57   ImageFileCanvas *m_pCanvas;
58   wxMenu* m_pFileMenu;
59   wxMenu* m_pFilterMenu;
60   bool m_bMinSpecified;
61   bool m_bMaxSpecified;
62   double m_dMinPixel;
63   double m_dMaxPixel;
64   double m_dAutoScaleFactor;
65
66   int m_iDefaultExportFormatID;
67
68   wxFrame* getFrameForChild()
69 #if CTSIM_MDI
70   { return theApp->getMainFrame(); }
71 #else
72   { return m_pFrame; }
73 #endif
74
75 public:
76   ImageFileView();
77   virtual ~ImageFileView();
78   void canvasClosed()
79   { m_pCanvas = NULL; m_pFrame = NULL; }
80
81   wxMenu* getFileMenu()
82   { return m_pFileMenu; }
83
84   bool OnCreate(wxDocument *doc, long flags);
85   void OnDraw(wxDC* dc);
86   void OnUpdate(wxView *sender, wxObject *hint = NULL);
87   bool OnClose (bool deleteWindow = true);
88
89   void OnEditCopy (wxCommandEvent& event);
90   void OnEditCut (wxCommandEvent& event);
91   void OnEditPaste (wxCommandEvent& event);
92
93   void OnRevert (wxCommandEvent& event);
94   void OnExport (wxCommandEvent& event);
95   void OnProperties (wxCommandEvent& event);
96
97   void OnCompare (wxCommandEvent& event);
98   void OnScaleSize (wxCommandEvent& event);
99   void OnInvertValues (wxCommandEvent& event);
100   void OnSquare (wxCommandEvent& event);
101   void OnSquareRoot (wxCommandEvent& event);
102   void OnLog (wxCommandEvent& event);
103   void OnExp (wxCommandEvent& event);
104   void OnAdd (wxCommandEvent& event);
105   void OnSubtract (wxCommandEvent& event);
106   void OnMultiply (wxCommandEvent& event);
107   void OnDivide (wxCommandEvent& event);
108   void OnFourier (wxCommandEvent& event);
109   void OnInverseFourier (wxCommandEvent& event);
110   void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
111   void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
112 #if wxUSE_GLCANVAS
113   void OnConvert3d (wxCommandEvent& event);
114 #endif
115
116 #ifdef HAVE_FFT
117   void OnFFT (wxCommandEvent& event);
118   void OnIFFT (wxCommandEvent& event);
119   void OnFFTRows (wxCommandEvent& event);
120   void OnIFFTRows (wxCommandEvent& event);
121   void OnFFTCols (wxCommandEvent& event);
122   void OnIFFTCols (wxCommandEvent& event);
123 #endif
124
125   void OnMagnitude (wxCommandEvent& event);
126   void OnPhase (wxCommandEvent& event);
127   void OnReal (wxCommandEvent& event);
128   void OnImaginary (wxCommandEvent& event);
129
130   void OnScaleAuto (wxCommandEvent& event);
131   void OnScaleMinMax (wxCommandEvent& event);
132   void OnScaleFull (wxCommandEvent& event);
133   void OnPlotRow (wxCommandEvent& event);
134   void OnPlotCol (wxCommandEvent& event);
135 #if HAVE_FFT
136   void OnPlotFFTRow (wxCommandEvent& event);
137   void OnPlotFFTCol (wxCommandEvent& event);
138 #endif
139   void OnPlotHistogram (wxCommandEvent& event);
140   void OnCompareRow (wxCommandEvent& event);
141   void OnCompareCol (wxCommandEvent& event);
142
143 #if CTSIM_MDI
144   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
145 #else
146   wxDocChildFrame* getFrame() { return m_pFrame; }
147 #endif
148   void setInitialClientSize();
149
150   wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
151
152   ImageFileDocument* GetDocument()
153   { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
154
155   DECLARE_EVENT_TABLE()
156 };
157
158 class ImageFileCanvas: public wxScrolledWindow
159 {
160 private:
161   ImageFileView* m_pView;
162
163   int m_xCursor;
164   int m_yCursor;
165
166 public:
167   ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
168   virtual ~ImageFileCanvas();
169
170   virtual void OnDraw(wxDC& dc);
171   void OnChar(wxKeyEvent& event);
172   void OnMouseEvent(wxMouseEvent& event);
173   void DrawRubberBandCursor (wxDC& dc, int x, int y);
174   bool GetCurrentCursor (int& x, int& y);
175
176   virtual wxSize GetBestSize() const;
177   void setView(ImageFileView* pView)
178   { m_pView = pView; }
179
180
181   DECLARE_EVENT_TABLE()
182 };
183
184
185 class ProjectionFileCanvas;
186 class ProjectionFileView : public wxView
187 {
188 private:
189   DECLARE_DYNAMIC_CLASS(ProjectionFileView)
190
191   wxMemoryDC m_memoryDC;
192   wxBitmap* m_pBitmap;
193
194   ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
195 #if CTSIM_MDI
196   wxDocMDIChildFrame* m_pFrame;
197   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
198 #else
199   wxDocChildFrame* m_pFrame;
200   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
201 #endif
202
203   ProjectionFileCanvas *m_pCanvas;
204   wxMenu* m_pFileMenu;
205   wxMenu* m_pReconstructMenu;
206   wxMenu* m_pConvertMenu;
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   wxMenu* getReconstructMenu()  { return m_pReconstructMenu; }
266
267   ProjectionFileDocument* GetDocument()
268   { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
269   DECLARE_EVENT_TABLE()
270 };
271
272 class ProjectionFileCanvas: public wxScrolledWindow
273 {
274 private:
275   ProjectionFileView* m_pView;
276
277 public:
278   ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
279   virtual ~ProjectionFileCanvas() ;
280
281   virtual wxSize GetBestSize() const;
282   virtual void OnDraw(wxDC& dc);
283   void setView(ProjectionFileView* pView)
284   { m_pView = pView; }
285 };
286
287
288 class PhantomCanvas;
289 class PhantomFileView : public wxView
290 {
291 private:
292   DECLARE_DYNAMIC_CLASS(PhantomFileView)
293   DECLARE_EVENT_TABLE()
294
295   PhantomCanvas *CreateCanvas (wxFrame* parent);
296 #if CTSIM_MDI
297   wxDocMDIChildFrame* m_pFrame;
298   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
299 #else
300   wxDocChildFrame* m_pFrame;
301   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
302 #endif
303
304   PhantomCanvas *m_pCanvas;
305   wxMenu* m_pFileMenu;
306
307   int m_iDefaultNDet;
308   int m_iDefaultNView;
309   int m_iDefaultOffsetView;
310   int m_iDefaultNSample;
311   int m_iDefaultGeometry;
312   int m_iDefaultTrace;
313   double m_dDefaultRotation;
314   double m_dDefaultFocalLength;
315   double m_dDefaultCenterDetectorLength;
316   double m_dDefaultViewRatio;
317   double m_dDefaultScanRatio;
318
319   int m_iDefaultRasterNX;
320   int m_iDefaultRasterNY;
321   int m_iDefaultRasterNSamples;
322   double m_dDefaultRasterViewRatio;
323
324   wxWindow* getFrameForChild()
325 #if CTSIM_MDI
326   { return theApp->getMainFrame(); }
327 #else
328   { return m_pFrame; }
329 #endif
330
331 public:
332   PhantomFileView();
333   virtual ~PhantomFileView();
334   void canvasClosed()
335   { m_pCanvas = NULL; m_pFrame = NULL; }
336
337   bool OnCreate(wxDocument *doc, long flags);
338   void OnUpdate(wxView *sender, wxObject *hint = NULL);
339   bool OnClose (bool deleteWindow = true);
340   void OnDraw(wxDC* dc);
341   void OnProperties (wxCommandEvent& event);
342   void OnRasterize (wxCommandEvent& event);
343   void OnProjections (wxCommandEvent& event);
344
345   PhantomFileDocument* GetDocument()
346   { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
347
348   wxMenu* getFileMenu() { return m_pFileMenu; }
349 #if CTSIM_MDI
350   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
351 #else
352   wxDocChildFrame* getFrame() { return m_pFrame; }
353 #endif
354 };
355
356 class PhantomCanvas: public wxScrolledWindow
357 {
358 private:
359   PhantomFileView* m_pView;
360
361 public:
362   PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
363   virtual ~PhantomCanvas();
364
365   virtual wxSize GetBestSize() const;
366   void setView(PhantomFileView* pView)
367   { m_pView = pView; }
368   virtual void OnDraw(wxDC& dc);
369 };
370
371 class PlotFileCanvas;
372 class PlotFileView : public wxView
373 {
374   DECLARE_DYNAMIC_CLASS(PlotFileView)
375
376 private:
377 #if CTSIM_MDI
378   wxDocMDIChildFrame* m_pFrame;
379   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
380 #else
381   wxDocChildFrame* m_pFrame;
382   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
383 #endif
384
385   PlotFileCanvas *m_pCanvas;
386   EZPlot* m_pEZPlot;
387   wxMenu* m_pFileMenu;
388
389   bool m_bMinSpecified;
390   bool m_bMaxSpecified;
391   double m_dMinPixel;
392   double m_dMaxPixel;
393   double m_dAutoScaleFactor;
394
395   PlotFileCanvas *CreateCanvas (wxFrame* parent);
396   wxWindow* getFrameForChild()
397 #if CTSIM_MDI
398   { return theApp->getMainFrame(); }
399 #else
400   { return m_pFrame; }
401 #endif
402
403 public:
404   PlotFileView();
405   virtual ~PlotFileView();
406   void canvasClosed()
407   { m_pCanvas = NULL; m_pFrame = NULL; }
408
409   bool OnCreate(wxDocument *doc, long flags);
410   void OnDraw(wxDC* dc);
411   void OnUpdate(wxView *sender, wxObject *hint = NULL);
412   bool OnClose (bool deleteWindow = true);
413
414   void OnProperties (wxCommandEvent& event);
415   void OnScaleMinMax (wxCommandEvent& event);
416   void OnScaleAuto (wxCommandEvent& event);
417   void OnScaleFull (wxCommandEvent& event);
418
419 #if CTSIM_MDI
420   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
421 #else
422   wxDocChildFrame* getFrame() { return m_pFrame; }
423 #endif
424
425   void setInitialClientSize();
426   wxMenu* getFileMenu() { return m_pFileMenu; }
427   PlotFileDocument* GetDocument()
428   { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
429
430   DECLARE_EVENT_TABLE()
431 };
432
433 class PlotFileCanvas: public wxScrolledWindow
434 {
435 private:
436   PlotFileView* m_pView;
437
438 public:
439   PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
440   virtual ~PlotFileCanvas();
441
442   virtual void OnDraw(wxDC& dc);
443   virtual wxSize GetBestSize() const;
444
445   void setView (PlotFileView* pView)
446   { m_pView = pView; }
447 };
448
449
450 class TextFileCanvas;
451 class TextFileView: public wxView
452 {
453 private:
454   DECLARE_DYNAMIC_CLASS(TextFileView)
455
456 #if CTSIM_MDI
457   wxDocMDIChildFrame* m_pFrame;
458   wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
459 #else
460   wxDocChildFrame* m_pFrame;
461   wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
462 #endif
463     wxMenu* m_pFileMenu;
464     TextFileCanvas *m_pCanvas;
465
466 public:
467     TextFileView()
468       : wxView() , m_pFrame(0), m_pCanvas(0)
469     {}
470     ~TextFileView();
471     void canvasClosed()
472     { m_pFrame = NULL; }
473
474     bool OnCreate (wxDocument *doc, long flags);
475     void OnDraw (wxDC *dc);
476     void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
477     bool OnClose (bool deleteWindow = TRUE);
478
479     TextFileDocument* GetDocument()
480     { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
481
482     TextFileCanvas* getTextCtrl() { return m_pCanvas; }
483     wxMenu* getFileMenu() { return m_pFileMenu; }
484 #if CTSIM_MDI
485   wxDocMDIChildFrame* getFrame() { return m_pFrame; }
486 #else
487   wxDocChildFrame* getFrame() { return m_pFrame; }
488 #endif
489 };
490
491 class TextFileCanvas: public wxTextCtrl
492 {
493     TextFileView *m_pView;
494
495 public:
496     TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
497     ~TextFileCanvas ();
498     virtual wxSize GetBestSize() const;
499 };
500
501
502 #endif
503