diff --git a/src/Mod/Fem/App/FemPostFunction.cpp b/src/Mod/Fem/App/FemPostFunction.cpp index 7008cd3bf7..56e61fc684 100644 --- a/src/Mod/Fem/App/FemPostFunction.cpp +++ b/src/Mod/Fem/App/FemPostFunction.cpp @@ -99,6 +99,13 @@ void FemPostCylinderFunction::onChanged(const Property* prop) Fem::FemPostFunction::onChanged(prop); } +void FemPostCylinderFunction::onDocumentRestored() +{ + // This is to notify the view provider that the document has been fully restored + Axis.touch(); +} + + // *************************************************************************** // plane function PROPERTY_SOURCE(Fem::FemPostPlaneFunction, Fem::FemPostFunction) diff --git a/src/Mod/Fem/App/FemPostFunction.h b/src/Mod/Fem/App/FemPostFunction.h index db8e70006e..91b7890e47 100644 --- a/src/Mod/Fem/App/FemPostFunction.h +++ b/src/Mod/Fem/App/FemPostFunction.h @@ -104,7 +104,7 @@ public: protected: void onChanged(const App::Property* prop) override; /// get called after a document has been fully restored -// void onDocumentRestored() override; + void onDocumentRestored() override; vtkSmartPointer m_cylinder; }; diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index fe3762d7ee..8b72d2cc47 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -2178,14 +2178,13 @@ void CmdFemPostFunctions::activated(int iMsg) FeatName.c_str(), center[0], center[1] + box.GetLength(1) / 2, - center[2] + box.GetLength(2) / 2); + center[2]); doCommand(Doc, "App.ActiveDocument.%s.Radius = %f", FeatName.c_str(), - box.GetDiagonalLength() / 2); + box.GetDiagonalLength() / 3.6); // make cylinder a bit higher than the box } - this->updateActive(); //most of the times functions are added inside of a filter, make sure this still works if (!Gui::Application::Instance->activeDocument()->getInEdit()) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index b7d9a7b41d..aa22774d6c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -389,6 +389,7 @@ ViewProviderFemPostCylinderFunction::ViewProviderFemPostCylinderFunction() setAutoScale(false); + // setup the visualisation geometry getGeometryNode()->addChild(ShapeNodes::postCylinder()); } @@ -408,8 +409,8 @@ void ViewProviderFemPostCylinderFunction::draggerUpdate(SoDragger* m) func->Axis.setValue(norm[0], norm[1], norm[2]); } -void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p) { - +void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p) +{ Fem::FemPostCylinderFunction* func = static_cast(getObject()); if (!isDragging() && (p == &func->Center || p == &func->Radius || p == &func->Axis)) { Base::Vector3d trans = func->Center.getValue(); @@ -417,8 +418,9 @@ void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p) { double radius = func->Radius.getValue(); SbMatrix translate; - SbRotation rot(SbVec3f(0,0,1), SbVec3f(axis.x, axis.y, axis.z)); - translate.setTransform(SbVec3f(trans.x, trans.y, trans.z), rot, SbVec3f(radius,radius,radius)); + SbRotation rot(SbVec3f(0.0, 0.0, 1.0), SbVec3f(axis.x, axis.y, axis.z)); + translate.setTransform( + SbVec3f(trans.x, trans.y, trans.z), rot, SbVec3f(radius, radius, radius)); getManipulator()->setMatrix(translate); } @@ -546,7 +548,6 @@ static const App::PropertyFloatConstraint::Constraints scaleConstraint = {1e-4, ViewProviderFemPostPlaneFunction::ViewProviderFemPostPlaneFunction() : m_detectscale(false) { - ADD_PROPERTY_TYPE(Scale, (1000.0), "Manipulator", App::Prop_None, "Scaling factor for the manipulator"); Scale.setConstraints(&scaleConstraint); sPixmap = "fem-post-geo-plane"; @@ -570,7 +571,7 @@ void ViewProviderFemPostPlaneFunction::draggerUpdate(SoDragger* m) { const SbVec3f& base = dragger->translation.getValue(); const SbVec3f& scale = dragger->scaleFactor.getValue(); - SbVec3f norm(0., 1., 0.); + SbVec3f norm(0.0, 1.0, 0.0); dragger->rotation.getValue().multVec(norm, norm); func->Origin.setValue(base[0], base[1], base[2]); func->Normal.setValue(norm[0], norm[1], norm[2]); @@ -617,7 +618,7 @@ void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) { Base::Vector3d norm = func->Normal.getValue(); norm.Normalize(); - SbRotation rot(SbVec3f(0., 1., 0.), SbVec3f(norm.x, norm.y, norm.z)); + SbRotation rot(SbVec3f(0.0, 1.0, 0.0), SbVec3f(norm.x, norm.y, norm.z)); float scale = static_cast(Scale.getValue()); SbMatrix mat;