diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx index 199bb65f494267765a17f37ae064175d42e69c44..22f15036691ea9670056270231f84ce03f059966 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx @@ -141,37 +141,27 @@ ParameterGroup::AddChoice(std::string paramKey, std::string paramName) void ParameterGroup::ClearChoices(std::string paramKey) { - ParameterKey pKey( paramKey ); - // Split the parameter name - std::vector<std::string> splitKey = pKey.Split(); - std::string parentkey; - Parameter::Pointer parentParam; + Parameter * param = GetParameterByKey(paramKey); - if (splitKey.size() > 1) - { - parentkey = pKey.GetRoot(); - parentParam = GetParameterByKey(parentkey); - } - else + if(!param) { - parentParam = GetParameterByKey(splitKey[0]); + itkExceptionMacro("Parameter "<<paramKey<<" not found"); } + + // param must be a choice, a listBox or this is an error + ListViewParameter* paramAsChoice = dynamic_cast<ListViewParameter*>(param); - // parentParam must be a choice, a listBox or this is an error - ListViewParameter* listBoxParentAsChoice = dynamic_cast<ListViewParameter*>(parentParam.GetPointer()); - - if (listBoxParentAsChoice) + if (paramAsChoice) { - listBoxParentAsChoice->ClearChoices(); + paramAsChoice->ClearChoices(); } else { - itkExceptionMacro(<<parentkey << " is not a ListView"); + itkExceptionMacro(<<paramKey << " is not a ListView"); } } - void ParameterGroup::AddOutXMLParameter() { Parameter::Pointer tmpParam; @@ -216,34 +206,25 @@ void ParameterGroup::AddInXMLParameter() std::vector<int> ParameterGroup::GetSelectedItems(std::string paramKey) { - std::vector<int> selectedItems; - ParameterKey pKey( paramKey ); - // Split the parameter name - std::vector<std::string> splitKey = pKey.Split(); + Parameter * param = GetParameterByKey(paramKey); - std::string parentkey; - Parameter::Pointer parentParam; - - if (splitKey.size() > 1) + if(!param) { - parentkey = pKey.GetRoot(); - parentParam = GetParameterByKey(parentkey); + itkExceptionMacro("Parameter "<<paramKey<<" not found"); } - else - { - parentParam = GetParameterByKey(splitKey[0]); - } - - // parentParam must be a choice, a listBox or this is an error - ListViewParameter* listBoxParentAsChoice = dynamic_cast<ListViewParameter*>(parentParam.GetPointer()); + + // param must be a choice, a listBox or this is an error + ListViewParameter* paramAsChoice = dynamic_cast<ListViewParameter*>(param); + + std::vector<int> selectedItems; - if (listBoxParentAsChoice) + if (paramAsChoice) { - selectedItems = listBoxParentAsChoice->GetSelectedItems(); + selectedItems = paramAsChoice->GetSelectedItems(); } else { - itkExceptionMacro(<<parentkey << " is not a ListView"); + itkExceptionMacro(<<paramKey << " is not a ListView"); } return selectedItems;