FEM: use python base constraint class, mesh boundary layer
This commit is contained in:
@@ -30,76 +30,26 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import FemGui # needed to display the icons in TreeView
|
||||
from . import ViewProviderFemConstraint
|
||||
|
||||
# for the panel
|
||||
from PySide import QtCore
|
||||
from . import FemSelectionWidgets
|
||||
|
||||
False if FemGui.__name__ else True # flake8, dummy FemGui usage
|
||||
|
||||
|
||||
class _ViewProviderFemMeshBoundaryLayer:
|
||||
class _ViewProviderFemMeshBoundaryLayer(ViewProviderFemConstraint.ViewProxy):
|
||||
"A View Provider for the FemMeshBoundaryLayer object"
|
||||
|
||||
def __init__(self, vobj):
|
||||
vobj.Proxy = self
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/fem-femmesh-boundary-layer.svg"
|
||||
|
||||
def attach(self, vobj):
|
||||
from pivy import coin
|
||||
self.ViewObject = vobj
|
||||
self.Object = vobj.Object
|
||||
self.standard = coin.SoGroup()
|
||||
vobj.addDisplayMode(self.standard, "Default")
|
||||
|
||||
def getDisplayModes(self, obj):
|
||||
return ["Default"]
|
||||
|
||||
def getDefaultDisplayMode(self):
|
||||
return "Default"
|
||||
|
||||
def updateData(self, obj, prop):
|
||||
return
|
||||
|
||||
def onChanged(self, vobj, prop):
|
||||
return
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
# hide all meshes
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.isDerivedFrom("Fem::FemMeshObject"):
|
||||
o.ViewObject.hide()
|
||||
# show task panel
|
||||
taskd = _TaskPanelFemMeshBoundaryLayer(self.Object)
|
||||
taskd.obj = vobj.Object
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return True
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
guidoc = FreeCADGui.getDocument(vobj.Object.Document)
|
||||
# check if another VP is in edit mode
|
||||
# https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
|
||||
if not guidoc.getInEdit():
|
||||
guidoc.setEdit(vobj.Object.Name)
|
||||
else:
|
||||
from PySide.QtGui import QMessageBox
|
||||
message = "Active Task Dialog found! Please close this one before opening a new one!"
|
||||
QMessageBox.critical(None, "Error in tree view", message)
|
||||
FreeCAD.Console.PrintError(message + "\n")
|
||||
return True
|
||||
|
||||
def __getstate__(self):
|
||||
return None
|
||||
|
||||
def __setstate__(self, state):
|
||||
return None
|
||||
ViewProviderFemConstraint.ViewProxy.setEdit(
|
||||
self,
|
||||
vobj,
|
||||
mode,
|
||||
_TaskPanelFemMeshBoundaryLayer
|
||||
)
|
||||
|
||||
|
||||
class _TaskPanelFemMeshBoundaryLayer:
|
||||
|
||||
@@ -32,6 +32,6 @@ class Proxy(object):
|
||||
BaseType = "Fem::ConstraintPython"
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.Proxy = self
|
||||
obj.Proxy = self # link between App::DocumentObject to this object
|
||||
|
||||
## @}
|
||||
|
||||
@@ -27,13 +27,16 @@ __url__ = "http://www.freecadweb.org"
|
||||
# \ingroup FEM
|
||||
# \brief FEM mesh boundary layer object
|
||||
|
||||
from . import FemConstraint
|
||||
|
||||
class _FemMeshBoundaryLayer:
|
||||
|
||||
class _FemMeshBoundaryLayer(FemConstraint.Proxy):
|
||||
"The FemMeshBoundaryLayer object"
|
||||
|
||||
Type = "Fem::FemMeshBoundaryLayer"
|
||||
|
||||
def __init__(self, obj):
|
||||
self.Type = "Fem::FemMeshBoundaryLayer"
|
||||
self.Object = obj # keep a ref to the DocObj for nonGui usage
|
||||
obj.Proxy = self # link between App::DocumentObject to this object
|
||||
super(_FemMeshBoundaryLayer, self).__init__(obj)
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyInteger",
|
||||
@@ -67,13 +70,3 @@ class _FemMeshBoundaryLayer:
|
||||
"MeshBoundaryLayerShapes",
|
||||
"List of FEM mesh region shapes"
|
||||
)
|
||||
|
||||
def execute(self, obj):
|
||||
return
|
||||
|
||||
def __getstate__(self):
|
||||
return self.Type
|
||||
|
||||
def __setstate__(self, state):
|
||||
if state:
|
||||
self.Type = state
|
||||
|
||||
Reference in New Issue
Block a user