FEM: use python base constraint class, constraint self weight

This commit is contained in:
Bernd Hahnebach
2020-03-03 21:04:25 +01:00
parent 5791bdddf0
commit f1554faec7
2 changed files with 10 additions and 48 deletions

View File

@@ -28,51 +28,11 @@ __url__ = "http://www.freecadweb.org"
# \ingroup FEM
# \brief FreeCAD FEM Constraint SelfWeight ViewProvider
import FreeCAD
import FreeCADGui
import FemGui # needed to display the icons in TreeView
False if FemGui.__name__ else True # flake8, dummy FemGui usage
from . import ViewProviderFemConstraint
class _ViewProviderFemConstraintSelfWeight:
class _ViewProviderFemConstraintSelfWeight(ViewProviderFemConstraint.ViewProxy):
"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
def updateData(self, obj, prop):
return
def onChanged(self, vobj, prop):
return
def setEdit(self, vobj, mode=0):
# avoid edit mode by return False
# https://forum.freecadweb.org/viewtopic.php?t=12139&start=10#p161062
return False
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

View File

@@ -27,10 +27,17 @@ __url__ = "http://www.freecadweb.org"
# \ingroup FEM
# \brief FreeCAD FEM constraint self weight object
from . import FemConstraint
class _FemConstraintSelfWeight:
class _FemConstraintSelfWeight(FemConstraint.Proxy):
"The FemConstraintSelfWeight object"
Type = "Fem::ConstraintSelfWeight"
def __init__(self, obj):
super(_FemConstraintSelfWeight, self).__init__(obj)
obj.addProperty(
"App::PropertyFloat",
"Gravity_x",
@@ -52,8 +59,3 @@ class _FemConstraintSelfWeight:
obj.Gravity_x = 0.0
obj.Gravity_y = 0.0
obj.Gravity_z = -1.0
obj.Proxy = self
self.Type = "Fem::ConstraintSelfWeight"
def execute(self, obj):
return