Skip to content
Snippets Groups Projects
Commit fc7ccf55 authored by Antoine Regimbeau's avatar Antoine Regimbeau
Browse files

ENH : adding a method to remove observer

WARNING : code not clean QtProgressBar::ClearObserver()
parent 55c7d6fd
No related branches found
No related tags found
1 merge request!22Register Pipeline Services (ProcessObjects and DataObjects)
......@@ -52,10 +52,11 @@ public:
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 );
void ClearObserver();
signals:
void SetValueChanged(int);
......
......@@ -61,6 +61,7 @@ public slots:
void AddNewProcessToReport();
private:
void ClearEvent();
QtWidgetSimpleProgressReport(const QtWidgetSimpleProgressReport&); //purposely not implemented
void operator=(const QtWidgetSimpleProgressReport&); //purposely not
//implemented
......
......@@ -98,4 +98,24 @@ QtProgressBar::Observe( itk::Object *caller )
m_Caller->AddObserver( itk::ProgressEvent(), m_RedrawCommand.GetPointer() );
}
void
QtProgressBar::ClearObserver()
{
if ( m_Caller->HasObserver(itk::ProgressEvent()) )
{
unsigned int i(0);
while ( (m_Caller->GetCommand(i)) != (m_RedrawCommand.GetPointer()) )
{
++i;
if (i>10)
std::cout<<"ERROR"<<std::endl;
}
std::cout<<i<<std::endl;
m_Caller->RemoveObserver(i);
}
m_Caller = nullptr;
// m_Caller->RemoveAllObservers();
}
} // end namespace fltk
......@@ -78,12 +78,24 @@ QtWidgetSimpleProgressReport::ProcessEvent( itk::Object * itkNotUsed(caller),
if(eventToWatch)
{
m_CurrentProcess = eventToWatch->GetProcess();
std::cout<<"process in the box : "<<m_CurrentProcess->GetNameOfClass()<<std::endl;
m_CurrentDescription = eventToWatch->GetProcessDescription();
std::cout<<"Description is : "<<m_CurrentDescription<<std::endl;
emit AddNewProcessToReport();
}
}
}
void
QtWidgetSimpleProgressReport::ClearEvent()
{
std::cout<<"Cleaning event"<<std::endl;
m_CurrentProcess = nullptr;
m_CurrentDescription = "";
// emit AddNewProcessToReport();
m_Bar->ClearObserver();
}
void QtWidgetSimpleProgressReport::ReportProcess()
{
m_Bar->Observe(m_CurrentProcess);
......@@ -93,6 +105,7 @@ void QtWidgetSimpleProgressReport::ReportProcess()
void QtWidgetSimpleProgressReport::Init()
{
ClearEvent();
m_Bar->setValue(0);
m_Label->setText("No process");
}
......
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