From dde6f495fe3fc83ce98c2f12307d67f79b8c5c36 Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Tue, 11 Oct 2011 08:17:28 +0200
Subject: [PATCH] ENH: StreamingImageFileWriter observe its source for finer
 progress reporting

---
 Code/IO/otbStreamingImageFileWriter.txx | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Code/IO/otbStreamingImageFileWriter.txx b/Code/IO/otbStreamingImageFileWriter.txx
index 11fbd62384..0a9fd7947a 100644
--- a/Code/IO/otbStreamingImageFileWriter.txx
+++ b/Code/IO/otbStreamingImageFileWriter.txx
@@ -518,6 +518,27 @@ StreamingImageFileWriter<TInputImage>
   m_ImageIO->WriteImageInformation();
 
   this->UpdateProgress(0);
+  m_CurrentDivision = 0;
+  m_DivisionProgress = 0;
+
+  // Get the source process object
+  itk::ProcessObject* source = inputPtr->GetSource();
+
+  // Check if source exists
+  if(source)
+    {
+    typedef itk::MemberCommand<Self> CommandType;
+    typedef typename CommandType::Pointer CommandPointerType;
+
+    CommandPointerType command = CommandType::New();
+    command->SetCallbackFunction(this, &Self::ObserveSourceFilterProgress);
+
+    source->AddObserver(itk::ProgressEvent(), command);
+    }
+  else
+    {
+    itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy");
+    }
 
   for (m_CurrentDivision = 0;
        m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData();
-- 
GitLab