Skip to content

Commit 51d2c88

Browse files
chenneskadet1090
authored andcommitted
PD: For Body get the color from the tip
Mostly affects STEP export.
1 parent 7da6467 commit 51d2c88

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Mod/PartDesign/Gui/ViewProviderBody.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,21 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop)
349349
}
350350
}
351351

352+
std::map<std::string, Base::Color> ViewProviderBody::getElementColors(const char* element) const
353+
{
354+
// A PartDesign Body doesn't really have element colors on its own: it's a sort of container,
355+
// and its subshapes are the ones that have actual colors. If you query a body's ViewProvider
356+
// for its element colors, what you are really asking for is the element colors of its tip.
357+
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
358+
if (App::DocumentObject* tip = body->Tip.getValue()) {
359+
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(tip->getDocument());
360+
Gui::ViewProvider* vp = guiDoc->getViewProvider(tip);
361+
return vp->getElementColors(element);
362+
}
363+
return ViewProviderPart::getElementColors(element);
364+
}
365+
366+
352367
void ViewProviderBody::setVisualBodyMode(bool bodymode)
353368
{
354369

src/Mod/PartDesign/Gui/ViewProviderBody.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class PartDesignGuiExport ViewProviderBody: public PartGui::ViewProviderPart,
9797
return true;
9898
};
9999

100+
/// Override to return the color of the tip instead of the body, which doesn't really have color
101+
std::map<std::string, Base::Color> getElementColors(const char* element) const override;
102+
100103
protected:
101104
/// Copy over all visual properties to the child features
102105
void unifyVisualProperty(const App::Property* prop);

0 commit comments

Comments
 (0)