@@ -486,12 +486,16 @@ def _get_param_dictionary():
|
||||
"BackgroundColor": ("unsigned", 336897023),
|
||||
"BackgroundColor2": ("unsigned", 859006463),
|
||||
"BackgroundColor3": ("unsigned", 2543299327),
|
||||
"DefaultAmbientColor": ("unsigned", 1431655935),
|
||||
"DefaultEmissiveColor": ("unsigned", 255),
|
||||
"DefaultShapeColor": ("unsigned", 3435980543),
|
||||
"DefaultShapeLineColor": ("unsigned", 421075455),
|
||||
"DefaultShapeLineWidth": ("int", 2),
|
||||
"DefaultShapePointSize": ("int", 2),
|
||||
"DefaultShapeShininess": ("int", 90),
|
||||
"DefaultShapeTransparency": ("int", 0),
|
||||
"DefaultShapeVertexColor": ("unsigned", 421075455),
|
||||
"DefaultSpecularColor": ("unsigned", 2290649343),
|
||||
"EnableSelection": ("bool", True),
|
||||
"Gradient": ("bool", True),
|
||||
"MarkerSize": ("int", 9),
|
||||
@@ -580,7 +584,7 @@ def _get_param_dictionary():
|
||||
PARAM_DICT = _get_param_dictionary()
|
||||
|
||||
|
||||
def get_param(entry, path="Mod/Draft"):
|
||||
def get_param(entry, path="Mod/Draft", ret_default=False):
|
||||
"""Return a stored parameter value or its default.
|
||||
|
||||
Parameters
|
||||
@@ -591,6 +595,9 @@ def get_param(entry, path="Mod/Draft"):
|
||||
Defaults to "Mod/Draft".
|
||||
The path where the parameter can be found.
|
||||
This string is appended to "User parameter:BaseApp/Preferences/".
|
||||
ret_default: bool, optional
|
||||
Defaults to `False`.
|
||||
If `True`, always return the default value even if a stored value is available.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -601,6 +608,8 @@ def get_param(entry, path="Mod/Draft"):
|
||||
return None
|
||||
param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
|
||||
typ, default = PARAM_DICT[path][entry]
|
||||
if ret_default:
|
||||
return default
|
||||
if typ == "bool":
|
||||
return param_grp.GetBool(entry, default)
|
||||
if typ == "float":
|
||||
@@ -614,12 +623,12 @@ def get_param(entry, path="Mod/Draft"):
|
||||
return None
|
||||
|
||||
|
||||
def get_param_arch(entry):
|
||||
return get_param(entry, path="Mod/Arch")
|
||||
def get_param_arch(entry, ret_default=False):
|
||||
return get_param(entry, path="Mod/Arch", ret_default=ret_default)
|
||||
|
||||
|
||||
def get_param_view(entry):
|
||||
return get_param(entry, path="View")
|
||||
def get_param_view(entry, ret_default=False):
|
||||
return get_param(entry, path="View", ret_default=ret_default)
|
||||
|
||||
|
||||
def set_param(entry, value, path="Mod/Draft"):
|
||||
|
||||
@@ -88,17 +88,35 @@ def get_default_shape_style():
|
||||
display_mode_index = params.get_param("DefaultDisplayMode")
|
||||
draw_style_index = params.get_param("DefaultDrawStyle")
|
||||
return {
|
||||
"DisplayMode": ("index", display_mode_index, DISPLAY_MODES[display_mode_index]),
|
||||
"DrawStyle": ("index", draw_style_index, DRAW_STYLES[draw_style_index]),
|
||||
"LineColor": ("color", params.get_param_view("DefaultShapeLineColor")),
|
||||
"LineWidth": ("int", params.get_param_view("DefaultShapeLineWidth")),
|
||||
"PointColor": ("color", params.get_param_view("DefaultShapeVertexColor")),
|
||||
"PointSize": ("int", params.get_param_view("DefaultShapePointSize")),
|
||||
"ShapeColor": ("color", params.get_param_view("DefaultShapeColor")),
|
||||
"Transparency": ("int", params.get_param_view("DefaultShapeTransparency"))
|
||||
"DisplayMode": ("index", display_mode_index, DISPLAY_MODES[display_mode_index]),
|
||||
"DrawStyle": ("index", draw_style_index, DRAW_STYLES[draw_style_index]),
|
||||
"LineColor": ("color", params.get_param_view("DefaultShapeLineColor")),
|
||||
"LineWidth": ("int", params.get_param_view("DefaultShapeLineWidth")),
|
||||
"PointColor": ("color", params.get_param_view("DefaultShapeVertexColor")),
|
||||
"PointSize": ("int", params.get_param_view("DefaultShapePointSize")),
|
||||
"ShapeAppearance": ("material", (get_appearance_material(), ))
|
||||
}
|
||||
|
||||
|
||||
def get_appearance_material(ret_default=False):
|
||||
"""Return a ShapeAppearance material with properties based on the preferences.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
ret_default: bool, optional
|
||||
Defaults to `False`.
|
||||
If `True`, always use default preference values even if stored values are available.
|
||||
"""
|
||||
material = App.Material()
|
||||
material.AmbientColor = params.get_param_view("DefaultAmbientColor", ret_default=ret_default)
|
||||
material.DiffuseColor = params.get_param_view("DefaultShapeColor", ret_default=ret_default)
|
||||
material.EmissiveColor = params.get_param_view("DefaultEmissiveColor", ret_default=ret_default)
|
||||
material.Shininess = params.get_param_view("DefaultShapeShininess", ret_default=ret_default) / 100
|
||||
material.SpecularColor = params.get_param_view("DefaultSpecularColor", ret_default=ret_default)
|
||||
material.Transparency = params.get_param_view("DefaultShapeTransparency", ret_default=ret_default) / 100
|
||||
return material
|
||||
|
||||
|
||||
def string_encode_coin(ustr):
|
||||
"""Encode a unicode object to be used as a string in coin.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user