** 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
return m_pListBoxPhantom->getSelectionStringValue();
}
+\r
+/////////////////////////////////////////////////////////////////////\r
+// CLASS DiaglogGetMinMax Implementation\r
+/////////////////////////////////////////////////////////////////////\r
-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);
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;
}
double
-DialogGetImageMinMax::getMaximum (void)
+DialogGetMinMax::getMaximum (void)
{
wxString strCtrl = m_pTextCtrlMax->GetValue();
double dValue;
}
+/////////////////////////////////////////////////////////////////////\r
+// CLASS DialogAutoScaleParameters IMPLEMENTATION\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, double mean, double mode, double median, double stddev, double dDefaultScaleFactor)\r
+ : wxDialog (pParent, -1, "Auto Scale Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION), m_dMean(mean), m_dMode(mode), m_dMedian(median), m_dStdDev(stddev)\r
+{\r
+ wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);\r
+\r
+ pTopSizer->Add (new wxStaticText (this, -1, "Auto Scale Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);\r
+ \r
+ pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
+\r
+ wxString asTitle[3];\r
+ asTitle[0] = "Median";\r
+ asTitle[1] = "Mode";\r
+ asTitle[2] = "Mean";\r
+\r
+ m_pListBoxCenter = new wxListBox (this, -1, wxDefaultPosition, wxDefaultSize, 3, asTitle, wxLB_SINGLE | wxLB_NEEDED_SB);\r
+ m_pListBoxCenter->SetSelection (0);\r
+ pTopSizer->Add (m_pListBoxCenter, 0, wxALL | wxALIGN_CENTER | wxEXPAND);\r
+\r
+ wxGridSizer *pGridSizer = new wxGridSizer (2);\r
+ pGridSizer->Add (new wxStaticText (this, -1, "Standard Deviation Factor"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);\r
+ std::ostringstream osDefaultFactor;\r
+ osDefaultFactor << dDefaultScaleFactor;\r
+ m_pTextCtrlStdDevFactor = new wxTextCtrl (this, -1, osDefaultFactor.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);\r
+ pGridSizer->Add (m_pTextCtrlStdDevFactor, 0, wxALIGN_CENTER_VERTICAL);\r
+ pTopSizer->Add (pGridSizer, 1, wxALL, 10);\r
+\r
+ pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);\r
+\r
+ wxBoxSizer* pButtonSizer = new wxBoxSizer (wxHORIZONTAL);\r
+ wxButton* pButtonOk = new wxButton (this, wxID_OK, "Okay");\r
+ wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");\r
+ pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);\r
+ pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);\r
+\r
+ pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);\r
+\r
+ SetAutoLayout (true);\r
+ SetSizer (pTopSizer);\r
+ pTopSizer->Fit (this);\r
+ pTopSizer->SetSizeHints (this);\r
+}\r
+\r
+bool\r
+DialogAutoScaleParameters::getMinMax (double* pMin, double* pMax)\r
+{\r
+ int iCenter = m_pListBoxCenter->GetSelection();\r
+ double dCenter = m_dMedian;\r
+ if (iCenter == 1)\r
+ dCenter = m_dMode;\r
+ else if (iCenter == 2)\r
+ dCenter = m_dMode;\r
+ \r
+ wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();\r
+ double dValue;\r
+ if (! sStddevFactor.ToDouble (&dValue)) {\r
+ *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";\r
+ return false;\r
+ }\r
+ double dHalfWidth = dValue * m_dStdDev / 2;\r
+ *pMin = dCenter - dHalfWidth;\r
+ *pMax = dCenter + dHalfWidth;\r
+ *theApp->getLog() << "Setting minimum to " << *pMin << " and maximum to " << *pMax << "\n";\r
+\r
+ return true;\r
+}\r
+\r
+double\r
+DialogAutoScaleParameters::getAutoScaleFactor ()\r
+{\r
+ wxString sStddevFactor = m_pTextCtrlStdDevFactor->GetValue();\r
+ double dValue = 1.;\r
+ if (! sStddevFactor.ToDouble (&dValue)) {\r
+ *theApp->getLog() << "Error: Non-numeric Standard Deviation Factor of " << sStddevFactor << "\n";\r
+ }\r
+\r
+ return dValue;\r
+}\r
+\r
+\r
/////////////////////////////////////////////////////////////////////
// CLASS IDENTIFICATION
//
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;
-}
+\r