From 3e5afd296ef8db9ea04e86ec149911bed36855c8 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath@c-s.fr> Date: Thu, 7 May 2015 19:14:52 +0200 Subject: [PATCH] BUG: Do not clear choices if not needed mantis #1025 --- .../AppImageUtils/app/otbExtractROI.cxx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 827e723251..42e2406a51 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -21,6 +21,7 @@ #include "otbMultiChannelExtractROI.h" #include "otbStandardFilterWatcher.h" #include "otbWrapperNumericalParameter.h" +#include "otbWrapperListViewParameter.h" #include "otbWrapperTypes.h" #include "otbWrapperElevationParametersHandler.h" @@ -129,15 +130,20 @@ private: SetParameterInt("sizey", largestRegion.GetSize()[1]); } - // Update the values of the channels to be selected unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel(); - ClearChoices("cl"); - for (unsigned int idx = 0; idx < nbComponents; ++idx) + ListViewParameter *clParam = dynamic_cast<ListViewParameter*>(GetParameterByKey("cl")); + // Update the values of the channels to be selected if nbComponents is changed + if (clParam->GetNbChoices() != nbComponents) { - std::ostringstream key, item; - key<<"cl.channel"<<idx+1; - item<<"Channel"<<idx+1; - AddChoice(key.str(), item.str()); + + ClearChoices("cl"); + for (unsigned int idx = 0; idx < nbComponents; ++idx) + { + std::ostringstream key, item; + key<<"cl.channel"<<idx+1; + item<<"Channel"<<idx+1; + AddChoice(key.str(), item.str()); + } } // Put the limit of the index and the size relative the image -- GitLab