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.59 2003/01/23 23:35:58 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 ******************************************************************************/
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;
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; }
266 ProjectionFileDocument* GetDocument()
267 { return dynamic_cast<ProjectionFileDocument*>(wxView::GetDocument()); }
268 DECLARE_EVENT_TABLE()
271 class ProjectionFileCanvas: public wxScrolledWindow
274 ProjectionFileView* m_pView;
277 ProjectionFileCanvas (ProjectionFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
278 virtual ~ProjectionFileCanvas() ;
280 virtual wxSize GetBestSize() const;
281 virtual void OnDraw(wxDC& dc);
282 void setView(ProjectionFileView* pView)
288 class PhantomFileView : public wxView
291 DECLARE_DYNAMIC_CLASS(PhantomFileView)
292 DECLARE_EVENT_TABLE()
294 PhantomCanvas *CreateCanvas (wxFrame* parent);
296 wxDocMDIChildFrame* m_pFrame;
297 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
299 wxDocChildFrame* m_pFrame;
300 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
303 PhantomCanvas *m_pCanvas;
308 int m_iDefaultOffsetView;
309 int m_iDefaultNSample;
310 int m_iDefaultGeometry;
312 double m_dDefaultRotation;
313 double m_dDefaultFocalLength;
314 double m_dDefaultCenterDetectorLength;
315 double m_dDefaultViewRatio;
316 double m_dDefaultScanRatio;
318 int m_iDefaultRasterNX;
319 int m_iDefaultRasterNY;
320 int m_iDefaultRasterNSamples;
321 double m_dDefaultRasterViewRatio;
323 wxWindow* getFrameForChild()
325 { return theApp->getMainFrame(); }
332 virtual ~PhantomFileView();
334 { m_pCanvas = NULL; m_pFrame = NULL; }
336 bool OnCreate(wxDocument *doc, long flags);
337 void OnUpdate(wxView *sender, wxObject *hint = NULL);
338 bool OnClose (bool deleteWindow = true);
339 void OnDraw(wxDC* dc);
340 void OnProperties (wxCommandEvent& event);
341 void OnRasterize (wxCommandEvent& event);
342 void OnProjections (wxCommandEvent& event);
344 PhantomFileDocument* GetDocument()
345 { return dynamic_cast<PhantomFileDocument*>(wxView::GetDocument()); }
347 wxMenu* getFileMenu() { return m_pFileMenu; }
349 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
351 wxDocChildFrame* getFrame() { return m_pFrame; }
355 class PhantomCanvas: public wxScrolledWindow
358 PhantomFileView* m_pView;
361 PhantomCanvas (PhantomFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
362 virtual ~PhantomCanvas();
364 virtual wxSize GetBestSize() const;
365 void setView(PhantomFileView* pView)
367 virtual void OnDraw(wxDC& dc);
370 class PlotFileCanvas;
371 class PlotFileView : public wxView
373 DECLARE_DYNAMIC_CLASS(PlotFileView)
377 wxDocMDIChildFrame* m_pFrame;
378 wxDocMDIChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
380 wxDocChildFrame* m_pFrame;
381 wxDocChildFrame* CreateChildFrame(wxDocument *doc, wxView *view);
384 PlotFileCanvas *m_pCanvas;
388 bool m_bMinSpecified;
389 bool m_bMaxSpecified;
392 double m_dAutoScaleFactor;
394 PlotFileCanvas *CreateCanvas (wxFrame* parent);
395 wxWindow* getFrameForChild()
397 { return theApp->getMainFrame(); }
404 virtual ~PlotFileView();
406 { m_pCanvas = NULL; m_pFrame = NULL; }
408 bool OnCreate(wxDocument *doc, long flags);
409 void OnDraw(wxDC* dc);
410 void OnUpdate(wxView *sender, wxObject *hint = NULL);
411 bool OnClose (bool deleteWindow = true);
413 void OnProperties (wxCommandEvent& event);
414 void OnScaleMinMax (wxCommandEvent& event);
415 void OnScaleAuto (wxCommandEvent& event);
416 void OnScaleFull (wxCommandEvent& event);
419 wxDocMDIChildFrame* getFrame() { return m_pFrame; }
421 wxDocChildFrame* getFrame() { return m_pFrame; }
424 void setInitialClientSize();
425 wxMenu* getFileMenu() { return m_pFileMenu; }
426 PlotFileDocument* GetDocument()
427 { return dynamic_cast<PlotFileDocument*>(wxView::GetDocument()); }
429 DECLARE_EVENT_TABLE()
432 class PlotFileCanvas: public wxScrolledWindow
435 PlotFileView* m_pView;
438 PlotFileCanvas (PlotFileView* v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
439 virtual ~PlotFileCanvas();
441 virtual void OnDraw(wxDC& dc);
442 virtual wxSize GetBestSize() const;
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);
497 virtual wxSize GetBestSize() const;