Commit 2770d08f authored by Mathieu Deltorre's avatar Mathieu Deltorre
Browse files

Modif pour que le fltk watcher hérite de otb::FilterWatcherBase

La classe fltkWatcher surcharge a present les callbacks:
ShowProgress
EndFilter
BeginFilter
parent c7890012
......@@ -24,31 +24,11 @@ namespace otb
{
FltkFilterWatcher
::FltkFilterWatcher(itk::ProcessObject* o,int x, int y, int w, int h,const char *comment)
::FltkFilterWatcher(itk::ProcessObject* process,
int x, int y, int w, int h,
const char *comment)
: FilterWatcherBase(process, comment)
{
// Initialize state
m_Process = o;
m_Comment = comment;
// Create a series of commands
m_StartFilterCommand = CommandType::New();
m_EndFilterCommand = CommandType::New();
m_ProgressFilterCommand = CommandType::New();
// Assign the callbacks
m_StartFilterCommand->SetCallbackFunction(this,
&FltkFilterWatcher::StartFilter);
m_EndFilterCommand->SetCallbackFunction(this,
&FltkFilterWatcher::EndFilter);
m_ProgressFilterCommand->SetCallbackFunction(this,
&FltkFilterWatcher::ShowProgress);
// Add the commands as observers
m_StartTag = m_Process->AddObserver(itk::StartEvent(), m_StartFilterCommand);
m_EndTag = m_Process->AddObserver(itk::EndEvent(), m_EndFilterCommand);
m_ProgressTag
= m_Process->AddObserver(itk::ProgressEvent(), m_ProgressFilterCommand);
m_Window = new Fl_Window(x,y,w+10,h+10);
m_Window->label(m_Comment.c_str());
m_Window->begin();
......@@ -63,25 +43,8 @@ FltkFilterWatcher
FltkFilterWatcher
::~FltkFilterWatcher()
{
// Remove any observers we have on the old process object
if (m_Process)
{
if (m_StartFilterCommand)
{
m_Process->RemoveObserver(m_StartTag);
}
if (m_EndFilterCommand)
{
m_Process->RemoveObserver(m_EndTag);
}
if (m_ProgressFilterCommand)
{
m_Process->RemoveObserver(m_ProgressTag);
}
}
delete m_Progress;
delete m_Window;
}
} // end namespace otb
......@@ -21,30 +21,32 @@
#ifndef __otbFltkFilterWatcher_h
#define __otbFltkFilterWatcher_h
#include "itkCommand.h"
#include "itkProcessObject.h"
#include "itkTimeProbe.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Progress.H>
#include "otbFilterWatcherBase.h"
namespace otb
{
/** \class FltkFilterWatcher
* \brief This class implements the progress mechanim
* on pipeline filtering execution
*
*/
class ITK_EXPORT FltkFilterWatcher
class ITK_EXPORT FltkFilterWatcher : public otb::FilterWatcherBase
{
public:
/** Classes that need access to filter's private data */
friend class XMLFilterWatcher;
// friend class XMLFilterWatcher;
/** Constructor. Takes a ProcessObject to monitor and an optional
* comment string that is prepended to each event message. */
FltkFilterWatcher(itk::ProcessObject* o, int x, int y, int w,int h,const char *comment="");
FltkFilterWatcher(itk::ProcessObject* process,
int x, int y, int w,int h,
const char *comment="");
/** Destructor. */
virtual ~FltkFilterWatcher();
......@@ -74,19 +76,7 @@ protected:
}
private:
itk::TimeProbe m_TimeProbe;
std::string m_Comment;
itk::ProcessObject::Pointer m_Process;
typedef itk::SimpleMemberCommand<FltkFilterWatcher> CommandType;
CommandType::Pointer m_StartFilterCommand;
CommandType::Pointer m_EndFilterCommand;
CommandType::Pointer m_ProgressFilterCommand;
unsigned long m_StartTag;
unsigned long m_EndTag;
unsigned long m_ProgressTag;
Fl_Window * m_Window;
Fl_Progress * m_Progress;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment