X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=5c3c0d095e5ffea4249bcd9ea9b8ce06c798aa66;hp=1ce18dbda6210b05b51697e6c446da78820cfdb9;hb=6562049dd76f2b8d6ded69dc75b4649e1b203743;hpb=dc5eb7b285e647a99535740a99d73d468a856ba3 diff --git a/src/views.cpp b/src/views.cpp index 1ce18db..5c3c0d0 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.151 2002/05/03 00:40:30 kevin Exp $ +** $Id: views.cpp,v 1.155 2002/05/05 14:22:44 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 @@ -58,6 +58,8 @@ #include #endif +// Used to reduce calls to progress bar update function +const short int ITER_PER_UPDATE = 10; // ImageFileCanvas @@ -1985,8 +1987,9 @@ PhantomCanvas::GetBestSize() const #ifdef CTSIM_MDI ySize = xSize = (xSize / 4); #else - ySize = xSize; + xSize = ySize = ySize * .7; #endif + return wxSize (xSize, ySize); } @@ -2155,10 +2158,11 @@ PhantomFileView::OnProjections (wxCommandEvent& event) for (int i = 0; i < pProj->nView(); i++) { //theScanner.collectProjections (*pProj, rPhantom, i, 1, true, m_iDefaultTrace); theScanner.collectProjections (*pProj, rPhantom, i, 1, theScanner.offsetView(), true, m_iDefaultTrace); - if (! dlgProgress.Update (i+1)) { - delete pProj; - return; - } + if ((i + 1) % ITER_PER_UPDATE == 0) + if (! dlgProgress.Update (i+1)) { + delete pProj; + return; + } } } } @@ -2173,18 +2177,6 @@ PhantomFileView::OnProjections (wxCommandEvent& event) return; } pProjectionDoc->setProjections (pProj); - ProjectionFileView* projView = pProjectionDoc->getView(); - if (projView) { - projView->OnUpdate (projView, NULL); - if (projView->getCanvas()) - projView->getCanvas()->SetClientSize (m_iDefaultNDet, m_iDefaultNView); - if (wxFrame* pFrame = projView->getFrame()) { - pFrame->Show(true); - pFrame->SetFocus(); - pFrame->Raise(); - } - GetDocumentManager()->ActivateView (projView, true, false); - } if (theApp->getAskDeleteNewDocs()) pProjectionDoc-> Modify(true); pProjectionDoc->UpdateAllViews (this); @@ -2234,15 +2226,21 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) { ImageFile* pImageFile = new ImageFile (m_iDefaultRasterNX, m_iDefaultRasterNY); - wxProgressDialog dlgProgress (wxString("Rasterize"), wxString("Rasterization Progress"), - pImageFile->nx() + 1, getFrameForChild(), wxPD_CAN_ABORT ); + wxProgressDialog dlgProgress (wxString("Rasterize"), + wxString("Rasterization Progress"), + pImageFile->nx() + 1, + getFrameForChild(), + wxPD_CAN_ABORT ); Timer timer; for (unsigned int i = 0; i < pImageFile->nx(); i++) { - rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, m_iDefaultRasterNSamples, Trace::TRACE_NONE, i, 1, true); - if (! dlgProgress.Update (i+1)) { - delete pImageFile; - return; - } + rPhantom.convertToImagefile (*pImageFile, m_dDefaultRasterViewRatio, + m_iDefaultRasterNSamples, Trace::TRACE_NONE, + i, 1, true); + if ((i + 1) % ITER_PER_UPDATE == 0) + if (! dlgProgress.Update (i+1)) { + delete pImageFile; + return; + } } ImageFileDocument* pRasterDoc = theApp->newImageDoc(); @@ -2256,7 +2254,7 @@ PhantomFileView::OnRasterize (wxCommandEvent& event) *theApp->getLog() << os.str().c_str() << "\n"; pImageFile->labelAdd (os.str().c_str(), timer.timerEnd()); - pRasterDoc->UpdateAllViews(); + pRasterDoc->UpdateAllViews(this); pRasterDoc->getView()->setInitialClientSize(); pRasterDoc->Activate(); } @@ -2542,6 +2540,7 @@ ProjectionFileView::OnConvertRectangular (wxCommandEvent& event) pIF->labelAdd (os.str().c_str()); if (theApp->getAskDeleteNewDocs()) pRectDoc->Modify (true); + pRectDoc->UpdateAllViews(); pRectDoc->getView()->setInitialClientSize(); pRectDoc->Activate(); } @@ -2623,7 +2622,7 @@ ProjectionFileView::OnConvertFFTPolar (wxCommandEvent& event) pIF->labelAdd (os.str().c_str()); if (theApp->getAskDeleteNewDocs()) pPolarDoc->Modify (true); - pPolarDoc->UpdateAllViews (); + pPolarDoc->UpdateAllViews (this); pPolarDoc->getView()->setInitialClientSize(); pPolarDoc->Activate(); } @@ -2935,10 +2934,11 @@ ProjectionFileView::doReconstructFBP (const Projections& rProj, bool bRebinToPar for (int iView = 0; iView < rProj.nView(); iView++) { pReconstructor->reconstructView (iView, 1); - if (! dlgProgress.Update (iView + 1)) { - delete pReconstructor; - return; // don't make new window, thread will do this - } + if ((iView + 1) % ITER_PER_UPDATE == 0) + if (! dlgProgress.Update (iView + 1)) { + delete pReconstructor; + return; // don't make new window, thread will do this + } } pReconstructor->postProcessing(); delete pReconstructor; @@ -3106,7 +3106,7 @@ void ProjectionFileView::setInitialClientSize () { wxSize bestSize = m_pCanvas->GetBestSize(); - + if (bestSize.x > 800) bestSize.x = 800; if (bestSize.y > 800) @@ -3158,16 +3158,13 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) wxImage image (nDet, nView, imageData, true); m_bitmap = image.ConvertToBitmap(); delete imageData; - //int xSize = nDet; - //int ySize = nView; - //xSize = clamp (xSize, 0, 800); - //ySize = clamp (ySize, 0, 800); - //m_pFrame->SetClientSize (xSize, ySize); - m_pCanvas->SetScrollbars (20, 20, nDet/20, nView/20); } - if (m_pCanvas) - m_pCanvas->Refresh(); + m_pCanvas->SetScrollbars(20, 20, nDet/20, nView/20); + m_pCanvas->SetBackgroundColour(*wxWHITE); + + if (m_pCanvas) + m_pCanvas->Refresh(); } bool @@ -3673,7 +3670,7 @@ TextFileCanvas::~TextFileCanvas () } wxSize -PlotFileCanvas::GetBestSize() const +TextFileCanvas::GetBestSize() const { int xSize, ySize; theApp->getMainFrame()->GetClientSize (&xSize, &ySize);