FEM: use python base constraint class, constraint tie

This commit is contained in:
Bernd Hahnebach
2020-03-03 21:04:29 +01:00
parent d4f60113c6
commit 0aad1a0164
2 changed files with 16 additions and 64 deletions

View File

@@ -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, QtGui
from . import FemSelectionWidgets
False if FemGui.__name__ else True # flake8, dummy FemGui usage
class _ViewProviderFemConstraintTie:
class _ViewProviderFemConstraintTie(ViewProviderFemConstraint.ViewProxy):
"A View Provider for the FemConstraintTie object"
def __init__(self, vobj):
vobj.Proxy = self
def getIcon(self):
return ":/icons/fem-constraint-tie.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 = _TaskPanelFemConstraintTie(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,
_TaskPanelFemConstraintTie
)
class _TaskPanelFemConstraintTie:

View File

@@ -27,18 +27,20 @@ __url__ = "https://www.freecadweb.org"
# \ingroup FEM
# \brief FreeCAD FEM constraint tie object
from . import FemConstraint
class _FemConstraintTie:
class _FemConstraintTie(FemConstraint.Proxy):
"The FemConstraintTie object"
Type = "Fem::ConstraintTie"
def __init__(self, obj):
super(_FemConstraintTie, self).__init__(obj)
obj.addProperty(
"App::PropertyLength",
"Tolerance",
"Geometry",
"set max gap between tied faces"
)
obj.Proxy = self
self.Type = "Fem::ConstraintTie"
def execute(self, obj):
return