Skip to content
Snippets Groups Projects
Commit d5e5adba authored by Julien Malik's avatar Julien Malik
Browse files

ENH: add SetValue(std::string) for choice

parent 80fd1e19
No related branches found
No related tags found
No related merge requests found
......@@ -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()
{
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment