+/////////////////////////////////////////////////////////////////////\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