r184: *** empty log message ***
[ctsim.git] / src / views.cpp
index 4cb6f694fe54de5e67e97cbe5d85573c49d57396..1cd730e7db5dc5f0e129b7312853629e05c64633 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.15 2000/08/22 16:49:56 kevin Exp $
+**  $Id: views.cpp,v 1.16 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
@@ -108,8 +108,8 @@ IMPLEMENT_DYNAMIC_CLASS(ImageFileView, wxView)
 
 BEGIN_EVENT_TABLE(ImageFileView, wxView)
   EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties)
-  EVT_MENU(IFMENU_VIEW_WINDOW_MINMAX, ImageFileView::OnWindowMinMax)
-  EVT_MENU(IFMENU_VIEW_WINDOW_AUTO, ImageFileView::OnWindowAuto)
+  EVT_MENU(IFMENU_VIEW_SCALE_MINMAX, ImageFileView::OnScaleMinMax)
+  EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto)
 END_EVENT_TABLE()
 
 ImageFileView::ImageFileView(void) 
@@ -148,13 +148,24 @@ ImageFileView::OnProperties (wxCommandEvent& event)
 }
 
 void 
-ImageFileView::OnWindowAuto (wxCommandEvent& event)
+ImageFileView::OnScaleAuto (wxCommandEvent& event)
 {
-    *theApp->getLog() << "ImageFile: Window Auto\n";
+    const ImageFile& rIF = GetDocument()->getImageFile();
+    DialogAutoScaleParameters dialogAutoScale (m_frame, rIF);
+    int iRetVal = dialogAutoScale.ShowModal();
+    if (iRetVal == wxID_OK) {
+      m_bMinSpecified = true;
+      m_bMaxSpecified = true;
+      double dMin, dMax;
+      dialogAutoScale.getMinMax (&dMin, &dMax);
+      m_dMinPixel = dMin;
+      m_dMaxPixel = dMax;
+      OnUpdate (this, NULL);
+    }
 }
 
 void 
-ImageFileView::OnWindowMinMax (wxCommandEvent& event)
+ImageFileView::OnScaleMinMax (wxCommandEvent& event)
 {
     const ImageFile& rIF = GetDocument()->getImageFile();
     double min, max;
@@ -216,8 +227,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
     file_menu->Append(wxID_PREVIEW, "Print Pre&view");
     
     wxMenu *view_menu = new wxMenu;
-    view_menu->Append(IFMENU_VIEW_WINDOW_MINMAX, "&Set Window Min/Max");
-    view_menu->Append(IFMENU_VIEW_WINDOW_AUTO, "&Auto Window...");
+    view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set...");
+    view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto...");
     
     wxMenu *help_menu = new wxMenu;
     help_menu->Append(MAINMENU_HELP_ABOUT, "&About");
@@ -391,19 +402,26 @@ PhantomView::OnProperties (wxCommandEvent& event)
 void
 PhantomView::OnProjections (wxCommandEvent& event)
 {
-  DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., Scanner::GEOMETRY_PARALLEL);
+  DialogGetProjectionParameters dialogProjection (m_frame, 367, 320, 1, 1., 1., 1., Scanner::GEOMETRY_PARALLEL);
   int retVal = dialogProjection.ShowModal();
   if (retVal == wxID_OK) {
     int nDet = dialogProjection.getNDet();
     int nView = dialogProjection.getNView();
     int nSamples = dialogProjection.getNSamples();
     double dRotAngle = dialogProjection.getRotAngle();
+    double dFocalLengthRatio = dialogProjection.getFocalLengthRatio();
+    double dFieldOfViewRatio = dialogProjection.getFieldOfViewRatio();
+
     wxString sGeometry = dialogProjection.getGeometry();
     if (nDet > 0 && nView > 0 && sGeometry != "") {
       const Phantom& rPhantom = GetDocument()->getPhantom();
       ProjectionFileDocument* pProjectionDoc = dynamic_cast<ProjectionFileDocument*>(theApp->getDocManager()->CreateDocument("untitled.pj", wxDOC_SILENT));
       Projections& rProj = pProjectionDoc->getProjections();
-      Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle);
+      Scanner theScanner (rPhantom, sGeometry.c_str(), nDet, nView, nSamples, dRotAngle, dFocalLengthRatio, dFieldOfViewRatio);
+      if (theScanner.fail()) {
+       *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n";
+       return;
+      }
       rProj.initFromScanner (theScanner);
 
 #if 1
@@ -414,7 +432,9 @@ PhantomView::OnProjections (wxCommandEvent& event)
       frame.GetClientSize(&x, &y);
       SGPDriver driver (dynamic_cast<wxDC*>(&dc), x, y);
       SGP sgp (driver);
-      theScanner.collectProjections (rProj, rPhantom, 0, TRACE_PHM, &sgp);
+      for (int iView = 0; iView < rProj.nView(); iView++) {
+       theScanner.collectProjections (rProj, rPhantom, iView, 1, true, TRACE_RAYS, &sgp);
+      }
 #else
       theScanner.collectProjections (rProj, rPhantom);
 #endif
@@ -422,7 +442,7 @@ PhantomView::OnProjections (wxCommandEvent& event)
       pProjectionDoc->Modify(true);
       pProjectionDoc->UpdateAllViews(this);
       ostringstream os;
-      os << "Projections for " << rPhantom.name() << ": nDet=" << nDet << ", nView=" << nView << ", nSamples=" << nSamples << ", RotAngle=" << dRotAngle << ", Geometry=" << sGeometry.c_str() << "\n";
+      os << "Projections for " << rPhantom.name() << ": nDet=" << nDet << ", nView=" << nView << ", nSamples=" << nSamples << ", RotAngle=" << dRotAngle << ", FocalLengthRatio=" << dFocalLengthRatio << ", FieldOfViewRatio=" << dFieldOfViewRatio << ", Geometry=" << sGeometry.c_str() << "\n";
       *theApp->getLog() << os.str().c_str();
     }
   }