[FEM] improve displacement constraint

- use a Distance and Angle property to get the unit handling right
This commit is contained in:
Uwe
2023-03-22 18:02:35 +01:00
parent 633eb24f88
commit 7fd12f8454
10 changed files with 215 additions and 103 deletions

View File

@@ -104,6 +104,45 @@ const char* ConstraintDisplacement::getViewProviderName() const
return "FemGui::ViewProviderFemConstraintDisplacement";
}
void ConstraintDisplacement::handleChangedPropertyType(Base::XMLReader& reader,
const char* TypeName,
App::Property* prop)
{
// properties _Displacement had App::PropertyFloat and were changed to App::PropertyDistance
if (prop == &xDisplacement && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance xDisplacementProperty;
// restore the PropertyFloat to be able to set its value
xDisplacementProperty.Restore(reader);
xDisplacement.setValue(xDisplacementProperty.getValue());
}
else if (prop == &yDisplacement && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance yDisplacementProperty;
yDisplacementProperty.Restore(reader);
yDisplacement.setValue(yDisplacementProperty.getValue());
}
else if (prop == &zDisplacement && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance zDisplacementProperty;
zDisplacementProperty.Restore(reader);
zDisplacement.setValue(zDisplacementProperty.getValue());
}
// properties _Displacement had App::PropertyFloat and were changed to App::PropertyAngle
else if (prop == &xRotation && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance xRotationProperty;
xRotationProperty.Restore(reader);
xRotation.setValue(xRotationProperty.getValue());
}
else if (prop == &yRotation && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance yRotationProperty;
yRotationProperty.Restore(reader);
yRotation.setValue(yRotationProperty.getValue());
}
else if (prop == &zRotation && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyDistance zRotationProperty;
zRotationProperty.Restore(reader);
zRotation.setValue(zRotationProperty.getValue());
}
}
void ConstraintDisplacement::onChanged(const App::Property* prop)
{
// Note: If we call this at the end, then the arrows are not oriented correctly initially