diff --git a/Code/Wrappers/SWIG/otbApplication.i b/Code/Wrappers/SWIG/otbApplication.i index 415f17bf8d6b15c1ad5bd83a770d4503119c9f92..dde9e6f7e860fbcb3def7bbb381571754f4dd326 100644 --- a/Code/Wrappers/SWIG/otbApplication.i +++ b/Code/Wrappers/SWIG/otbApplication.i @@ -15,22 +15,42 @@ namespace otb namespace Wrapper { -enum DefaultValueMode + enum DefaultValueMode { UNKNOWN, RELATIVE, ABSOLUTE }; - + + typedef enum + { + ParameterType_Empty, + ParameterType_Int, + ParameterType_Float, + ParameterType_String, + ParameterType_Filename, + ParameterType_Directory, + ParameterType_Choice, + ParameterType_InputImage, + ParameterType_InputComplexImage, + ParameterType_InputVectorData, + ParameterType_OutputImage, + ParameterType_OutputVectorData, + ParameterType_Radius, + ParameterType_Group, + } ParameterType; + + typedef enum + { + UserLevel_Basic, + UserLevel_Advanced + } UserLevel; } } -/** \class Parameter - * \brief This class represent a parameter for the wrapper framework - * This class is a high level class representing a parameter for the - * wrapper framework. It should be subclassed to represent different - * kinds of parameters - */ + + +/* class Parameter : public itkObject { public: @@ -84,6 +104,7 @@ private: void operator =(const ParameterGroup&); }; DECLARE_REF_COUNT_CLASS( ParameterGroup ) +*/ class Application: public itkObject { @@ -97,7 +118,22 @@ public: void Init(); void UpdateParameters(); void Execute(); - ParameterGroup* GetParameterList(); + void ExecuteAndWriteOutput(); + +// ParameterGroup* GetParameterList(); +// Parameter* GetParameterByKey(std::string parameter); +// const Parameter* GetParameterByKey(std::string parameter) const; + std::list<std::string> GetParametersKeys(); + + void EnableParameter(std::string paramKey); + void DisableParameter(std::string paramKey); + bool IsParameterEnabled(std::string paramKey) const; + bool IsMandatory(std::string paramKey) const; + bool HasUserValue(std::string paramKey) const; + void ClearValue(std::string paramKey); + bool HasValue(std::string paramKey) const; + otb::Wrapper::UserLevel GetParameterUserLevel(std::string paramKey) const; + otb::Wrapper::ParameterType GetParameterType(std::string paramKey) const; void SetParameterInt(std::string parameter, int value); void SetParameterFloat(std::string parameter, float value); @@ -110,7 +146,13 @@ public: protected: Application(); virtual ~Application(); - + + void AddChoice(std::string paramKey, std::string paramName); + void AddParameter(otb::Wrapper::ParameterType type, std::string paramKey, std::string paramName); + void MandatoryOn(std::string paramKey); + void MandatoryOff(std::string paramKey); + void SetParameterUserLevel(std::string paramKey, otb::Wrapper::UserLevel level); + private: virtual void DoCreateParameters() = 0; virtual void DoUpdateParameters() = 0; @@ -122,18 +164,18 @@ private: DECLARE_REF_COUNT_CLASS( Application ) -class ApplicationRegistry : public itkObject +class Registry : public itkObject { public: static std::list<std::string> GetAvailableApplications(); static Application_Pointer CreateApplication(const std::string& name); protected: - ApplicationRegistry(); - virtual ~ApplicationRegistry(); + Registry(); + virtual ~Registry(); private: - ApplicationRegistry(const Self&); + Registry(const Self&); void operator=(const Self&); }; diff --git a/Code/Wrappers/SWIG/otbWrapperSWIGIncludes.h b/Code/Wrappers/SWIG/otbWrapperSWIGIncludes.h index 7d7331447992e49bb89fcc6c9f2f314b20b971c4..b37a7440e7a3a9f555577b424bb8124a487086c9 100644 --- a/Code/Wrappers/SWIG/otbWrapperSWIGIncludes.h +++ b/Code/Wrappers/SWIG/otbWrapperSWIGIncludes.h @@ -18,22 +18,22 @@ #ifndef __otbWrapperSWIGIncludes_h #define __otbWrapperSWIGIncludes_h -#include "otbWrapperParameter.h" -#include "otbWrapperParameterGroup.h" +//#include "otbWrapperParameter.h" +//#include "otbWrapperParameterGroup.h" #include "otbWrapperApplication.h" #include "otbWrapperApplicationRegistry.h" -typedef otb::Wrapper::Parameter Parameter; -typedef otb::Wrapper::Parameter::Pointer::SmartPointer Parameter_Pointer; +//typedef otb::Wrapper::Parameter Parameter; +//typedef otb::Wrapper::Parameter::Pointer::SmartPointer Parameter_Pointer; -typedef otb::Wrapper::ParameterGroup ParameterGroup; -typedef otb::Wrapper::ParameterGroup::Pointer::SmartPointer ParameterGroup_Pointer; +//typedef otb::Wrapper::ParameterGroup ParameterGroup; +//typedef otb::Wrapper::ParameterGroup::Pointer::SmartPointer ParameterGroup_Pointer; typedef otb::Wrapper::Application Application; typedef otb::Wrapper::Application::Pointer::SmartPointer Application_Pointer; -typedef otb::Wrapper::ApplicationRegistry ApplicationRegistry; -typedef otb::Wrapper::ApplicationRegistry::Pointer::SmartPointer ApplicationRegistry_Pointer; +typedef otb::Wrapper::ApplicationRegistry Registry; +typedef otb::Wrapper::ApplicationRegistry::Pointer::SmartPointer Registry_Pointer; #endif diff --git a/Example/otbSmoothing.cxx b/Example/otbSmoothing.cxx index e100da3a7c8133eac10ea4d92591afc7588d346e..2a5786f54c2b0d269456ae560260b35ad5f6d483 100644 --- a/Example/otbSmoothing.cxx +++ b/Example/otbSmoothing.cxx @@ -64,7 +64,6 @@ private: std::cout << "~Smoothing" << std::endl; } - void DoCreateParameters() { AddParameter(ParameterType_InputImage, "in", "Input Image"); diff --git a/Testing/Python/PythonSmoothingTest.py b/Testing/Python/PythonSmoothingTest.py index 521b7c6a126933b2199bffbe5685636a0467c6fe..8f65613ca3e113b8d3b9945856ee7790996f28a8 100644 --- a/Testing/Python/PythonSmoothingTest.py +++ b/Testing/Python/PythonSmoothingTest.py @@ -2,14 +2,17 @@ # Example on the use of the Smoothing # from sys import argv -import otbApplication +import otbApplication as otb -print otbApplication.ApplicationRegistry.GetAvailableApplications() +print otb.Registry.GetAvailableApplications() + +app = otb.Registry.CreateApplication("Smoothing") +print app.GetParametersKeys() -app = otbApplication.ApplicationRegistry.CreateApplication("Smoothing") app.SetParameterString("in", argv[1]) for type in ['mean', 'gaussian', 'anidif']: + print 'Testing ' + type app.SetParameterString("type", type) app.SetParameterString("out", argv[2] + type + ".tif") app.Execute()