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.56 2001/09/24 09:40:42 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;
65 wxMenu* m_pFilterMenu;
70 double m_dAutoScaleFactor;
72 int m_iDefaultExportFormatID;
74 wxWindow* getFrameForChild()
76 { return theApp->getMainFrame(); }
83 virtual ~ImageFileView();
85 { m_pCanvas = NULL; m_pFrame = NULL; }
88 { return m_pFileMenu; }
90 bool OnCreate(wxDocument *doc, long flags);
91 void OnDraw(wxDC* dc);
92 void OnUpdate(wxView *sender, wxObject *hint = NULL);
93 bool OnClose (bool deleteWindow = true);
95 void OnEditCopy (wxCommandEvent& event);
96 void OnEditCut (wxCommandEvent& event);
97 void OnEditPaste (wxCommandEvent& event);
99 void OnRevert (wxCommandEvent& event);
100 void OnExport (wxCommandEvent& event);
101 void OnProperties (wxCommandEvent& event);
103 void OnCompare (wxCommandEvent& event);
104 void OnScaleSize (wxCommandEvent& event);
105 void OnInvertValues (wxCommandEvent& event);
106 void OnSquare (wxCommandEvent& event);
107 void OnSquareRoot (wxCommandEvent& event);
108 void OnLog (wxCommandEvent& event);
109 void OnExp (wxCommandEvent& event);
110 void OnAdd (wxCommandEvent& event);
111 void OnSubtract (wxCommandEvent& event);
112 void OnMultiply (wxCommandEvent& event);
113 void OnDivide (wxCommandEvent& event);
114 void OnFourier (wxCommandEvent& event);
115 void OnInverseFourier (wxCommandEvent& event);
116 void OnShuffleNaturalToFourierOrder (wxCommandEvent& event);
117 void OnShuffleFourierToNaturalOrder (wxCommandEvent& event);
119 void OnConvert3d (wxCommandEvent& event);
123 void OnFFT (wxCommandEvent& event);
124 void OnIFFT (wxCommandEvent& event);
125 void OnFFTRows (wxCommandEvent& event);
126 void OnIFFTRows (wxCommandEvent& event);
127 void OnFFTCols (wxCommandEvent& event);
128 void OnIFFTCols (wxCommandEvent& event);
131 void OnMagnitude (wxCommandEvent& event);
132 void OnPhase (wxCommandEvent& event);
133 void OnReal (wxCommandEvent& event);
134 void OnImaginary (wxCommandEvent& event);
136 void OnScaleAuto (wxCommandEvent& event);
137 void OnScaleMinMax (wxCommandEvent& event);
138 void OnScaleFull (wxCommandEvent& event);
139 void OnPlotRow (wxCommandEvent& event);
140 void OnPlotCol (wxCommandEvent& event);
142 void OnPlotFFTRow (wxCommandEvent& event);
143 void OnPlotFFTCol (wxCommandEvent& event);
145 void OnPlotHistogram (wxCommandEvent& event);
146 void OnCompareRow (wxCommandEvent& event);
147 void OnCompareCol (wxCommandEvent& event);
150 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
152 wxDocChildFrame* getFrame() { return m_pFrame; }
155 wxMenu* getMenuAnalyze() { return m_pMenuAnalyze; }
157 ImageFileDocument* GetDocument()
158 { return dynamic_cast<ImageFileDocument*>(wxView::GetDocument()); }
160 DECLARE_EVENT_TABLE()
163 class ImageFileCanvas: public wxScrolledWindow
166 ImageFileView* m_pView;
172 ImageFileCanvas (ImageFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
173 virtual ~ImageFileCanvas();
175 virtual void OnDraw(wxDC& dc);
176 void OnChar(wxKeyEvent& event);
177 void OnMouseEvent(wxMouseEvent& event);
178 void DrawRubberBandCursor (wxDC& dc, int x, int y);
179 bool GetCurrentCursor (int& x, int& y);
181 virtual wxSize GetBestSize() const;
182 void setView(ImageFileView* pView)
186 DECLARE_EVENT_TABLE()
190 class ProjectionFileCanvas;
191 class ProjectionFileView : public wxView
194 DECLARE_DYNAMIC_CLASS(ProjectionFileView)
196 wxMemoryDC m_memoryDC;
199 ProjectionFileCanvas *CreateCanvas (wxFrame* parent);
201 wxDocMDIChildFrame* m_pFrame;
202 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
204 wxDocChildFrame* m_pFrame;
205 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
208 ProjectionFileCanvas *m_pCanvas;
213 int m_iDefaultFilter;
214 int m_iDefaultFilterMethod;
215 double m_dDefaultFilterParam;
216 int m_iDefaultFilterGeneration;
217 int m_iDefaultZeropad;
218 int m_iDefaultInterpolation;
219 int m_iDefaultInterpParam;
220 int m_iDefaultBackprojector;
223 int m_iDefaultPolarNX;
224 int m_iDefaultPolarNY;
225 int m_iDefaultPolarInterpolation;
226 int m_iDefaultPolarZeropad;
228 wxWindow* getFrameForChild()
230 { return theApp->getMainFrame(); }
236 ProjectionFileView();
237 virtual ~ProjectionFileView();
239 { m_pCanvas = NULL; m_pFrame = NULL; }
241 bool OnCreate(wxDocument *doc, long flags);
242 void OnDraw(wxDC* dc);
243 void OnUpdate(wxView *sender, wxObject *hint = NULL);
244 bool OnClose (bool deleteWindow = true);
245 void OnProperties (wxCommandEvent& event);
246 void OnReconstructFBP (wxCommandEvent& event);
247 void OnReconstructFBPRebin (wxCommandEvent& event);
248 void OnReconstructFourier (wxCommandEvent& event);
249 void OnConvertRectangular (wxCommandEvent& event);
250 void OnConvertPolar (wxCommandEvent& event);
251 void OnConvertFFTPolar (wxCommandEvent& event);
252 void OnPlotTThetaSampling (wxCommandEvent& event);
253 void OnPlotHistogram (wxCommandEvent& event);
254 void OnConvertParallel (wxCommandEvent& event);
255 void OnArtifactReduction (wxCommandEvent& event);
257 void doReconstructFBP (const Projections& rProj, bool bRebinToParallel);
260 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
262 wxDocChildFrame* getFrame() { return m_pFrame; }
264 ProjectionFileCanvas* getCanvas() { return m_pCanvas; }
266 wxMenu* getFileMenu() { return m_pFileMenu; }
268 ProjectionFileDocument* GetDocument()
269 { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
270 DECLARE_EVENT_TABLE()
273 class ProjectionFileCanvas: public wxScrolledWindow
276 ProjectionFileView* m_pView;
279 ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
280 virtual ~ProjectionFileCanvas() ;
282 virtual wxSize GetBestSize() const;
283 virtual void OnDraw(wxDC& dc);
284 void setView(ProjectionFileView* pView)
290 class PhantomFileView : public wxView
293 DECLARE_DYNAMIC_CLASS(PhantomFileView)
294 DECLARE_EVENT_TABLE()
296 PhantomCanvas *CreateCanvas (wxFrame* parent);
298 wxDocMDIChildFrame* m_pFrame;
299 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
301 wxDocChildFrame* m_pFrame;
302 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
305 PhantomCanvas *m_pCanvas;
310 int m_iDefaultOffsetView;
311 int m_iDefaultNSample;
312 int m_iDefaultGeometry;
314 double m_dDefaultRotation;
315 double m_dDefaultFocalLength;
316 double m_dDefaultCenterDetectorLength;
317 double m_dDefaultViewRatio;
318 double m_dDefaultScanRatio;
320 int m_iDefaultRasterNX;
321 int m_iDefaultRasterNY;
322 int m_iDefaultRasterNSamples;
323 double m_dDefaultRasterViewRatio;
325 wxWindow* getFrameForChild()
327 { return theApp->getMainFrame(); }
334 virtual ~PhantomFileView();
336 { m_pCanvas = NULL; m_pFrame = NULL; }
338 bool OnCreate(wxDocument *doc, long flags);
339 void OnUpdate(wxView *sender, wxObject *hint = NULL);
340 bool OnClose (bool deleteWindow = true);
341 void OnDraw(wxDC* dc);
342 void OnProperties (wxCommandEvent& event);
343 void OnRasterize (wxCommandEvent& event);
344 void OnProjections (wxCommandEvent& event);
346 PhantomFileDocument* GetDocument()
347 { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
349 wxMenu* getFileMenu() { return m_pFileMenu; }
351 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
353 wxDocChildFrame* getFrame() { return m_pFrame; }
357 class PhantomCanvas: public wxScrolledWindow
360 PhantomFileView* m_pView;
363 PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
364 virtual ~PhantomCanvas();
366 virtual wxSize GetBestSize() const;
367 void setView(PhantomFileView* pView)
369 virtual void OnDraw(wxDC& dc);
372 class PlotFileCanvas;
373 class PlotFileView : public wxView
375 DECLARE_DYNAMIC_CLASS(PlotFileView)
379 wxDocMDIChildFrame* m_pFrame;
380 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
382 wxDocChildFrame* m_pFrame;
383 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
386 PlotFileCanvas *m_pCanvas;
390 bool m_bMinSpecified;
391 bool m_bMaxSpecified;
394 double m_dAutoScaleFactor;
396 PlotFileCanvas *CreateCanvas (wxFrame* parent);
397 wxWindow* getFrameForChild()
399 { return theApp->getMainFrame(); }
406 virtual ~PlotFileView();
408 { m_pCanvas = NULL; m_pFrame = NULL; }
410 bool OnCreate(wxDocument *doc, long flags);
411 void OnDraw(wxDC* dc);
412 void OnUpdate(wxView *sender, wxObject *hint = NULL);
413 bool OnClose (bool deleteWindow = true);
415 void OnProperties (wxCommandEvent& event);
416 void OnScaleMinMax (wxCommandEvent& event);
417 void OnScaleAuto (wxCommandEvent& event);
418 void OnScaleFull (wxCommandEvent& event);
421 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
423 wxDocChildFrame* getFrame() { return m_pFrame; }
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);
444 void setView (PlotFileView* pView)
449 class TextFileCanvas;
450 class TextFileView: public wxView
453 DECLARE_DYNAMIC_CLASS(TextFileView)
456 wxDocMDIChildFrame* m_pFrame;
457 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
459 wxDocChildFrame* m_pFrame;
460 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
463 TextFileCanvas *m_pCanvas;
467 : wxView() , m_pFrame(0), m_pCanvas(0)
473 bool OnCreate (wxDocument *doc, long flags);
474 void OnDraw (wxDC *dc);
475 void OnUpdate (wxView *sender, wxObject *hint = (wxObject *) NULL);
476 bool OnClose (bool deleteWindow = TRUE);
478 TextFileDocument* GetDocument()
479 { return dynamic_cast<TextFileDocument*>(wxView::GetDocument()); }
481 TextFileCanvas* getTextCtrl() { return m_pCanvas; }
482 wxMenu* getFileMenu() { return m_pFileMenu; }
484 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
486 wxDocChildFrame* getFrame() { return m_pFrame; }
490 class TextFileCanvas: public wxTextCtrl
492 TextFileView *m_pView;
495 TextFileCanvas (TextFileView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, long style);