From f1554faec796ad686f4e280d28fedd1281bdac82 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 3 Mar 2020 21:04:25 +0100 Subject: [PATCH] FEM: use python base constraint class, constraint self weight --- .../_ViewProviderFemConstraintSelfWeight.py | 44 +------------------ .../femobjects/_FemConstraintSelfWeight.py | 14 +++--- 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py index ad13c98de8..2c7e4a75e7 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemConstraintSelfWeight.py @@ -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 diff --git a/src/Mod/Fem/femobjects/_FemConstraintSelfWeight.py b/src/Mod/Fem/femobjects/_FemConstraintSelfWeight.py index b22e843467..d302690a65 100644 --- a/src/Mod/Fem/femobjects/_FemConstraintSelfWeight.py +++ b/src/Mod/Fem/femobjects/_FemConstraintSelfWeight.py @@ -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