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 authored and wwmayer committed Apr 23, 2015
1 parent d548490 commit 9b2f2b1
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -642,7 +642,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 @@ -657,31 +657,25 @@ 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)
if selected[0] == "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 selected[0] in ("U1", "U2", "U3", "Uabs"):
(min, max, avg) = self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject, selected[1])
if self.StressObject:
if selected[0] 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 @@ -719,6 +713,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 @@ -728,15 +724,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", 1))
self.form.comboBox_Type.addItem("U2 (Disp. Y)", ("U2", 2))
self.form.comboBox_Type.addItem("U3 (Disp. Z)", ("U3", 3))
self.form.comboBox_Type.addItem("Uabs (Disp. abs)", ("Uabs", 0))
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 9b2f2b1

Please sign in to comment.