r428: 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-2000 Kevin Rosenberg
11 **
12 **  $Id: ctsim.h,v 1.30 2001/01/20 17:43: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
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
58 class ImageFileDocument;
59
60 #include <vector>
61
62 #include "wx/docview.h"
63 #include "wx/textctrl.h"
64 #include "wx/menu.h"
65 #include "wx/help.h"
66 #include "wx/html/helpctrl.h"
67 #include "dlgezplot.h"
68
69
70 #if defined(__WXMSW__)
71 #define CTSIM_WINHELP   1
72 #endif
73
74 // Define a new frame for main window
75 #if CTSIM_MDI
76 class MainFrame: public wxDocMDIParentFrame
77 #else
78 class MainFrame: public wxDocParentFrame
79 #endif
80 {
81   DECLARE_CLASS(MainFrame)
82 private:
83   wxMenu* m_pWindowMenu;
84   
85   enum { MAX_WINDOW_MENUITEMS = 20 };
86   wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
87   wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
88   
89   int m_iDefaultPhantomID;
90   int m_iDefaultFilterID;
91   int m_iDefaultFilterDomainID;
92   unsigned int m_iDefaultFilterXSize;    
93   unsigned int m_iDefaultFilterYSize;
94   double m_dDefaultFilterParam;
95   double m_dDefaultFilterBandwidth;
96   double m_dDefaultFilterInputScale;
97   double m_dDefaultFilterOutputScale;
98   
99 #if CTSIM_WINHELP
100   wxWinHelpController      m_winHelp;
101 #endif
102   wxHtmlHelpController     m_htmlHelp;
103   
104 public:
105   MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
106   ~MainFrame();
107
108 #ifdef CTSIM_CUSTOM_MRU
109   void OnMRUFile (wxCommandEvent& event);
110 #endif
111   void OnSize (wxSizeEvent& event);
112
113 #if CTSIM_WINHELP
114   wxWinHelpController&   getWinHelpController()
115   {return m_winHelp; }
116 #endif
117   wxHtmlHelpController&  getHtmlHelpController()
118   { return m_htmlHelp; }
119
120   void showHelp (int commandID);
121
122   void OnAbout (wxCommandEvent& event);
123   void OnHelpTopics (wxCommandEvent& event);
124   void OnHelpContents (wxCommandEvent& event);
125   void OnCreatePhantom (wxCommandEvent& event);
126   
127 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
128   void OnHelpSecondary (wxCommandEvent& event);
129 #endif
130
131   void OnCreateFilter (wxCommandEvent& event);
132   void OnExit (wxCommandEvent& event);
133   
134   void OnUpdateUI (wxUpdateUIEvent& event);
135   
136   void OnWindowMenu0 (wxCommandEvent& event);
137   void OnWindowMenu1 (wxCommandEvent& event);
138   void OnWindowMenu2 (wxCommandEvent& event);
139   void OnWindowMenu3 (wxCommandEvent& event);
140   void OnWindowMenu4 (wxCommandEvent& event);
141   void OnWindowMenu5 (wxCommandEvent& event);
142   void OnWindowMenu6 (wxCommandEvent& event);
143   void OnWindowMenu7 (wxCommandEvent& event);
144   void OnWindowMenu8 (wxCommandEvent& event);
145   void OnWindowMenu9 (wxCommandEvent& event);
146   void OnWindowMenu10 (wxCommandEvent& event);
147   void OnWindowMenu11 (wxCommandEvent& event);
148   void OnWindowMenu12 (wxCommandEvent& event);
149   void OnWindowMenu13 (wxCommandEvent& event);
150   void OnWindowMenu14 (wxCommandEvent& event);
151   void OnWindowMenu15 (wxCommandEvent& event);
152   void OnWindowMenu16 (wxCommandEvent& event);
153   void OnWindowMenu17 (wxCommandEvent& event);
154   void OnWindowMenu18 (wxCommandEvent& event);
155   void OnWindowMenu19 (wxCommandEvent& event);
156   
157   void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
158   
159   DECLARE_EVENT_TABLE()
160 };
161
162
163 class wxDocManager;
164 class CTSimApp: public wxApp
165 {
166 private:
167   wxDocManager* m_docManager;
168   MainFrame* m_pFrame;
169   wxConfig* m_pConfig;
170   
171   void usage (const char* program);
172   
173   static struct option ctsimOptions[];
174   
175   enum { O_HELP, O_VERSION };
176   wxTextCtrl* m_pLog;
177
178 public:
179   CTSimApp();
180   bool OnInit();
181   int OnExit();
182   MainFrame* getMainFrame() const
183   { return m_pFrame; }
184
185   wxTextCtrl* getLog()
186   { return m_pLog; }
187
188   wxDocManager* getDocManager() 
189   { return m_docManager; }
190   
191   wxString getUntitledFilename();
192   
193   EZPlotDialog* makeEZPlotDialog()
194   { return new EZPlotDialog (m_pFrame); }
195   
196   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
197   
198   bool getSetModifyNewDocs() const
199   { return true; }
200   
201   void setIconForFrame (wxFrame* pFrame);
202   wxConfig* getConfig()
203   { return m_pConfig; }
204 };
205
206 DECLARE_APP(CTSimApp)
207
208 extern class CTSimApp* theApp;
209
210 enum {
211     MAINMENU_WINDOW_BASE = 500,
212     MAINMENU_HELP_ABOUT = 600,
213     MAINMENU_HELP_CONTENTS,
214     MAINMENU_HELP_TOPICS,
215     MAINMENU_HELP_SECONDARY,
216     MAINMENU_FILE_CREATE_PHANTOM,
217     
218     MAINMENU_FILE_CREATE_FILTER,
219     MAINMENU_FILE_EXIT,
220     
221     PJMENU_FILE_PROPERTIES,
222     PJMENU_RECONSTRUCT_FBP,
223     PJMENU_RECONSTRUCT_FOURIER,
224     PJMENU_CONVERT_POLAR,
225     PJMENU_CONVERT_FFT_POLAR,
226     
227     IFMENU_FILE_EXPORT,
228     IFMENU_FILE_PROPERTIES,
229     
230     IFMENU_PLOT_ROW,
231     IFMENU_PLOT_COL,
232     IFMENU_PLOT_FFT_ROW,
233     IFMENU_PLOT_FFT_COL,
234     IFMENU_PLOT_HISTOGRAM,
235     
236     IFMENU_VIEW_SCALE_AUTO,
237     IFMENU_VIEW_SCALE_MINMAX,
238     IFMENU_VIEW_SCALE_FULL,
239     
240     IFMENU_COMPARE_IMAGES,
241     IFMENU_COMPARE_ROW,
242     IFMENU_COMPARE_COL,
243     IFMENU_IMAGE_SCALESIZE,
244     IFMENU_IMAGE_ADD,
245     IFMENU_IMAGE_SUBTRACT,
246     IFMENU_IMAGE_MULTIPLY,
247     IFMENU_IMAGE_DIVIDE,
248     
249     IFMENU_FILTER_INVERTVALUES,
250     IFMENU_FILTER_SQRT,
251     IFMENU_FILTER_SQUARE,
252     IFMENU_FILTER_LOG,
253     IFMENU_FILTER_EXP,
254     IFMENU_FILTER_FOURIER,
255     IFMENU_FILTER_INVERSE_FOURIER,
256     IFMENU_FILTER_FFT,
257     IFMENU_FILTER_IFFT,
258     IFMENU_FILTER_FFT_ROWS,
259     IFMENU_FILTER_FFT_COLS,
260     IFMENU_FILTER_IFFT_ROWS,
261     IFMENU_FILTER_IFFT_COLS,
262     IFMENU_FILTER_MAGNITUDE,
263     IFMENU_FILTER_PHASE,
264     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
265     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
266     
267     PHMMENU_FILE_PROPERTIES,
268     PHMMENU_PROCESS_RASTERIZE,
269     PHMMENU_PROCESS_PROJECTIONS,
270     
271     PLOTMENU_VIEW_SCALE_MINMAX,
272     PLOTMENU_VIEW_SCALE_AUTO,
273     PLOTMENU_VIEW_SCALE_FULL,    
274 };
275
276 #endif