X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fdialogs.cpp;h=d620b12f19f6aff22a825d0ae78835af3a549cab;hp=ef5ece20e72863c30e08a454e1f65b14c5d14bc7;hb=c953cbb6ffc2fd50e736230f4e6976a025983cff;hpb=1e88cf0f7fa4f690ea9f110e8ed3f2b5338d0a10 diff --git a/src/dialogs.cpp b/src/dialogs.cpp index ef5ece2..d620b12 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -7,9 +7,9 @@ ** Date Started: July 2000 ** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg +** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: dialogs.cpp,v 1.9 2000/08/25 15:59:13 kevin Exp $ +** $Id: dialogs.cpp,v 1.44 2001/03/01 07:30:49 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 @@ -29,13 +29,8 @@ // #pragma implementation #endif -// For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - #ifndef WX_PRECOMP #include "wx/wx.h" #endif @@ -47,230 +42,528 @@ #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" +#include "ct.h" +#include "docs.h" +#include "views.h" +#include "imagefile.h" + +#if defined(MSVC) || HAVE_SSTREAM +#include +#else +#include +#endif -StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[]) - : wxListBox () +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// StringValueAndTitleListBox +/////////////////////////////////////////////////////////////////////// + +StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* const aszTitle[], const char* const aszValue[]) +: wxListBox () { - wxString asTitle[nChoices]; - for (int i = 0; i < nChoices; i++) - asTitle[i] = aszTitle[i]; + wxString* psTitle = new wxString [nChoices]; + for (int i = 0; i < nChoices; i++) + psTitle[i] = aszTitle[i]; + + Create (pParent, -1, wxDefaultPosition, wxSize(-1,-1), nChoices, psTitle, wxLB_SINGLE | wxLB_NEEDED_SB); + + m_ppszValues = aszValue; + delete [] psTitle; +}; - Create (pParent, -1, wxDefaultPosition, wxDefaultSize, nChoices, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB); +const char* +StringValueAndTitleListBox::getSelectionStringValue () const +{ + return m_ppszValues[GetSelection()]; +} - m_ppszValues = aszValue; +StringValueAndTitleRadioBox::StringValueAndTitleRadioBox (wxDialog* pParent, const wxString& strTitle, int nChoices, const char* const aszTitle[], const char* const aszValue[]) +: wxRadioBox () +{ + wxString* psTitle = new wxString [nChoices]; + for (int i = 0; i < nChoices; i++) + psTitle[i] = aszTitle[i]; + + Create (pParent, -1, strTitle, wxDefaultPosition, wxDefaultSize, nChoices, psTitle, 1, wxRA_SPECIFY_COLS); + + m_ppszValues = aszValue; + delete [] psTitle; }; const char* -StringValueAndTitleListBox::getSelectionStringValue (void) const +StringValueAndTitleRadioBox::getSelectionStringValue () const { return m_ppszValues[GetSelection()]; } +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// DialogGetPhantom +/////////////////////////////////////////////////////////////////////// + +DialogGetPhantom::DialogGetPhantom (wxWindow* 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, wxCENTER | wxALL, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + m_pRadioBoxPhantom = new StringValueAndTitleRadioBox (this, _T("Phantom"), Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray()); + m_pRadioBoxPhantom->SetSelection (iDefaultPhantom); + pTopSizer->Add (m_pRadioBoxPhantom, 0, wxALL | wxALIGN_CENTER); + + 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PHANTOM); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +const char* +DialogGetPhantom::getPhantom() +{ + return m_pRadioBoxPhantom->getSelectionStringValue(); +} + +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// DialogGetComparisonImage +/////////////////////////////////////////////////////////////////////// -DialogGetPhantom::DialogGetPhantom (wxFrame* pParent, int iDefaultPhantom = Phantom::PHM_HERMAN) - : wxDialog (pParent, -1, "Select Phantom", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +DialogGetComparisonImage::DialogGetComparisonImage (wxWindow* 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(); + } - 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_pListBoxImageChoices = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, iNImages, pstrImages, wxLB_SINGLE); + delete [] pstrImages; - m_pListBoxPhantom = new StringValueAndTitleListBox (this, Phantom::getPhantomCount(), Phantom::getPhantomTitleArray(), Phantom::getPhantomNameArray()); - m_pListBoxPhantom->SetSelection (iDefaultPhantom); - pTopSizer->Add (m_pListBoxPhantom, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + 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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_COMPARISON); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + pButtonOk->SetDefault(); + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -const char* -DialogGetPhantom::getPhantom(void) +ImageFileDocument* +DialogGetComparisonImage::getImageFileDocument() { - return m_pListBoxPhantom->getSelectionStringValue(); + return m_rVecIF[ m_pListBoxImageChoices->GetSelection() ]; } +bool +DialogGetComparisonImage::getMakeDifferenceImage() +{ + if (m_pMakeDifferenceImage) + return m_pMakeDifferenceImage->GetValue(); + else + return false; +} + + +///////////////////////////////////////////////////////////////////// +// CLASS DiaglogPreferences Implementation +///////////////////////////////////////////////////////////////////// -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) +DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTitle, + bool bAdvancedOptions, bool bAskDeleteNewDocs, bool bVerboseLogging, bool bStartupTips, bool bUseBackgroundTasks) +: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + 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); + + m_pCBAdvancedOptions = new wxCheckBox (this, -1, "Advanced Options", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBAdvancedOptions->SetValue (bAdvancedOptions); + pTopSizer->Add (m_pCBAdvancedOptions, 0, wxALIGN_CENTER_VERTICAL); + + m_pCBAskDeleteNewDocs = new wxCheckBox (this, -1, "Ask \"Save New Documents\" Before Closing", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBAskDeleteNewDocs->SetValue (bAskDeleteNewDocs); + pTopSizer->Add (m_pCBAskDeleteNewDocs, 0, wxALIGN_CENTER_VERTICAL); + + m_pCBVerboseLogging = new wxCheckBox (this, -1, "Verbose Logging", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBVerboseLogging->SetValue (bVerboseLogging); + pTopSizer->Add (m_pCBVerboseLogging, 0, wxALIGN_CENTER_VERTICAL); + + m_pCBStartupTips = new wxCheckBox (this, -1, "Show Tips at Start", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBStartupTips->SetValue (bStartupTips); + pTopSizer->Add (m_pCBStartupTips, 0, wxALIGN_CENTER_VERTICAL); + + m_pCBUseBackgroundTasks = new wxCheckBox (this, -1, "Put Tasks in Background", wxDefaultPosition, wxSize(250, 25), 0); + m_pCBUseBackgroundTasks->SetValue (bUseBackgroundTasks); + pTopSizer->Add (m_pCBUseBackgroundTasks, 0, wxALIGN_CENTER_VERTICAL); - pTopSizer->Add (new wxStaticText (this, -1, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PREFERENCES); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +DialogPreferences::~DialogPreferences () +{ +} + +bool +DialogPreferences::getAdvancedOptions () +{ + return static_cast(m_pCBAdvancedOptions->GetValue()); +} + +bool +DialogPreferences::getAskDeleteNewDocs () +{ + return static_cast(m_pCBAskDeleteNewDocs->GetValue()); +} + +bool +DialogPreferences::getVerboseLogging () +{ + return static_cast(m_pCBVerboseLogging->GetValue()); +} + +bool +DialogPreferences::getStartupTips () +{ + return static_cast(m_pCBStartupTips->GetValue()); +} + +bool +DialogPreferences::getUseBackgroundTasks () +{ + return static_cast(m_pCBUseBackgroundTasks->GetValue()); +} + + +///////////////////////////////////////////////////////////////////// +// CLASS DiaglogGetMinMax Implementation +///////////////////////////////////////////////////////////////////// - ostringstream os; +DialogGetMinMax::DialogGetMinMax (wxWindow* 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, pszTitle), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + 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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_MINMAX); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + pButtonOk->SetDefault(); + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -DialogGetImageMinMax::~DialogGetImageMinMax (void) +DialogGetMinMax::~DialogGetMinMax () { -#if 0 - delete m_pTextCtrlMin; - delete m_pTextCtrlMax; -#endif } double -DialogGetImageMinMax::getMinimum (void) +DialogGetMinMax::getMinimum () { - 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 () { - 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 (wxWindow *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[] = {"Median", "Mode", "Mean"}; + + m_pRadioBoxCenter = new wxRadioBox (this, -1, _T("Center"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS); + m_pRadioBoxCenter->SetSelection (0); + pTopSizer->Add (m_pRadioBoxCenter, 0, wxALL | wxALIGN_CENTER); + + 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_AUTOSCALE); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +bool +DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax) +{ + int iCenter = m_pRadioBoxCenter->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 + (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples, double dDefaultViewRatio) +: 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; + + wxFlexGridSizer *pGridSizer = new wxFlexGridSizer (2); + std::ostringstream os; os << iDefaultXSize; m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osYSize; - osYSize << iDefaultYSize; - m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - 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); pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osYSize; + osYSize << iDefaultYSize; + m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osViewRatio; + osViewRatio << dDefaultViewRatio; + m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osNSamples; + osNSamples << iDefaultNSamples; + m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); 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 (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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_RASTERIZE); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + pButtonOk->SetDefault(); + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -DialogGetRasterParameters::~DialogGetRasterParameters (void) +DialogGetRasterParameters::~DialogGetRasterParameters () { } unsigned int -DialogGetRasterParameters::getXSize (void) +DialogGetRasterParameters::getXSize () { - 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) +DialogGetRasterParameters::getYSize () { - 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) +DialogGetRasterParameters::getNSamples () { - 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 +DialogGetRasterParameters::getViewRatio () +{ + wxString strCtrl = m_pTextCtrlViewRatio->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultViewRatio); +} ///////////////////////////////////////////////////////////////////// @@ -280,152 +573,223 @@ DialogGetRasterParameters::getNSamples (void) ///////////////////////////////////////////////////////////////////// -DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., double dDefaultFocalLength = 1, double dDefaultFieldOfView = 1., int iDefaultGeometry = Scanner::GEOMETRY_PARALLEL) - : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +DialogGetProjectionParameters::DialogGetProjectionParameters + (wxWindow* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultNSamples, + double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultCenterDetectorLength, + double dDefaultViewRatio, double dDefaultScanRatio, 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_dDefaultCenterDetectorLength = dDefaultCenterDetectorLength; + m_dDefaultViewRatio = dDefaultViewRatio; + m_dDefaultScanRatio = dDefaultScanRatio; 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); + + wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2); + m_pRadioBoxGeometry = new StringValueAndTitleRadioBox (this, _T("Geometry"), Scanner::getGeometryCount(), Scanner::getGeometryTitleArray(), Scanner::getGeometryNameArray()); + m_pRadioBoxGeometry->SetSelection (iDefaultGeometry); + + pGridSizer->Add (m_pRadioBoxGeometry, 0, wxALL | wxALIGN_CENTER | wxEXPAND); + + m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), Trace::getTraceCount(), Trace::getTraceTitleArray(), Trace::getTraceNameArray()); + m_pRadioBoxTrace->SetSelection (iDefaultTrace); + pGridSizer->Add (m_pRadioBoxTrace, 0, wxALL | wxALIGN_CENTER | wxEXPAND); - 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; + wxFlexGridSizer* pText1Sizer = new wxFlexGridSizer(2); + std::ostringstream os; os << iDefaultNDet; m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osNView; + pText1Sizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText1Sizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osNView; osNView << iDefaultNView; m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osNSamples; + pText1Sizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText1Sizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osNSamples; osNSamples << iDefaultNSamples; m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osRotAngle; - osRotAngle << dDefaultRotAngle; - m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osFocalLength; + pText1Sizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText1Sizer->Add (m_pTextCtrlNSamples, 0, wxALIGN_CENTER_VERTICAL); + + pGridSizer->Add (pText1Sizer); + + wxFlexGridSizer* pText2Sizer = new wxFlexGridSizer(2); + std::ostringstream osViewRatio; + osViewRatio << dDefaultViewRatio; + m_pTextCtrlViewRatio = new wxTextCtrl (this, -1, osViewRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pText2Sizer->Add (new wxStaticText (this, -1, "View Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText2Sizer->Add (m_pTextCtrlViewRatio, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osScanRatio; + osScanRatio << dDefaultScanRatio; + m_pTextCtrlScanRatio = new wxTextCtrl (this, -1, osScanRatio.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pText2Sizer->Add (new wxStaticText (this, -1, "Scan Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText2Sizer->Add (m_pTextCtrlScanRatio, 0, wxALIGN_CENTER_VERTICAL); + std::ostringstream osFocalLength; osFocalLength << dDefaultFocalLength; m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osFieldOfView; - osFieldOfView << dDefaultFieldOfView; - m_pTextCtrlFieldOfView = new wxTextCtrl (this, -1, osFieldOfView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - - wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5); - 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); - pGridSizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - 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); - pTopSizer->Add (pGridSizer, 1, wxALL, 10); + pText2Sizer->Add (new wxStaticText (this, -1, "Focal Length Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText2Sizer->Add (m_pTextCtrlFocalLength, 0, wxALIGN_CENTER_VERTICAL); + + std::ostringstream osCenterDetectorLength; + osCenterDetectorLength << dDefaultCenterDetectorLength; + m_pTextCtrlCenterDetectorLength = new wxTextCtrl (this, -1, osCenterDetectorLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pText2Sizer->Add (new wxStaticText (this, -1, "Center-Detector Length Ratio"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText2Sizer->Add (m_pTextCtrlCenterDetectorLength, 0, wxALIGN_CENTER_VERTICAL); + + if (theApp->getAdvancedOptions()) { + std::ostringstream osRotAngle; + osRotAngle << dDefaultRotAngle; + m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pText2Sizer->Add (new wxStaticText (this, -1, "Rotation Angle (Fraction of circle)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pText2Sizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL); + } + pGridSizer->Add (pText2Sizer); + 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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_PROJECTIONS); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + pButtonOk->SetDefault(); + SetAutoLayout (true); SetSizer (pTopSizer); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -DialogGetProjectionParameters::~DialogGetProjectionParameters (void) +DialogGetProjectionParameters::~DialogGetProjectionParameters () { } unsigned int -DialogGetProjectionParameters::getNDet (void) +DialogGetProjectionParameters::getNDet () { - 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) +DialogGetProjectionParameters::getNView () { - 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) +DialogGetProjectionParameters::getNSamples () { - 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) +DialogGetProjectionParameters::getRotAngle () { + if (theApp->getAdvancedOptions()) { wxString strCtrl = m_pTextCtrlRotAngle->GetValue(); double dValue; if (strCtrl.ToDouble (&dValue)) - return (dValue * PI); + return (dValue * TWOPI); else return (m_dDefaultRotAngle); + } else { + if (Scanner::convertGeometryNameToID (m_pRadioBoxGeometry->getSelectionStringValue()) == + Scanner::GEOMETRY_PARALLEL) + return (PI); + else + return (TWOPI); + } } double -DialogGetProjectionParameters::getFocalLengthRatio (void) +DialogGetProjectionParameters::getFocalLengthRatio () { - wxString strCtrl = m_pTextCtrlFocalLength->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return (dValue); - else - return (m_dDefaultFocalLength); + wxString strCtrl = m_pTextCtrlFocalLength->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultFocalLength); } double -DialogGetProjectionParameters::getFieldOfViewRatio (void) +DialogGetProjectionParameters::getCenterDetectorLengthRatio () { - wxString strCtrl = m_pTextCtrlFieldOfView->GetValue(); - double dValue; - if (strCtrl.ToDouble (&dValue)) - return (dValue); - else - return (m_dDefaultFieldOfView); + wxString strCtrl = m_pTextCtrlCenterDetectorLength->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultCenterDetectorLength); +} + +double +DialogGetProjectionParameters::getViewRatio () +{ + wxString strCtrl = m_pTextCtrlViewRatio->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultViewRatio); +} + +double +DialogGetProjectionParameters::getScanRatio () +{ + wxString strCtrl = m_pTextCtrlScanRatio->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultScanRatio); } const char* -DialogGetProjectionParameters::getGeometry (void) +DialogGetProjectionParameters::getGeometry () +{ + return m_pRadioBoxGeometry->getSelectionStringValue(); +} + +int +DialogGetProjectionParameters::getTrace () { - return m_pListBoxGeometry->getSelectionStringValue(); + return Trace::convertTraceNameToID(m_pRadioBoxTrace->getSelectionStringValue()); } @@ -437,204 +801,500 @@ DialogGetProjectionParameters::getGeometry (void) ///////////////////////////////////////////////////////////////////// -DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultFilterID = SignalFilter::FILTER_ABS_BANDLIMIT, double dDefaultFilterParam = 1., int iDefaultFilterMethodID = ProcessSignal::FILTER_METHOD_CONVOLUTION, int iDefaultFilterGenerationID = ProcessSignal::FILTER_GENERATION_INVALID, 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) +DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxWindow* pParent, int iDefaultXSize, + int iDefaultYSize, int iDefaultFilterID, double dDefaultHammingParam, + 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); + + wxFlexGridSizer* pGridSizer = NULL; + if (theApp->getAdvancedOptions()) + pGridSizer = new wxFlexGridSizer (4); + else + pGridSizer = new wxFlexGridSizer (3); + + if (theApp->getAdvancedOptions()) + m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray()); + else + m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getReconstructFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray()); + m_pRadioBoxFilter->SetSelection (iDefaultFilterID); + pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + if (theApp->getAdvancedOptions()) { + m_pRadioBoxFilterMethod = new StringValueAndTitleRadioBox (this, _T("Filter Method"), ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray()); + m_pRadioBoxFilterMethod->SetSelection (iDefaultFilterMethodID); + pGridSizer->Add (m_pRadioBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + } else { +#if HAVE_FFTW + static const char* aszFilterMethodTitle[] = {"Convolution", "FFT"}; + static const char* aszFilterMethodName[] = {"convolution", "rfftw"}; +#else + static const char* aszFilterMethodTitle[] = {"Convolution", "Fourier"}; + static const char* aszFilterMethodName[] = {"convolution", "fourier-table"}; +#endif + m_pRadioBoxFilterMethod = new StringValueAndTitleRadioBox (this, _T("Filter Method"), 2, aszFilterMethodTitle, aszFilterMethodName); +#if HAVE_FFTW + m_pRadioBoxFilterMethod->SetSelection (1); +#else + m_pRadioBoxFilterMethod->SetSelection (0); +#endif + pGridSizer->Add (m_pRadioBoxFilterMethod, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + } - 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, ProcessSignal::getFilterMethodCount(), ProcessSignal::getFilterMethodTitleArray(), ProcessSignal::getFilterMethodNameArray()); - m_pListBoxFilterMethod->SetSelection (iDefaultFilterMethodID); - pTopSizer->Add (m_pListBoxFilterMethod, 0, wxALL | wxALIGN_CENTER | wxEXPAND); - m_pListBoxFilterGeneration = new StringValueAndTitleListBox (this, ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray()); - m_pListBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID); - pTopSizer->Add (m_pListBoxFilterGeneration, 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); + if (theApp->getAdvancedOptions()) { + m_pRadioBoxFilterGeneration = new StringValueAndTitleRadioBox (this, _T("Filter Generation"), ProcessSignal::getFilterGenerationCount(), ProcessSignal::getFilterGenerationTitleArray(), ProcessSignal::getFilterGenerationNameArray()); + m_pRadioBoxFilterGeneration->SetSelection (iDefaultFilterGenerationID); + pGridSizer->Add (m_pRadioBoxFilterGeneration, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + m_pRadioBoxBackproject = new StringValueAndTitleRadioBox (this, _T("Backprojection"), Backprojector::getBackprojectCount(), Backprojector::getBackprojectTitleArray(), Backprojector::getBackprojectNameArray()); + m_pRadioBoxBackproject->SetSelection (iDefaultBackprojectID); + pGridSizer->Add (m_pRadioBoxBackproject, 0, wxALL | wxALIGN_RIGHT | wxEXPAND); + } - ostringstream os; + m_pRadioBoxInterp = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Backprojector::getInterpCount(), Backprojector::getInterpTitleArray(), Backprojector::getInterpNameArray()); + m_pRadioBoxInterp->SetSelection (iDefaultInterpID); + pGridSizer->Add (m_pRadioBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND); + + static const char* aszTraceTitle[] = {"None", "Full"}; + static const char* aszTraceName[] = {"none", "full"}; + m_pRadioBoxTrace = new StringValueAndTitleRadioBox (this, _T("Trace Level"), 2, aszTraceTitle, aszTraceName); + iTrace = clamp(iTrace, 0, 1); + m_pRadioBoxTrace->SetSelection (iTrace); + pGridSizer->Add (m_pRadioBoxTrace); + + wxFlexGridSizer* pTextGridSizer = new wxFlexGridSizer (2); + std::ostringstream os; os << iDefaultXSize; m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osYSize; + pTextGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + std::ostringstream osYSize; osYSize << iDefaultYSize; m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osFilterParam; - osFilterParam << dDefaultFilterParam; - m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osZeropad; - osZeropad << iDefaultZeropad; - m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); - ostringstream osInterpParam; + pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osHammingParam; + osHammingParam << dDefaultHammingParam; + m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osHammingParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pTextGridSizer->Add (new wxStaticText (this, -1, "Hamming Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + if (theApp->getAdvancedOptions()) { + std::ostringstream osZeropad; + osZeropad << iDefaultZeropad; + m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + } + pGridSizer->Add (pTextGridSizer); + +#if HAVE_FREQ_PREINTERP + 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); - 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); - pGridSizer->Add (m_pTextCtrlYSize, 0, 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 (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - pGridSizer->Add (m_pTextCtrlZeropad, 0, 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); - + pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); +#endif + + 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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); - + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_RECONSTRUCTION); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); - + pButtonOk->SetDefault(); + SetAutoLayout (true); SetSizer (pTopSizer); + pTopSizer->Layout(); pTopSizer->Fit (this); pTopSizer->SetSizeHints (this); } -DialogGetReconstructionParameters::~DialogGetReconstructionParameters (void) +DialogGetReconstructionParameters::~DialogGetReconstructionParameters () { } unsigned int -DialogGetReconstructionParameters::getXSize (void) +DialogGetReconstructionParameters::getXSize () { - 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) +DialogGetReconstructionParameters::getYSize () { - 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) +DialogGetReconstructionParameters::getZeropad () { + if (theApp->getAdvancedOptions()) { wxString strCtrl = m_pTextCtrlZeropad->GetValue(); unsigned long lValue; if (strCtrl.ToULong (&lValue)) - return lValue; + return lValue; else - return (m_iDefaultZeropad); + return (m_iDefaultZeropad); + } else + return 1; } unsigned int -DialogGetReconstructionParameters::getInterpParam (void) +DialogGetReconstructionParameters::getInterpParam () { - wxString strCtrl = m_pTextCtrlInterpParam->GetValue(); - unsigned long lValue; - if (strCtrl.ToULong (&lValue)) - return lValue; - else - return (m_iDefaultInterpParam); +#if HAVE_FREQ_PREINTERP + wxString strCtrl = m_pTextCtrlInterpParam->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultInterpParam); +#else + return 1; +#endif } double -DialogGetReconstructionParameters::getFilterParam (void) +DialogGetReconstructionParameters::getFilterParam () { - 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 char* -DialogGetReconstructionParameters::getFilterName (void) +DialogGetReconstructionParameters::getFilterName () { - return m_pListBoxFilter->getSelectionStringValue(); + return m_pRadioBoxFilter->getSelectionStringValue(); } const char* -DialogGetReconstructionParameters::getFilterMethodName (void) +DialogGetReconstructionParameters::getFilterMethodName () { - return m_pListBoxFilterMethod->getSelectionStringValue(); + return m_pRadioBoxFilterMethod->getSelectionStringValue(); } const char* -DialogGetReconstructionParameters::getInterpName (void) +DialogGetReconstructionParameters::getInterpName () +{ + return m_pRadioBoxInterp->getSelectionStringValue(); +} + +int +DialogGetReconstructionParameters::getTrace () { - return m_pListBoxInterp->getSelectionStringValue(); + int iTrace = 0; + if (strcmp("full", m_pRadioBoxTrace->getSelectionStringValue()) == 0) + iTrace = Trace::TRACE_PLOT; + return iTrace; } const char* -DialogGetReconstructionParameters::getBackprojectName (void) +DialogGetReconstructionParameters::getBackprojectName () { - return m_pListBoxBackproject->getSelectionStringValue(); + if (theApp->getAdvancedOptions()) { + return m_pRadioBoxBackproject->getSelectionStringValue(); + } else + return "idiff"; } const char* -DialogGetReconstructionParameters::getFilterGenerationName (void) +DialogGetReconstructionParameters::getFilterGenerationName () { - return m_pListBoxFilterGeneration->getSelectionStringValue(); + if (theApp->getAdvancedOptions()) { + return m_pRadioBoxFilterGeneration->getSelectionStringValue(); + } else { + if (ProcessSignal::convertFilterMethodNameToID(m_pRadioBoxFilterMethod->getSelectionStringValue()) + == ProcessSignal::FILTER_METHOD_CONVOLUTION) + return "direct"; + else + return "inverse-fourier"; + } } -DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, const ImageFile& rIF) - : wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rImageFile(rIF) +///////////////////////////////////////////////////////////////////// +// CLASS IDENTIFICATION +// +// DialogGetFilterParameters +///////////////////////////////////////////////////////////////////// + + + +DialogGetFilterParameters::DialogGetFilterParameters (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultFilterID, double dDefaultFilterParam, double dDefaultBandwidth, int iDefaultDomainID, double dDefaultInputScale, double dDefaultOutputScale) +: wxDialog (pParent, -1, "Set Filter Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) { wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, "Set Filter Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5); + + wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2); - pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); - + m_pRadioBoxFilter = new StringValueAndTitleRadioBox (this, _T("Filter"), SignalFilter::getFilterCount(), SignalFilter::getFilterTitleArray(), SignalFilter::getFilterNameArray()); + m_pRadioBoxFilter->SetSelection (iDefaultFilterID); + pGridSizer->Add (m_pRadioBoxFilter, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + m_pRadioBoxDomain = new StringValueAndTitleRadioBox (this, _T("Domain"), SignalFilter::getDomainCount(), SignalFilter::getDomainTitleArray(), SignalFilter::getDomainNameArray()); + m_pRadioBoxDomain->SetSelection (iDefaultDomainID); + pGridSizer->Add (m_pRadioBoxDomain, 0, wxALL | wxALIGN_LEFT | wxEXPAND); + + std::ostringstream os; + os << iDefaultXSize; + m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osYSize; + osYSize << iDefaultYSize; + m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osFilterParam; + osFilterParam << dDefaultFilterParam; + m_pTextCtrlFilterParam = new wxTextCtrl (this, -1, osFilterParam.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "Filter Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlFilterParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osBandwidth; + osBandwidth << dDefaultBandwidth; + m_pTextCtrlBandwidth = new wxTextCtrl (this, -1, osBandwidth.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "Bandwidth"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlBandwidth, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osInputScale; + osInputScale << dDefaultInputScale; + m_pTextCtrlInputScale = new wxTextCtrl (this, -1, osInputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "Axis (input) Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlInputScale, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + std::ostringstream osOutputScale; + osOutputScale << dDefaultOutputScale; + m_pTextCtrlOutputScale = new wxTextCtrl (this, -1, osOutputScale.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pGridSizer->Add (new wxStaticText (this, -1, "Filter Output Scale"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pGridSizer->Add (m_pTextCtrlOutputScale, 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_FILTER); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); - wxString asTitle[3]; - asTitle[0] = "Median"; - asTitle[1] = "Mode"; - asTitle[2] = "Mean"; + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Layout(); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} - 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); +DialogGetFilterParameters::~DialogGetFilterParameters () +{ +} - wxGridSizer *pGridSizer = new wxGridSizer (2, 2, 5); - pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, "1.0", 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); +unsigned int +DialogGetFilterParameters::getXSize () +{ + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); +} + +unsigned int +DialogGetFilterParameters::getYSize () +{ + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); +} + +double +DialogGetFilterParameters::getBandwidth () +{ + wxString strCtrl = m_pTextCtrlBandwidth->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultBandwidth); +} + +double +DialogGetFilterParameters::getFilterParam () +{ + wxString strCtrl = m_pTextCtrlFilterParam->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return (dValue); + else + return (m_dDefaultFilterParam); +} + +double +DialogGetFilterParameters::getInputScale () +{ + wxString strCtrl = m_pTextCtrlInputScale->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultInputScale); +} + +double +DialogGetFilterParameters::getOutputScale () +{ + wxString strCtrl = m_pTextCtrlOutputScale->GetValue(); + double dValue; + if (strCtrl.ToDouble (&dValue)) + return dValue; + else + return (m_dDefaultOutputScale); +} +const char* +DialogGetFilterParameters::getFilterName () +{ + return m_pRadioBoxFilter->getSelectionStringValue(); +} + +const char* +DialogGetFilterParameters::getDomainName () +{ + return m_pRadioBoxDomain->getSelectionStringValue(); +} + + +/////////////////////////////////////////////////////////////////////// +// CLASS IMPLEMENTATION +// DialogExportParameters +/////////////////////////////////////////////////////////////////////// + +DialogExportParameters::DialogExportParameters (wxWindow* pParent, int iDefaultFormatID) +: wxDialog (pParent, -1, "Select ExportParameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +{ + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + pTopSizer->Add (new wxStaticText (this, -1, "Select Export Format"), 0, wxALIGN_CENTER | wxALL, 5); + + pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxALL, 5); + + m_pRadioBoxFormat = new StringValueAndTitleRadioBox (this, _T("Export Type"), ImageFile::getFormatCount(), ImageFile::getFormatTitleArray(), ImageFile::getFormatNameArray()); + m_pRadioBoxFormat->SetSelection (iDefaultFormatID); + pTopSizer->Add (m_pRadioBoxFormat, 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); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_EXPORT); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); + + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + +const char* +DialogExportParameters::getFormatName() +{ + return m_pRadioBoxFormat->getSelectionStringValue(); +} + + +///////////////////////////////////////////////////////////////////// +// CLASS DiaglogGetXYSize Implementation +///////////////////////////////////////////////////////////////////// +DialogGetXYSize::DialogGetXYSize (wxWindow* pParent, const char* const pszTitle, int iDefaultXSize, int iDefaultYSize) +: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +{ + m_iDefaultXSize = iDefaultXSize; + m_iDefaultYSize = iDefaultYSize; + + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); + + 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); + + std::ostringstream os; + os << iDefaultXSize; + m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + std::ostringstream osYSize; + osYSize << iDefaultYSize; + m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + + 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); + pGridSizer->Add (m_pTextCtrlYSize, 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); SetAutoLayout (true); SetSizer (pTopSizer); @@ -642,27 +1302,149 @@ DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, const Im pTopSizer->SetSizeHints (this); } -void -DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax) +DialogGetXYSize::~DialogGetXYSize () { - int iCenter = m_pListBoxCenter->GetSelection(); - double min, max, mean, mode, median, stddev; - m_rImageFile.statistics (min, max, mean, mode, median, stddev); - double dCenter = median; - if (iCenter == 1) - dCenter = mode; - else if (iCenter == 2) - dCenter = mean; +} + +unsigned int +DialogGetXYSize::getXSize () +{ + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + long lValue; + if (strCtrl.ToLong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); +} + +unsigned int +DialogGetXYSize::getYSize () +{ + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + long lValue; + if (strCtrl.ToLong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); +} + + + +///////////////////////////////////////////////////////////////////// +// CLASS IDENTIFICATION +// +// DialogGetConvertPolarParameters +///////////////////////////////////////////////////////////////////// + +DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pParent, const char* const pszTitle, + int iDefaultXSize, int iDefaultYSize, int iDefaultInterpolationID, int iDefaultZeropad) +: wxDialog (pParent, -1, pszTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +{ + m_iDefaultXSize = iDefaultXSize; + m_iDefaultYSize = iDefaultYSize; + m_iDefaultZeropad = iDefaultZeropad; + + wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL); - wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue(); - double dValue; - if (! sStddevFactor.ToDouble (&dValue)) { - *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n"; - *pMin = min; - *pMax = max; + 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); + + wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (1); + + m_pRadioBoxInterpolation = new StringValueAndTitleRadioBox (this, _T("Interpolation"), Projections::getInterpCount(), Projections::getInterpTitleArray(), Projections::getInterpNameArray()); + m_pRadioBoxInterpolation->SetSelection (iDefaultInterpolationID); + pGridSizer->Add (m_pRadioBoxInterpolation, 0, wxALL | wxALIGN_CENTER); + + wxFlexGridSizer* pTextGridSizer = new wxFlexGridSizer (2); + std::ostringstream os; + os << iDefaultXSize; + m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pTextGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + std::ostringstream osYSize; + osYSize << iDefaultYSize; + m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); +#ifdef DEBUG + if (iDefaultZeropad >= 0) { + std::ostringstream osZeropad; + osZeropad << iDefaultZeropad; + m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0); + pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); } - double dHalfWidth = dValue * stddev / 2; - *pMin = dCenter - dHalfWidth; - *pMax = dCenter + dHalfWidth; - *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n"; +#endif + + pGridSizer->Add (pTextGridSizer, 0, wxALIGN_CENTER | wxALL); + + pTopSizer->Add (pGridSizer, 1, wxALL | wxALIGN_CENTER, 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"); + pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10); + wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel"); + pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10); + CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_POLAR); + pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10); + + pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER); + pButtonOk->SetDefault(); + SetAutoLayout (true); + SetSizer (pTopSizer); + pTopSizer->Layout(); + pTopSizer->Fit (this); + pTopSizer->SetSizeHints (this); +} + + +DialogGetConvertPolarParameters::~DialogGetConvertPolarParameters () +{ +} + + +unsigned int +DialogGetConvertPolarParameters::getXSize () +{ + wxString strCtrl = m_pTextCtrlXSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultXSize); +} + +unsigned int +DialogGetConvertPolarParameters::getYSize () +{ + wxString strCtrl = m_pTextCtrlYSize->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultYSize); +} + +unsigned int +DialogGetConvertPolarParameters::getZeropad () +{ +#ifdef DEBUG + wxString strCtrl = m_pTextCtrlZeropad->GetValue(); + unsigned long lValue; + if (strCtrl.ToULong (&lValue)) + return lValue; + else + return (m_iDefaultZeropad); +#else + return 0; +#endif } + +const char* +DialogGetConvertPolarParameters::getInterpolationName () +{ + return m_pRadioBoxInterpolation->getSelectionStringValue(); +} +