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