BaseFeature: improve attacher disabling
This commit is contained in:
parent
7d2d62bdea
commit
a192e19209
|
@ -40,7 +40,7 @@ EDIT_ATTACHMENT = 56 # Viewprovider edit mode number
|
||||||
def makeAttachablePlacement(name):
|
def makeAttachablePlacement(name):
|
||||||
'''makeAttachablePlacement(name): makes an attachable Placement object.'''
|
'''makeAttachablePlacement(name): makes an attachable Placement object.'''
|
||||||
if Compat.attach_extension_era:
|
if Compat.attach_extension_era:
|
||||||
obj = lattice2BaseFeature.makeLatticeFeature(name, AttachablePlacement, ViewProviderAttachablePlacement, no_disable_attacher= True)
|
obj = lattice2BaseFeature.makeLatticeFeature(name, AttachablePlacement, ViewProviderAttachablePlacement)
|
||||||
else:
|
else:
|
||||||
#obsolete!
|
#obsolete!
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::AttachableObjectPython",name)
|
obj = FreeCAD.ActiveDocument.addObject("Part::AttachableObjectPython",name)
|
||||||
|
@ -53,16 +53,13 @@ def makeAttachablePlacement(name):
|
||||||
class AttachableFeature(lattice2BaseFeature.LatticeFeature):
|
class AttachableFeature(lattice2BaseFeature.LatticeFeature):
|
||||||
"Base class for attachable features"
|
"Base class for attachable features"
|
||||||
|
|
||||||
|
attachable = True
|
||||||
|
|
||||||
def derivedInit(self,obj):
|
def derivedInit(self,obj):
|
||||||
if Compat.attach_extension_era:
|
if Compat.attach_extension_era:
|
||||||
if not obj.hasExtension('Part::AttachExtension'): #PartDesign-related hack: the placement already has attachextension if created in PD
|
if not obj.hasExtension('Part::AttachExtension'): #PartDesign-related hack: the placement already has attachextension if created in PD
|
||||||
obj.addExtension('Part::AttachExtensionPython', None)
|
obj.addExtension('Part::AttachExtensionPython', None)
|
||||||
|
|
||||||
def onDocumentRestored(self, selfobj):
|
|
||||||
#PartDesign-related hack: this dummy override disables disabling of attacher
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class AttachablePlacement(AttachableFeature):
|
class AttachablePlacement(AttachableFeature):
|
||||||
"Attachable Lattice Placement object"
|
"Attachable Lattice Placement object"
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,10 @@ def getDefShapeColor():
|
||||||
return (r/255.0, g/255.0, b/255.0, (255-o)/255.0)
|
return (r/255.0, g/255.0, b/255.0, (255-o)/255.0)
|
||||||
|
|
||||||
|
|
||||||
def makeLatticeFeature(name, AppClass, ViewClass, no_body = False, no_disable_attacher = False):
|
def makeLatticeFeature(name, AppClass, ViewClass, no_body = False):
|
||||||
'''makeLatticeFeature(name, AppClass, ViewClass, no_body = False): makes a document object for a LatticeFeature-derived object.
|
'''makeLatticeFeature(name, AppClass, ViewClass, no_body = False): makes a document object for a LatticeFeature-derived object.
|
||||||
|
|
||||||
no_body: if False, the Lattice object will end up in an active body, and Part2DObject will be used.
|
no_body: if False, the Lattice object will end up in an active body, and Part2DObject will be used.'''
|
||||||
no_disable_attacher: if True, attachment properties of Part2DObject won't be hidden'''
|
|
||||||
|
|
||||||
body = activeBody()
|
body = activeBody()
|
||||||
if body and not no_body:
|
if body and not no_body:
|
||||||
|
@ -105,6 +104,8 @@ def getMarkerSizeEstimate(ListOfPlacements):
|
||||||
class LatticeFeature(object):
|
class LatticeFeature(object):
|
||||||
"Base object for lattice objects (arrays of placements)"
|
"Base object for lattice objects (arrays of placements)"
|
||||||
|
|
||||||
|
attachable = False
|
||||||
|
|
||||||
def __init__(self,obj):
|
def __init__(self,obj):
|
||||||
# please, don't override. Override derivedInit instead.
|
# please, don't override. Override derivedInit instead.
|
||||||
obj.addProperty('App::PropertyString', 'Type', "Lattice", "module_name.class_name of this object, for proxy recovery", 0, True, True)
|
obj.addProperty('App::PropertyString', 'Type', "Lattice", "module_name.class_name of this object, for proxy recovery", 0, True, True)
|
||||||
|
@ -134,6 +135,10 @@ class LatticeFeature(object):
|
||||||
self.derivedInit(obj)
|
self.derivedInit(obj)
|
||||||
self.assureProperties(obj)
|
self.assureProperties(obj)
|
||||||
|
|
||||||
|
self.updateReadonlyness(obj)
|
||||||
|
if not self.attachable:
|
||||||
|
self.disableAttacher(obj)
|
||||||
|
|
||||||
obj.Proxy = self
|
obj.Proxy = self
|
||||||
|
|
||||||
def assureProperties(self, selfobj):
|
def assureProperties(self, selfobj):
|
||||||
|
@ -357,7 +362,7 @@ class LatticeFeature(object):
|
||||||
selfobj.MapMode = selfobj.MapMode #trigger attachment, to make it update property states
|
selfobj.MapMode = selfobj.MapMode #trigger attachment, to make it update property states
|
||||||
|
|
||||||
def onDocumentRestored(self, selfobj):
|
def onDocumentRestored(self, selfobj):
|
||||||
#override to have attachment!
|
if not self.attachable:
|
||||||
self.disableAttacher(selfobj)
|
self.disableAttacher(selfobj)
|
||||||
self.assureProperties(selfobj)
|
self.assureProperties(selfobj)
|
||||||
self.updateReadonlyness(selfobj)
|
self.updateReadonlyness(selfobj)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user