App: fix some property's setPathValue()

This commit is contained in:
Zheng, Lei
2020-04-27 11:55:35 +08:00
committed by wmayer
parent 66c3ba206b
commit 8030d56397

View File

@@ -152,12 +152,14 @@ void PropertyInteger::setPathValue(const ObjectIdentifier &path, const boost::an
if (value.type() == typeid(long))
setValue(boost::any_cast<long>(value));
else if (value.type() == typeid(double))
setValue(boost::math::round(boost::any_cast<double>(value)));
else if (value.type() == typeid(Quantity))
setValue(boost::math::round(boost::any_cast<Quantity>(value).getValue()));
else if (value.type() == typeid(int))
setValue(boost::any_cast<int>(value));
else if (value.type() == typeid(double))
setValue(boost::math::round(boost::any_cast<double>(value)));
else if (value.type() == typeid(float))
setValue(boost::math::round(boost::any_cast<float>(value)));
else if (value.type() == typeid(Quantity))
setValue(boost::math::round(boost::any_cast<Quantity>(value).getValue()));
else
throw bad_cast();
}
@@ -1026,8 +1028,14 @@ void PropertyFloat::setPathValue(const ObjectIdentifier &path, const boost::any
{
verifyPath(path);
if (value.type() == typeid(double))
if (value.type() == typeid(long))
setValue(boost::any_cast<long>(value));
else if (value.type() == typeid(int))
setValue(boost::any_cast<int>(value));
else if (value.type() == typeid(double))
setValue(boost::any_cast<double>(value));
else if (value.type() == typeid(float))
setValue(boost::any_cast<float>(value));
else if (value.type() == typeid(Quantity))
setValue((boost::any_cast<Quantity>(value)).getValue());
else if (value.type() == typeid(long))
@@ -1554,8 +1562,12 @@ void PropertyString::setPathValue(const ObjectIdentifier &path, const boost::any
setValue(boost::any_cast<bool>(value)?"True":"False");
else if (value.type() == typeid(int))
setValue(std::to_string(boost::any_cast<int>(value)));
else if (value.type() == typeid(long))
setValue(std::to_string(boost::any_cast<long>(value)));
else if (value.type() == typeid(double))
setValue(std::to_string(boost::math::round(App::any_cast<double>(value))));
setValue(std::to_string(App::any_cast<double>(value)));
else if (value.type() == typeid(float))
setValue(std::to_string(App::any_cast<float>(value)));
else if (value.type() == typeid(Quantity))
setValue(boost::any_cast<Quantity>(value).getUserString().toUtf8().constData());
else if (value.type() == typeid(std::string))