shaise / FreeCAD_FastenersWB

A workbench to add/attach various fasteners to parts
GNU General Public License v2.0
286 stars 86 forks source link

DefaultFastenerColor is 100 % transparent. #410

Open berberic2 opened 1 week ago

berberic2 commented 1 week ago

If DefaultFastenerColor is set in the preferences, the created screw has the property Transparency set to 100 %. Only the lines are visible.

The problem is that FSParam.GetUnsigned("DefaultFastenerColor", 0xcccccc00) returns a value with the lowest 8 bits set to 1 (0x??????FF), so having an alpha Value of 0xFF. It is not possible to set the alpha-value in the color-selection-dialog.

workaround:

diff --git a/FastenersCmd.py b/FastenersCmd.py
index 4e49727..8b7c4ba 100644
--- a/FastenersCmd.py
+++ b/FastenersCmd.py
@@ -885,7 +885,7 @@ class FSScrewCommand:
             FSScrewObject(a, self.Type, selObj)
             a.Label = a.Proxy.familyType
             if FSParam.GetBool("DefaultFastenerColorActive", False):
-                a.ViewObject.DiffuseColor = FSParam.GetUnsigned("DefaultFastenerColor", 0xcccccc00)
+                a.ViewObject.DiffuseColor = FSParam.GetUnsigned("DefaultFastenerColor", 0xcccccc00) & 0xFFFFFF00
             if FSParam.GetBool("DefaultLineWidthActive", False):
                 a.ViewObject.LineWidth = FSParam.GetFloat("DefaultLineWidth", 1.0)
             if FSParam.GetBool("DefaultVertexSizeActive", False):
OS: Debian GNU/Linux 12 (bookworm) (KDE/plasma/xcb)
Architecture: x86_64
Version: 1.1.0dev.39153 +4 (Git)
Build type: Release
Branch: Meins
Hash: 571ae7f9732bc78fc5777abba8ab5b6a5bfced3c
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Stylesheet/Theme/QtStyle: unset/FreeCAD Classic/Qt default
shaise commented 1 week ago

Wow this is so strange. An alpha value of 0xFF should be fully opaque (in all standards that I know of) why is it opposite in freecad?

berberic2 commented 1 week ago

I have DefaultFastenerColorActive set since at least June and I’m quite sure it worked until recently. DefaultFastenerColor had a value of 0xE6E6FAFF then (in user.cfg).

shaise commented 1 week ago

I KNOW it used to work before. So something must have changed. Anyway at least your change seems to be backward compatible