Commit 369bec75 authored by Julien Michel's avatar Julien Michel

BUG: Twisted logic for nested parameters keys

parent 9b8e76f6
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment