FEM: use python base constraint class, mesh gmsh

This commit is contained in:
Bernd Hahnebach
2020-03-04 06:54:06 +01:00
parent a47d33b5e2
commit c460f08cbd
2 changed files with 16 additions and 46 deletions

View File

@@ -31,6 +31,7 @@ import sys
import FreeCAD
import FreeCADGui
import FemGui
from . import ViewProviderFemConstraint
# for the panel
from femobjects import _FemMeshGmsh
@@ -41,38 +42,21 @@ from PySide.QtGui import QApplication
import time
class _ViewProviderFemMeshGmsh:
class _ViewProviderFemMeshGmsh(ViewProviderFemConstraint.ViewProxy):
"A View Provider for the FemMeshGmsh 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 setEdit(self, vobj, mode):
# hide all meshes
for o in FreeCAD.ActiveDocument.Objects:
if o.isDerivedFrom("Fem::FemMeshObject"):
o.ViewObject.hide()
# show the mesh we like to edit
self.ViewObject.show()
# show task panel
taskd = _TaskPanelFemMeshGmsh(self.Object)
taskd.obj = vobj.Object
FreeCADGui.Control.showDialog(taskd)
return True
def setEdit(self, vobj, mode=0):
ViewProviderFemConstraint.ViewProxy.setEdit(
self,
vobj,
mode,
_TaskPanelFemMeshGmsh
)
# overwrite unsetEdit, because the mesh should to be hided on task panel exit
def unsetEdit(self, vobj, mode):
FreeCADGui.Control.closeDialog()
self.ViewObject.hide() # hide the mesh after edit is finished
@@ -166,12 +150,6 @@ class _ViewProviderFemMeshGmsh:
FreeCAD.Console.PrintError(message + "\n")
return True
def __getstate__(self):
return None
def __setstate__(self, state):
return None
def claimChildren(self):
reg_childs = self.Object.MeshRegionList
gro_childs = self.Object.MeshGroupList

View File

@@ -27,11 +27,15 @@ __url__ = "http://www.freecadweb.org"
# \ingroup FEM
# \brief FreeCAD FEM _FemMeshGmsh
from . import FemConstraint
class _FemMeshGmsh():
class _FemMeshGmsh(FemConstraint.Proxy):
"""A Fem::FemMeshObject python type, add Gmsh specific properties
"""
Type = "Fem::FemMeshGmsh"
# they will be used from the task panel too, thus they need to be outside of the __init__
known_element_dimensions = ["From Shape", "1D", "2D", "3D"]
known_element_orders = ["1st", "2nd"]
@@ -55,9 +59,7 @@ class _FemMeshGmsh():
]
def __init__(self, obj):
self.Type = "Fem::FemMeshGmsh"
self.Object = obj # keep a ref to the DocObj for nonGui usage
obj.Proxy = self # link between App::DocumentObject to this object
super(_FemMeshGmsh, self).__init__(obj)
obj.addProperty(
"App::PropertyLinkList",
@@ -206,13 +208,3 @@ class _FemMeshGmsh():
"For each group create not only the elements but the nodes too."
)
obj.GroupsOfNodes = False
def execute(self, obj):
return
def __getstate__(self):
return self.Type
def __setstate__(self, state):
if state:
self.Type = state