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