assembly: change AsmElement icon when detached

This commit is contained in:
Zheng, Lei 2019-01-12 21:17:42 +08:00
parent 2595c27684
commit 363602e0f0
2 changed files with 18 additions and 5 deletions

View File

@ -787,6 +787,7 @@ class AsmElement(AsmBase):
class ViewProviderAsmElement(ViewProviderAsmOnTop):
_iconName = 'Assembly_Assembly_Element.svg'
_iconDisabledName = 'Assembly_Assembly_ElementDetached.svg'
def __init__(self,vobj):
vobj.ShapeColor = self.getDefaultColor()
@ -824,6 +825,14 @@ class ViewProviderAsmElement(ViewProviderAsmOnTop):
from . import mover
return mover.movePart()
def getIcon(self):
return utils.getIcon(self.__class__,
getattr(self.ViewObject.Object,'Detach',False))
def updateData(self,_obj,prop):
if prop == 'Detach':
self.ViewObject.signalChangeIcon()
class AsmElementSketch(AsmElement):
def __init__(self,obj,parent):

View File

@ -34,11 +34,15 @@ def getIcon(obj,disabled=False,path=None):
if not disabled:
return obj._icon
if not getattr(obj,'_iconDisabled',None):
pixmap = obj._icon.pixmap(*iconSize,mode=QIcon.Disabled)
icon = QIcon(pixmapDisabled)
icon.paint(QPainter(pixmap),
0,0,iconSize[0],iconSize[1],Qt.AlignCenter)
obj._iconDisabled = QIcon(pixmap)
name = getattr(obj,'_iconDisabledName',None)
if name:
obj._iconDisabled = QIcon(os.path.join(path,name))
else:
pixmap = obj._icon.pixmap(*iconSize,mode=QIcon.Disabled)
icon = QIcon(pixmapDisabled)
icon.paint(QPainter(pixmap),
0,0,iconSize[0],iconSize[1],Qt.AlignCenter)
obj._iconDisabled = QIcon(pixmap)
return obj._iconDisabled
def addIconToFCAD(iconFile,path=None):