** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: dialogs.cpp,v 1.3 2000/07/19 04:33:27 kevin Exp $
+** $Id: dialogs.cpp,v 1.7 2000/07/23 01:49:03 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "dialogs.h"
#include <sstream>
#include "ctsupport.h"
+#include "ctsim.h"
#include "scanner.h"
#include "phantom.h"
#include "filter.h"
#include "backprojectors.h"
-DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, const char* szDefaultPhantom = NULL)
- : wxDialog (pParent, -1, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[])
+ : wxListBox ()
+{
+ wxString asTitle[nChoices];
+ for (int i = 0; i < nChoices; i++)
+ asTitle[i] = aszTitle[i];
+
+ Create (pParent, -1, wxDefaultPosition, wxDefaultSize, nChoices, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB);
+
+ m_ppszValues = aszValue;
+};
+
+const char*
+StringValueAndTitleListBox::getSelectionStringValue (void) const
{
- m_sDefaultPhantom = szDefaultPhantom;
+ return m_ppszValues[GetSelection()];
+}
+
+
+DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, int iDefaultPhantom = Phantom::PHM_HERMAN)
+ : wxDialog (pParent, -1, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+{
wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
pTopSizer->Add (new wxStaticText (this, -1, "Select Phantom"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
- wxString aListPhantomTitle [5];
- aListPhantomTitle[0] = Phantom::PHM_HERMAN_TITLE_STR;
- aListPhantomTitle[1] = Phantom::PHM_BHERMAN_TITLE_STR;
- aListPhantomTitle[2] = Phantom::PHM_ROWLAND_TITLE_STR;
- aListPhantomTitle[3] = Phantom::PHM_BROWLAND_TITLE_STR;
- aListPhantomTitle[4] = Phantom::PHM_UNITPULSE_TITLE_STR;
- m_pListBoxPhantom = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, 5, aListPhantomTitle, wxLB_SINGLE | wxLB_NEEDED_SB);
+ m_pListBoxPhantom = new StringValueAndTitleListBox (this, Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray());
+ m_pListBoxPhantom->SetSelection (iDefaultPhantom);
pTopSizer->Add (m_pListBoxPhantom, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
pTopSizer->SetSizeHints (this);
}
-string
+const char*
DialogGetPhantom::getPhantom(void)
{
- string aListPhantom [5];
- aListPhantom[0] = Phantom::PHM_HERMAN_STR;
- aListPhantom[1] = Phantom::PHM_BHERMAN_STR;
- aListPhantom[2] = Phantom::PHM_ROWLAND_STR;;
- aListPhantom[3] = Phantom::PHM_BROWLAND_STR;
- aListPhantom[4] = Phantom::PHM_UNITPULSE_STR;
-
- int selection = m_pListBoxPhantom->GetSelection();
- if (selection >= 0)
- return (aListPhantom[selection]);
-
- return (m_sDefaultPhantom);
+ return m_pListBoxPhantom->getSelectionStringValue();
}
// DialogGetProjectionParameters
/////////////////////////////////////////////////////////////////////
-DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL)
+
+DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., int iDefaultGeometry = Scanner::GEOMETRY_PARALLEL)
: wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
{
wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+ m_pListBoxGeometry = new StringValueAndTitleListBox (this, Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray());
+ m_pListBoxGeometry->SetSelection (iDefaultGeometry);
+ pTopSizer->Add (m_pListBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
+
ostringstream os;
os << iDefaultNDet;
m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
pGridSizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
pGridSizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
pTopSizer->Add (pGridSizer, 1, wxALL, 10);
- m_sDefaultGeometry = szDefaultGeometry;
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
return (m_dDefaultRotAngle);
}
-const string&
+const char*
DialogGetProjectionParameters::getGeometry (void)
{
- return m_sDefaultGeometry;
+ return m_pListBoxGeometry->getSelectionStringValue();
}
// DialogGetReconstructionParameters
/////////////////////////////////////////////////////////////////////
-DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, const char* szDefaultFilterName = NULL, double dDefaultFilterParam = 1., const char* szDefaultFilterMethodName = NULL, int iDefaultZeropad = 3, const char* szDefaultInterpName = NULL, int iDefaultInterpParam = 1, const char* szDefaultBackprojName = NULL)
+
+DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultFilterID = SignalFilter::FILTER_ABS_BANDLIMIT, double dDefaultFilterParam = 1., int iDefaultFilterMethodID = SignalFilter::FILTER_METHOD_CONVOLUTION, int iDefaultZeropad = 3, int iDefaultInterpID = Backprojector::INTERP_LINEAR, int iDefaultInterpParam = 1, int iDefaultBackprojectID = Backprojector::BPROJ_IDIFF3)
: wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
{
wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+ m_pListBoxFilter = new StringValueAndTitleListBox (this, SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray());
+ m_pListBoxFilter->SetSelection (iDefaultFilterID);
+ pTopSizer->Add (m_pListBoxFilter, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
+
+ m_pListBoxFilterMethod = new StringValueAndTitleListBox (this, SignalFilter::getFilterMethodCount(), SignalFilter::getFilterMethodTitleArray(), SignalFilter::getFilterMethodNameArray());
+ m_pListBoxFilterMethod->SetSelection (iDefaultFilterMethodID);
+ pTopSizer->Add (m_pListBoxFilterMethod, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
+
+ m_pListBoxBackproject = new StringValueAndTitleListBox (this, Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray());
+ m_pListBoxBackproject->SetSelection (iDefaultBackprojectID);
+ pTopSizer->Add (m_pListBoxBackproject, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
+
+ m_pListBoxInterp = new StringValueAndTitleListBox (this, Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray());
+ m_pListBoxInterp->SetSelection (iDefaultInterpID);
+ pTopSizer->Add (m_pListBoxInterp, 0, wxALL | wxALIGN_CENTER | wxEXPAND);
+
ostringstream os;
os << iDefaultXSize;
m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_CENTER_VERTICAL);
pTopSizer->Add (pGridSizer, 1, wxALL, 10);
- wxString aTitlesFilter[4];
- aTitlesFilter[0] = "Abs * Bandlimit";
- aTitlesFilter[1] = "Abs * Hamming";
- aTitlesFilter[2] = "Abs * Hanning";
- aTitlesFilter[3] = "Abs * Cosine";
-
- m_pListBoxFilter = new wxListBox (this, -1, wxDefaultPosition, wxSize(-1,-1), 4, aTitlesFilter, wxLB_SINGLE | wxLB_NEEDED_SB);
- pTopSizer->Add (m_pListBoxFilter);
-
- m_sDefaultFilterName = szDefaultFilterName;
- m_sDefaultFilterMethodName = szDefaultFilterMethodName;
- m_sDefaultInterpName = szDefaultInterpName;
- m_sDefaultBackprojName = szDefaultBackprojName;
-
pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
return (m_dDefaultFilterParam);
}
-const string&
+const char*
DialogGetReconstructionParameters::getFilterName (void)
{
- return m_sDefaultFilterName;
+ return m_pListBoxFilter->getSelectionStringValue();
}
-const string&
+const char*
DialogGetReconstructionParameters::getFilterMethodName (void)
{
- return m_sDefaultFilterMethodName;
+ return m_pListBoxFilterMethod->getSelectionStringValue();
}
-const string&
+const char*
DialogGetReconstructionParameters::getInterpName (void)
{
- return m_sDefaultInterpName;
+ return m_pListBoxInterp->getSelectionStringValue();
}
-const string&
-DialogGetReconstructionParameters::getBackprojName (void)
+const char*
+DialogGetReconstructionParameters::getBackprojectName (void)
{
- return m_sDefaultBackprojName;
+ return m_pListBoxBackproject->getSelectionStringValue();
}