Part: Set per-face transparency in boolean ops - fixes #1029,#2806
This commit is contained in:
parent
ebb3c84bcb
commit
d7ed8c4383
|
@ -78,6 +78,20 @@ void ViewProviderPart::applyColor(const Part::ShapeHistory& hist,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewProviderPart::applyTransparency(const float& transparency,
|
||||||
|
std::vector<App::Color>& colors)
|
||||||
|
{
|
||||||
|
if (transparency != 0.0) {
|
||||||
|
// transparency has been set object-wide
|
||||||
|
std::vector<App::Color>::iterator j;
|
||||||
|
for (j = colors.begin(); j != colors.end(); ++j) {
|
||||||
|
// transparency hasn't been set for this face
|
||||||
|
if (j->a == 0.0)
|
||||||
|
j->a = transparency/100.0; // transparency comes in percent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ViewProviderShapeBuilder::buildNodes(const App::Property* , std::vector<SoNode*>& ) const
|
void ViewProviderShapeBuilder::buildNodes(const App::Property* , std::vector<SoNode*>& ) const
|
||||||
|
|
|
@ -57,6 +57,8 @@ protected:
|
||||||
void applyColor(const Part::ShapeHistory& hist,
|
void applyColor(const Part::ShapeHistory& hist,
|
||||||
const std::vector<App::Color>& colBase,
|
const std::vector<App::Color>& colBase,
|
||||||
std::vector<App::Color>& colBool);
|
std::vector<App::Color>& colBool);
|
||||||
|
void applyTransparency(const float& transparency,
|
||||||
|
std::vector<App::Color>& colors);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace PartGui
|
} // namespace PartGui
|
||||||
|
|
|
@ -106,6 +106,8 @@ void ViewProviderBoolean::updateData(const App::Property* prop)
|
||||||
std::vector<App::Color> colTool = static_cast<PartGui::ViewProviderPart*>(vpTool)->DiffuseColor.getValues();
|
std::vector<App::Color> colTool = static_cast<PartGui::ViewProviderPart*>(vpTool)->DiffuseColor.getValues();
|
||||||
std::vector<App::Color> colBool;
|
std::vector<App::Color> colBool;
|
||||||
colBool.resize(boolMap.Extent(), this->ShapeColor.getValue());
|
colBool.resize(boolMap.Extent(), this->ShapeColor.getValue());
|
||||||
|
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
|
||||||
|
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpTool)->Transparency.getValue(),colTool);
|
||||||
|
|
||||||
bool setColor=false;
|
bool setColor=false;
|
||||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||||
|
@ -203,6 +205,7 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop)
|
||||||
|
|
||||||
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
|
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
|
||||||
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
||||||
|
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
|
||||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||||
applyColor(hist[index], colBase, colBool);
|
applyColor(hist[index], colBase, colBool);
|
||||||
setColor = true;
|
setColor = true;
|
||||||
|
@ -332,6 +335,7 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop)
|
||||||
|
|
||||||
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
|
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
|
||||||
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
||||||
|
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
|
||||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||||
applyColor(hist[index], colBase, colBool);
|
applyColor(hist[index], colBase, colBool);
|
||||||
setColor = true;
|
setColor = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user