Fem: Change ConstraintPressure::Pressure property to App::PropertyPressure

This commit is contained in:
Uwe
2023-10-03 01:38:23 -03:00
committed by marioalexis
parent d8636dd058
commit 6845cb66f8
10 changed files with 72 additions and 56 deletions

View File

@@ -58,6 +58,21 @@ const char* ConstraintPressure::getViewProviderName() const
return "FemGui::ViewProviderFemConstraintPressure";
}
void ConstraintPressure::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop)
{
// property Pressure had App::PropertyFloat and was changed to App::PropertyPressure
if (prop == &Pressure && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat PressureProperty;
// restore the PropertyFloat to be able to set its value
PressureProperty.Restore(reader);
// the old implementation or pressure stored the value as MPa
// therefore we must convert the value with a factor 1000
Pressure.setValue(PressureProperty.getValue() * 1000.0);
}
}
void ConstraintPressure::onChanged(const App::Property* prop)
{
Constraint::onChanged(prop);

View File

@@ -37,7 +37,7 @@ class FemExport ConstraintPressure: public Fem::Constraint
public:
ConstraintPressure();
App::PropertyFloat Pressure;
App::PropertyPressure Pressure;
App::PropertyBool Reversed;
App::PropertyVectorList Points;
App::PropertyVectorList Normals;
@@ -49,6 +49,8 @@ public:
const char* getViewProviderName() const override;
protected:
void
handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop);
void onChanged(const App::Property* prop) override;
};