X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fviews.cpp;h=ebca038c6c32fbc6ad3929523fbe2adcddfe7bc4;hb=0392f1a597f0b8b608c81ff5d4f7adfda6154f4f;hp=4de349ef9166d95ddb071674fd1f94bae0cb87fc;hpb=3ea498d51ce4597e9649cd21f155b51175ea0bea;p=ctsim.git diff --git a/src/views.cpp b/src/views.cpp index 4de349e..ebca038 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** 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.142 2001/03/30 19:15:23 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 @@ -228,7 +228,7 @@ 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 +#ifdef wxUSE_GLCANVAS EVT_MENU(IFMENU_IMAGE_CONVERT3D, ImageFileView::OnConvert3d) #endif #ifdef HAVE_FFT @@ -791,15 +791,13 @@ void 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(); } @@ -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_MAGNITUDE, true); } 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(); @@ -1199,8 +1195,8 @@ ImageFileView::OnEditPaste (wxCommandEvent& event) double dScale3 = 3 * 255; unsigned char* pixels = image.GetData(); ImageFileArray v = rIF.getArray(); - for (int ix = 0; ix < rIF.nx(); ix++) { - for (int iy = 0; iy < rIF.ny(); iy++) { + for (unsigned int ix = 0; ix < rIF.nx(); ix++) { + for (unsigned int iy = 0; iy < rIF.ny(); iy++) { unsigned int iBase = 3 * (iy * nx + ix); if (ix == 0 && iy == 0 && (pixels[iBase] == pixels[iBase+1] && pixels[iBase+1] == pixels[iBase+2])) bMonochrome = true; @@ -2770,7 +2766,46 @@ ProjectionFileView::OnConvertParallel (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 @@ -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->Enable (PJMENU_RECONSTRUCT_FOURIER, false); wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents\tF1");