Implementing new Alignment approach
This commit is contained in:
parent
4ab5bd57c9
commit
6f5ae0dd42
|
@ -114,6 +114,8 @@ private:
|
||||||
void readNastran(const std::string &Filename);
|
void readNastran(const std::string &Filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// positioning matrix
|
||||||
|
Base::Matrix4D _Mtrx;
|
||||||
SMESH_Gen *myGen;
|
SMESH_Gen *myGen;
|
||||||
SMESH_Mesh *myMesh;
|
SMESH_Mesh *myMesh;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "FemMeshObject.h"
|
#include "FemMeshObject.h"
|
||||||
|
#include "FemMesh.h"
|
||||||
#include <App/DocumentObjectPy.h>
|
#include <App/DocumentObjectPy.h>
|
||||||
#include <Base/Placement.h>
|
#include <Base/Placement.h>
|
||||||
|
|
||||||
|
@ -62,4 +63,10 @@ PyObject *FemMeshObject::getPyObject()
|
||||||
void FemMeshObject::onChanged(const Property* prop)
|
void FemMeshObject::onChanged(const Property* prop)
|
||||||
{
|
{
|
||||||
App::GeoFeature::onChanged(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<Fem::FemMesh&>(this->FemMesh.getValue()).setTransform(this->Placement.getValue().toMatrix());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,9 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto minimize</string>
|
<string>Auto minimize</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -44,8 +44,24 @@ class _CommandAlignment:
|
||||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("MachDist_Alignment","Part Alignment")}
|
'ToolTip': QtCore.QT_TRANSLATE_NOOP("MachDist_Alignment","Part Alignment")}
|
||||||
|
|
||||||
def Activated(self):
|
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")
|
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)
|
FreeCADGui.Control.showDialog(taskd)
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
|
|
||||||
|
@ -58,19 +74,19 @@ class _CommandAlignment:
|
||||||
|
|
||||||
class _AlignTaskPanel:
|
class _AlignTaskPanel:
|
||||||
'''The editmode TaskPanel for Material objects'''
|
'''The editmode TaskPanel for Material objects'''
|
||||||
def __init__(self):
|
def __init__(self,object):
|
||||||
# the panel has a tree widget that contains categories
|
# the panel has a tree widget that contains categories
|
||||||
# for the subcomponents, such as additions, subtractions.
|
# for the subcomponents, such as additions, subtractions.
|
||||||
# the categories are shown only if they are not empty.
|
# the categories are shown only if they are not empty.
|
||||||
form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Machining_Distortion/Aligment.ui")
|
form_class, base_class = uic.loadUiType(FreeCAD.getHomePath() + "Mod/Machining_Distortion/Aligment.ui")
|
||||||
|
|
||||||
self.obj = None
|
self.obj = object
|
||||||
self.formUi = form_class()
|
self.formUi = form_class()
|
||||||
self.form = QtGui.QWidget()
|
self.form = QtGui.QWidget()
|
||||||
self.formUi.setupUi(self.form)
|
self.formUi.setupUi(self.form)
|
||||||
|
|
||||||
#Connect Signals and Slots
|
#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()
|
self.update()
|
||||||
|
|
||||||
|
@ -88,5 +104,7 @@ class _AlignTaskPanel:
|
||||||
def reject(self):
|
def reject(self):
|
||||||
FreeCADGui.Control.closeDialog()
|
FreeCADGui.Control.closeDialog()
|
||||||
|
|
||||||
|
def flipX(self):
|
||||||
|
return
|
||||||
|
|
||||||
FreeCADGui.addCommand('MachDist_Alignment',_CommandAlignment())
|
FreeCADGui.addCommand('MachDist_Alignment',_CommandAlignment())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user