| 118 | } |
| 119 | |
| 120 | QString MaterialProperty::getString() const |
| 121 | { |
| 122 | // This method produces a localized string. For a non-localized string use |
| 123 | // getDictionaryString() |
| 124 | if (isNull()) { |
| 125 | return {}; |
| 126 | } |
| 127 | if (getType() == MaterialValue::Quantity) { |
| 128 | auto quantity = getValue().value<Base::Quantity>(); |
| 129 | return QString::fromStdString(quantity.getUserString()); |
| 130 | } |
| 131 | if (getType() == MaterialValue::Float) { |
| 132 | auto value = getValue(); |
| 133 | if (value.isNull()) { |
| 134 | return {}; |
| 135 | } |
| 136 | return QString(QStringLiteral("%L1")).arg(value.toFloat(), 0, 'g', MaterialValue::PRECISION); |
| 137 | } |
| 138 | return getValue().toString(); |
| 139 | } |
| 140 | |
| 141 | QString MaterialProperty::getYAMLString() const |
| 142 | { |