diff --git a/Code/Core/otbWrapperChoiceParameter.h b/Code/Core/otbWrapperChoiceParameter.h index 66b1fbd0100b061bde2e2c8060cab2c69b9e9a9c..bbb71b17abd29010e31ef9a83b583aff932e1640 100644 --- a/Code/Core/otbWrapperChoiceParameter.h +++ b/Code/Core/otbWrapperChoiceParameter.h @@ -50,7 +50,17 @@ public: /** Add a value to the choice */ void AddChoice( std::string key, Parameter::Pointer param ) { - m_ChoiceMap[key] = param; + m_ChoiceList.push_back(key, param); + } + + Parameter::Pointer GetChoice( int i ) + { + return m_ChoiceList[i]; + } + + unsigned int GetNbChoice( void ) + { + return m_ChoiceList.size(); } /** Set any value */ @@ -83,8 +93,8 @@ private: ChoiceParameter(const ChoiceParameter &); //purposely not implemented void operator =(const ChoiceParameter&); //purposely not implemented - typedef std::map<std::string, Parameter::Pointer> ChoiceMap; - ChoiceMap m_ChoiceMap; + typedef std::vector<std::string, Parameter::Pointer> ChoiceList; + ChoiceList m_ChoiceList; unsigned int m_CurrentChoice; diff --git a/Code/Wrappers/QtWidget/CMakeLists.txt b/Code/Wrappers/QtWidget/CMakeLists.txt index 92c136ea85dfefae6a753ac0720871629a60ca82..26f2e871daf77c468f7b32436fbef1557c70cf33 100644 --- a/Code/Wrappers/QtWidget/CMakeLists.txt +++ b/Code/Wrappers/QtWidget/CMakeLists.txt @@ -2,4 +2,4 @@ FILE(GLOB srcs "*.cxx") ADD_LIBRARY(OTBWrapperQtWidget ${srcs}) -TARGET_LINK_LIBRARIES(OTBWrapperQtWidget OTBCommon OTBIO OTBWrapperCore) +TARGET_LINK_LIBRARIES(OTBWrapperQtWidget OTBCommon OTBIO OTBWrapperCore ${QT_LIBRARIES}) diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a3874527a55ce8c475657ff0f4e81c308802276b --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.cxx @@ -0,0 +1,69 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "otbWrapperQtWidgetChoiceParameterFactory.h" +#include "otbWrapperChoiceParameter.h" + + +namespace otb +{ + +namespace Wrapper +{ + +QtWidgetChoiceParameterFactory::QtWidgetChoiceParameterFactory() +{ +} + +QtWidgetChoiceParameterFactory::~QtWidgetChoiceParameterFactory() +{ +} + +QWidget * QtWidgetChoiceParameterFactory::CreateQtWidget(Parameter * param) +{ + // Try to cast to choice parameter + ChoiceParameter * choiceParam = dynamic_cast<ChoiceParameter *>(param); + + // Check if dynamic cast succeeds + if(!choiceParam) + { + return 0; + } + + // Set up input text edit + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0,0,0,0); + + QComboBox* combobox = new QComboBox; + combobox->setToolTip(choiceParam->GetDescription()); + + + for (unsigned int i = O; i < choiceParam->GetNbChoice(); ++i) + { + combobox->addItem( "test", QVariant("test") ); + } + + hLayout->addWidget(combobox); + QGroupBox *paramHGroup = new QGroupBox; + paramHGroup->setLayout(hLayout); + return paramHGroup; + +} +} +} diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..f3f4ad95eeefc039d43538538a0c88641338386d --- /dev/null +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameterFactory.h @@ -0,0 +1,59 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbWrapperQtWidgetChoiceParameterFactory_h +#define __otbWrapperQtWidgetChoiceParameterFactory_h + +#include "otbWrapperChoiceParameter.h" +#include "otbWrapperQtWidgetParameterFactory.h" + +namespace otb +{ +namespace Wrapper +{ + +class QtWidgetChoiceParameterFactory +: public QtWidgetParameterFactory +{ +public: + /** Standard class typedef */ + typedef QtWidgetChoiceParameterFactory Self; + typedef QtWidgetParameterFactory Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(QtWidgetChoiceParameterFactory,otb::Wrapper::QtWidgetParameterFactory); + + /** Create the appropriate ImageIO depending on the particulars of the file. */ + static QWidget * CreateQtWidget(Parameter * param); + +protected: + QtWidgetChoiceParameterFactory(); + ~QtWidgetChoiceParameterFactory(); + +private: + QtWidgetChoiceParameterFactory(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented +}; +} +} + +#endif