MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getDictionaryString

Method getDictionaryString

src/Mod/Material/App/Materials.cpp:172–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170
171
172QString MaterialProperty::getDictionaryString() const
173{
174 // This method produces a non-localized string. For a localized string use
175 // getString()
176 if (isNull()) {
177 return {};
178 }
179 if (getType() == MaterialValue::Quantity) {
180 auto quantity = getValue().value<Base::Quantity>();
181 auto string = QString(QStringLiteral("%1 %2"))
182 .arg(quantity.getValue(), 0, 'g', MaterialValue::PRECISION)
183 .arg(QString::fromStdString(quantity.getUnit().getString()));
184 return string;
185 }
186 if (getType() == MaterialValue::Float) {
187 auto value = getValue();
188 if (value.isNull()) {
189 return {};
190 }
191 return QString(QStringLiteral("%1")).arg(value.toFloat(), 0, 'g', MaterialValue::PRECISION);
192 }
193 return getValue().toString();
194}
195
196void MaterialProperty::setPropertyType(const QString& type)
197{

Callers 3

getPropertiesMethod · 0.80
getPhysicalPropertiesMethod · 0.80

Calls 9

isNullFunction · 0.70
getTypeFunction · 0.70
getValueFunction · 0.70
QStringClass · 0.70
getValueMethod · 0.45
getStringMethod · 0.45
getUnitMethod · 0.45
isNullMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected