diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h index 94a5429f0563ef3a3cc2233ca0267d966131fa90..6b4bf70c7d66869098aa17dc42aa2a7f12fc5d4f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h @@ -71,7 +71,9 @@ public: /** Get one specific stored image filename. */ std::string GetNthFileName( unsigned int i ) const; - /** Get one list of the stored image. */ + /** Get one list of the stored image. WARNING : if the parameter list changes, + * the returned image list may become obsolete. You should call + * GetImageList() again to make sure your image list is up-to-date. */ FloatVectorImageListType* GetImageList() const; /** Get one specific stored image. */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx index 45abefaeaf739497ee48c07f693a2b0cff45856d..cd41fcf1d80f0ffd3edcfeb1980ee6195a8654dc 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx @@ -56,7 +56,6 @@ InputImageListParameter::SetListFromFileName(const std::vector<std::string> & fi tmpInputImageParameter->SetFromFileName(filename); m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); } } @@ -70,7 +69,6 @@ void InputImageListParameter::AddNullElement() { m_InputImageParameterVector.push_back(ITK_NULLPTR); - m_ImageList->PushBack(ITK_NULLPTR); SetActive(false); this->Modified(); } @@ -85,7 +83,6 @@ InputImageListParameter::AddFromFileName(const std::string & filename) tmpInputImageParameter->SetFromFileName(filename); m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); this->Modified(); SetActive(true); @@ -110,7 +107,6 @@ InputImageListParameter::SetNthFileName( const unsigned int id, const std::strin tmpInputImageParameter->SetFromFileName(filename); m_InputImageParameterVector[id] = tmpInputImageParameter; - m_ImageList->SetNthElement(id,tmpInputImageParameter->GetFloatVectorImage()); this->Modified(); SetActive(true); @@ -150,17 +146,22 @@ InputImageListParameter::GetNthFileName( unsigned int i ) const FloatVectorImageListType* InputImageListParameter::GetImageList() const { + m_ImageList->Clear(); + for (unsigned int i=0 ; i < this->Size() ; ++i) + { + m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage()); + } return m_ImageList; } FloatVectorImageType* InputImageListParameter::GetNthImage(unsigned int i) const { - if(m_ImageList->Size()<i) + if(this->Size()<=i) { - itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available."); + itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); } - return m_ImageList->GetNthElement(i); + return m_InputImageParameterVector[i]->GetFloatVectorImage(); } void @@ -192,9 +193,9 @@ InputImageListParameter::SetImageList(FloatVectorImageListType* imList) void InputImageListParameter::SetNthImage(unsigned int i, ImageBaseType * img) { - if(m_ImageList->Size()<i) + if(this->Size()<i) { - itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available."); + itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); } // Check input availability @@ -206,7 +207,6 @@ void InputImageListParameter::SetNthImage(unsigned int i, ImageBaseType * img) tmpInputImageParameter->SetImage(img); m_InputImageParameterVector[i] = tmpInputImageParameter; - m_ImageList->SetNthElement(i,tmpInputImageParameter->GetFloatVectorImage()); } @@ -221,7 +221,6 @@ InputImageListParameter::AddImage(ImageBaseType* image) tmpInputImageParameter->SetImage(image); m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); this->Modified(); } @@ -229,16 +228,18 @@ InputImageListParameter::AddImage(ImageBaseType* image) bool InputImageListParameter::HasValue() const { - if(m_ImageList->Size() == 0) + if(this->Size() == 0) { return false; } bool res(true); unsigned int i(0); - while(i < m_ImageList->Size() && res == true) + while(i < this->Size() && res == true) { - res = m_ImageList->GetNthElement(i).IsNotNull(); + res = (m_InputImageParameterVector[i] ? + m_InputImageParameterVector[i]->HasValue() : + false); i++; } @@ -249,12 +250,11 @@ InputImageListParameter::HasValue() const void InputImageListParameter::Erase( unsigned int id ) { - if(m_ImageList->Size()<id) + if(this->Size()<id) { - itkExceptionMacro(<< "No image "<<id<<". Only "<<m_ImageList->Size()<<" images available."); + itkExceptionMacro(<< "No image "<<id<<". Only "<<this->Size()<<" images available."); } - m_ImageList->Erase( id ); m_InputImageParameterVector.erase(m_InputImageParameterVector.begin()+id); this->Modified(); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx index 18e3a7aa9c80e6c46737d5c6563ba69c9c73098c..5fb29a0ab94cc3837a18d32ebd912c2a622f9adb 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx @@ -160,16 +160,14 @@ void QtWidgetInputImageListParameter::DoCreateWidget() void QtWidgetInputImageListParameter::UpdateImageList() { - /* Adding a NullElement so to make the m_FileSelectionList and -* m_InputImageList's ImageList are of same size. So that GetImageList().Size() -* seems to be happy. - */ - for(unsigned int i = m_InputImageListParam->GetImageList()->Size(); i < m_FileSelectionList.size(); i++) + // Adding a NullElement so to make the m_FileSelectionList and + // m_InputImageList's ImageList are of same size. + for(unsigned int i = m_InputImageListParam->Size(); i < m_FileSelectionList.size(); i++) { m_InputImageListParam->AddNullElement(); } - for(unsigned int j = 0; j < m_InputImageListParam->GetImageList()->Size(); j++) + for(unsigned int j = 0; j < m_InputImageListParam->Size(); j++) { if(m_InputImageListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false) {