r399: *** empty log message ***
[ctsim.git] / src / ctsim.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          ctsim.cpp
5 **   Purpose:       Top-level routines for CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: ctsim.h,v 1.24 2001/01/13 10:14:06 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 CTSIM_MDI 1
40 #endif
41
42
43 class wxMenu;
44 class wxDocument;
45
46 class ImageFileDocument;
47
48 #include <vector>
49
50 #ifndef WX_PRECOMP
51 #include "wx/wx.h"
52 #endif
53
54 #include "wx/docview.h"
55 #include "wx/textctrl.h"
56 #include "wx/menu.h"
57 #include "dlgezplot.h"
58
59
60 // Define a new frame for main window
61 #if CTSIM_MDI
62 class MainFrame: public wxMDIParentFrame
63 #else
64 class MainFrame: public wxDocParentFrame
65 #endif
66 {
67   DECLARE_CLASS(MainFrame)
68 private:
69   wxTextCtrl* m_pLog;
70   wxMenu* m_pWindowMenu;
71   
72   enum { MAX_WINDOW_MENUITEMS = 20 };
73   wxMenuItem* m_apWindowMenuItems[MAX_WINDOW_MENUITEMS];
74   wxDocument* m_apWindowMenuData[MAX_WINDOW_MENUITEMS];
75   
76   int m_iDefaultPhantomID;
77   int m_iDefaultFilterID;
78   int m_iDefaultFilterDomainID;
79   unsigned int m_iDefaultFilterXSize;    
80   unsigned int m_iDefaultFilterYSize;
81   double m_dDefaultFilterParam;
82   double m_dDefaultFilterBandwidth;
83   double m_dDefaultFilterInputScale;
84   double m_dDefaultFilterOutputScale;
85   
86   
87 public:
88   MainFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long type);
89   
90   void OnAbout (wxCommandEvent& event);
91   void OnHelpContents (wxCommandEvent& event);
92   void OnCreatePhantom (wxCommandEvent& event);
93   
94   void OnCreateFilter (wxCommandEvent& event);
95   void OnExit (wxCommandEvent& event);
96   
97   void OnUpdateUI (wxUpdateUIEvent& event);
98   
99   wxTextCtrl* getLog() 
100   { return m_pLog; }
101   
102   void OnWindowMenu0 (wxCommandEvent& event);
103   void OnWindowMenu1 (wxCommandEvent& event);
104   void OnWindowMenu2 (wxCommandEvent& event);
105   void OnWindowMenu3 (wxCommandEvent& event);
106   void OnWindowMenu4 (wxCommandEvent& event);
107   void OnWindowMenu5 (wxCommandEvent& event);
108   void OnWindowMenu6 (wxCommandEvent& event);
109   void OnWindowMenu7 (wxCommandEvent& event);
110   void OnWindowMenu8 (wxCommandEvent& event);
111   void OnWindowMenu9 (wxCommandEvent& event);
112   void OnWindowMenu10 (wxCommandEvent& event);
113   void OnWindowMenu11 (wxCommandEvent& event);
114   void OnWindowMenu12 (wxCommandEvent& event);
115   void OnWindowMenu13 (wxCommandEvent& event);
116   void OnWindowMenu14 (wxCommandEvent& event);
117   void OnWindowMenu15 (wxCommandEvent& event);
118   void OnWindowMenu16 (wxCommandEvent& event);
119   void OnWindowMenu17 (wxCommandEvent& event);
120   void OnWindowMenu18 (wxCommandEvent& event);
121   void OnWindowMenu19 (wxCommandEvent& event);
122   
123   void DoWindowMenu (int iMenuPosition, wxCommandEvent& event);
124   
125   DECLARE_EVENT_TABLE()
126 };
127
128
129 class wxDocManager;
130 class CTSimApp: public wxApp
131 {
132 public:
133   CTSimApp();
134   bool OnInit();
135   int OnExit();
136   MainFrame* getMainFrame() const
137   { return m_pFrame; }
138   wxTextCtrl* getLog()
139   { return m_pFrame->getLog(); }
140   wxDocManager* getDocManager() 
141   { return m_docManager; }
142   
143   wxString getUntitledFilename();
144   
145   EZPlotDialog* makeEZPlotDialog()
146   { return new EZPlotDialog (m_pFrame); }
147   
148   void getCompatibleImages (const ImageFileDocument* pIFDoc, std::vector<ImageFileDocument*>& vecIF);
149   
150   bool getSetModifyNewDocs() const
151   { return true; }
152   
153   void setIconForFrame (wxFrame* pFrame);
154
155 private:
156   wxDocManager* m_docManager;
157   MainFrame* m_pFrame;
158   
159   void usage (const char* program);
160   
161   static struct option ctsimOptions[];
162   
163   enum { O_HELP, O_VERSION };
164 };
165
166 DECLARE_APP(CTSimApp)
167
168 extern class CTSimApp* theApp;
169
170
171 enum {
172   MAINMENU_HELP_ABOUT = 500,
173     MAINMENU_WINDOW_BASE,
174     MAINMENU_HELP_CONTENTS,
175     MAINMENU_FILE_CREATE_PHANTOM,
176     
177     MAINMENU_FILE_CREATE_FILTER,
178     MAINMENU_FILE_EXIT,
179     
180     PJMENU_FILE_PROPERTIES,
181     PJMENU_RECONSTRUCT_FBP,
182     PJMENU_RECONSTRUCT_FOURIER,
183     PJMENU_CONVERT_POLAR,
184     PJMENU_CONVERT_FFT_POLAR,
185     
186     IFMENU_FILE_EXPORT,
187     IFMENU_FILE_PROPERTIES,
188     
189     IFMENU_PLOT_ROW,
190     IFMENU_PLOT_COL,
191     IFMENU_PLOT_FFT_ROW,
192     IFMENU_PLOT_FFT_COL,
193     IFMENU_PLOT_HISTOGRAM,
194     
195     IFMENU_VIEW_SCALE_AUTO,
196     IFMENU_VIEW_SCALE_MINMAX,
197     IFMENU_VIEW_SCALE_FULL,
198     
199     IFMENU_COMPARE_IMAGES,
200     IFMENU_COMPARE_ROW,
201     IFMENU_COMPARE_COL,
202     IFMENU_IMAGE_SCALESIZE,
203     IFMENU_IMAGE_ADD,
204     IFMENU_IMAGE_SUBTRACT,
205     IFMENU_IMAGE_MULTIPLY,
206     IFMENU_IMAGE_DIVIDE,
207     
208     IFMENU_FILTER_INVERTVALUES,
209     IFMENU_FILTER_SQRT,
210     IFMENU_FILTER_SQUARE,
211     IFMENU_FILTER_LOG,
212     IFMENU_FILTER_EXP,
213     IFMENU_FILTER_FOURIER,
214     IFMENU_FILTER_INVERSE_FOURIER,
215     IFMENU_FILTER_FFT,
216     IFMENU_FILTER_IFFT,
217     IFMENU_FILTER_FFT_ROWS,
218     IFMENU_FILTER_FFT_COLS,
219     IFMENU_FILTER_IFFT_ROWS,
220     IFMENU_FILTER_IFFT_COLS,
221     IFMENU_FILTER_MAGNITUDE,
222     IFMENU_FILTER_PHASE,
223     IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER,
224     IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER,
225     
226     PHMMENU_FILE_PROPERTIES,
227     PHMMENU_PROCESS_RASTERIZE,
228     PHMMENU_PROCESS_PROJECTIONS,
229     
230     PLOTMENU_VIEW_SCALE_MINMAX,
231     PLOTMENU_VIEW_SCALE_AUTO,
232     PLOTMENU_VIEW_SCALE_FULL,
233     
234 };
235
236 #endif