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