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:
@@ -573,6 +573,9 @@ class Joint:
|
||||
for obj in joint.InList:
|
||||
if obj.isDerivedFrom("Assembly::AssemblyObject"):
|
||||
return obj
|
||||
elif obj.isDerivedFrom("Assembly::AssemblyLink"):
|
||||
return self.getAssembly(obj)
|
||||
|
||||
return None
|
||||
|
||||
def setJointType(self, joint, newType):
|
||||
@@ -946,6 +949,24 @@ class ViewProviderJoint:
|
||||
|
||||
return ":/icons/Assembly_CreateJoint.svg"
|
||||
|
||||
def getOverlayIcons(self):
|
||||
"""
|
||||
Return a dictionary of overlay icons.
|
||||
Keys are positions from Gui.IconPosition.
|
||||
Values are the icon resource names.
|
||||
"""
|
||||
|
||||
overlays = {}
|
||||
|
||||
assembly = self.app_obj.Proxy.getAssembly(self.app_obj)
|
||||
# Assuming Reference1 corresponds to the first part link
|
||||
if hasattr(self.app_obj, "Reference1"):
|
||||
part = UtilsAssembly.getMovingPart(assembly, self.app_obj.Reference1)
|
||||
if part is not None and not assembly.isPartConnected(part):
|
||||
overlays[Gui.IconPosition.BottomLeft] = "Part_Detached"
|
||||
|
||||
return overlays
|
||||
|
||||
def dumps(self):
|
||||
"""When saving the document this object gets stored using Python's json module.\
|
||||
Since we have some un-serializable parts here -- the Coin stuff -- we must define this method\
|
||||
|
||||
Reference in New Issue
Block a user