r184: *** empty log message ***
[ctsim.git] / src / dialogs.cpp
index 4b2738ff2111cac5f5ef58fff26540812a38dff5..ef5ece20e72863c30e08a454e1f65b14c5d14bc7 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dialogs.cpp,v 1.8 2000/08/22 07:02:48 kevin Exp $
+**  $Id: dialogs.cpp,v 1.9 2000/08/25 15:59:13 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
 **
 **  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
@@ -280,11 +280,18 @@ DialogGetRasterParameters::getNSamples (void)
 /////////////////////////////////////////////////////////////////////
 
 
 /////////////////////////////////////////////////////////////////////
 
 
-DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., int iDefaultGeometry = Scanner::GEOMETRY_PARALLEL)
-    : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+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)
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
 
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
 
+  m_dDefaultRotAngle = dDefaultRotAngle;
+  m_dDefaultFocalLength = dDefaultFocalLength;
+  m_dDefaultFieldOfView = dDefaultFieldOfView;
+  m_iDefaultNSamples = iDefaultNSamples;
+  m_iDefaultNView = iDefaultNView;
+  m_iDefaultNDet = iDefaultNDet;
+
   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);
   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);
@@ -305,6 +312,12 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent,
   ostringstream osRotAngle;
   osRotAngle << dDefaultRotAngle;
   m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.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;
+  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);
 
   wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5);
   pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
@@ -315,6 +328,10 @@ DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent,
   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 (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);
 
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
   pTopSizer->Add (pGridSizer, 1, wxALL, 10);
 
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
@@ -383,6 +400,28 @@ DialogGetProjectionParameters::getRotAngle (void)
       return (m_dDefaultRotAngle);
 }
 
       return (m_dDefaultRotAngle);
 }
 
+double
+DialogGetProjectionParameters::getFocalLengthRatio (void)
+{
+    wxString strCtrl = m_pTextCtrlFocalLength->GetValue();
+    double dValue;
+    if (strCtrl.ToDouble (&dValue))
+       return (dValue);
+    else
+      return (m_dDefaultFocalLength);
+}
+
+double
+DialogGetProjectionParameters::getFieldOfViewRatio (void)
+{
+    wxString strCtrl = m_pTextCtrlFieldOfView->GetValue();
+    double dValue;
+    if (strCtrl.ToDouble (&dValue))
+       return (dValue);
+    else
+      return (m_dDefaultFieldOfView);
+}
+
 const char*
 DialogGetProjectionParameters::getGeometry (void)
 {
 const char*
 DialogGetProjectionParameters::getGeometry (void)
 {
@@ -561,3 +600,69 @@ DialogGetReconstructionParameters::getFilterGenerationName (void)
 {
   return m_pListBoxFilterGeneration->getSelectionStringValue();
 }
 {
   return m_pListBoxFilterGeneration->getSelectionStringValue();
 }
+
+
+DialogAutoScaleParameters::DialogAutoScaleParameters (wxFrame *pParent, const ImageFile& rIF)
+  : 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, 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);
+
+  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";
+}