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

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>492</width>
<height>560</height>
<width>350</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
@ -15,75 +15,293 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Cross Section</string>
<string>Cross section parameter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="l_label_text_3">
<property name="text">
<string>Use FreeCAD Property Editor</string>
</property>
</widget>
<layout class="QGridLayout" name="_2">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="cb_crosssectiontype"/>
</item>
<item>
<widget class="QLabel" name="l_label_text_4">
<property name="text">
<string>to edit the cross section values</string>
<item row="3" column="0">
<widget class="QStackedWidget" name="widget_stack">
<property name="currentIndex">
<number>2</number>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Choose cross section type:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="rb_Rect">
<property name="text">
<string>Rectangular</string>
<widget class="QWidget" name="page_all">
<layout class="QGridLayout" name="_3">
<property name="margin">
<number>9</number>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_Circ">
<property name="text">
<string>Circular</string>
<property name="spacing">
<number>6</number>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_Pipe">
<property name="text">
<string>Pipe</string>
<item row="1" column="0">
<layout class="QFormLayout" name="formLayout_1">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="l_rec_width">
<property name="text">
<string>Width: </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="if_rec_width">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_rec_height">
<property name="text">
<string>Height: </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="if_rec_height">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_remaining">
<layout class="QGridLayout" name="_5">
<property name="margin">
<number>9</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="1">
<widget class="Gui::InputField" name="if_circ_diameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_circ_diameter">
<property name="text">
<string>Diameter: </string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_referenced">
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="l_pipe_diameter">
<property name="text">
<string>Diameter: </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="if_pipe_diameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_pipe_thickness">
<property name="text">
<string>Thickness:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="if_pipe_thickness">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep" stdset="0">
<double>1.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>1000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="decimals" stdset="0">
<number>2</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -98,17 +316,7 @@
<item>
<widget class="QLabel" name="l_label_text_1">
<property name="text">
<string>Leave references blank </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="l_label_text_2">
<property name="text">
<string>to choose all remaining shapes</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Leave blank to choose all remaining shapes</string>
</property>
</widget>
</item>
@ -137,7 +345,6 @@
</item>
</layout>
<zorder>l_label_text_1</zorder>
<zorder>l_label_text_2</zorder>
<zorder>pushButton_Reference</zorder>
<zorder>list_References</zorder>
<zorder>verticalSpacer</zorder>
@ -145,6 +352,30 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>cb_crosssectiontype</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>widget_stack</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>245</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>245</x>
<y>126</y>
</hint>
</hints>
</connection>
</connections>
</ui>

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"):