r1938: *** empty log message ***
[ctsim.git] / src / views.cpp
index 3a91f6eaa76d63c0efb53fba8488529b856cdb68..3f7db0b337b2fb85ed010e798ddaa26925e7191c 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.153 2002/05/03 09:57:41 kevin Exp $
+**  $Id: views.cpp,v 1.154 2002/05/05 05:31:16 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 <sstream_subst>
 #endif
 
+// Used to reduce calls to progress bar update function
+const short int ITER_PER_UPDATE = 10;
 
 // ImageFileCanvas
 
@@ -2155,10 +2157,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;
+         }
       }
     }
   }
@@ -2222,15 +2225,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();
@@ -2924,10 +2933,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;