Skip to content
Snippets Groups Projects
Commit 2c2cb84e authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH : Add class from ITKApp to manage progressEvents of ProcessObject filters

parent 6a41f1b6
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkQtProgressBar.cxx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkProcessObject.h"
#include "itkQtProgressBar.h"
namespace itk {
/** Constructor */
QtProgressBar::QtProgressBar( QWidget *parent):QProgressBar(parent)
{
m_RedrawCommand = RedrawCommandType::New();
m_RedrawCommand->SetCallbackFunction( this, &QtProgressBar::ProcessEvent );
m_RedrawCommand->SetCallbackFunction( this, &QtProgressBar::ConstProcessEvent );
this->setMaximum( 100 );
this->reset();
}
/** Get Command */
QtProgressBar::RedrawCommandType *
QtProgressBar::GetRedrawCommand( void ) const
{
return m_RedrawCommand.GetPointer();
}
/** Manage a Progress event */
void
QtProgressBar::ProcessEvent( itk::Object * caller,
const itk::EventObject & event )
{
if( typeid( itk::ProgressEvent ) == typeid( event ) )
{
::itk::ProcessObject::Pointer process =
dynamic_cast< itk::ProcessObject *>( caller );
const int value = static_cast<int>(
process->GetProgress() * this->maximum() );
emit SetValueChanged( value );
}
}
void
QtProgressBar::ConstProcessEvent( const itk::Object * caller,
const itk::EventObject & event )
{
if( typeid( itk::ProgressEvent ) == typeid( event ) )
{
itk::ProcessObject::ConstPointer process =
dynamic_cast< const itk::ProcessObject *>( caller );
const int value = static_cast<int>(
process->GetProgress() * this->maximum() );
emit SetValueChanged( value );
}
}
/** Manage a Progress event */
void
QtProgressBar::Observe( itk::Object *caller )
{
caller->AddObserver( itk::ProgressEvent(), m_RedrawCommand.GetPointer() );
}
} // end namespace fltk
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkQtProgressBar.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include <QtGui>
#include "itkCommand.h"
namespace itk {
class QtProgressBar : public ::QProgressBar
{
Q_OBJECT
public:
/** Command Class invoked for button redraw */
typedef itk::MemberCommand< QtProgressBar > RedrawCommandType;
/** Constructor */
QtProgressBar( QWidget *parent );
/** Get Command */
RedrawCommandType * GetRedrawCommand( void ) const;
/** Manage a Progress event */
void ProcessEvent(itk::Object * caller, const itk::EventObject & event );
void ConstProcessEvent(const itk::Object * caller, const itk::EventObject & event );
/** Manage a Progress event */
void Observe( itk::Object *caller );
signals:
void SetValueChanged(int);
private:
RedrawCommandType::Pointer m_RedrawCommand;
};
} // end of namespace
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment