r521: no message
[ctsim.git] / src / views.cpp
index 28d663e7009e842f7b8291190cf13c3948c1c7ab..2743605f22dc2be82f6d1349a21062766f7b4de2 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.91 2001/01/30 05:05:41 kevin Exp $
+**  $Id: views.cpp,v 1.103 2001/02/11 21:57:08 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
@@ -226,6 +226,9 @@ EVT_MENU(IFMENU_IMAGE_SUBTRACT, ImageFileView::OnSubtract)
 EVT_MENU(IFMENU_IMAGE_MULTIPLY, ImageFileView::OnMultiply)
 EVT_MENU(IFMENU_IMAGE_DIVIDE, ImageFileView::OnDivide)
 EVT_MENU(IFMENU_IMAGE_SCALESIZE, ImageFileView::OnScaleSize)
+#if wxUSE_GLCANVAS
+EVT_MENU(IFMENU_IMAGE_CONVERT3D, ImageFileView::OnConvert3d)
+#endif
 #ifdef HAVE_FFT
 EVT_MENU(IFMENU_FILTER_FFT, ImageFileView::OnFFT)
 EVT_MENU(IFMENU_FILTER_IFFT, ImageFileView::OnIFFT)
@@ -265,7 +268,7 @@ ImageFileView::OnProperties (wxCommandEvent& event)
   if (rIF.nx() == 0 || rIF.ny() == 0)
     *theApp->getLog() << "Properties: empty imagefile\n";
   else {
-    const std::string& rFilename = rIF.getFilename();
+    const std::string rFilename = m_pFrame->GetTitle().c_str();
     std::ostringstream os;
     double min, max, mean, mode, median, stddev;
     rIF.statistics (rIF.getArray(), min, max, mean, mode, median, stddev);
@@ -395,7 +398,8 @@ ImageFileView::OnCompare (wxCommandEvent& event)
           << " and " << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str() << ": "
           << os.str().c_str();
         pDifferenceImage->labelAdd (os.str().c_str());
-        pDifferenceDoc->Modify (true);
+        if (theApp->getAskDeleteNewDocs())
+          pDifferenceDoc->Modify (true);
         pDifferenceDoc->UpdateAllViews (this);
         pDifferenceDoc->getView()->OnUpdate (this, NULL);
         pDifferenceDoc->getView()->getFrame()->Show(true);
@@ -411,7 +415,8 @@ ImageFileView::OnInvertValues (wxCommandEvent& event)
   ImageFile& rIF = GetDocument()->getImageFile();
   rIF.invertPixelValues (rIF);
   rIF.labelAdd ("Invert Pixel Values");
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+          GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -421,7 +426,8 @@ ImageFileView::OnSquare (wxCommandEvent& event)
   ImageFile& rIF = GetDocument()->getImageFile();
   rIF.square (rIF);
   rIF.labelAdd ("Square Pixel Values");
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -431,7 +437,8 @@ ImageFileView::OnSquareRoot (wxCommandEvent& event)
   ImageFile& rIF = GetDocument()->getImageFile();
   rIF.sqrt (rIF);
   rIF.labelAdd ("Square-root Pixel Values");
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -441,7 +448,8 @@ ImageFileView::OnLog (wxCommandEvent& event)
   ImageFile& rIF = GetDocument()->getImageFile();
   rIF.log (rIF);
   rIF.labelAdd ("Logrithm base-e Pixel Values");
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -451,7 +459,8 @@ ImageFileView::OnExp (wxCommandEvent& event)
   ImageFile& rIF = GetDocument()->getImageFile();
   rIF.exp (rIF);
   rIF.labelAdd ("Exponent base-e Pixel Values");
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -487,7 +496,8 @@ ImageFileView::OnAdd (wxCommandEvent& event)
       newImage.labelsCopy (rRHSIF, s.c_str());
       newImage.labelAdd (os.str().c_str());
       *theApp->getLog() << os.str().c_str() << "\n";
-      pNewDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pNewDoc->Modify (true);
       pNewDoc->UpdateAllViews (this);
       pNewDoc->getView()->OnUpdate (this, NULL);
       pNewDoc->getView()->getFrame()->Show(true);
@@ -527,7 +537,8 @@ ImageFileView::OnSubtract (wxCommandEvent& event)
       newImage.labelsCopy (rRHSIF, s.c_str());
       newImage.labelAdd (os.str().c_str());
       *theApp->getLog() << os.str().c_str() << "\n";
-      pNewDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pNewDoc->Modify (true);
       pNewDoc->UpdateAllViews (this);
       pNewDoc->getView()->OnUpdate (this, NULL);
       pNewDoc->getView()->getFrame()->Show(true);
@@ -567,7 +578,8 @@ ImageFileView::OnMultiply (wxCommandEvent& event)
       newImage.labelsCopy (rRHSIF, s.c_str());
       newImage.labelAdd (os.str().c_str());
       *theApp->getLog() << os.str().c_str() << "\n";
-      pNewDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pNewDoc->Modify (true);
       pNewDoc->UpdateAllViews (this);
       pNewDoc->getView()->OnUpdate (this, NULL);
       pNewDoc->getView()->getFrame()->Show(true);
@@ -607,7 +619,8 @@ ImageFileView::OnDivide (wxCommandEvent& event)
       newImage.labelsCopy (rRHSIF, s.c_str());
       newImage.labelAdd (os.str().c_str());
       *theApp->getLog() << os.str().c_str() << "\n";
-      pNewDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pNewDoc->Modify (true);
       pNewDoc->UpdateAllViews (this);
       pNewDoc->getView()->OnUpdate (this, NULL);
       pNewDoc->getView()->getFrame()->Show(true);
@@ -625,7 +638,8 @@ ImageFileView::OnFFT (wxCommandEvent& event)
   rIF.labelAdd ("FFT Image");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -637,7 +651,8 @@ ImageFileView::OnIFFT (wxCommandEvent& event)
   rIF.labelAdd ("IFFT Image");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -649,7 +664,8 @@ ImageFileView::OnFFTRows (wxCommandEvent& event)
   rIF.labelAdd ("FFT Rows");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -661,7 +677,8 @@ ImageFileView::OnIFFTRows (wxCommandEvent& event)
   rIF.labelAdd ("IFFT Rows");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -673,7 +690,8 @@ ImageFileView::OnFFTCols (wxCommandEvent& event)
   rIF.labelAdd ("FFT Columns");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -685,7 +703,8 @@ ImageFileView::OnIFFTCols (wxCommandEvent& event)
   rIF.labelAdd ("IFFT Columns");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 #endif
@@ -699,7 +718,8 @@ ImageFileView::OnFourier (wxCommandEvent& event)
   rIF.labelAdd ("Fourier Image");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -712,7 +732,8 @@ ImageFileView::OnInverseFourier (wxCommandEvent& event)
   rIF.labelAdd ("Inverse Fourier Image");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -724,7 +745,8 @@ ImageFileView::OnShuffleNaturalToFourierOrder (wxCommandEvent& event)
   rIF.labelAdd ("Shuffle Natural To Fourier Order");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -736,7 +758,8 @@ ImageFileView::OnShuffleFourierToNaturalOrder (wxCommandEvent& event)
   rIF.labelAdd ("Shuffle Fourier To Natural Order");
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
-  GetDocument()->Modify (true);
+  if (theApp->getAskDeleteNewDocs())
+     GetDocument()->Modify (true);
   GetDocument()->UpdateAllViews (this);
 }
 
@@ -749,7 +772,8 @@ ImageFileView::OnMagnitude (wxCommandEvent& event)
     rIF.labelAdd ("Magnitude of complex-image");
     m_bMinSpecified = false;
     m_bMaxSpecified = false;
-    GetDocument()->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       GetDocument()->Modify (true);
     GetDocument()->UpdateAllViews (this);
   }
 }
@@ -763,7 +787,8 @@ ImageFileView::OnPhase (wxCommandEvent& event)
     rIF.labelAdd ("Phase of complex-image");
     m_bMinSpecified = false;
     m_bMaxSpecified = false;
-    GetDocument()->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       GetDocument()->Modify (true);
     GetDocument()->UpdateAllViews (this);
   }
 }
@@ -799,7 +824,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 #endif
   theApp->setIconForFrame (subframe);
   
-  wxMenu *m_pFileMenu = new wxMenu;
+  m_pFileMenu = new wxMenu;
   
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
@@ -819,6 +844,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Preview");
 #ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Pr&eferences...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
 #endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
@@ -861,6 +887,9 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   image_menu->Append (IFMENU_IMAGE_DIVIDE, "&Divide...");
   image_menu->AppendSeparator();
   image_menu->Append (IFMENU_IMAGE_SCALESIZE, "S&cale Size...");
+#if wxUSE_GLCANVAS
+  image_menu->Append (IFMENU_IMAGE_CONVERT3D, "Convert &3-D\tCtrl-3");
+#endif
   
   m_pMenuAnalyze = new wxMenu;
   m_pMenuAnalyze->Append (IFMENU_PLOT_ROW, "Plot &Row");
@@ -898,7 +927,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   
   subframe->Centre(wxBOTH);
   
-  wxAcceleratorEntry accelEntries[10];
+  wxAcceleratorEntry accelEntries[11];
   accelEntries[0].Set (wxACCEL_CTRL, static_cast<int>('O'), wxID_OPEN);
   accelEntries[1].Set (wxACCEL_CTRL, static_cast<int>('S'), wxID_SAVE);
   accelEntries[2].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_CLOSE);
@@ -909,7 +938,13 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   accelEntries[7].Set (wxACCEL_CTRL, static_cast<int>('A'), IFMENU_VIEW_SCALE_AUTO);
   accelEntries[8].Set (wxACCEL_CTRL, static_cast<int>('U'), IFMENU_VIEW_SCALE_FULL);
   accelEntries[9].Set (wxACCEL_CTRL, static_cast<int>('E'), IFMENU_VIEW_SCALE_MINMAX);
+#if wxUSE_GLCANVAS
+  accelEntries[10].Set (wxACCEL_CTRL, static_cast<int>('3'), IFMENU_IMAGE_CONVERT3D);
+  wxAcceleratorTable accelTable (11, accelEntries);
+#else
   wxAcceleratorTable accelTable (10, accelEntries);
+#endif
+
   subframe->SetAcceleratorTable (accelTable);
   
   return subframe;
@@ -920,7 +955,6 @@ bool
 ImageFileView::OnCreate (wxDocument *doc, long WXUNUSED(flags) )
 {
   m_pFrame = CreateChildFrame(doc, this);
-  (m_pFrame);
   
   m_bMinSpecified = false;
   m_bMaxSpecified = false;
@@ -1020,7 +1054,7 @@ ImageFileView::OnClose (bool deleteWindow)
   SetFrame(NULL);
   
   if (deleteWindow) {
-    m_pFrame->Destroy();
+    delete m_pFrame;
     m_pFrame = NULL;
     if (GetDocument() && GetDocument()->getBadFileOpen())
       ::wxYield();  // wxWindows bug workaround
@@ -1098,13 +1132,32 @@ ImageFileView::OnScaleSize (wxCommandEvent& event)
     rScaledIF.labelAdd (os.str().c_str());
     rIF.scaleImage (rScaledIF);
     *theApp->getLog() << os.str().c_str() << "\n";
-    pScaledDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       pScaledDoc->Modify (true);
     pScaledDoc->UpdateAllViews (this);
     pScaledDoc->getView()->OnUpdate (this, NULL);
     pScaledDoc->getView()->getFrame()->Show(true);
   }
 }
 
+#if wxUSE_GLCANVAS
+void
+ImageFileView::OnConvert3d (wxCommandEvent& event)
+{
+  ImageFile& rIF = GetDocument()->getImageFile();
+  Graph3dFileDocument* pGraph3d = theApp->newGraph3dDoc();
+  pGraph3d->setBadFileOpen();
+  pGraph3d->createFromImageFile (rIF);
+  pGraph3d->getView()->OnUpdate (this, NULL);
+  pGraph3d->UpdateAllViews();
+  pGraph3d->getView()->getFrame()->SetClientSize (400, 400);
+  pGraph3d->getView()->getFrame()->Show (true);
+  GetDocumentManager()->ActivateView (pGraph3d->getView(), true, false);
+  ::wxYield();
+  pGraph3d->getView()->getCanvas()->SetFocus();
+}
+#endif
+
 void
 ImageFileView::OnPlotRow (wxCommandEvent& event)
 {
@@ -1183,7 +1236,8 @@ ImageFileView::OnPlotRow (wxCommandEvent& event)
       delete pYImag;
       delete pYMag;
     }
-    pPlotDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       pPlotDoc->Modify (true);
     pPlotDoc->UpdateAllViews ();
     pPlotDoc->getView()->OnUpdate (this, NULL);
     pPlotDoc->getView()->getFrame()->Show(true);
@@ -1268,7 +1322,8 @@ ImageFileView::OnPlotCol (wxCommandEvent& event)
       delete pYImag;
       delete pYMag;
     }
-    pPlotDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       pPlotDoc->Modify (true);
     pPlotDoc->UpdateAllViews ();
     pPlotDoc->getView()->OnUpdate (this, NULL);
     pPlotDoc->getView()->getFrame()->Show(true);
@@ -1362,7 +1417,8 @@ ImageFileView::OnPlotFFTRow (wxCommandEvent& event)
     delete pYMag;
     delete [] pcIn;
     
-    pPlotDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       pPlotDoc->Modify (true);
     pPlotDoc->UpdateAllViews ();
     pPlotDoc->getView()->OnUpdate (this, NULL);
     pPlotDoc->getView()->getFrame()->Show(true);
@@ -1462,7 +1518,8 @@ ImageFileView::OnPlotFFTCol (wxCommandEvent& event)
     delete pdTemp;
     delete [] pcIn;
     
-    pPlotDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+       pPlotDoc->Modify (true);
     pPlotDoc->UpdateAllViews ();
     pPlotDoc->getView()->OnUpdate (this, NULL);
     pPlotDoc->getView()->getFrame()->Show(true);
@@ -1552,7 +1609,8 @@ ImageFileView::OnCompareCol (wxCommandEvent& event)
       delete pX;
       delete pY1;
       delete pY2;
-      pPlotDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pPlotDoc->Modify (true);
       pPlotDoc->UpdateAllViews ();
       pPlotDoc->getView()->OnUpdate (this, NULL);
       pPlotDoc->getView()->getFrame()->Show(true);
@@ -1643,7 +1701,8 @@ ImageFileView::OnCompareRow (wxCommandEvent& event)
       delete pX;
       delete pY1;
       delete pY2;
-      pPlotDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pPlotDoc->Modify (true);
       pPlotDoc->UpdateAllViews ();
       pPlotDoc->getView()->OnUpdate (this, NULL);
       pPlotDoc->getView()->getFrame()->Show(true);
@@ -1709,7 +1768,8 @@ ImageFileView::OnPlotHistogram (wxCommandEvent& event)
       rPlotFile.addDescription (os.str().c_str());
       delete pX;
       delete pY;
-      pPlotDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pPlotDoc->Modify (true);
       pPlotDoc->UpdateAllViews ();
       pPlotDoc->getView()->OnUpdate (this, NULL);
       pPlotDoc->getView()->getFrame()->Show(true);
@@ -1737,6 +1797,20 @@ PhantomCanvas::OnDraw (wxDC& dc)
     m_pView->OnDraw(& dc);
 }
 
+wxSize
+PhantomCanvas::GetBestSize() const
+{
+  if (! m_pView)
+    return wxSize(0,0);
+
+  int xSize, ySize;
+  theApp->getMainFrame()->GetClientSize (&xSize, &ySize);
+  xSize = maxValue<int> (xSize, ySize);
+  ySize = xSize = (xSize / 3);
+  return wxSize (xSize, ySize);
+}
+
+
 
 // PhantomFileView
 
@@ -1759,9 +1833,10 @@ PhantomFileView::PhantomFileView()
   m_iDefaultNView = 320;
 #endif
   m_iDefaultNSample = 1;
-  m_dDefaultRotation = 1;
+  m_dDefaultRotation = 2;
   m_dDefaultFocalLength = 2;
-  m_dDefaultFieldOfView = 1;
+  m_dDefaultViewRatio = 1;
+  m_dDefaultScanRatio = 1;
   m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
   m_iDefaultTrace = Trace::TRACE_NONE;
   
@@ -1774,6 +1849,7 @@ PhantomFileView::PhantomFileView()
   m_iDefaultRasterNY = 256;
   m_iDefaultRasterNSamples = 2;
 #endif
+  m_dDefaultRasterViewRatio = 1;
 }
 
 PhantomFileView::~PhantomFileView()
@@ -1802,7 +1878,10 @@ PhantomFileView::OnProperties (wxCommandEvent& event)
 void
 PhantomFileView::OnProjections (wxCommandEvent& event)
 {
-  DialogGetProjectionParameters dialogProjection (getFrameForChild(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView, m_iDefaultGeometry, m_iDefaultTrace);
+  DialogGetProjectionParameters dialogProjection (getFrameForChild(), 
+    m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, 
+    m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, m_iDefaultGeometry, 
+    m_iDefaultTrace);
   int retVal = dialogProjection.ShowModal();
   if (retVal == wxID_OK) {
     m_iDefaultNDet = dialogProjection.getNDet();
@@ -1811,7 +1890,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
     m_iDefaultTrace = dialogProjection.getTrace();
     m_dDefaultRotation = dialogProjection.getRotAngle();
     m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
-    m_dDefaultFieldOfView = dialogProjection.getFieldOfViewRatio();
+    m_dDefaultViewRatio = dialogProjection.getViewRatio();
+    m_dDefaultScanRatio = dialogProjection.getScanRatio();
     wxString sGeometry = dialogProjection.getGeometry();
     m_iDefaultGeometry = Scanner::convertGeometryNameToID (sGeometry.c_str());
     
@@ -1819,9 +1899,12 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
       const Phantom& rPhantom = GetDocument()->getPhantom();
       Projections* pProj = new Projections;
       Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, 
-                          m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultFieldOfView);
+                          m_dDefaultRotation, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio);
       if (theScanner.fail()) {
-        *theApp->getLog() << "Failed making scanner: " << theScanner.failMessage().c_str() << "\n";
+        wxString msg = "Failed making scanner\n";
+        msg += theScanner.failMessage().c_str();
+        *theApp->getLog() << msg << "\n";
+        wxMessageBox (msg, "Error");
         return;
       }
       pProj->initFromScanner (theScanner);
@@ -1854,7 +1937,12 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
       }
       
       std::ostringstream os;
-      os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength << ", FieldOfViewRatio=" << m_dDefaultFieldOfView << ", Geometry=" << sGeometry.c_str();
+      os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet 
+        << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample 
+        << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength 
+        << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio 
+        << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << 
+        convertRadiansToDegrees (theScanner.fanBeamAngle());
       pProj->setCalcTime (timer.timerEnd());
       pProj->setRemark (os.str());
       *theApp->getLog() << os.str().c_str() << "\n";
@@ -1879,7 +1967,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
         GetDocumentManager()->ActivateView (projView, true, false);
       }
       ::wxYield();
-      pProjectionDoc-> Modify(true);
+      if (theApp->getAskDeleteNewDocs())
+        pProjectionDoc-> Modify(true);
       pProjectionDoc->UpdateAllViews (this);
     }
   }
@@ -1889,14 +1978,18 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
 void
 PhantomFileView::OnRasterize (wxCommandEvent& event)
 {
-  DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY, m_iDefaultRasterNSamples);
+  DialogGetRasterParameters dialogRaster (getFrameForChild(), m_iDefaultRasterNX, m_iDefaultRasterNY, 
+    m_iDefaultRasterNSamples, m_dDefaultRasterViewRatio);
   int retVal = dialogRaster.ShowModal();
   if (retVal == wxID_OK) {
     m_iDefaultRasterNX = dialogRaster.getXSize();
     m_iDefaultRasterNY  = dialogRaster.getYSize();
     m_iDefaultRasterNSamples = dialogRaster.getNSamples();
+    m_dDefaultRasterViewRatio = dialogRaster.getViewRatio();
     if (m_iDefaultRasterNSamples < 1)
       m_iDefaultRasterNSamples = 1;
+    if (m_dDefaultRasterViewRatio < 0)
+      m_dDefaultRasterViewRatio = 0;
     if (m_iDefaultRasterNX > 0 && m_iDefaultRasterNY > 0) {
       const Phantom& rPhantom = GetDocument()->getPhantom();
 
@@ -1907,7 +2000,8 @@ PhantomFileView::OnRasterize (wxCommandEvent& event)
                                     pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT);
       Timer timer;
       for (unsigned int i = 0; i < pImageFile->nx(); i++) {
-        rPhantom.convertToImagefile (*pImageFile, m_iDefaultRasterNSamples, Trace::TRACE_NONE, i, 1, true);
+        rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, 
+          Trace::TRACE_NONE, i, 1, true);
         if (! dlgProgress.Update (i+1)) {
           delete pImageFile;
           return;
@@ -1921,12 +2015,14 @@ PhantomFileView::OnRasterize (wxCommandEvent& event)
       }
       pRasterDoc->setImageFile (pImageFile);
 
-      pRasterDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pRasterDoc->Modify (true);
       pRasterDoc->UpdateAllViews (this);
       pRasterDoc->getView()->getFrame()->Show(true);
       std::ostringstream os;
       os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << m_iDefaultRasterNX << ", YSize=" 
-        << m_iDefaultRasterNY << ", nSamples=" << m_iDefaultRasterNSamples;
+        << m_iDefaultRasterNY << ", ViewRatio=" << m_dDefaultRasterViewRatio << ", nSamples=" 
+        << m_iDefaultRasterNSamples;;
       *theApp->getLog() << os.str().c_str() << "\n";
       pImageFile->labelAdd (os.str().c_str(), timer.timerEnd());
       ImageFileView* rasterView = pRasterDoc->getView();
@@ -1944,11 +2040,8 @@ PhantomCanvas*
 PhantomFileView::CreateCanvas (wxFrame *parent)
 {
   PhantomCanvas* pCanvas;
-  int width, height;
-  parent->GetClientSize(&width, &height);
-  
-  pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(width, height), 0);
   
+  pCanvas = new PhantomCanvas (this, parent, wxPoint(0, 0), wxSize(0,0), 0);
   pCanvas->SetBackgroundColour(*wxWHITE);
   pCanvas->Clear();
   
@@ -1963,13 +2056,13 @@ wxDocChildFrame*
 PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 {
 #if CTSIM_MDI
-  wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
+  wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
 #else
-  wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(256, 256), wxDEFAULT_FRAME_STYLE);
+  wxDocChildFrame *subframe = new wxDocChildFrame (doc, view, theApp->getMainFrame(), -1, "Phantom Frame", wxPoint(10, 10), wxSize(0, 0), wxDEFAULT_FRAME_STYLE);
 #endif
   theApp->setIconForFrame (subframe);
   
-  wxMenu *m_pFileMenu = new wxMenu;
+  m_pFileMenu = new wxMenu;
   
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
@@ -1986,6 +2079,7 @@ PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
 #ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Pr&eferences...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
 #endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
@@ -2030,11 +2124,11 @@ PhantomFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
   m_pFrame = CreateChildFrame(doc, this);
   SetFrame(m_pFrame);
-  
-  int width, height;
-  m_pFrame->GetClientSize(&width, &height);
-  m_pFrame->SetTitle("PhantomFileView");
   m_pCanvas = CreateCanvas (m_pFrame);
+  m_pFrame->SetClientSize (m_pCanvas->GetBestSize());
+  m_pCanvas->SetClientSize (m_pCanvas->GetBestSize());
+  
+  m_pFrame->SetTitle ("PhantomFileView");
   
 #ifdef __X__
   int x, y;  // X requires a forced resize
@@ -2140,7 +2234,7 @@ EVT_MENU(PJMENU_CONVERT_FFT_POLAR, ProjectionFileView::OnConvertFFTPolar)
 END_EVENT_TABLE()
 
 ProjectionFileView::ProjectionFileView() 
-: wxView(), m_pCanvas(NULL), m_pFrame(NULL), m_pFileMenu(0)
+: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0)
 {
 #ifdef DEBUG
   m_iDefaultNX = 115;
@@ -2160,7 +2254,7 @@ ProjectionFileView::ProjectionFileView()
   m_iDefaultFilterGeneration = ProcessSignal::FILTER_GENERATION_DIRECT;
 #endif
   m_iDefaultZeropad = 1;
-  m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF3;
+  m_iDefaultBackprojector = Backprojector::BPROJ_IDIFF;
   m_iDefaultInterpolation = Backprojector::INTERP_LINEAR;
   m_iDefaultInterpParam = 1;
   m_iDefaultTrace = Trace::TRACE_NONE;
@@ -2215,7 +2309,8 @@ ProjectionFileView::OnConvertPolar (wxCommandEvent& event)
       << strInterpolation.c_str();
     *theApp->getLog() << os.str().c_str() << "\n";
     rIF.labelAdd (os.str().c_str());
-    pPolarDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+      pPolarDoc->Modify (true);
     pPolarDoc->UpdateAllViews ();
     pPolarDoc->getView()->OnUpdate (this, NULL);
     pPolarDoc->getView()->getFrame()->Show(true);
@@ -2249,7 +2344,8 @@ ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event)
       << strInterpolation.c_str() << ", zeropad=" << m_iDefaultPolarZeropad;
     *theApp->getLog() << os.str().c_str() << "\n";
     rIF.labelAdd (os.str().c_str());
-    pPolarDoc->Modify (true);
+    if (theApp->getAskDeleteNewDocs())
+      pPolarDoc->Modify (true);
     pPolarDoc->UpdateAllViews ();
     pPolarDoc->getView()->OnUpdate (this, NULL);
     pPolarDoc->getView()->getFrame()->Show(true);
@@ -2265,7 +2361,10 @@ ProjectionFileView::OnReconstructFourier (wxCommandEvent& event)
 void
 ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
 {
-  DialogGetReconstructionParameters dialogReconstruction (getFrameForChild(), m_iDefaultNX, m_iDefaultNY, m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, m_iDefaultTrace);
+  DialogGetReconstructionParameters dialogReconstruction (getFrameForChild(), m_iDefaultNX, m_iDefaultNY, 
+    m_iDefaultFilter, m_dDefaultFilterParam, m_iDefaultFilterMethod, m_iDefaultFilterGeneration, 
+    m_iDefaultZeropad, m_iDefaultInterpolation, m_iDefaultInterpParam, m_iDefaultBackprojector, 
+    m_iDefaultTrace);
   
   int retVal = dialogReconstruction.ShowModal();
   if (retVal == wxID_OK) {
@@ -2329,7 +2428,8 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
         return;
       }
       pReconDoc->setImageFile (pImageFile);
-      pReconDoc->Modify (true);
+      if (theApp->getAskDeleteNewDocs())
+        pReconDoc->Modify (true);
       pReconDoc->UpdateAllViews (this);
       if (ImageFileView* rasterView = pReconDoc->getView()) {
         rasterView->OnUpdate (rasterView, NULL);
@@ -2376,7 +2476,7 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 #endif
   theApp->setIconForFrame (subframe);
   
-  wxMenu *m_pFileMenu = new wxMenu;
+  m_pFileMenu = new wxMenu;
   
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
@@ -2394,6 +2494,7 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
 #ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Pr&eferences...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
 #endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
@@ -2706,7 +2807,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
 #endif
   theApp->setIconForFrame (subframe);
   
-  wxMenu *m_pFileMenu = new wxMenu;
+  m_pFileMenu = new wxMenu;
   
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
@@ -2724,6 +2825,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
 #ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Pr&eferences...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
 #endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);
@@ -2966,7 +3068,7 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
 #endif
   theApp->setIconForFrame (subframe);
   
 wxMenu *m_pFileMenu = new wxMenu;
+ m_pFileMenu = new wxMenu;
   
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_PHANTOM, "Cr&eate Phantom...\tCtrl-P");
   m_pFileMenu->Append(MAINMENU_FILE_CREATE_FILTER, "Create &Filter...\tCtrl-F");
@@ -2981,6 +3083,7 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view)
   m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view");
 #ifdef CTSIM_MDI
   m_pFileMenu->AppendSeparator();
+  m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Pr&eferences...");
   m_pFileMenu->Append(MAINMENU_FILE_EXIT, "E&xit");
 #endif
   GetDocumentManager()->FileHistoryAddFilesToMenu(m_pFileMenu);