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