1 /*****************************************************************************
5 ** Purpose: Header file for View & Canvas routines of CTSim program
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: views.h,v 1.52 2001/03/18 18:08:26 kevin Exp $
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.
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.
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 ******************************************************************************/
37 #include "imagefile.h"
38 #include "threadrecon.h"
41 #include "graph3dview.h"
44 class ImageFileCanvas;
45 class ImageFileView : public wxView
48 DECLARE_DYNAMIC_CLASS(ImageFileView)
50 wxMemoryDC m_memoryDC;
52 wxMenu* m_pMenuAnalyze;
54 ImageFileCanvas *CreateCanvas (wxFrame* parent);
56 wxDocMDIChildFrame* m_pFrame;
57 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
59 wxDocChildFrame* m_pFrame;
60 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
63 ImageFileCanvas *m_pCanvas;
69 double m_dAutoScaleFactor;
71 int m_iDefaultExportFormatID;
73 wxWindow* getFrameForChild()
75 { return theApp->getMainFrame(); }
82 virtual ~ImageFileView();
84 { m_pCanvas = NULL; m_pFrame = NULL; }
87 { return m_pFileMenu; }
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);
94 void OnEditCopy (wxCommandEvent& event);
95 void OnEditCut (wxCommandEvent& event);
96 void OnEditPaste (wxCommandEvent& event);
98 void OnRevert (wxCommandEvent& event);
99 void OnExport (wxCommandEvent& event);
100 void OnProperties (wxCommandEvent& event);
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);
118 void OnConvert3d (wxCommandEvent& event);
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);
130 void OnMagnitude (wxCommandEvent& event);
131 void OnPhase (wxCommandEvent& event);
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);
139 void OnPlotFFTRow (wxCommandEvent& event);
140 void OnPlotFFTCol (wxCommandEvent& event);
142 void OnPlotHistogram (wxCommandEvent& event);
143 void OnCompareRow (wxCommandEvent& event);
144 void OnCompareCol (wxCommandEvent& event);
147 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
149 wxDocChildFrame* getFrame() { return m_pFrame; }
152 wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
154 ImageFileDocument* GetDocument()
155 { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
157 DECLARE_EVENT_TABLE()
160 class ImageFileCanvas: public wxScrolledWindow
163 ImageFileView* m_pView;
169 ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
170 virtual ~ImageFileCanvas();
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);
178 virtual wxSize GetBestSize() const;
179 void setView(ImageFileView* pView)
183 DECLARE_EVENT_TABLE()
187 class ProjectionFileCanvas;
188 class ProjectionFileView : public wxView
191 DECLARE_DYNAMIC_CLASS(ProjectionFileView)
193 wxMemoryDC m_memoryDC;
196 ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
198 wxDocMDIChildFrame* m_pFrame;
199 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
201 wxDocChildFrame* m_pFrame;
202 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
205 ProjectionFileCanvas *m_pCanvas;
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;
220 int m_iDefaultPolarNX;
221 int m_iDefaultPolarNY;
222 int m_iDefaultPolarInterpolation;
223 int m_iDefaultPolarZeropad;
225 wxWindow* getFrameForChild()
227 { return theApp->getMainFrame(); }
233 ProjectionFileView();
234 virtual ~ProjectionFileView();
236 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
254 void doReconstructFBP (const Projections& rProj, bool bRebinToParallel);
257 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
259 wxDocChildFrame* getFrame() { return m_pFrame; }
261 ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
263 wxMenu* getFileMenu() { return m_pFileMenu; }
265 ProjectionFileDocument* GetDocument()
266 { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
267 DECLARE_EVENT_TABLE()
270 class ProjectionFileCanvas: public wxScrolledWindow
273 ProjectionFileView* m_pView;
276 ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
277 virtual ~ProjectionFileCanvas() ;
279 virtual wxSize GetBestSize() const;
280 virtual void OnDraw(wxDC& dc);
281 void setView(ProjectionFileView* pView)
287 class PhantomFileView : public wxView
290 DECLARE_DYNAMIC_CLASS(PhantomFileView)
291 DECLARE_EVENT_TABLE()
293 PhantomCanvas *CreateCanvas (wxFrame* parent);
295 wxDocMDIChildFrame* m_pFrame;
296 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
298 wxDocChildFrame* m_pFrame;
299 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
302 PhantomCanvas *m_pCanvas;
307 int m_iDefaultNSample;
308 int m_iDefaultGeometry;
310 double m_dDefaultRotation;
311 double m_dDefaultFocalLength;
312 double m_dDefaultCenterDetectorLength;
313 double m_dDefaultViewRatio;
314 double m_dDefaultScanRatio;
316 int m_iDefaultRasterNX;
317 int m_iDefaultRasterNY;
318 int m_iDefaultRasterNSamples;
319 double m_dDefaultRasterViewRatio;
321 wxWindow* getFrameForChild()
323 { return theApp->getMainFrame(); }
330 virtual ~PhantomFileView();
332 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
342 PhantomFileDocument* GetDocument()
343 { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
345 wxMenu* getFileMenu() { return m_pFileMenu; }
347 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
349 wxDocChildFrame* getFrame() { return m_pFrame; }
353 class PhantomCanvas: public wxScrolledWindow
356 PhantomFileView* m_pView;
359 PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
360 virtual ~PhantomCanvas();
362 virtual wxSize GetBestSize() const;
363 void setView(PhantomFileView* pView)
365 virtual void OnDraw(wxDC& dc);
368 class PlotFileCanvas;
369 class PlotFileView : public wxView
371 DECLARE_DYNAMIC_CLASS(PlotFileView)
375 wxDocMDIChildFrame* m_pFrame;
376 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
378 wxDocChildFrame* m_pFrame;
379 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
382 PlotFileCanvas *m_pCanvas;
386 bool m_bMinSpecified;
387 bool m_bMaxSpecified;
390 double m_dAutoScaleFactor;
392 PlotFileCanvas *CreateCanvas (wxFrame* parent);
393 wxWindow* getFrameForChild()
395 { return theApp->getMainFrame(); }
402 virtual ~PlotFileView();
404 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
411 void OnProperties (wxCommandEvent& event);
412 void OnScaleMinMax (wxCommandEvent& event);
413 void OnScaleAuto (wxCommandEvent& event);
414 void OnScaleFull (wxCommandEvent& event);
417 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
419 wxDocChildFrame* getFrame() { return m_pFrame; }
422 wxMenu* getFileMenu() { return m_pFileMenu; }
423 PlotFileDocument* GetDocument()
424 { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
426 DECLARE_EVENT_TABLE()
429 class PlotFileCanvas: public wxScrolledWindow
432 PlotFileView* m_pView;
435 PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
436 virtual ~PlotFileCanvas();
438 virtual void OnDraw(wxDC& dc);
440 void setView (PlotFileView* pView)
445 class TextFileCanvas;
446 class TextFileView: public wxView
449 DECLARE_DYNAMIC_CLASS(TextFileView)
452 wxDocMDIChildFrame* m_pFrame;
453 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
455 wxDocChildFrame* m_pFrame;
456 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
459 TextFileCanvas *m_pCanvas;
463 : wxView() , m_pFrame(0), m_pCanvas(0)
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);
474 TextFileDocument* GetDocument()
475 { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
477 TextFileCanvas* getTextCtrl() { return m_pCanvas; }
478 wxMenu* getFileMenu() { return m_pFileMenu; }
480 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
482 wxDocChildFrame* getFrame() { return m_pFrame; }
486 class TextFileCanvas: public wxTextCtrl
488 TextFileView *m_pView;
491 TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);