[vtkusers] Progress event with vtkMetaImageReader

Wang Zhimin zwang at i2r.a-star.edu.sg
Wed Jan 19 01:33:31 EST 2011


Hi, VTKers,

I am looking for a sample code to create a callback function to interact with QT's progress bar. In ITK, I usually do it in this way.

// The call back function
class ShowProgressObject
{
public:
    ShowProgressObject()
        {
            m_Process = NULL;
            m_progressBar = NULL;
            m_accumulatedProgress = 0;
            m_proportion = 1;
        }
    void SetProcessObject( itk::ProcessObject* o ) { m_Process = o; }
    void SetProgressBar( QProgressBar* p ) { m_progressBar = p; }
    void SetAccumulatedProgress( double ap ) { m_accumulatedProgress = ap; }
    void SetProportion( double p ) { m_proportion = p; }
    void ShowProgress()
        {
            if( m_progressBar )
            {
                m_progressBar->setValue( m_accumulatedProgress + m_Process->GetProgress() * 100 * m_proportion );
                qApp->processEvents();
            }
        }
    itk::ProcessObject::Pointer m_Process;
    QProgressBar* m_progressBar;
    double m_accumulatedProgress;
    double m_proportion;
};

// register it with itk filter/io
itk::SimpleMemberCommand<ShowProgressObject>::Pointer command;
    command = itk::SimpleMemberCommand<ShowProgressObject>::New();
	command->SetCallbackFunction(&progress,
                                 &ShowProgressObject::ShowProgress);
	
	itkMetaImageReader->SetFileName( inputFileName.c_str() );
	itkMetaImageReader->AddObserver( itk::ProgressEvent(), command );
    itkMetaImageReader->Update();

May I know how I can implement the above similarly with vtkMetaImageReader in VTK+QT application?

Thank you very much.

Zhimin WANG, Ph.D.
Institute for Infocomm Research 
A-STAR, Singapore
 

Institute for Infocomm Research disclaimer:  "This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110119/bc8ab6ce/attachment.htm>


More information about the vtkusers mailing list