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