diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 4748ab0c5ddc71a9a1ffff72b8ba89585d86bc8d..421ef9a4a71e239ba313477d0d9b9fa25fdff714 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -307,7 +307,7 @@ public: */ bool IsParameterMissing(const std::string &key) const; - /* Set an default integer value, must used in the + /* Set a default integer value, must be used in the * DoInit when setting a value by default * for the parameter * @@ -319,7 +319,17 @@ public: */ void SetDefaultParameterInt(std::string parameter, int value); - /* Set a default floating value, must used in the + /* Get the default integer value of a parameter + * + * Can be called for types : + * \li ParameterType_Int + * \li ParameterType_Float + * \li ParameterType_Radius + * \li ParameterType_Choice + */ + int GetDefaultParameterInt(std::string parameter); + + /* Set a default floating value, must be used in the * DoInit when setting a value by default * for the parameter * @@ -328,6 +338,13 @@ public: */ void SetDefaultParameterFloat(std::string parameter, float value); + /* Get the default floating value of a parameter + * + * Can be called for types : + * \li ParameterType_Float + */ + float GetDefaultParameterFloat(std::string parameter); + /** Set a default pixel type for an output image parameter * * \param[in] parameter Name of the output image parameter diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 7aec4f87620aa6917040ee282d4c5e0110848d53..7dbba9892d065b706987e85af751bacd42cf5137 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1040,6 +1040,37 @@ void Application::SetDefaultParameterInt(std::string parameter, int value) } } +int Application::GetDefaultParameterInt(std::string parameter) +{ + Parameter* param = GetParameterByKey(parameter); + int ret = 0 ; + if (dynamic_cast<RadiusParameter*>(param)) + { + RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); + ret = paramRadius->GetDefaultValue(); + } + else if (dynamic_cast<IntParameter*>(param)) + { + IntParameter* paramInt = dynamic_cast<IntParameter*>(param); + ret = paramInt->GetDefaultValue(); + } + else if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + ret = paramFloat->GetDefaultValue(); + } + else if (dynamic_cast<RAMParameter*>(param)) + { + RAMParameter* paramRAM = dynamic_cast<RAMParameter*>(param); + ret = paramRAM->GetDefaultValue(); + } + else + { + // log + } + return ret; +} + void Application::SetDefaultParameterFloat(std::string parameter, float value) { Parameter* param = GetParameterByKey(parameter); @@ -1052,6 +1083,18 @@ void Application::SetDefaultParameterFloat(std::string parameter, float value) } } +float Application::GetDefaultParameterFloat(std::string parameter) +{ + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + return paramFloat->GetDefaultValue(); + } + return 0; +} + void Application::SetDefaultOutputPixelType(std::string parameter, ImagePixelType type) { Parameter* param = GetParameterByKey(parameter);