r309: plotfile changes
[ctsim.git] / src / dialogs.cpp
index 87542a9e64e6f8208f90e77b388210e12dac7614..622efb29f56773e553b41ab8b7c6f486ee091345 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dialogs.cpp,v 1.14 2000/12/16 03:29: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
@@ -47,7 +47,6 @@
 #include "wx/statline.h"
 #include "wx/sizer.h"
 #include "dialogs.h"
-#include <sstream>
 #include "ctsupport.h"
 #include "ctsim.h"
 #include "scanner.h"
 #include "filter.h"
 #include "backprojectors.h"
 
+#if defined(MSVC) || HAVE_SSTREAM\r
+#include <sstream>\r
+#else\r
+#include <sstream_subst>\r
+#endif\r
+\r
 
 StringValueAndTitleListBox::StringValueAndTitleListBox (wxDialog* pParent, int nChoices, const char* aszTitle[], const char* aszValue[])
   : wxListBox ()
@@ -112,20 +117,24 @@ DialogGetPhantom::getPhantom(void)
     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);
 
-  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);
 
@@ -152,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;
@@ -172,7 +177,7 @@ DialogGetImageMinMax::getMinimum (void)
 }
 
 double
-DialogGetImageMinMax::getMaximum (void)
+DialogGetMinMax::getMaximum (void)
 {
     wxString strCtrl = m_pTextCtrlMax->GetValue();
     double dValue;
@@ -183,6 +188,89 @@ DialogGetImageMinMax::getMaximum (void)
 }
 
 
+/////////////////////////////////////////////////////////////////////\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
 //
@@ -198,13 +286,13 @@ DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDef
                   
   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);
 
@@ -299,22 +387,22 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent,
                   
   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);
-  ostringstream osFocalLength;
+  std::ostringstream osFocalLength;
   osFocalLength << dDefaultFocalLength;
   m_pTextCtrlFocalLength = new wxTextCtrl (this, -1, osFocalLength.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
-  ostringstream osFieldOfView;
+  std::ostringstream osFieldOfView;
   osFieldOfView << dDefaultFieldOfView;
   m_pTextCtrlFieldOfView = new wxTextCtrl (this, -1, osFieldOfView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
 
@@ -463,23 +551,23 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p
                   
   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);
 
-  wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
+  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);
@@ -494,7 +582,8 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p
   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);
-
+\r
+  
   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);
@@ -506,6 +595,14 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p
   pGridSizer->Add (m_pListBoxInterp, 0, wxALL | wxALIGN_RIGHT | wxEXPAND);
 
 
+  pGridSizer->Add (new wxStaticText (this, -1, "Trace Level"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);\r
+  static const char* aszTraceTitle[] = {"None", "Full"};\r
+  static const char* aszTraceName[] = {"none", "full"};\r
+  m_pListBoxTrace = new StringValueAndTitleListBox (this, 2, aszTraceTitle, aszTraceName);\r
+  iTrace = clamp(iTrace, 0, 1);\r
+  m_pListBoxTrace->SetSelection (iTrace);\r
+  pGridSizer->Add (m_pListBoxTrace);\r
+\r
   pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | 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);
@@ -517,14 +614,6 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxFrame* p
   pGridSizer->Add (new wxStaticText (this, -1, "Interpolation Parameter"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
   pGridSizer->Add (m_pTextCtrlInterpParam, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
 
-  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);
-
   pTopSizer->Add (pGridSizer, 1, wxALL, 3);
 
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
@@ -644,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);
-  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