From fbf96728b828a869667d655a90fb0acf3f9d30f2 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 28 May 2018 06:00:57 +0200 Subject: [PATCH] FEM: material editor, add it to materials menue --- src/Mod/Fem/Gui/Workbench.cpp | 3 ++- src/Mod/Fem/femcommands/commands.py | 16 ++++++++++++++++ src/Mod/Fem/femcommands/manager.py | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index ab55b71422..06432e4a5b 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -164,7 +164,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const material->setCommand("Materials"); *material << "FEM_MaterialSolid" << "FEM_MaterialFluid" - << "FEM_MaterialMechanicalNonlinear"; + << "FEM_MaterialMechanicalNonlinear" + << "FEM_MaterialEditor"; Gui::MenuItem* elec = new Gui::MenuItem; elec->setCommand("&Electrostatic Constraints"); diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py index e8fd0c08ee..30b685b283 100644 --- a/src/Mod/Fem/femcommands/commands.py +++ b/src/Mod/Fem/femcommands/commands.py @@ -303,6 +303,21 @@ class _CommandFemEquationHeat(CommandManager): FreeCAD.ActiveDocument.recompute() +class _CommandFemMaterialEditor(CommandManager): + "The FEM_MaterialEditor command definition" + def __init__(self): + super(_CommandFemMaterialEditor, self).__init__() + self.resources = {'Pixmap': 'fem-femmesh-clear-mesh', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Material Editor", "opens the FreeCAD material editor"), + # 'Accel': "Z, Z", + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Material Editor", "opens the FreeCAD material editor")} + self.is_active = 'allways' + + def Activated(self): + FreeCADGui.addModule("MaterialEditor") + FreeCADGui.doCommand("MaterialEditor.openEditor()") + + class _CommandFemMaterialFluid(CommandManager): "The FEM_MaterialFluid command definition" def __init__(self): @@ -750,6 +765,7 @@ FreeCADGui.addCommand('FEM_EquationElasticity', _CommandFemEquationElasticity()) FreeCADGui.addCommand('FEM_EquationFlow', _CommandFemEquationFlow()) FreeCADGui.addCommand('FEM_EquationFluxsolver', _CommandFemEquationFluxsolver()) FreeCADGui.addCommand('FEM_EquationHeat', _CommandFemEquationHeat()) +FreeCADGui.addCommand('FEM_MaterialEditor', _CommandFemMaterialEditor()) FreeCADGui.addCommand('FEM_MaterialFluid', _CommandFemMaterialFluid()) FreeCADGui.addCommand('FEM_MaterialMechanicalNonlinear', _CommandFemMaterialMechanicalNonlinear()) FreeCADGui.addCommand('FEM_MaterialSolid', _CommandFemMaterialSolid()) diff --git a/src/Mod/Fem/femcommands/manager.py b/src/Mod/Fem/femcommands/manager.py index 97f4f2ba42..69a2b7049b 100644 --- a/src/Mod/Fem/femcommands/manager.py +++ b/src/Mod/Fem/femcommands/manager.py @@ -53,6 +53,8 @@ class CommandManager(object): def IsActive(self): if not self.is_active: active = False + elif self.is_active == 'allways': + active = True elif self.is_active == 'with_document': active = FreeCADGui.ActiveDocument is not None elif self.is_active == 'with_analysis':