r427: Changes for MDI support
[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.29 2001/01/20 08:10:33 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 #if defined(CTSIM_MDI) && !wxUSE_MDI_ARCHITECTURE
43 #error You must set wxUSE_MDI_ARCHITECTURE to 1 in setup.h!
44 #endif
45 #ifdef CTSIM_MDI
46 #include "wx/docmdi.h"
47 #endif
48
49 class wxMenu;
50 class wxDocument;
51
52 class ImageFileDocument;
53
54 #include <vector>
55
56 #ifndef WX_PRECOMP
57 #include "wx/wx.h"
58 #endif
59
60 #include "wx/docview.h"
61 #include "wx/textctrl.h"
62 #include "wx/menu.h"
63 #include "wx/help.h"
64 #include "wx/html/helpctrl.h"
65 #include "dlgezplot.h"
66
67
68 #if defined(__WXMSW__)
69 #define CTSIM_WINHELP   1
70 #endif
71
72 // Define a new frame for main window
73 #if CTSIM_MDI
74 class MainFrame: public wxMDIParentFrame
75 #else
76 class MainFrame: public wxDocParentFrame
77 #endif
78 {
79   DECLARE_CLASS(MainFrame)
80 private:
81   wxTextCtrl* m_pLog;
82   wxMenu* m_pWindowMenu;
83   
84   enum { MAX_WINDOW_MENUITEMS = 20 };
85   wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
86   wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
87   
88   int m_iDefaultPhantomID;
89   int m_iDefaultFilterID;
90   int m_iDefaultFilterDomainID;
91   unsigned int m_iDefaultFilterXSize;    
92   unsigned int m_iDefaultFilterYSize;
93   double m_dDefaultFilterParam;
94   double m_dDefaultFilterBandwidth;
95   double m_dDefaultFilterInputScale;
96   double m_dDefaultFilterOutputScale;
97   
98 #if CTSIM_WINHELP
99   wxWinHelpController      m_winHelp;
100 #endif
101   wxHtmlHelpController     m_htmlHelp;
102   
103 public:
104   MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
105
106   void OnMRUFile (wxCommandEvent& event);
107
108   void OnSize (wxSizeEvent& event);
109
110 #if CTSIM_WINHELP
111   wxWinHelpController&   getWinHelpController()
112   {return m_winHelp; }
113 #endif
114   wxHtmlHelpController&  getHtmlHelpController()
115   { return m_htmlHelp; }
116
117   void showHelp (int commandID);
118
119   void OnAbout (wxCommandEvent& event);
120   void OnHelpTopics (wxCommandEvent& event);
121   void OnHelpContents (wxCommandEvent& event);
122   void OnCreatePhantom (wxCommandEvent& event);
123   
124 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
125   void OnHelpSecondary (wxCommandEvent& event);
126 #endif
127
128   void OnCreateFilter (wxCommandEvent& event);
129   void OnExit (wxCommandEvent& event);
130   
131   void OnUpdateUI (wxUpdateUIEvent& event);
132   
133   wxTextCtrl* getLog() 
134   { return m_pLog; }
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 public:
167   CTSimApp();
168   bool OnInit();
169   int OnExit();
170   MainFrame* getMainFrame() const
171   { return m_pFrame; }
172
173   wxTextCtrl* getLog()
174   { return m_pFrame->getLog(); }
175
176   wxDocManager* getDocManager() 
177   { return m_docManager; }
178   
179   wxString getUntitledFilename();
180   
181   EZPlotDialog* makeEZPlotDialog()
182   { return new EZPlotDialog (m_pFrame); }
183   
184   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
185   
186   bool getSetModifyNewDocs() const
187   { return true; }
188   
189   void setIconForFrame (wxFrame* pFrame);
190
191 private:
192   wxDocManager* m_docManager;
193   MainFrame* m_pFrame;
194   
195   void usage (const char* program);
196   
197   static struct option ctsimOptions[];
198   
199   enum { O_HELP, O_VERSION };
200 };
201
202 DECLARE_APP(CTSimApp)
203
204 extern class CTSimApp* theApp;
205
206 enum {
207     MAINMENU_WINDOW_BASE = 500,
208     MAINMENU_HELP_ABOUT = 600,
209     MAINMENU_HELP_CONTENTS,
210     MAINMENU_HELP_TOPICS,
211     MAINMENU_HELP_SECONDARY,
212     MAINMENU_FILE_CREATE_PHANTOM,
213     
214     MAINMENU_FILE_CREATE_FILTER,
215     MAINMENU_FILE_EXIT,
216     
217     PJMENU_FILE_PROPERTIES,
218     PJMENU_RECONSTRUCT_FBP,
219     PJMENU_RECONSTRUCT_FOURIER,
220     PJMENU_CONVERT_POLAR,
221     PJMENU_CONVERT_FFT_POLAR,
222     
223     IFMENU_FILE_EXPORT,
224     IFMENU_FILE_PROPERTIES,
225     
226     IFMENU_PLOT_ROW,
227     IFMENU_PLOT_COL,
228     IFMENU_PLOT_FFT_ROW,
229     IFMENU_PLOT_FFT_COL,
230     IFMENU_PLOT_HISTOGRAM,
231     
232     IFMENU_VIEW_SCALE_AUTO,
233     IFMENU_VIEW_SCALE_MINMAX,
234     IFMENU_VIEW_SCALE_FULL,
235     
236     IFMENU_COMPARE_IMAGES,
237     IFMENU_COMPARE_ROW,
238     IFMENU_COMPARE_COL,
239     IFMENU_IMAGE_SCALESIZE,
240     IFMENU_IMAGE_ADD,
241     IFMENU_IMAGE_SUBTRACT,
242     IFMENU_IMAGE_MULTIPLY,
243     IFMENU_IMAGE_DIVIDE,
244     
245     IFMENU_FILTER_INVERTVALUES,
246     IFMENU_FILTER_SQRT,
247     IFMENU_FILTER_SQUARE,
248     IFMENU_FILTER_LOG,
249     IFMENU_FILTER_EXP,
250     IFMENU_FILTER_FOURIER,
251     IFMENU_FILTER_INVERSE_FOURIER,
252     IFMENU_FILTER_FFT,
253     IFMENU_FILTER_IFFT,
254     IFMENU_FILTER_FFT_ROWS,
255     IFMENU_FILTER_FFT_COLS,
256     IFMENU_FILTER_IFFT_ROWS,
257     IFMENU_FILTER_IFFT_COLS,
258     IFMENU_FILTER_MAGNITUDE,
259     IFMENU_FILTER_PHASE,
260     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
261     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
262     
263     PHMMENU_FILE_PROPERTIES,
264     PHMMENU_PROCESS_RASTERIZE,
265     PHMMENU_PROCESS_PROJECTIONS,
266     
267     PLOTMENU_VIEW_SCALE_MINMAX,
268     PLOTMENU_VIEW_SCALE_AUTO,
269     PLOTMENU_VIEW_SCALE_FULL,    
270 };
271
272 #endif