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