r571: no message
[ctsim.git] / src / ctsim.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          ctsim.h
5 **   Purpose:       Header file for CTSim
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.51 2001/02/22 11:05:38 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 #ifdef __WXMSW__
43 #include "wx/msw/helpchm.h"
44 #endif
45
46 #ifdef MSVC
47 #define CTSIM_MDI 1
48 #endif
49 #define CTSIM_CUSTOM_MRU 1
50
51 #if defined(CTSIM_MDI) && !wxUSE_MDI_ARCHITECTURE
52 #error You must set wxUSE_MDI_ARCHITECTURE to 1 in setup.h!
53 #endif
54 #ifdef CTSIM_MDI
55 #include "wx/docmdi.h"
56 #endif
57
58 class wxMenu;
59 class wxDocument;
60 class ImageFileDocument;
61 class ProjectionFileDocument;
62 class PhantomFileDocument;
63 class PlotFileDocument;
64 class TextFileDocument;
65 #if wxUSE_GLCANVAS
66 class Graph3dFileDocument;
67 #endif
68
69 #include <vector>
70 #include "wx/docview.h"
71 #include "wx/textctrl.h"
72 #include "wx/menu.h"
73 #include "wx/help.h"
74 #include "wx/html/helpctrl.h"
75 #include "dlgezplot.h"
76 #include "ctsim-map.h"
77
78
79 #if defined(__WXMSW__) || defined (MSVC)
80 #define CTSIM_WINHELP   1
81 #endif
82
83 // Define a new frame for main window
84 #if CTSIM_MDI
85 class MainFrame: public wxDocMDIParentFrame
86 #else
87 class MainFrame: public wxDocParentFrame
88 #endif
89 {
90 private:
91   DECLARE_CLASS(MainFrame)
92   DECLARE_EVENT_TABLE()
93
94 #ifndef CTSIM_MDI
95   wxMenu* m_pWindowMenu;
96 #endif
97
98   enum { MAX_WINDOW_MENUITEMS = 20 };
99   wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
100   wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
101   
102   int m_iDefaultPhantomID;
103   int m_iDefaultFilterID;
104   int m_iDefaultFilterDomainID;
105   unsigned int m_iDefaultFilterXSize;    
106   unsigned int m_iDefaultFilterYSize;
107   double m_dDefaultFilterParam;
108   double m_dDefaultFilterBandwidth;
109   double m_dDefaultFilterInputScale;
110   double m_dDefaultFilterOutputScale;
111
112   bool m_bShuttingDown;
113
114 #if CTSIM_WINHELP
115   wxCHMHelpController      m_winHelp;
116 #endif
117   wxHtmlHelpController     m_htmlHelp;
118   
119 public:
120   MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
121   virtual ~MainFrame();
122
123 #ifdef CTSIM_CUSTOM_MRU
124   void OnMRUFile (wxCommandEvent& event);
125 #endif
126   void OnSize (wxSizeEvent& event);
127
128 #if CTSIM_WINHELP
129   wxCHMHelpController&   getWinHelpController()
130   {return m_winHelp; }
131 #endif
132   wxHtmlHelpController&  getHtmlHelpController()
133   { return m_htmlHelp; }
134
135   void showHelp (int commandID);
136
137   void OnAbout (wxCommandEvent& event);
138   void OnHelpContents (wxCommandEvent& event);
139   void OnHelpTips (wxCommandEvent& event);
140   void OnCreatePhantom (wxCommandEvent& event);
141   void OnPreferences (wxCommandEvent& event);
142   void OnLogEvent (wxCommandEvent& event);  // used by thread children
143
144   void OnHelpButton (wxCommandEvent& event);
145
146 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
147   void OnHelpSecondary (wxCommandEvent& event);
148 #endif
149
150   void OnCreateFilter (wxCommandEvent& event);
151   void OnExit (wxCommandEvent& event);
152   
153   void OnUpdateUI (wxUpdateUIEvent& event);
154   
155   void OnWindowMenu0 (wxCommandEvent& event);
156   void OnWindowMenu1 (wxCommandEvent& event);
157   void OnWindowMenu2 (wxCommandEvent& event);
158   void OnWindowMenu3 (wxCommandEvent& event);
159   void OnWindowMenu4 (wxCommandEvent& event);
160   void OnWindowMenu5 (wxCommandEvent& event);
161   void OnWindowMenu6 (wxCommandEvent& event);
162   void OnWindowMenu7 (wxCommandEvent& event);
163   void OnWindowMenu8 (wxCommandEvent& event);
164   void OnWindowMenu9 (wxCommandEvent& event);
165   void OnWindowMenu10 (wxCommandEvent& event);
166   void OnWindowMenu11 (wxCommandEvent& event);
167   void OnWindowMenu12 (wxCommandEvent& event);
168   void OnWindowMenu13 (wxCommandEvent& event);
169   void OnWindowMenu14 (wxCommandEvent& event);
170   void OnWindowMenu15 (wxCommandEvent& event);
171   void OnWindowMenu16 (wxCommandEvent& event);
172   void OnWindowMenu17 (wxCommandEvent& event);
173   void OnWindowMenu18 (wxCommandEvent& event);
174   void OnWindowMenu19 (wxCommandEvent& event);
175   
176   void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
177
178   bool getShuttingDown() const { return m_bShuttingDown; }
179 };
180
181
182 class wxDocManager;
183 class CTSimApp: public wxApp
184 {
185 private:
186   enum { O_HELP, O_PRINT, O_VERSION };
187   static struct option ctsimOptions[];
188
189   bool m_bAdvancedOptions;
190   bool m_bSetModifyNewDocs;
191   bool m_bVerboseLogging;
192   bool m_bShowStartupTips;
193   long m_iCurrentTip;
194
195   wxDocManager* m_docManager;
196   MainFrame* m_pFrame;
197   wxConfig* m_pConfig;
198   wxTextCtrl* m_pLog;
199   wxDocTemplate* m_pDocTemplImage;
200   wxDocTemplate* m_pDocTemplProjection;
201   wxDocTemplate* m_pDocTemplPhantom;
202   wxDocTemplate* m_pDocTemplPlot;
203   wxDocTemplate* m_pDocTemplText;
204 #if wxUSE_GLCANVAS
205   wxDocTemplate* m_pDocTemplGraph3d;
206 #endif
207   
208   TextFileDocument* m_pLogDoc;
209
210   void usage (const char* program);
211   void openConfig();
212   void closeConfig();
213
214 public:
215   CTSimApp();
216   bool OnInit();
217   int OnExit();
218   MainFrame* getMainFrame() const
219   { return m_pFrame; }
220
221   wxTextCtrl* getLog()
222   { return m_pLog; }
223
224   wxDocManager* getDocManager() 
225   { return m_docManager; }
226   
227   wxString getUntitledFilename();
228
229   int getNumberCPU() const { return wxThread::GetCPUCount(); }
230
231   EZPlotDialog* makeEZPlotDialog()
232   { return new EZPlotDialog (m_pFrame); }
233   
234   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
235   bool getAdvancedOptions() const { return m_bAdvancedOptions; }
236   void setAdvancedOptions (bool bAdv) { m_bAdvancedOptions = bAdv; }
237   bool getVerboseLogging() const { return m_bVerboseLogging; }
238   void setVerboseLogging (bool bVerbose) { m_bVerboseLogging = bVerbose; }
239   bool getStartupTips() const { return m_bShowStartupTips; }
240   void setStartupTips(bool bTips) { m_bShowStartupTips = bTips; }
241
242   void ShowTips();
243
244   void setIconForFrame (wxFrame* pFrame);
245   wxConfig* getConfig()
246   { return m_pConfig; }
247   bool getAskDeleteNewDocs() const { return m_bSetModifyNewDocs; }
248   void setAskDeleteNewDocs(bool bAsk) { m_bSetModifyNewDocs = bAsk; }
249
250   wxDocTemplate* getDocTemplImage() { return m_pDocTemplImage; }
251   wxDocTemplate* getDocTemplProjection() { return m_pDocTemplProjection; }
252   wxDocTemplate* getDocTemplPhantom() { return m_pDocTemplPhantom; }
253   wxDocTemplate* getDocTemplPlot() { return m_pDocTemplPlot; }
254   wxDocTemplate* getDocTemplText() { return m_pDocTemplText; }
255 #if wxUSE_GLCANVAS
256   wxDocTemplate* getDocTemplGraph3d() { return m_pDocTemplGraph3d; }
257 #endif
258   TextFileDocument* getLogDoc() { return m_pLogDoc; }
259
260   ProjectionFileDocument* newProjectionDoc();
261   ImageFileDocument* newImageDoc();
262   PhantomFileDocument* newPhantomDoc();
263   PlotFileDocument* newPlotDoc();
264   TextFileDocument* newTextDoc();
265 #if wxUSE_GLCANVAS
266   Graph3dFileDocument* newGraph3dDoc();
267 #endif
268 };
269
270 DECLARE_APP(CTSimApp)
271
272 extern class CTSimApp* theApp;
273
274 enum {
275     MAINMENU_WINDOW_BASE = 500,
276     MAINMENU_HELP_ABOUT = 600,
277     MAINMENU_HELP_CONTENTS,
278     MAINMENU_HELP_TIPS,
279 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
280     MAINMENU_HELP_SECONDARY,
281 #endif
282     MAINMENU_FILE_CREATE_PHANTOM,
283     MAINMENU_FILE_CREATE_FILTER,
284     MAINMENU_FILE_EXIT,
285     MAINMENU_FILE_PREFERENCES,
286     MAINMENU_LOG_EVENT,
287         
288     PJMENU_FILE_PROPERTIES,
289     PJMENU_RECONSTRUCT_FBP,
290     PJMENU_RECONSTRUCT_FOURIER,
291     PJMENU_CONVERT_POLAR,
292     PJMENU_CONVERT_FFT_POLAR,
293     
294     IFMENU_FILE_EXPORT,
295     IFMENU_FILE_PROPERTIES,
296     
297     IFMENU_PLOT_ROW,
298     IFMENU_PLOT_COL,
299     IFMENU_PLOT_FFT_ROW,
300     IFMENU_PLOT_FFT_COL,
301     IFMENU_PLOT_HISTOGRAM,
302     
303     IFMENU_VIEW_SCALE_AUTO,
304     IFMENU_VIEW_SCALE_MINMAX,
305     IFMENU_VIEW_SCALE_FULL,
306     
307     IFMENU_COMPARE_IMAGES,
308     IFMENU_COMPARE_ROW,
309     IFMENU_COMPARE_COL,
310     IFMENU_IMAGE_SCALESIZE,
311     IFMENU_IMAGE_ADD,
312     IFMENU_IMAGE_SUBTRACT,
313     IFMENU_IMAGE_MULTIPLY,
314     IFMENU_IMAGE_DIVIDE,
315 #if wxUSE_GLCANVAS
316     IFMENU_IMAGE_CONVERT3D,
317 #endif
318
319     IFMENU_FILTER_INVERTVALUES,
320     IFMENU_FILTER_SQRT,
321     IFMENU_FILTER_SQUARE,
322     IFMENU_FILTER_LOG,
323     IFMENU_FILTER_EXP,
324     IFMENU_FILTER_FOURIER,
325     IFMENU_FILTER_INVERSE_FOURIER,
326     IFMENU_FILTER_FFT,
327     IFMENU_FILTER_IFFT,
328     IFMENU_FILTER_FFT_ROWS,
329     IFMENU_FILTER_FFT_COLS,
330     IFMENU_FILTER_IFFT_ROWS,
331     IFMENU_FILTER_IFFT_COLS,
332     IFMENU_FILTER_MAGNITUDE,
333     IFMENU_FILTER_PHASE,
334     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
335     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
336     
337     PHMMENU_FILE_PROPERTIES,
338     PHMMENU_PROCESS_RASTERIZE,
339     PHMMENU_PROCESS_PROJECTIONS,
340
341     PLOTMENU_FILE_PROPERTIES,
342     PLOTMENU_VIEW_SCALE_MINMAX,
343     PLOTMENU_VIEW_SCALE_AUTO,
344     PLOTMENU_VIEW_SCALE_FULL,    
345
346     GRAPH3D_VIEW_SURFACE,
347     GRAPH3D_VIEW_COLOR,
348     GRAPH3D_VIEW_LIGHTING,
349     GRAPH3D_VIEW_SMOOTH,
350     GRAPH3D_VIEW_SCALE_AUTO,
351     GRAPH3D_VIEW_SCALE_MINMAX,
352     GRAPH3D_VIEW_SCALE_FULL,
353
354     RECONSTRUCTION_THREAD_EVENT,
355 };
356
357 #endif