From a8ff9bedd42b33739aaac8392f49267a824023bf Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 2 Aug 2017 05:53:30 +0100 Subject: [PATCH] FEM: mesh result object, implement new object --- src/Mod/Fem/App/CMakeLists.txt | 2 + src/Mod/Fem/CMakeLists.txt | 2 + src/Mod/Fem/ObjectsFem.py | 11 ++++ .../Fem/PyGui/_ViewProviderFemMeshResult.py | 53 +++++++++++++++++++ src/Mod/Fem/PyObjects/_FemMeshResult.py | 48 +++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 src/Mod/Fem/PyGui/_ViewProviderFemMeshResult.py create mode 100644 src/Mod/Fem/PyObjects/_FemMeshResult.py diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 8d74e99bcf..aa75d945b4 100644 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -109,6 +109,7 @@ SET(FemObjectsScripts_SRCS PyObjects/_FemMeshBoundaryLayer.py PyObjects/_FemMeshGmsh.py PyObjects/_FemMeshGroup.py + PyObjects/_FemMeshResult.py PyObjects/_FemMeshRegion.py PyObjects/_FemResultMechanical.py PyObjects/_FemSolverCalculix.py @@ -161,6 +162,7 @@ SET(FemGuiScripts_SRCS PyGui/_ViewProviderFemMeshGmsh.py PyGui/_ViewProviderFemMeshGroup.py PyGui/_ViewProviderFemMeshRegion.py + PyGui/_ViewProviderFemMeshResult.py PyGui/_ViewProviderFemResultMechanical.py PyGui/_ViewProviderFemSolverCalculix.py PyGui/_ViewProviderFemSolverZ88.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index f393174141..6d5deaa96e 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -60,6 +60,7 @@ INSTALL( PyObjects/_FemMeshGmsh.py PyObjects/_FemMeshGroup.py PyObjects/_FemMeshRegion.py + PyObjects/_FemMeshResult.py PyObjects/_FemResultMechanical.py PyObjects/_FemSolverCalculix.py PyObjects/_FemSolverZ88.py @@ -114,6 +115,7 @@ INSTALL( PyGui/_ViewProviderFemMeshGmsh.py PyGui/_ViewProviderFemMeshGroup.py PyGui/_ViewProviderFemMeshRegion.py + PyGui/_ViewProviderFemMeshResult.py PyGui/_ViewProviderFemResultMechanical.py PyGui/_ViewProviderFemSolverCalculix.py PyGui/_ViewProviderFemSolverZ88.py diff --git a/src/Mod/Fem/ObjectsFem.py b/src/Mod/Fem/ObjectsFem.py index 9ba6f2e93b..5966cfb37a 100644 --- a/src/Mod/Fem/ObjectsFem.py +++ b/src/Mod/Fem/ObjectsFem.py @@ -287,6 +287,17 @@ def makeMeshRegion(base_mesh, element_length=0.0, name="FEMMeshRegion"): return obj +def makeMeshResult(name="FEMMeshResult"): + '''(name): makes a Fem MeshResult object''' + obj = FreeCAD.ActiveDocument.addObject("Fem::FemMeshObjectPython", name) + import PyObjects._FemMeshResult + PyObjects._FemMeshResult._FemMeshResult(obj) + if FreeCAD.GuiUp: + import PyGui._ViewProviderFemMeshResult + PyGui._ViewProviderFemMeshResult._ViewProviderFemMeshResult(obj.ViewObject) + return obj + + ########## result objects ########## def makeResultMechanical(name="MechanicalResult"): '''makeResultMechanical(name): creates an mechanical result object to hold FEM results''' diff --git a/src/Mod/Fem/PyGui/_ViewProviderFemMeshResult.py b/src/Mod/Fem/PyGui/_ViewProviderFemMeshResult.py new file mode 100644 index 0000000000..0be2a716e5 --- /dev/null +++ b/src/Mod/Fem/PyGui/_ViewProviderFemMeshResult.py @@ -0,0 +1,53 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2017 - 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__ = "_ViewProviderFemMeshResult" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + +## @package ViewProviderFemMeshResult +# \ingroup FEM + + +class _ViewProviderFemMeshResult: + "A View Provider for the FemMeshResult object" + def __init__(self, vobj): + vobj.Proxy = self + + def getIcon(self): + return ":/icons/fem-femmesh-from-shape.svg" + + def attach(self, vobj): + self.ViewObject = vobj + self.Object = vobj.Object + + def updateData(self, obj, prop): + return + + def onChanged(self, vobj, prop): + return + + def __getstate__(self): + return None + + def __setstate__(self, state): + return None diff --git a/src/Mod/Fem/PyObjects/_FemMeshResult.py b/src/Mod/Fem/PyObjects/_FemMeshResult.py new file mode 100644 index 0000000000..1e2f94c991 --- /dev/null +++ b/src/Mod/Fem/PyObjects/_FemMeshResult.py @@ -0,0 +1,48 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2017 - 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__ = "_FemMeshResult" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + +## @package FemMeshResult +# \ingroup FEM + + +class _FemMeshResult(): + """The Fem::FemMeshObject's Proxy python type, add Result specific object type + """ + + def __init__(self, obj): + self.Type = "FemMeshResult" + self.Object = obj # keep a ref to the DocObj for nonGui usage + obj.Proxy = self # link between App::DocumentObject to this object + + def execute(self, obj): + return + + def __getstate__(self): + return self.Type + + def __setstate__(self, state): + if state: + self.Type = state