From 78e5b1e5b7151427ac20bd40b8ed5b92ce7e3e22 Mon Sep 17 00:00:00 2001 From: Zoltan Hubert Date: Sat, 17 Jul 2021 19:46:17 +0200 Subject: [PATCH 1/2] modified ViewProviderPart to show different icon for Assembly-Type --- src/Gui/Icons/Geoassembly.svg | 343 ++++++++++++++++++++++++++ src/Gui/Icons/Geofeaturegroup.svg | 393 +++++++++++++++++++++++------- src/Gui/Icons/resource.qrc | 1 + src/Gui/ViewProviderPart.cpp | 15 ++ src/Gui/ViewProviderPart.h | 7 + 5 files changed, 669 insertions(+), 90 deletions(-) create mode 100644 src/Gui/Icons/Geoassembly.svg diff --git a/src/Gui/Icons/Geoassembly.svg b/src/Gui/Icons/Geoassembly.svg new file mode 100644 index 0000000000..1573e4dbb6 --- /dev/null +++ b/src/Gui/Icons/Geoassembly.svg @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Path-Stock + 2015-07-04 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Path/Gui/Resources/icons/Path-Stock.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/Icons/Geofeaturegroup.svg b/src/Gui/Icons/Geofeaturegroup.svg index 1945b9a6fe..fea9f132bb 100644 --- a/src/Gui/Icons/Geofeaturegroup.svg +++ b/src/Gui/Icons/Geofeaturegroup.svg @@ -1,91 +1,304 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - Path-Stock - 2015-07-04 - http://www.freecadweb.org/wiki/index.php?title=Artwork - - - FreeCAD - - - FreeCAD/src/Mod/Path/Gui/Resources/icons/Path-Stock.svg - - - FreeCAD LGPL2+ - - - https://www.gnu.org/copyleft/lesser.html - - - [agryson] Alexander Gryson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Path-Stock + 2015-07-04 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Path/Gui/Resources/icons/Path-Stock.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 9de6436fbb..13ac71a492 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -216,6 +216,7 @@ AddonManager.svg Group.svg Geofeaturegroup.svg + Geoassembly.svg Std_Axis.svg Std_Plane.svg Link.svg diff --git a/src/Gui/ViewProviderPart.cpp b/src/Gui/ViewProviderPart.cpp index b39fdd109a..da0e2188af 100644 --- a/src/Gui/ViewProviderPart.cpp +++ b/src/Gui/ViewProviderPart.cpp @@ -57,6 +57,7 @@ ViewProviderPart::ViewProviderPart() initExtension(this); sPixmap = "Geofeaturegroup.svg"; + aPixmap = "Geoassembly.svg"; } ViewProviderPart::~ViewProviderPart() @@ -112,6 +113,20 @@ bool ViewProviderPart::doubleClicked(void) return true; } +QIcon ViewProviderPart::getIcon(void) const +{ + // the original Part object for this ViewProviderPart + App::Part* part = static_cast(this->getObject()); + // the normal case for Std_Part + const char* pixmap = sPixmap; + std::string type = part->Type.getStrValue(); + // if it's flagged as an Assembly in its Type, it gets another icon + if (type == "Assembly") { pixmap = aPixmap; } + + return mergeGreyableOverlayIcons (Gui::BitmapFactory().pixmap(pixmap)); +} + + // Python feature ----------------------------------------------------------------------- namespace Gui { diff --git a/src/Gui/ViewProviderPart.h b/src/Gui/ViewProviderPart.h index fe0fb5eb6c..1d756321fd 100644 --- a/src/Gui/ViewProviderPart.h +++ b/src/Gui/ViewProviderPart.h @@ -45,10 +45,17 @@ public: virtual bool doubleClicked(void) override; virtual void setupContextMenu(QMenu* menu, QObject* receiver, const char* member) override; + + /// deliver the icon shown in the tree view + /// override from ViewProvider.h + virtual QIcon getIcon(void) const; protected: /// get called by the container whenever a property has been changed virtual void onChanged(const App::Property* prop) override; + /// a second icon for the Assembly type + const char* aPixmap; + }; typedef ViewProviderPythonFeatureT ViewProviderPartPython; From da0c6cc5455aff82ace89fa35bd1c68b8851d351 Mon Sep 17 00:00:00 2001 From: Zoltan Hubert Date: Mon, 26 Jul 2021 13:32:03 +0200 Subject: [PATCH 2/2] fix in ViewProviderPart.cpp --- src/Gui/ViewProviderPart.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Gui/ViewProviderPart.cpp b/src/Gui/ViewProviderPart.cpp index da0e2188af..38543fc336 100644 --- a/src/Gui/ViewProviderPart.cpp +++ b/src/Gui/ViewProviderPart.cpp @@ -119,9 +119,8 @@ QIcon ViewProviderPart::getIcon(void) const App::Part* part = static_cast(this->getObject()); // the normal case for Std_Part const char* pixmap = sPixmap; - std::string type = part->Type.getStrValue(); // if it's flagged as an Assembly in its Type, it gets another icon - if (type == "Assembly") { pixmap = aPixmap; } + if (part->Type.getStrValue() == "Assembly") { pixmap = aPixmap; } return mergeGreyableOverlayIcons (Gui::BitmapFactory().pixmap(pixmap)); }