r311: image comparison functions
[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-2000 Kevin Rosenberg
11 **
12 **  $Id: dialogs.cpp,v 1.20 2000/12/22 04:18:00 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 "ctsupport.h"
51 #include "ctsim.h"
52 #include "scanner.h"
53 #include "phantom.h"
54 #include "filter.h"
55 #include "backprojectors.h"
56 #include "docs.h"\r
57 #include "views.h"\r
58 #include "imagefile.h"\r
59
60 #if defined(MSVC) || HAVE_SSTREAM\r
61 #include <sstream>\r
62 #else\r
63 #include <sstream_subst>\r
64 #endif\r
65 \r
66
67 ///////////////////////////////////////////////////////////////////////\r
68 // CLASS IMPLEMENTATION\r
69 //    StringValueAndTitleListBox\r
70 ///////////////////////////////////////////////////////////////////////\r
71 \r
72 StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[])
73 : wxListBox ()
74 {
75   wxString* psTitle = new wxString [nChoices];
76   for (int i = 0; i < nChoices; i++)
77     psTitle[i] = aszTitle[i];
78   
79   Create (pParent, -1, wxDefaultPosition, wxSize(200,-1), nChoices, psTitle, wxLB_SINGLE | wxLB_NEEDED_SB);
80   
81   m_ppszValues = aszValue;\r
82   delete [] psTitle;
83 };
84
85 const char*
86 StringValueAndTitleListBox::getSelectionStringValue (void) const
87 {
88   return m_ppszValues[GetSelection()];
89 }
90
91
92 ///////////////////////////////////////////////////////////////////////\r
93 // CLASS IMPLEMENTATION\r
94 //    DialogGetPhantom\r
95 ///////////////////////////////////////////////////////////////////////\r
96
97 DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, int iDefaultPhantom)
98 : wxDialog (pParent, -1, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
99 {
100   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
101   
102   pTopSizer->Add (new wxStaticText (this, -1, "Select Phantom"), 0, wxALIGN_CENTER | wxALL, 5);
103   
104   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);
105   
106   m_pListBoxPhantom = new StringValueAndTitleListBox (this, Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray());
107   m_pListBoxPhantom->SetSelection (iDefaultPhantom);
108   pTopSizer->Add (m_pListBoxPhantom, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
109   
110   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
111   
112   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
113   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
114   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
115   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
116   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
117   
118   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
119   
120   SetAutoLayout (true);
121   SetSizer (pTopSizer);
122   pTopSizer->Fit (this);
123   pTopSizer->SetSizeHints (this);
124 }
125
126 const char*
127 DialogGetPhantom::getPhantom(void)
128 {
129   return m_pListBoxPhantom->getSelectionStringValue();
130 }
131
132 \r
133 ///////////////////////////////////////////////////////////////////////\r
134 // CLASS IMPLEMENTATION\r
135 //    DialogGetComparisonImage\r
136 ///////////////////////////////////////////////////////////////////////\r
137 \r
138 DialogGetComparisonImage::DialogGetComparisonImage (wxFrame* pParent, const char* const pszTitle, const std::vector<ImageFileDocument*>& rVecIF, bool bShowMakeDifference)\r
139 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rVecIF(rVecIF)\r
140 {\r
141   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);\r
142   \r
143   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxALL, 5);\r
144   \r
145   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5);\r
146   \r
147   int iNImages = m_rVecIF.size();\r
148   wxString* pstrImages = new wxString [iNImages];\r
149   for (int i = 0; i < iNImages; i++) {\r
150     ImageFileView* pView = dynamic_cast<ImageFileView*>(m_rVecIF[i]->GetFirstView());\r
151     if (pView)\r
152       pstrImages[i] = pView->getFrame()->GetTitle();\r
153   }\r
154 \r
155   m_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE);\r
156   delete [] pstrImages;\r
157 \r
158   m_pListBoxImageChoices->SetSelection (0);\r
159   pTopSizer->Add (m_pListBoxImageChoices, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
160   \r
161   if (bShowMakeDifference) {\r
162     m_pMakeDifferenceImage = new wxCheckBox (this, -1, "Make Difference Image");\r
163     m_pMakeDifferenceImage->SetValue (FALSE);\r
164     pTopSizer->Add (m_pMakeDifferenceImage, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
165   } else\r
166     m_pMakeDifferenceImage = NULL;\r
167 \r
168   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
169   \r
170   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);\r
171   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");\r
172   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");\r
173   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);\r
174   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);\r
175   \r
176   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);\r
177   \r
178   SetAutoLayout (true);\r
179   SetSizer (pTopSizer);\r
180   pTopSizer->Fit (this);\r
181   pTopSizer->SetSizeHints (this);\r
182 }\r
183 \r
184 ImageFileDocument*\r
185 DialogGetComparisonImage::getImageFileDocument(void)\r
186 {\r
187   return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ];\r
188 }\r
189 \r
190 bool\r
191 DialogGetComparisonImage::getMakeDifferenceImage()\r
192 {\r
193   if (m_pMakeDifferenceImage)\r
194     return m_pMakeDifferenceImage->GetValue();\r
195   else\r
196     return false;\r
197 }\r
198 \r
199 \r
200 /////////////////////////////////////////////////////////////////////\r
201 // CLASS DiaglogGetMinMax Implementation\r
202 /////////////////////////////////////////////////////////////////////\r
203
204 DialogGetMinMax::DialogGetMinMax (wxFrame* pParent, const char* const pszTitle, double dDefaultMin, double dDefaultMax)
205 : wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
206 {
207   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
208   
209   pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
210   
211   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
212   
213   std::ostringstream os;
214   os << dDefaultMin;
215   m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
216   std::ostringstream osMax;
217   osMax << dDefaultMax;
218   m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
219   
220   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
221   pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
222   pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
223   pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
224   pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
225   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
226   
227   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
228   
229   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
230   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
231   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
232   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
233   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
234   
235   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
236   
237   SetAutoLayout (true);
238   SetSizer (pTopSizer);
239   pTopSizer->Fit (this);
240   pTopSizer->SetSizeHints (this);
241 }
242
243 DialogGetMinMax::~DialogGetMinMax (void)
244 {
245 }
246
247 double
248 DialogGetMinMax::getMinimum (void)
249 {
250   wxString strCtrl = m_pTextCtrlMin->GetValue();
251   double dValue;
252   if (strCtrl.ToDouble (&dValue))
253     return dValue;
254   else
255     return (m_dDefaultMin);
256 }
257
258 double
259 DialogGetMinMax::getMaximum (void)
260 {
261   wxString strCtrl = m_pTextCtrlMax->GetValue();
262   double dValue;
263   if (strCtrl.ToDouble (&dValue))
264     return dValue;
265   else
266     return (m_dDefaultMax);
267 }
268
269
270 /////////////////////////////////////////////////////////////////////\r
271 // CLASS DialogAutoScaleParameters IMPLEMENTATION\r
272 /////////////////////////////////////////////////////////////////////\r
273 \r
274 DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, double mean, double mode, double median, double stddev, double dDefaultScaleFactor)\r
275 : wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_dMean(mean), m_dMode(mode), m_dMedian(median), m_dStdDev(stddev)\r
276 {\r
277   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);\r
278   \r
279   pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);\r
280   \r
281   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
282   \r
283   wxString asTitle[3];\r
284   asTitle[0] = "Median";\r
285   asTitle[1] = "Mode";\r
286   asTitle[2] = "Mean";\r
287   \r
288   m_pListBoxCenter = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, 3, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB);\r
289   m_pListBoxCenter->SetSelection (0);\r
290   pTopSizer->Add (m_pListBoxCenter, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
291   \r
292   wxGridSizer *pGridSizer = new wxGridSizer (2);\r
293   pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);\r
294   std::ostringstream osDefaultFactor;\r
295   osDefaultFactor << dDefaultScaleFactor;\r
296   m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, osDefaultFactor.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);\r
297   pGridSizer->Add (m_pTextCtrlStdDevFactor, 0, wxALIGN_CENTER_VERTICAL);\r
298   pTopSizer->Add (pGridSizer, 1, wxALL, 10);\r
299   \r
300   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
301   \r
302   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);\r
303   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");\r
304   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");\r
305   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);\r
306   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);\r
307   \r
308   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);\r
309   \r
310   SetAutoLayout (true);\r
311   SetSizer (pTopSizer);\r
312   pTopSizer->Fit (this);\r
313   pTopSizer->SetSizeHints (this);\r
314 }\r
315 \r
316 bool\r
317 DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax)\r
318 {\r
319   int iCenter = m_pListBoxCenter->GetSelection();\r
320   double dCenter = m_dMedian;\r
321   if (iCenter == 1)\r
322     dCenter = m_dMode;\r
323   else if (iCenter == 2)\r
324     dCenter = m_dMode;\r
325   \r
326   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();\r
327   double dValue;\r
328   if (! sStddevFactor.ToDouble (&dValue)) {\r
329     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";\r
330     return false;\r
331   }\r
332   double dHalfWidth = dValue * m_dStdDev / 2;\r
333   *pMin = dCenter - dHalfWidth;\r
334   *pMax = dCenter + dHalfWidth;\r
335   *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n";\r
336   \r
337   return true;\r
338 }\r
339 \r
340 double\r
341 DialogAutoScaleParameters::getAutoScaleFactor ()\r
342 {\r
343   wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();\r
344   double dValue = 1.;\r
345   if (! sStddevFactor.ToDouble (&dValue)) {\r
346     *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";\r
347   }\r
348   \r
349   return dValue;\r
350 }\r
351 \r
352 \r
353 /////////////////////////////////////////////////////////////////////
354 // CLASS IDENTIFICATION
355 //
356 // DialogGetRasterParameters
357 /////////////////////////////////////////////////////////////////////
358
359 DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples)
360 : wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
361 {
362   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
363   
364   pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
365   
366   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
367   
368   std::ostringstream os;
369   os << iDefaultXSize;
370   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
371   std::ostringstream osYSize;
372   osYSize << iDefaultYSize;
373   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
374   std::ostringstream osNSamples;
375   osNSamples << iDefaultNSamples;
376   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
377   
378   wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2);
379   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
380   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
381   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
382   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
383   pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
384   pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
385   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
386   
387   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
388   
389   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
390   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
391   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
392   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
393   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
394   
395   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
396   
397   SetAutoLayout (true);
398   SetSizer (pTopSizer);
399   pTopSizer->Fit (this);
400   pTopSizer->SetSizeHints (this);
401 }
402
403 DialogGetRasterParameters::~DialogGetRasterParameters (void)
404 {
405 }
406
407
408 unsigned int
409 DialogGetRasterParameters::getXSize (void)
410 {
411   wxString strCtrl = m_pTextCtrlXSize->GetValue();
412   unsigned long lValue;
413   if (strCtrl.ToULong (&lValue))
414     return lValue;
415   else
416     return (m_iDefaultXSize);
417 }
418
419 unsigned int
420 DialogGetRasterParameters::getYSize (void)
421 {
422   wxString strCtrl = m_pTextCtrlYSize->GetValue();
423   unsigned long lValue;
424   if (strCtrl.ToULong (&lValue))
425     return lValue;
426   else
427     return (m_iDefaultYSize);
428 }
429
430
431 unsigned int
432 DialogGetRasterParameters::getNSamples (void)
433 {
434   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
435   unsigned long lValue;
436   if (strCtrl.ToULong (&lValue))
437     return lValue;
438   else
439     return (m_iDefaultNSamples);
440 }
441
442
443
444 /////////////////////////////////////////////////////////////////////
445 // CLASS IDENTIFICATION
446 //
447 // DialogGetProjectionParameters
448 /////////////////////////////////////////////////////////////////////
449
450
451 DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultNSamples, double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultFieldOfView, int iDefaultGeometry, int iDefaultTrace)
452 : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
453 {
454   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
455   
456   m_dDefaultRotAngle = dDefaultRotAngle;
457   m_dDefaultFocalLength = dDefaultFocalLength;
458   m_dDefaultFieldOfView = dDefaultFieldOfView;
459   m_iDefaultNSamples = iDefaultNSamples;
460   m_iDefaultNView = iDefaultNView;
461   m_iDefaultNDet = iDefaultNDet;
462   m_iDefaultTrace = iDefaultTrace;
463   m_iDefaultGeometry = iDefaultGeometry;
464   
465   pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
466   
467   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
468   
469   std::ostringstream os;
470   os << iDefaultNDet;
471   m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
472   std::ostringstream osNView;
473   osNView << iDefaultNView;
474   m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
475   std::ostringstream osNSamples;
476   osNSamples << iDefaultNSamples;
477   m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
478   std::ostringstream osRotAngle;
479   osRotAngle << dDefaultRotAngle;
480   m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
481   std::ostringstream osFocalLength;
482   osFocalLength << dDefaultFocalLength;
483   m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
484   std::ostringstream osFieldOfView;
485   osFieldOfView << dDefaultFieldOfView;
486   m_pTextCtrlFieldOfView = new wxTextCtrl (this, -1, osFieldOfView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
487   
488   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
489   pGridSizer->Add (new wxStaticText (this, -1, "Scanner Geometry"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
490   m_pListBoxGeometry = new StringValueAndTitleListBox (this, Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray());
491   m_pListBoxGeometry->SetSelection (iDefaultGeometry);
492   
493   pGridSizer->Add (m_pListBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
494   
495   pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
496   pGridSizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL);
497   pGridSizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
498   pGridSizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL);
499   pGridSizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
500   pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL);
501   pGridSizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
502   pGridSizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
503   pGridSizer->Add (new wxStaticText (this, -1, "Focal Length Ratio (phantom radius units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
504   pGridSizer->Add (m_pTextCtrlFocalLength, 0, wxALIGN_CENTER_VERTICAL);
505   pGridSizer->Add (new wxStaticText (this, -1, "Field of View (phantom diameter units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
506   pGridSizer->Add (m_pTextCtrlFieldOfView, 0, wxALIGN_CENTER_VERTICAL);
507   
508   m_pListBoxTrace = new StringValueAndTitleListBox (this, Trace::getTraceCount(), Trace::getTraceTitleArray(), Trace::getTraceNameArray());
509   m_pListBoxTrace->SetSelection (iDefaultTrace);
510   
511   pGridSizer->Add (new wxStaticText (this, -1, "Trace Level"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
512   pGridSizer->Add (m_pListBoxTrace, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
513   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
514   
515   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
516   
517   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
518   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
519   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
520   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
521   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
522   
523   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
524   
525   SetAutoLayout (true);
526   SetSizer (pTopSizer);
527   pTopSizer->Fit (this);
528   pTopSizer->SetSizeHints (this);
529 }
530
531 DialogGetProjectionParameters::~DialogGetProjectionParameters (void)
532 {
533 }
534
535
536 unsigned int
537 DialogGetProjectionParameters::getNDet (void)
538 {
539   wxString strCtrl = m_pTextCtrlNDet->GetValue();
540   unsigned long lValue;
541   if (strCtrl.ToULong (&lValue))
542     return lValue;
543   else
544     return (m_iDefaultNDet);
545 }
546
547 unsigned int
548 DialogGetProjectionParameters::getNView (void)
549 {
550   wxString strCtrl = m_pTextCtrlNView->GetValue();
551   unsigned long lValue;
552   if (strCtrl.ToULong (&lValue))
553     return lValue;
554   else
555     return (m_iDefaultNView);
556 }
557
558
559 unsigned int
560 DialogGetProjectionParameters::getNSamples (void)
561 {
562   wxString strCtrl = m_pTextCtrlNSamples->GetValue();
563   unsigned long lValue;
564   if (strCtrl.ToULong (&lValue))
565     return lValue;
566   else
567     return (m_iDefaultNSamples);
568 }
569
570 double
571 DialogGetProjectionParameters::getRotAngle (void)
572 {
573   wxString strCtrl = m_pTextCtrlRotAngle->GetValue();
574   double dValue;
575   if (strCtrl.ToDouble (&dValue))
576     return (dValue * PI);
577   else
578     return (m_dDefaultRotAngle);
579 }
580
581 double
582 DialogGetProjectionParameters::getFocalLengthRatio (void)
583 {
584   wxString strCtrl = m_pTextCtrlFocalLength->GetValue();
585   double dValue;
586   if (strCtrl.ToDouble (&dValue))
587     return (dValue);
588   else
589     return (m_dDefaultFocalLength);
590 }
591
592 double
593 DialogGetProjectionParameters::getFieldOfViewRatio (void)
594 {
595   wxString strCtrl = m_pTextCtrlFieldOfView->GetValue();
596   double dValue;
597   if (strCtrl.ToDouble (&dValue))
598     return (dValue);
599   else
600     return (m_dDefaultFieldOfView);
601 }
602
603 const char*
604 DialogGetProjectionParameters::getGeometry (void)
605 {
606   return m_pListBoxGeometry->getSelectionStringValue();
607 }
608
609 int
610 DialogGetProjectionParameters::getTrace (void)
611 {
612   return Trace::convertTraceNameToID(m_pListBoxTrace->getSelectionStringValue());
613 }
614
615
616
617 /////////////////////////////////////////////////////////////////////
618 // CLASS IDENTIFICATION
619 //
620 // DialogGetReconstructionParameters
621 /////////////////////////////////////////////////////////////////////
622
623
624 DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultFilterID, double dDefaultFilterParam,  int iDefaultFilterMethodID, int iDefaultFilterGenerationID, int iDefaultZeropad, int iDefaultInterpID, int iDefaultInterpParam, int iDefaultBackprojectID, int iTrace)
625 : wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
626 {
627   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
628   
629   pTopSizer->Add (new wxStaticText (this, -1, "Set Reconstruction Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
630   
631   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
632   
633   std::ostringstream os;
634   os << iDefaultXSize;
635   m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
636   std::ostringstream osYSize;
637   osYSize << iDefaultYSize;
638   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
639   std::ostringstream osFilterParam;
640   osFilterParam << dDefaultFilterParam;
641   m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
642   std::ostringstream osZeropad;
643   osZeropad << iDefaultZeropad;
644   m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
645   std::ostringstream osInterpParam;
646   osInterpParam << iDefaultInterpParam;
647   m_pTextCtrlInterpParam = new wxTextCtrl (this, -1, osInterpParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
648   
649   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (6);
650   pGridSizer->Add (new wxStaticText (this, -1, "Filter"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
651   m_pListBoxFilter = new StringValueAndTitleListBox (this, SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
652   m_pListBoxFilter->SetSelection (iDefaultFilterID);
653   pGridSizer->Add (m_pListBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
654   
655   m_pListBoxFilterMethod = new StringValueAndTitleListBox (this, ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray());
656   m_pListBoxFilterMethod->SetSelection (iDefaultFilterMethodID);
657   pGridSizer->Add (new wxStaticText (this, -1, "Filter Method"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
658   pGridSizer->Add (m_pListBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
659   
660   m_pListBoxFilterGeneration = new StringValueAndTitleListBox (this, ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray());
661   m_pListBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID);
662   pGridSizer->Add (new wxStaticText (this, -1, "Filter Generation"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
663   pGridSizer->Add (m_pListBoxFilterGeneration, 0, wxALL | wxALIGN_LEFT | wxEXPAND);
664   \r
665   
666   m_pListBoxBackproject = new StringValueAndTitleListBox (this, Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray());
667   m_pListBoxBackproject->SetSelection (iDefaultBackprojectID);
668   pGridSizer->Add (new wxStaticText (this, -1, "Backprojection"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
669   pGridSizer->Add (m_pListBoxBackproject, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
670   
671   m_pListBoxInterp = new StringValueAndTitleListBox (this, Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray());
672   m_pListBoxInterp->SetSelection (iDefaultInterpID);
673   pGridSizer->Add (new wxStaticText (this, -1, "Interpolation"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
674   pGridSizer->Add (m_pListBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
675   
676   
677   pGridSizer->Add (new wxStaticText (this, -1, "Trace Level"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);\r
678   static const char* aszTraceTitle[] = {"None", "Full"};\r
679   static const char* aszTraceName[] = {"none", "full"};\r
680   m_pListBoxTrace = new StringValueAndTitleListBox (this, 2, aszTraceTitle, aszTraceName);\r
681   iTrace = clamp(iTrace, 0, 1);\r
682   m_pListBoxTrace->SetSelection (iTrace);\r
683   pGridSizer->Add (m_pListBoxTrace);\r
684   \r
685   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
686   pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
687   pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
688   pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
689   pGridSizer->Add (new wxStaticText (this, -1, "Filter Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
690   pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
691   pGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
692   pGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
693   pGridSizer->Add (new wxStaticText (this, -1, "Interpolation Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
694   pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
695   
696   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
697   
698   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
699   
700   wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
701   wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");
702   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
703   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
704   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
705   
706   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
707   
708   SetAutoLayout (true);
709   SetSizer (pTopSizer);
710   pTopSizer->Layout();
711   pTopSizer->Fit (this);
712   pTopSizer->SetSizeHints (this);
713 }
714
715 DialogGetReconstructionParameters::~DialogGetReconstructionParameters (void)
716 {
717 }
718
719
720 unsigned int
721 DialogGetReconstructionParameters::getXSize (void)
722 {
723   wxString strCtrl = m_pTextCtrlXSize->GetValue();
724   unsigned long lValue;
725   if (strCtrl.ToULong (&lValue))
726     return lValue;
727   else
728     return (m_iDefaultXSize);
729 }
730
731 unsigned int
732 DialogGetReconstructionParameters::getYSize (void)
733 {
734   wxString strCtrl = m_pTextCtrlYSize->GetValue();
735   unsigned long lValue;
736   if (strCtrl.ToULong (&lValue))
737     return lValue;
738   else
739     return (m_iDefaultYSize);
740 }
741
742 unsigned int
743 DialogGetReconstructionParameters::getZeropad (void)
744 {
745   wxString strCtrl = m_pTextCtrlZeropad->GetValue();
746   unsigned long lValue;
747   if (strCtrl.ToULong (&lValue))
748     return lValue;
749   else
750     return (m_iDefaultZeropad);
751 }
752
753
754 unsigned int
755 DialogGetReconstructionParameters::getInterpParam (void)
756 {
757   wxString strCtrl = m_pTextCtrlInterpParam->GetValue();
758   unsigned long lValue;
759   if (strCtrl.ToULong (&lValue))
760     return lValue;
761   else
762     return (m_iDefaultInterpParam);
763 }
764
765 double
766 DialogGetReconstructionParameters::getFilterParam (void)
767 {
768   wxString strCtrl = m_pTextCtrlFilterParam->GetValue();
769   double dValue;
770   if (strCtrl.ToDouble (&dValue))
771     return (dValue);
772   else
773     return (m_dDefaultFilterParam);
774 }
775
776 const char*
777 DialogGetReconstructionParameters::getFilterName (void)
778 {
779   return m_pListBoxFilter->getSelectionStringValue();
780 }
781
782 const char*
783 DialogGetReconstructionParameters::getFilterMethodName (void)
784 {
785   return m_pListBoxFilterMethod->getSelectionStringValue();
786 }
787
788 const char*
789 DialogGetReconstructionParameters::getInterpName (void)
790 {
791   return m_pListBoxInterp->getSelectionStringValue();
792 }
793
794 int
795 DialogGetReconstructionParameters::getTrace (void)
796 {
797   int iTrace = 0;
798   if (strcmp("full", m_pListBoxTrace->getSelectionStringValue()) == 0)
799     iTrace = Trace::TRACE_PLOT;
800   return iTrace;
801 }
802
803 const char*
804 DialogGetReconstructionParameters::getBackprojectName (void)
805 {
806   return m_pListBoxBackproject->getSelectionStringValue();
807 }
808
809 const char*
810 DialogGetReconstructionParameters::getFilterGenerationName (void)
811 {
812   return m_pListBoxFilterGeneration->getSelectionStringValue();
813 }
814
815 \r