Import: Fix of alpha channel misinterpretation
This commit is contained in:
@@ -1002,7 +1002,7 @@ void LinkView::setMaterial(int index, const App::Material *material) {
|
||||
return;
|
||||
}
|
||||
App::Color c = material->diffuseColor;
|
||||
c.a = material->transparency;
|
||||
c.setTransparency(material->transparency);
|
||||
pcLinkRoot->setColorOverride(c);
|
||||
for(int i=0;i<getSize();++i)
|
||||
setMaterial(i,nullptr);
|
||||
@@ -1015,7 +1015,7 @@ void LinkView::setMaterial(int index, const App::Material *material) {
|
||||
return;
|
||||
}
|
||||
App::Color c = material->diffuseColor;
|
||||
c.a = material->transparency;
|
||||
c.setTransparency(material->transparency);
|
||||
info.pcRoot->setColorOverride(c);
|
||||
}
|
||||
}
|
||||
@@ -3074,7 +3074,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
|
||||
if(wildcard == "Face" || wildcard == "Face*" || wildcard.empty()) {
|
||||
if(wildcard.size()==4 || OverrideMaterial.getValue()) {
|
||||
App::Color c = ShapeMaterial.getValue().diffuseColor;
|
||||
c.a = ShapeMaterial.getValue().transparency;
|
||||
c.setTransparency(ShapeMaterial.getValue().transparency);
|
||||
colors["Face"] = c;
|
||||
if(wildcard.size()==4)
|
||||
return colors;
|
||||
@@ -3113,7 +3113,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
|
||||
while(true) {
|
||||
if(wildcard!=ViewProvider::hiddenMarker() && vp->OverrideMaterial.getValue()) {
|
||||
auto color = ShapeMaterial.getValue().diffuseColor;
|
||||
color.a = ShapeMaterial.getValue().transparency;
|
||||
color.setTransparency(ShapeMaterial.getValue().transparency);
|
||||
colors.emplace(wildcard,color);
|
||||
}
|
||||
auto link = vp->getObject()->getLinkedObject(false);
|
||||
@@ -3139,7 +3139,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
|
||||
if(!overrides[i])
|
||||
continue;
|
||||
auto color = mat.diffuseColor;
|
||||
color.a = mat.transparency;
|
||||
color.setTransparency(mat.transparency);
|
||||
colors.emplace(std::to_string(i)+"."+wildcard,color);
|
||||
}
|
||||
}
|
||||
@@ -3284,7 +3284,7 @@ void ViewProviderLink::setElementColors(const std::map<std::string, App::Color>
|
||||
if(hasFaceColor) {
|
||||
auto mat = ShapeMaterial.getValue();
|
||||
mat.diffuseColor = faceColor;
|
||||
mat.transparency = faceColor.a;
|
||||
mat.transparency = faceColor.transparency();
|
||||
ShapeMaterial.setStatus(App::Property::User3,true);
|
||||
ShapeMaterial.setValue(mat);
|
||||
ShapeMaterial.setStatus(App::Property::User3,false);
|
||||
|
||||
@@ -63,7 +63,7 @@ using namespace Import;
|
||||
ExportOCAFOptions::ExportOCAFOptions()
|
||||
{
|
||||
defaultColor.setPackedValue(0xCCCCCC00);
|
||||
defaultColor.a = 0;
|
||||
defaultColor.a = 1;
|
||||
}
|
||||
|
||||
ExportOCAF2::ExportOCAF2(Handle(TDocStd_Document) h, GetShapeColorsFunc func)
|
||||
@@ -94,7 +94,7 @@ ExportOCAFOptions ExportOCAF2::customExportOptions()
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
defaultOptions.defaultColor.setPackedValue(
|
||||
handle->GetUnsigned("DefaultShapeColor", defaultOptions.defaultColor.getPackedValue()));
|
||||
defaultOptions.defaultColor.a = 0;
|
||||
defaultOptions.defaultColor.a = 1;
|
||||
|
||||
return defaultOptions;
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ using namespace Import;
|
||||
ImportOCAFOptions::ImportOCAFOptions()
|
||||
{
|
||||
defaultFaceColor.setPackedValue(0xCCCCCC00);
|
||||
defaultFaceColor.a = 0;
|
||||
defaultFaceColor.a = 1.0F;
|
||||
|
||||
defaultEdgeColor.setPackedValue(421075455UL);
|
||||
defaultEdgeColor.a = 0;
|
||||
defaultEdgeColor.a = 1.0F;
|
||||
}
|
||||
|
||||
ImportOCAF2::ImportOCAF2(Handle(TDocStd_Document) hDoc, App::Document* doc, const std::string& name)
|
||||
@@ -114,12 +114,12 @@ ImportOCAFOptions ImportOCAF2::customImportOptions()
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
defaultOptions.defaultFaceColor.setPackedValue(
|
||||
hGrp->GetUnsigned("DefaultShapeColor", defaultOptions.defaultFaceColor.getPackedValue()));
|
||||
defaultOptions.defaultFaceColor.a = 0;
|
||||
defaultOptions.defaultFaceColor.a = 1.0F;
|
||||
|
||||
defaultOptions.defaultEdgeColor.setPackedValue(
|
||||
hGrp->GetUnsigned("DefaultShapeLineColor",
|
||||
defaultOptions.defaultEdgeColor.getPackedValue()));
|
||||
defaultOptions.defaultEdgeColor.a = 0;
|
||||
defaultOptions.defaultEdgeColor.a = 1.0F;
|
||||
|
||||
return defaultOptions;
|
||||
}
|
||||
@@ -353,9 +353,6 @@ bool ImportOCAF2::createObject(App::Document* doc,
|
||||
hasFaceColors = true;
|
||||
info.hasFaceColor = true;
|
||||
}
|
||||
else {
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foundEdgeColor) {
|
||||
|
||||
@@ -53,12 +53,12 @@ App::Color Tools::convertColor(const Quantity_ColorRGBA& rgba)
|
||||
return App::Color(static_cast<float>(red),
|
||||
static_cast<float>(green),
|
||||
static_cast<float>(blue),
|
||||
1.0f - static_cast<float>(rgba.Alpha()));
|
||||
static_cast<float>(rgba.Alpha()));
|
||||
}
|
||||
|
||||
Quantity_ColorRGBA Tools::convertColor(const App::Color& col)
|
||||
{
|
||||
return Quantity_ColorRGBA(Quantity_Color(col.r, col.g, col.b, OCC_COLOR_SPACE), 1.0f - col.a);
|
||||
return Quantity_ColorRGBA(Quantity_Color(col.r, col.g, col.b, OCC_COLOR_SPACE), col.a);
|
||||
}
|
||||
|
||||
static inline std::ostream& operator<<(std::ostream& os, const Quantity_ColorRGBA& rgba)
|
||||
|
||||
@@ -51,7 +51,7 @@ void ImportOCAFGui::applyFaceColors(Part::Feature* part, const std::vector<App::
|
||||
|
||||
if (colors.size() == 1) {
|
||||
vp->ShapeAppearance.setDiffuseColor(colors.front());
|
||||
vp->Transparency.setValue(100 * colors.front().a);
|
||||
vp->Transparency.setValue(100 * colors.front().transparency());
|
||||
}
|
||||
else {
|
||||
vp->ShapeAppearance.setDiffuseColors(colors);
|
||||
|
||||
@@ -341,13 +341,12 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
}
|
||||
else if (prop == &_diffuseColor) {
|
||||
// Used to load the old DiffuseColor values asynchronously
|
||||
// v0.21 used the alpha channel to store transparency values
|
||||
std::vector<App::Color> colors = _diffuseColor.getValues();
|
||||
std::vector<float> transparencies;
|
||||
transparencies.resize(static_cast<int>(colors.size()));
|
||||
for (int i = 0; i < static_cast<int>(colors.size()); i++) {
|
||||
transparencies[i] = colors[i].a;
|
||||
colors[i].a = 1.0;
|
||||
transparencies[i] = colors[i].transparency();
|
||||
colors[i].a = 1.0F;
|
||||
}
|
||||
ShapeAppearance.setDiffuseColors(colors);
|
||||
ShapeAppearance.setTransparencies(transparencies);
|
||||
@@ -665,7 +664,7 @@ std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const cha
|
||||
|
||||
if(!element || !element[0]) {
|
||||
auto color = ShapeAppearance.getDiffuseColor();
|
||||
color.a = Transparency.getValue()/100.0f;
|
||||
color.setTransparency(Transparency.getValue()/100.0F);
|
||||
ret["Face"] = color;
|
||||
ret["Edge"] = LineColor.getValue();
|
||||
ret["Vertex"] = PointColor.getValue();
|
||||
@@ -676,7 +675,7 @@ std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const cha
|
||||
auto size = ShapeAppearance.getSize();
|
||||
if(element[4]=='*') {
|
||||
auto color = ShapeAppearance.getDiffuseColor();
|
||||
color.a = Transparency.getValue()/100.0f;
|
||||
color.setTransparency(Transparency.getValue()/100.0F);
|
||||
bool singleColor = true;
|
||||
for(int i=0;i<size;++i) {
|
||||
if (ShapeAppearance.getDiffuseColor(i) != color) {
|
||||
@@ -688,7 +687,7 @@ std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const cha
|
||||
}
|
||||
if(size && singleColor) {
|
||||
color = ShapeAppearance.getDiffuseColor(0);
|
||||
color.a = Transparency.getValue()/100.0f;
|
||||
color.setTransparency(Transparency.getValue()/100.0F);
|
||||
ret.clear();
|
||||
}
|
||||
ret["Face"] = color;
|
||||
@@ -699,7 +698,7 @@ std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const cha
|
||||
else
|
||||
ret[element] = ShapeAppearance.getDiffuseColor();
|
||||
if(size==1)
|
||||
ret[element].a = Transparency.getValue()/100.0f;
|
||||
ret[element].setTransparency(Transparency.getValue()/100.0F);
|
||||
}
|
||||
} else if (boost::starts_with(element,"Edge")) {
|
||||
auto size = LineColorArray.getSize();
|
||||
|
||||
Reference in New Issue
Block a user