forked from FreeCAD/FreeCAD
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request FreeCAD#12064 from bdieterm/fixPlaneTransparency
Gui: add explicit transparency specification
- Loading branch information
Showing
7 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import unittest | ||
|
||
import FreeCAD as App | ||
|
||
|
||
class ColorTransparencyTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self._doc = App.newDocument() | ||
self._pg = App.ParamGet('User parameter:BaseApp/Preferences/View') | ||
self._backup_default_transparency = self._pg.GetInt('DefaultShapeTransparency') | ||
self._backup_default_shapecolor = self._pg.GetUnsigned('DefaultShapeColor') | ||
|
||
|
||
def tearDown(self): | ||
App.closeDocument(self._doc.Name) | ||
self._pg.SetInt('DefaultShapeTransparency', self._backup_default_transparency) | ||
self._pg.SetUnsigned('DefaultShapeColor', self._backup_default_shapecolor) | ||
|
||
|
||
def test_default_shape_transparency(self): | ||
""" | ||
related: https://github.com/FreeCAD/FreeCAD/pull/11866 | ||
related: https://github.com/FreeCAD/FreeCAD/pull/11586 | ||
""" | ||
transparency = 70 | ||
self._pg.SetInt('DefaultShapeTransparency', transparency) | ||
obj = self._doc.addObject('Part::Box') | ||
assert obj.ViewObject.Transparency == transparency | ||
obj.ViewObject.ShapeColor = (0.5, 0.0, 0.0) | ||
|
||
self.assertEqual(obj.ViewObject.Transparency, transparency, | ||
'transparency was unexpectedly changed to {} when changing the color.'.format( | ||
obj.ViewObject.Transparency)) | ||
|
||
|
||
def test_default_shape_color(self): | ||
""" | ||
related: https://github.com/FreeCAD/FreeCAD/pull/11866 | ||
""" | ||
self._pg.SetUnsigned('DefaultShapeColor', 0xff000000) # red | ||
obj = self._doc.addObject('Part::Box') | ||
|
||
self.assertEqual(obj.ViewObject.ShapeColor, (1.0, 0.0, 0.0, 0.0), | ||
'default shape color was not set correctly') | ||
|
||
|
||
def test_app_plane_transparency(self): | ||
""" | ||
related: https://github.com/FreeCAD/FreeCAD/pull/12064 | ||
""" | ||
self._pg.SetInt('DefaultShapeTransparency', 70) | ||
obj = self._doc.addObject('App::Origin') | ||
t = self._doc.findObjects('App::Plane')[0].ViewObject.Transparency | ||
|
||
self.assertEqual(t, 0, | ||
'transparency of App::Plane object is {} instead of 0'.format(t)) | ||
|