Material: Add thermal reference temperature (#13026)

* Material: Add thermal reference temperature

Fixes #13019

Adds the property 'Thermal Expansion Reference Temperature' to
the Thermal properties

* Fix delegates
This commit is contained in:
David Carter
2024-04-01 12:00:45 -04:00
committed by GitHub
parent 6b721ac797
commit 8776c5bf98
5 changed files with 30 additions and 13 deletions

View File

@@ -106,8 +106,13 @@ void BaseDelegate::paintQuantity(QPainter* painter,
else {
QVariant item = getValue(index);
auto quantity = item.value<Base::Quantity>();
QString text = quantity.getUserString();
painter->drawText(option.rect, 0, text);
if (quantity.isValid()) {
QString text = quantity.getUserString();
painter->drawText(option.rect, 0, text);
}
else {
painter->drawText(option.rect, 0, QString());
}
}
painter->restore();
@@ -350,8 +355,10 @@ void BaseDelegate::setModelData(QWidget* editor,
}
else if (type == Materials::MaterialValue::Quantity) {
auto input = dynamic_cast<Gui::InputField*>(editor);
value = input->text();
return;
// value = input->text();
// return;
auto quantity = Base::Quantity::parse(input->text());
value = QVariant::fromValue(quantity);
}
else if (type == Materials::MaterialValue::Integer) {
auto spinner = dynamic_cast<Gui::IntSpinBox*>(editor);

View File

@@ -133,8 +133,10 @@ void MaterialDelegate::setValue(QAbstractItemModel* model,
auto material = group->child(row, 1)->data().value<std::shared_ptr<Materials::Material>>();
// auto propertyName = group->child(row, 0)->text();
auto propertyName = group->child(row, 0)->data().toString();
material->getProperty(propertyName)->setValue(value);
group->child(row, 1)->setText(value.toString());
std::string _name = propertyName.toStdString();
auto property = material->getProperty(propertyName);
property->setValue(value);
group->child(row, 1)->setText(property->getString());
}
notifyChanged(model, index);
@@ -267,7 +269,7 @@ void MaterialDelegate::showImageModal(const QString& propertyName, QStandardItem
dlg->adjustSize();
//connect(dlg, &QDialog::finished, this, [&](int result) {});
// connect(dlg, &QDialog::finished, this, [&](int result) {});
dlg->exec();
}
@@ -281,7 +283,7 @@ void MaterialDelegate::showListModal(const QString& propertyName, QStandardItem*
dlg->adjustSize();
//connect(dlg, &QDialog::finished, this, [&](int result) {});
// connect(dlg, &QDialog::finished, this, [&](int result) {});
dlg->exec();
}
@@ -295,7 +297,7 @@ void MaterialDelegate::showMultiLineStringModal(const QString& propertyName, QSt
dlg->adjustSize();
//connect(dlg, &QDialog::finished, this, [&](int result) {});
// connect(dlg, &QDialog::finished, this, [&](int result) {});
dlg->exec();
}
@@ -310,7 +312,7 @@ void MaterialDelegate::showArray2DModal(const QString& propertyName, QStandardIt
dlg->adjustSize();
//connect(dlg, &QDialog::finished, this, [&](int result) {});
// connect(dlg, &QDialog::finished, this, [&](int result) {});
dlg->exec();
}
@@ -324,7 +326,7 @@ void MaterialDelegate::showArray3DModal(const QString& propertyName, QStandardIt
dlg->adjustSize();
//connect(dlg, &QDialog::finished, this, [&](int result) {});
// connect(dlg, &QDialog::finished, this, [&](int result) {});
dlg->exec();
}

View File

@@ -48,3 +48,11 @@ Model:
Description: >
Thermal expansion coefficient (linear) in [FreeCAD
ThermalExpansionCoefficient unit]
ThermalExpansionReferenceTemperature:
DisplayName: "Thermal Expansion Reference Temperature"
Type: 'Quantity'
Units: 'K'
URL: ''
Description: >
The reference temperature is the temperature at which zero thermal
strains exist for the analysis.

View File

@@ -67,7 +67,7 @@ class MaterialTestCases(unittest.TestCase):
self.assertTrue(steel.isPhysicalModelComplete(self.uuids.Density))
self.assertFalse(steel.isPhysicalModelComplete(self.uuids.IsotropicLinearElastic))
self.assertTrue(steel.isPhysicalModelComplete(self.uuids.Thermal))
self.assertFalse(steel.isPhysicalModelComplete(self.uuids.Thermal))
self.assertFalse(steel.isPhysicalModelComplete(self.uuids.LinearElastic))
self.assertTrue(steel.isAppearanceModelComplete(self.uuids.BasicRendering))

View File

@@ -239,7 +239,7 @@ TEST_F(TestMaterial, TestCalculiXSteel)
EXPECT_TRUE(steel->isPhysicalModelComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_Density)); // Density
EXPECT_FALSE(steel->isPhysicalModelComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_IsotropicLinearElastic)); // IsotropicLinearElastic - incomplete
EXPECT_TRUE(steel->isPhysicalModelComplete(Materials::ModelUUIDs::ModelUUID_Thermal_Default)); // Thermal
EXPECT_FALSE(steel->isPhysicalModelComplete(Materials::ModelUUIDs::ModelUUID_Thermal_Default)); // Thermal
EXPECT_FALSE(steel->isPhysicalModelComplete(Materials::ModelUUIDs::ModelUUID_Mechanical_LinearElastic)); // Legacy linear elastic - Not in the model
EXPECT_TRUE(steel->isAppearanceModelComplete(Materials::ModelUUIDs::ModelUUID_Rendering_Basic)); // BasicRendering - inherited from Steel.FCMat