Commit 25027100 authored by Julien Michel's avatar Julien Michel

ENH: Adding antoher constructor to specify a different source to watch

parent 4fc9a572
......@@ -31,6 +31,14 @@ StandardWriterWatcher
m_StarsCount = 50;
}
StandardWriterWatcher
::StandardWriterWatcher(itk::ProcessObject* process,itk::ProcessObject * source,
const char *comment)
: WriterWatcherBase(process,source,comment)
{
m_StarsCount = 50;
}
StandardWriterWatcher
::StandardWriterWatcher( const StandardWriterWatcher& watch)
{
......
......@@ -54,6 +54,8 @@ namespace otb
* comment string that is prepended to each event message. */
StandardWriterWatcher(itk::ProcessObject* process,
const char *comment="");
StandardWriterWatcher(itk::ProcessObject* process,itk::ProcessObject * source,
const char *comment="");
/** Copy constructor */
StandardWriterWatcher(const StandardWriterWatcher&);
......
......@@ -88,6 +88,61 @@ WriterWatcherBase
}
}
WriterWatcherBase
::WriterWatcherBase(itk::ProcessObject* process, itk::ProcessObject * source,
const char *comment)
{
// Initialize state
m_Process = process;
m_Comment = comment;
// Create a series of commands
m_StartWriterCommand = CommandType::New();
m_EndWriterCommand = CommandType::New();
m_ProgressWriterCommand = CommandType::New();
m_StartFilterCommand = CommandType::New();
m_EndFilterCommand = CommandType::New();
m_ProgressFilterCommand = CommandType::New();
// Assign the callbacks
m_StartFilterCommand->SetCallbackFunction(this,
&WriterWatcherBase::StartFilter);
m_EndFilterCommand->SetCallbackFunction(this,
&WriterWatcherBase::EndFilter);
m_ProgressFilterCommand->SetCallbackFunction(this,
&WriterWatcherBase::ShowFilterProgress);
m_StartWriterCommand->SetCallbackFunction(this,
&WriterWatcherBase::StartWriter);
m_EndWriterCommand->SetCallbackFunction(this,
&WriterWatcherBase::EndWriter);
m_ProgressWriterCommand->SetCallbackFunction(this,
&WriterWatcherBase::ShowWriterProgress);
// Add the commands as observers
m_StartWriterTag = m_Process->AddObserver(itk::StartEvent(),
m_StartWriterCommand);
m_EndWriterTag = m_Process->AddObserver(itk::EndEvent(),
m_EndWriterCommand);
m_ProgressWriterTag = m_Process->AddObserver(itk::ProgressEvent(),
m_ProgressWriterCommand);
m_SourceProcess = source;
m_SourceProcess = m_Process->GetInputs()[0]->GetSource();
// Add the commands as observers
m_StartFilterTag = m_SourceProcess->AddObserver(itk::StartEvent(),
m_StartFilterCommand);
m_EndFilterTag = m_SourceProcess->AddObserver(itk::EndEvent(),
m_EndFilterCommand);
m_ProgressFilterTag = m_SourceProcess->AddObserver(itk::ProgressEvent(),
m_ProgressFilterCommand);
}
WriterWatcherBase
::WriterWatcherBase( const WriterWatcherBase& watch)
{
......
......@@ -50,6 +50,10 @@ namespace otb
WriterWatcherBase(itk::ProcessObject* process,
const char *comment="");
/** This other constructor is provided so that the user can set a different processing filter than the one
just before process in the pipeline */
WriterWatcherBase(itk::ProcessObject* process, itk::ProcessObject * source,const char *comment="");
/** Default constructor */
WriterWatcherBase();
......
......@@ -28,11 +28,28 @@ FltkWriterWatcher
int x, int y, int w, int h,
const char *comment)
: WriterWatcherBase(process, comment)
{
this->BuildGUI(x,y,w,h,comment);
}
FltkWriterWatcher
::FltkWriterWatcher(itk::ProcessObject* process,
itk::ProcessObject* source,
int x, int y, int w, int h,
const char *comment)
: WriterWatcherBase(process,source,comment)
{
this->BuildGUI(x,y,w,h,comment);
}
void FltkWriterWatcher
::BuildGUI(int x, int y, int w, int h,const char * comment)
{
m_Window = new Fl_Window(x,y,w+10,h+15);
m_Window->label(m_Comment.c_str());
m_Window->begin();
m_FilterProgress = new Fl_Progress(5,5,w,h/2);
m_FilterProgress->selection_color(FL_DARK_BLUE);
m_FilterProgress->minimum(0);
......@@ -47,7 +64,6 @@ FltkWriterWatcher
m_WriterProgress->label("writing");
m_WriterProgress->align(FL_ALIGN_INSIDE);
m_Window->end();
}
FltkWriterWatcher
......
......@@ -47,6 +47,12 @@ public:
int x, int y, int w,int h,
const char *comment="");
FltkWriterWatcher(itk::ProcessObject* process,
itk::ProcessObject * source,
int x, int y, int w,int h,
const char *comment="");
/** Destructor. */
virtual ~FltkWriterWatcher();
......@@ -98,6 +104,7 @@ protected:
m_WriterProgress->show();
}
void BuildGUI(int x, int y, int w, int h,const char * comment);
private:
......
Markdown is supported
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