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-2009 Kevin Rosenberg
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.
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.
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 ******************************************************************************/
31 #include "imagefile.h"
32 #include "threadrecon.h"
35 #include "graph3dview.h"
38 class ImageFileCanvas;
39 class ImageFileView : public wxView
42 DECLARE_DYNAMIC_CLASS(ImageFileView)
44 wxMemoryDC m_memoryDC;
46 wxMenu* m_pMenuAnalyze;
48 ImageFileCanvas *CreateCanvas (wxFrame* parent);
50 wxDocMDIChildFrame* m_pFrame;
51 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
53 wxDocChildFrame* m_pFrame;
54 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
57 ImageFileCanvas *m_pCanvas;
59 wxMenu* m_pFilterMenu;
64 double m_dAutoScaleFactor;
66 int m_iDefaultExportFormatID;
68 wxFrame* getFrameForChild()
70 { return theApp->getMainFrame(); }
77 virtual ~ImageFileView();
79 { m_pCanvas = NULL; m_pFrame = NULL; }
82 { return m_pFileMenu; }
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);
89 void OnEditCopy (wxCommandEvent& event);
90 void OnEditCut (wxCommandEvent& event);
91 void OnEditPaste (wxCommandEvent& event);
93 void OnRevert (wxCommandEvent& event);
94 void OnExport (wxCommandEvent& event);
95 void OnProperties (wxCommandEvent& event);
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);
113 void OnConvert3d (wxCommandEvent& event);
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);
125 void OnMagnitude (wxCommandEvent& event);
126 void OnPhase (wxCommandEvent& event);
127 void OnReal (wxCommandEvent& event);
128 void OnImaginary (wxCommandEvent& event);
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);
136 void OnPlotFFTRow (wxCommandEvent& event);
137 void OnPlotFFTCol (wxCommandEvent& event);
139 void OnPlotHistogram (wxCommandEvent& event);
140 void OnCompareRow (wxCommandEvent& event);
141 void OnCompareCol (wxCommandEvent& event);
144 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
146 wxDocChildFrame* getFrame() { return m_pFrame; }
148 void setInitialClientSize();
150 wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
152 ImageFileDocument* GetDocument()
153 { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
155 DECLARE_EVENT_TABLE()
158 class ImageFileCanvas: public wxScrolledWindow
161 ImageFileView* m_pView;
167 ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
168 virtual ~ImageFileCanvas();
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);
176 virtual wxSize GetBestSize() const;
177 void setView(ImageFileView* pView)
181 DECLARE_EVENT_TABLE()
185 class ProjectionFileCanvas;
186 class ProjectionFileView : public wxView
189 DECLARE_DYNAMIC_CLASS(ProjectionFileView)
191 wxMemoryDC m_memoryDC;
194 ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
196 wxDocMDIChildFrame* m_pFrame;
197 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
199 wxDocChildFrame* m_pFrame;
200 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
203 ProjectionFileCanvas *m_pCanvas;
205 wxMenu* m_pReconstructMenu;
206 wxMenu* m_pConvertMenu;
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; }
262 void setInitialClientSize();
264 wxMenu* getFileMenu() { return m_pFileMenu; }
265 wxMenu* getReconstructMenu() { return m_pReconstructMenu; }
267 ProjectionFileDocument* GetDocument()
268 { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
269 DECLARE_EVENT_TABLE()
272 class ProjectionFileCanvas: public wxScrolledWindow
275 ProjectionFileView* m_pView;
278 ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
279 virtual ~ProjectionFileCanvas() ;
281 virtual wxSize GetBestSize() const;
282 virtual void OnDraw(wxDC& dc);
283 void setView(ProjectionFileView* pView)
289 class PhantomFileView : public wxView
292 DECLARE_DYNAMIC_CLASS(PhantomFileView)
293 DECLARE_EVENT_TABLE()
295 PhantomCanvas *CreateCanvas (wxFrame* parent);
297 wxDocMDIChildFrame* m_pFrame;
298 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
300 wxDocChildFrame* m_pFrame;
301 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
304 PhantomCanvas *m_pCanvas;
309 int m_iDefaultOffsetView;
310 int m_iDefaultNSample;
311 int m_iDefaultGeometry;
313 double m_dDefaultRotation;
314 double m_dDefaultFocalLength;
315 double m_dDefaultCenterDetectorLength;
316 double m_dDefaultViewRatio;
317 double m_dDefaultScanRatio;
319 int m_iDefaultRasterNX;
320 int m_iDefaultRasterNY;
321 int m_iDefaultRasterNSamples;
322 double m_dDefaultRasterViewRatio;
324 wxWindow* getFrameForChild()
326 { return theApp->getMainFrame(); }
333 virtual ~PhantomFileView();
335 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
345 PhantomFileDocument* GetDocument()
346 { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
348 wxMenu* getFileMenu() { return m_pFileMenu; }
350 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
352 wxDocChildFrame* getFrame() { return m_pFrame; }
356 class PhantomCanvas: public wxScrolledWindow
359 PhantomFileView* m_pView;
362 PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
363 virtual ~PhantomCanvas();
365 virtual wxSize GetBestSize() const;
366 void setView(PhantomFileView* pView)
368 virtual void OnDraw(wxDC& dc);
371 class PlotFileCanvas;
372 class PlotFileView : public wxView
374 DECLARE_DYNAMIC_CLASS(PlotFileView)
378 wxDocMDIChildFrame* m_pFrame;
379 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
381 wxDocChildFrame* m_pFrame;
382 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
385 PlotFileCanvas *m_pCanvas;
389 bool m_bMinSpecified;
390 bool m_bMaxSpecified;
393 double m_dAutoScaleFactor;
395 PlotFileCanvas *CreateCanvas (wxFrame* parent);
396 wxWindow* getFrameForChild()
398 { return theApp->getMainFrame(); }
405 virtual ~PlotFileView();
407 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
414 void OnProperties (wxCommandEvent& event);
415 void OnScaleMinMax (wxCommandEvent& event);
416 void OnScaleAuto (wxCommandEvent& event);
417 void OnScaleFull (wxCommandEvent& event);
420 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
422 wxDocChildFrame* getFrame() { return m_pFrame; }
425 void setInitialClientSize();
426 wxMenu* getFileMenu() { return m_pFileMenu; }
427 PlotFileDocument* GetDocument()
428 { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
430 DECLARE_EVENT_TABLE()
433 class PlotFileCanvas: public wxScrolledWindow
436 PlotFileView* m_pView;
439 PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
440 virtual ~PlotFileCanvas();
442 virtual void OnDraw(wxDC& dc);
443 virtual wxSize GetBestSize() const;
445 void setView (PlotFileView* pView)
450 class TextFileCanvas;
451 class TextFileView: public wxView
454 DECLARE_DYNAMIC_CLASS(TextFileView)
457 wxDocMDIChildFrame* m_pFrame;
458 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
460 wxDocChildFrame* m_pFrame;
461 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
464 TextFileCanvas *m_pCanvas;
468 : wxView() , m_pFrame(0), m_pCanvas(0)
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);
479 TextFileDocument* GetDocument()
480 { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
482 TextFileCanvas* getTextCtrl() { return m_pCanvas; }
483 wxMenu* getFileMenu() { return m_pFileMenu; }
485 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
487 wxDocChildFrame* getFrame() { return m_pFrame; }
491 class TextFileCanvas: public wxTextCtrl
493 TextFileView *m_pView;
496 TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
498 virtual wxSize GetBestSize() const;