Skip to content

Commit

Permalink
Arch: Fixed recursive loop in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Feb 27, 2018
1 parent 8aad83f commit ea0f679
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/Mod/Arch/ArchWindow.py
Expand Up @@ -1019,11 +1019,28 @@ def getIcon(self):
return ":/icons/Arch_Window_Tree.svg"

def updateData(self,obj,prop):
if prop == "Shape":
if obj.Base:
if obj.Base.isDerivedFrom("Part::Compound"):
if obj.ViewObject.DiffuseColor != obj.Base.ViewObject.DiffuseColor:
if len(obj.Base.ViewObject.DiffuseColor) > 1:
obj.ViewObject.DiffuseColor = obj.Base.ViewObject.DiffuseColor
obj.ViewObject.update()
elif prop == "CloneOf":
if obj.CloneOf:
mat = None
if hasattr(obj,"Material"):
if obj.Material:
mat = obj.Material
if not mat:
if obj.ViewObject.DiffuseColor != obj.CloneOf.ViewObject.DiffuseColor:
if len(obj.CloneOf.ViewObject.DiffuseColor) > 1:
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
obj.ViewObject.update()
if (prop in ["WindowParts","Shape"]):
if obj.Shape:
if not obj.Shape.isNull():
self.colorize(obj)
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)

def onDelete(self,vobj,subelements):
for o in vobj.Object.Hosts:
Expand Down Expand Up @@ -1073,19 +1090,24 @@ def colorize(self,obj):
ccol = None
if len(obj.WindowParts) > i*5:
name = obj.WindowParts[(i*5)]
typeidx = (i*5)+1
mtype = obj.WindowParts[(i*5)+1]
if hasattr(obj,"Material"):
if obj.Material:
if hasattr(obj.Material,"Materials"):
if obj.Material.Names:
mat = None
if name in obj.Material.Names:
mat = obj.Material.Materials[obj.Material.Names.index(name)]
elif mtype in obj.Material.Names:
mat = obj.Material.Materials[obj.Material.Names.index(mtype)]
if mat:
if 'DiffuseColor' in mat.Material:
if "(" in mat.Material['DiffuseColor']:
ccol = tuple([float(f) for f in mat.Material['DiffuseColor'].strip("()").split(",")])
if 'Transparency' in mat.Material:
ccol = (ccol[0],ccol[1],ccol[2],float(mat.Material['Transparency']))
if not ccol:
typeidx = (i*5)+1
if typeidx < len(obj.WindowParts):
typ = obj.WindowParts[typeidx]
if typ == WindowPartTypes[2]: # transparent parts
Expand All @@ -1095,7 +1117,10 @@ def colorize(self,obj):
colors.extend([ccol for f in solids[i].Faces])
#print("colors: ",colors)
if colors:
obj.ViewObject.DiffuseColor = colors
if colors != obj.ViewObject.DiffuseColor:
if obj.Material and (len(colors) > 1):
print obj.Label,colors
obj.ViewObject.DiffuseColor = colors

class _ArchWindowTaskPanel:
'''The TaskPanel for Arch Windows'''
Expand Down

0 comments on commit ea0f679

Please sign in to comment.