diff --git a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py index 4e8dbe422a..dba68203da 100644 --- a/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py +++ b/src/Mod/Fem/femguiobjects/_ViewProviderFemElementRotation1D.py @@ -30,84 +30,30 @@ __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 _ViewProviderFemElementRotation1D: +class _ViewProviderFemElementRotation1D(ViewProviderFemConstraint.ViewProxy): "A View Provider for the FemElementRotation1D object" - def __init__(self, vobj): - vobj.Proxy = self def getIcon(self): return ":/icons/fem-element-rotation-1d.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 - """ # do not activate the task panel, since rotation with reference shapes is not yet supported 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 = _TaskPanelFemElementRotation1D(self.Object) - taskd.obj = vobj.Object - FreeCADGui.Control.showDialog(taskd) - return True - - def unsetEdit(self, vobj, mode=0): - FreeCADGui.Control.closeDialog() - return True + ViewProviderFemConstraint.ViewProxy.setEdit( + self, + vobj, + mode, + _TaskPanelFemElementRotation1D + ) """ - 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 - class _TaskPanelFemElementRotation1D: """The TaskPanel for editing References property of FemElementRotation1D objects""" diff --git a/src/Mod/Fem/femobjects/_FemElementRotation1D.py b/src/Mod/Fem/femobjects/_FemElementRotation1D.py index a62cec292a..19c18855a3 100644 --- a/src/Mod/Fem/femobjects/_FemElementRotation1D.py +++ b/src/Mod/Fem/femobjects/_FemElementRotation1D.py @@ -27,11 +27,16 @@ __url__ = "https://www.freecadweb.org" # \ingroup FEM # \brief FreeCAD FEM element rotation 1D object +from . import FemConstraint -class _FemElementRotation1D: + +class _FemElementRotation1D(FemConstraint.Proxy): "The FemElementRotation1D object" + Type = "Fem::ElementRotation1D" + def __init__(self, obj): + super(_FemElementRotation1D, self).__init__(obj) obj.addProperty( "App::PropertyAngle", "Rotation", @@ -44,8 +49,3 @@ class _FemElementRotation1D: "BeamRotation", "List of beam rotation shapes" ) - obj.Proxy = self - self.Type = "Fem::ElementRotation1D" - - def execute(self, obj): - return