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