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