63316b4190bd697c3f18a5066508f277e6030469
[ctsim.git] / src / ctsim.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          ctsim.cpp
5 **   Purpose:       Top-level routines for CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: ctsim.h,v 1.42 2001/02/06 06:57:46 kevin Exp $
13 **
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.
17 **
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.
22 **
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 ******************************************************************************/
27
28 #ifndef __CTSIMH__
29 #define __CTSIMH__
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34 #ifdef HAVE_DMALLOC
35 #include <dmalloc.h>
36 #endif
37
38 #ifndef WX_PRECOMP
39 #include "wx/wx.h"
40 #endif
41 #include "wx/config.h"
42
43 #ifdef MSVC
44 #define CTSIM_MDI 1
45 #endif
46 #define CTSIM_CUSTOM_MRU 1
47
48 #if defined(CTSIM_MDI) && !wxUSE_MDI_ARCHITECTURE
49 #error You must set wxUSE_MDI_ARCHITECTURE to 1 in setup.h!
50 #endif
51 #ifdef CTSIM_MDI
52 #include "wx/docmdi.h"
53 #endif
54
55 class wxMenu;
56 class wxDocument;
57 class ImageFileDocument;
58 class ProjectionFileDocument;
59 class PhantomFileDocument;
60 class PlotFileDocument;
61 class TextFileDocument;
62 #if wxUSE_GLCANVAS
63 class Graph3dFileDocument;
64 #endif
65
66 #include <vector>
67 #include "wx/docview.h"
68 #include "wx/textctrl.h"
69 #include "wx/menu.h"
70 #include "wx/help.h"
71 #include "wx/html/helpctrl.h"
72 #include "dlgezplot.h"
73
74
75 #if defined(__WXMSW__)
76 #define CTSIM_WINHELP   1
77 #endif
78
79 // Define a new frame for main window
80 #if CTSIM_MDI
81 class MainFrame: public wxDocMDIParentFrame
82 #else
83 class MainFrame: public wxDocParentFrame
84 #endif
85 {
86 private:
87   DECLARE_CLASS(MainFrame)
88   DECLARE_EVENT_TABLE()
89
90 #ifndef CTSIM_MDI
91   wxMenu* m_pWindowMenu;
92 #endif
93
94   enum { MAX_WINDOW_MENUITEMS = 20 };
95   wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
96   wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
97   
98   int m_iDefaultPhantomID;
99   int m_iDefaultFilterID;
100   int m_iDefaultFilterDomainID;
101   unsigned int m_iDefaultFilterXSize;    
102   unsigned int m_iDefaultFilterYSize;
103   double m_dDefaultFilterParam;
104   double m_dDefaultFilterBandwidth;
105   double m_dDefaultFilterInputScale;
106   double m_dDefaultFilterOutputScale;
107
108   bool m_bShuttingDown;
109
110 #if CTSIM_WINHELP
111   wxWinHelpController      m_winHelp;
112 #endif
113   wxHtmlHelpController     m_htmlHelp;
114   
115 public:
116   MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
117   virtual ~MainFrame();
118
119 #ifdef CTSIM_CUSTOM_MRU
120   void OnMRUFile (wxCommandEvent& event);
121 #endif
122   void OnSize (wxSizeEvent& event);
123
124 #if CTSIM_WINHELP
125   wxWinHelpController&   getWinHelpController()
126   {return m_winHelp; }
127 #endif
128   wxHtmlHelpController&  getHtmlHelpController()
129   { return m_htmlHelp; }
130
131   void showHelp (int commandID);
132
133   void OnAbout (wxCommandEvent& event);
134   void OnHelpTopics (wxCommandEvent& event);
135   void OnHelpContents (wxCommandEvent& event);
136   void OnCreatePhantom (wxCommandEvent& event);
137   
138 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
139   void OnHelpSecondary (wxCommandEvent& event);
140 #endif
141
142   void OnCreateFilter (wxCommandEvent& event);
143   void OnExit (wxCommandEvent& event);
144   
145   void OnUpdateUI (wxUpdateUIEvent& event);
146   
147   void OnWindowMenu0 (wxCommandEvent& event);
148   void OnWindowMenu1 (wxCommandEvent& event);
149   void OnWindowMenu2 (wxCommandEvent& event);
150   void OnWindowMenu3 (wxCommandEvent& event);
151   void OnWindowMenu4 (wxCommandEvent& event);
152   void OnWindowMenu5 (wxCommandEvent& event);
153   void OnWindowMenu6 (wxCommandEvent& event);
154   void OnWindowMenu7 (wxCommandEvent& event);
155   void OnWindowMenu8 (wxCommandEvent& event);
156   void OnWindowMenu9 (wxCommandEvent& event);
157   void OnWindowMenu10 (wxCommandEvent& event);
158   void OnWindowMenu11 (wxCommandEvent& event);
159   void OnWindowMenu12 (wxCommandEvent& event);
160   void OnWindowMenu13 (wxCommandEvent& event);
161   void OnWindowMenu14 (wxCommandEvent& event);
162   void OnWindowMenu15 (wxCommandEvent& event);
163   void OnWindowMenu16 (wxCommandEvent& event);
164   void OnWindowMenu17 (wxCommandEvent& event);
165   void OnWindowMenu18 (wxCommandEvent& event);
166   void OnWindowMenu19 (wxCommandEvent& event);
167   
168   void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
169
170   bool getShuttingDown() const { return m_bShuttingDown; }
171 };
172
173
174 class wxDocManager;
175 class CTSimApp: public wxApp
176 {
177 private:
178   enum { O_HELP, O_VERSION };
179   static struct option ctsimOptions[];
180   
181   wxDocManager* m_docManager;
182   MainFrame* m_pFrame;
183   wxConfig* m_pConfig;
184   wxTextCtrl* m_pLog;
185   wxDocTemplate* m_pDocTemplImage;
186   wxDocTemplate* m_pDocTemplProjection;
187   wxDocTemplate* m_pDocTemplPhantom;
188   wxDocTemplate* m_pDocTemplPlot;
189   wxDocTemplate* m_pDocTemplText;
190 #if wxUSE_GLCANVAS
191   wxDocTemplate* m_pDocTemplGraph3d;
192 #endif
193   
194   TextFileDocument* m_pLogDoc;
195
196   void usage (const char* program);
197   
198 public:
199   CTSimApp();
200   bool OnInit();
201   int OnExit();
202   MainFrame* getMainFrame() const
203   { return m_pFrame; }
204
205   wxTextCtrl* getLog()
206   { return m_pLog; }
207
208   wxDocManager* getDocManager() 
209   { return m_docManager; }
210   
211   wxString getUntitledFilename();
212   
213   EZPlotDialog* makeEZPlotDialog()
214   { return new EZPlotDialog (m_pFrame); }
215   
216   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
217   
218   void setIconForFrame (wxFrame* pFrame);
219   wxConfig* getConfig()
220   { return m_pConfig; }
221
222   wxDocTemplate* getDocTemplImage() { return m_pDocTemplImage; }
223   wxDocTemplate* getDocTemplProjection() { return m_pDocTemplProjection; }
224   wxDocTemplate* getDocTemplPhantom() { return m_pDocTemplPhantom; }
225   wxDocTemplate* getDocTemplPlot() { return m_pDocTemplPlot; }
226   wxDocTemplate* getDocTemplText() { return m_pDocTemplText; }
227 #if wxUSE_GLCANVAS
228   wxDocTemplate* getDocTemplGraph3d() { return m_pDocTemplGraph3d; }
229 #endif
230   TextFileDocument* getLogDoc() { return m_pLogDoc; }
231
232   ProjectionFileDocument* newProjectionDoc();
233   ImageFileDocument* newImageDoc();
234   PhantomFileDocument* newPhantomDoc();
235   PlotFileDocument* newPlotDoc();
236   TextFileDocument* newTextDoc();
237 #if wxUSE_GLCANVAS
238   Graph3dFileDocument* newGraph3dDoc();
239 #endif
240 };
241
242 DECLARE_APP(CTSimApp)
243
244 extern class CTSimApp* theApp;
245
246 enum {
247     MAINMENU_WINDOW_BASE = 500,
248     MAINMENU_HELP_ABOUT = 600,
249     MAINMENU_HELP_CONTENTS,
250     MAINMENU_HELP_TOPICS,
251 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
252     MAINMENU_HELP_SECONDARY,
253 #endif
254     MAINMENU_FILE_CREATE_PHANTOM,
255     
256     MAINMENU_FILE_CREATE_FILTER,
257     MAINMENU_FILE_EXIT,
258     
259     PJMENU_FILE_PROPERTIES,
260     PJMENU_RECONSTRUCT_FBP,
261     PJMENU_RECONSTRUCT_FOURIER,
262     PJMENU_CONVERT_POLAR,
263     PJMENU_CONVERT_FFT_POLAR,
264     
265     IFMENU_FILE_EXPORT,
266     IFMENU_FILE_PROPERTIES,
267     
268     IFMENU_PLOT_ROW,
269     IFMENU_PLOT_COL,
270     IFMENU_PLOT_FFT_ROW,
271     IFMENU_PLOT_FFT_COL,
272     IFMENU_PLOT_HISTOGRAM,
273     
274     IFMENU_VIEW_SCALE_AUTO,
275     IFMENU_VIEW_SCALE_MINMAX,
276     IFMENU_VIEW_SCALE_FULL,
277     
278     IFMENU_COMPARE_IMAGES,
279     IFMENU_COMPARE_ROW,
280     IFMENU_COMPARE_COL,
281     IFMENU_IMAGE_SCALESIZE,
282     IFMENU_IMAGE_ADD,
283     IFMENU_IMAGE_SUBTRACT,
284     IFMENU_IMAGE_MULTIPLY,
285     IFMENU_IMAGE_DIVIDE,
286 #if wxUSE_GLCANVAS
287     IFMENU_IMAGE_CONVERT3D,
288 #endif
289
290     IFMENU_FILTER_INVERTVALUES,
291     IFMENU_FILTER_SQRT,
292     IFMENU_FILTER_SQUARE,
293     IFMENU_FILTER_LOG,
294     IFMENU_FILTER_EXP,
295     IFMENU_FILTER_FOURIER,
296     IFMENU_FILTER_INVERSE_FOURIER,
297     IFMENU_FILTER_FFT,
298     IFMENU_FILTER_IFFT,
299     IFMENU_FILTER_FFT_ROWS,
300     IFMENU_FILTER_FFT_COLS,
301     IFMENU_FILTER_IFFT_ROWS,
302     IFMENU_FILTER_IFFT_COLS,
303     IFMENU_FILTER_MAGNITUDE,
304     IFMENU_FILTER_PHASE,
305     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
306     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
307     
308     PHMMENU_FILE_PROPERTIES,
309     PHMMENU_PROCESS_RASTERIZE,
310     PHMMENU_PROCESS_PROJECTIONS,
311     
312     PLOTMENU_VIEW_SCALE_MINMAX,
313     PLOTMENU_VIEW_SCALE_AUTO,
314     PLOTMENU_VIEW_SCALE_FULL,    
315
316     GRAPH3D_VIEW_SURFACE,
317     GRAPH3D_VIEW_COLOR,
318     GRAPH3D_VIEW_LIGHTING,
319     GRAPH3D_VIEW_SMOOTH,
320     GRAPH3D_VIEW_SCALE_AUTO,
321     GRAPH3D_VIEW_SCALE_MINMAX,
322     GRAPH3D_VIEW_SCALE_FULL,
323 };
324
325 #endif