FEM: Python VP objects without task panel, proper prevent edit mode

This commit is contained in:
Bernd Hahnebach
2018-05-21 14:32:09 +02:00
committed by wmayer
parent 5f37a30230
commit a4bb93d559
4 changed files with 53 additions and 4 deletions

View File

@@ -27,8 +27,8 @@ __url__ = "http://www.freecadweb.org"
import FreeCAD
if FreeCAD.GuiUp:
from pivy import coin
import FreeCADGui
from pivy import coin
class ViewProxy(object):
@@ -51,3 +51,17 @@ class ViewProxy(object):
def setDisplayMode(self, mode):
return mode
def setEdit(self, vobj, mode=0):
# needs to be overwritten if task panel exists
# avoid edit mode by return False, https://forum.freecadweb.org/viewtopic.php?t=12139&start=10#p161062
return False
def doubleClicked(self, vobj):
doc = FreeCADGui.getDocument(vobj.Object.Document)
# check if another VP is in edit mode, https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
if not doc.getInEdit():
doc.setEdit(vobj.Object.Name)
else:
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
return True

View File

@@ -27,6 +27,9 @@ __url__ = "http://www.freecadweb.org"
## @package ViewProviderFemConstraintSelfWeight
# \ingroup FEM
import FreeCAD
import FreeCADGui
class _ViewProviderFemConstraintSelfWeight:
"A View Provider for the FemConstraintSelfWeight object"
@@ -46,6 +49,19 @@ class _ViewProviderFemConstraintSelfWeight:
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):
doc = FreeCADGui.getDocument(vobj.Object.Document)
# check if another VP is in edit mode, https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
if not doc.getInEdit():
doc.setEdit(vobj.Object.Name)
else:
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
return True
def __getstate__(self):
return None

View File

@@ -30,7 +30,6 @@ __url__ = "http://www.freecadweb.org"
import FreeCAD
import FreeCADGui
# for the panel
from PySide import QtCore
from PySide import QtGui
@@ -79,15 +78,20 @@ class _ViewProviderFemElementRotation1D:
def unsetEdit(self, vobj, mode=0):
FreeCADGui.Control.closeDialog()
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):
doc = FreeCADGui.getDocument(vobj.Object.Document)
# check if another VP is in edit mode, https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
if not doc.getInEdit():
doc.setEdit(vobj.Object.Name)
else:
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
return True
'''
def __getstate__(self):
return None

View File

@@ -27,6 +27,8 @@ __url__ = "http://www.freecadweb.org"
## @package ViewProviderFemMaterialMechanicalNonLinear
# \ingroup FEM
import FreeCAD
import FreeCADGui
from pivy import coin
@@ -56,6 +58,19 @@ class _ViewProviderFemMaterialMechanicalNonlinear:
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):
doc = FreeCADGui.getDocument(vobj.Object.Document)
# check if another VP is in edit mode, https://forum.freecadweb.org/viewtopic.php?t=13077#p104702
if not doc.getInEdit():
doc.setEdit(vobj.Object.Name)
else:
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
return True
def __getstate__(self):
return None