1 /*****************************************************************************
5 ** Purpose: Top-level routines for CTSim program
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.47 2001/02/16 02:36:18 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 ******************************************************************************/
41 #include "wx/config.h"
43 #include "wx/msw/helpchm.h"
49 #define CTSIM_CUSTOM_MRU 1
51 #if defined(CTSIM_MDI) && !wxUSE_MDI_ARCHITECTURE
52 #error You must set wxUSE_MDI_ARCHITECTURE to 1 in setup.h!
55 #include "wx/docmdi.h"
60 class ImageFileDocument;
61 class ProjectionFileDocument;
62 class PhantomFileDocument;
63 class PlotFileDocument;
64 class TextFileDocument;
66 class Graph3dFileDocument;
70 #include "wx/docview.h"
71 #include "wx/textctrl.h"
74 #include "wx/html/helpctrl.h"
75 #include "dlgezplot.h"
76 #include "ctsim-map.h"
79 #if defined(__WXMSW__) || defined (MSVC)
80 #define CTSIM_WINHELP 1
83 // Define a new frame for main window
85 class MainFrame: public wxDocMDIParentFrame
87 class MainFrame: public wxDocParentFrame
91 DECLARE_CLASS(MainFrame)
95 wxMenu* m_pWindowMenu;
98 enum { MAX_WINDOW_MENUITEMS = 20 };
99 wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
100 wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
102 int m_iDefaultPhantomID;
103 int m_iDefaultFilterID;
104 int m_iDefaultFilterDomainID;
105 unsigned int m_iDefaultFilterXSize;
106 unsigned int m_iDefaultFilterYSize;
107 double m_dDefaultFilterParam;
108 double m_dDefaultFilterBandwidth;
109 double m_dDefaultFilterInputScale;
110 double m_dDefaultFilterOutputScale;
112 bool m_bShuttingDown;
115 wxCHMHelpController m_winHelp;
117 wxHtmlHelpController m_htmlHelp;
120 MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
121 virtual ~MainFrame();
123 #ifdef CTSIM_CUSTOM_MRU
124 void OnMRUFile (wxCommandEvent& event);
126 void OnSize (wxSizeEvent& event);
129 wxCHMHelpController& getWinHelpController()
132 wxHtmlHelpController& getHtmlHelpController()
133 { return m_htmlHelp; }
135 void showHelp (int commandID);
137 void OnAbout (wxCommandEvent& event);
138 void OnHelpContents (wxCommandEvent& event);
139 void OnCreatePhantom (wxCommandEvent& event);
140 void OnPreferences (wxCommandEvent& event);
142 void OnHelpButton (wxCommandEvent& event);
144 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
145 void OnHelpSecondary (wxCommandEvent& event);
148 void OnCreateFilter (wxCommandEvent& event);
149 void OnExit (wxCommandEvent& event);
151 void OnUpdateUI (wxUpdateUIEvent& event);
153 void OnWindowMenu0 (wxCommandEvent& event);
154 void OnWindowMenu1 (wxCommandEvent& event);
155 void OnWindowMenu2 (wxCommandEvent& event);
156 void OnWindowMenu3 (wxCommandEvent& event);
157 void OnWindowMenu4 (wxCommandEvent& event);
158 void OnWindowMenu5 (wxCommandEvent& event);
159 void OnWindowMenu6 (wxCommandEvent& event);
160 void OnWindowMenu7 (wxCommandEvent& event);
161 void OnWindowMenu8 (wxCommandEvent& event);
162 void OnWindowMenu9 (wxCommandEvent& event);
163 void OnWindowMenu10 (wxCommandEvent& event);
164 void OnWindowMenu11 (wxCommandEvent& event);
165 void OnWindowMenu12 (wxCommandEvent& event);
166 void OnWindowMenu13 (wxCommandEvent& event);
167 void OnWindowMenu14 (wxCommandEvent& event);
168 void OnWindowMenu15 (wxCommandEvent& event);
169 void OnWindowMenu16 (wxCommandEvent& event);
170 void OnWindowMenu17 (wxCommandEvent& event);
171 void OnWindowMenu18 (wxCommandEvent& event);
172 void OnWindowMenu19 (wxCommandEvent& event);
174 void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
176 bool getShuttingDown() const { return m_bShuttingDown; }
181 class CTSimApp: public wxApp
184 enum { O_HELP, O_VERSION };
185 static struct option ctsimOptions[];
187 bool m_bAdvancedOptions;
188 bool m_bSetModifyNewDocs;
190 wxDocManager* m_docManager;
194 wxDocTemplate* m_pDocTemplImage;
195 wxDocTemplate* m_pDocTemplProjection;
196 wxDocTemplate* m_pDocTemplPhantom;
197 wxDocTemplate* m_pDocTemplPlot;
198 wxDocTemplate* m_pDocTemplText;
200 wxDocTemplate* m_pDocTemplGraph3d;
203 TextFileDocument* m_pLogDoc;
205 void usage (const char* program);
213 MainFrame* getMainFrame() const
219 wxDocManager* getDocManager()
220 { return m_docManager; }
222 wxString getUntitledFilename();
224 EZPlotDialog* makeEZPlotDialog()
225 { return new EZPlotDialog (m_pFrame); }
227 void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
228 bool getAdvancedOptions() const { return m_bAdvancedOptions; }
229 void setAdvancedOptions (bool bAdv) { m_bAdvancedOptions = bAdv; }
231 void setIconForFrame (wxFrame* pFrame);
232 wxConfig* getConfig()
233 { return m_pConfig; }
234 bool getAskDeleteNewDocs() const { return m_bSetModifyNewDocs; }
235 void setAskDeleteNewDocs(bool bAsk) { m_bSetModifyNewDocs = bAsk; }
237 wxDocTemplate* getDocTemplImage() { return m_pDocTemplImage; }
238 wxDocTemplate* getDocTemplProjection() { return m_pDocTemplProjection; }
239 wxDocTemplate* getDocTemplPhantom() { return m_pDocTemplPhantom; }
240 wxDocTemplate* getDocTemplPlot() { return m_pDocTemplPlot; }
241 wxDocTemplate* getDocTemplText() { return m_pDocTemplText; }
243 wxDocTemplate* getDocTemplGraph3d() { return m_pDocTemplGraph3d; }
245 TextFileDocument* getLogDoc() { return m_pLogDoc; }
247 ProjectionFileDocument* newProjectionDoc();
248 ImageFileDocument* newImageDoc();
249 PhantomFileDocument* newPhantomDoc();
250 PlotFileDocument* newPlotDoc();
251 TextFileDocument* newTextDoc();
253 Graph3dFileDocument* newGraph3dDoc();
257 DECLARE_APP(CTSimApp)
259 extern class CTSimApp* theApp;
262 MAINMENU_WINDOW_BASE = 500,
263 MAINMENU_HELP_ABOUT = 600,
264 MAINMENU_HELP_CONTENTS,
265 #if defined(CTSIM_WINHELP) && (defined(DEBUG) || defined(_DEBUG))
266 MAINMENU_HELP_SECONDARY,
268 MAINMENU_FILE_CREATE_PHANTOM,
270 MAINMENU_FILE_CREATE_FILTER,
272 MAINMENU_FILE_PREFERENCES,
274 PJMENU_FILE_PROPERTIES,
275 PJMENU_RECONSTRUCT_FBP,
276 PJMENU_RECONSTRUCT_FOURIER,
277 PJMENU_CONVERT_POLAR,
278 PJMENU_CONVERT_FFT_POLAR,
281 IFMENU_FILE_PROPERTIES,
287 IFMENU_PLOT_HISTOGRAM,
289 IFMENU_VIEW_SCALE_AUTO,
290 IFMENU_VIEW_SCALE_MINMAX,
291 IFMENU_VIEW_SCALE_FULL,
293 IFMENU_COMPARE_IMAGES,
296 IFMENU_IMAGE_SCALESIZE,
298 IFMENU_IMAGE_SUBTRACT,
299 IFMENU_IMAGE_MULTIPLY,
302 IFMENU_IMAGE_CONVERT3D,
305 IFMENU_FILTER_INVERTVALUES,
307 IFMENU_FILTER_SQUARE,
310 IFMENU_FILTER_FOURIER,
311 IFMENU_FILTER_INVERSE_FOURIER,
314 IFMENU_FILTER_FFT_ROWS,
315 IFMENU_FILTER_FFT_COLS,
316 IFMENU_FILTER_IFFT_ROWS,
317 IFMENU_FILTER_IFFT_COLS,
318 IFMENU_FILTER_MAGNITUDE,
320 IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
321 IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
323 PHMMENU_FILE_PROPERTIES,
324 PHMMENU_PROCESS_RASTERIZE,
325 PHMMENU_PROCESS_PROJECTIONS,
327 PLOTMENU_VIEW_SCALE_MINMAX,
328 PLOTMENU_VIEW_SCALE_AUTO,
329 PLOTMENU_VIEW_SCALE_FULL,
331 GRAPH3D_VIEW_SURFACE,
333 GRAPH3D_VIEW_LIGHTING,
335 GRAPH3D_VIEW_SCALE_AUTO,
336 GRAPH3D_VIEW_SCALE_MINMAX,
337 GRAPH3D_VIEW_SCALE_FULL,