Esempio n. 1
0
QStringList ParametersToolBox::resetPage(int index)
{
	QStringList paramChanged;
	const QObjectList & children = stackedWidget_->widget(index)->children().first()->children().first()->children();
	for(int j=0; j<children.size();++j)
	{
		QString key = children.at(j)->objectName();
		// ignore working memory
		QString group = key.split("/").first();
		if(parameters_.find(key.toStdString())!=parameters_.end())
		{
			UASSERT_MSG(parameters_.find(key.toStdString()) != parameters_.end(), uFormat("key=%s", key.toStdString().c_str()).c_str());
			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;
}
Esempio n. 2
0
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));
	}
}
Esempio n. 3
0
void ParametersToolBox::updateParameter(const std::string & key, const std::string & value)
{
	QString group = QString::fromStdString(key).split("/").first();
	if(!ignoredGroups_.contains(group))
	{
		if(parameters_.find(key) == parameters_.end())
		{
			UWARN("key=\"%s\" doesn't exist", key.c_str());
		}
		else
		{
			parameters_.at(key) = value;
			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));
			}
		}
	}
}
Esempio n. 4
0
void BayesFilter::parseParameters(const ParametersMap & parameters)
{
	ParametersMap::const_iterator iter;
	if((iter=parameters.find(Parameters::kBayesVirtualPlacePriorThr())) != parameters.end())
	{
		this->setVirtualPlacePrior(std::atof((*iter).second.c_str()));
	}
	if((iter=parameters.find(Parameters::kBayesPredictionLC())) != parameters.end())
	{
		this->setPredictionLC((*iter).second);
	}
	if((iter=parameters.find(Parameters::kBayesFullPredictionUpdate())) != parameters.end())
	{
		_fullPredictionUpdate = uStr2Bool((*iter).second.c_str());
	}

}