Skip to content
Snippets Groups Projects
Commit 0d7b0fbe authored by Julien Malik's avatar Julien Malik
Browse files

ENH: add choice subparameters management

parent a42f4f7a
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
}
}
}
......@@ -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;
};
}
}
......
......@@ -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);
......
......@@ -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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment