PD: For Body get the color from the tip

Mostly affects STEP export.
This commit is contained in:
Chris Hennes
2025-12-24 19:48:36 -06:00
committed by Kacper Donat
parent 6aea45a226
commit dd14033329
2 changed files with 18 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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);