FEM: beamsection task panel, add length values and use combobox to choose the section type

This commit is contained in:
Bernd Hahnebach
2016-12-20 18:11:48 +01:00
committed by Yorik van Havre
parent a826a6d2bf
commit 856b7844c0
2 changed files with 373 additions and 111 deletions

View File

@@ -31,6 +31,7 @@ import FreeCAD
import FreeCADGui
from PySide import QtGui
from PySide import QtCore
import _FemBeamSection
class _TaskPanelFemBeamSection:
@@ -39,33 +40,27 @@ class _TaskPanelFemBeamSection:
FreeCADGui.Selection.clearSelection()
self.sel_server = None
self.obj = obj
self.references = []
if self.obj.References:
self.tuplereferences = self.obj.References
self.get_references()
self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/TaskPanelFemBeamSection.ui")
if self.obj.SectionType == 'Rectangular':
self.form.rb_Rect.setChecked(True)
elif self.obj.SectionType == 'Circular':
self.form.rb_Circ.setChecked(True)
elif self.obj.SectionType == 'Pipe':
self.form.rb_Pipe.setChecked(True)
QtCore.QObject.connect(self.form.cb_crosssectiontype, QtCore.SIGNAL("activated(int)"), self.sectiontype_changed)
QtCore.QObject.connect(self.form.if_rec_height, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.rec_height_changed)
QtCore.QObject.connect(self.form.if_rec_width, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.rec_width_changed)
QtCore.QObject.connect(self.form.if_circ_diameter, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.circ_diameter_changed)
QtCore.QObject.connect(self.form.if_pipe_diameter, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.pipe_diameter_changed)
QtCore.QObject.connect(self.form.if_pipe_thickness, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.pipe_thickness_changed)
QtCore.QObject.connect(self.form.pushButton_Reference, QtCore.SIGNAL("clicked()"), self.add_references)
QtCore.QObject.connect(self.form.rb_Rect, QtCore.SIGNAL("clicked()"), self.rect_section)
QtCore.QObject.connect(self.form.rb_Circ, QtCore.SIGNAL("clicked()"), self.circ_section)
QtCore.QObject.connect(self.form.rb_Pipe, QtCore.SIGNAL("clicked()"), self.pipe_section)
self.form.list_References.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.form.list_References.connect(self.form.list_References, QtCore.SIGNAL("customContextMenuRequested(QPoint)"), self.references_list_right_clicked)
self.rebuild_list_References()
self.form.cb_crosssectiontype.addItems(_FemBeamSection._FemBeamSection.known_beam_types)
self.get_beamsection_props()
self.update()
def accept(self):
self.set_beamsection_props()
if self.sel_server:
FreeCADGui.Selection.removeObserver(self.sel_server)
self.obj.References = self.references
FreeCADGui.ActiveDocument.resetEdit()
FreeCAD.ActiveDocument.recompute()
return True
@@ -76,6 +71,59 @@ class _TaskPanelFemBeamSection:
FreeCADGui.ActiveDocument.resetEdit()
return True
def get_beamsection_props(self):
self.references = []
if self.obj.References:
self.tuplereferences = self.obj.References
self.get_references()
self.SectionType = self.obj.SectionType
self.RectHeight = self.obj.RectHeight
self.RectWidth = self.obj.RectWidth
self.CircRadius = self.obj.CircRadius
self.PipeRadius = self.obj.PipeRadius
self.PipeThickness = self.obj.PipeThickness
def set_beamsection_props(self):
self.obj.References = self.references
self.obj.SectionType = self.SectionType
self.obj.RectHeight = self.RectHeight
self.obj.RectWidth = self.RectWidth
self.obj.CircRadius = self.CircRadius
self.obj.PipeRadius = self.PipeRadius
self.obj.PipeThickness = self.PipeThickness
def update(self):
'fills the widgets'
index_crosssectiontype = self.form.cb_crosssectiontype.findText(self.SectionType)
self.form.cb_crosssectiontype.setCurrentIndex(index_crosssectiontype)
self.form.if_rec_height.setText(self.RectHeight.UserString)
self.form.if_rec_width.setText(self.RectWidth.UserString)
self.form.if_circ_diameter.setText(self.CircRadius.UserString)
self.form.if_pipe_diameter.setText(self.PipeRadius.UserString)
self.form.if_pipe_thickness.setText(self.PipeThickness.UserString)
self.rebuild_list_References()
def sectiontype_changed(self, index):
if index < 0:
return
self.form.cb_crosssectiontype.setCurrentIndex(index)
self.SectionType = str(self.form.cb_crosssectiontype.itemText(index)) # form returns unicode
def rec_height_changed(self, base_quantity_value):
self.RectHeight = base_quantity_value
def rec_width_changed(self, base_quantity_value):
self.RectWidth = base_quantity_value
def circ_diameter_changed(self, base_quantity_value):
self.CircRadius = base_quantity_value
def pipe_diameter_changed(self, base_quantity_value):
self.PipeRadius = base_quantity_value
def pipe_thickness_changed(self, base_quantity_value):
self.PipeThickness = base_quantity_value
def get_references(self):
for ref in self.tuplereferences:
for elem in ref[1]:
@@ -111,23 +159,6 @@ class _TaskPanelFemBeamSection:
import FemSelectionObserver
self.sel_server = FemSelectionObserver.FemSelectionObserver(self.selectionParser, print_message)
def rect_section(self):
'''Called if Rectangular radio button is triggered'''
self.obj.SectionType = 'Rectangular'
self.obj.RectWidth = 20.0
self.obj.RectHeight = 20.0
def circ_section(self):
'''Called if Circular radio button is triggered'''
self.obj.SectionType = 'Circular'
self.obj.CircRadius = 20.0
def pipe_section(self):
'''Called if Pipe radio button is triggered'''
self.obj.SectionType = 'Pipe'
self.obj.PipeRadius = 20.0
self.obj.PipeThickness = 2.0
def selectionParser(self, selection):
# print('selection: ', selection[0].Shape.ShapeType, ' ', selection[0].Name, ' ', selection[1])
if hasattr(selection[0], "Shape"):