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