Draft: fix small warning for the DraftLink class used in arrays
This commit is contained in:
@@ -34,13 +34,13 @@ the arrays that use it.
|
|||||||
# \ingroup DRAFT
|
# \ingroup DRAFT
|
||||||
# \brief Provides the object code for the Draft Link object.
|
# \brief Provides the object code for the Draft Link object.
|
||||||
|
|
||||||
|
import lazy_loader.lazy_loader as lz
|
||||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||||
|
|
||||||
import FreeCAD as App
|
import FreeCAD as App
|
||||||
import lazy_loader.lazy_loader as lz
|
|
||||||
|
|
||||||
from draftobjects.base import DraftObject
|
|
||||||
from draftutils.messages import _wrn
|
from draftutils.messages import _wrn
|
||||||
|
from draftobjects.base import DraftObject
|
||||||
|
|
||||||
# Delay import of module until first use because it is heavy
|
# Delay import of module until first use because it is heavy
|
||||||
Part = lz.LazyLoader("Part", globals(), "Part")
|
Part = lz.LazyLoader("Part", globals(), "Part")
|
||||||
@@ -82,20 +82,27 @@ class DraftLink(DraftObject):
|
|||||||
def canLinkProperties(self, _obj):
|
def canLinkProperties(self, _obj):
|
||||||
"""Link properties.
|
"""Link properties.
|
||||||
|
|
||||||
TODO: add more explanation. C++ override???"""
|
TODO: add more explanation. Overrides a C++ method?
|
||||||
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def linkSetup(self, obj):
|
def linkSetup(self, obj):
|
||||||
"""Set up the link properties on attachment."""
|
"""Set up the link properties on attachment."""
|
||||||
obj.configLinkProperty('Placement', LinkedObject='Base')
|
obj.configLinkProperty('Placement', LinkedObject='Base')
|
||||||
|
|
||||||
if hasattr(obj, 'ShowElement'):
|
if hasattr(obj, 'ShowElement'):
|
||||||
# Rename 'ShowElement' property to 'ExpandArray' to avoid conflict
|
# Rename 'ShowElement' property to 'ExpandArray' to avoid conflict
|
||||||
# with native App::Link
|
# with native App::Link
|
||||||
obj.configLinkProperty('ShowElement')
|
obj.configLinkProperty('ShowElement')
|
||||||
showElement = obj.ShowElement
|
showElement = obj.ShowElement
|
||||||
|
|
||||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||||
"Show array element as children object")
|
"Show the individual array elements")
|
||||||
obj.addProperty("App::PropertyBool", "ExpandArray", "Draft", _tip)
|
obj.addProperty("App::PropertyBool",
|
||||||
|
"ExpandArray",
|
||||||
|
"Draft",
|
||||||
|
_tip)
|
||||||
|
|
||||||
obj.ExpandArray = showElement
|
obj.ExpandArray = showElement
|
||||||
obj.configLinkProperty(ShowElement='ExpandArray')
|
obj.configLinkProperty(ShowElement='ExpandArray')
|
||||||
obj.removeProperty('ShowElement')
|
obj.removeProperty('ShowElement')
|
||||||
@@ -110,12 +117,12 @@ class DraftLink(DraftObject):
|
|||||||
if not hasattr(obj, 'LinkTransform'):
|
if not hasattr(obj, 'LinkTransform'):
|
||||||
obj.addProperty('App::PropertyBool',
|
obj.addProperty('App::PropertyBool',
|
||||||
'LinkTransform',
|
'LinkTransform',
|
||||||
' Link')
|
'Link')
|
||||||
|
|
||||||
if not hasattr(obj, 'ColoredElements'):
|
if not hasattr(obj, 'ColoredElements'):
|
||||||
obj.addProperty('App::PropertyLinkSubHidden',
|
obj.addProperty('App::PropertyLinkSubHidden',
|
||||||
'ColoredElements',
|
'ColoredElements',
|
||||||
' Link')
|
'Link')
|
||||||
obj.setPropertyStatus('ColoredElements', 'Hidden')
|
obj.setPropertyStatus('ColoredElements', 'Hidden')
|
||||||
|
|
||||||
obj.configLinkProperty('LinkTransform', 'ColoredElements')
|
obj.configLinkProperty('LinkTransform', 'ColoredElements')
|
||||||
@@ -138,8 +145,8 @@ class DraftLink(DraftObject):
|
|||||||
# all models should use 'use_link' by default
|
# all models should use 'use_link' by default
|
||||||
# and this won't be run.
|
# and this won't be run.
|
||||||
self.use_link = bool(self.useLink)
|
self.use_link = bool(self.useLink)
|
||||||
_wrn("Migrating 'useLink' to 'use_link', "
|
_wrn("v0.19, {}, 'useLink' will be migrated "
|
||||||
"{} ({})\n".format(obj.Label, obj.TypeId))
|
"to 'use_link'".format(obj.Label))
|
||||||
del self.useLink
|
del self.useLink
|
||||||
|
|
||||||
def onDocumentRestored(self, obj):
|
def onDocumentRestored(self, obj):
|
||||||
@@ -215,4 +222,5 @@ class DraftLink(DraftObject):
|
|||||||
obj.setPropertyStatus('PlacementList', 'Immutable')
|
obj.setPropertyStatus('PlacementList', 'Immutable')
|
||||||
|
|
||||||
|
|
||||||
|
# Alias for compatibility with old versions of v0.19
|
||||||
_DraftLink = DraftLink
|
_DraftLink = DraftLink
|
||||||
|
|||||||
Reference in New Issue
Block a user