Skip to content

Commit

Permalink
FEM: Add reset_mesh_color and reset_mesh_deformation functions
Browse files Browse the repository at this point in the history
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and yorikvanhavre committed Jun 9, 2015
1 parent ca47eea commit f29b003
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -140,6 +140,8 @@ def GetResources(self):

def Activated(self):
purge_fem_results()
reset_mesh_color()
reset_mesh_deformation()

def IsActive(self):
return FreeCADGui.ActiveDocument is not None and results_present()
Expand Down Expand Up @@ -352,6 +354,8 @@ def calculixFinished(self, exitCode):
self.femConsoleMessage("Loading result sets...")
self.form.label_Time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
purge_fem_results()
reset_mesh_color()
reset_mesh_deformation()
if os.path.isfile(self.base_name + '.frd'):
QApplication.setOverrideCursor(Qt.WaitCursor)
ccxFrdReader.importFrd(self.base_name + '.frd', FemGui.getActiveAnalysis())
Expand Down Expand Up @@ -538,9 +542,7 @@ def get_stats(self, type_name):
def typeChanged(self, index):
selected = self.form.comboBox_Type.itemData(index)
if selected[0] == "None":
self.MeshObject.ViewObject.NodeColor = {}
self.MeshObject.ViewObject.ElementColor = {}
self.MeshObject.ViewObject.setNodeColorByResult()
reset_mesh_color()
unit = "mm"

QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down Expand Up @@ -647,6 +649,25 @@ def purge_fem_results(Analysis=None):
FreeCAD.ActiveDocument.removeObject(o.Name)


def reset_mesh_color(mesh=None):
import FemGui
if mesh is None:
for i in FemGui.getActiveAnalysis().Member:
if i.isDerivedFrom("Fem::FemMeshObject"):
mesh = i
mesh.ViewObject.NodeColor = {}
mesh.ViewObject.ElementColor = {}
mesh.ViewObject.setNodeColorByResult()


def reset_mesh_deformation(mesh=None):
import FemGui
if mesh is None:
for i in FemGui.getActiveAnalysis().Member:
if i.isDerivedFrom("Fem::FemMeshObject"):
mesh = i
mesh.ViewObject.applyDisplacement(0.0)

FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())
Expand Down

0 comments on commit f29b003

Please sign in to comment.