r540: Improved dialog boxes
[ctsim.git] / src / dialogs.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          dialogs.cpp
5 **   Purpose:       Dialog routines for CTSim program
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  July 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: dialogs.cpp,v 1.32 2001/02/14 18:39:47 kevin Exp $
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 #ifdef __GNUG__
29 // #pragma implementation
30 #endif
31
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
34
35 #ifdef __BORLANDC__
36 #pragma hdrstop
37 #endif
38
39 #ifndef WX_PRECOMP
40 #include "wx/wx.h"
41 #endif
42
43 #if !wxUSE_DOC_VIEW_ARCHITECTURE
44 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in setup.h!
45 #endif
46
47 #include "wx/statline.h"
48 #include "wx/sizer.h"
49 #include "dialogs.h"
50 #include "ctsim.h"
51 #include "ct.h"
52 #include "docs.h"
53 #include "views.h"
54 #include "imagefile.h"
55
56 #if defined(MSVC) || HAVE_SSTREAM
57 #include <sstream>
58 #else
59 #include <sstream_subst>
60 #endif
61
62
63 ///////////////////////////////////////////////////////////////////////
64 // CLASS IMPLEMENTATION
65 //    StringValueAndTitleListBox
66 ///////////////////////////////////////////////////////////////////////
67
68 StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[])
69 : wxListBox ()
70 {
71   wxString* psTitle = new wxString [nChoices];
72   for (int i = 0; i < nChoices; i++)
73     psTitle[i] = aszTitle[i];
74   
75   Create (pParent, -1, wxDefaultPosition, wxSize(-1,-1), nChoices, psTitle, wxLB_SINGLE | wxLB_NEEDED_SB);
76   
77   m_ppszValues = aszValue;
78   delete [] psTitle;
79 };
80
81 const char*
82 StringValueAndTitleListBox::getSelectionStringValue () const
83 {
84   return m_ppszValues[GetSelection()];
85 }
86
87 StringValueAndTitleRadioBox::StringValueAndTitleRadioBox (wxDialog* pParent, const wxString& strTitle, int nChoices, const char* aszTitle[], const char* aszValue[])
88 : wxRadioBox ()
89 {
90   wxString* psTitle = new wxString [nChoices];
91   for (int i = 0; i < nChoices; i++)
92     psTitle[i] = 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 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, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
113 {
114   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
115   
116   pTopSizer->Add (new wxStaticText (this, -1, "Select Phantom"), 0, wxALIGN_CENTER | wxALL, 5);
117   
118   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, 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 | wxEXPAND);
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, "Okay");
128   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
129   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
130   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
131   
132   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
133   
134   SetAutoLayout (true);
135   SetSizer (pTopSizer);
136   pTopSizer->Fit (this);
137   pTopSizer->SetSizeHints (this);
138 }
139
140 const char*
141 DialogGetPhantom::getPhantom()
142 {
143   return m_pRadioBoxPhantom->getSelectionStringValue();
144 }
145
146
147 ///////////////////////////////////////////////////////////////////////
148 // CLASS IMPLEMENTATION
149 //    DialogGetComparisonImage
150 ///////////////////////////////////////////////////////////////////////
151
152 DialogGetComparisonImage::DialogGetComparisonImage (wxWindow* pParent, const char* const pszTitle, const std::vector<ImageFileDocument*>& rVecIF, bool bShowMakeDifference)
153 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rVecIF(rVecIF)
154 {
155   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
156   
157   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxALL, 5);
158   
159   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
160   
161   int iNImages = m_rVecIF.size();
162   wxString* pstrImages = new wxString [iNImages];
163   for (int i = 0; i < iNImages; i++) {
164     ImageFileView* pView = dynamic_cast<ImageFileView*>(m_rVecIF[i]->GetFirstView());
165     if (pView)
166       pstrImages[i] = pView->getFrame()->GetTitle();
167   }
168
169   m_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE);
170   delete [] pstrImages;
171
172   m_pListBoxImageChoices->SetSelection (0);
173   pTopSizer->Add (m_pListBoxImageChoices, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
174   
175   if (bShowMakeDifference) {
176     m_pMakeDifferenceImage = new wxCheckBox (this, -1, "Make Difference Image");
177     m_pMakeDifferenceImage->SetValue (FALSE);
178     pTopSizer->Add (m_pMakeDifferenceImage, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
179   } else
180     m_pMakeDifferenceImage = NULL;
181
182   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
183   
184   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
185   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
186   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
187   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
188   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
189   
190   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
191   
192   SetAutoLayout (true);
193   SetSizer (pTopSizer);
194   pTopSizer->Fit (this);
195   pTopSizer->SetSizeHints (this);
196 }
197
198 ImageFileDocument*
199 DialogGetComparisonImage::getImageFileDocument()
200 {
201   return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ];
202 }
203
204 bool
205 DialogGetComparisonImage::getMakeDifferenceImage()
206 {
207   if (m_pMakeDifferenceImage)
208     return m_pMakeDifferenceImage->GetValue();
209   else
210     return false;
211 }
212
213
214 /////////////////////////////////////////////////////////////////////
215 // CLASS DiaglogPreferences Implementation
216 /////////////////////////////////////////////////////////////////////
217
218 DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTitle, 
219                                       bool bAdvancedOptions, bool bAskDeleteNewDocs)
220 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
221 {
222   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
223   
224   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
225   
226   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
227
228   m_pCBAdvancedOptions = new wxCheckBox (this, -1, "Advanced Options", wxDefaultPosition, wxSize(250, 25), 0);
229   m_pCBAdvancedOptions->SetValue (bAdvancedOptions);
230   pTopSizer->Add (m_pCBAdvancedOptions, 0, wxALIGN_CENTER_VERTICAL);
231
232   m_pCBAskDeleteNewDocs = new wxCheckBox (this, -1, "Ask \"Save New Documents\" Before Closing", wxDefaultPosition, wxSize(250, 25), 0);
233   m_pCBAskDeleteNewDocs->SetValue (bAskDeleteNewDocs);
234   pTopSizer->Add (m_pCBAskDeleteNewDocs, 0, wxALIGN_CENTER_VERTICAL);
235
236   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
237   
238   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
239   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
240   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
241   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
242   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
243   
244   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
245   
246   SetAutoLayout (true);
247   SetSizer (pTopSizer);
248   pTopSizer->Fit (this);
249   pTopSizer->SetSizeHints (this);
250 }
251
252 DialogPreferences::~DialogPreferences ()
253 {
254 }
255
256 bool
257 DialogPreferences::getAdvancedOptions ()
258 {
259   return static_cast<bool>(m_pCBAdvancedOptions->GetValue());
260 }
261
262 bool
263 DialogPreferences::getAskDeleteNewDocs ()
264 {
265   return static_cast<bool>(m_pCBAskDeleteNewDocs->GetValue());
266 }
267
268
269 /////////////////////////////////////////////////////////////////////
270 // CLASS DiaglogGetMinMax Implementation
271 /////////////////////////////////////////////////////////////////////
272
273 DialogGetMinMax::DialogGetMinMax (wxWindow* pParent, const char* const pszTitle, double dDefaultMin, double dDefaultMax)
274 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
275 {
276   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
277   
278   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
279   
280   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
281   
282   std::ostringstream os;
283   os << dDefaultMin;
284   m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
285   std::ostringstream osMax;
286   osMax << dDefaultMax;
287   m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
288   
289   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
290   pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
291   pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
292   pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
293   pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
294   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
295   
296   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
297   
298   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
299   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
300   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
301   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
302   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
303   
304   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
305   
306   SetAutoLayout (true);
307   SetSizer (pTopSizer);
308   pTopSizer->Fit (this);
309   pTopSizer->SetSizeHints (this);
310 }
311
312 DialogGetMinMax::~DialogGetMinMax ()
313 {
314 }
315
316 double
317 DialogGetMinMax::getMinimum ()
318 {
319   wxString strCtrl = m_pTextCtrlMin->GetValue();
320   double dValue;
321   if (strCtrl.ToDouble (&dValue))
322     return dValue;
323   else
324     return (m_dDefaultMin);
325 }
326
327 double
328 DialogGetMinMax::getMaximum ()
329 {
330   wxString strCtrl = m_pTextCtrlMax->GetValue();
331   double dValue;
332   if (strCtrl.ToDouble (&dValue))
333     return dValue;
334   else
335     return (m_dDefaultMax);
336 }
337
338
339 /////////////////////////////////////////////////////////////////////
340 // CLASS DialogAutoScaleParameters IMPLEMENTATION
341 /////////////////////////////////////////////////////////////////////
342
343 DialogAutoScaleParameters::DialogAutoScaleParameters (wxWindow *pParent, double mean, double mode, double median, double stddev, double dDefaultScaleFactor)
344 : wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_dMean(mean), m_dMode(mode), m_dMedian(median), m_dStdDev(stddev)
345 {
346   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
347   
348   pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
349   
350   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
351   
352   wxString asTitle[] = {"Median", "Mode", "Mean"};
353   
354   m_pRadioBoxCenter = new wxRadioBox (this, -1, _T("Center"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS);
355   m_pRadioBoxCenter->SetSelection (0);
356   pTopSizer->Add (m_pRadioBoxCenter, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
357   
358   wxGridSizer *pGridSizer = new wxGridSizer (2);
359   pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
360   std::ostringstream osDefaultFactor;
361   osDefaultFactor << dDefaultScaleFactor;
362   m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, osDefaultFactor.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
363   pGridSizer->Add (m_pTextCtrlStdDevFactor, 0, wxALIGN_CENTER_VERTICAL);
364   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
365   
366   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
367   
368   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
369   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
370   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
371   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
372   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
373   
374   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
375   
376   SetAutoLayout (true);
377   SetSizer (pTopSizer);
378   pTopSizer->Fit (this);
379   pTopSizer->SetSizeHints (this);
380 }
381
382 bool
383 DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax)
384 {
385   int iCenter = m_pRadioBoxCenter->GetSelection();
386   double dCenter = m_dMedian;
387   if (iCenter == 1)
388     dCenter = m_dMode;
389   else if (iCenter == 2)
390     dCenter = m_dMode;
391   
392   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();
393   double dValue;
394   if (! sStddevFactor.ToDouble (&dValue)) {
395     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";
396     return false;
397   }
398   double dHalfWidth = dValue * m_dStdDev / 2;
399   *pMin = dCenter - dHalfWidth;
400   *pMax = dCenter + dHalfWidth;
401   *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n";
402   
403   return true;
404 }
405
406 double
407 DialogAutoScaleParameters::getAutoScaleFactor ()
408 {
409   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();
410   double dValue = 1.;
411   if (! sStddevFactor.ToDouble (&dValue)) {
412     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";
413   }
414   
415   return dValue;
416 }
417
418
419 /////////////////////////////////////////////////////////////////////
420 // CLASS IDENTIFICATION
421 //
422 // DialogGetRasterParameters
423 /////////////////////////////////////////////////////////////////////
424
425 DialogGetRasterParameters::DialogGetRasterParameters 
426    (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples, double dDefaultViewRatio)
427 : wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
428 {
429   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
430   
431   pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
432   
433   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
434     
435   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
436   std::ostringstream os;
437   os << iDefaultXSize;
438   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
439   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
440   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
441   std::ostringstream osYSize;
442   osYSize << iDefaultYSize;
443   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
444   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
445   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
446   std::ostringstream osViewRatio;
447   osViewRatio << dDefaultViewRatio;
448   m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
449   pGridSizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
450   pGridSizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL);
451   std::ostringstream osNSamples;
452   osNSamples << iDefaultNSamples;
453   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
454   pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
455   pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
456
457   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
458   
459   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
460   
461   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
462   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
463   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
464   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
465   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
466   
467   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
468   
469   SetAutoLayout (true);
470   SetSizer (pTopSizer);
471   pTopSizer->Fit (this);
472   pTopSizer->SetSizeHints (this);
473 }
474
475 DialogGetRasterParameters::~DialogGetRasterParameters ()
476 {
477 }
478
479
480 unsigned int
481 DialogGetRasterParameters::getXSize ()
482 {
483   wxString strCtrl = m_pTextCtrlXSize->GetValue();
484   unsigned long lValue;
485   if (strCtrl.ToULong (&lValue))
486     return lValue;
487   else
488     return (m_iDefaultXSize);
489 }
490
491 unsigned int
492 DialogGetRasterParameters::getYSize ()
493 {
494   wxString strCtrl = m_pTextCtrlYSize->GetValue();
495   unsigned long lValue;
496   if (strCtrl.ToULong (&lValue))
497     return lValue;
498   else
499     return (m_iDefaultYSize);
500 }
501
502 unsigned int
503 DialogGetRasterParameters::getNSamples ()
504 {
505   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
506   unsigned long lValue;
507   if (strCtrl.ToULong (&lValue))
508     return lValue;
509   else
510     return (m_iDefaultNSamples);
511 }
512
513 double
514 DialogGetRasterParameters::getViewRatio ()
515 {
516   wxString strCtrl = m_pTextCtrlViewRatio->GetValue();
517   double dValue;
518   if (strCtrl.ToDouble (&dValue))
519     return dValue;
520   else
521     return (m_dDefaultViewRatio);
522 }
523
524
525 /////////////////////////////////////////////////////////////////////
526 // CLASS IDENTIFICATION
527 //
528 // DialogGetProjectionParameters
529 /////////////////////////////////////////////////////////////////////
530
531
532 DialogGetProjectionParameters::DialogGetProjectionParameters 
533    (wxWindow* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultNSamples, 
534     double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultViewRatio,
535     double dDefaultScanRatio, int iDefaultGeometry, int iDefaultTrace)
536 : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
537 {
538   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
539   
540   m_dDefaultRotAngle = dDefaultRotAngle;
541   m_dDefaultFocalLength = dDefaultFocalLength;
542   m_dDefaultViewRatio = dDefaultViewRatio;
543   m_dDefaultScanRatio = dDefaultScanRatio;
544   m_iDefaultNSamples = iDefaultNSamples;
545   m_iDefaultNView = iDefaultNView;
546   m_iDefaultNDet = iDefaultNDet;
547   m_iDefaultTrace = iDefaultTrace;
548   m_iDefaultGeometry = iDefaultGeometry;
549   
550   pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
551   
552   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
553     
554   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
555   m_pRadioBoxGeometry = new StringValueAndTitleRadioBox (this, _T("Geometry"), Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray());
556   m_pRadioBoxGeometry->SetSelection (iDefaultGeometry);
557   
558   pGridSizer->Add (m_pRadioBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
559   
560   m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), Trace::getTraceCount(), Trace::getTraceTitleArray(), Trace::getTraceNameArray());
561   m_pRadioBoxTrace->SetSelection (iDefaultTrace);
562   pGridSizer->Add (m_pRadioBoxTrace, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
563
564           wxFlexGridSizer* pText1Sizer = new wxFlexGridSizer(2);
565   std::ostringstream os;
566   os << iDefaultNDet;
567   m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
568   pText1Sizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
569   pText1Sizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL);
570   std::ostringstream osNView;
571   osNView << iDefaultNView;
572   m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
573   pText1Sizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
574   pText1Sizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL);
575   std::ostringstream osNSamples;
576   osNSamples << iDefaultNSamples;
577   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
578   pText1Sizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
579   pText1Sizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
580
581   pGridSizer->Add (pText1Sizer);
582
583   wxFlexGridSizer* pText2Sizer = new wxFlexGridSizer(2);
584   std::ostringstream osViewRatio;
585   osViewRatio << dDefaultViewRatio;
586   m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
587   pText2Sizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
588   pText2Sizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL);
589   std::ostringstream osScanRatio;
590   osScanRatio << dDefaultScanRatio;
591   m_pTextCtrlScanRatio = new wxTextCtrl (this, -1, osScanRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
592   pText2Sizer->Add (new wxStaticText (this, -1, "Scan Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
593   pText2Sizer->Add (m_pTextCtrlScanRatio, 0, wxALIGN_CENTER_VERTICAL);
594   std::ostringstream osFocalLength;
595   osFocalLength << dDefaultFocalLength;
596   m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
597   pText2Sizer->Add (new wxStaticText (this, -1, "Focal Length Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
598   pText2Sizer->Add (m_pTextCtrlFocalLength, 0, wxALIGN_CENTER_VERTICAL);
599   
600   if (theApp->getAdvancedOptions()) {
601     std::ostringstream osRotAngle;
602     osRotAngle << dDefaultRotAngle;
603     m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
604     pText2Sizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
605     pText2Sizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
606   }
607   pGridSizer->Add (pText2Sizer);
608
609   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
610   
611   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
612   
613   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
614   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
615   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
616   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
617   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
618   
619   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
620   
621   SetAutoLayout (true);
622   SetSizer (pTopSizer);
623   pTopSizer->Fit (this);
624   pTopSizer->SetSizeHints (this);
625 }
626
627 DialogGetProjectionParameters::~DialogGetProjectionParameters ()
628 {
629 }
630
631
632 unsigned int
633 DialogGetProjectionParameters::getNDet ()
634 {
635   wxString strCtrl = m_pTextCtrlNDet->GetValue();
636   unsigned long lValue;
637   if (strCtrl.ToULong (&lValue))
638     return lValue;
639   else
640     return (m_iDefaultNDet);
641 }
642
643 unsigned int
644 DialogGetProjectionParameters::getNView ()
645 {
646   wxString strCtrl = m_pTextCtrlNView->GetValue();
647   unsigned long lValue;
648   if (strCtrl.ToULong (&lValue))
649     return lValue;
650   else
651     return (m_iDefaultNView);
652 }
653
654
655 unsigned int
656 DialogGetProjectionParameters::getNSamples ()
657 {
658   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
659   unsigned long lValue;
660   if (strCtrl.ToULong (&lValue))
661     return lValue;
662   else
663     return (m_iDefaultNSamples);
664 }
665
666 double
667 DialogGetProjectionParameters::getRotAngle ()
668 {
669   if (theApp->getAdvancedOptions()) {
670     wxString strCtrl = m_pTextCtrlRotAngle->GetValue();
671     double dValue;
672     if (strCtrl.ToDouble (&dValue))
673       return (dValue * PI);
674     else
675       return (m_dDefaultRotAngle);
676   } else {
677     if (Scanner::convertGeometryNameToID (m_pRadioBoxGeometry->getSelectionStringValue()) == 
678           Scanner::GEOMETRY_PARALLEL)
679       return (PI);
680     else
681       return (2 * PI);
682   }
683 }
684
685 double
686 DialogGetProjectionParameters::getFocalLengthRatio ()
687 {
688   wxString strCtrl = m_pTextCtrlFocalLength->GetValue();
689   double dValue;
690   if (strCtrl.ToDouble (&dValue))
691     return (dValue);
692   else
693     return (m_dDefaultFocalLength);
694 }
695
696 double
697 DialogGetProjectionParameters::getViewRatio ()
698 {
699   wxString strCtrl = m_pTextCtrlViewRatio->GetValue();
700   double dValue;
701   if (strCtrl.ToDouble (&dValue))
702     return (dValue);
703   else
704     return (m_dDefaultViewRatio);
705 }
706
707 double
708 DialogGetProjectionParameters::getScanRatio ()
709 {
710   wxString strCtrl = m_pTextCtrlScanRatio->GetValue();
711   double dValue;
712   if (strCtrl.ToDouble (&dValue))
713     return (dValue);
714   else
715     return (m_dDefaultScanRatio);
716 }
717
718 const char*
719 DialogGetProjectionParameters::getGeometry ()
720 {
721   return m_pRadioBoxGeometry->getSelectionStringValue();
722 }
723
724 int
725 DialogGetProjectionParameters::getTrace ()
726 {
727   return Trace::convertTraceNameToID(m_pRadioBoxTrace->getSelectionStringValue());
728 }
729
730
731
732 /////////////////////////////////////////////////////////////////////
733 // CLASS IDENTIFICATION
734 //
735 // DialogGetReconstructionParameters
736 /////////////////////////////////////////////////////////////////////
737
738
739 DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxWindow* pParent, int iDefaultXSize, 
740                      int iDefaultYSize, int iDefaultFilterID, double dDefaultHammingParam,  
741                      int iDefaultFilterMethodID, int iDefaultFilterGenerationID, int iDefaultZeropad, 
742                      int iDefaultInterpID, int iDefaultInterpParam, int iDefaultBackprojectID, int iTrace)
743 : wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
744 {
745   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
746   
747   pTopSizer->Add (new wxStaticText (this, -1, "Set Reconstruction Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
748   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
749   
750   wxFlexGridSizer* pGridSizer = NULL;
751   if (theApp->getAdvancedOptions())
752     pGridSizer = new wxFlexGridSizer (4);
753   else
754     pGridSizer = new wxFlexGridSizer (3);
755
756   if (theApp->getAdvancedOptions())
757     m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
758   else
759     m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getReconstructFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
760   m_pRadioBoxFilter->SetSelection (iDefaultFilterID);
761   pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
762   
763   m_pRadioBoxFilterMethod = new StringValueAndTitleRadioBox (this, _T("Filter Method"), ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray());
764   m_pRadioBoxFilterMethod->SetSelection (iDefaultFilterMethodID);
765   pGridSizer->Add (m_pRadioBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
766   
767   if (theApp->getAdvancedOptions()) {
768     m_pRadioBoxFilterGeneration = new StringValueAndTitleRadioBox (this, _T("Filter Generation"), ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray());
769     m_pRadioBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID);
770     pGridSizer->Add (m_pRadioBoxFilterGeneration, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
771   
772     m_pRadioBoxBackproject = new StringValueAndTitleRadioBox (this, _T("Backprojection"), Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray());
773     m_pRadioBoxBackproject->SetSelection (iDefaultBackprojectID);
774     pGridSizer->Add (m_pRadioBoxBackproject, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
775   }
776
777   m_pRadioBoxInterp = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray());
778   m_pRadioBoxInterp->SetSelection (iDefaultInterpID);
779   pGridSizer->Add (m_pRadioBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
780   
781   static const char* aszTraceTitle[] = {"None", "Full"};
782   static const char* aszTraceName[] = {"none", "full"};
783   m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), 2, aszTraceTitle, aszTraceName);
784   iTrace = clamp(iTrace, 0, 1);
785   m_pRadioBoxTrace->SetSelection (iTrace);
786   pGridSizer->Add (m_pRadioBoxTrace);
787
788   wxFlexGridSizer* pTextGridSizer = new wxFlexGridSizer (2);
789   std::ostringstream os;
790   os << iDefaultXSize;
791   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
792   pTextGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
793   pTextGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
794   std::ostringstream osYSize;
795   osYSize << iDefaultYSize;
796   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
797   pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
798   pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
799
800   std::ostringstream osHammingParam;
801   osHammingParam << dDefaultHammingParam;
802   m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osHammingParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
803   pTextGridSizer->Add (new wxStaticText (this, -1, "Hamming Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
804   pTextGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
805
806   if (theApp->getAdvancedOptions()) {
807     std::ostringstream osZeropad;
808     osZeropad << iDefaultZeropad;
809     m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
810     pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
811     pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
812   }
813   pGridSizer->Add (pTextGridSizer);
814
815 #if HAVE_FREQ_PREINTERP
816   std::ostringstream osInterpParam;
817   osInterpParam << iDefaultInterpParam;
818   m_pTextCtrlInterpParam = new wxTextCtrl (this, -1, osInterpParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
819   pGridSizer->Add (new wxStaticText (this, -1, "Interpolation Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
820   pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
821 #endif  
822   
823   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
824   
825   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
826   
827   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
828   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
829   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
830   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
831   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
832   
833   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
834   
835   SetAutoLayout (true);
836   SetSizer (pTopSizer);
837   pTopSizer->Layout();
838   pTopSizer->Fit (this);
839   pTopSizer->SetSizeHints (this);
840 }
841
842 DialogGetReconstructionParameters::~DialogGetReconstructionParameters ()
843 {
844 }
845
846
847 unsigned int
848 DialogGetReconstructionParameters::getXSize ()
849 {
850   wxString strCtrl = m_pTextCtrlXSize->GetValue();
851   unsigned long lValue;
852   if (strCtrl.ToULong (&lValue))
853     return lValue;
854   else
855     return (m_iDefaultXSize);
856 }
857
858 unsigned int
859 DialogGetReconstructionParameters::getYSize ()
860 {
861   wxString strCtrl = m_pTextCtrlYSize->GetValue();
862   unsigned long lValue;
863   if (strCtrl.ToULong (&lValue))
864     return lValue;
865   else
866     return (m_iDefaultYSize);
867 }
868
869 unsigned int
870 DialogGetReconstructionParameters::getZeropad ()
871 {
872   if (theApp->getAdvancedOptions()) {
873     wxString strCtrl = m_pTextCtrlZeropad->GetValue();
874     unsigned long lValue;
875     if (strCtrl.ToULong (&lValue))
876       return lValue;
877     else
878       return (m_iDefaultZeropad);
879   } else
880     return 1;
881 }
882
883
884 unsigned int
885 DialogGetReconstructionParameters::getInterpParam ()
886 {
887 #if HAVE_FREQ_PREINTERP
888   wxString strCtrl = m_pTextCtrlInterpParam->GetValue();
889   unsigned long lValue;
890   if (strCtrl.ToULong (&lValue))
891     return lValue;
892   else
893     return (m_iDefaultInterpParam);
894 #else
895   return 1;
896 #endif
897 }
898
899 double
900 DialogGetReconstructionParameters::getFilterParam ()
901 {
902   wxString strCtrl = m_pTextCtrlFilterParam->GetValue();
903   double dValue;
904   if (strCtrl.ToDouble (&dValue))
905     return (dValue);
906   else
907     return (m_dDefaultFilterParam);
908 }
909
910 const char*
911 DialogGetReconstructionParameters::getFilterName ()
912 {
913   return m_pRadioBoxFilter->getSelectionStringValue();
914 }
915
916 const char*
917 DialogGetReconstructionParameters::getFilterMethodName ()
918 {
919   return m_pRadioBoxFilterMethod->getSelectionStringValue();
920 }
921
922 const char*
923 DialogGetReconstructionParameters::getInterpName ()
924 {
925   return m_pRadioBoxInterp->getSelectionStringValue();
926 }
927
928 int
929 DialogGetReconstructionParameters::getTrace ()
930 {
931   int iTrace = 0;
932   if (strcmp("full", m_pRadioBoxTrace->getSelectionStringValue()) == 0)
933     iTrace = Trace::TRACE_PLOT;
934   return iTrace;
935 }
936
937 const char*
938 DialogGetReconstructionParameters::getBackprojectName ()
939 {
940   if (theApp->getAdvancedOptions()) {
941     return m_pRadioBoxBackproject->getSelectionStringValue();
942   } else
943     return "idiff";
944 }
945
946 const char*
947 DialogGetReconstructionParameters::getFilterGenerationName ()
948 {
949   if (theApp->getAdvancedOptions()) {
950     return m_pRadioBoxFilterGeneration->getSelectionStringValue();
951   } else {
952     if (ProcessSignal::convertFilterMethodNameToID(m_pRadioBoxFilterMethod->getSelectionStringValue())
953         == ProcessSignal::FILTER_METHOD_CONVOLUTION)
954       return "direct";
955     else
956       return "inverse-fourier";
957   }
958 }
959
960
961 /////////////////////////////////////////////////////////////////////
962 // CLASS IDENTIFICATION
963 //
964 // DialogGetFilterParameters
965 /////////////////////////////////////////////////////////////////////
966
967
968
969 DialogGetFilterParameters::DialogGetFilterParameters (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultFilterID, double dDefaultFilterParam,  double dDefaultBandwidth, int iDefaultDomainID, double dDefaultInputScale, double dDefaultOutputScale)
970 : wxDialog (pParent, -1, "Set Filter Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
971 {
972   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
973   
974   pTopSizer->Add (new wxStaticText (this, -1, "Set Filter Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); 
975   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
976   
977   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
978
979   m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
980   m_pRadioBoxFilter->SetSelection (iDefaultFilterID);
981   pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
982   
983   m_pRadioBoxDomain = new StringValueAndTitleRadioBox (this, _T("Domain"), SignalFilter::getDomainCount(), SignalFilter::getDomainTitleArray(), SignalFilter::getDomainNameArray());
984   m_pRadioBoxDomain->SetSelection (iDefaultDomainID);
985   pGridSizer->Add (m_pRadioBoxDomain, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
986   
987   std::ostringstream os;
988   os << iDefaultXSize;
989   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
990   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
991   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
992
993   std::ostringstream osYSize;
994   osYSize << iDefaultYSize;
995   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
996   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
997   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
998
999   std::ostringstream osFilterParam;
1000   osFilterParam << dDefaultFilterParam;
1001   m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1002   pGridSizer->Add (new wxStaticText (this, -1, "Filter Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1003   pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1004
1005   std::ostringstream osBandwidth;
1006   osBandwidth << dDefaultBandwidth;
1007   m_pTextCtrlBandwidth = new wxTextCtrl (this, -1, osBandwidth.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1008   pGridSizer->Add (new wxStaticText (this, -1, "Bandwidth"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1009   pGridSizer->Add (m_pTextCtrlBandwidth, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1010
1011   std::ostringstream osInputScale;
1012   osInputScale << dDefaultInputScale;
1013   m_pTextCtrlInputScale = new wxTextCtrl (this, -1, osInputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1014   pGridSizer->Add (new wxStaticText (this, -1, "Axis (input) Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1015   pGridSizer->Add (m_pTextCtrlInputScale, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1016
1017   std::ostringstream osOutputScale;
1018   osOutputScale << dDefaultOutputScale;
1019   m_pTextCtrlOutputScale = new wxTextCtrl (this, -1, osOutputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1020   pGridSizer->Add (new wxStaticText (this, -1, "Filter Output Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1021   pGridSizer->Add (m_pTextCtrlOutputScale, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1022   
1023   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
1024   
1025   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1026   
1027   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1028   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1029   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1030   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1031   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1032   
1033   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1034   
1035   SetAutoLayout (true);
1036   SetSizer (pTopSizer);
1037   pTopSizer->Layout();
1038   pTopSizer->Fit (this);
1039   pTopSizer->SetSizeHints (this);
1040 }
1041
1042 DialogGetFilterParameters::~DialogGetFilterParameters ()
1043 {
1044 }
1045
1046
1047 unsigned int
1048 DialogGetFilterParameters::getXSize ()
1049 {
1050   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1051   unsigned long lValue;
1052   if (strCtrl.ToULong (&lValue))
1053     return lValue;
1054   else
1055     return (m_iDefaultXSize);
1056 }
1057
1058 unsigned int
1059 DialogGetFilterParameters::getYSize ()
1060 {
1061   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1062   unsigned long lValue;
1063   if (strCtrl.ToULong (&lValue))
1064     return lValue;
1065   else
1066     return (m_iDefaultYSize);
1067 }
1068
1069 double
1070 DialogGetFilterParameters::getBandwidth ()
1071 {
1072   wxString strCtrl = m_pTextCtrlBandwidth->GetValue();
1073   double dValue;
1074   if (strCtrl.ToDouble (&dValue))
1075     return dValue;
1076   else
1077     return (m_dDefaultBandwidth);
1078 }
1079
1080 double
1081 DialogGetFilterParameters::getFilterParam ()
1082 {
1083   wxString strCtrl = m_pTextCtrlFilterParam->GetValue();
1084   double dValue;
1085   if (strCtrl.ToDouble (&dValue))
1086     return (dValue);
1087   else
1088     return (m_dDefaultFilterParam);
1089 }
1090
1091 double
1092 DialogGetFilterParameters::getInputScale ()
1093 {
1094   wxString strCtrl = m_pTextCtrlInputScale->GetValue();
1095   double dValue;
1096   if (strCtrl.ToDouble (&dValue))
1097     return dValue;
1098   else
1099     return (m_dDefaultInputScale);
1100 }
1101
1102 double
1103 DialogGetFilterParameters::getOutputScale ()
1104 {
1105   wxString strCtrl = m_pTextCtrlOutputScale->GetValue();
1106   double dValue;
1107   if (strCtrl.ToDouble (&dValue))
1108     return dValue;
1109   else
1110     return (m_dDefaultOutputScale);
1111 }
1112
1113 const char*
1114 DialogGetFilterParameters::getFilterName ()
1115 {
1116   return m_pRadioBoxFilter->getSelectionStringValue();
1117 }
1118
1119 const char*
1120 DialogGetFilterParameters::getDomainName ()
1121 {
1122   return m_pRadioBoxDomain->getSelectionStringValue();
1123 }
1124
1125
1126 ///////////////////////////////////////////////////////////////////////
1127 // CLASS IMPLEMENTATION
1128 //    DialogExportParameters
1129 ///////////////////////////////////////////////////////////////////////
1130
1131 DialogExportParameters::DialogExportParameters (wxWindow* pParent, int iDefaultFormatID)
1132 : wxDialog (pParent, -1, "Select ExportParameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1133 {
1134   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1135   
1136   pTopSizer->Add (new wxStaticText (this, -1, "Select Export Format"), 0, wxALIGN_CENTER | wxALL, 5);
1137   
1138   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
1139   
1140   m_pRadioBoxFormat = new StringValueAndTitleRadioBox (this, _T("Export Type"), ImageFile::getFormatCount(), ImageFile::getFormatTitleArray(), ImageFile::getFormatNameArray());
1141   m_pRadioBoxFormat->SetSelection (iDefaultFormatID);
1142   pTopSizer->Add (m_pRadioBoxFormat, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
1143   
1144   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1145   
1146   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1147   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1148   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1149   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1150   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1151   
1152   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1153   
1154   SetAutoLayout (true);
1155   SetSizer (pTopSizer);
1156   pTopSizer->Fit (this);
1157   pTopSizer->SetSizeHints (this);
1158 }
1159
1160 const char*
1161 DialogExportParameters::getFormatName()
1162 {
1163   return m_pRadioBoxFormat->getSelectionStringValue();
1164 }
1165
1166
1167 /////////////////////////////////////////////////////////////////////
1168 // CLASS DiaglogGetXYSize Implementation
1169 /////////////////////////////////////////////////////////////////////
1170
1171 DialogGetXYSize::DialogGetXYSize (wxWindow* pParent, const char* const pszTitle, int iDefaultXSize, int iDefaultYSize)
1172 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1173 {
1174   m_iDefaultXSize = iDefaultXSize;
1175   m_iDefaultYSize = iDefaultYSize;
1176
1177   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1178   
1179   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
1180   
1181   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1182   
1183   std::ostringstream os;
1184   os << iDefaultXSize;
1185   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1186   std::ostringstream osYSize;
1187   osYSize << iDefaultYSize;
1188   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1189   
1190   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
1191   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1192   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
1193   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1194   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
1195   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
1196   
1197   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1198   
1199   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1200   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1201   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1202   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1203   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1204   
1205   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1206   
1207   SetAutoLayout (true);
1208   SetSizer (pTopSizer);
1209   pTopSizer->Fit (this);
1210   pTopSizer->SetSizeHints (this);
1211 }
1212
1213 DialogGetXYSize::~DialogGetXYSize ()
1214 {
1215 }
1216
1217 unsigned int
1218 DialogGetXYSize::getXSize ()
1219 {
1220   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1221   long lValue;
1222   if (strCtrl.ToLong (&lValue))
1223     return lValue;
1224   else
1225     return (m_iDefaultXSize);
1226 }
1227
1228 unsigned int
1229 DialogGetXYSize::getYSize ()
1230 {
1231   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1232   long lValue;
1233   if (strCtrl.ToLong (&lValue))
1234     return lValue;
1235   else
1236     return (m_iDefaultYSize);
1237 }
1238
1239
1240
1241 /////////////////////////////////////////////////////////////////////
1242 // CLASS IDENTIFICATION
1243 //
1244 // DialogGetConvertPolarParameters
1245 /////////////////////////////////////////////////////////////////////
1246
1247 DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pParent, const char* const pszTitle, 
1248        int iDefaultXSize, int iDefaultYSize, int iDefaultInterpolationID, int iDefaultZeropad)
1249 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
1250 {
1251   m_iDefaultXSize = iDefaultXSize;
1252   m_iDefaultYSize = iDefaultYSize;
1253   m_iDefaultZeropad = iDefaultZeropad;
1254
1255   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
1256   
1257   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
1258   
1259   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1260   
1261   std::ostringstream os;
1262   os << iDefaultXSize;
1263   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1264   std::ostringstream osYSize;
1265   osYSize << iDefaultYSize;
1266   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1267   
1268   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
1269   
1270   m_pRadioBoxInterpolation = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Projections::getInterpCount(), Projections::getInterpTitleArray(), Projections::getInterpNameArray());
1271   m_pRadioBoxInterpolation->SetSelection (iDefaultInterpolationID);
1272   pGridSizer->Add (m_pRadioBoxInterpolation, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
1273   
1274   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1275   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1276   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1277   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1278   if (iDefaultZeropad >= 0) {
1279     std::ostringstream osZeropad;
1280     osZeropad << iDefaultZeropad;
1281     m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
1282     pGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
1283     pGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
1284   }
1285   
1286   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
1287   
1288   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
1289   
1290   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
1291   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
1292   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
1293   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
1294   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
1295   
1296   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
1297   
1298   SetAutoLayout (true);
1299   SetSizer (pTopSizer);
1300   pTopSizer->Layout();
1301   pTopSizer->Fit (this);
1302   pTopSizer->SetSizeHints (this);
1303 }
1304
1305
1306 DialogGetConvertPolarParameters::~DialogGetConvertPolarParameters ()
1307 {
1308 }
1309
1310
1311 unsigned int
1312 DialogGetConvertPolarParameters::getXSize ()
1313 {
1314   wxString strCtrl = m_pTextCtrlXSize->GetValue();
1315   unsigned long lValue;
1316   if (strCtrl.ToULong (&lValue))
1317     return lValue;
1318   else
1319     return (m_iDefaultXSize);
1320 }
1321
1322 unsigned int
1323 DialogGetConvertPolarParameters::getYSize ()
1324 {
1325   wxString strCtrl = m_pTextCtrlYSize->GetValue();
1326   unsigned long lValue;
1327   if (strCtrl.ToULong (&lValue))
1328     return lValue;
1329   else
1330     return (m_iDefaultYSize);
1331 }
1332
1333 unsigned int
1334 DialogGetConvertPolarParameters::getZeropad ()
1335 {
1336   wxString strCtrl = m_pTextCtrlZeropad->GetValue();
1337   unsigned long lValue;
1338   if (strCtrl.ToULong (&lValue))
1339     return lValue;
1340   else
1341     return (m_iDefaultZeropad);
1342 }
1343
1344 const char*
1345 DialogGetConvertPolarParameters::getInterpolationName ()
1346 {
1347   return m_pRadioBoxInterpolation->getSelectionStringValue();
1348 }
1349