X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=a4826e0292c0d7137c6ae94144788f9f64ab5335;hp=b8404bda75be20c0dfea8b9e5b9badc333e750d9;hb=df521cfe14a9e0b47bdcd98d1f67d03acf242162;hpb=e081109a4a541c8780aaa253b874acada5957200 diff --git a/src/views.cpp b/src/views.cpp index b8404bd..a4826e0 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.113 2001/02/22 15:00:20 kevin Exp $ +** $Id: views.cpp,v 1.118 2001/02/25 10:52:55 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 @@ -113,6 +113,7 @@ ImageFileCanvas::OnMouseEvent(wxMouseEvent& event) { if (! m_pView) return; + wxClientDC dc(this); PrepareDC(dc); @@ -1001,6 +1002,10 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) double scaleWidth = m_dMaxPixel - m_dMinPixel; unsigned char* imageData = new unsigned char [nx * ny * 3]; + if (! imageData) { + sys_error (ERR_SEVERE, "Unable to allocate memory for Image display"); + return; + } for (int ix = 0; ix < nx; ix++) { for (int iy = 0; iy < ny; iy++) { double scaleValue = ((v[ix][iy] - m_dMinPixel) / scaleWidth) * 255; @@ -1897,6 +1902,13 @@ PhantomFileView::OnProjections (wxCommandEvent& event) wxMessageBox (msg, "Error"); return; } + std::ostringstream os; + os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet + << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample + << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength + << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio + << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << + convertRadiansToDegrees (theScanner.fanBeamAngle()); pProj->initFromScanner (theScanner); m_dDefaultRotation /= TWOPI; // convert back to fraction of a circle @@ -1926,15 +1938,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event) } } - std::ostringstream os; - os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet - << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample - << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength - << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio - << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << - convertRadiansToDegrees (theScanner.fanBeamAngle()); - pProj->setCalcTime (timer.timerEnd()); pProj->setRemark (os.str()); + pProj->setCalcTime (timer.timerEnd()); *theApp->getLog() << os.str().c_str() << "\n"; ::wxYield(); @@ -2411,6 +2416,7 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) ::wxUsleep(50); } } + pReconstructor->postProcessing(); delete pDlgReconstruct; delete pReconstructor; ImageFileDocument* pReconDoc = theApp->newImageDoc(); @@ -2433,15 +2439,17 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) } else { if (theApp->getUseBackgroundTasks() || theApp->getNumberCPU() > 1) { - ThreadedReconstructor* pReconstructor = new ThreadedReconstructor (this, + ReconstructorSupervisorThread* pReconstructor = new ReconstructorSupervisorThread (this, m_iDefaultNX, m_iDefaultNY, optFilterName.c_str(), m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), os.str().c_str()); - if (! pReconstructor->start()) { + if (pReconstructor->Create() != wxTHREAD_NO_ERROR) { + sys_error (ERR_SEVERE, "Error creating reconstructor thread"); delete pReconstructor; return; } - // delete pReconstructor; // reconstructor is still running +// pReconstructor->SetPriority (60); + pReconstructor->Run(); } else { ImageFile* pImageFile = new ImageFile; pImageFile->setArraySize (m_iDefaultNX, m_iDefaultNY); @@ -2458,6 +2466,7 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event) return; } } + pReconstructor->postProcessing(); delete pReconstructor; ImageFileDocument* pReconDoc = theApp->newImageDoc(); if (! pReconDoc) { @@ -2635,6 +2644,10 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } unsigned char* imageData = new unsigned char [nDet * nView * 3]; + if (! imageData) { + sys_error (ERR_SEVERE, "Unable to allocate memory for image display"); + return; + } double scale = (max - min) / 255; for (int iy2 = 0; iy2 < nView; iy2++) { const DetectorArray& detarray = rProj.getDetectorArray (iy2);