f2d70bb92603997b9ae9c6ca84d0e10dfc162cfa
[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.63 2001/09/24 11:20:08 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
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   void OnSize (wxSizeEvent& event);
133
134 #if CTSIM_WINHELP
135   wxCHMHelpController&   getWinHelpController()
136   {return m_winHelp; }
137 #endif
138   wxHtmlHelpController&  getHtmlHelpController()
139   { return m_htmlHelp; }
140
141   void showHelp (int commandID);
142
143   void OnAbout (wxCommandEvent& event);
144   void OnHelpContents (wxCommandEvent& event);
145   void OnHelpTips (wxCommandEvent& event);
146   void OnCreatePhantom (wxCommandEvent& event);
147   void OnPreferences (wxCommandEvent& event);
148   void OnLogEvent (wxCommandEvent& event);  // used by thread children
149   void OnNewImageFile (wxCommandEvent& event);
150   void OnNewProjectionFile (wxCommandEvent& event);
151
152   void OnHelpButton (wxCommandEvent& event);
153   void OnImport (wxCommandEvent& event);
154
155 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
156   void OnHelpSecondary (wxCommandEvent& event);
157 #endif
158
159   void OnCreateFilter (wxCommandEvent& event);
160   void OnExit (wxCommandEvent& event);
161   
162   void OnUpdateUI (wxUpdateUIEvent& event);
163   
164   void OnWindowMenu0 (wxCommandEvent& event);
165   void OnWindowMenu1 (wxCommandEvent& event);
166   void OnWindowMenu2 (wxCommandEvent& event);
167   void OnWindowMenu3 (wxCommandEvent& event);
168   void OnWindowMenu4 (wxCommandEvent& event);
169   void OnWindowMenu5 (wxCommandEvent& event);
170   void OnWindowMenu6 (wxCommandEvent& event);
171   void OnWindowMenu7 (wxCommandEvent& event);
172   void OnWindowMenu8 (wxCommandEvent& event);
173   void OnWindowMenu9 (wxCommandEvent& event);
174   void OnWindowMenu10 (wxCommandEvent& event);
175   void OnWindowMenu11 (wxCommandEvent& event);
176   void OnWindowMenu12 (wxCommandEvent& event);
177   void OnWindowMenu13 (wxCommandEvent& event);
178   void OnWindowMenu14 (wxCommandEvent& event);
179   void OnWindowMenu15 (wxCommandEvent& event);
180   void OnWindowMenu16 (wxCommandEvent& event);
181   void OnWindowMenu17 (wxCommandEvent& event);
182   void OnWindowMenu18 (wxCommandEvent& event);
183   void OnWindowMenu19 (wxCommandEvent& event);
184   
185   void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
186
187   bool getShuttingDown() const { return m_bShuttingDown; }
188 };
189
190
191 class wxDocManager;
192 class CTSimApp: public wxApp
193 {
194 private:
195   enum { O_HELP, O_PRINT, O_VERSION };
196   static struct option ctsimOptions[];
197
198   bool m_bAdvancedOptions;
199   bool m_bSetModifyNewDocs;
200   bool m_bVerboseLogging;
201   bool m_bShowStartupTips;
202   long m_iCurrentTip;
203   bool m_bUseBackgroundTasks;
204
205   wxDocManager* m_docManager;
206   MainFrame* m_pFrame;
207   wxConfig* m_pConfig;
208   wxTextCtrl* m_pLog;
209   TextFileDocument* m_pLogDoc;
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   void usage (const char* program);
220   void openConfig();
221   void closeConfig();
222   BackgroundManager*  m_pBackgroundMgr;
223
224 public:
225   CTSimApp();
226   bool OnInit();
227   int OnExit();
228   MainFrame* getMainFrame() const
229   { return m_pFrame; }
230
231   wxTextCtrl* getLog()
232   { return m_pLog; }
233
234   wxDocManager* getDocManager() 
235   { return m_docManager; }
236   
237   wxString getUntitledFilename();
238
239   int getNumberCPU() const { return wxThread::GetCPUCount(); }
240
241   EZPlotDialog* makeEZPlotDialog()
242   { return new EZPlotDialog (m_pFrame); }
243   
244   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
245   bool getAdvancedOptions() const { return m_bAdvancedOptions; }
246   void setAdvancedOptions (bool bAdv) { m_bAdvancedOptions = bAdv; }
247   bool getVerboseLogging() const { return m_bVerboseLogging; }
248   void setVerboseLogging (bool bVerbose) { m_bVerboseLogging = bVerbose; }
249   bool getStartupTips() const { return m_bShowStartupTips; }
250   void setStartupTips(bool bTips) { m_bShowStartupTips = bTips; }
251   bool getUseBackgroundTasks() const { return m_bUseBackgroundTasks; }
252   void setUseBackgroundTasks(bool bBkgd) { m_bUseBackgroundTasks = bBkgd; }
253
254   BackgroundManager* getBackgroundManager() {return m_pBackgroundMgr;}
255
256   void ShowTips();
257
258   void setIconForFrame (wxFrame* pFrame);
259   wxConfig* getConfig()
260   { return m_pConfig; }
261   bool getAskDeleteNewDocs() const { return m_bSetModifyNewDocs; }
262   void setAskDeleteNewDocs(bool bAsk) { m_bSetModifyNewDocs = bAsk; }
263
264   wxDocTemplate* getDocTemplImage() { return m_pDocTemplImage; }
265   wxDocTemplate* getDocTemplProjection() { return m_pDocTemplProjection; }
266   wxDocTemplate* getDocTemplPhantom() { return m_pDocTemplPhantom; }
267   wxDocTemplate* getDocTemplPlot() { return m_pDocTemplPlot; }
268   wxDocTemplate* getDocTemplText() { return m_pDocTemplText; }
269 #if wxUSE_GLCANVAS
270   wxDocTemplate* getDocTemplGraph3d() { return m_pDocTemplGraph3d; }
271 #endif
272   TextFileDocument* getLogDoc() { return m_pLogDoc; }
273
274   ProjectionFileDocument* newProjectionDoc();
275   ImageFileDocument* newImageDoc();
276   PhantomFileDocument* newPhantomDoc();
277   PlotFileDocument* newPlotDoc();
278   TextFileDocument* newTextDoc();
279 #if wxUSE_GLCANVAS
280   Graph3dFileDocument* newGraph3dDoc();
281 #endif
282 };
283
284 DECLARE_APP(CTSimApp)
285
286 extern class CTSimApp* theApp;
287
288 enum {
289     MAINMENU_WINDOW_BASE = 500,
290     MAINMENU_HELP_ABOUT = 600,
291     MAINMENU_HELP_CONTENTS,
292     MAINMENU_HELP_TIPS,
293 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
294     MAINMENU_HELP_SECONDARY,
295 #endif
296     MAINMENU_FILE_CREATE_PHANTOM,
297     MAINMENU_FILE_CREATE_FILTER,
298     MAINMENU_FILE_EXIT,
299     MAINMENU_FILE_PREFERENCES,
300     MAINMENU_LOG_EVENT,
301     MAINMENU_IMPORT,
302     
303     PJMENU_FILE_PROPERTIES,
304     PJMENU_RECONSTRUCT_FBP,
305     PJMENU_RECONSTRUCT_FBP_REBIN,
306     PJMENU_RECONSTRUCT_FOURIER,
307     PJMENU_CONVERT_RECTANGULAR,
308     PJMENU_CONVERT_POLAR,
309     PJMENU_CONVERT_FFT_POLAR,
310     PJMENU_CONVERT_PARALLEL,
311     PJMENU_PLOT_TTHETA_SAMPLING,
312     PJMENU_PLOT_HISTOGRAM,
313     PJMENU_ARTIFACT_REDUCTION,
314     
315     IFMENU_FILE_EXPORT,
316     IFMENU_FILE_PROPERTIES,
317
318     IFMENU_EDIT_COPY,
319     IFMENU_EDIT_CUT,
320     IFMENU_EDIT_PASTE,
321
322     IFMENU_PLOT_ROW,
323     IFMENU_PLOT_COL,
324     IFMENU_PLOT_FFT_ROW,
325     IFMENU_PLOT_FFT_COL,
326     IFMENU_PLOT_HISTOGRAM,
327     
328     IFMENU_VIEW_SCALE_AUTO,
329     IFMENU_VIEW_SCALE_MINMAX,
330     IFMENU_VIEW_SCALE_FULL,
331     
332     IFMENU_COMPARE_IMAGES,
333     IFMENU_COMPARE_ROW,
334     IFMENU_COMPARE_COL,
335     IFMENU_IMAGE_SCALESIZE,
336     IFMENU_IMAGE_ADD,
337     IFMENU_IMAGE_SUBTRACT,
338     IFMENU_IMAGE_MULTIPLY,
339     IFMENU_IMAGE_DIVIDE,
340 #ifdef wxUSE_GLCANVAS
341     IFMENU_IMAGE_CONVERT3D,
342 #endif
343
344     IFMENU_FILTER_INVERTVALUES,
345     IFMENU_FILTER_SQRT,
346     IFMENU_FILTER_SQUARE,
347     IFMENU_FILTER_LOG,
348     IFMENU_FILTER_EXP,
349     IFMENU_FILTER_FOURIER,
350     IFMENU_FILTER_INVERSE_FOURIER,
351     IFMENU_FILTER_FFT,
352     IFMENU_FILTER_IFFT,
353     IFMENU_FILTER_FFT_ROWS,
354     IFMENU_FILTER_FFT_COLS,
355     IFMENU_FILTER_IFFT_ROWS,
356     IFMENU_FILTER_IFFT_COLS,
357     IFMENU_FILTER_MAGNITUDE,
358     IFMENU_FILTER_PHASE,
359     IFMENU_FILTER_REAL,
360     IFMENU_FILTER_IMAGINARY,
361     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
362     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
363     
364     PHMMENU_FILE_PROPERTIES,
365     PHMMENU_PROCESS_RASTERIZE,
366     PHMMENU_PROCESS_PROJECTIONS,
367
368     PLOTMENU_FILE_PROPERTIES,
369     PLOTMENU_VIEW_SCALE_MINMAX,
370     PLOTMENU_VIEW_SCALE_AUTO,
371     PLOTMENU_VIEW_SCALE_FULL,    
372
373     GRAPH3D_VIEW_WIREFRAME,
374     GRAPH3D_VIEW_COLOR,
375     GRAPH3D_VIEW_LIGHTING,
376     GRAPH3D_VIEW_SMOOTH,
377     GRAPH3D_VIEW_SCALE_AUTO,
378     GRAPH3D_VIEW_SCALE_MINMAX,
379     GRAPH3D_VIEW_SCALE_FULL,
380
381     RECONSTRUCTION_THREAD_EVENT,
382     NEW_IMAGEFILE_EVENT,
383     NEW_PROJECTIONFILE_EVENT,
384 };
385
386 #endif