diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 57bb49771431..219ae4ebb1c1 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -313,6 +313,8 @@ SET(FemGui_SRCS_Module ActiveAnalysisObserver.cpp ActiveAnalysisObserver.h Command.cpp + FemSettings.cpp + FemSettings.h Resources/Fem.qrc PreCompiled.cpp PreCompiled.h diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index da53fdc29d20..afc4c80d8c88 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -53,6 +53,7 @@ #include #include "ActiveAnalysisObserver.h" +#include "FemSettings.h" #ifdef FC_USE_VTK #include @@ -1744,12 +1745,7 @@ CmdFemPostApllyChanges::CmdFemPostApllyChanges() void CmdFemPostApllyChanges::activated(int iMsg) { - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); - - if (iMsg == 1) - hGrp->SetBool("PostAutoRecompute", true); - else - hGrp->SetBool("PostAutoRecompute", false); + FemGui::FemSettings().setPostAutoRecompute(iMsg == 1); } bool CmdFemPostApllyChanges::isActive(void) @@ -1764,8 +1760,7 @@ Gui::Action* CmdFemPostApllyChanges::createAction(void) { Gui::Action* pcAction = Command::createAction(); pcAction->setCheckable(true); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); - pcAction->setChecked(hGrp->GetBool("PostAutoRecompute", false)); + pcAction->setChecked(FemGui::FemSettings().getPostAutoRecompute()); return pcAction; } diff --git a/src/Mod/Fem/Gui/FemSettings.cpp b/src/Mod/Fem/Gui/FemSettings.cpp new file mode 100644 index 000000000000..64e6dff4c381 --- /dev/null +++ b/src/Mod/Fem/Gui/FemSettings.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (c) 2022 Werner Mayer * + * * + * 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 "FemSettings.h" +#include + +using namespace FemGui; + + +FemSettings::FemSettings() +{ + pGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); +} + +void FemSettings::setPostAutoRecompute(bool on) +{ + pGroup->SetBool("PostAutoRecompute", on); +} + +bool FemSettings::getPostAutoRecompute() const +{ + return pGroup->GetBool("PostAutoRecompute", true); +} diff --git a/src/Mod/Fem/Gui/FemSettings.h b/src/Mod/Fem/Gui/FemSettings.h new file mode 100644 index 000000000000..03da65edb0f8 --- /dev/null +++ b/src/Mod/Fem/Gui/FemSettings.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (c) 2022 Werner Mayer * + * * + * 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_SETTINGS_H +#define FEMGUI_SETTINGS_H + +#include + +namespace FemGui { + +class FemSettings +{ +public: + FemSettings(); + void setPostAutoRecompute(bool); + bool getPostAutoRecompute() const; + +private: + ParameterGrp::handle pGroup; +}; + +} //namespace FemGui + +#endif // FEMGUI_SETTINGS_H diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 5003cf4dfbfc..8559a4585314 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -55,6 +55,7 @@ #include "ui_TaskPostScalarClip.h" #include "ui_TaskPostWarpVector.h" +#include "FemSettings.h" #include "TaskPostBoxes.h" #include "ViewProviderFemPostFilter.h" #include "ViewProviderFemPostFunction.h" @@ -300,8 +301,7 @@ TaskPostBox::~TaskPostBox() { bool TaskPostBox::autoApply() { - ParameterGrp::handle pGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); - return pGroup->GetBool("PostAutoRecompute", false); + return FemSettings().getPostAutoRecompute(); } void TaskPostBox::recompute() { diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp index 442a8447b55d..a43338a786d4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp @@ -55,6 +55,7 @@ #include "ViewProviderFemPostFunction.h" #include "ActiveAnalysisObserver.h" +#include "FemSettings.h" #include "TaskPostBoxes.h" #include "ui_PlaneWidget.h" @@ -268,8 +269,7 @@ void ViewProviderFemPostFunction::dragStartCallback(void* data, SoDragger*) reinterpret_cast(data)->m_isDragging = true; ViewProviderFemPostFunction* that = reinterpret_cast(data); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Fem"); - that->m_autoRecompute = hGrp->GetBool("PostAutoRecompute", false); + that->m_autoRecompute = FemSettings().getPostAutoRecompute(); } void ViewProviderFemPostFunction::dragFinishCallback(void* data, SoDragger*)