From 86730b474b4e16c26f41b0edcbe9f4143ecfb1fb Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Tue, 11 Oct 2011 07:47:15 +0200 Subject: [PATCH] ENH: support progress reporting from Python --- Code/ApplicationEngine/otbWrapperApplication.cxx | 14 ++++++++++++++ Code/ApplicationEngine/otbWrapperApplication.h | 11 ++++++++++- Code/Wrappers/SWIG/itkBase.i | 1 + Code/Wrappers/SWIG/otbApplication.i | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx index b2c52b1e5f..807e01de5c 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.cxx +++ b/Code/ApplicationEngine/otbWrapperApplication.cxx @@ -762,11 +762,25 @@ Application::IsApplicationReady() void Application::AddProcess(itk::ProcessObject* object, std::string description) { + m_ProgressSource = object; + m_ProgressSourceDescription = description; + AddProcessToWatchEvent event; event.SetProcess(object); event.SetProcessDescription(description); this->InvokeEvent(event); } +itk::ProcessObject* Application::GetProgressSource() const +{ + return m_ProgressSource; +} + +std::string Application::GetProgressDescription() const +{ + return m_ProgressSourceDescription; +} + + } } diff --git a/Code/ApplicationEngine/otbWrapperApplication.h b/Code/ApplicationEngine/otbWrapperApplication.h index 21d942f355..d83260be3f 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.h +++ b/Code/ApplicationEngine/otbWrapperApplication.h @@ -337,7 +337,10 @@ public: itk::Logger* GetLogger(); - void AddProcess(itk::ProcessObject* object, std::string description); + itk::ProcessObject* GetProgressSource() const; + + std::string GetProgressDescription() const; + protected: /** Constructor */ @@ -346,6 +349,9 @@ protected: /** Destructor */ virtual ~Application(); + /* Register a ProcessObject as a new progress source */ + void AddProcess(itk::ProcessObject* object, std::string description); + /** Add a new choice value to an existing choice parameter */ void AddChoice(std::string paramKey, std::string paramName); @@ -388,6 +394,9 @@ private: itk::Logger::Pointer m_Logger; + itk::ProcessObject::Pointer m_ProgressSource; + std::string m_ProgressSourceDescription; + }; //end class } // end namespace Wrapper diff --git a/Code/Wrappers/SWIG/itkBase.i b/Code/Wrappers/SWIG/itkBase.i index a56792c52f..0362211e81 100644 --- a/Code/Wrappers/SWIG/itkBase.i +++ b/Code/Wrappers/SWIG/itkBase.i @@ -166,6 +166,7 @@ class itkIndent { public: //static itkProcessObject_Pointer New(); virtual itkLightObject_Pointer CreateAnother() const; + const float& GetProgress(); private: itkProcessObject(itkProcessObject const & arg0); void operator=(itkProcessObject const & arg0); diff --git a/Code/Wrappers/SWIG/otbApplication.i b/Code/Wrappers/SWIG/otbApplication.i index ce4ea5a77c..87493f26d2 100644 --- a/Code/Wrappers/SWIG/otbApplication.i +++ b/Code/Wrappers/SWIG/otbApplication.i @@ -134,6 +134,10 @@ public: std::string GetParameterAsString(std::string paramKey); + itkProcessObject* GetProgressSource() const; + + std::string GetProgressDescription() const; + protected: Application(); //virtual ~Application(); -- GitLab