fixed issue 12: In Feature2d panel, only show parameters of the current selected detector/descriptor.

git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@201 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
matlabbe 2014-03-24 22:32:54 +00:00
parent 3eda414d91
commit 2d2e69340a
2 changed files with 80 additions and 0 deletions

View File

@ -109,6 +109,76 @@ void ParametersToolBox::resetAllPages()
emit parametersChanged(paramChanged); emit parametersChanged(paramChanged);
} }
void ParametersToolBox::updateParametersVisibility()
{
//show/hide not used parameters
QComboBox * descriptorBox = this->findChild<QComboBox*>(Settings::kFeature2D_2Descriptor());
QComboBox * detectorBox = this->findChild<QComboBox*>(Settings::kFeature2D_1Detector());
if(descriptorBox && detectorBox)
{
QString group = Settings::kFeature2D_2Descriptor().split('/').first();
QWidget * panel = 0;
for(int i=0; i<this->count(); ++i)
{
if(this->widget(i)->objectName().compare(group) == 0)
{
panel = this->widget(i);
break;
}
}
if(panel)
{
const QObjectList & objects = panel->children();
QString descriptorName = descriptorBox->currentText();
QString detectorName = detectorBox->currentText();
for(int i=0; i<objects.size(); ++i)
{
if(objects[i]->objectName().contains(descriptorName) || objects[i]->objectName().contains(detectorName))
{
((QWidget*)objects[i])->setVisible(true);
}
else if(!objects[i]->objectName().split('/').at(1).at(0).isDigit())
{
((QWidget*)objects[i])->setVisible(false);
}
}
}
}
QComboBox * nnBox = this->findChild<QComboBox*>(Settings::kNearestNeighbor_1Strategy());
if(nnBox)
{
QString group = Settings::kNearestNeighbor_1Strategy().split('/').first();
QWidget * panel = 0;
for(int i=0; i<this->count(); ++i)
{
if(this->widget(i)->objectName().compare(group) == 0)
{
panel = this->widget(i);
break;
}
}
if(panel)
{
const QObjectList & objects = panel->children();
QString nnName = nnBox->currentText();
for(int i=0; i<objects.size(); ++i)
{
if(objects[i]->objectName().contains(nnName))
{
((QWidget*)objects[i])->setVisible(true);
}
else if(!objects[i]->objectName().split('/').at(1).at(0).isDigit())
{
((QWidget*)objects[i])->setVisible(false);
}
}
}
}
}
void ParametersToolBox::setupUi() void ParametersToolBox::setupUi()
{ {
this->removeItem(0); // remove dummy page used in .ui this->removeItem(0); // remove dummy page used in .ui
@ -139,6 +209,8 @@ void ParametersToolBox::setupUi()
addParameter((QVBoxLayout*)currentItem->layout(), iter.key(), iter.value()); addParameter((QVBoxLayout*)currentItem->layout(), iter.key(), iter.value());
} }
} }
updateParametersVisibility();
} }
void ParametersToolBox::updateParameter(const QString & key) void ParametersToolBox::updateParameter(const QString & key)
@ -316,6 +388,7 @@ void ParametersToolBox::addParameter(QVBoxLayout * layout, const QString & key,
tmp.remove(0,1); tmp.remove(0,1);
} }
QLabel * label = new QLabel(tmp, this); QLabel * label = new QLabel(tmp, this);
label->setObjectName(key+"/label");
label->setToolTip(QString("<FONT>%1</FONT>").arg(Settings::getDescriptions().value(key, ""))); label->setToolTip(QString("<FONT>%1</FONT>").arg(Settings::getDescriptions().value(key, "")));
hLayout->addWidget(label); hLayout->addWidget(label);
hLayout->addWidget(widget); hLayout->addWidget(widget);
@ -355,6 +428,7 @@ void ParametersToolBox::changeParameter()
emit parametersChanged(paramChanged); emit parametersChanged(paramChanged);
} }
} }
void ParametersToolBox::changeParameter(const int & value) void ParametersToolBox::changeParameter(const int & value)
{ {
if(sender()) if(sender())
@ -391,6 +465,7 @@ void ParametersToolBox::changeParameter(const int & value)
nnBox->blockSignals(false); nnBox->blockSignals(false);
if(sender() == nnBox) if(sender() == nnBox)
{ {
this->updateParametersVisibility();
return; return;
} }
nnStrategyChanged = true; nnStrategyChanged = true;
@ -412,6 +487,7 @@ void ParametersToolBox::changeParameter(const int & value)
nnBox->blockSignals(false); nnBox->blockSignals(false);
if(sender() == nnBox) if(sender() == nnBox)
{ {
this->updateParametersVisibility();
return; return;
} }
nnStrategyChanged = true; nnStrategyChanged = true;
@ -442,6 +518,7 @@ void ParametersToolBox::changeParameter(const int & value)
distBox->blockSignals(false); distBox->blockSignals(false);
if(sender() == distBox) if(sender() == distBox)
{ {
this->updateParametersVisibility();
return; return;
} }
paramChanged.append(Settings::kNearestNeighbor_2Distance_type()); paramChanged.append(Settings::kNearestNeighbor_2Distance_type());
@ -455,6 +532,8 @@ void ParametersToolBox::changeParameter(const int & value)
} }
QString merged = QString::number(value) + QString(":") + items.join(";"); QString merged = QString::number(value) + QString(":") + items.join(";");
Settings::setParameter(sender()->objectName(), merged); Settings::setParameter(sender()->objectName(), merged);
this->updateParametersVisibility();
} }
else if(checkBox) else if(checkBox)
{ {

View File

@ -42,6 +42,7 @@ private slots:
private: private:
QStringList resetPage(int index); QStringList resetPage(int index);
void updateParametersVisibility();
}; };
#endif /* PARAMETERSTOOLBOX_H_ */ #endif /* PARAMETERSTOOLBOX_H_ */