[FEM] Temperature constraints overhaul

- fix bug that changing constraint type in dialog lost flux value
- accept and not immediately save any changed value
- make the temperatures a PropertyTemperature to get rid of hacks
- also fix some too long code lines
This commit is contained in:
Uwe
2023-03-27 20:13:42 +02:00
parent 468a54cb6d
commit cc6c98c1d4
18 changed files with 176 additions and 137 deletions

View File

@@ -34,12 +34,16 @@ PROPERTY_SOURCE(Fem::ConstraintInitialTemperature, Fem::Constraint)
ConstraintInitialTemperature::ConstraintInitialTemperature()
{
ADD_PROPERTY(initialTemperature,(300.0));
ADD_PROPERTY(initialTemperature, (300.0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points, (Base::Vector3d()),
"ConstraintInitialTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintInitialTemperature",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals, (Base::Vector3d()),
"ConstraintInitialTemperature",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
@@ -57,6 +61,19 @@ const char* ConstraintInitialTemperature::getViewProviderName() const
return "FemGui::ViewProviderFemConstraintInitialTemperature";
}
void ConstraintInitialTemperature::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop)
{
// property initialTemperature had App::PropertyFloat, was changed to App::PropertyTemperature
if (prop == &initialTemperature && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat initialTemperatureProperty;
// restore the PropertyFloat to be able to set its value
initialTemperatureProperty.Restore(reader);
initialTemperature.setValue(initialTemperatureProperty.getValue());
}
}
void ConstraintInitialTemperature::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially