diff --git a/Code/Core/otbWrapperChoiceParameter.cxx b/Code/Core/otbWrapperChoiceParameter.cxx index 3209325f9db7e1797886aa1d1442c285fb3ce450..ad9c269ede34e49f0b3fcd25e97fbf6141205186 100644 --- a/Code/Core/otbWrapperChoiceParameter.cxx +++ b/Code/Core/otbWrapperChoiceParameter.cxx @@ -88,7 +88,6 @@ ChoiceParameter::GetNbChoices( void ) return m_ChoiceList.size(); } -/** Set any value */ void ChoiceParameter::SetValue(unsigned int v) { @@ -98,7 +97,26 @@ ChoiceParameter::SetValue(unsigned int v) this->Modified(); } -/** Return any value */ +void +ChoiceParameter::SetValue(std::string choiceKey) +{ + ChoiceList::iterator it = m_ChoiceList.begin(); + + unsigned int i = 0; + for (it = m_ChoiceList.begin(); it != m_ChoiceList.end(); ++it) + { + if ( it->m_Key == choiceKey ) + { + m_CurrentChoice = i; + this->Modified(); + return; + } + ++i; + } + + itkExceptionMacro(<< "Cannot find " << choiceKey); +} + unsigned int ChoiceParameter::GetValue() { diff --git a/Code/Core/otbWrapperChoiceParameter.h b/Code/Core/otbWrapperChoiceParameter.h index e8ae2b2b9bd2c83827b4b65a98d85ec6730135d1..09daa299109d9a57a0cdcc69b88c42cb222f04c4 100644 --- a/Code/Core/otbWrapperChoiceParameter.h +++ b/Code/Core/otbWrapperChoiceParameter.h @@ -69,9 +69,12 @@ public: /** Get the number of available choice */ unsigned int GetNbChoices( void ); - /** Set any value */ + /** Set choice value */ virtual void SetValue(unsigned int v); + /** Set choice value by its key */ + virtual void SetValue(std::string choiceKey); + /** Return any value */ virtual unsigned int GetValue();