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