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