FEM: prefs, move material prefs from general tab into an own tab in FEM

This commit is contained in:
Bernd Hahnebach
2018-06-05 07:31:25 +02:00
committed by Yorik van Havre
parent 71a27731b2
commit 7c316ba01e
8 changed files with 297 additions and 190 deletions

View File

@@ -39,6 +39,7 @@
#include "DlgSettingsFemGeneralImp.h"
#include "DlgSettingsFemGmshImp.h"
#include "DlgSettingsFemInOutVtkImp.h"
#include "DlgSettingsFemMaterialImp.h"
#include "DlgSettingsFemZ88Imp.h"
#include "ViewProviderFemMesh.h"
#include "ViewProviderFemMeshShape.h"
@@ -164,6 +165,7 @@ PyMOD_INIT_FUNC(FemGui)
new Gui::PrefPageProducer<FemGui::DlgSettingsFemCcxImp> (QT_TRANSLATE_NOOP("QObject","FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemElmerImp> (QT_TRANSLATE_NOOP("QObject","FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemZ88Imp> (QT_TRANSLATE_NOOP("QObject","FEM"));
new Gui::PrefPageProducer<FemGui::DlgSettingsFemMaterialImp> (QT_TRANSLATE_NOOP("QObject","FEM"));
// register preferences pages on Import-Export
new Gui::PrefPageProducer<FemGui::DlgSettingsFemExportAbaqusImp> (QT_TRANSLATE_NOOP("QObject","Import-Export"));

View File

@@ -51,6 +51,7 @@ set(FemGui_MOC_HDRS
DlgSettingsFemGeneralImp.h
DlgSettingsFemGmshImp.h
DlgSettingsFemInOutVtkImp.h
DlgSettingsFemMaterialImp.h
DlgSettingsFemZ88Imp.h
PropertyFemMeshItem.h
TaskObjectName.h
@@ -95,6 +96,7 @@ set(FemGui_UIC_SRCS
DlgSettingsFemGeneral.ui
DlgSettingsFemGmsh.ui
DlgSettingsFemInOutVtk.ui
DlgSettingsFemMaterial.ui
DlgSettingsFemZ88.ui
TaskCreateNodeSet.ui
TaskObjectName.ui
@@ -158,6 +160,9 @@ SET(FemGui_DLG_SRCS
DlgSettingsFemInOutVtk.ui
DlgSettingsFemInOutVtkImp.cpp
DlgSettingsFemInOutVtkImp.h
DlgSettingsFemMaterial.ui
DlgSettingsFemMaterialImp.cpp
DlgSettingsFemMaterialImp.h
DlgSettingsFemZ88.ui
DlgSettingsFemZ88Imp.cpp
DlgSettingsFemZ88Imp.h

View File

@@ -67,9 +67,6 @@
<property name="prefEntry" stdset="0">
<cstring>WorkingDir</cstring>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/General</cstring>
</property>
@@ -287,9 +284,6 @@
<property name="prefEntry" stdset="0">
<cstring>CustomDirectoryPath</cstring>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
</widget>
</item>
<item>
@@ -344,115 +338,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_4_materials">
<property name="title">
<string>Materials</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_built_in_materials">
<property name="text">
<string>Use built-in materials</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseBuiltInMaterials</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_mat_from_config_dir">
<property name="text">
<string>Use materials from Materials directory in users FreeCAD user pref directory.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseMaterialsFromConfigDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_mat_from_custom_dir">
<property name="text">
<string>Use materials from user defined directory</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseMaterialsFromCustomDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/General</cstring>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fc_custom_mat_dir" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<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="prefEntry" stdset="0">
<cstring>CustomMaterialsDir</cstring>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/General</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_custom_mat_dir">
<property name="enabled">
<bool>true</bool>
</property>
<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>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_5_results">
<property name="title">
@@ -567,70 +452,6 @@
<include location="Resources/Fem.qrc"/>
</resources>
<connections>
<connection>
<sender>cb_use_mat_from_custom_dir</sender>
<signal>toggled(bool)</signal>
<receiver>l_custom_mat_dir</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>93</x>
<y>262</y>
</hint>
<hint type="destinationlabel">
<x>89</x>
<y>289</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_use_mat_from_custom_dir</sender>
<signal>toggled(bool)</signal>
<receiver>fc_custom_mat_dir</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>240</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>241</x>
<y>285</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_use_mat_from_custom_dir</sender>
<signal>toggled(bool)</signal>
<receiver>l_custom_mat_dir</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>123</x>
<y>266</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>297</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_use_mat_from_custom_dir</sender>
<signal>toggled(bool)</signal>
<receiver>fc_custom_mat_dir</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>380</x>
<y>266</y>
</hint>
<hint type="destinationlabel">
<x>380</x>
<y>293</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_wd_custom</sender>
<signal>toggled(bool)</signal>

View File

@@ -48,11 +48,6 @@ void DlgSettingsFemGeneralImp::saveSettings()
cb_analysis_group_meshing->onSave();
cb_use_built_in_materials->onSave();
cb_use_mat_from_config_dir->onSave();
cb_use_mat_from_custom_dir->onSave();
fc_custom_mat_dir->onSave();
cb_restore_result_dialog->onSave();
cb_keep_results_on_rerun->onSave();
cb_hide_constraint->onSave();
@@ -69,11 +64,6 @@ void DlgSettingsFemGeneralImp::loadSettings()
cb_analysis_group_meshing->onRestore();
cb_use_built_in_materials->onRestore();
cb_use_mat_from_config_dir->onRestore();
cb_use_mat_from_custom_dir->onRestore();
fc_custom_mat_dir->onRestore();
cb_restore_result_dialog->onRestore();
cb_keep_results_on_rerun->onRestore();
cb_hide_constraint->onRestore();

View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FemGui::DlgSettingsFemMaterialImp</class>
<widget class="QWidget" name="FemGui::DlgSettingsFemMaterialImp">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>505</width>
<height>451</height>
</rect>
</property>
<property name="windowTitle">
<string>Material</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="gb_4_materials">
<property name="title">
<string>Material Resources</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_built_in_materials">
<property name="text">
<string>Use built-in materials</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseBuiltInMaterials</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Material/Resources</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_mat_from_config_dir">
<property name="text">
<string>Use materials from Materials directory in users FreeCAD user pref directory.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseMaterialsFromConfigDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Material/Resources</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="cb_use_mat_from_custom_dir">
<property name="text">
<string>Use materials from user defined directory</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseMaterialsFromCustomDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Material/Resources</cstring>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fc_custom_mat_dir" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<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="prefEntry" stdset="0">
<cstring>CustomMaterialsDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Material/Resources</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="l_custom_mat_dir">
<property name="enabled">
<bool>true</bool>
</property>
<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>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefFileChooser</class>
<extends>Gui::FileChooser</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/Fem.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,73 @@
/***************************************************************************
* Copyright (c) 2018 FreeCAD Developers *
* Author: Bernd Hahnebach <bernd@bimstatik.ch> *
* Based on src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Gui/Application.h"
#include "DlgSettingsFemMaterialImp.h"
#include <Gui/PrefWidgets.h>
using namespace FemGui;
DlgSettingsFemMaterialImp::DlgSettingsFemMaterialImp( QWidget* parent )
: PreferencePage( parent )
{
this->setupUi(this);
}
DlgSettingsFemMaterialImp::~DlgSettingsFemMaterialImp()
{
// no need to delete child widgets, Qt does it all for us
}
void DlgSettingsFemMaterialImp::saveSettings()
{
cb_use_built_in_materials->onSave();
cb_use_mat_from_config_dir->onSave();
cb_use_mat_from_custom_dir->onSave();
fc_custom_mat_dir->onSave();
}
void DlgSettingsFemMaterialImp::loadSettings()
{
cb_use_built_in_materials->onRestore();
cb_use_mat_from_config_dir->onRestore();
cb_use_mat_from_custom_dir->onRestore();
fc_custom_mat_dir->onRestore();
}
/**
* Sets the strings of the subwidgets using the current language.
*/
void DlgSettingsFemMaterialImp::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
}
else {
QWidget::changeEvent(e);
}
}
#include "moc_DlgSettingsFemMaterialImp.cpp"

View File

@@ -0,0 +1,50 @@
/**************************************************************************
* Copyright (c) 2018 FreeCAD Developers *
* Author: Bernd Hahnebach <bernd@bimstatik.ch> *
* Based on src/Mod/Fem/Gui/DlgSettingsFemElmer.h *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef FEMGUI_DLGSETTINGSFEMMATERIALIMP_H
#define FEMGUI_DLGSETTINGSFEMMATERIALIMP_H
#include "ui_DlgSettingsFemMaterial.h"
#include <Gui/PropertyPage.h>
namespace FemGui {
class DlgSettingsFemMaterialImp : public Gui::Dialog::PreferencePage, public Ui_DlgSettingsFemMaterialImp
{
Q_OBJECT
public:
DlgSettingsFemMaterialImp( QWidget* parent = 0 );
~DlgSettingsFemMaterialImp();
protected:
void saveSettings();
void loadSettings();
void changeEvent(QEvent *e);
};
} // namespace FemGui
#endif // FEMGUI_DLGSETTINGSFEMMATERIALIMP_H

View File

@@ -536,7 +536,7 @@ class _TaskPanelFemMaterial:
self.pathList = []
self.parameterWidget.cb_materials.clear()
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/General")
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Material/Resources")
if self.obj.Category == 'Fluid':
self.import_fluid_materials()
else: