Skip to content

Commit

Permalink
Fem: move handling of PostAutoRecompute to a central class and by def…
Browse files Browse the repository at this point in the history
…ault set its value to true
  • Loading branch information
wwmayer committed Apr 7, 2022
1 parent 02cb0b8 commit c4c0304
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/Mod/Fem/Gui/CMakeLists.txt
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions src/Mod/Fem/Gui/Command.cpp
Expand Up @@ -53,6 +53,7 @@
#include <Mod/Fem/App/FemSetNodesObject.h>

#include "ActiveAnalysisObserver.h"
#include "FemSettings.h"

#ifdef FC_USE_VTK
#include <Mod/Fem/App/FemPostPipeline.h>
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
44 changes: 44 additions & 0 deletions src/Mod/Fem/Gui/FemSettings.cpp
@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 <App/Application.h>

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);
}
44 changes: 44 additions & 0 deletions src/Mod/Fem/Gui/FemSettings.h
@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 <Base/Parameter.h>

namespace FemGui {

class FemSettings
{
public:
FemSettings();
void setPostAutoRecompute(bool);
bool getPostAutoRecompute() const;

private:
ParameterGrp::handle pGroup;
};

} //namespace FemGui

#endif // FEMGUI_SETTINGS_H
4 changes: 2 additions & 2 deletions src/Mod/Fem/Gui/TaskPostBoxes.cpp
Expand Up @@ -55,6 +55,7 @@
#include "ui_TaskPostScalarClip.h"
#include "ui_TaskPostWarpVector.h"

#include "FemSettings.h"
#include "TaskPostBoxes.h"
#include "ViewProviderFemPostFilter.h"
#include "ViewProviderFemPostFunction.h"
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Fem/Gui/ViewProviderFemPostFunction.cpp
Expand Up @@ -55,6 +55,7 @@

#include "ViewProviderFemPostFunction.h"
#include "ActiveAnalysisObserver.h"
#include "FemSettings.h"
#include "TaskPostBoxes.h"

#include "ui_PlaneWidget.h"
Expand Down Expand Up @@ -268,8 +269,7 @@ void ViewProviderFemPostFunction::dragStartCallback(void* data, SoDragger*)
reinterpret_cast<ViewProviderFemPostFunction*>(data)->m_isDragging = true;

ViewProviderFemPostFunction* that = reinterpret_cast<ViewProviderFemPostFunction*>(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*)
Expand Down

0 comments on commit c4c0304

Please sign in to comment.