[FEM] improve displacement constraint
- use a Distance and Angle property to get the unit handling right
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Mod/Fem/FemGlobal.h>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FEM_CONSTRAINTDISPLACEMENT_H
|
||||
#define FEM_CONSTRAINTDISPLACEMENT_H
|
||||
|
||||
#include "FemConstraint.h"
|
||||
|
||||
|
||||
namespace Fem
|
||||
{
|
||||
|
||||
@@ -45,12 +45,12 @@ public:
|
||||
App::PropertyVectorList Normals;
|
||||
|
||||
//Displacement parameters
|
||||
App::PropertyFloat xDisplacement;
|
||||
App::PropertyFloat yDisplacement;
|
||||
App::PropertyFloat zDisplacement;
|
||||
App::PropertyFloat xRotation;
|
||||
App::PropertyFloat yRotation;
|
||||
App::PropertyFloat zRotation;
|
||||
App::PropertyDistance xDisplacement;
|
||||
App::PropertyDistance yDisplacement;
|
||||
App::PropertyDistance zDisplacement;
|
||||
App::PropertyAngle xRotation;
|
||||
App::PropertyAngle yRotation;
|
||||
App::PropertyAngle zRotation;
|
||||
App::PropertyString xDisplacementFormula;
|
||||
App::PropertyString yDisplacementFormula;
|
||||
App::PropertyString zDisplacementFormula;
|
||||
@@ -78,6 +78,8 @@ public:
|
||||
const char* getViewProviderName() const override;
|
||||
|
||||
protected:
|
||||
void handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
|
||||
App::Property* prop) override;
|
||||
void onChanged(const App::Property* prop) override;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user