Skip to content

Commit

Permalink
Draft: Now uses general FreeCAD shape colors instead of defining its own
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 3, 2019
1 parent 25c1007 commit b9bcffd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/Mod/Draft/Draft.py
Expand Up @@ -139,6 +139,8 @@ def getParam(param,default=None):
elif t == "unsigned":
if default == None:
default = 0
if param == "color":
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("DefaultShapeLineColor",default)
return p.GetUnsigned(param,default)
else:
return None
Expand All @@ -147,11 +149,19 @@ def setParam(param,value):
"setParam(parameterName,value): sets a Draft parameter with the given value"
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
t = getParamType(param)
if t == "int": p.SetInt(param,value)
elif t == "string": p.SetString(param,value)
elif t == "float": p.SetFloat(param,value)
elif t == "bool": p.SetBool(param,value)
elif t == "unsigned": p.SetUnsigned(param,value)
if t == "int":
p.SetInt(param,value)
elif t == "string":
p.SetString(param,value)
elif t == "float":
p.SetFloat(param,value)
elif t == "bool":
p.SetBool(param,value)
elif t == "unsigned":
if param == "color":
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").SetUnsigned("DefaultShapeLineColor",value)
else:
p.SetUnsigned(param,value)

def precision():
"precision(): returns the precision value from Draft user settings"
Expand Down Expand Up @@ -5754,13 +5764,13 @@ def pathArray(self,shape,pathwire,count,xlate,align):
shape.Placement.Rotation, pathwire, count, xlate, align)

base = []

for placement in placements:
ns = shape.copy()
ns.Placement = placement

base.append(ns)

return (Part.makeCompound(base))

class _PointArray(_DraftObject):
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/Draft/DraftGui.py
Expand Up @@ -345,7 +345,7 @@ def __init__(self):
#print("taskmode: ",str(self.taskmode))
self.paramcolor = Draft.getParam("color",255)>>8
self.color = QtGui.QColor(self.paramcolor)
self.facecolor = QtGui.QColor(204,204,204)
self.facecolor = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("DefaultShapeColor",4294967295)>>8
self.linewidth = Draft.getParam("linewidth",2)
self.fontsize = Draft.getParam("textheight",0.20)
self.paramconstr = Draft.getParam("constructioncolor",746455039)>>8
Expand Down Expand Up @@ -1469,6 +1469,8 @@ def getfacecol(self):
return
self.facecolorPix.fill(self.facecolor)
self.facecolorButton.setIcon(QtGui.QIcon(self.facecolorPix))
if Draft.getParam("saveonexit",False):
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").SetUnsigned("DefaultShapeColor",self.facecolor.rgb()<<8)
r = float(self.facecolor.red()/255.0)
g = float(self.facecolor.green()/255.0)
b = float(self.facecolor.blue()/255.0)
Expand Down

0 comments on commit b9bcffd

Please sign in to comment.