From 7c316ba01ebf16dac355cc73e2ad12aa42e31a32 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 5 Jun 2018 07:31:25 +0200 Subject: [PATCH] FEM: prefs, move material prefs from general tab into an own tab in FEM --- src/Mod/Fem/Gui/AppFemGui.cpp | 2 + src/Mod/Fem/Gui/CMakeLists.txt | 5 + src/Mod/Fem/Gui/DlgSettingsFemGeneral.ui | 179 ------------------ src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp | 10 - src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui | 166 ++++++++++++++++ src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.cpp | 73 +++++++ src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h | 50 +++++ .../femguiobjects/_ViewProviderFemMaterial.py | 2 +- 8 files changed, 297 insertions(+), 190 deletions(-) create mode 100644 src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui create mode 100644 src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.cpp create mode 100644 src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h diff --git a/src/Mod/Fem/Gui/AppFemGui.cpp b/src/Mod/Fem/Gui/AppFemGui.cpp index 89192fddb5..e8cfdf01df 100644 --- a/src/Mod/Fem/Gui/AppFemGui.cpp +++ b/src/Mod/Fem/Gui/AppFemGui.cpp @@ -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 (QT_TRANSLATE_NOOP("QObject","FEM")); new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject","FEM")); new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject","FEM")); + new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject","FEM")); // register preferences pages on Import-Export new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject","Import-Export")); diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 7449889e98..ed7479ee56 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -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 diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGeneral.ui b/src/Mod/Fem/Gui/DlgSettingsFemGeneral.ui index ed37a9db45..42b33736db 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGeneral.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemGeneral.ui @@ -67,9 +67,6 @@ WorkingDir - - Gui::FileChooser::Directory - Mod/Fem/General @@ -287,9 +284,6 @@ CustomDirectoryPath - - Gui::FileChooser::Directory - @@ -344,115 +338,6 @@ - - - - Materials - - - - - - - - Use built-in materials - - - true - - - UseBuiltInMaterials - - - Mod/Fem/General - - - - - - - Use materials from Materials directory in users FreeCAD user pref directory. - - - true - - - UseMaterialsFromConfigDir - - - Mod/Fem/General - - - - - - - Use materials from user defined directory - - - true - - - UseMaterialsFromCustomDir - - - Mod/Fem/General - - - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - CustomMaterialsDir - - - Gui::FileChooser::Directory - - - Mod/Fem/General - - - - - - - true - - - - 100 - 0 - - - - User directory - - - - - - - - - - @@ -567,70 +452,6 @@ - - cb_use_mat_from_custom_dir - toggled(bool) - l_custom_mat_dir - setDisabled(bool) - - - 93 - 262 - - - 89 - 289 - - - - - cb_use_mat_from_custom_dir - toggled(bool) - fc_custom_mat_dir - setDisabled(bool) - - - 240 - 258 - - - 241 - 285 - - - - - cb_use_mat_from_custom_dir - toggled(bool) - l_custom_mat_dir - setEnabled(bool) - - - 123 - 266 - - - 122 - 297 - - - - - cb_use_mat_from_custom_dir - toggled(bool) - fc_custom_mat_dir - setEnabled(bool) - - - 380 - 266 - - - 380 - 293 - - - cb_wd_custom toggled(bool) diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp index 85028fe95c..46c0b3a406 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemGeneralImp.cpp @@ -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(); diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui b/src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui new file mode 100644 index 0000000000..a0d94d57fd --- /dev/null +++ b/src/Mod/Fem/Gui/DlgSettingsFemMaterial.ui @@ -0,0 +1,166 @@ + + + FemGui::DlgSettingsFemMaterialImp + + + + 0 + 0 + 505 + 451 + + + + Material + + + + 6 + + + + + Material Resources + + + + + + + + Use built-in materials + + + true + + + UseBuiltInMaterials + + + Mod/Material/Resources + + + + + + + Use materials from Materials directory in users FreeCAD user pref directory. + + + true + + + UseMaterialsFromConfigDir + + + Mod/Material/Resources + + + + + + + Use materials from user defined directory + + + true + + + UseMaterialsFromCustomDir + + + Mod/Material/Resources + + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + CustomMaterialsDir + + + Mod/Material/Resources + + + + + + + true + + + + 100 + 0 + + + + User directory + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 40 + + + + + + + + + + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+ + Gui::FileChooser + QWidget +
Gui/FileDialog.h
+
+ + Gui::PrefFileChooser + Gui::FileChooser +
Gui/PrefWidgets.h
+
+
+ + + + +
diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.cpp new file mode 100644 index 0000000000..d2f73c15bb --- /dev/null +++ b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** + * Copyright (c) 2018 FreeCAD Developers * + * Author: Bernd Hahnebach * + * 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 + +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" diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h new file mode 100644 index 0000000000..aa7fd66c31 --- /dev/null +++ b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h @@ -0,0 +1,50 @@ + /************************************************************************** + * Copyright (c) 2018 FreeCAD Developers * + * Author: Bernd Hahnebach * + * 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 + +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 diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py index 6b13108f0a..5ab4cb18fc 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py @@ -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: