diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.cxx index 6d4c96dbb786e1d894b1fb4a8d3c5649855b802a..5550f9ef51264b83e074890e3ac66e14788a64a8 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.cxx +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.cxx @@ -17,6 +17,9 @@ =========================================================================*/ #include "otbWrapperQtWidgetChoiceParameter.h" +#include "otbWrapperQtWidgetParameterLabel.h" +#include "otbWrapperQtWidgetParameterFactory.h" + namespace otb { namespace Wrapper @@ -31,29 +34,52 @@ QtWidgetChoiceParameter::QtWidgetChoiceParameter(ChoiceParameter* param, QtWidge QtWidgetChoiceParameter::~QtWidgetChoiceParameter() { - } void QtWidgetChoiceParameter::CreateWidget() { - // Set up input text edit - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setSpacing(0); - hLayout->setContentsMargins(0,0,0,0); + m_ComboBox = new QComboBox; + m_ComboBox->setToolTip(m_ChoiceParam->GetDescription()); + + m_StackWidget = new QStackedWidget; + + connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) ); + connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), m_StackWidget, SLOT(setCurrentIndex(int)) ); - QComboBox* combobox = new QComboBox; - combobox->setToolTip(m_ChoiceParam->GetDescription()); for (unsigned int i = 0; i < m_ChoiceParam->GetNbChoices(); ++i) { QString key = QString::fromStdString( m_ChoiceParam->GetChoiceKey(i) ); - combobox->addItem( key, QVariant(key) ); + m_ComboBox->addItem( key, QVariant(key) ); + + Parameter::Pointer param = m_ChoiceParam->GetChoiceAssociatedParameter(i); + if (param.IsNotNull()) + { + std::cout << param->GetName() << std::endl; + QWidget* label = new QtWidgetParameterLabel( param ); + QWidget* specificWidget = QtWidgetParameterFactory::CreateQtWidget( param, GetModel() ); + QHBoxLayout* hbox = new QHBoxLayout; + hbox->addWidget(label); + hbox->addWidget(specificWidget); + QGroupBox* group = new QGroupBox; + group->setLayout(hbox); + m_StackWidget->addWidget(group); + } } - connect( combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetValue(int)) ); + m_VLayout = new QVBoxLayout; + m_VLayout->addWidget(m_ComboBox); + m_VLayout->addWidget(m_StackWidget); + + m_VLayoutGroup = new QGroupBox; + m_VLayoutGroup->setLayout(m_VLayout); + m_VLayoutGroup->setFlat(true); - hLayout->addWidget(combobox); - this->setLayout(hLayout); + m_MainHLayout = new QHBoxLayout; + m_MainHLayout->setSpacing(0); + m_MainHLayout->setContentsMargins(0,0,0,0); + m_MainHLayout->addWidget(m_VLayoutGroup); + this->setLayout(m_MainHLayout); } void QtWidgetChoiceParameter::SetValue(int value) @@ -61,6 +87,5 @@ void QtWidgetChoiceParameter::SetValue(int value) m_ChoiceParam->SetValue( value ); } - } } diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.h index d789021fce81e6e0572100a908b1fc1144611b7f..21212ff6e48f8ac77f65084f7345372af5171043 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.h +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetChoiceParameter.h @@ -48,8 +48,15 @@ protected: private: QtWidgetChoiceParameter(const QtWidgetChoiceParameter&); //purposely not implemented void operator=(const QtWidgetChoiceParameter&); //purposely not implemented -}; + QHBoxLayout* m_MainHLayout; + + QComboBox* m_ComboBox; + QStackedWidget* m_StackWidget; + + QVBoxLayout* m_VLayout; + QGroupBox* m_VLayoutGroup; +}; } } diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx index 56f5908b1fcf891c9832cf469b5d6a86e2ac01b6..db7757d53440256e7bbc26377cadfd0562990954 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx @@ -49,8 +49,7 @@ void QtWidgetParameterGroup::CreateWidget() QWidget* label = new QtWidgetParameterLabel( param ); gridLayout->addWidget(label, i, 0); QWidget* specificWidget = QtWidgetParameterFactory::CreateQtWidget( param, GetModel() ); - //if (specificWidget) - gridLayout->addWidget(specificWidget, i, 1); + gridLayout->addWidget(specificWidget, i, 1); } this->setLayout(gridLayout); diff --git a/Example/Smoothing/otbSmoothing.cxx b/Example/Smoothing/otbSmoothing.cxx index 9929677af2352113a192bce77ecabded535912dc..4dd52d447a3edd646b8aacfb36cb8790c8db2bdf 100644 --- a/Example/Smoothing/otbSmoothing.cxx +++ b/Example/Smoothing/otbSmoothing.cxx @@ -49,9 +49,22 @@ void Smoothing::DoCreateParameters() smoothingType->SetName("Smoothing Type"); smoothingType->SetKey("type"); - smoothingType->AddChoice("Mean", 0); - smoothingType->AddChoice("Gaussian", 0); - smoothingType->AddChoice("Anisotropic Diffusion", 0); + otb::Wrapper::RadiusParameter::Pointer meanSmoothingRadius = otb::Wrapper::RadiusParameter::New(); + smoothingType->AddChoice("Mean", meanSmoothingRadius.GetPointer()); + + otb::Wrapper::RadiusParameter::Pointer gaussianSmoothingRadius = otb::Wrapper::RadiusParameter::New(); + smoothingType->AddChoice("Gaussian", gaussianSmoothingRadius.GetPointer()); + + otb::Wrapper::FloatParameter::Pointer aniDifTimeStep = otb::Wrapper::FloatParameter::New(); + aniDifTimeStep->SetName("Time Step"); + aniDifTimeStep->SetKey("TimeStep"); + otb::Wrapper::IntParameter::Pointer aniDifNbIter = otb::Wrapper::IntParameter::New(); + aniDifTimeStep->SetName("Nb Iterations"); + aniDifTimeStep->SetKey("NbIter"); + otb::Wrapper::ParameterGroup::Pointer aniDifGroup = otb::Wrapper::ParameterGroup::New(); + aniDifGroup->AddParameter(aniDifTimeStep.GetPointer()); + aniDifGroup->AddParameter(aniDifNbIter.GetPointer()); + smoothingType->AddChoice("Anisotropic Diffusion", aniDifGroup.GetPointer()); ParameterGroup* params = GetParameterList(); params->AddParameter(inImage.GetPointer());