Skip to content

Commit

Permalink
Draft: Layer, Separate Line color and shape color override
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeL63 authored and berndhahnebach committed Dec 23, 2019
1 parent a00eec9 commit a0e88df
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Mod/Draft/DraftLayer.py
Expand Up @@ -129,15 +129,17 @@ class ViewProviderLayer:
"""A View Provider for the Layer object"""

def __init__(self,vobj):
vobj.addProperty("App::PropertyBool","OverrideChildren","Layer",QT_TRANSLATE_NOOP("App::Property","If on, the child objects of this layer will match its visual aspects"))
vobj.addProperty("App::PropertyBool", "OverrideLineColorChildren", "Layer", QT_TRANSLATE_NOOP("App::Property", "If on, the child objects of this layer will match its visual aspects"))
vobj.addProperty("App::PropertyBool", "OverrideShapeColorChildren", "Layer", QT_TRANSLATE_NOOP("App::Property", "If on, the child objects of this layer will match its visual aspects"))
vobj.addProperty("App::PropertyColor","LineColor","Layer",QT_TRANSLATE_NOOP("App::Property","The line color of the children of this layer"))
vobj.addProperty("App::PropertyColor","ShapeColor","Layer",QT_TRANSLATE_NOOP("App::Property","The shape color of the children of this layer"))
vobj.addProperty("App::PropertyFloat","LineWidth","Layer",QT_TRANSLATE_NOOP("App::Property","The line width of the children of this layer"))
vobj.addProperty("App::PropertyEnumeration","DrawStyle","Layer",QT_TRANSLATE_NOOP("App::Property","The draw style of the children of this layer"))
vobj.addProperty("App::PropertyInteger","Transparency","Layer",QT_TRANSLATE_NOOP("App::Property","The transparency of the children of this layer"))
vobj.DrawStyle = ["Solid","Dashed","Dotted","Dashdot"]

vobj.OverrideChildren = True
vobj.OverrideLineColorChildren = True
vobj.OverrideShapeColorChildren = True
c = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("DefaultShapeLineColor",255)
vobj.LineColor = (((c>>24)&0xFF)/255.0,((c>>16)&0xFF)/255.0,((c>>8)&0xFF)/255.0)
w = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetInt("DefaultShapeLineWidth",2)
Expand Down Expand Up @@ -185,16 +187,21 @@ def updateData(self,obj,prop):
self.onChanged(obj.ViewObject,"LineColor")

def onChanged(self,vobj,prop):
if hasattr(vobj,"OverrideChildren") and vobj.OverrideChildren:
if hasattr(vobj,"OverrideLineColorChildren") and vobj.OverrideLineColorChildren:
if hasattr(vobj,"Object")and hasattr(vobj.Object,"Group"):
for o in vobj.Object.Group:
if o.ViewObject:
for p in ["LineColor","ShapeColor","LineWidth","DrawStyle","Transparency"]:
if hasattr(vobj,p) and hasattr(o.ViewObject,p):
setattr(o.ViewObject,p,getattr(vobj,p))
# give line color to texts
if hasattr(vobj,"LineColor") and hasattr(o.ViewObject,"TextColor"):
o.ViewObject.TextColor = vobj.LineColor
if p == "ShapeColor":
if hasattr(vobj, "OverrideShapeColorChildren") and vobj.OverrideShapeColorChildren:
setattr(o.ViewObject, p, getattr(vobj, p))
else:
if hasattr(vobj, p) and hasattr(o.ViewObject,p):
setattr(o.ViewObject,p,getattr(vobj,p))

# give line color to texts
if hasattr(vobj,"LineColor") and hasattr(o.ViewObject,"TextColor"):
o.ViewObject.TextColor = vobj.LineColor

if (prop == "Visibility") and hasattr(vobj,"Visibility"):
if hasattr(vobj,"Object")and hasattr(vobj.Object,"Group"):
Expand Down

0 comments on commit a0e88df

Please sign in to comment.