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 ...@@ -31,6 +31,14 @@ StandardWriterWatcher
m_StarsCount = 50; m_StarsCount = 50;
} }
StandardWriterWatcher
::StandardWriterWatcher(itk::ProcessObject* process,itk::ProcessObject * source,
const char *comment)
: WriterWatcherBase(process,source,comment)
{
m_StarsCount = 50;
}
StandardWriterWatcher StandardWriterWatcher
::StandardWriterWatcher( const StandardWriterWatcher& watch) ::StandardWriterWatcher( const StandardWriterWatcher& watch)
{ {
......
...@@ -54,6 +54,8 @@ namespace otb ...@@ -54,6 +54,8 @@ namespace otb
* comment string that is prepended to each event message. */ * comment string that is prepended to each event message. */
StandardWriterWatcher(itk::ProcessObject* process, StandardWriterWatcher(itk::ProcessObject* process,
const char *comment=""); const char *comment="");
StandardWriterWatcher(itk::ProcessObject* process,itk::ProcessObject * source,
const char *comment="");
/** Copy constructor */ /** Copy constructor */
StandardWriterWatcher(const StandardWriterWatcher&); StandardWriterWatcher(const StandardWriterWatcher&);
......
...@@ -88,6 +88,61 @@ WriterWatcherBase ...@@ -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
::WriterWatcherBase( const WriterWatcherBase& watch) ::WriterWatcherBase( const WriterWatcherBase& watch)
{ {
......
...@@ -49,7 +49,11 @@ namespace otb ...@@ -49,7 +49,11 @@ namespace otb
* comment string that is prepended to each event message. */ * comment string that is prepended to each event message. */
WriterWatcherBase(itk::ProcessObject* process, WriterWatcherBase(itk::ProcessObject* process,
const char *comment=""); 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 */ /** Default constructor */
WriterWatcherBase(); WriterWatcherBase();
......
...@@ -29,10 +29,27 @@ FltkWriterWatcher ...@@ -29,10 +29,27 @@ FltkWriterWatcher
const char *comment) const char *comment)
: WriterWatcherBase(process, comment) : WriterWatcherBase(process, comment)
{ {
m_Window = new Fl_Window(x,y,w+10,h+15); 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->label(m_Comment.c_str());
m_Window->begin(); m_Window->begin();
m_FilterProgress = new Fl_Progress(5,5,w,h/2); m_FilterProgress = new Fl_Progress(5,5,w,h/2);
m_FilterProgress->selection_color(FL_DARK_BLUE); m_FilterProgress->selection_color(FL_DARK_BLUE);
m_FilterProgress->minimum(0); m_FilterProgress->minimum(0);
...@@ -47,7 +64,6 @@ FltkWriterWatcher ...@@ -47,7 +64,6 @@ FltkWriterWatcher
m_WriterProgress->label("writing"); m_WriterProgress->label("writing");
m_WriterProgress->align(FL_ALIGN_INSIDE); m_WriterProgress->align(FL_ALIGN_INSIDE);
m_Window->end(); m_Window->end();
} }
FltkWriterWatcher FltkWriterWatcher
......
...@@ -46,6 +46,12 @@ public: ...@@ -46,6 +46,12 @@ public:
FltkWriterWatcher(itk::ProcessObject* process, FltkWriterWatcher(itk::ProcessObject* process,
int x, int y, int w,int h, int x, int y, int w,int h,
const char *comment=""); const char *comment="");
FltkWriterWatcher(itk::ProcessObject* process,
itk::ProcessObject * source,
int x, int y, int w,int h,
const char *comment="");
/** Destructor. */ /** Destructor. */
virtual ~FltkWriterWatcher(); virtual ~FltkWriterWatcher();
...@@ -98,6 +104,7 @@ protected: ...@@ -98,6 +104,7 @@ protected:
m_WriterProgress->show(); m_WriterProgress->show();
} }
void BuildGUI(int x, int y, int w, int h,const char * comment);
private: 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