diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index 7db0d1e1c..e7a013f51 100755 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -114,6 +114,8 @@ private: void readNastran(const std::string &Filename); private: + /// positioning matrix + Base::Matrix4D _Mtrx; SMESH_Gen *myGen; SMESH_Mesh *myMesh; diff --git a/src/Mod/Fem/App/FemMeshObject.cpp b/src/Mod/Fem/App/FemMeshObject.cpp index 7b3208db7..eb44c8a52 100755 --- a/src/Mod/Fem/App/FemMeshObject.cpp +++ b/src/Mod/Fem/App/FemMeshObject.cpp @@ -27,6 +27,7 @@ #endif #include "FemMeshObject.h" +#include "FemMesh.h" #include #include @@ -62,4 +63,10 @@ PyObject *FemMeshObject::getPyObject() void FemMeshObject::onChanged(const Property* prop) { App::GeoFeature::onChanged(prop); + + // if the placement has changed apply the change to the mesh data as well + if (prop == &this->Placement) { + const_cast(this->FemMesh.getValue()).setTransform(this->Placement.getValue().toMatrix()); + } + } diff --git a/src/Mod/Machining_Distortion/Aligment.ui b/src/Mod/Machining_Distortion/Aligment.ui index ef18f412d..b39f82938 100644 --- a/src/Mod/Machining_Distortion/Aligment.ui +++ b/src/Mod/Machining_Distortion/Aligment.ui @@ -58,6 +58,9 @@ Auto minimize + + true + diff --git a/src/Mod/Machining_Distortion/MachDistAlignment.py b/src/Mod/Machining_Distortion/MachDistAlignment.py index 90caab1ea..6187a9717 100644 --- a/src/Mod/Machining_Distortion/MachDistAlignment.py +++ b/src/Mod/Machining_Distortion/MachDistAlignment.py @@ -44,8 +44,24 @@ class _CommandAlignment: 'ToolTip': QtCore.QT_TRANSLATE_NOOP("MachDist_Alignment","Part Alignment")} def Activated(self): + FemMeshObject = None + import FemGui, Mesh + # check if a active analysis is present and no Mesh in it + if FemGui.getActiveAnalysis() != None: + for i in FemGui.getActiveAnalysis().Member: + if i.isDerivedFrom("Fem::FemMeshObject"): + FemMeshObject = i + break + else: + return FreeCAD.ActiveDocument.openTransaction("Alignment") - taskd = _AlignTaskPanel() + + n = FemMeshObject.FemMesh.Nodes + p = Mesh.calculateEigenTransform(n) + p2 = p.inverse() + FemMeshObject.Placement = p2 + + taskd = _AlignTaskPanel(FemMeshObject) FreeCADGui.Control.showDialog(taskd) FreeCAD.ActiveDocument.commitTransaction() @@ -58,19 +74,19 @@ class _CommandAlignment: class _AlignTaskPanel: '''The editmode TaskPanel for Material objects''' - def __init__(self): + def __init__(self,object): # the panel has a tree widget that contains categories # for the subcomponents, such as additions, subtractions. # the categories are shown only if they are not empty. form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Machining_Distortion/Aligment.ui") - self.obj = None + self.obj = object self.formUi = form_class() self.form = QtGui.QWidget() self.formUi.setupUi(self.form) #Connect Signals and Slots - #QtCore.QObject.connect(form.button_select_files, QtCore.SIGNAL("clicked()"), self.select_files) + QtCore.QObject.connect(self.formUi.pushButton_FlipX, QtCore.SIGNAL("clicked()"), self.flipX) self.update() @@ -87,6 +103,8 @@ class _AlignTaskPanel: def reject(self): FreeCADGui.Control.closeDialog() - + + def flipX(self): + return FreeCADGui.addCommand('MachDist_Alignment',_CommandAlignment())