Fem: Show all solvers in tool bar - fixes #27703
This commit is contained in:
committed by
Chris Hennes
parent
f0a70d5468
commit
18cf24e1d9
@@ -23,8 +23,8 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
#include "DlgSettingsFemGeneralImp.h"
|
||||
#include "ui_DlgSettingsFemGeneral.h"
|
||||
@@ -40,24 +40,7 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent)
|
||||
|
||||
// fill solvers combo with available solvers
|
||||
ui->cmb_def_solver->clear();
|
||||
std::vector<std::string> Solvers = {"None"};
|
||||
|
||||
if (!Fem::Tools::checkIfBinaryExists("Ccx", "ccx", "ccx").empty()) {
|
||||
Solvers.emplace_back("CalculiX");
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) {
|
||||
Solvers.emplace_back("Elmer");
|
||||
}
|
||||
// also check the multi-CPU Elmer build
|
||||
else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) {
|
||||
Solvers.emplace_back("Elmer");
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) {
|
||||
Solvers.emplace_back("Mystran");
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) {
|
||||
Solvers.emplace_back("Z88");
|
||||
}
|
||||
std::vector<std::string> Solvers = {"None", "CalculiX", "Elmer", "Mystran", "Z88"};
|
||||
|
||||
QStringList solversList;
|
||||
for (auto item : Solvers) {
|
||||
@@ -65,15 +48,8 @@ DlgSettingsFemGeneralImp::DlgSettingsFemGeneralImp(QWidget* parent)
|
||||
}
|
||||
ui->cmb_def_solver->addItems(solversList);
|
||||
|
||||
// if the "DefaultSolver" parameter is not yet set and there is only
|
||||
// one available solver, set this solver
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Fem/General"
|
||||
);
|
||||
auto DefaultSolver = hGrp->GetInt("DefaultSolver", 0);
|
||||
if (!DefaultSolver && ui->cmb_def_solver->count() == 2) {
|
||||
ui->cmb_def_solver->setCurrentIndex(1);
|
||||
}
|
||||
ParameterGrp::handle hGrp = ui->cmb_def_solver->getWindowParameter();
|
||||
ui->cmb_def_solver->setCurrentIndex(hGrp->GetInt(ui->cmb_def_solver->entryName(), 0));
|
||||
}
|
||||
|
||||
DlgSettingsFemGeneralImp::~DlgSettingsFemGeneralImp() = default;
|
||||
@@ -92,6 +68,17 @@ void DlgSettingsFemGeneralImp::saveSettings()
|
||||
ui->le_wd_custom->onSave();
|
||||
ui->cb_overwrite_solver_working_directory->onSave();
|
||||
ui->cmb_def_solver->onSave();
|
||||
|
||||
// set default solver icon
|
||||
Gui::CommandManager& cmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::Command* cmd = cmdMgr.getCommandByName("FEM_CompSolvers");
|
||||
if (cmd) {
|
||||
auto action = static_cast<Gui::ActionGroup*>(cmd->getAction());
|
||||
|
||||
ParameterGrp::handle hGrp = ui->cmb_def_solver->getWindowParameter();
|
||||
int index = hGrp->GetInt(ui->cmb_def_solver->entryName(), 0);
|
||||
action->setCheckedAction(index > 0 ? index - 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettingsFemGeneralImp::loadSettings()
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 97 KiB |
@@ -163,23 +163,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
|
||||
Gui::ToolBarItem* solve = new Gui::ToolBarItem(root);
|
||||
solve->setCommand("Solve");
|
||||
if (!Fem::Tools::checkIfBinaryExists("Ccx", "ccx", "ccx").empty()) {
|
||||
*solve << "FEM_SolverCalculiX";
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver").empty()) {
|
||||
*solve << "FEM_SolverElmer";
|
||||
}
|
||||
// also check the multi-CPU Elmer build
|
||||
else if (!Fem::Tools::checkIfBinaryExists("Elmer", "elmer", "ElmerSolver_mpi").empty()) {
|
||||
*solve << "FEM_SolverElmer";
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Mystran", "mystran", "mystran").empty()) {
|
||||
*solve << "FEM_SolverMystran";
|
||||
}
|
||||
if (!Fem::Tools::checkIfBinaryExists("Z88", "z88", "z88r").empty()) {
|
||||
*solve << "FEM_SolverZ88";
|
||||
}
|
||||
*solve << "Separator"
|
||||
*solve << "FEM_CompSolvers"
|
||||
<< "Separator"
|
||||
<< "FEM_CompMechEquations"
|
||||
<< "FEM_CompEmEquations"
|
||||
<< "FEM_EquationFlow"
|
||||
@@ -331,10 +316,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
Gui::MenuItem* solve = new Gui::MenuItem;
|
||||
root->insertItem(item, solve);
|
||||
solve->setCommand("&Solve");
|
||||
*solve << "FEM_SolverCalculiX"
|
||||
<< "FEM_SolverElmer"
|
||||
<< "FEM_SolverMystran"
|
||||
<< "FEM_SolverZ88"
|
||||
*solve << "FEM_CompSolvers"
|
||||
<< "Separator"
|
||||
<< "FEM_CompMechEquations"
|
||||
<< "FEM_CompEmEquations"
|
||||
|
||||
@@ -1166,6 +1166,33 @@ class _PostFilterGlyph(CommandManager):
|
||||
self.do_activated = "add_filter_set_edit"
|
||||
|
||||
|
||||
class _CompSolvers(CommandManager):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.pixmap = ""
|
||||
self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_CompSolvers", "Solvers")
|
||||
self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_CompSolvers", "Creates a FEM solver")
|
||||
self.is_active = "with_analysis"
|
||||
self.commands = [
|
||||
"FEM_SolverCalculiX",
|
||||
"FEM_SolverElmer",
|
||||
"FEM_SolverMystran",
|
||||
"FEM_SolverZ88",
|
||||
]
|
||||
|
||||
def Activated(self, i):
|
||||
FreeCADGui.runCommand(self.commands[i])
|
||||
|
||||
def GetCommands(self):
|
||||
return self.commands
|
||||
|
||||
def GetDefaultCommand(self):
|
||||
gen_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/General")
|
||||
# DefaultSolver == 0 is "None"
|
||||
index = gen_prefs.GetInt("DefaultSolver", 0)
|
||||
return (index - 1) if index > 0 else 0
|
||||
|
||||
|
||||
# the string in add command will be the page name on FreeCAD wiki
|
||||
FreeCADGui.addCommand("FEM_Analysis", _Analysis())
|
||||
FreeCADGui.addCommand("FEM_ClippingPlaneAdd", _ClippingPlaneAdd())
|
||||
@@ -1220,6 +1247,7 @@ FreeCADGui.addCommand("FEM_SolverElmer", _SolverElmer())
|
||||
FreeCADGui.addCommand("FEM_SolverMystran", _SolverMystran())
|
||||
FreeCADGui.addCommand("FEM_SolverRun", _SolverRun())
|
||||
FreeCADGui.addCommand("FEM_SolverZ88", _SolverZ88())
|
||||
FreeCADGui.addCommand("FEM_CompSolvers", _CompSolvers())
|
||||
|
||||
if "BUILD_FEM_VTK_PYTHON" in FreeCAD.__cmake__:
|
||||
FreeCADGui.addCommand("FEM_PostFilterGlyph", _PostFilterGlyph())
|
||||
|
||||
@@ -168,15 +168,13 @@ def get_dir_setting():
|
||||
|
||||
def get_default_solver():
|
||||
"""Return default solver name."""
|
||||
solver_map = {0: None}
|
||||
if get_binary("Calculix", True):
|
||||
solver_map[1] = "CalculiX"
|
||||
if get_binary("ElmerSolver", True):
|
||||
solver_map[len(solver_map)] = "Elmer"
|
||||
if get_binary("Mystran", True):
|
||||
solver_map[len(solver_map)] = "Mystran"
|
||||
if get_binary("Z88", True):
|
||||
solver_map[len(solver_map)] = "Z88"
|
||||
solver_map = {
|
||||
0: None,
|
||||
1: "CalculiX",
|
||||
2: "Elmer",
|
||||
3: "Mystran",
|
||||
4: "Z88",
|
||||
}
|
||||
param_group = FreeCAD.ParamGet(_GENERAL_PARAM)
|
||||
return solver_map[param_group.GetInt("DefaultSolver", 0)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user