OnDelete implementations

Unhide originals when deleting features that hide originals.
Special logic with explode (prevent unhiding), to be able to delete
unneeded stuff easily.
This commit is contained in:
DeepSOIC 2015-10-18 21:54:53 +03:00
parent 180eb77733
commit 0babf30fdd
3 changed files with 28 additions and 1 deletions

View File

@ -155,7 +155,9 @@ class _ViewProviderCompoundFilter:
def __init__(self,vobj):
vobj.Proxy = self
vobj.addProperty("App::PropertyBool","DontUnhideOnDelete","CompoundFilter","When this object is deleted, Base and Stencil are unhidden. This flag stops it from happening.")
vobj.setEditorMode("DontUnhideOnDelete", 2) # set hidden
def getIcon(self):
return getIconPath("Lattice_CompoundFilter.svg")
@ -182,6 +184,16 @@ class _ViewProviderCompoundFilter:
children.append(self.Object.Stencil)
return children
def onDelete(self, feature, subelements): # subelements is a tuple of strings
if not self.ViewObject.DontUnhideOnDelete:
try:
self.Object.Base.ViewObject.show()
if self.Object.Stencil:
self.Object.Stencil.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True
def CreateCompoundFilter(name):
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction("Create CompoundFilter")
@ -253,6 +265,7 @@ class _CommandExplode:
cf.Base = obj
cf.FilterType = 'specific items'
cf.items = str(i)
cf.ViewObject.DontUnhideOnDelete = True
FreeCAD.ActiveDocument.recompute()
except Exception:
FreeCAD.ActiveDocument.abortTransaction()

View File

@ -92,6 +92,13 @@ class _ViewProviderFuseCompound:
def claimChildren(self):
return [self.Object.Base]
def onDelete(self, feature, subelements): # subelements is a tuple of strings
try:
self.Object.Base.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True
def CreateFuseCompound(name):
FreeCAD.ActiveDocument.openTransaction("Create FuseCompound")

View File

@ -119,6 +119,13 @@ class _ViewProviderLatticeDowngrade:
def claimChildren(self):
return [self.Object.Base]
def onDelete(self, feature, subelements): # subelements is a tuple of strings
try:
self.Object.Base.ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True
def CreateLatticeDowngrade(name, mode = "Wires"):
FreeCAD.ActiveDocument.openTransaction("Create latticeDowngrade")