X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=aba89cc3198de6c70e40e6b0c0ff058d65ff1fae;hp=f7d8a1f1407469442860b4d9657c150f6fa68563;hb=23f5654dacb1952c15bda92c2606fae3a55e48ad;hpb=0eb095f799dd4222e6eb9b1db9e8c6f2831a1540 diff --git a/src/views.cpp b/src/views.cpp index f7d8a1f..aba89cc 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: views.cpp,v 1.50 2001/01/03 22:00:46 kevin Exp $ +** $Id: views.cpp,v 1.51 2001/01/04 21:28: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 @@ -170,6 +170,7 @@ EVT_MENU(IFMENU_FILE_EXPORT, ImageFileView::OnExport) EVT_MENU(IFMENU_FILE_PROPERTIES, ImageFileView::OnProperties) EVT_MENU(IFMENU_VIEW_SCALE_MINMAX, ImageFileView::OnScaleMinMax) EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto) +EVT_MENU(IFMENU_VIEW_SCALE_FULL, ImageFileView::OnScaleFull) EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare) EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow) EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol) @@ -286,6 +287,16 @@ ImageFileView::OnScaleMinMax (wxCommandEvent& event) } } +void +ImageFileView::OnScaleFull (wxCommandEvent& event) +{ + if (m_bMinSpecified || m_bMaxSpecified) { + m_bMinSpecified = false; + m_bMaxSpecified = false; + OnUpdate (this, NULL); + } +} + void ImageFileView::OnCompare (wxCommandEvent& event) { @@ -304,7 +315,7 @@ ImageFileView::OnCompare (wxCommandEvent& event) std::ostringstream os; double min, max, mean, mode, median, stddev; rIF.statistics (min, max, mean, mode, median, stddev); - os << rIF.getFilename() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n"; + os << GetFrame()->GetTitle().c_str() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n"; rCompareIF.statistics (min, max, mean, mode, median, stddev); os << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str() << ": minimum=" << min << ", maximum=" << max << ", mean=" << mean << ", mode=" << mode << ", median=" << median << ", stddev=" << stddev << "\n"; os << "\n"; @@ -326,7 +337,7 @@ ImageFileView::OnCompare (wxCommandEvent& event) return; } - wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + wxString s = GetFrame()->GetTitle() + ": "; differenceImage.labelsCopy (rIF, s.c_str()); s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; differenceImage.labelsCopy (rCompareIF, s.c_str()); @@ -561,7 +572,7 @@ ImageFileView::OnDivide (wxCommandEvent& event) } -#ifdef HAVE_FFTW +#ifdef HAVE_FFT void ImageFileView::OnFFT (wxCommandEvent& event) { @@ -604,6 +615,7 @@ ImageFileView::OnFourier (wxCommandEvent& event) GetDocument()->Modify(TRUE); GetDocument()->UpdateAllViews(this); } + void ImageFileView::OnInverseFourier (wxCommandEvent& event) { @@ -717,6 +729,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *view_menu = new wxMenu; view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set..."); view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto..."); + view_menu->Append(IFMENU_VIEW_SCALE_FULL, "Display &Full Scale"); wxMenu* filter_menu = new wxMenu; filter_menu->Append (IFMENU_FILTER_INVERTVALUES, "&Invert Values"); @@ -725,7 +738,7 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) filter_menu->Append (IFMENU_FILTER_LOG, "&Log"); filter_menu->Append (IFMENU_FILTER_EXP, "&Exp"); filter_menu->AppendSeparator(); -#ifdef HAVE_FFTW +#ifdef HAVE_FFT filter_menu->Append (IFMENU_FILTER_FFT, "&FFT"); filter_menu->Append (IFMENU_FILTER_IFFT, "&IFFT"); filter_menu->Append (IFMENU_FILTER_FOURIER, "F&ourier"); @@ -1283,7 +1296,7 @@ PhantomView::PhantomView(void) m_iDefaultNDet = 367; m_iDefaultNView = 320; m_iDefaultNSample = 2; - m_dDefaultRotation = 2; + m_dDefaultRotation = 1; m_dDefaultFocalLength = 2; m_dDefaultFieldOfView = 1; m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL; @@ -1617,6 +1630,11 @@ ProjectionFileView::ProjectionFileView(void) m_iDefaultInterpolation = Backprojector::INTERP_LINEAR; m_iDefaultInterpParam = 1; m_iDefaultTrace = Trace::TRACE_NONE; + + m_iDefaultPolarNX = 256; + m_iDefaultPolarNY = 256; + m_iDefaultPolarInterpolation = Projections::POLAR_INTERP_BILINEAR; + m_iDefaultPolarZeropad = 1; } ProjectionFileView::~ProjectionFileView(void) @@ -1639,23 +1657,67 @@ void ProjectionFileView::OnConvertPolar (wxCommandEvent& event) { Projections& rProj = GetDocument()->getProjections(); + DialogGetConvertPolarParameters dialogPolar (m_frame, "Convert Polar", m_iDefaultPolarNX, m_iDefaultPolarNY, + m_iDefaultPolarInterpolation, -1); + if (dialogPolar.ShowModal() == wxID_OK) { + wxString strInterpolation (dialogPolar.getInterpolationName()); + m_iDefaultPolarNX = dialogPolar.getXSize(); + m_iDefaultPolarNY = dialogPolar.getYSize(); + ImageFileDocument* pPolarDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + ImageFile& rIF = pPolarDoc->getImageFile(); + if (! pPolarDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + rIF.setArraySize (m_iDefaultPolarNX, m_iDefaultPolarNY); + m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str()); + rProj.convertPolar (rIF, m_iDefaultPolarInterpolation); + rIF.labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime()); + std::ostringstream os; + os << "Convert projection file " << GetFrame()->GetTitle().c_str() << " to polar image: xSize=" + << m_iDefaultPolarNX << ", ySize=" << m_iDefaultPolarNY << ", interpolation=" + << strInterpolation.c_str(); + *theApp->getLog() << os.str().c_str() << "\n"; + rIF.labelAdd (os.str().c_str()); + if (theApp->getSetModifyNewDocs()) + pPolarDoc->Modify(true); + pPolarDoc->UpdateAllViews(); + pPolarDoc->GetFirstView()->OnUpdate (this, NULL); + } } void ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) { Projections& rProj = GetDocument()->getProjections(); - wxMessageBox ("Polar conversion not yet implemented", "Unimplemented function"); -#if 0 - rProj.convertPolar (); - if (theApp->getSetModifyNewDocs()) - GetDocument()->Modify(true); - GetDocument()->UpdateAllViews(); -#ifndef HAVE_FFT - wxMessageBox ("FFT support has not been compiled into this version of CTSim", "Error"); -#endif -#endif -} + DialogGetConvertPolarParameters dialogPolar (m_frame, "Convert to FFT Polar", m_iDefaultPolarNX, m_iDefaultPolarNY, + m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad); + if (dialogPolar.ShowModal() == wxID_OK) { + wxString strInterpolation (dialogPolar.getInterpolationName()); + m_iDefaultPolarNX = dialogPolar.getXSize(); + m_iDefaultPolarNY = dialogPolar.getYSize(); + m_iDefaultPolarZeropad = dialogPolar.getZeropad(); + ImageFileDocument* pPolarDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + ImageFile& rIF = pPolarDoc->getImageFile(); + if (! pPolarDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + rIF.setArraySize (m_iDefaultPolarNX, m_iDefaultPolarNY); + m_iDefaultPolarInterpolation = Projections::convertInterpNameToID (strInterpolation.c_str()); + rProj.convertFFTPolar (rIF, m_iDefaultPolarInterpolation, m_iDefaultPolarZeropad); + rIF.labelAdd (rProj.getLabel().getLabelString().c_str(), rProj.calcTime()); + std::ostringstream os; + os << "Convert projection file " << GetFrame()->GetTitle().c_str() << " to FFT polar image: xSize=" + << m_iDefaultPolarNX << ", ySize=" << m_iDefaultPolarNY << ", interpolation=" + << strInterpolation.c_str() << ", zeropad=" << m_iDefaultPolarZeropad; + *theApp->getLog() << os.str().c_str() << "\n"; + rIF.labelAdd (os.str().c_str()); + if (theApp->getSetModifyNewDocs()) + pPolarDoc->Modify(true); + pPolarDoc->UpdateAllViews(); + pPolarDoc->GetFirstView()->OnUpdate (this, NULL); + }} void ProjectionFileView::OnReconstructFourier (wxCommandEvent& event) @@ -1947,6 +2009,7 @@ BEGIN_EVENT_TABLE(PlotFileView, wxView) EVT_MENU(PJMENU_FILE_PROPERTIES, PlotFileView::OnProperties) EVT_MENU(PLOTMENU_VIEW_SCALE_MINMAX, PlotFileView::OnScaleMinMax) EVT_MENU(PLOTMENU_VIEW_SCALE_AUTO, PlotFileView::OnScaleAuto) +EVT_MENU(PLOTMENU_VIEW_SCALE_FULL, PlotFileView::OnScaleFull) END_EVENT_TABLE() PlotFileView::PlotFileView(void) @@ -2026,6 +2089,16 @@ PlotFileView::OnScaleMinMax (wxCommandEvent& event) } } +void +PlotFileView::OnScaleFull (wxCommandEvent& event) +{ + if (m_bMinSpecified || m_bMaxSpecified) { + m_bMinSpecified = false; + m_bMaxSpecified = false; + OnUpdate (this, NULL); + } +} + PlotFileCanvas* PlotFileView::CreateCanvas (wxView *view, wxFrame *parent) @@ -2067,6 +2140,7 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) wxMenu *view_menu = new wxMenu; view_menu->Append(PLOTMENU_VIEW_SCALE_MINMAX, "Display Scale &Set..."); view_menu->Append(PLOTMENU_VIEW_SCALE_AUTO, "Display Scale &Auto..."); + view_menu->Append(PLOTMENU_VIEW_SCALE_FULL, "Display &Full Scale"); wxMenu *help_menu = new wxMenu; help_menu->Append(MAINMENU_HELP_CONTENTS, "&Contents");