PD: For Body get the color from the tip

Mostly affects STEP export.

(cherry picked from commit 51d2c88b02)
This commit is contained in:
Chris Hennes
2025-12-27 19:30:04 +01:00
committed by Max Wilfinger
parent 62181c7e74
commit 4a9f2ff24a
2 changed files with 18 additions and 0 deletions
@@ -349,6 +349,21 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop)
}
}
std::map<std::string, Base::Color> ViewProviderBody::getElementColors(const char* element) const
{
// A PartDesign Body doesn't really have element colors on its own: it's a sort of container,
// and its subshapes are the ones that have actual colors. If you query a body's ViewProvider
// for its element colors, what you are really asking for is the element colors of its tip.
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
if (App::DocumentObject* tip = body->Tip.getValue()) {
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(tip->getDocument());
Gui::ViewProvider* vp = guiDoc->getViewProvider(tip);
return vp->getElementColors(element);
}
return ViewProviderPart::getElementColors(element);
}
void ViewProviderBody::setVisualBodyMode(bool bodymode)
{
@@ -97,6 +97,9 @@ public:
return true;
};
/// Override to return the color of the tip instead of the body, which doesn't really have color
std::map<std::string, Base::Color> getElementColors(const char* element) const override;
protected:
/// Copy over all visual properties to the child features
void unifyVisualProperty(const App::Property* prop);