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:
PaddleStroke
2025-07-26 22:35:24 +02:00
committed by GitHub
parent 17381534a7
commit 59c6742155
7 changed files with 172 additions and 17 deletions

View File

@@ -158,6 +158,64 @@ QIcon ViewProviderFeaturePythonImp::getIcon() const
return {};
}
std::map<BitmapFactoryInst::Position, std::string>
ViewProviderFeaturePythonImp::getOverlayIcons() const
{
std::map<BitmapFactoryInst::Position, std::string> overlays;
_FC_PY_CALL_CHECK(getOverlayIcons, return overlays);
Base::PyGILStateLocker lock;
try {
Py::Object ret(Base::pyCall(py_getOverlayIcons.ptr()));
if (ret.isNone()) {
return overlays;
}
// Expect a dictionary (dict) from Python
if (!PyDict_Check(ret.ptr())) {
return overlays;
}
Py::Dict dict(ret);
PyObject *key, *value;
Py_ssize_t pos = 0;
// Iterate over the dictionary items
while (PyDict_Next(dict.ptr(), &pos, &key, &value)) {
// Key should be an integer (from the enum)
if (!PyLong_Check(key)) {
continue;
}
// Value should be a string
if (!PyUnicode_Check(value)) {
continue;
}
long position_val = PyLong_AsLong(key);
// Basic validation for the enum range
if (position_val >= BitmapFactoryInst::TopLeft
&& position_val <= BitmapFactoryInst::BottomRight) {
auto position = static_cast<BitmapFactoryInst::Position>(position_val);
std::string iconName = Py::String(value).as_std_string("utf-8");
if (!iconName.empty()) {
overlays[position] = iconName;
}
}
}
}
catch (Py::Exception&) {
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
PyErr_Clear();
}
else {
Base::PyException e;
e.reportException();
}
}
return overlays;
}
bool ViewProviderFeaturePythonImp::claimChildren(std::vector<App::DocumentObject*> &children) const
{
_FC_PY_CALL_CHECK(claimChildren,return(false));