add VerifyIntegrity to lattice viewprovider

VerifyIntegrity is a method that checks if standard __init__ method was
overridden by accident, and prints an error.
This commit is contained in:
DeepSOIC 2015-11-11 01:49:20 +03:00
parent 67a50b2a30
commit c8f40a3a80

View File

@ -165,10 +165,12 @@ class LatticeFeature():
def derivedExecute(self,obj): def derivedExecute(self,obj):
'''For overriding by derived class. If this returns a list of placements, '''For overriding by derived class. If this returns a list of placements,
it's going to be used to build the shape. If returns None, it is assumed that it's going to be used to build the shape. If returns None, it is assumed that
derivedExecute has already assigned the shape, and no further actions are needed.''' derivedExecute has already assigned the shape, and no further actions are needed.
Moreover, None is a signal that the object is not a lattice array, and it will
morph into a non-lattice if isLattice is set to auto'''
return [] return []
def verifyIntegrity(self,obj): def verifyIntegrity(self):
if self.__init__.__func__ is not LatticeFeature.__init__.__func__: if self.__init__.__func__ is not LatticeFeature.__init__.__func__:
FreeCAD.Console.PrintError("__init__() of lattice object is overridden. Please don't! Fix it!\n") FreeCAD.Console.PrintError("__init__() of lattice object is overridden. Please don't! Fix it!\n")
if self.execute.__func__ is not LatticeFeature.execute.__func__: if self.execute.__func__ is not LatticeFeature.execute.__func__:
@ -212,6 +214,10 @@ class ViewProviderLatticeFeature:
def derivedInit(self,vobj): def derivedInit(self,vobj):
pass pass
def verifyIntegrity(self):
if self.__init__.__func__ is not ViewProviderLatticeFeature.__init__.__func__:
FreeCAD.Console.PrintError("__init__() of lattice object view provider is overridden. Please don't! Fix it!\n")
def getIcon(self): def getIcon(self):
return getIconPath("Lattice.svg") return getIconPath("Lattice.svg")
@ -233,7 +239,8 @@ class ViewProviderLatticeFeature:
return None return None
def claimChildren(self): def claimChildren(self):
self.Object.Proxy.verifyIntegrity(self.Object) self.Object.Proxy.verifyIntegrity()
self.verifyIntegrity()
return [] return []
def onDelete(self, feature, subelements): # subelements is a tuple of strings def onDelete(self, feature, subelements): # subelements is a tuple of strings