diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx index 9cdb26cc5f957a0a4cd6580b062591a18c1ad1fe..f7a6252a7ef05844ff8cc4c61fd28b20a3e4143c 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.cxx +++ b/Code/ApplicationEngine/otbWrapperApplication.cxx @@ -1179,10 +1179,44 @@ Application::IsApplicationReady() // - The param is not root and belonging to a Mandatory Group // wich is activated if ( !this->HasValue(*it) && IsMandatory(*it) ) - if( GetParameterByKey(*it)->IsRoot() || GetParameterByKey(*it)->GetRoot()->GetActive() ) + { + if( GetParameterByKey(*it)->IsRoot() ) { + otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Root)"); return false; } + else + { + // check if the parameter is linked to a root parameter with a chain of active parameters + Parameter* currentParam = GetParameterByKey(*it)->GetRoot(); + if (currentParam->IsRoot()) + { + otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level 1)"); + return false; + } + + int level = 1; + + while (!currentParam->IsRoot()) + { + if (!currentParam->GetActive()) + { + // the missing parameter is not on an active branch : we can ignore it + break; + } + currentParam = currentParam->GetRoot(); + + level++; + + if (currentParam->IsRoot()) + { + // the missing parameter is on an active branch : we need it + otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level "<< level<<")"); + return false; + } + } + } + } } } diff --git a/Code/ApplicationEngine/otbWrapperChoiceParameter.cxx b/Code/ApplicationEngine/otbWrapperChoiceParameter.cxx index bc4ebafd3811c8f2269a7606948e71d9df994b8b..66d184a0d63d716747151d9a4af2e87c454c96a6 100644 --- a/Code/ApplicationEngine/otbWrapperChoiceParameter.cxx +++ b/Code/ApplicationEngine/otbWrapperChoiceParameter.cxx @@ -40,8 +40,16 @@ ChoiceParameter::AddChoice( std::string choicekey, std::string choiceName ) choice.m_Name = choiceName; choice.m_AssociatedParameter = ParameterGroup::New(); choice.m_AssociatedParameter->SetName(choiceName); + choice.m_AssociatedParameter->SetRoot(this); + m_ChoiceList.push_back(choice); + // check if the new choice matches the m_CurrentChoice : if so the group should be active. + if (m_CurrentChoice == (m_ChoiceList.size() - 1)) + { + m_ChoiceList[m_CurrentChoice].m_AssociatedParameter->SetActive(true); + } + // Add the associated parameter as a child // in order to not have a gap in the children hierarchy this->AddChild(choice.m_AssociatedParameter.GetPointer()); @@ -123,6 +131,28 @@ ChoiceParameter::SetValue(unsigned int v) { m_CurrentChoice = v; SetActive(true); + // update the active flag in sub parameters + for (unsigned int i=0; i< m_ChoiceList.size();i++) + { + if (m_ChoiceList[i].m_AssociatedParameter) + { + if (i==m_CurrentChoice) + { + if (!m_ChoiceList[i].m_AssociatedParameter->GetActive()) + { + m_ChoiceList[i].m_AssociatedParameter->SetActive(true); + } + } + else + { + if (m_ChoiceList[i].m_AssociatedParameter->GetActive()) + { + m_ChoiceList[i].m_AssociatedParameter->SetActive(false); + } + } + } + } + // Call Modified(); this->Modified(); }