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