r644: no message
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 28 Mar 2001 16:44:41 +0000 (16:44 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 28 Mar 2001 16:44:41 +0000 (16:44 +0000)
src/views.cpp

index 4de349ef9166d95ddb071674fd1f94bae0cb87fc..631f481f78cda69482ea5bf6fa66551721812252 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.140 2001/03/21 21:45:31 kevin Exp $
+**  $Id: views.cpp,v 1.141 2001/03/28 16:44: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
 **
 **  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
@@ -791,15 +791,13 @@ void
 ImageFileView::OnMagnitude (wxCommandEvent& event)
 {
   ImageFile& rIF = GetDocument()->getImageFile();
 ImageFileView::OnMagnitude (wxCommandEvent& event)
 {
   ImageFile& rIF = GetDocument()->getImageFile();
-  if (rIF.isComplex()) {
-    rIF.magnitude (rIF);
-    rIF.labelAdd ("Magnitude of complex-image");
-    m_bMinSpecified = false;
-    m_bMaxSpecified = false;
-    if (theApp->getAskDeleteNewDocs())
-      GetDocument()->Modify (true);
-    GetDocument()->UpdateAllViews (this);
-  }
+  rIF.magnitude (rIF);
+  rIF.labelAdd ("Magnitude");
+  m_bMinSpecified = false;
+  m_bMaxSpecified = false;
+  if (theApp->getAskDeleteNewDocs())
+    GetDocument()->Modify (true);
+  GetDocument()->UpdateAllViews (this);
   GetDocument()->Activate();
 }
 
   GetDocument()->Activate();
 }
 
@@ -1069,12 +1067,10 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
     m_pFilterMenu->Enable(IFMENU_FILTER_REAL, true);
     m_pFilterMenu->Enable(IFMENU_FILTER_IMAGINARY, true);
     m_pFilterMenu->Enable(IFMENU_FILTER_PHASE, true);
     m_pFilterMenu->Enable(IFMENU_FILTER_REAL, true);
     m_pFilterMenu->Enable(IFMENU_FILTER_IMAGINARY, true);
     m_pFilterMenu->Enable(IFMENU_FILTER_PHASE, true);
-    m_pFilterMenu->Enable(IFMENU_FILTER_MAGNITUDE, true);
   } else {
     m_pFilterMenu->Enable(IFMENU_FILTER_REAL, false);
     m_pFilterMenu->Enable(IFMENU_FILTER_IMAGINARY, false);
     m_pFilterMenu->Enable(IFMENU_FILTER_PHASE, false);
   } else {
     m_pFilterMenu->Enable(IFMENU_FILTER_REAL, false);
     m_pFilterMenu->Enable(IFMENU_FILTER_IMAGINARY, false);
     m_pFilterMenu->Enable(IFMENU_FILTER_PHASE, false);
-    m_pFilterMenu->Enable(IFMENU_FILTER_MAGNITUDE, false);
   }
   ImageFileArrayConst v = rIF.getArray();
   int nx = rIF.nx();
   }
   ImageFileArrayConst v = rIF.getArray();
   int nx = rIF.nx();
@@ -2770,7 +2766,46 @@ ProjectionFileView::OnConvertParallel (wxCommandEvent& event)
 void
 ProjectionFileView::OnReconstructFourier (wxCommandEvent& event)
 {
 void
 ProjectionFileView::OnReconstructFourier (wxCommandEvent& event)
 {
-  wxMessageBox ("Fourier Reconstruction is not yet supported", "Unimplemented function");
+  Projections& rProj = GetDocument()->getProjections();
+  DialogGetConvertPolarParameters dialogPolar (getFrameForChild(), "Fourier Reconstruction", m_iDefaultPolarNX, m_iDefaultPolarNY,
+    m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad);
+  if (dialogPolar.ShowModal() == wxID_OK) {
+    wxProgressDialog dlgProgress (wxString("Reconstruction Fourier"), wxString("Reconstruction Progress"), 1, getFrameForChild(), wxPD_APP_MODAL);
+    wxString strInterpolation (dialogPolar.getInterpolationName());
+    m_iDefaultPolarNX = dialogPolar.getXSize();
+    m_iDefaultPolarNY = dialogPolar.getYSize();
+    m_iDefaultPolarZeropad = dialogPolar.getZeropad();
+    ImageFile* pIF = new ImageFile (m_iDefaultPolarNX, m_iDefaultPolarNY);
+    
+    m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str());
+    if (! rProj.convertFFTPolar (*pIF, m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad)) {
+      delete pIF;
+      *theApp->getLog() << "Error converting to polar\n";
+      return;
+    }
+    pIF->ifft(*pIF);
+    pIF->magnitude(*pIF);
+    Fourier::shuffleFourierToNaturalOrder (*pIF);
+
+    ImageFileDocument* pPolarDoc = theApp->newImageDoc();
+    if (! pPolarDoc) {
+      sys_error (ERR_SEVERE, "Unable to create image file");
+      return;
+    }
+    pPolarDoc->setImageFile (pIF);
+    pIF->labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime());
+    std::ostringstream os;
+    os << "Reconstruct Fourier " << GetFrame()->GetTitle().c_str() << ": xSize=" 
+      << m_iDefaultPolarNX << ", ySize=" << m_iDefaultPolarNY << ", interpolation=" 
+      << strInterpolation.c_str() << ", zeropad=" << m_iDefaultPolarZeropad;
+    *theApp->getLog() << os.str().c_str() << "\n";
+    pIF->labelAdd (os.str().c_str());
+    if (theApp->getAskDeleteNewDocs())
+      pPolarDoc->Modify (true);
+    pPolarDoc->getView()->getFrame()->Show(true);
+    pPolarDoc->UpdateAllViews ();
+    pPolarDoc->Activate();
+  }
 }
 
 void
 }
 
 void
@@ -2995,7 +3030,6 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view)
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP, "&Filtered Backprojection...\tCtrl-R", "Reconstruct image using filtered backprojection");
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FBP_REBIN, "Filtered &Backprojection (Rebin to Parallel)...\tCtrl-B", "Reconstruct image using filtered backprojection");
   reconstruct_menu->Append (PJMENU_RECONSTRUCT_FOURIER, "&Fourier...\tCtrl-E", "Reconstruct image using inverse Fourier");
-  reconstruct_menu->Enable (PJMENU_RECONSTRUCT_FOURIER, false);
   
   wxMenu *help_menu = new wxMenu;
   help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");
   
   wxMenu *help_menu = new wxMenu;
   help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");