Skip to content

Commit

Permalink
FEM: Change way of handling combobox with FEM results
Browse files Browse the repository at this point in the history
Identification of selected result item is no longer based
on the item string, but on a separate userData. This method
is language agnostic.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF committed Apr 22, 2015
1 parent ea6b187 commit 1659e25
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -622,7 +622,7 @@ def __init__(self,object):
self.obj = object

#Connect Signals and Slots
QtCore.QObject.connect(self.form.comboBox_Type, QtCore.SIGNAL("currentIndexChanged(QString)"), self.typeChanged)
QtCore.QObject.connect(self.form.comboBox_Type, QtCore.SIGNAL("activated(int)"), self.typeChanged)

QtCore.QObject.connect(self.form.checkBox_ShowDisplacement, QtCore.SIGNAL("clicked(bool)"), self.showDisplacementClicked)
QtCore.QObject.connect(self.form.horizontalScrollBar_Factor, QtCore.SIGNAL("valueChanged(int)"), self.sliderValue)
Expand All @@ -637,31 +637,27 @@ def __init__(self,object):
def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Close)

def typeChanged(self,typeName):
if typeName == "None":
def typeChanged(self, index):
selected = self.form.comboBox_Type.itemData(index)
sel_key = selected.keys()[0]
sel_value = selected[sel_key]
if sel_key == "None":
self.MeshObject.ViewObject.NodeColor = {}
self.MeshObject.ViewObject.ElementColor = {}
return

QApplication.setOverrideCursor(Qt.WaitCursor)

if typeName[:2] == "Ua" and self.DisplacementObject:
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject)
if typeName[:2] == "U1" and self.DisplacementObject:
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,1)
if typeName[:2] == "U2" and self.DisplacementObject:
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,2)
if typeName[:2] == "U3" and self.DisplacementObject:
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject,3)
if typeName[:2] == "Sa" and self.StressObject:
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.StressObject)
if self.DisplacementObject:
if sel_key in ("U1", "U2", "U3", "Uabs"):
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject, sel_value)
if self.StressObject:
if sel_key in ("Sabs"):
(min,max,avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.StressObject)

self.form.lineEdit_Max.setText(str(max))
self.form.lineEdit_Min.setText(str(min))
self.form.lineEdit_Avg.setText(str(avg))

print typeName

QtGui.qApp.restoreOverrideCursor()

def showDisplacementClicked(self,bool):
Expand Down Expand Up @@ -699,6 +695,8 @@ def update(self):
'fills the widgets'
#print "Update-------------------------------"
self.MeshObject = None
self.form.comboBox_Type.clear()
self.form.comboBox_Type.addItem("None", {"None":0})
if FemGui.getActiveAnalysis():
for i in FemGui.getActiveAnalysis().Member:
if i.isDerivedFrom("Fem::FemMeshObject"):
Expand All @@ -708,15 +706,15 @@ def update(self):
if i.isDerivedFrom("Fem::FemResultVector"):
if i.DataType == 'Displacement':
self.DisplacementObject = i
self.form.comboBox_Type.addItem("U1 (Disp. X)")
self.form.comboBox_Type.addItem("U2 (Disp. Y)")
self.form.comboBox_Type.addItem("U3 (Disp. z)")
self.form.comboBox_Type.addItem("Uabs (Disp. abs)")
self.form.comboBox_Type.addItem("U1 (Disp. X)", {"U1":0})
self.form.comboBox_Type.addItem("U2 (Disp. Y)", {"U2":1})
self.form.comboBox_Type.addItem("U3 (Disp. Z)", {"U3":2})
self.form.comboBox_Type.addItem("Uabs (Disp. abs)", {"Uabs":3})
for i in FemGui.getActiveAnalysis().Member:
if i.isDerivedFrom("Fem::FemResultValue"):
if i.DataType == 'VonMisesStress':
self.StressObject = i
self.form.comboBox_Type.addItem("Sabs (Von Mises Stress)")
self.form.comboBox_Type.addItem("Sabs (Von Mises Stress)", {"Sabs":0})

def accept(self):
FreeCADGui.Control.closeDialog()
Expand Down

0 comments on commit 1659e25

Please sign in to comment.