From aac8bdd7bcc0d58fa2ac9f71e1e67fae48b2b05e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 29 Jun 2024 12:35:56 +0200 Subject: [PATCH] Fixes #14772: Random color problem --- src/Gui/CommandFeat.cpp | 17 ++++++++++++----- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index dfee930f48..730b77394e 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -25,8 +25,9 @@ #ifndef _PreComp_ #endif -#include +#include #include +#include #include "Application.h" #include "CommandT.h" #include "DockWindowManager.h" @@ -116,6 +117,10 @@ void StdCmdRandomColor::activated(int iMsg) } }; + auto allowToChangeColor = [](const App::DocumentObject* obj) { + return (obj->isDerivedFrom() || obj->isDerivedFrom()); + }; + // get the complete selection std::vector sel = Selection().getCompleteSelection(); @@ -125,10 +130,12 @@ void StdCmdRandomColor::activated(int iMsg) setRandomColor(view); if (auto grp = it.pObject->getExtension()) { - std::vector objs = grp->getObjects(); - for (auto obj : objs) { - ViewProvider* view = Application::Instance->getViewProvider(obj); - setRandomColor(view); + if (allowToChangeColor(it.pObject)) { + std::vector objs = grp->getObjects(); + for (auto obj : objs) { + ViewProvider* view = Application::Instance->getViewProvider(obj); + setRandomColor(view); + } } } } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index aa78a19e97..79947520cf 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -427,7 +427,6 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) { if (prop == &Visibility || prop == &Selectable || prop == &DisplayModeBody || - prop == &ShapeAppearance || prop == &PointColorArray || prop == &LineColorArray) { return;