X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=0a8f4c8b7472f9c4c9850ea9c01bf130d39efcb4;hp=3ec3b6bdae002955050f22087c48926cf07dcf42;hb=e3776d3d7bf82adfea545c1f06c8b4ce660190b0;hpb=9b2bb510160bdb56f04847f5b55ab61dd8a47976 diff --git a/src/views.cpp b/src/views.cpp index 3ec3b6b..0a8f4c8 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.44 2001/01/02 05:34:57 kevin Exp $ +** $Id: views.cpp,v 1.45 2001/01/02 06:29: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 @@ -173,26 +173,26 @@ EVT_MENU(IFMENU_VIEW_SCALE_AUTO, ImageFileView::OnScaleAuto) EVT_MENU(IFMENU_COMPARE_IMAGES, ImageFileView::OnCompare) EVT_MENU(IFMENU_COMPARE_ROW, ImageFileView::OnCompareRow) EVT_MENU(IFMENU_COMPARE_COL, ImageFileView::OnCompareCol) -EVT_MENU(IFMENU_PROCESS_INVERTVALUES, ImageFileView::OnInvertValues) -EVT_MENU(IFMENU_PROCESS_SQUARE, ImageFileView::OnSquare) -EVT_MENU(IFMENU_PROCESS_SQRT, ImageFileView::OnSquareRoot) -EVT_MENU(IFMENU_PROCESS_LOG, ImageFileView::OnLog) -EVT_MENU(IFMENU_PROCESS_EXP, ImageFileView::OnExp) -EVT_MENU(IFMENU_PROCESS_ADD, ImageFileView::OnAdd) -EVT_MENU(IFMENU_PROCESS_SUBTRACT, ImageFileView::OnSubtract) -EVT_MENU(IFMENU_PROCESS_MULTIPLY, ImageFileView::OnMultiply) -EVT_MENU(IFMENU_PROCESS_DIVIDE, ImageFileView::OnDivide) -EVT_MENU(IFMENU_PROCESS_FOURIER, ImageFileView::OnFourier) -EVT_MENU(IFMENU_PROCESS_SCALESIZE, ImageFileView::OnScaleSize) -EVT_MENU(IFMENU_PROCESS_INVERSE_FOURIER, ImageFileView::OnInverseFourier) -EVT_MENU(IFMENU_PROCESS_SHUFFLEFOURIERTONATURALORDER, ImageFileView::OnShuffleFourierToNaturalOrder) -EVT_MENU(IFMENU_PROCESS_SHUFFLENATURALTOFOURIERORDER, ImageFileView::OnShuffleNaturalToFourierOrder) +EVT_MENU(IFMENU_FILTER_INVERTVALUES, ImageFileView::OnInvertValues) +EVT_MENU(IFMENU_FILTER_SQUARE, ImageFileView::OnSquare) +EVT_MENU(IFMENU_FILTER_SQRT, ImageFileView::OnSquareRoot) +EVT_MENU(IFMENU_FILTER_LOG, ImageFileView::OnLog) +EVT_MENU(IFMENU_FILTER_EXP, ImageFileView::OnExp) +EVT_MENU(IFMENU_FILTER_FOURIER, ImageFileView::OnFourier) +EVT_MENU(IFMENU_FILTER_INVERSE_FOURIER, ImageFileView::OnInverseFourier) +EVT_MENU(IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER, ImageFileView::OnShuffleFourierToNaturalOrder) +EVT_MENU(IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER, ImageFileView::OnShuffleNaturalToFourierOrder) +EVT_MENU(IFMENU_IMAGE_ADD, ImageFileView::OnAdd) +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) #ifdef HAVE_FFTW -EVT_MENU(IFMENU_PROCESS_FFT, ImageFileView::OnFFT) -EVT_MENU(IFMENU_PROCESS_IFFT, ImageFileView::OnIFFT) +EVT_MENU(IFMENU_FILTER_FFT, ImageFileView::OnFFT) +EVT_MENU(IFMENU_FILTER_IFFT, ImageFileView::OnIFFT) #endif -EVT_MENU(IFMENU_PROCESS_MAGNITUDE, ImageFileView::OnMagnitude) -EVT_MENU(IFMENU_PROCESS_PHASE, ImageFileView::OnPhase) +EVT_MENU(IFMENU_FILTER_MAGNITUDE, ImageFileView::OnMagnitude) +EVT_MENU(IFMENU_FILTER_PHASE, ImageFileView::OnPhase) EVT_MENU(IFMENU_PLOT_ROW, ImageFileView::OnPlotRow) EVT_MENU(IFMENU_PLOT_COL, ImageFileView::OnPlotCol) END_EVENT_TABLE() @@ -325,6 +325,15 @@ ImageFileView::OnCompare (wxCommandEvent& event) return; } + wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + differenceImage.labelsCopy (rIF, s.c_str()); + s = pCompareDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; + differenceImage.labelsCopy (rCompareIF, s.c_str()); + std::ostringstream osLabel; + osLabel << "Compare image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() + << " and " << pCompareDoc->GetFirstView()->GetFrame()->GetTitle().c_str() << ": " + << os.str().c_str(); + differenceImage.labelAdd (os.str().c_str()); if (theApp->getSetModifyNewDocs()) pDifferenceDoc->Modify(true); pDifferenceDoc->UpdateAllViews(this); @@ -405,15 +414,27 @@ ImageFileView::OnAdd (wxCommandEvent& event) ImageFile& rIF = GetDocument()->getImageFile(); ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rRHSIF = pRHSDoc->getImageFile(); - rIF.addImages (rRHSIF, rIF); + ImageFileDocument* pNewDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + if (! pNewDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + ImageFile& newImage = pNewDoc->getImageFile(); + newImage.setArraySize (rIF.nx(), rIF.ny()); + rIF.addImages (rRHSIF, newImage); std::ostringstream os; os << "Add image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and " << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); - rIF.labelAdd (os.str().c_str()); + wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rIF, s.c_str()); + s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rRHSIF, s.c_str()); + newImage.labelAdd (os.str().c_str()); *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getSetModifyNewDocs()) - GetDocument()->Modify(TRUE); - GetDocument()->UpdateAllViews(this); + pNewDoc->Modify(TRUE); + pNewDoc->UpdateAllViews(this); + pNewDoc->GetFirstView()->OnUpdate (this, NULL); } } } @@ -433,15 +454,27 @@ ImageFileView::OnSubtract (wxCommandEvent& event) ImageFile& rIF = GetDocument()->getImageFile(); ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rRHSIF = pRHSDoc->getImageFile(); - rIF.subtractImages (rRHSIF, rIF); + ImageFileDocument* pNewDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + if (! pNewDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + ImageFile& newImage = pNewDoc->getImageFile(); + newImage.setArraySize (rIF.nx(), rIF.ny()); + rIF.subtractImages (rRHSIF, newImage); std::ostringstream os; - os << "Subtract image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() - << " and " << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); - rIF.labelAdd (os.str().c_str()); + os << "Subtract image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and " + << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); + wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rIF, s.c_str()); + s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rRHSIF, s.c_str()); + newImage.labelAdd (os.str().c_str()); *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getSetModifyNewDocs()) - GetDocument()->Modify(TRUE); - GetDocument()->UpdateAllViews(this); + pNewDoc->Modify(TRUE); + pNewDoc->UpdateAllViews(this); + pNewDoc->GetFirstView()->OnUpdate (this, NULL); } } } @@ -461,15 +494,27 @@ ImageFileView::OnMultiply (wxCommandEvent& event) ImageFile& rIF = GetDocument()->getImageFile(); ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rRHSIF = pRHSDoc->getImageFile(); - rIF.multiplyImages (rRHSIF, rIF); + ImageFileDocument* pNewDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + if (! pNewDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + ImageFile& newImage = pNewDoc->getImageFile(); + newImage.setArraySize (rIF.nx(), rIF.ny()); + rIF.multiplyImages (rRHSIF, newImage); std::ostringstream os; - os << "Multiply image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() - << " and " << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); - rIF.labelAdd (os.str().c_str()); + os << "Multiply image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " and " + << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); + wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rIF, s.c_str()); + s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rRHSIF, s.c_str()); + newImage.labelAdd (os.str().c_str()); *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getSetModifyNewDocs()) - GetDocument()->Modify(TRUE); - GetDocument()->UpdateAllViews(this); + pNewDoc->Modify(TRUE); + pNewDoc->UpdateAllViews(this); + pNewDoc->GetFirstView()->OnUpdate (this, NULL); } } } @@ -489,15 +534,27 @@ ImageFileView::OnDivide (wxCommandEvent& event) ImageFile& rIF = GetDocument()->getImageFile(); ImageFileDocument* pRHSDoc = dialogGetCompare.getImageFileDocument(); const ImageFile& rRHSIF = pRHSDoc->getImageFile(); - rIF.divideImages (rRHSIF, rIF); + ImageFileDocument* pNewDoc = dynamic_cast(theApp->getDocManager()->CreateDocument("untitled.if", wxDOC_SILENT)); + if (! pNewDoc) { + sys_error (ERR_SEVERE, "Unable to create image file"); + return; + } + ImageFile& newImage = pNewDoc->getImageFile(); + newImage.setArraySize (rIF.nx(), rIF.ny()); + rIF.divideImages (rRHSIF, newImage); std::ostringstream os; - os << "Divide image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() - << " by " << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); - rIF.labelAdd (os.str().c_str()); + os << "Divide image " << GetDocument()->GetFirstView()->GetFrame()->GetTitle().c_str() << " by " + << pRHSDoc->GetFirstView()->GetFrame()->GetTitle().c_str(); + wxString s = GetDocument()->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rIF, s.c_str()); + s = pRHSDoc->GetFirstView()->GetFrame()->GetTitle() + ": "; + newImage.labelsCopy (rRHSIF, s.c_str()); + newImage.labelAdd (os.str().c_str()); *theApp->getLog() << os.str().c_str() << "\n"; if (theApp->getSetModifyNewDocs()) - GetDocument()->Modify(TRUE); - GetDocument()->UpdateAllViews(this); + pNewDoc->Modify(TRUE); + pNewDoc->UpdateAllViews(this); + pNewDoc->GetFirstView()->OnUpdate (this, NULL); } } } @@ -660,33 +717,35 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) view_menu->Append(IFMENU_VIEW_SCALE_MINMAX, "Display Scale &Set..."); view_menu->Append(IFMENU_VIEW_SCALE_AUTO, "Display Scale &Auto..."); - wxMenu* process_menu = new wxMenu; - process_menu->Append (IFMENU_PROCESS_INVERTVALUES, "&Invert Values"); - process_menu->Append (IFMENU_PROCESS_SQUARE, "&Square"); - process_menu->Append (IFMENU_PROCESS_SQRT, "Square &Root"); - process_menu->Append (IFMENU_PROCESS_LOG, "&Log"); - process_menu->Append (IFMENU_PROCESS_EXP, "&Exp"); - process_menu->AppendSeparator(); - process_menu->Append (IFMENU_PROCESS_ADD, "&Add"); - process_menu->Append (IFMENU_PROCESS_SUBTRACT, "Su&btract"); - process_menu->Append (IFMENU_PROCESS_MULTIPLY, "&Multiply"); - process_menu->Append (IFMENU_PROCESS_DIVIDE, "&Divide"); - process_menu->AppendSeparator(); - process_menu->Append (IFMENU_PROCESS_SCALESIZE, "S&cale Size..."); - process_menu->AppendSeparator(); + wxMenu* filter_menu = new wxMenu; + filter_menu->Append (IFMENU_FILTER_INVERTVALUES, "&Invert Values"); + filter_menu->Append (IFMENU_FILTER_SQUARE, "&Square"); + filter_menu->Append (IFMENU_FILTER_SQRT, "Square &Root"); + filter_menu->Append (IFMENU_FILTER_LOG, "&Log"); + filter_menu->Append (IFMENU_FILTER_EXP, "&Exp"); + filter_menu->AppendSeparator(); #ifdef HAVE_FFTW - process_menu->Append (IFMENU_PROCESS_FFT, "&FFT"); - process_menu->Append (IFMENU_PROCESS_IFFT, "&IFFT"); - process_menu->Append (IFMENU_PROCESS_FOURIER, "F&ourier"); - process_menu->Append (IFMENU_PROCESS_INVERSE_FOURIER, "Inverse Fo&urier"); + filter_menu->Append (IFMENU_FILTER_FFT, "&FFT"); + filter_menu->Append (IFMENU_FILTER_IFFT, "&IFFT"); + filter_menu->Append (IFMENU_FILTER_FOURIER, "F&ourier"); + filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "Inverse Fo&urier"); #else - process_menu->Append (IFMENU_PROCESS_FOURIER, "&Fourier"); - process_menu->Append (IFMENU_PROCESS_INVERSE_FOURIER, "&Inverse Fourier"); + filter_menu->Append (IFMENU_FILTER_FOURIER, "&Fourier"); + filter_menu->Append (IFMENU_FILTER_INVERSE_FOURIER, "&Inverse Fourier"); #endif - process_menu->Append (IFMENU_PROCESS_SHUFFLEFOURIERTONATURALORDER, "S&huffle Fourier to Natural Order"); - process_menu->Append (IFMENU_PROCESS_SHUFFLENATURALTOFOURIERORDER, "Shu&ffle Natural to Fourier Order"); - process_menu->Append (IFMENU_PROCESS_MAGNITUDE, "&Magnitude"); - process_menu->Append (IFMENU_PROCESS_PHASE, "&Phase"); + filter_menu->Append (IFMENU_FILTER_SHUFFLEFOURIERTONATURALORDER, "S&huffle Fourier to Natural Order"); + filter_menu->Append (IFMENU_FILTER_SHUFFLENATURALTOFOURIERORDER, "Shu&ffle Natural to Fourier Order"); + filter_menu->Append (IFMENU_FILTER_MAGNITUDE, "&Magnitude"); + filter_menu->Append (IFMENU_FILTER_PHASE, "&Phase"); + + wxMenu* image_menu = new wxMenu; + filter_menu->AppendSeparator(); + image_menu->Append (IFMENU_IMAGE_ADD, "&Add..."); + image_menu->Append (IFMENU_IMAGE_SUBTRACT, "&Subtract..."); + image_menu->Append (IFMENU_IMAGE_MULTIPLY, "&Multiply..."); + image_menu->Append (IFMENU_IMAGE_DIVIDE, "&Divide..."); + image_menu->AppendSeparator(); + image_menu->Append (IFMENU_IMAGE_SCALESIZE, "S&cale Size..."); wxMenu *plot_menu = new wxMenu; plot_menu->Append (IFMENU_PLOT_ROW, "Plot &Row"); @@ -704,7 +763,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) menu_bar->Append(file_menu, "&File"); menu_bar->Append(view_menu, "&View"); - menu_bar->Append(process_menu, "&Process"); + menu_bar->Append(image_menu, "&Image"); + menu_bar->Append(filter_menu, "Fi<er"); menu_bar->Append(plot_menu, "P&lot"); menu_bar->Append(compare_menu, "&Compare"); menu_bar->Append(help_menu, "&Help"); @@ -1292,7 +1352,7 @@ PhantomView::OnRasterize (wxCommandEvent& event) if (retVal == wxID_OK) { int xSize = dialogRaster.getXSize(); int ySize = dialogRaster.getYSize(); - int nSamples = dialogRaster.getNSamples(); + int nSamples = dialogRaster.getNSamples(); if (nSamples < 1) nSamples = 1; if (xSize > 0 && ySize > 0) { @@ -1305,7 +1365,8 @@ PhantomView::OnRasterize (wxCommandEvent& event) ImageFile& imageFile = pRasterDoc->getImageFile(); imageFile.setArraySize (xSize, ySize); - wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), imageFile.nx() + 1, m_frame, wxPD_CAN_ABORT); + wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), imageFile.nx() + 1, m_frame, wxPD_CAN_ABORT); + Timer timer; for (unsigned int i = 0; i < imageFile.nx(); i++) { rPhantom.convertToImagefile (imageFile, nSamples, Trace::TRACE_NONE, i, 1, true); if (! dlgProgress.Update(i+1)) { @@ -1315,16 +1376,17 @@ PhantomView::OnRasterize (wxCommandEvent& event) } if (theApp->getSetModifyNewDocs()) pRasterDoc->Modify(true); - pRasterDoc->UpdateAllViews(this); + pRasterDoc->UpdateAllViews(this); + std::ostringstream os; + os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples; + *theApp->getLog() << os.str().c_str() << "\n"; + imageFile.labelAdd (os.str().c_str(), timer.timerEnd()); ImageFileView* rasterView = dynamic_cast(pRasterDoc->GetFirstView()); if (rasterView) { rasterView->getFrame()->SetFocus(); rasterView->OnUpdate (rasterView, NULL); } - std::ostringstream os; - os << "Rasterize Phantom " << rPhantom.name() << ": XSize=" << xSize << ", YSize=" << ySize << ", nSamples=" << nSamples << "\n"; - *theApp->getLog() << os.str().c_str(); } } } @@ -1552,24 +1614,9 @@ ProjectionFileView::OnReconstruct (wxCommandEvent& event) wxMessageBox ("Sorry!\nCurrently, frequency-based filtering with direct filter generation is not support for geometries other than parallel.\nAborting command.", "Not Supported", wxOK | wxICON_WARNING, m_frame); return; } -#if 0 - SGPDriver* pSGPDriver = NULL; - SGP* pSGP = NULL; - wxMemoryDC* pDCPlot = NULL; - wxBitmap bitmap; - if (m_iDefaultTrace >= Trace::TRACE_PLOT) { - bitmap.Create (500, 500); - pDCPlot = new wxMemoryDC; - pDCPlot->SelectObject (bitmap); - pSGPDriver = new SGPDriver (dynamic_castpDCPlot, 500, 500); - pSGP = new SGP (*pSGPDriver); - } - Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace, pSGP); - delete pSGP; -#else + Reconstructor* pReconstruct = new Reconstructor (rProj, imageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); -#endif - + Timer timerRecon; if (m_iDefaultTrace > Trace::TRACE_CONSOLE) { ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstruct, rProj, imageFile, m_iDefaultTrace, m_frame); @@ -1614,7 +1661,7 @@ ProjectionFileView::OnReconstruct (wxCommandEvent& event) os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str(); *theApp->getLog() << os.str().c_str() << "\n"; imageFile.labelAdd (rProj.getLabel()); - imageFile.labelAdd (Array2dFileLabel::L_HISTORY, os.str().c_str(), timerRecon.timerEnd()); + imageFile.labelAdd (os.str().c_str(), timerRecon.timerEnd()); } } }