1 /*****************************************************************************
5 ** Purpose: Header file for CTSim
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 2000
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: ctsim.h,v 1.54 2001/03/02 21:11:50 kevin Exp $
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.
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.
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 ******************************************************************************/
39 #define HAVE_WXTHREADS 1
47 #include "wx/config.h"
49 #include "wx/msw/helpchm.h"
55 #define CTSIM_CUSTOM_MRU 1
57 #if defined(CTSIM_MDI) && !wxUSE_MDI_ARCHITECTURE
58 #error You must set wxUSE_MDI_ARCHITECTURE to 1 in setup.h!
61 #include "wx/docmdi.h"
66 class ImageFileDocument;
67 class ProjectionFileDocument;
68 class PhantomFileDocument;
69 class PlotFileDocument;
70 class TextFileDocument;
71 class BackgroundManager;
74 class Graph3dFileDocument;
78 #include "wx/docview.h"
79 #include "wx/textctrl.h"
82 #include "wx/html/helpctrl.h"
83 #include "dlgezplot.h"
84 #include "ctsim-map.h"
87 #if defined(__WXMSW__) || defined (MSVC)
88 #define CTSIM_WINHELP 1
91 // Define a new frame for main window
93 class MainFrame: public wxDocMDIParentFrame
95 class MainFrame: public wxDocParentFrame
99 DECLARE_CLASS(MainFrame)
100 DECLARE_EVENT_TABLE()
103 wxMenu* m_pWindowMenu;
106 enum { MAX_WINDOW_MENUITEMS = 20 };
107 wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
108 wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
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;
121 bool m_bShuttingDown;
124 wxCHMHelpController m_winHelp;
126 wxHtmlHelpController m_htmlHelp;
129 MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
130 virtual ~MainFrame();
132 #ifdef CTSIM_CUSTOM_MRU
133 void OnMRUFile (wxCommandEvent& event);
135 void OnSize (wxSizeEvent& event);
138 wxCHMHelpController& getWinHelpController()
141 wxHtmlHelpController& getHtmlHelpController()
142 { return m_htmlHelp; }
144 void showHelp (int commandID);
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
153 void OnHelpButton (wxCommandEvent& event);
154 void OnImport (wxCommandEvent& event);
156 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
157 void OnHelpSecondary (wxCommandEvent& event);
160 void OnCreateFilter (wxCommandEvent& event);
161 void OnExit (wxCommandEvent& event);
163 void OnUpdateUI (wxUpdateUIEvent& event);
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);
186 void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
188 bool getShuttingDown() const { return m_bShuttingDown; }
193 class CTSimApp: public wxApp
196 enum { O_HELP, O_PRINT, O_VERSION };
197 static struct option ctsimOptions[];
199 bool m_bAdvancedOptions;
200 bool m_bSetModifyNewDocs;
201 bool m_bVerboseLogging;
202 bool m_bShowStartupTips;
204 bool m_bUseBackgroundTasks;
206 wxDocManager* m_docManager;
210 wxDocTemplate* m_pDocTemplImage;
211 wxDocTemplate* m_pDocTemplProjection;
212 wxDocTemplate* m_pDocTemplPhantom;
213 wxDocTemplate* m_pDocTemplPlot;
214 wxDocTemplate* m_pDocTemplText;
216 wxDocTemplate* m_pDocTemplGraph3d;
219 TextFileDocument* m_pLogDoc;
221 void usage (const char* program);
224 BackgroundManager* m_pBackgroundMgr;
230 MainFrame* getMainFrame() const
236 wxDocManager* getDocManager()
237 { return m_docManager; }
239 wxString getUntitledFilename();
241 int getNumberCPU() const { return wxThread::GetCPUCount(); }
243 EZPlotDialog* makeEZPlotDialog()
244 { return new EZPlotDialog (m_pFrame); }
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; }
256 BackgroundManager* getBackgroundManager() {return m_pBackgroundMgr;}
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; }
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; }
272 wxDocTemplate* getDocTemplGraph3d() { return m_pDocTemplGraph3d; }
274 TextFileDocument* getLogDoc() { return m_pLogDoc; }
276 ProjectionFileDocument* newProjectionDoc();
277 ImageFileDocument* newImageDoc();
278 PhantomFileDocument* newPhantomDoc();
279 PlotFileDocument* newPlotDoc();
280 TextFileDocument* newTextDoc();
282 Graph3dFileDocument* newGraph3dDoc();
286 DECLARE_APP(CTSimApp)
288 extern class CTSimApp* theApp;
291 MAINMENU_WINDOW_BASE = 500,
292 MAINMENU_HELP_ABOUT = 600,
293 MAINMENU_HELP_CONTENTS,
295 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
296 MAINMENU_HELP_SECONDARY,
298 MAINMENU_FILE_CREATE_PHANTOM,
299 MAINMENU_FILE_CREATE_FILTER,
301 MAINMENU_FILE_PREFERENCES,
305 PJMENU_FILE_PROPERTIES,
306 PJMENU_RECONSTRUCT_FBP,
307 PJMENU_RECONSTRUCT_FOURIER,
308 PJMENU_CONVERT_POLAR,
309 PJMENU_CONVERT_FFT_POLAR,
312 IFMENU_FILE_PROPERTIES,
318 IFMENU_PLOT_HISTOGRAM,
320 IFMENU_VIEW_SCALE_AUTO,
321 IFMENU_VIEW_SCALE_MINMAX,
322 IFMENU_VIEW_SCALE_FULL,
324 IFMENU_COMPARE_IMAGES,
327 IFMENU_IMAGE_SCALESIZE,
329 IFMENU_IMAGE_SUBTRACT,
330 IFMENU_IMAGE_MULTIPLY,
333 IFMENU_IMAGE_CONVERT3D,
336 IFMENU_FILTER_INVERTVALUES,
338 IFMENU_FILTER_SQUARE,
341 IFMENU_FILTER_FOURIER,
342 IFMENU_FILTER_INVERSE_FOURIER,
345 IFMENU_FILTER_FFT_ROWS,
346 IFMENU_FILTER_FFT_COLS,
347 IFMENU_FILTER_IFFT_ROWS,
348 IFMENU_FILTER_IFFT_COLS,
349 IFMENU_FILTER_MAGNITUDE,
351 IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
352 IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
354 PHMMENU_FILE_PROPERTIES,
355 PHMMENU_PROCESS_RASTERIZE,
356 PHMMENU_PROCESS_PROJECTIONS,
358 PLOTMENU_FILE_PROPERTIES,
359 PLOTMENU_VIEW_SCALE_MINMAX,
360 PLOTMENU_VIEW_SCALE_AUTO,
361 PLOTMENU_VIEW_SCALE_FULL,
363 GRAPH3D_VIEW_SURFACE,
365 GRAPH3D_VIEW_LIGHTING,
367 GRAPH3D_VIEW_SCALE_AUTO,
368 GRAPH3D_VIEW_SCALE_MINMAX,
369 GRAPH3D_VIEW_SCALE_FULL,
371 RECONSTRUCTION_THREAD_EVENT,