FEM: Add option to define custom material directory

That commit also tidies up FEM preferences, so all file
choosers have the same width

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
Przemo Firszt 2015-04-09 11:49:30 +01:00 committed by wmayer
parent 0039ea9e72
commit f7fd04aa2b
3 changed files with 162 additions and 66 deletions

View File

@ -21,30 +21,30 @@
<number>6</number>
</property>
<item row="1" column="0">
<widget class="QGroupBox" name="gb_calculix">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>CalculiX</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gl_calculix">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="gb_calculix">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>CalculiX</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="Gui::PrefCheckBox" name="cb_int_editor">
<property name="text">
@ -62,18 +62,24 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hl_ext_editor">
<item>
<layout class="QGridLayout" name="gl_calculix">
<item row="2" column="0">
<widget class="QLabel" name="l_ext_editor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>External editor:</string>
</property>
</widget>
</item>
<item>
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ext_editor">
<property name="enabled">
<bool>false</bool>
@ -86,38 +92,119 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ccx_binary">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Leave blank to use default CalculiX ccx binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ccxBinaryPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="l_ccx_binary">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>ccx binary</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_materials">
<property name="title">
<string>Materials</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="l_ccx_binary">
<property name="text">
<string>ccx binary</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefFileChooser" name="fc_ccx_binary">
<property name="toolTip">
<string>Leave blank to use default CalculiX ccx binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ccxBinaryPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fc_custom_mat_dir">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>CustomMaterialsDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_custom_mat_dir">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>User directory</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
@ -172,22 +259,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>l_ext_editor</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>120</x>
<y>74</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
@ -204,6 +275,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>
<receiver>l_ext_editor</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>120</x>
<y>74</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_int_editor</sender>
<signal>toggled(bool)</signal>

View File

@ -46,6 +46,7 @@ void DlgSettingsFemImp::saveSettings()
cb_int_editor->onSave();
fc_ext_editor->onSave();
fc_ccx_binary->onSave();
fc_custom_mat_dir->onSave();
}
void DlgSettingsFemImp::loadSettings()
@ -53,6 +54,7 @@ void DlgSettingsFemImp::loadSettings()
cb_int_editor->onRestore();
fc_ext_editor->onRestore();
fc_ccx_binary->onRestore();
fc_custom_mat_dir->onRestore();
}
/**

View File

@ -207,5 +207,12 @@ class _MechanicalMaterialTaskPanel:
material_name = os.path.basename(i[:-l])
self.form.comboBox_MaterialsInDir.addItem(material_name)
self.pathList = self.pathList + user_mat_path_list
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
custom_mat_dir = self.fem_prefs.GetString("CustomMaterialsDir","")
custom_mat_path_list = glob.glob(custom_mat_dir + '/*' + mat_file_extension)
for i in custom_mat_path_list:
material_name = os.path.basename(i[:-l])
self.form.comboBox_MaterialsInDir.addItem(material_name)
self.pathList = self.pathList + custom_mat_path_list
FreeCADGui.addCommand('Fem_MechanicalMaterial',_CommandMechanicalMaterial())