Assembly: Use icon overlay for unconnected joints instead of annoying warning. (#22662)
* Core: FeaturePython : Add getOverlayIcons to python interface * Assembly: unconnected joints icon overlay Fix #22643 * Update src/Mod/Assembly/Gui/ViewProviderAssembly.cpp Co-authored-by: Kacper Donat <kadet1090@gmail.com> * Update AssemblyObject.cpp * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update ViewProviderFeaturePython.h * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update ViewProviderFeaturePython.h * Update JointObject.py * Update ViewProviderFeaturePython.h * Update ViewProviderFeaturePython.cpp * Update Application.cpp * Update ViewProviderFeaturePython.cpp * Update ViewProviderFeaturePython.h * Update ViewProviderAssembly.cpp --------- Co-authored-by: Kacper Donat <kadet1090@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "ViewProviderGeometryObject.h"
|
||||
#include "Document.h"
|
||||
#include "BitmapFactory.h"
|
||||
|
||||
class SoSensor;
|
||||
class SoDragger;
|
||||
@@ -55,6 +56,8 @@ public:
|
||||
|
||||
// Returns the icon
|
||||
QIcon getIcon() const;
|
||||
// returns a map of position -> icon name.
|
||||
std::map<BitmapFactoryInst::Position, std::string> getOverlayIcons() const;
|
||||
bool claimChildren(std::vector<App::DocumentObject*>&) const;
|
||||
ValueT useNewSelectionModel() const;
|
||||
void onSelectionChanged(const SelectionChanges&);
|
||||
@@ -138,6 +141,7 @@ private:
|
||||
|
||||
#define FC_PY_VIEW_OBJECT \
|
||||
FC_PY_ELEMENT(getIcon) \
|
||||
FC_PY_ELEMENT(getOverlayIcons) \
|
||||
FC_PY_ELEMENT(claimChildren) \
|
||||
FC_PY_ELEMENT(useNewSelectionModel) \
|
||||
FC_PY_ELEMENT(getElementPicked) \
|
||||
@@ -224,6 +228,29 @@ public:
|
||||
return icon;
|
||||
}
|
||||
|
||||
QIcon mergeColorfulOverlayIcons(const QIcon& orig) const override
|
||||
{
|
||||
QIcon currentIcon = orig;
|
||||
|
||||
// Get the map of overlay names from the Python implementation
|
||||
std::map<BitmapFactoryInst::Position, std::string> overlayMap = imp->getOverlayIcons();
|
||||
|
||||
if (!overlayMap.empty()) {
|
||||
// Use the static instance of BitmapFactory to perform the merge
|
||||
for (const auto& [position, name] : overlayMap) {
|
||||
static const QSize overlayIconSize { 10, 10 };
|
||||
QPixmap overlayPixmap =
|
||||
Gui::BitmapFactory().pixmapFromSvg(name.c_str(), overlayIconSize);
|
||||
if (!overlayPixmap.isNull()) {
|
||||
currentIcon =
|
||||
Gui::BitmapFactoryInst::mergePixmap(currentIcon, overlayPixmap, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ViewProviderT::mergeColorfulOverlayIcons(currentIcon);
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> claimChildren() const override {
|
||||
std::vector<App::DocumentObject *> res;
|
||||
if(!imp->claimChildren(res))
|
||||
|
||||
Reference in New Issue
Block a user