X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fdialogs.cpp;h=622efb29f56773e553b41ab8b7c6f486ee091345;hp=f2102d03931d146b127a43b7b5c2bcb85a873c01;hb=fd1d136a94a6d20013f38d6a997bdfefad0f5e98;hpb=efc398029330f4d9170257db29e4420e50f25625 diff --git a/src/dialogs.cpp b/src/dialogs.cpp index f2102d0..622efb2 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.17 2000/12/17 19:30:02 kevin Exp $ +** $Id: dialogs.cpp,v 1.18 2000/12/20 20:08:48 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 @@ -117,13 +117,17 @@ DialogGetPhantom::getPhantom(void) return m_pListBoxPhantom->getSelectionStringValue(); } + +///////////////////////////////////////////////////////////////////// +// CLASS DiaglogGetMinMax Implementation +///////////////////////////////////////////////////////////////////// -DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin, double dDefaultMax) - : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION) +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); @@ -157,16 +161,12 @@ DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& r 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; @@ -177,7 +177,7 @@ DialogGetImageMinMax::getMinimum (void) } double -DialogGetImageMinMax::getMaximum (void) +DialogGetMinMax::getMaximum (void) { wxString strCtrl = m_pTextCtrlMax->GetValue(); double dValue; @@ -188,6 +188,89 @@ DialogGetImageMinMax::getMaximum (void) } +///////////////////////////////////////////////////////////////////// +// 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 // @@ -650,82 +733,4 @@ DialogGetReconstructionParameters::getFilterGenerationName (void) return m_pListBoxFilterGeneration->getSelectionStringValue(); } - -DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, const ImageFile& rIF, double dDefaultScaleFactor) - : wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_rImageFile(rIF) -{ - 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); -} - -void -DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax) -{ - 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; - - 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; - } - double dHalfWidth = dValue * stddev / 2; - *pMin = dCenter - dHalfWidth; - *pMax = dCenter + dHalfWidth; - *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n"; -} - -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; -} +