r1883: *** empty log message ***
[ctsim.git] / src / dialogs.cpp
index 57dc3f73a42d8ec1db7407e83cfbcef7b3ef1dac..03e1f7240aa69e4dd500aaa78f41098963aee7ee 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: dialogs.cpp,v 1.51 2001/03/11 17:55:29 kevin Exp $
+**  $Id: dialogs.cpp,v 1.57 2002/05/03 09:57:41 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,6 +47,7 @@
 #include "docs.h"
 #include "views.h"
 #include "imagefile.h"
+#include "projections.h"
 
 #if defined(MSVC) || HAVE_SSTREAM
 #include <sstream>
@@ -142,6 +143,64 @@ DialogGetPhantom::getPhantom()
 }
 
 
+///////////////////////////////////////////////////////////////////////
+// CLASS IMPLEMENTATION
+//    DialogGetThetaRange
+///////////////////////////////////////////////////////////////////////
+
+DialogGetThetaRange::DialogGetThetaRange (wxWindow* pParent, int iDefaultThetaRange)
+: wxDialog (pParent, -1, _T("Select Phantom"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+{
+  wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
+  
+  pTopSizer->Add (new wxStaticText (this, -1, "Select Theta Range"), 0, wxCENTER | wxALL, 5);
+  
+  pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+  
+  wxString asTitle[] = {"Unconstrained", "Normalized to 2pi", "Fold to pi"};
+  
+  m_pRadioBoxThetaRange = new wxRadioBox (this, -1, _T("Theta Range"), wxDefaultPosition, wxDefaultSize, 3, asTitle, 1, wxRA_SPECIFY_COLS);
+  if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_UNCONSTRAINED)
+    m_pRadioBoxThetaRange->SetSelection (0);
+  else if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_NORMALIZE_TO_TWOPI)
+    m_pRadioBoxThetaRange->SetSelection (1);
+  else if (iDefaultThetaRange == ParallelRaysums::THETA_RANGE_FOLD_TO_PI)
+    m_pRadioBoxThetaRange->SetSelection (2);
+
+  pTopSizer->Add (m_pRadioBoxThetaRange, 0, wxALL | wxALIGN_CENTER);
+  
+  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");
+  pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
+  wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
+  pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
+  CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_THETA_RANGE);
+  pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
+
+  pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
+  pButtonOk->SetDefault();
+  
+  SetAutoLayout (true);
+  SetSizer (pTopSizer);
+  pTopSizer->Fit (this);
+  pTopSizer->SetSizeHints (this);
+}
+
+int
+DialogGetThetaRange::getThetaRange()
+{
+  int iSelection = m_pRadioBoxThetaRange->GetSelection();
+  if (iSelection == 0)
+    return ParallelRaysums::THETA_RANGE_UNCONSTRAINED;
+  else if (iSelection == 1)
+    return ParallelRaysums::THETA_RANGE_NORMALIZE_TO_TWOPI;
+  else
+    return ParallelRaysums::THETA_RANGE_FOLD_TO_PI;
+}
+
+
 ///////////////////////////////////////////////////////////////////////
 // CLASS IMPLEMENTATION
 //    DialogGetComparisonImage
@@ -242,7 +301,7 @@ DialogPreferences::DialogPreferences (wxWindow* pParent, const char* const pszTi
   m_pCBStartupTips->SetValue (bStartupTips);
   pTopSizer->Add (m_pCBStartupTips, 0, wxALIGN_CENTER_VERTICAL);
 
-#ifdef HAVE_WXTHREADS
+#if HAVE_WXTHREADS && MSVC
   m_pCBUseBackgroundTasks = new wxCheckBox (this, -1, "Put Tasks in Background", wxDefaultPosition, wxSize(250, 25), 0);
   m_pCBUseBackgroundTasks->SetValue (bUseBackgroundTasks);
   pTopSizer->Add (m_pCBUseBackgroundTasks, 0, wxALIGN_CENTER_VERTICAL);
@@ -298,7 +357,7 @@ DialogPreferences::getStartupTips ()
 bool
 DialogPreferences::getUseBackgroundTasks ()
 {
-#ifdef HAVE_WXTHREADS
+#if HAVE_WXTHREADS && MSVC
   return static_cast<bool>(m_pCBUseBackgroundTasks->GetValue());
 #else
   return false;
@@ -471,11 +530,11 @@ DialogAutoScaleParameters::getAutoScaleFactor ()
 
 DialogGetRasterParameters::DialogGetRasterParameters 
    (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultNSamples, double dDefaultViewRatio)
-: wxDialog (pParent, -1, _T("Set Rasterization Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+: wxDialog (pParent, -1, _T("Rasterization Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
   
-  pTopSizer->Add (new wxStaticText (this, -1, "Set Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
+  pTopSizer->Add (new wxStaticText (this, -1, "Rasterization Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
   
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
     
@@ -580,10 +639,10 @@ DialogGetRasterParameters::getViewRatio ()
 
 
 DialogGetProjectionParameters::DialogGetProjectionParameters 
-   (wxWindow* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultNSamples, 
+   (wxWindow* pParent, int iDefaultNDet, int iDefaultNView, int iDefaultOffsetView, int iDefaultNSamples, 
     double dDefaultRotAngle, double dDefaultFocalLength, double dDefaultCenterDetectorLength,
     double dDefaultViewRatio, double dDefaultScanRatio, int iDefaultGeometry, int iDefaultTrace)
-: wxDialog (pParent, -1, _T("Set Projection Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+: wxDialog (pParent, -1, _T("Projection Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
   
@@ -598,7 +657,7 @@ DialogGetProjectionParameters::DialogGetProjectionParameters
   m_iDefaultTrace = iDefaultTrace;
   m_iDefaultGeometry = iDefaultGeometry;
   
-  pTopSizer->Add (new wxStaticText (this, -1, "Set Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
+  pTopSizer->Add (new wxStaticText (this, -1, "Projection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
   
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
     
@@ -660,6 +719,13 @@ DialogGetProjectionParameters::DialogGetProjectionParameters
     m_pTextCtrlRotAngle = new wxTextCtrl (this, -1, osRotAngle.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
     pText2Sizer->Add (new wxStaticText (this, -1, "Rotation Angle (Fraction of circle)"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
     pText2Sizer->Add (m_pTextCtrlRotAngle, 0, wxALIGN_CENTER_VERTICAL);
+                       
+    std::ostringstream osOffsetView;
+    osOffsetView << iDefaultOffsetView;
+    m_pTextCtrlOffsetView = new wxTextCtrl (this, -1, osOffsetView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+    pText2Sizer->Add (new wxStaticText (this, -1, "Gantry offset in units of 'views' "), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+    pText2Sizer->Add (m_pTextCtrlOffsetView, 0, wxALIGN_CENTER_VERTICAL);
+
   }
   pGridSizer->Add (pText2Sizer);
 
@@ -713,6 +779,20 @@ DialogGetProjectionParameters::getNView ()
     return (m_iDefaultNView);
 }
 
+unsigned int
+DialogGetProjectionParameters::getOffsetView ()
+{
+  if (theApp->getAdvancedOptions()) {
+         wxString strCtrl = m_pTextCtrlOffsetView->GetValue();
+         unsigned long lValue;
+         if (strCtrl.ToULong (&lValue))
+           return lValue;
+         else
+           return (m_iDefaultOffsetView);
+  }
+  else
+    return 0;
+}
 
 unsigned int
 DialogGetProjectionParameters::getNSamples ()
@@ -817,7 +897,7 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxWindow*
                      int iDefaultFilterMethodID, int iDefaultFilterGenerationID, int iDefaultZeropad, 
                      int iDefaultInterpID, int iDefaultInterpParam, int iDefaultBackprojectID, int iTrace,
                      ReconstructionROI* pDefaultROI)
-: wxDialog (pParent, -1, _T("Set Reconstruction Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+: wxDialog (pParent, -1, _T("Reconstruction Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
   
@@ -831,7 +911,7 @@ DialogGetReconstructionParameters::DialogGetReconstructionParameters (wxWindow*
   m_dDefaultRoiYMin = pDefaultROI->m_dYMin;
   m_dDefaultRoiYMax = pDefaultROI->m_dYMax;
 
-  pTopSizer->Add (new wxStaticText (this, -1, "Set Reconstruction Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
+  pTopSizer->Add (new wxStaticText (this, -1, "Filtered Backprojection Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
   
   wxFlexGridSizer* pGridSizer = NULL;
@@ -1131,11 +1211,11 @@ DialogGetReconstructionParameters::getROI (ReconstructionROI* pROI)
 
 
 DialogGetFilterParameters::DialogGetFilterParameters (wxWindow* pParent, int iDefaultXSize, int iDefaultYSize, int iDefaultFilterID, double dDefaultFilterParam,  double dDefaultBandwidth, int iDefaultDomainID, double dDefaultInputScale, double dDefaultOutputScale)
-: wxDialog (pParent, -1, _T("Set Filter Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+: wxDialog (pParent, -1, _T("Filter Parameters"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
   wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
   
-  pTopSizer->Add (new wxStaticText (this, -1, "Set Filter Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); 
+  pTopSizer->Add (new wxStaticText (this, -1, "Filter Parameters"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5); 
   pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
   
   wxFlexGridSizer* pGridSizer = new wxFlexGridSizer (2);
@@ -1462,7 +1542,7 @@ DialogGetXYSize::getYSize ()
 /////////////////////////////////////////////////////////////////////
 
 DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pParent, const char* const pszTitle, 
-       int iDefaultXSize, int iDefaultYSize, int iDefaultInterpolationID, int iDefaultZeropad)
+       int iDefaultXSize, int iDefaultYSize, int iDefaultInterpolationID, int iDefaultZeropad, int iHelpID)
 : wxDialog (pParent, -1, _T(pszTitle), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
   m_iDefaultXSize = iDefaultXSize;
@@ -1491,15 +1571,13 @@ DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pPar
   m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
   pTextGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
   pTextGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
-#ifdef DEBUG
-  if (iDefaultZeropad >= 0) {
+  if (m_iDefaultZeropad >= 0) {
     std::ostringstream osZeropad;
     osZeropad << iDefaultZeropad;
     m_pTextCtrlZeropad = new wxTextCtrl (this, -1, osZeropad.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
     pTextGridSizer->Add (new wxStaticText (this, -1, "Zeropad"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
     pTextGridSizer->Add (m_pTextCtrlZeropad, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
   }
-#endif
 
   pGridSizer->Add (pTextGridSizer, 0, wxALIGN_CENTER | wxALL);
 
@@ -1512,7 +1590,7 @@ DialogGetConvertPolarParameters::DialogGetConvertPolarParameters (wxWindow* pPar
   pButtonSizer->Add (pButtonOk, 0, wxEXPAND | wxALL, 10);
   wxButton* pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
   pButtonSizer->Add (pButtonCancel, 0, wxEXPAND | wxALL, 10);
-  CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, IDH_DLG_POLAR);
+  CTSimHelpButton* pButtonHelp = new CTSimHelpButton (this, iHelpID);
   pButtonSizer->Add (pButtonHelp, 0, wxEXPAND | wxALL, 10);
   
   pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
@@ -1555,16 +1633,15 @@ DialogGetConvertPolarParameters::getYSize ()
 unsigned int
 DialogGetConvertPolarParameters::getZeropad ()
 {
-#ifdef DEBUG
-  wxString strCtrl = m_pTextCtrlZeropad->GetValue();
-  unsigned long lValue;
-  if (strCtrl.ToULong (&lValue))
-    return lValue;
-  else
-    return (m_iDefaultZeropad);
-#else
-  return 0;
-#endif
+  if (m_iDefaultZeropad >= 0) {
+    wxString strCtrl = m_pTextCtrlZeropad->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+      return lValue;
+    else
+      return (m_iDefaultZeropad);
+  } else
+    return 0;
 }
 
 const char*