X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fdialogs.cpp;h=e608fd168a56acfbcddfdf97e30b74b0e3dfb489;hb=286d655a25df2668bd65ad365676c6ecc94415a1;hp=27b454f0ff857dabbca266e00399557414ed7814;hpb=27a474e0622ebb7229fd5705552021f63d8f932d;p=ctsim.git diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 27b454f..e608fd1 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: dialogs.cpp,v 1.4 2000/07/20 11:17:31 kevin Exp $ +** $Id: dialogs.cpp,v 1.5 2000/07/22 15:45:33 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 @@ -55,38 +55,36 @@ #include "backprojectors.h" +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]; -const wxString DialogGetPhantom::s_asPhantom[] = -{ - wxString(Phantom::PHM_HERMAN_STR), - wxString(Phantom::PHM_BHERMAN_STR), - wxString(Phantom::PHM_ROWLAND_STR), - wxString(Phantom::PHM_BROWLAND_STR), - wxString(Phantom::PHM_UNITPULSE_STR), -}; -const wxString DialogGetPhantom::s_asPhantomTitle[] = -{ - wxString(Phantom::PHM_HERMAN_TITLE_STR), - wxString(Phantom::PHM_BHERMAN_TITLE_STR), - wxString(Phantom::PHM_ROWLAND_TITLE_STR), - wxString(Phantom::PHM_BROWLAND_TITLE_STR), - wxString(Phantom::PHM_UNITPULSE_TITLE_STR), + Create (pParent, -1, wxDefaultPosition, wxDefaultSize, nChoices, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + + m_ppszValues = aszValue; }; -const unsigned int DialogGetPhantom::s_iNumPhantom = sizeof(s_asPhantom) / sizeof(wxString); + +const char* +StringValueAndTitleListBox::getSelectionStringValue (void) const +{ + return m_ppszValues[GetSelection()]; +} -DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, const char* szDefaultPhantom = NULL) + +DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, int iDefaultPhantom = Phantom::PHM_HERMAN) : wxDialog (pParent, -1, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { - m_sDefaultPhantom = szDefaultPhantom; - 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); - m_pListBoxPhantom = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, s_iNumPhantom, s_asPhantomTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + m_pListBoxPhantom = new StringValueAndTitleListBox (this, Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray()); pTopSizer->Add (m_pListBoxPhantom, 0, wxALL | wxALIGN_CENTER | wxEXPAND); pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); @@ -105,14 +103,10 @@ DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, const char* szDefaultPhant pTopSizer->SetSizeHints (this); } -const wxString& +const char* DialogGetPhantom::getPhantom(void) { - int selection = m_pListBoxPhantom->GetSelection(); - if (selection >= 0) - return (s_asPhantom[selection]); - - return (m_sDefaultPhantom); + return m_pListBoxPhantom->getSelectionStringValue(); } @@ -283,22 +277,8 @@ DialogGetRasterParameters::getNSamples (void) // DialogGetProjectionParameters ///////////////////////////////////////////////////////////////////// -const wxString DialogGetProjectionParameters::s_asGeometry[] = -{ - wxString(Scanner::GEOMETRY_PARALLEL_STR), - wxString(Scanner::GEOMETRY_EQUILINEAR_STR), - wxString(Scanner::GEOMETRY_EQUIANGULAR_STR), -}; -const wxString DialogGetProjectionParameters::s_asGeometryTitle[] = -{ - wxString(Scanner::GEOMETRY_PARALLEL_TITLE_STR), - wxString(Scanner::GEOMETRY_EQUILINEAR_TITLE_STR), - wxString(Scanner::GEOMETRY_EQUIANGULAR_TITLE_STR), -}; -const unsigned int DialogGetProjectionParameters::s_iNumGeometry = sizeof(s_asGeometry) / sizeof(wxString); - -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); @@ -307,7 +287,7 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - m_pListBoxGeometry = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, s_iNumGeometry, s_asGeometryTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + m_pListBoxGeometry = new StringValueAndTitleListBox (this, Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray()); pTopSizer->Add (m_pListBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND); ostringstream os; @@ -333,7 +313,6 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, 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); @@ -401,14 +380,10 @@ DialogGetProjectionParameters::getRotAngle (void) return (m_dDefaultRotAngle); } -const wxString& +const char* DialogGetProjectionParameters::getGeometry (void) { - int selection = m_pListBoxGeometry->GetSelection(); - if (selection >= 0) - return (s_asGeometry[selection]); - - return m_sDefaultGeometry; + return m_pListBoxGeometry->getSelectionStringValue(); } @@ -419,33 +394,8 @@ DialogGetProjectionParameters::getGeometry (void) // DialogGetReconstructionParameters ///////////////////////////////////////////////////////////////////// -const wxString DialogGetReconstructionParameters::s_asFilter[] = -{ - wxString(SignalFilter::FILTER_ABS_BANDLIMIT_STR), - wxString(SignalFilter::FILTER_SHEPP_STR), -}; -const wxString DialogGetReconstructionParameters::s_asFilterTitle[] = -{ - wxString(SignalFilter::FILTER_ABS_BANDLIMIT_TITLE_STR), - wxString(SignalFilter::FILTER_SHEPP_TITLE_STR), -}; -const unsigned int DialogGetReconstructionParameters::s_iNumFilter = sizeof(s_asFilter) / sizeof(wxString); - - -const wxString DialogGetReconstructionParameters::s_asInterp[] = -{ - wxString(Backprojector::INTERP_NEAREST_STR), - wxString(Backprojector::INTERP_LINEAR_STR), -}; -const wxString DialogGetReconstructionParameters::s_asInterpTitle[] = -{ - wxString(Backprojector::INTERP_NEAREST_TITLE_STR), - wxString(Backprojector::INTERP_LINEAR_TITLE_STR), - }; -const unsigned int DialogGetReconstructionParameters::s_iNumInterp = sizeof(s_asInterp) / sizeof(wxString); - -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 iDefaultBackprojID = Backprojector::BPROJ_IDIFF3) : wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); @@ -454,10 +404,16 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - m_pListBoxFilter = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, s_iNumFilter, s_asFilterTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + m_pListBoxFilter = new StringValueAndTitleListBox (this, SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray()); pTopSizer->Add (m_pListBoxFilter, 0, wxALL | wxALIGN_CENTER | wxEXPAND); - m_pListBoxInterp = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, s_iNumInterp, s_asInterpTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + m_pListBoxFilterMethod = new StringValueAndTitleListBox (this, SignalFilter::getFilterMethodCount(), SignalFilter::getFilterMethodTitleArray(), SignalFilter::getFilterMethodNameArray()); + pTopSizer->Add (m_pListBoxFilterMethod, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + + m_pListBoxBackproject = new StringValueAndTitleListBox (this, Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray()); + pTopSizer->Add (m_pListBoxBackproject, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + + m_pListBoxInterp = new StringValueAndTitleListBox (this, Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray()); pTopSizer->Add (m_pListBoxInterp, 0, wxALL | wxALIGN_CENTER | wxEXPAND); ostringstream os; @@ -489,11 +445,6 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_CENTER_VERTICAL); pTopSizer->Add (pGridSizer, 1, wxALL, 10); - 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); @@ -571,34 +522,26 @@ DialogGetReconstructionParameters::getFilterParam (void) return (m_dDefaultFilterParam); } -const wxString& +const char* DialogGetReconstructionParameters::getFilterName (void) { - int selection = m_pListBoxFilter->GetSelection(); - if (selection >= 0) - return (s_asFilter[selection]); - - return m_sDefaultFilterName; + return m_pListBoxFilter->getSelectionStringValue(); } -const wxString& +const char* DialogGetReconstructionParameters::getFilterMethodName (void) { - return m_sDefaultFilterMethodName; + return m_pListBoxFilterMethod->getSelectionStringValue(); } -const wxString& +const char* DialogGetReconstructionParameters::getInterpName (void) { - int selection = m_pListBoxInterp->GetSelection(); - if (selection >= 0) - return (s_asInterp[selection]); - - return m_sDefaultInterpName; + return m_pListBoxInterp->getSelectionStringValue(); } -const wxString& -DialogGetReconstructionParameters::getBackprojName (void) +const char* +DialogGetReconstructionParameters::getBackprojectName (void) { - return m_sDefaultBackprojName; + return m_pListBoxBackproject->getSelectionStringValue(); }