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
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 ******************************************************************************/
33 #include "imagefile.h"
34 #include "threadrecon.h"
37 #include "graph3dview.h"
40 class ImageFileCanvas;
41 class ImageFileView : public wxView
44 DECLARE_DYNAMIC_CLASS(ImageFileView)
46 wxMemoryDC m_memoryDC;
48 wxMenu* m_pMenuAnalyze;
50 ImageFileCanvas *CreateCanvas (wxFrame* parent);
52 wxDocMDIChildFrame* m_pFrame;
53 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
55 wxDocChildFrame* m_pFrame;
56 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
59 ImageFileCanvas *m_pCanvas;
61 wxMenu* m_pFilterMenu;
66 double m_dAutoScaleFactor;
68 int m_iDefaultExportFormatID;
70 wxWindow* getFrameForChild()
72 { return theApp->getMainFrame(); }
79 virtual ~ImageFileView();
81 { m_pCanvas = NULL; m_pFrame = NULL; }
84 { return m_pFileMenu; }
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);
91 void OnEditCopy (wxCommandEvent& event);
92 void OnEditCut (wxCommandEvent& event);
93 void OnEditPaste (wxCommandEvent& event);
95 void OnRevert (wxCommandEvent& event);
96 void OnExport (wxCommandEvent& event);
97 void OnProperties (wxCommandEvent& event);
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);
115 void OnConvert3d (wxCommandEvent& event);
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);
127 void OnMagnitude (wxCommandEvent& event);
128 void OnPhase (wxCommandEvent& event);
129 void OnReal (wxCommandEvent& event);
130 void OnImaginary (wxCommandEvent& event);
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);
138 void OnPlotFFTRow (wxCommandEvent& event);
139 void OnPlotFFTCol (wxCommandEvent& event);
141 void OnPlotHistogram (wxCommandEvent& event);
142 void OnCompareRow (wxCommandEvent& event);
143 void OnCompareCol (wxCommandEvent& event);
146 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
148 wxDocChildFrame* getFrame() { return m_pFrame; }
150 void setInitialClientSize();
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;
207 wxMenu* m_pReconstructMenu;
208 wxMenu* m_pConvertMenu;
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;
222 int m_iDefaultPolarNX;
223 int m_iDefaultPolarNY;
224 int m_iDefaultPolarInterpolation;
225 int m_iDefaultPolarZeropad;
227 wxWindow* getFrameForChild()
229 { return theApp->getMainFrame(); }
235 ProjectionFileView();
236 virtual ~ProjectionFileView();
238 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
256 void doReconstructFBP (const Projections& rProj, bool bRebinToParallel);
259 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
261 wxDocChildFrame* getFrame() { return m_pFrame; }
263 ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
264 void setInitialClientSize();
266 wxMenu* getFileMenu() { return m_pFileMenu; }
267 wxMenu* getReconstructMenu() { return m_pReconstructMenu; }
269 ProjectionFileDocument* GetDocument()
270 { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
271 DECLARE_EVENT_TABLE()
274 class ProjectionFileCanvas: public wxScrolledWindow
277 ProjectionFileView* m_pView;
280 ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
281 virtual ~ProjectionFileCanvas() ;
283 virtual wxSize GetBestSize() const;
284 virtual void OnDraw(wxDC& dc);
285 void setView(ProjectionFileView* pView)
291 class PhantomFileView : public wxView
294 DECLARE_DYNAMIC_CLASS(PhantomFileView)
295 DECLARE_EVENT_TABLE()
297 PhantomCanvas *CreateCanvas (wxFrame* parent);
299 wxDocMDIChildFrame* m_pFrame;
300 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
302 wxDocChildFrame* m_pFrame;
303 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
306 PhantomCanvas *m_pCanvas;
311 int m_iDefaultOffsetView;
312 int m_iDefaultNSample;
313 int m_iDefaultGeometry;
315 double m_dDefaultRotation;
316 double m_dDefaultFocalLength;
317 double m_dDefaultCenterDetectorLength;
318 double m_dDefaultViewRatio;
319 double m_dDefaultScanRatio;
321 int m_iDefaultRasterNX;
322 int m_iDefaultRasterNY;
323 int m_iDefaultRasterNSamples;
324 double m_dDefaultRasterViewRatio;
326 wxWindow* getFrameForChild()
328 { return theApp->getMainFrame(); }
335 virtual ~PhantomFileView();
337 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
347 PhantomFileDocument* GetDocument()
348 { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
350 wxMenu* getFileMenu() { return m_pFileMenu; }
352 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
354 wxDocChildFrame* getFrame() { return m_pFrame; }
358 class PhantomCanvas: public wxScrolledWindow
361 PhantomFileView* m_pView;
364 PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
365 virtual ~PhantomCanvas();
367 virtual wxSize GetBestSize() const;
368 void setView(PhantomFileView* pView)
370 virtual void OnDraw(wxDC& dc);
373 class PlotFileCanvas;
374 class PlotFileView : public wxView
376 DECLARE_DYNAMIC_CLASS(PlotFileView)
380 wxDocMDIChildFrame* m_pFrame;
381 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
383 wxDocChildFrame* m_pFrame;
384 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
387 PlotFileCanvas *m_pCanvas;
391 bool m_bMinSpecified;
392 bool m_bMaxSpecified;
395 double m_dAutoScaleFactor;
397 PlotFileCanvas *CreateCanvas (wxFrame* parent);
398 wxWindow* getFrameForChild()
400 { return theApp->getMainFrame(); }
407 virtual ~PlotFileView();
409 { m_pCanvas = NULL; m_pFrame = NULL; }
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);
416 void OnProperties (wxCommandEvent& event);
417 void OnScaleMinMax (wxCommandEvent& event);
418 void OnScaleAuto (wxCommandEvent& event);
419 void OnScaleFull (wxCommandEvent& event);
422 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
424 wxDocChildFrame* getFrame() { return m_pFrame; }
427 void setInitialClientSize();
428 wxMenu* getFileMenu() { return m_pFileMenu; }
429 PlotFileDocument* GetDocument()
430 { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
432 DECLARE_EVENT_TABLE()
435 class PlotFileCanvas: public wxScrolledWindow
438 PlotFileView* m_pView;
441 PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
442 virtual ~PlotFileCanvas();
444 virtual void OnDraw(wxDC& dc);
445 virtual wxSize GetBestSize() const;
447 void setView (PlotFileView* pView)
452 class TextFileCanvas;
453 class TextFileView: public wxView
456 DECLARE_DYNAMIC_CLASS(TextFileView)
459 wxDocMDIChildFrame* m_pFrame;
460 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
462 wxDocChildFrame* m_pFrame;
463 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
466 TextFileCanvas *m_pCanvas;
470 : wxView() , m_pFrame(0), m_pCanvas(0)
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);
481 TextFileDocument* GetDocument()
482 { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
484 TextFileCanvas* getTextCtrl() { return m_pCanvas; }
485 wxMenu* getFileMenu() { return m_pFileMenu; }
487 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
489 wxDocChildFrame* getFrame() { return m_pFrame; }
493 class TextFileCanvas: public wxTextCtrl
495 TextFileView *m_pView;
498 TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);
500 virtual wxSize GetBestSize() const;