37 #include <QDoubleSpinBox>
39 #include <QStackedWidget>
40 #include <QScrollArea>
44 #include <QVBoxLayout>
45 #include <QMessageBox>
46 #include <QPushButton>
51 #include <opencv2/opencv_modules.hpp>
57 comboBox_(new QComboBox(
this)),
58 stackedWidget_(new QStackedWidget(
this))
60 QVBoxLayout * layout =
new QVBoxLayout(
this);
61 this->setLayout(layout);
65 QPushButton * resetButton =
new QPushButton(
this);
66 resetButton->setText(tr(
"Restore Defaults"));
67 layout->addWidget(resetButton);
77 return this->findChild<QWidget*>(
key);
82 QStringList paramChanged;
83 const QObjectList & children =
stackedWidget_->widget(index)->children().first()->children().first()->children();
84 for(
int j=0;
j<children.size();++
j)
86 QString
key = children.at(
j)->objectName();
88 QString group =
key.split(
"/").first();
95 if(qobject_cast<QComboBox*>(children.at(
j)))
97 if(((QComboBox*)children.at(
j))->currentIndex() != QString::fromStdString(
value).split(
':').first().toInt())
99 ((QComboBox*)children.at(
j))->setCurrentIndex(QString::fromStdString(
value).split(
':').first().toInt());
100 paramChanged.append(
key);
103 else if(qobject_cast<QSpinBox*>(children.at(
j)))
108 paramChanged.append(
key);
111 else if(qobject_cast<QDoubleSpinBox*>(children.at(
j)))
116 paramChanged.append(
key);
119 else if(qobject_cast<QCheckBox*>(children.at(
j)))
124 paramChanged.append(
key);
127 else if(qobject_cast<QLineEdit*>(children.at(
j)))
129 if(((QLineEdit*)children.at(
j))->
text().compare(QString::fromStdString(
value)) != 0)
131 ((QLineEdit*)children.at(
j))->setText(QString::fromStdString(
value));
132 paramChanged.append(
key);
142 this->blockSignals(
true);
144 this->blockSignals(
false);
150 QStringList paramChanged;
151 this->blockSignals(
true);
156 this->blockSignals(
false);
208 QWidget * currentItem = 0;
210 for(ParametersMap::const_iterator
iter=parameters.begin();
211 iter!=parameters.end();
214 QStringList splitted = QString::fromStdString(
iter->first).split(
'/');
215 QString group = splitted.first();
217 QString
name = splitted.last();
218 if(currentItem == 0 || currentItem->objectName().compare(group) != 0)
220 groups.push_back(group);
221 QScrollArea * area =
new QScrollArea(
this);
223 currentItem =
new QWidget();
224 currentItem->setObjectName(group);
225 QVBoxLayout * layout =
new QVBoxLayout(currentItem);
226 layout->setSizeConstraint(QLayout::SetMinimumSize);
227 layout->setContentsMargins(0,0,0,0);
228 layout->setSpacing(0);
229 area->setWidget(currentItem);
246 QString group = QString::fromStdString(
key).split(
"/").first();
250 QWidget * widget = this->findChild<QWidget*>(
key.c_str());
252 if(
type.compare(
"string") == 0)
254 QString valueQt = QString::fromStdString(
value);
255 if(valueQt.contains(
';'))
258 QStringList splitted = valueQt.split(
':');
259 ((QComboBox*)widget)->setCurrentIndex(splitted.first().toInt());
263 ((QLineEdit*)widget)->setText(valueQt);
266 else if(
type.compare(
"int") == 0)
270 else if(
type.compare(
"uint") == 0)
274 else if(
type.compare(
"double") == 0)
278 else if(
type.compare(
"float") == 0)
282 else if(
type.compare(
"bool") == 0)
290 QVBoxLayout * layout,
291 const std::string & key,
292 const std::string & value)
295 if(
type.compare(
"string") == 0)
299 else if(
type.compare(
"int") == 0 ||
300 type.compare(
"uint") == 0 ||
301 type.compare(
"unsigned int") == 0)
305 else if(
type.compare(
"double") == 0 ||
306 type.compare(
"float") == 0)
310 else if(
type.compare(
"bool") == 0)
316 UWARN(
"Not implemented type \"%s\" for parameter \"%s\". Parameter is not added to toolbox.",
type.c_str(),
key.c_str());
322 const QString & value)
324 if(
value.contains(
';'))
326 QComboBox * widget =
new QComboBox(
this);
327 widget->setObjectName(
key);
328 QStringList splitted =
value.split(
':');
329 widget->addItems(splitted.last().split(
';'));
331 widget->setCurrentIndex(splitted.first().toInt());
332 connect(widget, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeParameter(
int)));
337 QLineEdit * widget =
new QLineEdit(
value,
this);
338 widget->setObjectName(
key);
339 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
346 const double & value)
348 QDoubleSpinBox * widget =
new QDoubleSpinBox(
this);
350 int decimalValue = 0;
355 str.replace(
',',
'.');
356 QStringList items =
str.split(
'.');
357 if(items.size() == 2)
359 decimals = items.back().length();
360 decimalValue = items.back().toInt();
365 if(def<0.001 || (decimals >= 4 && decimalValue>0))
367 widget->setDecimals(5);
368 widget->setSingleStep(0.0001);
370 else if(def<0.01 || (decimals >= 3 && decimalValue>0))
372 widget->setDecimals(4);
373 widget->setSingleStep(0.001);
375 else if(def<0.1 || (decimals >= 2 && decimalValue>0))
377 widget->setDecimals(3);
378 widget->setSingleStep(0.01);
380 else if(def<1.0 || (decimals >= 1 && decimalValue>0))
382 widget->setDecimals(2);
383 widget->setSingleStep(0.1);
387 widget->setDecimals(1);
393 widget->setMaximum(def*1000000.0);
397 widget->setMaximum(1000000.0);
401 widget->setMinimum(def*1000000.0);
402 widget->setMaximum(0.0);
406 if(
key.compare(Parameters::kGridMinGroundHeight().c_str()) == 0 ||
407 key.compare(Parameters::kGridMaxGroundHeight().c_str()) == 0 ||
408 key.compare(Parameters::kGridMaxObstacleHeight().c_str()) == 0)
410 widget->setMinimum(-1000000.0);
413 widget->setValue(
value);
414 widget->setObjectName(
key);
415 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
423 QSpinBox * widget =
new QSpinBox(
this);
428 widget->setMaximum(def*1000000);
432 widget->setMaximum(1000000);
436 widget->setMinimum(def*1000000);
437 widget->setMaximum(0);
439 widget->setValue(
value);
440 widget->setObjectName(
key);
442 if(
key.compare(Parameters::kVisFeatureType().c_str()) == 0)
444 #ifndef RTABMAP_NONFREE
447 UWARN(
"SURF/SIFT not available, setting feature default to FAST/BRIEF.");
452 if(
key.compare(Parameters::kOptimizerStrategy().c_str()) == 0)
458 UWARN(
"TORO is not available, setting optimization default to GTSAM.");
463 UWARN(
"TORO is not available, setting optimization default to g2o.");
471 UWARN(
"g2o is not available, setting optimization default to GTSAM.");
476 UWARN(
"g2o is not available, setting optimization default to TORO.");
484 UWARN(
"GTSAM is not available, setting optimization default to g2o.");
489 UWARN(
"GTSAM is not available, setting optimization default to TORO.");
497 widget->setEnabled(
false);
501 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
509 QCheckBox * widget =
new QCheckBox(
this);
510 widget->setChecked(
value);
511 widget->setObjectName(
key);
512 connect(widget, SIGNAL(stateChanged(
int)),
this, SLOT(
changeParameter(
int)));
518 QHBoxLayout * hLayout =
new QHBoxLayout();
519 layout->insertLayout(layout->count()-1, hLayout);
520 QString tmp =
key.split(
'/').last();
521 QLabel * label =
new QLabel(tmp,
this);
522 label->setObjectName(
key+
"/label");
523 label->setToolTip(QString(
"<FONT>%1 [default=%2]</FONT>")
526 label->setTextInteractionFlags(Qt::TextSelectableByMouse);
527 hLayout->addWidget(label);
528 hLayout->addWidget(widget);
536 QStringList paramChanged;
537 paramChanged.append(sender()->objectName());
545 QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
546 QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
547 QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
558 parameters_.at(sender()->objectName().toStdString()) = lineEdit->text().toStdString();
560 QStringList paramChanged;
561 paramChanged.append(sender()->objectName());
570 QStringList paramChanged;
571 QComboBox * comboBox = qobject_cast<QComboBox*>(sender());
572 QCheckBox * checkBox = qobject_cast<QCheckBox*>(sender());
576 for(
int i=0;
i<comboBox->count(); ++
i)
578 items.append(comboBox->itemText(
i));
580 QString merged = QString::number(
value) + QString(
":") + items.join(
";");
581 parameters_.at(sender()->objectName().toStdString()) = merged.toStdString();
590 paramChanged.append(sender()->objectName());