2015-12-17 14:13:19 -05:00
|
|
|
/*
|
|
|
|
|
Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
* Neither the name of the Universite de Sherbrooke nor the
|
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Original version from Find-Object: https://github.com/introlab/find-object
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <rtabmap/core/Parameters.h>
|
|
|
|
|
#include <rtabmap/core/Optimizer.h>
|
|
|
|
|
|
|
|
|
|
#include "ParametersToolBox.h"
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
|
#include <QLineEdit>
|
2015-12-21 17:27:05 -05:00
|
|
|
#include <QStackedWidget>
|
|
|
|
|
#include <QScrollArea>
|
2015-12-17 14:13:19 -05:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QMessageBox>
|
2015-12-21 17:27:05 -05:00
|
|
|
#include <QPushButton>
|
2015-12-17 14:13:19 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <rtabmap/utilite/ULogger.h>
|
|
|
|
|
#include <rtabmap/utilite/UConversion.h>
|
|
|
|
|
#include <opencv2/opencv_modules.hpp>
|
|
|
|
|
|
|
|
|
|
namespace rtabmap {
|
|
|
|
|
|
|
|
|
|
ParametersToolBox::ParametersToolBox(QWidget *parent) :
|
2015-12-21 17:27:05 -05:00
|
|
|
QWidget(parent),
|
|
|
|
|
comboBox_(new QComboBox(this)),
|
|
|
|
|
stackedWidget_(new QStackedWidget(this)),
|
2015-12-17 14:13:19 -05:00
|
|
|
parameters_(Parameters::getDefaultParameters())
|
|
|
|
|
{
|
2015-12-21 17:27:05 -05:00
|
|
|
QVBoxLayout * layout = new QVBoxLayout(this);
|
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(comboBox_);
|
|
|
|
|
layout->addWidget(stackedWidget_, 1);
|
|
|
|
|
QPushButton * resetButton = new QPushButton(this);
|
|
|
|
|
resetButton->setText(tr("Restore Defaults"));
|
|
|
|
|
layout->addWidget(resetButton);
|
|
|
|
|
connect(resetButton, SIGNAL(clicked()), this, SLOT(resetCurrentPage()));
|
2015-12-17 14:13:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParametersToolBox::~ParametersToolBox()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget * ParametersToolBox::getParameterWidget(const QString & key)
|
|
|
|
|
{
|
|
|
|
|
return this->findChild<QWidget*>(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ParametersToolBox::resetPage(int index)
|
|
|
|
|
{
|
|
|
|
|
QStringList paramChanged;
|
2015-12-21 17:27:05 -05:00
|
|
|
const QObjectList & children = stackedWidget_->widget(index)->children().first()->children().first()->children();
|
2015-12-17 14:13:19 -05:00
|
|
|
for(int j=0; j<children.size();++j)
|
|
|
|
|
{
|
|
|
|
|
QString key = children.at(j)->objectName();
|
|
|
|
|
// ignore working memory
|
|
|
|
|
QString group = key.split("/").first();
|
2015-12-21 17:27:05 -05:00
|
|
|
if(!ignoredGroups_.contains(group) && parameters_.find(key.toStdString())!=parameters_.end())
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
2015-12-21 17:27:05 -05:00
|
|
|
UASSERT_MSG(parameters_.find(key.toStdString()) != parameters_.end(), uFormat("key=%s", key.toStdString().c_str()).c_str());
|
2015-12-17 14:13:19 -05:00
|
|
|
std::string value = Parameters::getDefaultParameters().at(key.toStdString());
|
|
|
|
|
parameters_.at(key.toStdString()) = value;
|
|
|
|
|
|
|
|
|
|
if(qobject_cast<QComboBox*>(children.at(j)))
|
|
|
|
|
{
|
|
|
|
|
if(((QComboBox*)children.at(j))->currentIndex() != QString::fromStdString(value).split(':').first().toInt())
|
|
|
|
|
{
|
|
|
|
|
((QComboBox*)children.at(j))->setCurrentIndex(QString::fromStdString(value).split(':').first().toInt());
|
|
|
|
|
paramChanged.append(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(qobject_cast<QSpinBox*>(children.at(j)))
|
|
|
|
|
{
|
|
|
|
|
if(((QSpinBox*)children.at(j))->value() != uStr2Int(value))
|
|
|
|
|
{
|
|
|
|
|
((QSpinBox*)children.at(j))->setValue(uStr2Int(value));
|
|
|
|
|
paramChanged.append(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
|
|
|
|
|
{
|
|
|
|
|
if(((QDoubleSpinBox*)children.at(j))->value() != uStr2Double(value))
|
|
|
|
|
{
|
|
|
|
|
((QDoubleSpinBox*)children.at(j))->setValue(uStr2Double(value));
|
|
|
|
|
paramChanged.append(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(qobject_cast<QCheckBox*>(children.at(j)))
|
|
|
|
|
{
|
|
|
|
|
if(((QCheckBox*)children.at(j))->isChecked() != uStr2Bool(value))
|
|
|
|
|
{
|
|
|
|
|
((QCheckBox*)children.at(j))->setChecked(uStr2Bool(value));
|
|
|
|
|
paramChanged.append(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(qobject_cast<QLineEdit*>(children.at(j)))
|
|
|
|
|
{
|
|
|
|
|
if(((QLineEdit*)children.at(j))->text().compare(QString::fromStdString(value)) != 0)
|
|
|
|
|
{
|
|
|
|
|
((QLineEdit*)children.at(j))->setText(QString::fromStdString(value));
|
|
|
|
|
paramChanged.append(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return paramChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::resetCurrentPage()
|
|
|
|
|
{
|
|
|
|
|
this->blockSignals(true);
|
2015-12-21 17:27:05 -05:00
|
|
|
QStringList paramChanged = this->resetPage(stackedWidget_->currentIndex());
|
2015-12-17 14:13:19 -05:00
|
|
|
this->blockSignals(false);
|
|
|
|
|
Q_EMIT parametersChanged(paramChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::resetAllPages()
|
|
|
|
|
{
|
|
|
|
|
QStringList paramChanged;
|
|
|
|
|
this->blockSignals(true);
|
2015-12-21 17:27:05 -05:00
|
|
|
for(int i=0; i< stackedWidget_->count(); ++i)
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
|
|
|
|
paramChanged.append(this->resetPage(i));
|
|
|
|
|
}
|
|
|
|
|
this->blockSignals(false);
|
|
|
|
|
Q_EMIT parametersChanged(paramChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::updateParametersVisibility()
|
|
|
|
|
{
|
|
|
|
|
//show/hide not used parameters
|
|
|
|
|
/*QComboBox * descriptorBox = this->findChild<QComboBox*>(Parameters::kFeature2D_2Descriptor());
|
|
|
|
|
QComboBox * detectorBox = this->findChild<QComboBox*>(Parameters::kFeature2D_1Detector());
|
|
|
|
|
if(descriptorBox && detectorBox)
|
|
|
|
|
{
|
|
|
|
|
QString group = Parameters::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().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if(objects[i]->objectName().contains(descriptorName) || objects[i]->objectName().contains(detectorName))
|
|
|
|
|
{
|
|
|
|
|
((QWidget*)objects[i])->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
else if(objects[i]->objectName().contains("Fast") && detectorName == QString("ORB"))
|
|
|
|
|
{
|
|
|
|
|
((QWidget*)objects[i])->setVisible(true); // ORB uses some FAST parameters
|
|
|
|
|
}
|
|
|
|
|
else if(!objects[i]->objectName().split('/').at(1).at(0).isDigit())
|
|
|
|
|
{
|
|
|
|
|
((QWidget*)objects[i])->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::setupUi(const QSet<QString> & ignoredGroups)
|
|
|
|
|
{
|
|
|
|
|
ignoredGroups_ = ignoredGroups;
|
|
|
|
|
QWidget * currentItem = 0;
|
|
|
|
|
const ParametersMap & parameters = Parameters::getDefaultParameters();
|
2015-12-21 17:27:05 -05:00
|
|
|
QStringList groups;
|
2015-12-17 14:13:19 -05:00
|
|
|
for(ParametersMap::const_iterator iter=parameters.begin();
|
|
|
|
|
iter!=parameters.end();
|
|
|
|
|
++iter)
|
|
|
|
|
{
|
|
|
|
|
QStringList splitted = QString::fromStdString(iter->first).split('/');
|
|
|
|
|
QString group = splitted.first();
|
|
|
|
|
if(!ignoredGroups_.contains(group))
|
|
|
|
|
{
|
|
|
|
|
QString name = splitted.last();
|
|
|
|
|
if(currentItem == 0 || currentItem->objectName().compare(group) != 0)
|
|
|
|
|
{
|
2015-12-21 17:27:05 -05:00
|
|
|
groups.push_back(group);
|
|
|
|
|
QScrollArea * area = new QScrollArea(this);
|
|
|
|
|
stackedWidget_->addWidget(area);
|
|
|
|
|
currentItem = new QWidget();
|
2015-12-17 14:13:19 -05:00
|
|
|
currentItem->setObjectName(group);
|
|
|
|
|
QVBoxLayout * layout = new QVBoxLayout(currentItem);
|
2015-12-21 17:27:05 -05:00
|
|
|
layout->setSizeConstraint(QLayout::SetMinimumSize);
|
2015-12-17 14:13:19 -05:00
|
|
|
layout->setContentsMargins(0,0,0,0);
|
|
|
|
|
layout->setSpacing(0);
|
2015-12-21 17:27:05 -05:00
|
|
|
area->setWidget(currentItem);
|
2015-12-17 14:13:19 -05:00
|
|
|
|
|
|
|
|
addParameter(layout, iter->first, iter->second);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addParameter((QVBoxLayout*)currentItem->layout(), iter->first, iter->second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-21 17:27:05 -05:00
|
|
|
comboBox_->addItems(groups);
|
|
|
|
|
connect(comboBox_, SIGNAL(currentIndexChanged(int)), stackedWidget_, SLOT(setCurrentIndex(int)));
|
2015-12-17 14:13:19 -05:00
|
|
|
|
|
|
|
|
updateParametersVisibility();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::updateParameter(const std::string & key, const std::string & value)
|
|
|
|
|
{
|
|
|
|
|
QString group = QString::fromStdString(key).split("/").first();
|
|
|
|
|
if(!ignoredGroups_.contains(group))
|
|
|
|
|
{
|
2015-12-21 17:27:05 -05:00
|
|
|
UASSERT_MSG(parameters_.find(key) != parameters_.end(), uFormat("key=\"%s\"", key.c_str()).c_str());
|
|
|
|
|
parameters_.at(key) = value;
|
2015-12-17 14:13:19 -05:00
|
|
|
QWidget * widget = this->findChild<QWidget*>(key.c_str());
|
|
|
|
|
QString type = QString::fromStdString(Parameters::getType(key));
|
|
|
|
|
if(type.compare("string") == 0)
|
|
|
|
|
{
|
|
|
|
|
QString valueQt = QString::fromStdString(value);
|
|
|
|
|
if(valueQt.contains(';'))
|
|
|
|
|
{
|
|
|
|
|
// It's a list, just change the index
|
|
|
|
|
QStringList splitted = valueQt.split(':');
|
|
|
|
|
((QComboBox*)widget)->setCurrentIndex(splitted.first().toInt());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
((QLineEdit*)widget)->setText(valueQt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("int") == 0)
|
|
|
|
|
{
|
|
|
|
|
((QSpinBox*)widget)->setValue(uStr2Int(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("uint") == 0)
|
|
|
|
|
{
|
|
|
|
|
((QSpinBox*)widget)->setValue(uStr2Int(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("double") == 0)
|
|
|
|
|
{
|
|
|
|
|
((QDoubleSpinBox*)widget)->setValue(uStr2Double(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("float") == 0)
|
|
|
|
|
{
|
|
|
|
|
((QDoubleSpinBox*)widget)->setValue(uStr2Float(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
((QCheckBox*)widget)->setChecked(uStr2Bool(value));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(
|
|
|
|
|
QVBoxLayout * layout,
|
|
|
|
|
const std::string & key,
|
|
|
|
|
const std::string & value)
|
|
|
|
|
{
|
|
|
|
|
std::string type = Parameters::getType(key);
|
|
|
|
|
if(type.compare("string") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), QString::fromStdString(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("int") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), uStr2Int(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("uint") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), uStr2Int(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("double") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), uStr2Double(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("float") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), uStr2Double(value));
|
|
|
|
|
}
|
|
|
|
|
else if(type.compare("bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
addParameter(layout, key.c_str(), uStr2Bool(value));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(QVBoxLayout * layout,
|
|
|
|
|
const QString & key,
|
|
|
|
|
const QString & value)
|
|
|
|
|
{
|
|
|
|
|
if(value.contains(';'))
|
|
|
|
|
{
|
|
|
|
|
QComboBox * widget = new QComboBox(this);
|
|
|
|
|
widget->setObjectName(key);
|
|
|
|
|
QStringList splitted = value.split(':');
|
|
|
|
|
widget->addItems(splitted.last().split(';'));
|
|
|
|
|
|
|
|
|
|
widget->setCurrentIndex(splitted.first().toInt());
|
|
|
|
|
connect(widget, SIGNAL(currentIndexChanged(int)), this, SLOT(changeParameter(int)));
|
|
|
|
|
addParameter(layout, key, widget);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QLineEdit * widget = new QLineEdit(value, this);
|
|
|
|
|
widget->setObjectName(key);
|
|
|
|
|
connect(widget, SIGNAL(editingFinished()), this, SLOT(changeParameter()));
|
|
|
|
|
addParameter(layout, key, widget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(QVBoxLayout * layout,
|
|
|
|
|
const QString & key,
|
|
|
|
|
const double & value)
|
|
|
|
|
{
|
|
|
|
|
QDoubleSpinBox * widget = new QDoubleSpinBox(this);
|
|
|
|
|
double def = uStr2Double(Parameters::getDefaultParameters().at(key.toStdString()));
|
|
|
|
|
if(def<0.01)
|
|
|
|
|
{
|
|
|
|
|
widget->setDecimals(4);
|
|
|
|
|
}
|
|
|
|
|
else if(def<0.1)
|
|
|
|
|
{
|
|
|
|
|
widget->setDecimals(3);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 17:27:05 -05:00
|
|
|
if(def>0.0)
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
|
|
|
|
widget->setMaximum(def*1000000.0);
|
|
|
|
|
}
|
|
|
|
|
else if(def==0.0)
|
|
|
|
|
{
|
|
|
|
|
widget->setMaximum(1000000.0);
|
|
|
|
|
}
|
|
|
|
|
else if(def<0.0)
|
|
|
|
|
{
|
|
|
|
|
widget->setMinimum(def*1000000.0);
|
|
|
|
|
widget->setMaximum(0.0);
|
|
|
|
|
}
|
|
|
|
|
widget->setValue(value);
|
|
|
|
|
widget->setObjectName(key);
|
|
|
|
|
connect(widget, SIGNAL(editingFinished()), this, SLOT(changeParameter()));
|
|
|
|
|
addParameter(layout, key, widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(QVBoxLayout * layout,
|
|
|
|
|
const QString & key,
|
|
|
|
|
const int & value)
|
|
|
|
|
{
|
|
|
|
|
QSpinBox * widget = new QSpinBox(this);
|
|
|
|
|
int def = uStr2Int(Parameters::getDefaultParameters().at(key.toStdString()));
|
|
|
|
|
|
|
|
|
|
if(def>0)
|
|
|
|
|
{
|
|
|
|
|
widget->setMaximum(def*1000000);
|
|
|
|
|
}
|
|
|
|
|
else if(def == 0)
|
|
|
|
|
{
|
|
|
|
|
widget->setMaximum(1000000);
|
|
|
|
|
}
|
|
|
|
|
else if(def<0)
|
|
|
|
|
{
|
|
|
|
|
widget->setMinimum(def*1000000);
|
|
|
|
|
widget->setMaximum(0);
|
|
|
|
|
}
|
|
|
|
|
widget->setValue(value);
|
|
|
|
|
widget->setObjectName(key);
|
|
|
|
|
|
|
|
|
|
if(key.compare(Parameters::kVisFeatureType().c_str()) == 0)
|
|
|
|
|
{
|
2016-03-01 14:25:00 -05:00
|
|
|
#ifndef RTABMAP_NONFREE
|
|
|
|
|
if(value <= 1)
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
2016-03-01 14:25:00 -05:00
|
|
|
UWARN("SURF/SIFT not available, setting feature default to FAST/BRIEF.");
|
|
|
|
|
widget->setValue(4);
|
2015-12-17 14:13:19 -05:00
|
|
|
}
|
2016-03-01 14:25:00 -05:00
|
|
|
#endif
|
2015-12-17 14:13:19 -05:00
|
|
|
}
|
|
|
|
|
if(key.compare(Parameters::kOptimizerStrategy().c_str()) == 0)
|
|
|
|
|
{
|
2016-03-01 14:25:00 -05:00
|
|
|
if(value == 0 && !Optimizer::isAvailable(Optimizer::kTypeTORO))
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
2016-03-01 14:25:00 -05:00
|
|
|
if(Optimizer::isAvailable(Optimizer::kTypeGTSAM))
|
|
|
|
|
{
|
|
|
|
|
UWARN("TORO is not available, setting optimization default to GTSAM.");
|
|
|
|
|
widget->setValue(2);
|
|
|
|
|
}
|
|
|
|
|
else if(Optimizer::isAvailable(Optimizer::kTypeG2O))
|
|
|
|
|
{
|
|
|
|
|
UWARN("TORO is not available, setting optimization default to g2o.");
|
|
|
|
|
widget->setValue(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(value == 1 && !Optimizer::isAvailable(Optimizer::kTypeG2O))
|
|
|
|
|
{
|
|
|
|
|
if(Optimizer::isAvailable(Optimizer::kTypeGTSAM))
|
|
|
|
|
{
|
|
|
|
|
UWARN("g2o is not available, setting optimization default to GTSAM.");
|
|
|
|
|
widget->setValue(2);
|
|
|
|
|
}
|
|
|
|
|
else if(Optimizer::isAvailable(Optimizer::kTypeTORO))
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
|
|
|
|
UWARN("g2o is not available, setting optimization default to TORO.");
|
|
|
|
|
widget->setValue(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-01 14:25:00 -05:00
|
|
|
if(value == 2 && !Optimizer::isAvailable(Optimizer::kTypeGTSAM))
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
2016-03-01 14:25:00 -05:00
|
|
|
if(Optimizer::isAvailable(Optimizer::kTypeG2O))
|
|
|
|
|
{
|
|
|
|
|
UWARN("GTSAM is not available, setting optimization default to g2o.");
|
|
|
|
|
widget->setValue(2);
|
|
|
|
|
}
|
|
|
|
|
else if(Optimizer::isAvailable(Optimizer::kTypeTORO))
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
|
|
|
|
UWARN("GTSAM is not available, setting optimization default to TORO.");
|
2016-03-01 14:25:00 -05:00
|
|
|
widget->setValue(1);
|
2015-12-17 14:13:19 -05:00
|
|
|
}
|
|
|
|
|
}
|
2016-03-01 14:25:00 -05:00
|
|
|
if(!Optimizer::isAvailable(Optimizer::kTypeG2O) &&
|
|
|
|
|
!Optimizer::isAvailable(Optimizer::kTypeGTSAM) &&
|
|
|
|
|
!Optimizer::isAvailable(Optimizer::kTypeTORO))
|
2015-12-17 14:13:19 -05:00
|
|
|
{
|
|
|
|
|
widget->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(widget, SIGNAL(editingFinished()), this, SLOT(changeParameter()));
|
|
|
|
|
addParameter(layout, key, widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(QVBoxLayout * layout,
|
|
|
|
|
const QString & key,
|
|
|
|
|
const bool & value)
|
|
|
|
|
{
|
|
|
|
|
QCheckBox * widget = new QCheckBox(this);
|
|
|
|
|
widget->setChecked(value);
|
|
|
|
|
widget->setObjectName(key);
|
|
|
|
|
connect(widget, SIGNAL(stateChanged(int)), this, SLOT(changeParameter(int)));
|
|
|
|
|
addParameter(layout, key, widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::addParameter(QVBoxLayout * layout, const QString & key, QWidget * widget)
|
|
|
|
|
{
|
|
|
|
|
QHBoxLayout * hLayout = new QHBoxLayout();
|
|
|
|
|
layout->insertLayout(layout->count()-1, hLayout);
|
|
|
|
|
QString tmp = key.split('/').last();
|
|
|
|
|
if(tmp.at(0).isDigit())
|
|
|
|
|
{
|
|
|
|
|
tmp.remove(0,1);
|
|
|
|
|
}
|
|
|
|
|
QLabel * label = new QLabel(tmp, this);
|
|
|
|
|
label->setObjectName(key+"/label");
|
|
|
|
|
label->setToolTip(QString("<FONT>%1</FONT>").arg(Parameters::getDescription(key.toStdString()).c_str()));
|
|
|
|
|
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
|
|
hLayout->addWidget(label);
|
|
|
|
|
hLayout->addWidget(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::changeParameter(const QString & value)
|
|
|
|
|
{
|
|
|
|
|
if(sender())
|
|
|
|
|
{
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = value.toStdString();
|
|
|
|
|
QStringList paramChanged;
|
|
|
|
|
paramChanged.append(sender()->objectName());
|
|
|
|
|
Q_EMIT parametersChanged(paramChanged);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void ParametersToolBox::changeParameter()
|
|
|
|
|
{
|
|
|
|
|
if(sender())
|
|
|
|
|
{
|
|
|
|
|
QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
|
|
|
|
QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
|
|
|
|
|
QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
|
if(doubleSpinBox)
|
|
|
|
|
{
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = uNumber2Str(doubleSpinBox->value());
|
|
|
|
|
}
|
|
|
|
|
else if(spinBox)
|
|
|
|
|
{
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = uNumber2Str(spinBox->value());
|
|
|
|
|
}
|
|
|
|
|
else if(lineEdit)
|
|
|
|
|
{
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = lineEdit->text().toStdString();
|
|
|
|
|
}
|
|
|
|
|
QStringList paramChanged;
|
|
|
|
|
paramChanged.append(sender()->objectName());
|
|
|
|
|
Q_EMIT parametersChanged(paramChanged);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParametersToolBox::changeParameter(const int & value)
|
|
|
|
|
{
|
|
|
|
|
if(sender())
|
|
|
|
|
{
|
|
|
|
|
QStringList paramChanged;
|
|
|
|
|
QComboBox * comboBox = qobject_cast<QComboBox*>(sender());
|
|
|
|
|
QCheckBox * checkBox = qobject_cast<QCheckBox*>(sender());
|
|
|
|
|
if(comboBox)
|
|
|
|
|
{
|
|
|
|
|
QStringList items;
|
|
|
|
|
for(int i=0; i<comboBox->count(); ++i)
|
|
|
|
|
{
|
|
|
|
|
items.append(comboBox->itemText(i));
|
|
|
|
|
}
|
|
|
|
|
QString merged = QString::number(value) + QString(":") + items.join(";");
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = merged.toStdString();
|
|
|
|
|
|
|
|
|
|
this->updateParametersVisibility();
|
|
|
|
|
}
|
|
|
|
|
else if(checkBox)
|
|
|
|
|
{
|
|
|
|
|
parameters_.at(sender()->objectName().toStdString()) = uBool2Str(value==Qt::Checked?true:false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
paramChanged.append(sender()->objectName());
|
|
|
|
|
Q_EMIT parametersChanged(paramChanged);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace find_object
|