diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index 17ed01b137da..7caa9eb708e5 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -37,6 +37,7 @@ from DraftGui import todo from PathScripts import PathUtils from PathScripts.PathGeom import * +from PathScripts.PathPreferences import * from PySide import QtCore, QtGui from pivy import coin @@ -1074,28 +1075,32 @@ def updatePoint(self): self.pt = FreeCAD.Vector(x, y, z) class HoldingTagMarker: - def __init__(self, p): - self.point = p + def __init__(self, point, colors): + self.point = point + self.color = colors self.sep = coin.SoSeparator() self.pos = coin.SoTranslation() - self.pos.translation = (p.x, p.y, p.z) + self.pos.translation = (point.x, point.y, point.z) self.sphere = coin.SoSphere() self.material = coin.SoMaterial() self.sep.addChild(self.pos) self.sep.addChild(self.material) self.sep.addChild(self.sphere) + self.enabled = True + self.selected = False def setSelected(self, select): self.selected = select self.sphere.radius = 1.5 if select else 1.0 + self.setEnabled(self.enabled) def setEnabled(self, enabled): self.enabled = enabled if enabled: - self.material.diffuseColor = coin.SbColor(0.0, 1.0, 0.0) + self.material.diffuseColor = self.color[0] if not self.selected else self.color[2] self.material.transparency = 0.0 else: - self.material.diffuseColor = coin.SbColor(0.8, 0.8, 0.8) + self.material.diffuseColor = self.color[1] if not self.selected else self.color[2] self.material.transparency = 0.6 class ViewProviderDressup: @@ -1103,7 +1108,20 @@ class ViewProviderDressup: def __init__(self, vobj): vobj.Proxy = self + def setupColors(self): + def colorForColorValue(val): + v = [((val >> n) & 0xff) / 255. for n in [24, 16, 8, 0]] + return coin.SbColor(v[0], v[1], v[2]) + + pref = PathPreferences.preferences() + # R G B A + npc = pref.GetUnsigned("DefaultPathMarkerColor", (( 85*256 + 255)*256 + 0)*256 + 255) + hpc = pref.GetUnsigned("DefaultHighlightPathColor", ((255*256 + 125)*256 + 0)*256 + 255) + dpc = pref.GetUnsigned("DefaultDisabledPathColor", ((205*256 + 205)*256 + 205)*256 + 154) + self.colors = [colorForColorValue(npc), colorForColorValue(dpc), colorForColorValue(hpc)] + def attach(self, vobj): + self.setupColors() self.obj = vobj.Object self.tags = [] self.switch = coin.SoSwitch() @@ -1164,7 +1182,7 @@ def updateData(self, obj, propName): self.switch.removeChild(tag.sep) tags = [] for i, p in enumerate(obj.Positions): - tag = HoldingTagMarker(p) + tag = HoldingTagMarker(p, self.colors) tag.setEnabled(not i in obj.Disabled) tags.append(tag) self.switch.addChild(tag.sep) diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py index ab155ab2f710..e1fe309120c9 100644 --- a/src/Mod/Path/PathScripts/PathPreferences.py +++ b/src/Mod/Path/PathScripts/PathPreferences.py @@ -31,6 +31,10 @@ class PathPreferences: PostProcessorDefaultArgs = "PostProcessorDefaultArgs" PostProcessorBlacklist = "PostProcessorBlacklist" + @classmethod + def preferences(cls): + return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") + @classmethod def allAvailablePostProcessors(cls): path = FreeCAD.getHomePath() + ("Mod/Path/PathScripts/") @@ -58,28 +62,28 @@ def allEnabledPostProcessors(cls, include = None): @classmethod def defaultPostProcessor(cls): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - return preferences.GetString(cls.PostProcessorDefault, "") + pref = cls.preferences() + return pref.GetString(cls.PostProcessorDefault, "") @classmethod def defaultPostProcessorArgs(cls): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - return preferences.GetString(cls.PostProcessorDefaultArgs, "") + pref = cls.preferences() + return pref.GetString(cls.PostProcessorDefaultArgs, "") @classmethod def postProcessorBlacklist(cls): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - blacklist = preferences.GetString(cls.PostProcessorBlacklist, "") + pref = cls.preferences() + blacklist = pref.GetString(cls.PostProcessorBlacklist, "") if not blacklist: return [] return eval(blacklist) @classmethod def savePostProcessorDefaults(cls, processor, args, blacklist): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - preferences.SetString(cls.PostProcessorDefault, processor) - preferences.SetString(cls.PostProcessorDefaultArgs, args) - preferences.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist)) + pref = cls.preferences() + pref.SetString(cls.PostProcessorDefault, processor) + pref.SetString(cls.PostProcessorDefaultArgs, args) + pref.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist)) DefaultOutputFile = "DefaultOutputFile" @@ -87,16 +91,16 @@ def savePostProcessorDefaults(cls, processor, args, blacklist): @classmethod def saveOutputFileDefaults(cls, file, policy): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - preferences.SetString(cls.DefaultOutputFile, file) - preferences.SetString(cls.DefaultOutputPolicy, policy) + pref = cls.preferences() + pref.SetString(cls.DefaultOutputFile, file) + pref.SetString(cls.DefaultOutputPolicy, policy) @classmethod def defaultOutputFile(cls): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - return preferences.GetString(cls.DefaultOutputFile, "") + pref = cls.preferences() + return pref.GetString(cls.DefaultOutputFile, "") @classmethod def defaultOutputPolicy(cls): - preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path") - return preferences.GetString(cls.DefaultOutputPolicy, "") + pref = cls.preferences() + return pref.GetString(cls.DefaultOutputPolicy, "")