X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fdialogs.cpp;h=7d8c0ecab7e7dbf3fd526e644476806382a40e6f;hp=b084fd4c4fba2c7716c84a807cdea58d13ef78ff;hb=c551b53b39a7571cf52831f5e117be1cca95c420;hpb=ab4a3ba2c1ba9672136b5022897f81fc55d03493 diff --git a/src/dialogs.cpp b/src/dialogs.cpp index b084fd4..7d8c0ec 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.3 2000/07/19 04:33:27 kevin Exp $ +** $Id: dialogs.cpp,v 1.20 2000/12/22 04:18:00 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 @@ -47,164 +47,335 @@ #include "wx/statline.h" #include "wx/sizer.h" #include "dialogs.h" -#include #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) +#include "docs.h" +#include "views.h" +#include "imagefile.h" + +#if defined(MSVC) || HAVE_SSTREAM +#include +#else +#include +#endif + + +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// StringValueAndTitleListBox +/////////////////////////////////////////////////////////////////////// + +StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[]) +: wxListBox () +{ + wxString* psTitle = new wxString [nChoices]; + for (int i = 0; i < nChoices; i++) + psTitle[i] = aszTitle[i]; + + Create (pParent, -1, wxDefaultPosition, wxSize(200,-1), nChoices, psTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + + m_ppszValues = aszValue; + delete [] psTitle; +}; + +const char* +StringValueAndTitleListBox::getSelectionStringValue (void) const { - m_sDefaultPhantom = szDefaultPhantom; + return m_ppszValues[GetSelection()]; +} - 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); +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// DialogGetPhantom +/////////////////////////////////////////////////////////////////////// - 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); +DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, int iDefaultPhantom) +: 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 | wxALL, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5); + + 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); - + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); 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(); } - -DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.) - : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) + +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// DialogGetComparisonImage +/////////////////////////////////////////////////////////////////////// + +DialogGetComparisonImage::DialogGetComparisonImage (wxFrame* pParent, const char* const pszTitle, const std::vector& rVecIF, bool bShowMakeDifference) +: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rVecIF(rVecIF) +{ + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxALL, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5); + + int iNImages = m_rVecIF.size(); + wxString* pstrImages = new wxString [iNImages]; + for (int i = 0; i < iNImages; i++) { + ImageFileView* pView = dynamic_cast(m_rVecIF[i]->GetFirstView()); + if (pView) + pstrImages[i] = pView->getFrame()->GetTitle(); + } + + m_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE); + delete [] pstrImages; + + m_pListBoxImageChoices->SetSelection (0); + pTopSizer->Add (m_pListBoxImageChoices, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + + if (bShowMakeDifference) { + m_pMakeDifferenceImage = new wxCheckBox (this, -1, "Make Difference Image"); + m_pMakeDifferenceImage->SetValue (FALSE); + pTopSizer->Add (m_pMakeDifferenceImage, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + } else + m_pMakeDifferenceImage = NULL; + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +ImageFileDocument* +DialogGetComparisonImage::getImageFileDocument(void) +{ + return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ]; +} + +bool +DialogGetComparisonImage::getMakeDifferenceImage() +{ + if (m_pMakeDifferenceImage) + return m_pMakeDifferenceImage->GetValue(); + else + return false; +} + + +///////////////////////////////////////////////////////////////////// +// CLASS DiaglogGetMinMax Implementation +///////////////////////////////////////////////////////////////////// + +DialogGetMinMax::DialogGetMinMax (wxFrame* pParent, const char* const pszTitle, double dDefaultMin, double dDefaultMax) +: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - - pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - + + pTopSizer->Add (new wxStaticText (this, -1, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - - ostringstream os; + + std::ostringstream os; os << dDefaultMin; m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osMax; + std::ostringstream osMax; osMax << dDefaultMax; m_pTextCtrlMax = new wxTextCtrl (this, -1, osMax.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - - wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5); + + wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2); pGridSizer->Add (new wxStaticText (this, -1, "Minimum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL); pTopSizer->Add (pGridSizer, 1, wxALL, 10); - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -DialogGetImageMinMax::~DialogGetImageMinMax (void) +DialogGetMinMax::~DialogGetMinMax (void) { -#if 0 - delete m_pTextCtrlMin; - delete m_pTextCtrlMax; -#endif } double -DialogGetImageMinMax::getMinimum (void) +DialogGetMinMax::getMinimum (void) { - wxString strCtrl = m_pTextCtrlMin->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return dValue; - else - return (m_dDefaultMin); + wxString strCtrl = m_pTextCtrlMin->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultMin); } double -DialogGetImageMinMax::getMaximum (void) +DialogGetMinMax::getMaximum (void) { - wxString strCtrl = m_pTextCtrlMax->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return dValue; - else - return (m_dDefaultMax); + wxString strCtrl = m_pTextCtrlMax->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultMax); } +///////////////////////////////////////////////////////////////////// +// CLASS DialogAutoScaleParameters IMPLEMENTATION +///////////////////////////////////////////////////////////////////// + +DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, double mean, double mode, double median, double stddev, double dDefaultScaleFactor) +: wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_dMean(mean), m_dMode(mode), m_dMedian(median), m_dStdDev(stddev) +{ + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxString asTitle[3]; + asTitle[0] = "Median"; + asTitle[1] = "Mode"; + asTitle[2] = "Mean"; + + m_pListBoxCenter = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, 3, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + m_pListBoxCenter->SetSelection (0); + pTopSizer->Add (m_pListBoxCenter, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + + wxGridSizer *pGridSizer = new wxGridSizer (2); + pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + std::ostringstream osDefaultFactor; + osDefaultFactor << dDefaultScaleFactor; + m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, osDefaultFactor.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (m_pTextCtrlStdDevFactor, 0, wxALIGN_CENTER_VERTICAL); + pTopSizer->Add (pGridSizer, 1, wxALL, 10); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); + wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +bool +DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax) +{ + int iCenter = m_pListBoxCenter->GetSelection(); + double dCenter = m_dMedian; + if (iCenter == 1) + dCenter = m_dMode; + else if (iCenter == 2) + dCenter = m_dMode; + + wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue(); + double dValue; + if (! sStddevFactor.ToDouble (&dValue)) { + *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n"; + return false; + } + double dHalfWidth = dValue * m_dStdDev / 2; + *pMin = dCenter - dHalfWidth; + *pMax = dCenter + dHalfWidth; + *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n"; + + return true; +} + +double +DialogAutoScaleParameters::getAutoScaleFactor () +{ + wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue(); + double dValue = 1.; + if (! sStddevFactor.ToDouble (&dValue)) { + *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n"; + } + + return dValue; +} + + ///////////////////////////////////////////////////////////////////// // CLASS IDENTIFICATION // // DialogGetRasterParameters ///////////////////////////////////////////////////////////////////// -DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultNSamples = 1) - : wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples) +: wxDialog (pParent, -1, "Set Rasterization Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - + pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - - ostringstream os; + + std::ostringstream os; os << iDefaultXSize; m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osYSize; + std::ostringstream osYSize; osYSize << iDefaultYSize; m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osNSamples; + std::ostringstream osNSamples; osNSamples << iDefaultNSamples; m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - - wxGridSizer *pGridSizer = new wxGridSizer (2, 3, 5); + + wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2); pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -212,17 +383,17 @@ DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDef pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL); pTopSizer->Add (pGridSizer, 1, wxALL, 10); - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); @@ -237,35 +408,35 @@ DialogGetRasterParameters::~DialogGetRasterParameters (void) unsigned int DialogGetRasterParameters::getXSize (void) { - wxString strCtrl = m_pTextCtrlXSize->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultXSize); + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); } unsigned int DialogGetRasterParameters::getYSize (void) { - wxString strCtrl = m_pTextCtrlYSize->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultYSize); + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); } unsigned int DialogGetRasterParameters::getNSamples (void) { - wxString strCtrl = m_pTextCtrlNSamples->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultNSamples); + wxString strCtrl = m_pTextCtrlNSamples->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNSamples); } @@ -276,29 +447,51 @@ DialogGetRasterParameters::getNSamples (void) // DialogGetProjectionParameters ///////////////////////////////////////////////////////////////////// -DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL) - : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) + +DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultNSamples, double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultFieldOfView, int iDefaultGeometry, int iDefaultTrace) +: wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - + + m_dDefaultRotAngle = dDefaultRotAngle; + m_dDefaultFocalLength = dDefaultFocalLength; + m_dDefaultFieldOfView = dDefaultFieldOfView; + m_iDefaultNSamples = iDefaultNSamples; + m_iDefaultNView = iDefaultNView; + m_iDefaultNDet = iDefaultNDet; + m_iDefaultTrace = iDefaultTrace; + m_iDefaultGeometry = iDefaultGeometry; + pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - - ostringstream os; + + std::ostringstream os; os << iDefaultNDet; m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osNView; + std::ostringstream osNView; osNView << iDefaultNView; m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osNSamples; + std::ostringstream osNSamples; osNSamples << iDefaultNSamples; m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osRotAngle; + std::ostringstream osRotAngle; osRotAngle << dDefaultRotAngle; m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - - wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5); + std::ostringstream osFocalLength; + osFocalLength << dDefaultFocalLength; + m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + std::ostringstream osFieldOfView; + osFieldOfView << dDefaultFieldOfView; + m_pTextCtrlFieldOfView = new wxTextCtrl (this, -1, osFieldOfView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + + wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2); + pGridSizer->Add (new wxStaticText (this, -1, "Scanner Geometry"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + m_pListBoxGeometry = new StringValueAndTitleListBox (this, Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray()); + m_pListBoxGeometry->SetSelection (iDefaultGeometry); + + pGridSizer->Add (m_pListBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); @@ -307,19 +500,28 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, pGridSizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Rotation Angle (PI units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Focal Length Ratio (phantom radius units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlFocalLength, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (new wxStaticText (this, -1, "Field of View (phantom diameter units)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlFieldOfView, 0, wxALIGN_CENTER_VERTICAL); + + m_pListBoxTrace = new StringValueAndTitleListBox (this, Trace::getTraceCount(), Trace::getTraceTitleArray(), Trace::getTraceNameArray()); + m_pListBoxTrace->SetSelection (iDefaultTrace); + + pGridSizer->Add (new wxStaticText (this, -1, "Trace Level"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pListBoxTrace, 0, wxALL | wxALIGN_CENTER | wxEXPAND); pTopSizer->Add (pGridSizer, 1, wxALL, 10); - m_sDefaultGeometry = szDefaultGeometry; - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); @@ -334,52 +536,80 @@ DialogGetProjectionParameters::~DialogGetProjectionParameters (void) unsigned int DialogGetProjectionParameters::getNDet (void) { - wxString strCtrl = m_pTextCtrlNDet->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultNDet); + wxString strCtrl = m_pTextCtrlNDet->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNDet); } unsigned int DialogGetProjectionParameters::getNView (void) { - wxString strCtrl = m_pTextCtrlNView->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultNView); + wxString strCtrl = m_pTextCtrlNView->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNView); } unsigned int DialogGetProjectionParameters::getNSamples (void) { - wxString strCtrl = m_pTextCtrlNSamples->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultNSamples); + wxString strCtrl = m_pTextCtrlNSamples->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultNSamples); } double DialogGetProjectionParameters::getRotAngle (void) { - wxString strCtrl = m_pTextCtrlRotAngle->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return (dValue * PI); - else - return (m_dDefaultRotAngle); + wxString strCtrl = m_pTextCtrlRotAngle->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue * PI); + else + return (m_dDefaultRotAngle); +} + +double +DialogGetProjectionParameters::getFocalLengthRatio (void) +{ + wxString strCtrl = m_pTextCtrlFocalLength->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultFocalLength); +} + +double +DialogGetProjectionParameters::getFieldOfViewRatio (void) +{ + wxString strCtrl = m_pTextCtrlFieldOfView->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultFieldOfView); } -const string& +const char* DialogGetProjectionParameters::getGeometry (void) { - return m_sDefaultGeometry; + return m_pListBoxGeometry->getSelectionStringValue(); +} + +int +DialogGetProjectionParameters::getTrace (void) +{ + return Trace::convertTraceNameToID(m_pListBoxTrace->getSelectionStringValue()); } @@ -390,70 +620,94 @@ DialogGetProjectionParameters::getGeometry (void) // 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) - : wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) + +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) +: wxDialog (pParent, -1, "Set Reconstruction Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - + pTopSizer->Add (new wxStaticText (this, -1, "Set Reconstruction Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - - ostringstream os; + + std::ostringstream os; os << iDefaultXSize; m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osYSize; + std::ostringstream osYSize; osYSize << iDefaultYSize; m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osFilterParam; + std::ostringstream osFilterParam; osFilterParam << dDefaultFilterParam; m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osZeropad; + std::ostringstream osZeropad; osZeropad << iDefaultZeropad; m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osInterpParam; + std::ostringstream osInterpParam; osInterpParam << iDefaultInterpParam; m_pTextCtrlInterpParam = new wxTextCtrl (this, -1, osInterpParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - - wxGridSizer *pGridSizer = new wxGridSizer (2, 5, 5); + + wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (6); + pGridSizer->Add (new wxStaticText (this, -1, "Filter"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + m_pListBoxFilter = new StringValueAndTitleListBox (this, SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray()); + m_pListBoxFilter->SetSelection (iDefaultFilterID); + pGridSizer->Add (m_pListBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + m_pListBoxFilterMethod = new StringValueAndTitleListBox (this, ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray()); + m_pListBoxFilterMethod->SetSelection (iDefaultFilterMethodID); + pGridSizer->Add (new wxStaticText (this, -1, "Filter Method"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + pGridSizer->Add (m_pListBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + m_pListBoxFilterGeneration = new StringValueAndTitleListBox (this, ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray()); + m_pListBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID); + pGridSizer->Add (new wxStaticText (this, -1, "Filter Generation"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + pGridSizer->Add (m_pListBoxFilterGeneration, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + + m_pListBoxBackproject = new StringValueAndTitleListBox (this, Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray()); + m_pListBoxBackproject->SetSelection (iDefaultBackprojectID); + pGridSizer->Add (new wxStaticText (this, -1, "Backprojection"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + pGridSizer->Add (m_pListBoxBackproject, 0, wxALL | wxALIGN_RIGHT | wxEXPAND); + + m_pListBoxInterp = new StringValueAndTitleListBox (this, Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray()); + m_pListBoxInterp->SetSelection (iDefaultInterpID); + pGridSizer->Add (new wxStaticText (this, -1, "Interpolation"), 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + pGridSizer->Add (m_pListBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND); + + + pGridSizer->Add (new wxStaticText (this, -1, "Trace Level"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + static const char* aszTraceTitle[] = {"None", "Full"}; + static const char* aszTraceName[] = {"none", "full"}; + m_pListBoxTrace = new StringValueAndTitleListBox (this, 2, aszTraceTitle, aszTraceName); + iTrace = clamp(iTrace, 0, 1); + m_pListBoxTrace->SetSelection (iTrace); + pGridSizer->Add (m_pListBoxTrace); + pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Filter Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (new wxStaticText (this, -1, "Interpolation Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - 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; - + pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add (pGridSizer, 1, wxALL, 3); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); - + wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL); wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay"); wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + SetAutoLayout (true); SetSizer (pTopSizer); + pTopSizer->Layout(); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } @@ -466,79 +720,96 @@ DialogGetReconstructionParameters::~DialogGetReconstructionParameters (void) unsigned int DialogGetReconstructionParameters::getXSize (void) { - wxString strCtrl = m_pTextCtrlXSize->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultXSize); + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); } unsigned int DialogGetReconstructionParameters::getYSize (void) { - wxString strCtrl = m_pTextCtrlYSize->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultYSize); + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); } unsigned int DialogGetReconstructionParameters::getZeropad (void) { - wxString strCtrl = m_pTextCtrlZeropad->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultZeropad); + wxString strCtrl = m_pTextCtrlZeropad->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultZeropad); } unsigned int DialogGetReconstructionParameters::getInterpParam (void) { - wxString strCtrl = m_pTextCtrlInterpParam->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultInterpParam); + wxString strCtrl = m_pTextCtrlInterpParam->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultInterpParam); } double DialogGetReconstructionParameters::getFilterParam (void) { - wxString strCtrl = m_pTextCtrlFilterParam->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return (dValue); - else - return (m_dDefaultFilterParam); + wxString strCtrl = m_pTextCtrlFilterParam->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + 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(); +} + +int +DialogGetReconstructionParameters::getTrace (void) +{ + int iTrace = 0; + if (strcmp("full", m_pListBoxTrace->getSelectionStringValue()) == 0) + iTrace = Trace::TRACE_PLOT; + return iTrace; } -const string& -DialogGetReconstructionParameters::getBackprojName (void) +const char* +DialogGetReconstructionParameters::getBackprojectName (void) { - return m_sDefaultBackprojName; + return m_pListBoxBackproject->getSelectionStringValue(); } + +const char* +DialogGetReconstructionParameters::getFilterGenerationName (void) +{ + return m_pListBoxFilterGeneration->getSelectionStringValue(); +} + +