Base: Quantity: return std::string
This commit is contained in:
committed by
Yorik van Havre
parent
c11b37e312
commit
2ea8a633ac
@@ -115,8 +115,7 @@ std::shared_ptr<Material2DArray> MaterialYamlEntry::read2DArray(const YAML::Node
|
||||
|
||||
auto row = std::make_shared<QList<QVariant>>();
|
||||
for (std::size_t j = 0; j < yamlRow.size(); j++) {
|
||||
Base::Quantity qq =
|
||||
Base::Quantity::parse(QString::fromStdString(yamlRow[j].as<std::string>()));
|
||||
Base::Quantity qq = Base::Quantity::parse(yamlRow[j].as<std::string>());
|
||||
qq.setFormat(MaterialValue::getQuantityFormat());
|
||||
row->push_back(QVariant::fromValue(qq));
|
||||
}
|
||||
@@ -142,10 +141,8 @@ std::shared_ptr<Material3DArray> MaterialYamlEntry::read3DArray(const YAML::Node
|
||||
for (std::size_t depth = 0; depth < yamlArray.size(); depth++) {
|
||||
auto yamlDepth = yamlArray[depth];
|
||||
for (auto it = yamlDepth.begin(); it != yamlDepth.end(); it++) {
|
||||
auto depthValue =
|
||||
Base::Quantity::parse(QString::fromStdString(it->first.as<std::string>()));
|
||||
auto depthValue = Base::Quantity::parse(it->first.as<std::string>());
|
||||
depthValue.setFormat(MaterialValue::getQuantityFormat());
|
||||
|
||||
array3d->addDepth(depth, depthValue);
|
||||
|
||||
auto yamlTable = it->second;
|
||||
@@ -154,8 +151,7 @@ std::shared_ptr<Material3DArray> MaterialYamlEntry::read3DArray(const YAML::Node
|
||||
|
||||
auto row = std::make_shared<QList<Base::Quantity>>();
|
||||
for (std::size_t j = 0; j < yamlRow.size(); j++) {
|
||||
auto qq = Base::Quantity::parse(
|
||||
QString::fromStdString(yamlRow[j].as<std::string>()));
|
||||
auto qq = Base::Quantity::parse(yamlRow[j].as<std::string>());
|
||||
qq.setFormat(MaterialValue::getQuantityFormat());
|
||||
row->push_back(qq);
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ QString MaterialValue::getYAMLString() const
|
||||
}
|
||||
if (getType() == MaterialValue::Quantity) {
|
||||
auto quantity = getValue().value<Base::Quantity>();
|
||||
yaml += quantity.getUserString();
|
||||
yaml += QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
else if (getType() == MaterialValue::Float) {
|
||||
auto value = getValue();
|
||||
@@ -500,7 +500,7 @@ QString Material2DArray::getYAMLString() const
|
||||
}
|
||||
yaml += QString::fromStdString("\"");
|
||||
auto quantity = column.value<Base::Quantity>();
|
||||
yaml += quantity.getUserString();
|
||||
yaml += QString::fromStdString(quantity.getUserString());
|
||||
yaml += QString::fromStdString("\"");
|
||||
}
|
||||
|
||||
@@ -814,7 +814,7 @@ QString Material3DArray::getYAMLString() const
|
||||
}
|
||||
|
||||
yaml += QString::fromStdString("\"");
|
||||
auto value = getDepthValue(depth).getUserString();
|
||||
auto value = QString::fromStdString(getDepthValue(depth).getUserString());
|
||||
yaml += value;
|
||||
yaml += QString::fromStdString("\": [");
|
||||
|
||||
@@ -844,7 +844,7 @@ QString Material3DArray::getYAMLString() const
|
||||
}
|
||||
yaml += QString::fromStdString("\"");
|
||||
// Base::Quantity quantity = column.value<Base::Quantity>();
|
||||
yaml += column.getUserString();
|
||||
yaml += QString::fromStdString(column.getUserString());
|
||||
yaml += QString::fromStdString("\"");
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ QString MaterialProperty::getString() const
|
||||
}
|
||||
if (getType() == MaterialValue::Quantity) {
|
||||
auto quantity = getValue().value<Base::Quantity>();
|
||||
return quantity.getUserString();
|
||||
return QString::fromStdString(quantity.getUserString());
|
||||
}
|
||||
if (getType() == MaterialValue::Float) {
|
||||
auto value = getValue();
|
||||
@@ -266,7 +266,7 @@ QVariant MaterialProperty::getColumnNull(int column) const
|
||||
|
||||
switch (valueType) {
|
||||
case MaterialValue::Quantity: {
|
||||
Base::Quantity quant = Base::Quantity(0, getColumnUnits(column));
|
||||
Base::Quantity quant = Base::Quantity(0, getColumnUnits(column).toStdString());
|
||||
return QVariant::fromValue(quant);
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ void MaterialProperty::setValue(const QString& value)
|
||||
}
|
||||
else if (_valuePtr->getType() == MaterialValue::Quantity) {
|
||||
try {
|
||||
setQuantity(Base::Quantity::parse(value));
|
||||
setQuantity(Base::Quantity::parse(value.toStdString()));
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
Base::Console().Log("MaterialProperty::setValue Error '%s' - '%s'\n",
|
||||
@@ -392,12 +392,12 @@ void MaterialProperty::setQuantity(const Base::Quantity& value)
|
||||
|
||||
void MaterialProperty::setQuantity(double value, const QString& units)
|
||||
{
|
||||
setQuantity(Base::Quantity(value, units));
|
||||
setQuantity(Base::Quantity(value, units.toStdString()));
|
||||
}
|
||||
|
||||
void MaterialProperty::setQuantity(const QString& value)
|
||||
{
|
||||
setQuantity(Base::Quantity::parse(value));
|
||||
setQuantity(Base::Quantity::parse(value.toStdString()));
|
||||
}
|
||||
|
||||
void MaterialProperty::setList(const QList<QVariant>& value)
|
||||
@@ -1038,7 +1038,7 @@ Material::getValueString(const std::map<QString, std::shared_ptr<MaterialPropert
|
||||
if (value.isNull()) {
|
||||
return {};
|
||||
}
|
||||
return value.value<Base::Quantity>().getUserString();
|
||||
return QString::fromStdString(value.value<Base::Quantity>().getUserString());
|
||||
}
|
||||
if (property->getType() == MaterialValue::Float) {
|
||||
auto value = property->getValue();
|
||||
|
||||
Reference in New Issue
Block a user