X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=f902f19ca1d31b6a1c372282975a1c543976b58a;hp=fdfbc9f6dde82fd16e1d9576f4f5d87894a77454;hb=c358b8c8b5649f14e2b8203b999ba8549a244727;hpb=432ba2c487a5320352f14bdd2cce008fccef6902 diff --git a/src/views.cpp b/src/views.cpp index fdfbc9f..f902f19 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.121 2001/02/27 03:59:30 kevin Exp $ +** $Id: views.cpp,v 1.123 2001/03/01 20:02:18 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 @@ -249,7 +249,7 @@ END_EVENT_TABLE() ImageFileView::ImageFileView() : wxView(), m_pFrame(NULL), m_pCanvas(NULL), m_pFileMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false) { - m_iDefaultExportFormatID = ImageFile::FORMAT_PNG; + m_iDefaultExportFormatID = ImageFile::EXPORT_FORMAT_PNG; } ImageFileView::~ImageFileView() @@ -840,6 +840,8 @@ ImageFileView::CreateChildFrame(wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_PRINT, "&Print..."); m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); m_pFileMenu->Append(wxID_PREVIEW, "Print Preview"); + m_pFileMenu->AppendSeparator(); + m_pFileMenu->Append(MAINMENU_IMPORT, "&Import\tCtrl-I..."); #ifdef CTSIM_MDI m_pFileMenu->AppendSeparator(); m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces..."); @@ -1080,20 +1082,24 @@ ImageFileView::OnExport (wxCommandEvent& event) DialogExportParameters dialogExport (getFrameForChild(), m_iDefaultExportFormatID); if (dialogExport.ShowModal() == wxID_OK) { wxString strFormatName (dialogExport.getFormatName ()); - m_iDefaultExportFormatID = ImageFile::convertFormatNameToID (strFormatName.c_str()); + m_iDefaultExportFormatID = ImageFile::convertExportFormatNameToID (strFormatName.c_str()); wxString strExt; wxString strWildcard; - if (m_iDefaultExportFormatID == ImageFile::FORMAT_PGM || m_iDefaultExportFormatID == ImageFile::FORMAT_PGMASCII) { + if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGM || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PGMASCII) { strExt = ".pgm"; strWildcard = "PGM Files (*.pgm)|*.pgm"; } #ifdef HAVE_PNG - else if (m_iDefaultExportFormatID == ImageFile::FORMAT_PNG || m_iDefaultExportFormatID == ImageFile::FORMAT_PNG16) { + else if (m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG || m_iDefaultExportFormatID == ImageFile::EXPORT_FORMAT_PNG16) { strExt = ".png"; strWildcard = "PNG Files (*.png)|*.png"; } #endif + else { + strExt = ""; + strWildcard = "Miscellaneous (*.*)|*.*"; + } const wxString& strFilename = wxFileSelector (wxString("Export Filename"), wxString(""), wxString(""), strExt, strWildcard, wxOVERWRITE_PROMPT | wxHIDE_READONLY | wxSAVE); @@ -1825,13 +1831,15 @@ PhantomFileView::PhantomFileView() #if defined(DEBUG) || defined(_DEBUG) m_iDefaultNDet = 165; m_iDefaultNView = 180; + m_iDefaultNSample = 1; #else m_iDefaultNDet = 367; m_iDefaultNView = 320; -#endif m_iDefaultNSample = 2; +#endif m_dDefaultRotation = 1; m_dDefaultFocalLength = 2; + m_dDefaultCenterDetectorLength = 2; m_dDefaultViewRatio = 1; m_dDefaultScanRatio = 1; m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL; @@ -1877,8 +1885,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event) { DialogGetProjectionParameters dialogProjection (getFrameForChild(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, - m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, m_iDefaultGeometry, - m_iDefaultTrace); + m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio, + m_iDefaultGeometry, m_iDefaultTrace); int retVal = dialogProjection.ShowModal(); if (retVal != wxID_OK) return; @@ -1889,6 +1897,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) m_iDefaultTrace = dialogProjection.getTrace(); m_dDefaultRotation = dialogProjection.getRotAngle(); m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio(); + m_dDefaultCenterDetectorLength = dialogProjection.getCenterDetectorLengthRatio(); m_dDefaultViewRatio = dialogProjection.getViewRatio(); m_dDefaultScanRatio = dialogProjection.getScanRatio(); wxString sGeometry = dialogProjection.getGeometry(); @@ -1901,7 +1910,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) const Phantom& rPhantom = GetDocument()->getPhantom(); Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, - dRotationRadians, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio); + dRotationRadians, m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio); if (theScanner.fail()) { wxString msg = "Failed making scanner\n"; msg += theScanner.failMessage().c_str(); @@ -1914,6 +1923,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength + << ", CenterDetectorLengthRatio=" << m_dDefaultCenterDetectorLength << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << convertRadiansToDegrees (theScanner.fanBeamAngle()); @@ -1941,7 +1951,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event) if (theApp->getUseBackgroundTasks() || theApp->getNumberCPU() > 1) { ProjectorSupervisorThread* pProjector = new ProjectorSupervisorThread (this, m_iDefaultNDet, m_iDefaultNView, sGeometry.c_str(), m_iDefaultNSample, dRotationRadians, - m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str()); + m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str()); if (pProjector->Create() != wxTHREAD_NO_ERROR) { sys_error (ERR_SEVERE, "Error creating projector thread"); delete pProjector; @@ -2102,6 +2112,8 @@ PhantomFileView::CreateChildFrame(wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_PRINT, "&Print..."); m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view"); + m_pFileMenu->AppendSeparator(); + m_pFileMenu->Append(MAINMENU_IMPORT, "&Import\tCtrl-I..."); #ifdef CTSIM_MDI m_pFileMenu->AppendSeparator(); m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces..."); @@ -2427,14 +2439,14 @@ ProjectionFileView::OnReconstructFBP (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(); Timer timerRecon; - ImageFile rImageFile; + ImageFile* pImageFile = NULL; if (m_iDefaultTrace > Trace::TRACE_CONSOLE) { - rImageFile.setArraySize (m_iDefaultNX, m_iDefaultNY); - Reconstructor* pReconstructor = new Reconstructor (rProj, rImageFile, optFilterName.c_str(), + pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY); + Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); - ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, rImageFile, m_iDefaultTrace, getFrameForChild()); + ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, *pImageFile, m_iDefaultTrace, getFrameForChild()); for (int iView = 0; iView < rProj.nView(); iView++) { ::wxYield(); if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView, true)) { @@ -2467,8 +2479,8 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) pReconstructor->Run(); return; } else { - rImageFile.setArraySize (m_iDefaultNX, m_iDefaultNY); - Reconstructor* pReconstructor = new Reconstructor (rProj, rImageFile, optFilterName.c_str(), + pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY); + Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace); @@ -2482,11 +2494,6 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) } pReconstructor->postProcessing(); delete pReconstructor; - ImageFileDocument* pReconDoc = theApp->newImageDoc(); - if (! pReconDoc) { - sys_error (ERR_SEVERE, "Unable to create image file"); - return; - } } } ImageFileDocument* pReconDoc = theApp->newImageDoc(); @@ -2494,7 +2501,7 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) sys_error (ERR_SEVERE, "Unable to create image file"); return; } - pReconDoc->setImageFile (&rImageFile); + pReconDoc->setImageFile (pImageFile); if (theApp->getAskDeleteNewDocs()) pReconDoc->Modify (true); pReconDoc->UpdateAllViews (this); @@ -2504,8 +2511,8 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) rasterView->getFrame()->Show(true); } *theApp->getLog() << os.str().c_str() << "\n"; - rImageFile.labelAdd (rProj.getLabel()); - rImageFile.labelAdd (os.str().c_str(), timerRecon.timerEnd()); + pImageFile->labelAdd (rProj.getLabel()); + pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd()); } @@ -2555,6 +2562,8 @@ ProjectionFileView::CreateChildFrame(wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_PRINT, "&Print..."); m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view"); + m_pFileMenu->AppendSeparator(); + m_pFileMenu->Append(MAINMENU_IMPORT, "&Import\tCtrl-I..."); #ifdef CTSIM_MDI m_pFileMenu->AppendSeparator(); m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces..."); @@ -2885,6 +2894,8 @@ PlotFileView::CreateChildFrame(wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_PRINT, "&Print..."); m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view"); + m_pFileMenu->AppendSeparator(); + m_pFileMenu->Append(MAINMENU_IMPORT, "&Import\tCtrl-I..."); #ifdef CTSIM_MDI m_pFileMenu->AppendSeparator(); m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces..."); @@ -3138,6 +3149,8 @@ TextFileView::CreateChildFrame (wxDocument *doc, wxView *view) m_pFileMenu->Append(wxID_PRINT, "&Print..."); m_pFileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); m_pFileMenu->Append(wxID_PREVIEW, "Print Pre&view"); + m_pFileMenu->AppendSeparator(); + m_pFileMenu->Append(MAINMENU_IMPORT, "&Import\tCtrl-I..."); #ifdef CTSIM_MDI m_pFileMenu->AppendSeparator(); m_pFileMenu->Append (MAINMENU_FILE_PREFERENCES, "Prefere&nces...");