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