4f4706afc9f3fa211c4dfb149f2cc9d61a2712cc
[ctsim.git] / src / dialogs.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          dialogs.cpp
5 **   Purpose:       Dialog 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-2001 Kevin Rosenberg
11 **
12 **  $Id: dialogs.cpp,v 1.58 2003/01/23 23:35:58 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 #include "wx/wxprec.h"
29
30 #ifndef WX_PRECOMP
31 #include "wx/wx.h"
32 #endif
33
34 #if !wxUSE_DOC_VIEW_ARCHITECTURE
35 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
36 #endif
37
38 #include "wx/statline.h"
39 #include "wx/sizer.h"
40 #include "dialogs.h"
41 #include "ctsim.h"
42 #include "ct.h"
43 #include "docs.h"
44 #include "views.h"
45 #include "imagefile.h"
46 #include "projections.h"
47
48 #if defined(MSVC) || HAVE_SSTREAM
49 #include <sstream>
50 #else
51 #include <sstream_subst>
52 #endif
53
54
55 ///////////////////////////////////////////////////////////////////////
56 // CLASS IMPLEMENTATION
57 //    StringValueAndTitleListBox
58 ///////////////////////////////////////////////////////////////////////
59
60 StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* const aszTitle[], const char* const aszValue[])
61 : wxListBox ()
62 {
63   wxString* psTitle = new wxString [nChoices];
64   for (int i = 0; i < nChoices; i++)
65     psTitle[i] = aszTitle[i];
66   
67   Create (pParent, -1, wxDefaultPosition, wxSize(-1,-1), nChoices, psTitle, wxLB_SINGLE | wxLB_NEEDED_SB);
68   
69   m_ppszValues = aszValue;
70   delete [] psTitle;
71 };
72
73 const char*
74 StringValueAndTitleListBox::getSelectionStringValue () const
75 {
76   return m_ppszValues[GetSelection()];
77 }
78
79 StringValueAndTitleRadioBox::StringValueAndTitleRadioBox (wxDialog* pParent, const wxString& strTitle, int nChoices, const char* const aszTitle[], const char* const aszValue[])
80 : wxRadioBox ()
81 {
82   wxString* psTitle = new wxString [nChoices];
83   for (int i = 0; i < nChoices; i++)
84     psTitle[i] = aszTitle[i];
85   
86   Create (pParent, -1, strTitle, wxDefaultPosition, wxDefaultSize, nChoices, psTitle, 1, wxRA_SPECIFY_COLS);
87   
88   m_ppszValues = aszValue;
89   delete [] psTitle;
90 };
91
92 const char*
93 StringValueAndTitleRadioBox::getSelectionStringValue () const
94 {
95   return m_ppszValues[GetSelection()];
96 }
97
98 ///////////////////////////////////////////////////////////////////////
99 // CLASS IMPLEMENTATION
100 //    DialogGetPhantom
101 ///////////////////////////////////////////////////////////////////////
102
103 DialogGetPhantom::DialogGetPhantom (wxWindow* pParent, int iDefaultPhantom)
104 : wxDialog (pParent, -1, _T("Select Phantom"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
105 {
106   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
107   
108   pTopSizer->Add (new wxStaticText (this, -1, "Select Phantom"), 0, wxCENTER | wxALL, 5);
109   
110   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
111   
112   m_pRadioBoxPhantom = new StringValueAndTitleRadioBox (this, _T("Phantom"), Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray());
113   m_pRadioBoxPhantom->SetSelection (iDefaultPhantom);
114   pTopSizer->Add (m_pRadioBoxPhantom, 0, wxALL | wxALIGN_CENTER);
115   
116   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
117   
118   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
119   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
120   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
121   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
122   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
123   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PHANTOM);
124   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
125
126   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
127   pButtonOk->SetDefault();
128   
129   SetAutoLayout (true);
130   SetSizer (pTopSizer);
131   pTopSizer->Fit (this);
132   pTopSizer->SetSizeHints (this);
133 }
134
135 const char*
136 DialogGetPhantom::getPhantom()
137 {
138   return m_pRadioBoxPhantom->getSelectionStringValue();
139 }
140
141
142 ///////////////////////////////////////////////////////////////////////
143 // CLASS IMPLEMENTATION
144 //    DialogGetThetaRange
145 ///////////////////////////////////////////////////////////////////////
146
147 DialogGetThetaRange::DialogGetThetaRange (wxWindow* pParent, int iDefaultThetaRange)
148 : wxDialog (pParent, -1, _T("Select Phantom"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
149 {
150   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
151   
152   pTopSizer->Add (new wxStaticText (this, -1, "Select Theta Range"), 0, wxCENTER | wxALL, 5);
153   
154   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
155   
156   wxString asTitle[] = {"Unconstrained", "Normalized to 2pi", "Fold to pi"};
157   
158   m_pRadioBoxThetaRange = new wxRadioBox (this, -1, _T("Theta Range"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS);
159   if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_UNCONSTRAINED)
160     m_pRadioBoxThetaRange->SetSelection (0);
161   else if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_NORMALIZE_TO_TWOPI)
162     m_pRadioBoxThetaRange->SetSelection (1);
163   else if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_FOLD_TO_PI)
164     m_pRadioBoxThetaRange->SetSelection (2);
165
166   pTopSizer->Add (m_pRadioBoxThetaRange, 0, wxALL | wxALIGN_CENTER);
167   
168   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
169   
170   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
171   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
172   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
173   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
174   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
175   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_THETA_RANGE);
176   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
177
178   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
179   pButtonOk->SetDefault();
180   
181   SetAutoLayout (true);
182   SetSizer (pTopSizer);
183   pTopSizer->Fit (this);
184   pTopSizer->SetSizeHints (this);
185 }
186
187 int
188 DialogGetThetaRange::getThetaRange()
189 {
190   int iSelection = m_pRadioBoxThetaRange->GetSelection();
191   if (iSelection == 0)
192     return ParallelRaysums::THETA_RANGE_UNCONSTRAINED;
193   else if (iSelection == 1)
194     return ParallelRaysums::THETA_RANGE_NORMALIZE_TO_TWOPI;
195   else
196     return ParallelRaysums::THETA_RANGE_FOLD_TO_PI;
197 }
198
199
200 ///////////////////////////////////////////////////////////////////////
201 // CLASS IMPLEMENTATION
202 //    DialogGetComparisonImage
203 ///////////////////////////////////////////////////////////////////////
204
205 DialogGetComparisonImage::DialogGetComparisonImage (wxWindow* pParent, const char* const pszTitle, const std::vector<ImageFileDocument*>& rVecIF, bool bShowMakeDifference)
206 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rVecIF(rVecIF)
207 {
208   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
209   
210   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxALL, 5);
211   
212   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
213   
214   int iNImages = m_rVecIF.size();
215   wxString* pstrImages = new wxString [iNImages];
216   for (int i = 0; i < iNImages; i++) {
217     ImageFileView* pView = dynamic_cast<ImageFileView*>(m_rVecIF[i]->GetFirstView());
218     if (pView)
219       pstrImages[i] = pView->getFrame()->GetTitle();
220   }
221
222   m_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE);
223   delete [] pstrImages;
224
225   m_pListBoxImageChoices->SetSelection (0);
226   pTopSizer->Add (m_pListBoxImageChoices, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
227   
228   if (bShowMakeDifference) {
229     m_pMakeDifferenceImage = new wxCheckBox (this, -1, "Make Difference Image");
230     m_pMakeDifferenceImage->SetValue (FALSE);
231     pTopSizer->Add (m_pMakeDifferenceImage, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
232   } else
233     m_pMakeDifferenceImage = NULL;
234
235   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
236   
237   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
238   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
239   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
240   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
241   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
242   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_COMPARISON);
243   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
244   
245   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
246   pButtonOk->SetDefault();
247   
248   SetAutoLayout (true);
249   SetSizer (pTopSizer);
250   pTopSizer->Fit (this);
251   pTopSizer->SetSizeHints (this);
252 }
253
254 ImageFileDocument*
255 DialogGetComparisonImage::getImageFileDocument()
256 {
257   return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ];
258 }
259
260 bool
261 DialogGetComparisonImage::getMakeDifferenceImage()
262 {
263   if (m_pMakeDifferenceImage)
264     return m_pMakeDifferenceImage->GetValue();
265   else
266     return false;
267 }
268
269
270 /////////////////////////////////////////////////////////////////////
271 // CLASS DiaglogPreferences Implementation
272 /////////////////////////////////////////////////////////////////////
273
274 DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTitle, 
275                    bool bAdvancedOptions, bool bAskDeleteNewDocs, bool bVerboseLogging, bool bStartupTips, bool bUseBackgroundTasks)
276 : wxDialog (pParent, -1, _T(pszTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
277 {
278   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
279   
280   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
281   
282   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
283
284   m_pCBAdvancedOptions = new wxCheckBox (this, -1, "Advanced Options", wxDefaultPosition, wxSize(250, 25), 0);
285   m_pCBAdvancedOptions->SetValue (bAdvancedOptions);
286   pTopSizer->Add (m_pCBAdvancedOptions, 0, wxALIGN_CENTER_VERTICAL);
287
288   m_pCBAskDeleteNewDocs = new wxCheckBox (this, -1, "Ask \"Save New Documents\" Before Closing", wxDefaultPosition, wxSize(250, 25), 0);
289   m_pCBAskDeleteNewDocs->SetValue (bAskDeleteNewDocs);
290   pTopSizer->Add (m_pCBAskDeleteNewDocs, 0, wxALIGN_CENTER_VERTICAL);
291
292   m_pCBVerboseLogging = new wxCheckBox (this, -1, "Verbose Logging", wxDefaultPosition, wxSize(250, 25), 0);
293   m_pCBVerboseLogging->SetValue (bVerboseLogging);
294   pTopSizer->Add (m_pCBVerboseLogging, 0, wxALIGN_CENTER_VERTICAL);
295
296   m_pCBStartupTips = new wxCheckBox (this, -1, "Show Tips at Start", wxDefaultPosition, wxSize(250, 25), 0);
297   m_pCBStartupTips->SetValue (bStartupTips);
298   pTopSizer->Add (m_pCBStartupTips, 0, wxALIGN_CENTER_VERTICAL);
299
300 #if HAVE_WXTHREADS && MSVC
301   m_pCBUseBackgroundTasks = new wxCheckBox (this, -1, "Put Tasks in Background", wxDefaultPosition, wxSize(250, 25), 0);
302   m_pCBUseBackgroundTasks->SetValue (bUseBackgroundTasks);
303   pTopSizer->Add (m_pCBUseBackgroundTasks, 0, wxALIGN_CENTER_VERTICAL);
304 #endif
305
306   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
307   
308   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
309   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
310   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
311   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
312   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
313   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PREFERENCES);
314   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
315   
316   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
317   pButtonOk->SetDefault();
318   
319   SetAutoLayout (true);
320   SetSizer (pTopSizer);
321   pTopSizer->Fit (this);
322   pTopSizer->SetSizeHints (this);
323 }
324
325 DialogPreferences::~DialogPreferences ()
326 {
327 }
328
329 bool
330 DialogPreferences::getAdvancedOptions ()
331 {
332   return static_cast<bool>(m_pCBAdvancedOptions->GetValue());
333 }
334
335 bool
336 DialogPreferences::getAskDeleteNewDocs ()
337 {
338   return static_cast<bool>(m_pCBAskDeleteNewDocs->GetValue());
339 }
340
341 bool
342 DialogPreferences::getVerboseLogging ()
343 {
344   return static_cast<bool>(m_pCBVerboseLogging->GetValue());
345 }
346
347 bool
348 DialogPreferences::getStartupTips ()
349 {
350   return static_cast<bool>(m_pCBStartupTips->GetValue());
351 }
352
353 bool
354 DialogPreferences::getUseBackgroundTasks ()
355 {
356 #if HAVE_WXTHREADS && MSVC
357   return static_cast<bool>(m_pCBUseBackgroundTasks->GetValue());
358 #else
359   return false;
360 #endif
361 }
362
363
364 /////////////////////////////////////////////////////////////////////
365 // CLASS DiaglogGetMinMax Implementation
366 /////////////////////////////////////////////////////////////////////
367
368 DialogGetMinMax::DialogGetMinMax (wxWindow* pParent, const char* const pszTitle, double dDefaultMin, double dDefaultMax)
369 : wxDialog (pParent, -1, _T(pszTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
370 {
371   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
372   
373   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
374   
375   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
376   
377   std::ostringstream os;
378   os << dDefaultMin;
379   m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
380   std::ostringstream osMax;
381   osMax << dDefaultMax;
382   m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
383   
384   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
385   pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
386   pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
387   pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
388   pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
389   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
390   
391   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
392   
393   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
394   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
395   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
396   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
397   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
398   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_MINMAX);
399   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
400   
401   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
402   pButtonOk->SetDefault();
403   
404   SetAutoLayout (true);
405   SetSizer (pTopSizer);
406   pTopSizer->Fit (this);
407   pTopSizer->SetSizeHints (this);
408 }
409
410 DialogGetMinMax::~DialogGetMinMax ()
411 {
412 }
413
414 double
415 DialogGetMinMax::getMinimum ()
416 {
417   wxString strCtrl = m_pTextCtrlMin->GetValue();
418   double dValue;
419   if (strCtrl.ToDouble (&dValue))
420     return dValue;
421   else
422     return (m_dDefaultMin);
423 }
424
425 double
426 DialogGetMinMax::getMaximum ()
427 {
428   wxString strCtrl = m_pTextCtrlMax->GetValue();
429   double dValue;
430   if (strCtrl.ToDouble (&dValue))
431     return dValue;
432   else
433     return (m_dDefaultMax);
434 }
435
436
437 /////////////////////////////////////////////////////////////////////
438 // CLASS DialogAutoScaleParameters IMPLEMENTATION
439 /////////////////////////////////////////////////////////////////////
440
441 DialogAutoScaleParameters::DialogAutoScaleParameters (wxWindow *pParent, double mean, double mode, double median, double stddev, double dDefaultScaleFactor)
442 : wxDialog (pParent, -1, _T("Auto Scale Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_dMean(mean), m_dMode(mode), m_dMedian(median), m_dStdDev(stddev)
443 {
444   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
445   
446   pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
447   
448   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
449   
450   wxString asTitle[] = {"Mode", "Median", "Mean"};
451   
452   m_pRadioBoxCenter = new wxRadioBox (this, -1, _T("Center"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS);
453   m_pRadioBoxCenter->SetSelection (0);
454   pTopSizer->Add (m_pRadioBoxCenter, 0, wxALL | wxALIGN_CENTER);
455   
456   wxGridSizer *pGridSizer = new wxGridSizer (2);
457   pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
458   std::ostringstream osDefaultFactor;
459   osDefaultFactor << dDefaultScaleFactor;
460   m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, osDefaultFactor.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
461   pGridSizer->Add (m_pTextCtrlStdDevFactor, 0, wxALIGN_CENTER_VERTICAL);
462   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
463   
464   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
465   
466   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
467   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
468   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
469   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
470   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
471   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_AUTOSCALE);
472   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
473   
474   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
475   pButtonOk->SetDefault();
476   
477   SetAutoLayout (true);
478   SetSizer (pTopSizer);
479   pTopSizer->Fit (this);
480   pTopSizer->SetSizeHints (this);
481 }
482
483 bool
484 DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax)
485 {
486   int iCenter = m_pRadioBoxCenter->GetSelection();
487   double dCenter = m_dMode;
488   if (iCenter == 1)
489     dCenter = m_dMedian;
490   else if (iCenter == 2)
491     dCenter = m_dMean;
492   
493   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();
494   double dValue;
495   if (! sStddevFactor.ToDouble (&dValue)) {
496     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";
497     return false;
498   }
499   double dHalfWidth = dValue * m_dStdDev / 2;
500   *pMin = dCenter - dHalfWidth;
501   *pMax = dCenter + dHalfWidth;
502   *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n";
503   
504   return true;
505 }
506
507 double
508 DialogAutoScaleParameters::getAutoScaleFactor ()
509 {
510   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();
511   double dValue = 1.;
512   if (! sStddevFactor.ToDouble (&dValue)) {
513     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";
514   }
515   
516   return dValue;
517 }
518
519
520
521 /////////////////////////////////////////////////////////////////////
522 // CLASS IDENTIFICATION
523 //
524 // DialogGetRasterParameters
525 /////////////////////////////////////////////////////////////////////
526
527 DialogGetRasterParameters::DialogGetRasterParameters 
528    (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples, double dDefaultViewRatio)
529 : wxDialog (pParent, -1, _T("Rasterization Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
530 {
531   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
532   
533   pTopSizer->Add (new wxStaticText (this, -1, "Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
534   
535   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
536     
537   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
538   std::ostringstream os;
539   os << iDefaultXSize;
540   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
541   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
542   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
543   std::ostringstream osYSize;
544   osYSize << iDefaultYSize;
545   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
546   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
547   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
548   std::ostringstream osViewRatio;
549   osViewRatio << dDefaultViewRatio;
550   m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
551   pGridSizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
552   pGridSizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL);
553   std::ostringstream osNSamples;
554   osNSamples << iDefaultNSamples;
555   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
556   pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
557   pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
558
559   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
560   
561   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
562   
563   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
564   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
565   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
566   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
567   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
568   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_RASTERIZE);
569   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
570
571   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
572   pButtonOk->SetDefault();
573   
574   SetAutoLayout (true);
575   SetSizer (pTopSizer);
576   pTopSizer->Fit (this);
577   pTopSizer->SetSizeHints (this);
578 }
579
580 DialogGetRasterParameters::~DialogGetRasterParameters ()
581 {
582 }
583
584
585 unsigned int
586 DialogGetRasterParameters::getXSize ()
587 {
588   wxString strCtrl = m_pTextCtrlXSize->GetValue();
589   unsigned long lValue;
590   if (strCtrl.ToULong (&lValue))
591     return lValue;
592   else
593     return (m_iDefaultXSize);
594 }
595
596 unsigned int
597 DialogGetRasterParameters::getYSize ()
598 {
599   wxString strCtrl = m_pTextCtrlYSize->GetValue();
600   unsigned long lValue;
601   if (strCtrl.ToULong (&lValue))
602     return lValue;
603   else
604     return (m_iDefaultYSize);
605 }
606
607 unsigned int
608 DialogGetRasterParameters::getNSamples ()
609 {
610   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
611   unsigned long lValue;
612   if (strCtrl.ToULong (&lValue))
613     return lValue;
614   else
615     return (m_iDefaultNSamples);
616 }
617
618 double
619 DialogGetRasterParameters::getViewRatio ()
620 {
621   wxString strCtrl = m_pTextCtrlViewRatio->GetValue();
622   double dValue;
623   if (strCtrl.ToDouble (&dValue))
624     return dValue;
625   else
626     return (m_dDefaultViewRatio);
627 }
628
629
630 /////////////////////////////////////////////////////////////////////
631 // CLASS IDENTIFICATION
632 //
633 // DialogGetProjectionParameters
634 /////////////////////////////////////////////////////////////////////
635
636
637 DialogGetProjectionParameters::DialogGetProjectionParameters 
638    (wxWindow* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultOffsetView, int iDefaultNSamples, 
639     double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultCenterDetectorLength,
640     double dDefaultViewRatio, double dDefaultScanRatio, int iDefaultGeometry, int iDefaultTrace)
641 : wxDialog (pParent, -1, _T("Projection Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
642 {
643   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
644   
645   m_dDefaultRotAngle = dDefaultRotAngle;
646   m_dDefaultFocalLength = dDefaultFocalLength;
647   m_dDefaultCenterDetectorLength = dDefaultCenterDetectorLength;
648   m_dDefaultViewRatio = dDefaultViewRatio;
649   m_dDefaultScanRatio = dDefaultScanRatio;
650   m_iDefaultNSamples = iDefaultNSamples;
651   m_iDefaultNView = iDefaultNView;
652   m_iDefaultNDet = iDefaultNDet;
653   m_iDefaultTrace = iDefaultTrace;
654   m_iDefaultGeometry = iDefaultGeometry;
655   
656   pTopSizer->Add (new wxStaticText (this, -1, "Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
657   
658   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
659     
660   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
661   m_pRadioBoxGeometry = new StringValueAndTitleRadioBox (this, _T("Geometry"), Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray());
662   m_pRadioBoxGeometry->SetSelection (iDefaultGeometry);
663   
664   pGridSizer->Add (m_pRadioBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
665   
666   m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), Trace::getTraceCount(), Trace::getTraceTitleArray(), Trace::getTraceNameArray());
667   m_pRadioBoxTrace->SetSelection (iDefaultTrace);
668   pGridSizer->Add (m_pRadioBoxTrace, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
669
670           wxFlexGridSizer* pText1Sizer = new wxFlexGridSizer(2);
671   std::ostringstream os;
672   os << iDefaultNDet;
673   m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
674   pText1Sizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
675   pText1Sizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL);
676   std::ostringstream osNView;
677   osNView << iDefaultNView;
678   m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
679   pText1Sizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
680   pText1Sizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL);
681   std::ostringstream osNSamples;
682   osNSamples << iDefaultNSamples;
683   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
684   pText1Sizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
685   pText1Sizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
686
687   pGridSizer->Add (pText1Sizer);
688
689   wxFlexGridSizer* pText2Sizer = new wxFlexGridSizer(2);
690   std::ostringstream osViewRatio;
691   osViewRatio << dDefaultViewRatio;
692   m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
693   pText2Sizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
694   pText2Sizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL);
695   std::ostringstream osScanRatio;
696   osScanRatio << dDefaultScanRatio;
697   m_pTextCtrlScanRatio = new wxTextCtrl (this, -1, osScanRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
698   pText2Sizer->Add (new wxStaticText (this, -1, "Scan Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
699   pText2Sizer->Add (m_pTextCtrlScanRatio, 0, wxALIGN_CENTER_VERTICAL);
700   std::ostringstream osFocalLength;
701   osFocalLength << dDefaultFocalLength;
702   m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
703   pText2Sizer->Add (new wxStaticText (this, -1, "Focal Length Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
704   pText2Sizer->Add (m_pTextCtrlFocalLength, 0, wxALIGN_CENTER_VERTICAL);
705
706   if (theApp->getAdvancedOptions()) {
707     std::ostringstream osCenterDetectorLength;
708     osCenterDetectorLength << dDefaultCenterDetectorLength;
709     m_pTextCtrlCenterDetectorLength = new wxTextCtrl (this, -1, osCenterDetectorLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
710     pText2Sizer->Add (new wxStaticText (this, -1, "Center-Detector Length Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
711     pText2Sizer->Add (m_pTextCtrlCenterDetectorLength, 0, wxALIGN_CENTER_VERTICAL);
712
713     std::ostringstream osRotAngle;
714     osRotAngle << dDefaultRotAngle;
715     m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
716     pText2Sizer->Add (new wxStaticText (this, -1, "Rotation Angle (Fraction of circle)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
717     pText2Sizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
718                         
719     std::ostringstream osOffsetView;
720     osOffsetView << iDefaultOffsetView;
721     m_pTextCtrlOffsetView = new wxTextCtrl (this, -1, osOffsetView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
722     pText2Sizer->Add (new wxStaticText (this, -1, "Gantry offset in units of 'views' "), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
723     pText2Sizer->Add (m_pTextCtrlOffsetView, 0, wxALIGN_CENTER_VERTICAL);
724
725   }
726   pGridSizer->Add (pText2Sizer);
727
728   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
729   
730   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
731   
732   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
733   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
734   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
735   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
736   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
737   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PROJECTIONS);
738   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
739   
740   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
741   pButtonOk->SetDefault();
742   
743   SetAutoLayout (true);
744   SetSizer (pTopSizer);
745   pTopSizer->Fit (this);
746   pTopSizer->SetSizeHints (this);
747
748   m_pRadioBoxGeometry->SetFocus();
749 }
750
751 DialogGetProjectionParameters::~DialogGetProjectionParameters ()
752 {
753 }
754
755
756 unsigned int
757 DialogGetProjectionParameters::getNDet ()
758 {
759   wxString strCtrl = m_pTextCtrlNDet->GetValue();
760   unsigned long lValue;
761   if (strCtrl.ToULong (&lValue))
762     return lValue;
763   else
764     return (m_iDefaultNDet);
765 }
766
767 unsigned int
768 DialogGetProjectionParameters::getNView ()
769 {
770   wxString strCtrl = m_pTextCtrlNView->GetValue();
771   unsigned long lValue;
772   if (strCtrl.ToULong (&lValue))
773     return lValue;
774   else
775     return (m_iDefaultNView);
776 }
777
778 unsigned int
779 DialogGetProjectionParameters::getOffsetView ()
780 {
781   if (theApp->getAdvancedOptions()) {
782           wxString strCtrl = m_pTextCtrlOffsetView->GetValue();
783           unsigned long lValue;
784           if (strCtrl.ToULong (&lValue))
785             return lValue;
786           else
787             return (m_iDefaultOffsetView);
788   }
789   else
790     return 0;
791 }
792
793 unsigned int
794 DialogGetProjectionParameters::getNSamples ()
795 {
796   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
797   unsigned long lValue;
798   if (strCtrl.ToULong (&lValue))
799     return lValue;
800   else
801     return (m_iDefaultNSamples);
802 }
803
804 double
805 DialogGetProjectionParameters::getRotAngle ()
806 {
807   if (theApp->getAdvancedOptions()) {
808     wxString strCtrl = m_pTextCtrlRotAngle->GetValue();
809     double dValue;
810     if (strCtrl.ToDouble (&dValue))
811       return (dValue * TWOPI);
812     else
813       return (m_dDefaultRotAngle);
814   } else {
815     if (Scanner::convertGeometryNameToID (m_pRadioBoxGeometry->getSelectionStringValue()) == 
816           Scanner::GEOMETRY_PARALLEL)
817       return (PI);
818     else
819       return (TWOPI);
820   }
821 }
822
823 double
824 DialogGetProjectionParameters::getFocalLengthRatio ()
825 {
826   wxString strCtrl = m_pTextCtrlFocalLength->GetValue();
827   double dValue;
828   if (strCtrl.ToDouble (&dValue))
829     return (dValue);
830   else
831     return (m_dDefaultFocalLength);
832 }
833
834 double
835 DialogGetProjectionParameters::getCenterDetectorLengthRatio ()
836 {
837   if (theApp->getAdvancedOptions()) {
838     wxString strCtrl = m_pTextCtrlCenterDetectorLength->GetValue();
839     double dValue;
840     if (strCtrl.ToDouble (&dValue))
841       return (dValue);
842     else
843       return (m_dDefaultCenterDetectorLength);
844   } else
845     return getFocalLengthRatio(); // default is to set equal to focal-length
846 }
847
848 double
849 DialogGetProjectionParameters::getViewRatio ()
850 {
851   wxString strCtrl = m_pTextCtrlViewRatio->GetValue();
852   double dValue;
853   if (strCtrl.ToDouble (&dValue))
854     return (dValue);
855   else
856     return (m_dDefaultViewRatio);
857 }
858
859 double
860 DialogGetProjectionParameters::getScanRatio ()
861 {
862   wxString strCtrl = m_pTextCtrlScanRatio->GetValue();
863   double dValue;
864   if (strCtrl.ToDouble (&dValue))
865     return (dValue);
866   else
867     return (m_dDefaultScanRatio);
868 }
869
870 const char*
871 DialogGetProjectionParameters::getGeometry ()
872 {
873   return m_pRadioBoxGeometry->getSelectionStringValue();
874 }
875
876 int
877 DialogGetProjectionParameters::getTrace ()
878 {
879   return Trace::convertTraceNameToID(m_pRadioBoxTrace->getSelectionStringValue());
880 }
881
882
883
884 /////////////////////////////////////////////////////////////////////
885 // CLASS IDENTIFICATION
886 //
887 // DialogGetReconstructionParameters
888 /////////////////////////////////////////////////////////////////////
889
890
891 DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxWindow* pParent, int iDefaultXSize, 
892                      int iDefaultYSize, int iDefaultFilterID, double dDefaultHammingParam,  
893                      int iDefaultFilterMethodID, int iDefaultFilterGenerationID, int iDefaultZeropad, 
894                      int iDefaultInterpID, int iDefaultInterpParam, int iDefaultBackprojectID, int iTrace,
895                      ReconstructionROI* pDefaultROI)
896 : wxDialog (pParent, -1, _T("Reconstruction Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
897 {
898   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
899   
900   m_iDefaultXSize = iDefaultXSize;
901   m_iDefaultYSize = iDefaultYSize;
902   m_dDefaultFilterParam = dDefaultHammingParam;
903   m_iDefaultZeropad = iDefaultZeropad;
904   m_iDefaultInterpParam = iDefaultInterpParam;
905   m_dDefaultRoiXMin = pDefaultROI->m_dXMin;
906   m_dDefaultRoiXMax = pDefaultROI->m_dXMax;
907   m_dDefaultRoiYMin = pDefaultROI->m_dYMin;
908   m_dDefaultRoiYMax = pDefaultROI->m_dYMax;
909
910   pTopSizer->Add (new wxStaticText (this, -1, "Filtered Backprojection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
911   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
912   
913   wxFlexGridSizer* pGridSizer = NULL;
914   if (theApp->getAdvancedOptions())
915     pGridSizer = new wxFlexGridSizer (4);
916   else
917     pGridSizer = new wxFlexGridSizer (3);
918
919   if (theApp->getAdvancedOptions())
920     m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
921   else
922     m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getReconstructFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
923   m_pRadioBoxFilter->SetSelection (iDefaultFilterID);
924   pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
925   
926   if (theApp->getAdvancedOptions()) {
927     m_pRadioBoxFilterMethod = new StringValueAndTitleRadioBox (this, _T("Filter Method"), ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray());
928     m_pRadioBoxFilterMethod->SetSelection (iDefaultFilterMethodID);
929     pGridSizer->Add (m_pRadioBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
930   } else {
931 #if HAVE_FFTW
932     static const char* aszFilterMethodTitle[] = {"Convolution", "FFT"};
933     static const char* aszFilterMethodName[] = {"convolution", "rfftw"};
934 #else
935     static const char* aszFilterMethodTitle[] = {"Convolution", "Fourier"};
936     static const char* aszFilterMethodName[] = {"convolution", "fourier-table"};
937 #endif
938       m_pRadioBoxFilterMethod = new StringValueAndTitleRadioBox (this, _T("Filter Method"), 2, aszFilterMethodTitle, aszFilterMethodName);
939 #if HAVE_FFTW
940       m_pRadioBoxFilterMethod->SetSelection (1);
941 #else
942       m_pRadioBoxFilterMethod->SetSelection (0);
943 #endif
944       pGridSizer->Add (m_pRadioBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
945   }
946
947   if (theApp->getAdvancedOptions()) {
948     m_pRadioBoxFilterGeneration = new StringValueAndTitleRadioBox (this, _T("Filter Generation"), ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray());
949     m_pRadioBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID);
950     pGridSizer->Add (m_pRadioBoxFilterGeneration, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
951   
952     m_pRadioBoxBackproject = new StringValueAndTitleRadioBox (this, _T("Backprojection"), Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray());
953     m_pRadioBoxBackproject->SetSelection (iDefaultBackprojectID);
954     pGridSizer->Add (m_pRadioBoxBackproject, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
955   }
956
957   m_pRadioBoxInterp = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray());
958   m_pRadioBoxInterp->SetSelection (iDefaultInterpID);
959   pGridSizer->Add (m_pRadioBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
960   
961   static const char* aszTraceTitle[] = {"None", "Full"};
962   static const char* aszTraceName[] = {"none", "full"};
963   m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), 2, aszTraceTitle, aszTraceName);
964   iTrace = clamp(iTrace, 0, 1);
965   m_pRadioBoxTrace->SetSelection (iTrace);
966   pGridSizer->Add (m_pRadioBoxTrace);
967
968   wxFlexGridSizer* pTextGridSizer = new wxFlexGridSizer (2);
969   std::ostringstream os;
970   os << iDefaultXSize;
971   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
972   pTextGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
973   pTextGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
974   std::ostringstream osYSize;
975   osYSize << iDefaultYSize;
976   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
977   pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
978   pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
979
980   std::ostringstream osHammingParam;
981   osHammingParam << dDefaultHammingParam;
982   m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osHammingParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
983   pTextGridSizer->Add (new wxStaticText (this, -1, "Hamming Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
984   pTextGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
985
986   if (theApp->getAdvancedOptions()) {
987     std::ostringstream osZeropad;
988     osZeropad << iDefaultZeropad;
989     m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
990     pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
991     pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
992   }
993   pGridSizer->Add (pTextGridSizer);
994
995 #if HAVE_FREQ_PREINTERP
996   std::ostringstream osInterpParam;
997   osInterpParam << iDefaultInterpParam;
998   m_pTextCtrlInterpParam = new wxTextCtrl (this, -1, osInterpParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
999   pGridSizer->Add (new wxStaticText (this, -1, "Interpolation Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1000   pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1001 #endif  
1002
1003   if (theApp->getAdvancedOptions()) {
1004     wxFlexGridSizer* pROIGridSizer = new wxFlexGridSizer (2);
1005     std::ostringstream osRoiXMin;
1006     osRoiXMin << m_dDefaultRoiXMin;
1007     m_pTextCtrlRoiXMin = new wxTextCtrl (this, -1, osRoiXMin.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1008     pROIGridSizer->Add (new wxStaticText (this, -1, "ROI XMin"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1009     pROIGridSizer->Add (m_pTextCtrlRoiXMin, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1010     std::ostringstream osRoiXMax;
1011     osRoiXMax << m_dDefaultRoiXMax;
1012     m_pTextCtrlRoiXMax = new wxTextCtrl (this, -1, osRoiXMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1013     pROIGridSizer->Add (new wxStaticText (this, -1, "ROI XMax"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1014     pROIGridSizer->Add (m_pTextCtrlRoiXMax, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1015     std::ostringstream osRoiYMin;
1016     osRoiYMin << m_dDefaultRoiYMin;
1017     m_pTextCtrlRoiYMin = new wxTextCtrl (this, -1, osRoiYMin.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1018     pROIGridSizer->Add (new wxStaticText (this, -1, "ROI YMin"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1019     pROIGridSizer->Add (m_pTextCtrlRoiYMin, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1020     std::ostringstream osRoiYMax;
1021     osRoiYMax << m_dDefaultRoiYMax;
1022     m_pTextCtrlRoiYMax = new wxTextCtrl (this, -1, osRoiYMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1023     pROIGridSizer->Add (new wxStaticText (this, -1, "ROI YMax"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1024     pROIGridSizer->Add (m_pTextCtrlRoiYMax, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1025
1026     pGridSizer->Add (pROIGridSizer);
1027   }
1028
1029   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
1030   
1031   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1032   
1033   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1034   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1035   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1036   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1037   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1038   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_RECONSTRUCTION);
1039   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
1040   
1041   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1042   pButtonOk->SetDefault();
1043   
1044   SetAutoLayout (true);
1045   SetSizer (pTopSizer);
1046   pTopSizer->Layout();
1047   pTopSizer->Fit (this);
1048   pTopSizer->SetSizeHints (this);
1049 }
1050
1051 DialogGetReconstructionParameters::~DialogGetReconstructionParameters ()
1052 {
1053 }
1054
1055
1056 unsigned int
1057 DialogGetReconstructionParameters::getXSize ()
1058 {
1059   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1060   unsigned long lValue;
1061   if (strCtrl.ToULong (&lValue))
1062     return lValue;
1063   else
1064     return (m_iDefaultXSize);
1065 }
1066
1067 unsigned int
1068 DialogGetReconstructionParameters::getYSize ()
1069 {
1070   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1071   unsigned long lValue;
1072   if (strCtrl.ToULong (&lValue))
1073     return lValue;
1074   else
1075     return (m_iDefaultYSize);
1076 }
1077
1078 unsigned int
1079 DialogGetReconstructionParameters::getZeropad ()
1080 {
1081   if (theApp->getAdvancedOptions()) {
1082     wxString strCtrl = m_pTextCtrlZeropad->GetValue();
1083     unsigned long lValue;
1084     if (strCtrl.ToULong (&lValue))
1085       return lValue;
1086     else
1087       return (m_iDefaultZeropad);
1088   } else
1089     return 1;
1090 }
1091
1092
1093 unsigned int
1094 DialogGetReconstructionParameters::getInterpParam ()
1095 {
1096 #if HAVE_FREQ_PREINTERP
1097   wxString strCtrl = m_pTextCtrlInterpParam->GetValue();
1098   unsigned long lValue;
1099   if (strCtrl.ToULong (&lValue))
1100     return lValue;
1101   else
1102     return (m_iDefaultInterpParam);
1103 #else
1104   return 1;
1105 #endif
1106 }
1107
1108 double
1109 DialogGetReconstructionParameters::getFilterParam ()
1110 {
1111   wxString strCtrl = m_pTextCtrlFilterParam->GetValue();
1112   double dValue;
1113   if (strCtrl.ToDouble (&dValue))
1114     return (dValue);
1115   else
1116     return (m_dDefaultFilterParam);
1117 }
1118
1119 const char*
1120 DialogGetReconstructionParameters::getFilterName ()
1121 {
1122   return m_pRadioBoxFilter->getSelectionStringValue();
1123 }
1124
1125 const char*
1126 DialogGetReconstructionParameters::getFilterMethodName ()
1127 {
1128   return m_pRadioBoxFilterMethod->getSelectionStringValue();
1129 }
1130
1131 const char*
1132 DialogGetReconstructionParameters::getInterpName ()
1133 {
1134   return m_pRadioBoxInterp->getSelectionStringValue();
1135 }
1136
1137 int
1138 DialogGetReconstructionParameters::getTrace ()
1139 {
1140   int iTrace = 0;
1141   if (strcmp("full", m_pRadioBoxTrace->getSelectionStringValue()) == 0)
1142     iTrace = Trace::TRACE_PLOT;
1143   return iTrace;
1144 }
1145
1146 const char*
1147 DialogGetReconstructionParameters::getBackprojectName ()
1148 {
1149   if (theApp->getAdvancedOptions()) {
1150     return m_pRadioBoxBackproject->getSelectionStringValue();
1151   } else
1152     return "idiff";
1153 }
1154
1155 const char*
1156 DialogGetReconstructionParameters::getFilterGenerationName ()
1157 {
1158   if (theApp->getAdvancedOptions()) {
1159     return m_pRadioBoxFilterGeneration->getSelectionStringValue();
1160   } else {
1161     if (ProcessSignal::convertFilterMethodNameToID(m_pRadioBoxFilterMethod->getSelectionStringValue())
1162         == ProcessSignal::FILTER_METHOD_CONVOLUTION)
1163       return "direct";
1164     else
1165       return "inverse-fourier";
1166   }
1167 }
1168
1169 void
1170 DialogGetReconstructionParameters::getROI (ReconstructionROI* pROI)
1171 {
1172   if (theApp->getAdvancedOptions()) {
1173     double dValue;
1174     if (m_pTextCtrlRoiXMin->GetValue().ToDouble (&dValue))
1175       pROI->m_dXMin = dValue;
1176     else
1177       pROI->m_dXMin = m_dDefaultRoiXMin;
1178
1179     if (m_pTextCtrlRoiXMax->GetValue().ToDouble (&dValue))
1180       pROI->m_dXMax = dValue;
1181     else
1182       pROI->m_dXMax = m_dDefaultRoiXMax;
1183
1184     if (m_pTextCtrlRoiYMin->GetValue().ToDouble (&dValue))
1185       pROI->m_dYMin = dValue;
1186     else
1187       pROI->m_dYMin = m_dDefaultRoiYMin;
1188
1189     if (m_pTextCtrlRoiYMax->GetValue().ToDouble (&dValue))
1190       pROI->m_dYMax = dValue;
1191     else
1192       pROI->m_dYMax = m_dDefaultRoiYMax;
1193   } else {
1194     pROI->m_dXMin = m_dDefaultRoiXMin;
1195     pROI->m_dXMax = m_dDefaultRoiXMax;
1196     pROI->m_dYMin = m_dDefaultRoiYMin;
1197     pROI->m_dYMax = m_dDefaultRoiYMax;
1198   }
1199 }
1200
1201 /////////////////////////////////////////////////////////////////////
1202 // CLASS IDENTIFICATION
1203 //
1204 // DialogGetFilterParameters
1205 /////////////////////////////////////////////////////////////////////
1206
1207
1208
1209 DialogGetFilterParameters::DialogGetFilterParameters (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultFilterID, double dDefaultFilterParam,  double dDefaultBandwidth, int iDefaultDomainID, double dDefaultInputScale, double dDefaultOutputScale)
1210 : wxDialog (pParent, -1, _T("Filter Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1211 {
1212   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1213   
1214   pTopSizer->Add (new wxStaticText (this, -1, "Filter Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); 
1215   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1216   
1217   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
1218
1219   m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
1220   m_pRadioBoxFilter->SetSelection (iDefaultFilterID);
1221   pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
1222   
1223   m_pRadioBoxDomain = new StringValueAndTitleRadioBox (this, _T("Domain"), SignalFilter::getDomainCount(), SignalFilter::getDomainTitleArray(), SignalFilter::getDomainNameArray());
1224   m_pRadioBoxDomain->SetSelection (iDefaultDomainID);
1225   pGridSizer->Add (m_pRadioBoxDomain, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
1226   
1227   std::ostringstream os;
1228   os << iDefaultXSize;
1229   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1230   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1231   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1232
1233   std::ostringstream osYSize;
1234   osYSize << iDefaultYSize;
1235   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1236   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1237   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1238
1239   std::ostringstream osFilterParam;
1240   osFilterParam << dDefaultFilterParam;
1241   m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1242   pGridSizer->Add (new wxStaticText (this, -1, "Filter Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1243   pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1244
1245   std::ostringstream osBandwidth;
1246   osBandwidth << dDefaultBandwidth;
1247   m_pTextCtrlBandwidth = new wxTextCtrl (this, -1, osBandwidth.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1248   pGridSizer->Add (new wxStaticText (this, -1, "Bandwidth"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1249   pGridSizer->Add (m_pTextCtrlBandwidth, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1250
1251   std::ostringstream osInputScale;
1252   osInputScale << dDefaultInputScale;
1253   m_pTextCtrlInputScale = new wxTextCtrl (this, -1, osInputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1254   pGridSizer->Add (new wxStaticText (this, -1, "Axis (input) Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1255   pGridSizer->Add (m_pTextCtrlInputScale, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1256
1257   std::ostringstream osOutputScale;
1258   osOutputScale << dDefaultOutputScale;
1259   m_pTextCtrlOutputScale = new wxTextCtrl (this, -1, osOutputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1260   pGridSizer->Add (new wxStaticText (this, -1, "Filter Output Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1261   pGridSizer->Add (m_pTextCtrlOutputScale, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1262   
1263   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
1264   
1265   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1266   
1267   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1268   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1269   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1270   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1271   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1272   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_FILTER);
1273   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
1274   
1275   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1276   pButtonOk->SetDefault();
1277
1278   SetAutoLayout (true);
1279   SetSizer (pTopSizer);
1280   pTopSizer->Layout();
1281   pTopSizer->Fit (this);
1282   pTopSizer->SetSizeHints (this);
1283 }
1284
1285 DialogGetFilterParameters::~DialogGetFilterParameters ()
1286 {
1287 }
1288
1289
1290 unsigned int
1291 DialogGetFilterParameters::getXSize ()
1292 {
1293   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1294   unsigned long lValue;
1295   if (strCtrl.ToULong (&lValue))
1296     return lValue;
1297   else
1298     return (m_iDefaultXSize);
1299 }
1300
1301 unsigned int
1302 DialogGetFilterParameters::getYSize ()
1303 {
1304   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1305   unsigned long lValue;
1306   if (strCtrl.ToULong (&lValue))
1307     return lValue;
1308   else
1309     return (m_iDefaultYSize);
1310 }
1311
1312 double
1313 DialogGetFilterParameters::getBandwidth ()
1314 {
1315   wxString strCtrl = m_pTextCtrlBandwidth->GetValue();
1316   double dValue;
1317   if (strCtrl.ToDouble (&dValue))
1318     return dValue;
1319   else
1320     return (m_dDefaultBandwidth);
1321 }
1322
1323 double
1324 DialogGetFilterParameters::getFilterParam ()
1325 {
1326   wxString strCtrl = m_pTextCtrlFilterParam->GetValue();
1327   double dValue;
1328   if (strCtrl.ToDouble (&dValue))
1329     return (dValue);
1330   else
1331     return (m_dDefaultFilterParam);
1332 }
1333
1334 double
1335 DialogGetFilterParameters::getInputScale ()
1336 {
1337   wxString strCtrl = m_pTextCtrlInputScale->GetValue();
1338   double dValue;
1339   if (strCtrl.ToDouble (&dValue))
1340     return dValue;
1341   else
1342     return (m_dDefaultInputScale);
1343 }
1344
1345 double
1346 DialogGetFilterParameters::getOutputScale ()
1347 {
1348   wxString strCtrl = m_pTextCtrlOutputScale->GetValue();
1349   double dValue;
1350   if (strCtrl.ToDouble (&dValue))
1351     return dValue;
1352   else
1353     return (m_dDefaultOutputScale);
1354 }
1355
1356 const char*
1357 DialogGetFilterParameters::getFilterName ()
1358 {
1359   return m_pRadioBoxFilter->getSelectionStringValue();
1360 }
1361
1362 const char*
1363 DialogGetFilterParameters::getDomainName ()
1364 {
1365   return m_pRadioBoxDomain->getSelectionStringValue();
1366 }
1367
1368
1369 ///////////////////////////////////////////////////////////////////////
1370 // CLASS IMPLEMENTATION
1371 //    DialogExportParameters
1372 ///////////////////////////////////////////////////////////////////////
1373
1374 DialogExportParameters::DialogExportParameters (wxWindow* pParent, int iDefaultFormatID)
1375 : wxDialog (pParent, -1, _T("Select ExportParameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1376 {
1377   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1378   
1379   pTopSizer->Add (new wxStaticText (this, -1, "Select Export Format"), 0, wxALIGN_CENTER | wxALL, 5);
1380   
1381   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
1382   
1383   m_pRadioBoxFormat = new StringValueAndTitleRadioBox (this, _T("File Type"), 
1384     ImageFile::getExportFormatCount(), ImageFile::getExportFormatTitleArray(), ImageFile::getExportFormatNameArray());
1385   m_pRadioBoxFormat->SetSelection (iDefaultFormatID);
1386   pTopSizer->Add (m_pRadioBoxFormat, 0, wxALL | wxALIGN_CENTER);
1387   
1388   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1389   
1390   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1391   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1392   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1393   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1394   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1395   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_EXPORT);
1396   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
1397   
1398   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1399   pButtonOk->SetDefault();
1400
1401   SetAutoLayout (true);
1402   SetSizer (pTopSizer);
1403   pTopSizer->Fit (this);
1404   pTopSizer->SetSizeHints (this);
1405 }
1406
1407 const char*
1408 DialogExportParameters::getFormatName()
1409 {
1410   return m_pRadioBoxFormat->getSelectionStringValue();
1411 }
1412
1413
1414 ///////////////////////////////////////////////////////////////////////
1415 // CLASS IMPLEMENTATION
1416 //    DialogImportParameters
1417 ///////////////////////////////////////////////////////////////////////
1418
1419 DialogImportParameters::DialogImportParameters (wxWindow* pParent, int iDefaultFormatID)
1420 : wxDialog (pParent, -1, _T("Select Import Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1421 {
1422   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1423   
1424   pTopSizer->Add (new wxStaticText (this, -1, "Select Import Format"), 0, wxALIGN_CENTER | wxALL, 5);
1425   
1426   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
1427   
1428   m_pRadioBoxFormat = new StringValueAndTitleRadioBox (this, _T("File Type"), 
1429     ImageFile::getImportFormatCount(), ImageFile::getImportFormatTitleArray(), ImageFile::getImportFormatNameArray());
1430   m_pRadioBoxFormat->SetSelection (iDefaultFormatID);
1431   pTopSizer->Add (m_pRadioBoxFormat, 0, wxALL | wxALIGN_CENTER);
1432   
1433   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1434   
1435   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1436   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1437   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1438   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1439   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1440   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_IMPORT);
1441   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
1442   
1443   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1444   pButtonOk->SetDefault();
1445
1446   SetAutoLayout (true);
1447   SetSizer (pTopSizer);
1448   pTopSizer->Fit (this);
1449   pTopSizer->SetSizeHints (this);
1450 }
1451
1452 const char*
1453 DialogImportParameters::getFormatName()
1454 {
1455   return m_pRadioBoxFormat->getSelectionStringValue();
1456 }
1457
1458
1459 /////////////////////////////////////////////////////////////////////
1460 // CLASS DiaglogGetXYSize Implementation
1461 /////////////////////////////////////////////////////////////////////
1462
1463 DialogGetXYSize::DialogGetXYSize (wxWindow* pParent, const char* const pszTitle, int iDefaultXSize, int iDefaultYSize)
1464 : wxDialog (pParent, -1, _T(pszTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1465 {
1466   m_iDefaultXSize = iDefaultXSize;
1467   m_iDefaultYSize = iDefaultYSize;
1468
1469   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1470   
1471   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
1472   
1473   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1474   
1475   std::ostringstream os;
1476   os << iDefaultXSize;
1477   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1478   std::ostringstream osYSize;
1479   osYSize << iDefaultYSize;
1480   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1481   
1482   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
1483   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1484   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
1485   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1486   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
1487   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
1488   
1489   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1490   
1491   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1492   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1493   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1494   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1495   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1496   
1497   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1498   pButtonOk->SetDefault();
1499
1500   SetAutoLayout (true);
1501   SetSizer (pTopSizer);
1502   pTopSizer->Fit (this);
1503   pTopSizer->SetSizeHints (this);
1504 }
1505
1506 DialogGetXYSize::~DialogGetXYSize ()
1507 {
1508 }
1509
1510 unsigned int
1511 DialogGetXYSize::getXSize ()
1512 {
1513   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1514   long lValue;
1515   if (strCtrl.ToLong (&lValue))
1516     return lValue;
1517   else
1518     return (m_iDefaultXSize);
1519 }
1520
1521 unsigned int
1522 DialogGetXYSize::getYSize ()
1523 {
1524   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1525   long lValue;
1526   if (strCtrl.ToLong (&lValue))
1527     return lValue;
1528   else
1529     return (m_iDefaultYSize);
1530 }
1531
1532
1533
1534 /////////////////////////////////////////////////////////////////////
1535 // CLASS IDENTIFICATION
1536 //
1537 // DialogGetConvertPolarParameters
1538 /////////////////////////////////////////////////////////////////////
1539
1540 DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pParent, const char* const pszTitle, 
1541        int iDefaultXSize, int iDefaultYSize, int iDefaultInterpolationID, int iDefaultZeropad, int iHelpID)
1542 : wxDialog (pParent, -1, _T(pszTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1543 {
1544   m_iDefaultXSize = iDefaultXSize;
1545   m_iDefaultYSize = iDefaultYSize;
1546   m_iDefaultZeropad = iDefaultZeropad;
1547
1548   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1549   
1550   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); 
1551   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1552   
1553   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (1);
1554   
1555   m_pRadioBoxInterpolation = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Projections::getInterpCount(), Projections::getInterpTitleArray(), Projections::getInterpNameArray());
1556   m_pRadioBoxInterpolation->SetSelection (iDefaultInterpolationID);
1557   pGridSizer->Add (m_pRadioBoxInterpolation, 0, wxALL | wxALIGN_CENTER);
1558   
1559   wxFlexGridSizer* pTextGridSizer = new wxFlexGridSizer (2);
1560   std::ostringstream os;
1561   os << iDefaultXSize;
1562   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);  
1563   pTextGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1564   pTextGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1565   std::ostringstream osYSize;
1566   osYSize << iDefaultYSize;
1567   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1568   pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1569   pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1570   if (m_iDefaultZeropad >= 0) {
1571     std::ostringstream osZeropad;
1572     osZeropad << iDefaultZeropad;
1573     m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1574     pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1575     pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1576   }
1577
1578   pGridSizer->Add (pTextGridSizer, 0, wxALIGN_CENTER | wxALL);
1579
1580   pTopSizer->Add (pGridSizer, 1, wxALL | wxALIGN_CENTER, 3);
1581   
1582   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1583   
1584   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1585   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1586   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1587   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1588   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1589   CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, iHelpID);
1590   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
1591   
1592   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1593   pButtonOk->SetDefault();
1594   SetAutoLayout (true);
1595   SetSizer (pTopSizer);
1596   pTopSizer->Layout();
1597   pTopSizer->Fit (this);
1598   pTopSizer->SetSizeHints (this);
1599 }
1600
1601
1602 DialogGetConvertPolarParameters::~DialogGetConvertPolarParameters ()
1603 {
1604 }
1605
1606
1607 unsigned int
1608 DialogGetConvertPolarParameters::getXSize ()
1609 {
1610   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1611   unsigned long lValue;
1612   if (strCtrl.ToULong (&lValue))
1613     return lValue;
1614   else
1615     return (m_iDefaultXSize);
1616 }
1617
1618 unsigned int
1619 DialogGetConvertPolarParameters::getYSize ()
1620 {
1621   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1622   unsigned long lValue;
1623   if (strCtrl.ToULong (&lValue))
1624     return lValue;
1625   else
1626     return (m_iDefaultYSize);
1627 }
1628
1629 unsigned int
1630 DialogGetConvertPolarParameters::getZeropad ()
1631 {
1632   if (m_iDefaultZeropad >= 0) {
1633     wxString strCtrl = m_pTextCtrlZeropad->GetValue();
1634     unsigned long lValue;
1635     if (strCtrl.ToULong (&lValue))
1636       return lValue;
1637     else
1638       return (m_iDefaultZeropad);
1639   } else
1640     return 0;
1641 }
1642
1643 const char*
1644 DialogGetConvertPolarParameters::getInterpolationName ()
1645 {
1646   return m_pRadioBoxInterpolation->getSelectionStringValue();
1647 }
1648