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