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