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