Core: Extend Color API
* Fix issues with alpha value <> transparency * Use type traits to convert between different color classes (fixes #14515)
This commit is contained in:
@@ -525,7 +525,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn)
|
||||
str >> std::ws >> a;
|
||||
// no transparency
|
||||
if (!str) {
|
||||
a = 0.0f;
|
||||
a = 1.0f;
|
||||
}
|
||||
|
||||
if (r > 1.0f || g > 1.0f || b > 1.0f || a > 1.0f) {
|
||||
@@ -578,7 +578,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn)
|
||||
str >> std::ws >> a;
|
||||
// no transparency
|
||||
if (!str) {
|
||||
a = 0.0f;
|
||||
a = 1.0f;
|
||||
}
|
||||
|
||||
if (r > 1.0f || g > 1.0f || b > 1.0f || a > 1.0f) {
|
||||
|
||||
@@ -363,7 +363,7 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
|
||||
for (auto const& value : fValues | boost::adaptors::indexed(0)) {
|
||||
App::Color c = pcColorBar->getColor(value.value());
|
||||
diffcol[value.index()].setValue(c.r, c.g, c.b);
|
||||
transp[value.index()] = c.a;
|
||||
transp[value.index()] = c.transparency();
|
||||
}
|
||||
|
||||
pcColorMat->diffuseColor.finishEditing();
|
||||
|
||||
@@ -88,7 +88,7 @@ void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Co
|
||||
for (auto& j : colors) {
|
||||
// transparency hasn't been set for this face
|
||||
if (j.a == 0.0) {
|
||||
j.a = transparency/100.0F; // transparency comes in percent
|
||||
j.setTransparency(transparency/100.0F); // transparency comes in percent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1451,11 +1451,11 @@ class DocumentPlatformCases(unittest.TestCase):
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[0][0] - 1.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[0][1] - 0.5) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[0][2] - 0.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[0][3] - 0.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[0][3] - 1.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[1][0] - 0.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[1][1] - 0.5) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[1][2] - 1.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[1][3] - 0.0) < 0.01)
|
||||
self.assertTrue(abs(self.Doc.Test.ColourList[1][3] - 1.0) < 0.01)
|
||||
|
||||
def testVectorList(self):
|
||||
self.Doc.Test.VectorList = [(-0.05, 2.5, 5.2), (-0.05, 2.5, 5.2)]
|
||||
|
||||
Reference in New Issue
Block a user