r153: *** empty log message ***
[ctsim.git] / src / dialogs.cpp
index 4c8d96745dfd5a5272761d202306d9d35b6aa610..4b37f4b31c2f90bdbbb091dde5d5b92cba4b440d 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: dialogs.cpp,v 1.1 2000/07/18 03:14:35 kevin Exp $
+**  $Id: dialogs.cpp,v 1.2 2000/07/18 14:51:06 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
 #include "wx/sizer.h"
 #include "dialogs.h"
 #include <sstream>
+#include "ctsupport.h"
+#include "scanner.h"
 
 DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& rImagefile, double dDefaultMin = 0., double dDefaultMax = 0.)
-    : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCAPTION), m_pTopSizer(NULL), m_pTextCtrlMin(NULL), m_pTextCtrlMax(NULL), m_pButtonSizer(NULL), m_pButtonOk(NULL), m_pButtonCancel(NULL), m_dDefaultMin(dDefaultMin), m_dDefaultMax(dDefaultMax)
+    : wxDialog (pParent, -1, "Set Image Display Minimum & Maximum", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
 {
-  wxBoxSizer* m_pTopSizer = new wxBoxSizer (wxVERTICAL);
+  wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
 
-  m_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, "Set Image Display Minimum and Maximum"), 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 5);
                   
+  pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+
   ostringstream os;
   os << dDefaultMin;
   m_pTextCtrlMin = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
@@ -68,33 +72,29 @@ DialogGetImageMinMax::DialogGetImageMinMax (wxFrame* pParent, const ImageFile& r
   pGridSizer->Add (m_pTextCtrlMin, 0, wxALIGN_CENTER_VERTICAL);
   pGridSizer->Add (new wxStaticText (this, -1, "Maximum"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
   pGridSizer->Add (m_pTextCtrlMax, 0, wxALIGN_CENTER_VERTICAL);
-  m_pTopSizer->Add (pGridSizer, 1, wxALL, 10);
+  pTopSizer->Add (pGridSizer, 1, wxALL, 10);
 
-  m_pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+  pTopSizer->Add (new wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
 
-  m_pButtonSizer = new wxBoxSizer (wxHORIZONTAL);
-  m_pButtonOk = new wxButton (this, wxID_OK, "Okay");
-  m_pButtonCancel = new wxButton (this, wxID_CANCEL, "Cancel");
-  m_pButtonSizer->Add (m_pButtonOk, 0, wxEXPAND | wxALL, 10);
-  m_pButtonSizer->Add (m_pButtonCancel, 0, wxEXPAND | wxALL, 10);
+  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);
 
-  m_pTopSizer->Add (m_pButtonSizer, 0, wxALIGN_CENTER);
+  pTopSizer->Add (pButtonSizer, 0, wxALIGN_CENTER);
 
   SetAutoLayout (true);
-  SetSizer (m_pTopSizer);
-  m_pTopSizer->Fit (this);
-  m_pTopSizer->SetSizeHints (this);
+  SetSizer (pTopSizer);
+  pTopSizer->Fit (this);
+  pTopSizer->SetSizeHints (this);
 }
 
 DialogGetImageMinMax::~DialogGetImageMinMax (void)
 {
 #if 0
-  delete m_pTopSizer;
   delete m_pTextCtrlMin;
   delete m_pTextCtrlMax;
-  delete m_pButtonSizer;
-  delete m_pButtonOk;
-  delete m_pButtonCancel;
 #endif
 }
 
@@ -120,3 +120,206 @@ DialogGetImageMinMax::getMaximum (void)
        return (m_dDefaultMax);
 }
 
+
+/////////////////////////////////////////////////////////////////////
+// CLASS IDENTIFICATION
+//
+// DialogGetRasterParameters
+/////////////////////////////////////////////////////////////////////
+
+DialogGetRasterParameters::DialogGetRasterParameters (wxFrame* pParent, int iDefaultXSize = 0, int iDefaultYSize = 0, int iDefaultNSamples = 1)
+    : wxDialog (pParent, -1, "Set 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 wxStaticLine (this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, wxEXPAND | wxALL, 5);
+
+  ostringstream os;
+  os << iDefaultXSize;
+  m_pTextCtrlXSize = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+  ostringstream osYSize;
+  osYSize << iDefaultYSize;
+  m_pTextCtrlYSize = new wxTextCtrl (this, -1, osYSize.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+  ostringstream osNSamples;
+  osNSamples << iDefaultNSamples;
+  m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+
+  wxGridSizer *pGridSizer = new wxGridSizer (2, 3, 5);
+  pGridSizer->Add (new wxStaticText (this, -1, "X Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlXSize, 0, wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (new wxStaticText (this, -1, "Y Size"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlYSize, 0, wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (new wxStaticText (this, -1, "Samples per Pixel"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlNSamples, 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);
+}
+
+DialogGetRasterParameters::~DialogGetRasterParameters (void)
+{
+}
+
+
+unsigned int
+DialogGetRasterParameters::getXSize (void)
+{
+    wxString strCtrl = m_pTextCtrlXSize->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultXSize);
+}
+
+unsigned int
+DialogGetRasterParameters::getYSize (void)
+{
+    wxString strCtrl = m_pTextCtrlYSize->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultYSize);
+}
+
+
+unsigned int
+DialogGetRasterParameters::getNSamples (void)
+{
+    wxString strCtrl = m_pTextCtrlNSamples->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultNSamples);
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+// CLASS IDENTIFICATION
+//
+// DialogGetProjectionsParameters
+/////////////////////////////////////////////////////////////////////
+
+DialogGetProjectionParameters::DialogGetProjectionParameters (wxFrame* pParent, int iDefaultNDet = 0, int iDefaultNView = 0, int iDefaultNSamples = 1, double dDefaultRotAngle = 1., const char* szDefaultGeometry = NULL)
+    : wxDialog (pParent, -1, "Set Projection Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxCAPTION)
+{
+  wxBoxSizer* pTopSizer = new wxBoxSizer (wxVERTICAL);
+
+  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);
+
+  ostringstream os;
+  os << iDefaultNDet;
+  m_pTextCtrlNDet = new wxTextCtrl (this, -1, os.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+  ostringstream osNView;
+  osNView << iDefaultNView;
+  m_pTextCtrlNView = new wxTextCtrl (this, -1, osNView.str().c_str(), wxDefaultPosition, wxSize(100, 25), 0);
+  ostringstream osNSamples;
+  osNSamples << iDefaultNSamples;
+  m_pTextCtrlNSamples = new wxTextCtrl (this, -1, osNSamples.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);
+
+  wxGridSizer *pGridSizer = new wxGridSizer (2, 4, 5);
+  pGridSizer->Add (new wxStaticText (this, -1, "Detectors"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlNDet, 0, wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (new wxStaticText (this, -1, "Views"), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (m_pTextCtrlNView, 0, wxALIGN_CENTER_VERTICAL);
+  pGridSizer->Add (new wxStaticText (this, -1, "Samples per Detector"), 0, wxALIGN_RIGHT | 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);
+  pTopSizer->Add (pGridSizer, 1, wxALL, 10);
+  m_sDefaultGeometry = szDefaultGeometry;
+
+  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);
+}
+
+DialogGetProjectionParameters::~DialogGetProjectionParameters (void)
+{
+}
+
+
+unsigned int
+DialogGetProjectionParameters::getNDet (void)
+{
+    wxString strCtrl = m_pTextCtrlNDet->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultNDet);
+}
+
+unsigned int
+DialogGetProjectionParameters::getNView (void)
+{
+    wxString strCtrl = m_pTextCtrlNView->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultNView);
+}
+
+
+unsigned int
+DialogGetProjectionParameters::getNSamples (void)
+{
+    wxString strCtrl = m_pTextCtrlNSamples->GetValue();
+    unsigned long lValue;
+    if (strCtrl.ToULong (&lValue))
+       return lValue;
+    else
+       return (m_iDefaultNSamples);
+}
+
+double
+DialogGetProjectionParameters::getRotAngle (void)
+{
+    wxString strCtrl = m_pTextCtrlRotAngle->GetValue();
+    double dValue;
+    if (strCtrl.ToDouble (&dValue))
+       return (dValue * PI);
+    else
+      return (m_dDefaultRotAngle);
+}
+
+const string&
+DialogGetProjectionParameters::getGeometry (void)
+{
+  return m_sDefaultGeometry;
+}