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)))
105 if(((QSpinBox*)children.at(j))->value() !=
uStr2Int(value))
107 ((QSpinBox*)children.at(j))->setValue(
uStr2Int(value));
108 paramChanged.append(key);
111 else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
113 if(((QDoubleSpinBox*)children.at(j))->value() !=
uStr2Double(value))
115 ((QDoubleSpinBox*)children.at(j))->setValue(
uStr2Double(value));
116 paramChanged.append(key);
119 else if(qobject_cast<QCheckBox*>(children.at(j)))
121 if(((QCheckBox*)children.at(j))->isChecked() !=
uStr2Bool(value))
123 ((QCheckBox*)children.at(j))->setChecked(
uStr2Bool(value));
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);
235 addParameter((QVBoxLayout*)currentItem->layout(), iter->first, iter->second);
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)
268 ((QSpinBox*)widget)->setValue(
uStr2Int(value));
270 else if(type.compare(
"uint") == 0)
272 ((QSpinBox*)widget)->setValue(
uStr2Int(value));
274 else if(type.compare(
"double") == 0)
276 ((QDoubleSpinBox*)widget)->setValue(
uStr2Double(value));
278 else if(type.compare(
"float") == 0)
280 ((QDoubleSpinBox*)widget)->setValue(
uStr2Float(value));
282 else if(type.compare(
"bool") == 0)
284 ((QCheckBox*)widget)->setChecked(
uStr2Bool(value));
290 QVBoxLayout * layout,
291 const std::string & key,
292 const std::string & value)
295 if(type.compare(
"string") == 0)
297 addParameter(layout, key.c_str(), QString::fromStdString(value));
299 else if(type.compare(
"int") == 0)
303 else if(type.compare(
"uint") == 0)
307 else if(type.compare(
"double") == 0)
311 else if(type.compare(
"float") == 0)
315 else if(type.compare(
"bool") == 0)
323 const QString & value)
325 if(value.contains(
';'))
327 QComboBox * widget =
new QComboBox(
this);
328 widget->setObjectName(key);
329 QStringList splitted = value.split(
':');
330 widget->addItems(splitted.last().split(
';'));
332 widget->setCurrentIndex(splitted.first().toInt());
333 connect(widget, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeParameter(
int)));
338 QLineEdit * widget =
new QLineEdit(value,
this);
339 widget->setObjectName(key);
340 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
347 const double & value)
349 QDoubleSpinBox * widget =
new QDoubleSpinBox(
this);
351 int decimalValue = 0;
356 str.replace(
',',
'.');
357 QStringList items = str.split(
'.');
358 if(items.size() == 2)
360 decimals = items.back().length();
361 decimalValue = items.back().toInt();
366 if(def<0.001 || (decimals >= 4 && decimalValue>0))
368 widget->setDecimals(5);
369 widget->setSingleStep(0.0001);
371 else if(def<0.01 || (decimals >= 3 && decimalValue>0))
373 widget->setDecimals(4);
374 widget->setSingleStep(0.001);
376 else if(def<0.1 || (decimals >= 2 && decimalValue>0))
378 widget->setDecimals(3);
379 widget->setSingleStep(0.01);
381 else if(def<1.0 || (decimals >= 1 && decimalValue>0))
383 widget->setDecimals(2);
384 widget->setSingleStep(0.1);
388 widget->setDecimals(1);
394 widget->setMaximum(def*1000000.0);
398 widget->setMaximum(1000000.0);
402 widget->setMinimum(def*1000000.0);
403 widget->setMaximum(0.0);
407 if(key.compare(Parameters::kGridMinGroundHeight().c_str()) == 0 ||
408 key.compare(Parameters::kGridMaxGroundHeight().c_str()) == 0 ||
409 key.compare(Parameters::kGridMaxObstacleHeight().c_str()) == 0)
411 widget->setMinimum(-1000000.0);
414 widget->setValue(value);
415 widget->setObjectName(key);
416 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
424 QSpinBox * widget =
new QSpinBox(
this);
429 widget->setMaximum(def*1000000);
433 widget->setMaximum(1000000);
437 widget->setMinimum(def*1000000);
438 widget->setMaximum(0);
440 widget->setValue(value);
441 widget->setObjectName(key);
443 if(key.compare(Parameters::kVisFeatureType().c_str()) == 0)
445 #ifndef RTABMAP_NONFREE 448 UWARN(
"SURF/SIFT not available, setting feature default to FAST/BRIEF.");
453 if(key.compare(Parameters::kOptimizerStrategy().c_str()) == 0)
459 UWARN(
"TORO is not available, setting optimization default to GTSAM.");
464 UWARN(
"TORO is not available, setting optimization default to g2o.");
472 UWARN(
"g2o is not available, setting optimization default to GTSAM.");
477 UWARN(
"g2o is not available, setting optimization default to TORO.");
485 UWARN(
"GTSAM is not available, setting optimization default to g2o.");
490 UWARN(
"GTSAM is not available, setting optimization default to TORO.");
498 widget->setEnabled(
false);
502 connect(widget, SIGNAL(editingFinished()),
this, SLOT(
changeParameter()));
510 QCheckBox * widget =
new QCheckBox(
this);
511 widget->setChecked(value);
512 widget->setObjectName(key);
513 connect(widget, SIGNAL(stateChanged(
int)),
this, SLOT(
changeParameter(
int)));
519 QHBoxLayout * hLayout =
new QHBoxLayout();
520 layout->insertLayout(layout->count()-1, hLayout);
521 QString tmp = key.split(
'/').last();
522 QLabel * label =
new QLabel(tmp,
this);
523 label->setObjectName(key+
"/label");
524 label->setToolTip(QString(
"<FONT>%1 [default=%2]</FONT>")
527 label->setTextInteractionFlags(Qt::TextSelectableByMouse);
528 hLayout->addWidget(label);
529 hLayout->addWidget(widget);
536 parameters_.at(sender()->objectName().toStdString()) = value.toStdString();
537 QStringList paramChanged;
538 paramChanged.append(sender()->objectName());
546 QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
547 QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
548 QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
559 parameters_.at(sender()->objectName().toStdString()) = lineEdit->text().toStdString();
561 QStringList paramChanged;
562 paramChanged.append(sender()->objectName());
571 QStringList paramChanged;
572 QComboBox * comboBox = qobject_cast<QComboBox*>(sender());
573 QCheckBox * checkBox = qobject_cast<QCheckBox*>(sender());
577 for(
int i=0; i<comboBox->count(); ++i)
579 items.append(comboBox->itemText(i));
581 QString merged = QString::number(value) + QString(
":") + items.join(
";");
582 parameters_.at(sender()->objectName().toStdString()) = merged.toStdString();
588 parameters_.at(sender()->objectName().toStdString()) =
uBool2Str(value==Qt::Checked?
true:
false);
591 paramChanged.append(sender()->objectName());
int UTILITE_EXP uStr2Int(const std::string &str)
static std::string getDescription(const std::string ¶mKey)
double UTILITE_EXP uStr2Double(const std::string &str)
bool UTILITE_EXP uStr2Bool(const char *str)
float UTILITE_EXP uStr2Float(const std::string &str)
std::map< std::string, std::string > ParametersMap
std::string UTILITE_EXP uBool2Str(bool boolean)
Some conversion functions.
static bool isAvailable(Optimizer::Type type)
Wrappers of STL for convenient functions.
#define UASSERT_MSG(condition, msg_str)
static std::string getType(const std::string ¶mKey)
static const ParametersMap & getDefaultParameters()
ULogger class and convenient macros.
std::string UTILITE_EXP uFormat(const char *fmt,...)
std::string UTILITE_EXP uNumber2Str(unsigned int number)
V uValue(const std::map< K, V > &m, const K &key, const V &defaultValue=V())