Arch: Fixed window transparency bug
This commit is contained in:
@@ -73,7 +73,7 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"):
|
||||
_Window(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWindow(obj.ViewObject)
|
||||
obj.ViewObject.Transparency=p.GetInt("WindowTransparency",85)
|
||||
#obj.ViewObject.Transparency=p.GetInt("WindowTransparency",85)
|
||||
if width:
|
||||
obj.Width = width
|
||||
if height:
|
||||
@@ -98,8 +98,14 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"):
|
||||
if obj.Base and FreeCAD.GuiUp:
|
||||
obj.Base.ViewObject.DisplayMode = "Wireframe"
|
||||
obj.Base.ViewObject.hide()
|
||||
from DraftGui import todo
|
||||
todo.delay(recolorize,obj)
|
||||
return obj
|
||||
|
||||
def recolorize(obj):
|
||||
if obj.ViewObject:
|
||||
if obj.ViewObject.Proxy:
|
||||
obj.ViewObject.Proxy.colorize(obj,force=True)
|
||||
|
||||
def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None):
|
||||
"""makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,[placement]): makes a
|
||||
@@ -1029,6 +1035,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
if len(obj.Base.ViewObject.DiffuseColor) > 1:
|
||||
obj.ViewObject.DiffuseColor = obj.Base.ViewObject.DiffuseColor
|
||||
obj.ViewObject.update()
|
||||
self.colorize(obj)
|
||||
elif prop == "CloneOf":
|
||||
if obj.CloneOf:
|
||||
mat = None
|
||||
@@ -1040,10 +1047,6 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
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)
|
||||
|
||||
def onDelete(self,vobj,subelements):
|
||||
for o in vobj.Object.Hosts:
|
||||
@@ -1051,12 +1054,10 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
return True
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
if (prop in ["DiffuseColor","ShapeColor","Transparency"]) and vobj.Object:
|
||||
if vobj.Object.Base:
|
||||
if len(vobj.DiffuseColor) < 2:
|
||||
if vobj.Object.Shape:
|
||||
if not vobj.Object.Shape.isNull():
|
||||
self.colorize(vobj.Object)
|
||||
if (prop in ["DiffuseColor","Transparency"]) and vobj.Object:
|
||||
self.colorize(vobj.Object)
|
||||
elif prop == "ShapeColor":
|
||||
self.colorize(vobj.Object,force=True)
|
||||
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
@@ -1080,13 +1081,18 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
return
|
||||
|
||||
def colorize(self,obj):
|
||||
def colorize(self,obj,force=False):
|
||||
"setting different part colors"
|
||||
if obj.CloneOf:
|
||||
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
||||
if self.areDifferentColors(obj.ViewObject.DiffuseColor,obj.CloneOf.ViewObject.DiffuseColor) or force:
|
||||
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
||||
return
|
||||
if not obj.WindowParts:
|
||||
return
|
||||
if not obj.Shape:
|
||||
return
|
||||
if not obj.Shape.Solids:
|
||||
return
|
||||
solids = obj.Shape.copy().Solids
|
||||
#print("Colorizing ", solids)
|
||||
colors = []
|
||||
@@ -1121,9 +1127,16 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
ccol = base
|
||||
colors.extend([ccol for f in solids[i].Faces])
|
||||
#print("colors: ",colors)
|
||||
if len(colors) > 1:
|
||||
if colors != obj.ViewObject.DiffuseColor:
|
||||
obj.ViewObject.DiffuseColor = colors
|
||||
if self.areDifferentColors(colors,obj.ViewObject.DiffuseColor) or force:
|
||||
obj.ViewObject.DiffuseColor = colors
|
||||
|
||||
def areDifferentColors(self,a,b):
|
||||
if len(a) != len(b):
|
||||
return True
|
||||
for i in range(len(a)):
|
||||
if abs(sum(a[i]) - sum(b[i])) > 0.00001:
|
||||
return True
|
||||
return False
|
||||
|
||||
class _ArchWindowTaskPanel:
|
||||
'''The TaskPanel for Arch Windows'''
|
||||
|
||||
@@ -2980,6 +2980,9 @@ def clone(obj,delta=None,forcedraft=False):
|
||||
pass
|
||||
if gui:
|
||||
cl.ViewObject.DiffuseColor = base.ViewObject.DiffuseColor
|
||||
if obj[0].Proxy.Type == "Window":
|
||||
from DraftGui import todo
|
||||
todo.delay(Arch.recolorize,cl)
|
||||
select(cl)
|
||||
return cl
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user