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