[Insight-users] How to know the progress of an executing filter?

Luis Ibanez luis . ibanez at kitware . com
Sun, 17 Aug 2003 09:52:38 -0400


Hi Zhao,


Please take a look at the itkCommand.h file
in Insight/Code/Common.

There are multiple mechanisms for using the Command/Observers.
Here is one that is commonly used:

---------------------------------------------
#include itkCommand.h"

class GUI
{
   typedef itk::SimplememberCommand< GUI >  ObserverType;
   typedef itk::WatershedImageFilter< ImageType > WatershedFilterType;

    // More GUI stuff here....

GUI() // constructor
    {
    m_Observer        = ObserverType::New();
    m_WatershedFilter = WatershedFilterType::New();

    m_WatershedFilter->AddObserver( itk::ProgressEvent(), m_Observer );
    m_CommandObserver->SetCallbackFunction(
                               this,
                               &GUI::UpdateWatershedProgressBar );
    }


    void UpdateWatershedProgressBar()
    {
     // update the widget: FLTK, Qt, MFC, ....
     progressBarWidget->SetValue(  m_WatershedFilter->GetProgress() );
    }

private:
     ObserverType::Pointer          m_Observer;
     WatershedFilterType::Pointer   m_WatershedFilter;
     //
     // more GUI stuff here...
     //
}


--------------------------------------------------



Regards,


    Luis


------------------
Zhaocg wrote:
> Hi Friends,
>     
>     I am using WatershedImageFilter of itk under VC6. The execution of this filter is time consuming. So, during the execution, I want to use a ProgressBar to inform this filter's progress. How to realize it? Thanks!
>  
>     From the example, I noticed that itk use itk::PrintProgressCommand, itk::ProgressEvent and AddObserver to inform the progress. But how to use these functions under VC?
>  
>  
> Zhao