Draft: updates related to transparency to alpha change
This commit is contained in:
@@ -194,7 +194,7 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
|
||||
if hasattr(vobj, attr):
|
||||
try:
|
||||
if vobj.getTypeIdOfProperty(attr) == "App::PropertyColor":
|
||||
value = value & 0xFFFFFF00
|
||||
value = value | 0x000000FF
|
||||
setattr(vobj, attr, value)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -314,7 +314,7 @@ class AddToConstruction(gui_base.GuiCommandNeedsSelection):
|
||||
if not hasattr(Gui, "draftToolBar"):
|
||||
return
|
||||
|
||||
col = params.get_param("constructioncolor") & 0xFFFFFF00
|
||||
col = params.get_param("constructioncolor") | 0x000000FF
|
||||
|
||||
# Get the construction group or create it if it doesn't exist
|
||||
grp = self.doc.getObject("Draft_Construction")
|
||||
|
||||
@@ -462,8 +462,6 @@ def apply_current_style(objs):
|
||||
if style[prop][0] == "index":
|
||||
if style[prop][2] in vobj.getEnumerationsOfProperty(prop):
|
||||
setattr(vobj, prop, style[prop][2])
|
||||
elif style[prop][0] == "color":
|
||||
setattr(vobj, prop, style[prop][1] & 0xFFFFFF00)
|
||||
else:
|
||||
setattr(vobj, prop, style[prop][1])
|
||||
|
||||
@@ -565,7 +563,7 @@ def format_object(target, origin=None):
|
||||
obrep.DisplayMode = dm
|
||||
if Gui.draftToolBar.isConstructionMode():
|
||||
doc = App.ActiveDocument
|
||||
col = params.get_param("constructioncolor") & 0xFFFFFF00
|
||||
col = params.get_param("constructioncolor") | 0x000000FF
|
||||
grp = doc.getObject("Draft_Construction")
|
||||
if not grp:
|
||||
grp = doc.addObject("App::DocumentObjectGroup", "Draft_Construction")
|
||||
|
||||
@@ -72,13 +72,13 @@ def get_default_annotation_style():
|
||||
"ExtOvershoot": ("float", params.get_param("extovershoot")),
|
||||
"FontName": ("font", params.get_param("textfont")),
|
||||
"FontSize": ("float", params.get_param("textheight")),
|
||||
"LineColor": ("color", params.get_param("DefaultAnnoLineColor")),
|
||||
"LineColor": ("color", params.get_param("DefaultAnnoLineColor") | 0x000000FF),
|
||||
"LineSpacing": ("float", params.get_param("LineSpacing")),
|
||||
"LineWidth": ("int", params.get_param("DefaultAnnoLineWidth")),
|
||||
"ScaleMultiplier": ("float", params.get_param("DefaultAnnoScaleMultiplier")),
|
||||
"ShowLine": ("bool", params.get_param("DimShowLine")),
|
||||
"ShowUnit": ("bool", params.get_param("showUnit")),
|
||||
"TextColor": ("color", params.get_param("DefaultTextColor")),
|
||||
"TextColor": ("color", params.get_param("DefaultTextColor") | 0x000000FF),
|
||||
"TextSpacing": ("float", params.get_param("dimspacing")),
|
||||
"UnitOverride": ("str", params.get_param("overrideUnit"))
|
||||
}
|
||||
@@ -91,9 +91,9 @@ def get_default_shape_style():
|
||||
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")),
|
||||
"LineColor": ("color", params.get_param_view("DefaultShapeLineColor") | 0x000000FF),
|
||||
"LineWidth": ("int", params.get_param_view("DefaultShapeLineWidth")),
|
||||
"PointColor": ("color", params.get_param_view("DefaultShapeVertexColor")),
|
||||
"PointColor": ("color", params.get_param_view("DefaultShapeVertexColor") | 0x000000FF),
|
||||
"PointSize": ("int", params.get_param_view("DefaultShapePointSize")),
|
||||
"ShapeAppearance": ("material", (get_view_material(), ))
|
||||
}
|
||||
@@ -102,11 +102,11 @@ def get_default_shape_style():
|
||||
def get_view_material():
|
||||
"""Return a ShapeAppearance material with properties based on the preferences."""
|
||||
material = App.Material()
|
||||
material.AmbientColor = params.get_param_view("DefaultAmbientColor") & 0xFFFFFF00
|
||||
material.DiffuseColor = params.get_param_view("DefaultShapeColor") & 0xFFFFFF00
|
||||
material.EmissiveColor = params.get_param_view("DefaultEmissiveColor") & 0xFFFFFF00
|
||||
material.AmbientColor = params.get_param_view("DefaultAmbientColor") | 0x000000FF
|
||||
material.DiffuseColor = params.get_param_view("DefaultShapeColor") | 0x000000FF
|
||||
material.EmissiveColor = params.get_param_view("DefaultEmissiveColor") | 0x000000FF
|
||||
material.Shininess = params.get_param_view("DefaultShapeShininess") / 100
|
||||
material.SpecularColor = params.get_param_view("DefaultSpecularColor") & 0xFFFFFF00
|
||||
material.SpecularColor = params.get_param_view("DefaultSpecularColor") | 0x000000FF
|
||||
material.Transparency = params.get_param_view("DefaultShapeTransparency") / 100
|
||||
return material
|
||||
|
||||
@@ -834,8 +834,11 @@ getrgb = get_rgb
|
||||
def argb_to_rgba(color):
|
||||
"""Change byte order of a 4 byte color int from ARGB (Qt) to RGBA (FreeCAD).
|
||||
|
||||
Alpha in both integers is always 255.
|
||||
Alpha in color properties, although ignored, is always zero however.
|
||||
Alpha in both integers should always be 255.
|
||||
|
||||
Alpha in color properties is not used in the 3D view, but is shown in the
|
||||
color swatches in the Property editor. It therefore better to ensure alpha
|
||||
is 255 (version 1.1 dev cycle).
|
||||
|
||||
Usage:
|
||||
|
||||
@@ -846,14 +849,11 @@ def argb_to_rgba(color):
|
||||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")\
|
||||
.SetUnsigned("DefaultShapeColor", fc_int)
|
||||
|
||||
obj.ViewObject.ShapeColor = fc_int & 0xFFFFFF00
|
||||
obj.ViewObject.ShapeColor = fc_int | 0x000000FF
|
||||
|
||||
Related:
|
||||
|
||||
getRgbF() returns an RGBA tuple. 4 floats in the range 0.0 - 1.0. Alpha is always 1.
|
||||
Alpha should be set to zero or removed before using the tuple to change a color property:
|
||||
|
||||
obj.ViewObject.ShapeColor = self.form.ShapeColor.property("color").getRgbF()[:3]
|
||||
getRgbF() returns an RGBA tuple. 4 floats in the range 0.0 - 1.0. Alpha is always 1.0.
|
||||
"""
|
||||
return ((color & 0xFFFFFF) << 8) + ((color & 0xFF000000) >> 24)
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class ViewProviderDraftAnnotation(object):
|
||||
"TextColor",
|
||||
"Text",
|
||||
_tip)
|
||||
vobj.TextColor = params.get_param("DefaultTextColor") & 0xFFFFFF00
|
||||
vobj.TextColor = params.get_param("DefaultTextColor") | 0x000000FF
|
||||
|
||||
def set_units_properties(self, vobj, properties):
|
||||
return
|
||||
@@ -157,7 +157,7 @@ class ViewProviderDraftAnnotation(object):
|
||||
"LineColor",
|
||||
"Graphics",
|
||||
_tip)
|
||||
vobj.LineColor = params.get_param("DefaultAnnoLineColor") & 0xFFFFFF00
|
||||
vobj.LineColor = params.get_param("DefaultAnnoLineColor") | 0x000000FF
|
||||
|
||||
def dumps(self):
|
||||
"""Return a tuple of objects to save or None."""
|
||||
@@ -215,7 +215,7 @@ class ViewProviderDraftAnnotation(object):
|
||||
value = style[visprop]
|
||||
try:
|
||||
if vobj.getTypeIdOfProperty(visprop) == "App::PropertyColor":
|
||||
value = value & 0xFFFFFF00
|
||||
value = value | 0x000000FF
|
||||
setattr(vobj, visprop, value)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -101,7 +101,7 @@ class ViewProviderLayer:
|
||||
"LineColor",
|
||||
"Layer",
|
||||
_tip)
|
||||
vobj.LineColor = params.get_param_view("DefaultShapeLineColor") & 0xFFFFFF00
|
||||
vobj.LineColor = params.get_param_view("DefaultShapeLineColor") | 0x000000FF
|
||||
|
||||
if "ShapeColor" not in properties:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
@@ -112,7 +112,7 @@ class ViewProviderLayer:
|
||||
"Layer",
|
||||
_tip,
|
||||
4) # Hidden
|
||||
vobj.ShapeColor = params.get_param_view("DefaultShapeColor") & 0xFFFFFF00
|
||||
vobj.ShapeColor = params.get_param_view("DefaultShapeColor") | 0x000000FF
|
||||
|
||||
if "ShapeAppearance" not in properties:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
@@ -123,7 +123,7 @@ class ViewProviderLayer:
|
||||
"Layer",
|
||||
_tip)
|
||||
material = App.Material()
|
||||
material.DiffuseColor = params.get_param_view("DefaultShapeColor") & 0xFFFFFF00
|
||||
material.DiffuseColor = params.get_param_view("DefaultShapeColor") | 0x000000FF
|
||||
vobj.ShapeAppearance = (material, )
|
||||
|
||||
if "LineWidth" not in properties:
|
||||
|
||||
@@ -70,10 +70,7 @@ class ViewProviderWorkingPlaneProxy:
|
||||
vobj.ArrowSize = 5
|
||||
vobj.Transparency = 70
|
||||
vobj.LineWidth = 1
|
||||
|
||||
ch = params.get_param_arch("ColorHelpers")
|
||||
if ch:
|
||||
vobj.LineColor = ch & 0xFFFFFF00
|
||||
vobj.LineColor = params.get_param_arch("ColorHelpers") | 0x000000FF
|
||||
|
||||
vobj.Proxy = self
|
||||
vobj.RestoreView = True
|
||||
|
||||
Reference in New Issue
Block a user