Skip to content

Commit

Permalink
Fixes FreeCAD#14772: Random color problem
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 29, 2024
1 parent f28394a commit ec890a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/Gui/CommandFeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#ifndef _PreComp_
#endif

#include <App/DocumentObject.h>
#include <App/DocumentObjectGroup.h>
#include <App/GroupExtension.h>
#include <App/Part.h>
#include "Application.h"
#include "CommandT.h"
#include "DockWindowManager.h"
Expand Down Expand Up @@ -116,6 +117,10 @@ void StdCmdRandomColor::activated(int iMsg)
}
};

auto allowToChangeColor = [](const App::DocumentObject* obj) {
return (obj->isDerivedFrom<App::Part>() || obj->isDerivedFrom<App::DocumentObjectGroup>());
};

// get the complete selection
std::vector<SelectionSingleton::SelObj> sel = Selection().getCompleteSelection();

Expand All @@ -125,10 +130,12 @@ void StdCmdRandomColor::activated(int iMsg)
setRandomColor(view);

if (auto grp = it.pObject->getExtension<App::GroupExtension>()) {
std::vector<App::DocumentObject*> objs = grp->getObjects();
for (auto obj : objs) {
ViewProvider* view = Application::Instance->getViewProvider(obj);
setRandomColor(view);
if (allowToChangeColor(it.pObject)) {
std::vector<App::DocumentObject*> objs = grp->getObjects();
for (auto obj : objs) {
ViewProvider* view = Application::Instance->getViewProvider(obj);
setRandomColor(view);
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Mod/PartDesign/Gui/ViewProviderBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ec890a8

Please sign in to comment.