From 84e017e4dbde516bf9c29be2a48416faa8410cbe Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 21 Jul 2016 06:07:24 +0100 Subject: [PATCH] FEM: constraint self weight: object implementation --- src/Mod/Fem/App/CMakeLists.txt | 6 +- src/Mod/Fem/CMakeLists.txt | 5 ++ src/Mod/Fem/FemConstraintSelfWeight.py | 40 ++++++++++++ src/Mod/Fem/Gui/Workbench.cpp | 2 + src/Mod/Fem/InitGui.py | 2 + src/Mod/Fem/_CommandConstraintSelfWeight.py | 53 ++++++++++++++++ src/Mod/Fem/_FemConstraintSelfWeight.py | 35 +++++++++++ .../_ViewProviderFemConstraintSelfWeight.py | 63 +++++++++++++++++++ 8 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 src/Mod/Fem/FemConstraintSelfWeight.py create mode 100644 src/Mod/Fem/_CommandConstraintSelfWeight.py create mode 100644 src/Mod/Fem/_FemConstraintSelfWeight.py create mode 100644 src/Mod/Fem/_ViewProviderFemConstraintSelfWeight.py diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 5aa79b0fc..c4a2fee19 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -74,6 +74,7 @@ SET(FemScripts_SRCS _CommandAnalysis.py _CommandBeamSection.py _CommandControlSolver.py + _CommandConstraintSelfWeight.py _CommandMechanicalMaterial.py _CommandShowResult.py _CommandMeshFromShape.py @@ -84,6 +85,7 @@ SET(FemScripts_SRCS _CommandSolverZ88.py _FemAnalysis.py _FemBeamSection.py + _FemConstraintSelfWeight.py _FemShellThickness.py _FemSolverCalculix.py _FemSolverZ88.py @@ -95,6 +97,7 @@ SET(FemScripts_SRCS _TaskPanelShowResult.py _ViewProviderFemAnalysis.py _ViewProviderFemBeamSection.py + _ViewProviderFemConstraintSelfWeight.py _ViewProviderFemShellThickness.py _ViewProviderFemSolverCalculix.py _ViewProviderFemSolverZ88.py @@ -106,8 +109,9 @@ SET(FemScripts_SRCS Init.py InitGui.py FemAnalysis.py - FemCommands.py FemBeamSection.py + FemCommands.py + FemConstraintSelfWeight.py FemInputWriter.py FemInputWriterCcx.py FemInputWriterZ88.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index 6cab3bab6..cc7e8989f 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -83,6 +83,11 @@ INSTALL( _ViewProviderFemSolverZ88.py _CommandSolverZ88.py + FemConstraintSelfWeight.py + _FemConstraintSelfWeight.py + _ViewProviderFemConstraintSelfWeight.py + _CommandConstraintSelfWeight.py + DESTINATION Mod/Fem ) diff --git a/src/Mod/Fem/FemConstraintSelfWeight.py b/src/Mod/Fem/FemConstraintSelfWeight.py new file mode 100644 index 000000000..c8f25856e --- /dev/null +++ b/src/Mod/Fem/FemConstraintSelfWeight.py @@ -0,0 +1,40 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program 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 program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "FemConstraintSelfWeight" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +import FreeCAD +import FemGui +import _FemConstraintSelfWeight + + +def makeFemConstraintSelfWeight(name="FemConstraintSelfWeight"): + '''makeFemFemConstraintSelfWeight([name]): creates an beamsection object to define a cross section''' + obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name) + _FemConstraintSelfWeight._FemConstraintSelfWeight(obj) + if FreeCAD.GuiUp: + import _ViewProviderFemConstraintSelfWeight + _ViewProviderFemConstraintSelfWeight._ViewProviderFemConstraintSelfWeight(obj.ViewObject) + return obj diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index ca23dab91..97aaa785e 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -68,6 +68,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "Fem_ConstraintFixed" << "Fem_ConstraintDisplacement" << "Separator" + << "Fem_ConstraintSelfWeight" << "Fem_ConstraintForce" << "Fem_ConstraintPressure" << "Fem_ConstraintBearing" @@ -116,6 +117,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Fem_ConstraintFixed" << "Fem_ConstraintDisplacement" << "Separator" + << "Fem_ConstraintSelfWeight" << "Fem_ConstraintForce" << "Fem_ConstraintPressure" << "Fem_ConstraintBearing" diff --git a/src/Mod/Fem/InitGui.py b/src/Mod/Fem/InitGui.py index 12b66069e..7fc560f86 100644 --- a/src/Mod/Fem/InitGui.py +++ b/src/Mod/Fem/InitGui.py @@ -58,6 +58,8 @@ class FemWorkbench (Workbench): import _CommandMechanicalMaterial import _CommandSolverCalculix import _CommandSolverZ88 + import _CommandConstraintSelfWeight + import subprocess from platform import system diff --git a/src/Mod/Fem/_CommandConstraintSelfWeight.py b/src/Mod/Fem/_CommandConstraintSelfWeight.py new file mode 100644 index 000000000..1556319b4 --- /dev/null +++ b/src/Mod/Fem/_CommandConstraintSelfWeight.py @@ -0,0 +1,53 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program 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 program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "Command constraint self weight" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +import FreeCAD +from FemCommands import FemCommands + +if FreeCAD.GuiUp: + import FreeCADGui + from PySide import QtCore + + +class _CommandConstraintSelfWeight(FemCommands): + "The Fem_ConstraintSelfWeight command definition" + def __init__(self): + super(_CommandConstraintSelfWeight, self).__init__() + self.resources = {'Pixmap': 'fem-constraint-selfweight', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_ConstraintSelfWeight", "Constraint self weigt"), + 'Accel': "C, W", + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_ConstraintSelfWeight", "Creates a FEM constraint self weigt")} + self.is_active = 'with_analysis' + + def Activated(self): + FreeCAD.ActiveDocument.openTransaction("Create FemConstraintSelfWeight") + FreeCADGui.addModule("FemConstraintSelfWeight") + FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemConstraintSelfWeight.makeFemConstraintSelfWeight()]") + + +if FreeCAD.GuiUp: + FreeCADGui.addCommand('Fem_ConstraintSelfWeight', _CommandConstraintSelfWeight()) diff --git a/src/Mod/Fem/_FemConstraintSelfWeight.py b/src/Mod/Fem/_FemConstraintSelfWeight.py new file mode 100644 index 000000000..a62540a02 --- /dev/null +++ b/src/Mod/Fem/_FemConstraintSelfWeight.py @@ -0,0 +1,35 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2015 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program 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 program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "the constraint self weight object" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +class _FemConstraintSelfWeight: + "The FemConstraintSelfWeight object" + def __init__(self, obj): + obj.Proxy = self + self.Type = "FemConstraintSelfWeight" + + def execute(self, obj): + return diff --git a/src/Mod/Fem/_ViewProviderFemConstraintSelfWeight.py b/src/Mod/Fem/_ViewProviderFemConstraintSelfWeight.py new file mode 100644 index 000000000..cb6c5bd62 --- /dev/null +++ b/src/Mod/Fem/_ViewProviderFemConstraintSelfWeight.py @@ -0,0 +1,63 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program 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 program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "_ViewProviderFemConstraintSelfWeight" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + + +import FreeCAD +import FreeCADGui +from pivy import coin + + +class _ViewProviderFemConstraintSelfWeight: + "A View Provider for the FemConstraintSelfWeight object" + def __init__(self, vobj): + vobj.Proxy = self + + def getIcon(self): + return ":/icons/fem-constraint-selfweight.svg" + + def attach(self, vobj): + self.ViewObject = vobj + self.Object = vobj.Object + self.standard = coin.SoGroup() + vobj.addDisplayMode(self.standard, "Standard") + + def getDisplayModes(self, obj): + return ["Standard"] + + def getDefaultDisplayMode(self): + return "Standard" + + def updateData(self, obj, prop): + return + + def onChanged(self, vobj, prop): + return + + def __getstate__(self): + return None + + def __setstate__(self, state): + return None