diff --git a/src/Mod/CAM/Path/Op/Base.py b/src/Mod/CAM/Path/Op/Base.py index 01d06fa179..e685840a28 100644 --- a/src/Mod/CAM/Path/Op/Base.py +++ b/src/Mod/CAM/Path/Op/Base.py @@ -531,6 +531,9 @@ class ObjectOp(object): self.opOnChanged(obj, prop) + if prop == "Active" and obj.ViewObject: + obj.ViewObject.signalChangeIcon() + def applyExpression(self, obj, prop, expr): """applyExpression(obj, prop, expr) ... set expression expr on obj.prop if expr is set""" if expr: diff --git a/src/Mod/CAM/Path/Op/Custom.py b/src/Mod/CAM/Path/Op/Custom.py index 931da577a9..5c4ab4efb2 100644 --- a/src/Mod/CAM/Path/Op/Custom.py +++ b/src/Mod/CAM/Path/Op/Custom.py @@ -114,6 +114,9 @@ class ObjectCustom(PathOp.ObjectOp): if prop == "Source": self.setEditorModes(obj) + if prop == "Active" and obj.ViewObject: + obj.ViewObject.signalChangeIcon() + def opOnDocumentRestored(self, obj): if not hasattr(obj, "Source"): obj.addProperty( diff --git a/src/Mod/CAM/Path/Op/Gui/SimpleCopy.py b/src/Mod/CAM/Path/Op/Gui/SimpleCopy.py index 0a840d730b..e9df79e5fa 100644 --- a/src/Mod/CAM/Path/Op/Gui/SimpleCopy.py +++ b/src/Mod/CAM/Path/Op/Gui/SimpleCopy.py @@ -30,6 +30,32 @@ __doc__ = """CAM SimpleCopy command""" translate = FreeCAD.Qt.translate +class ViewProvider: + + def __init__(self, vobj): + self.Object = vobj.Object + vobj.Proxy = self + + def attach(self, vobj): + self.Object = vobj.Object + return + + def dumps(self): + return None + + def loads(self, state): + return None + + def onChanged(self, vobj, prop): + return + + def getIcon(self): + if self.Object.Active: + return ":/icons/CAM_SimpleCopy.svg" + else: + return ":/icons/CAM_OpActive.svg" + + class CommandPathSimpleCopy: def GetResources(self): return { @@ -70,8 +96,10 @@ class CommandPathSimpleCopy: FreeCADGui.doCommand("srcpath = PathScripts.PathUtils.getPathWithPlacement(srcobj)\n") FreeCADGui.addModule("Path.Op.Custom") FreeCADGui.doCommand('obj = Path.Op.Custom.Create("' + selection[0].Name + '_SimpleCopy")') - FreeCADGui.doCommand("obj.ViewObject.Proxy = 0") FreeCADGui.doCommand("obj.Gcode = [c.toGCode() for c in srcpath.Commands]") + FreeCADGui.doCommand( + "obj.ViewObject.Proxy = Path.Op.Gui.SimpleCopy.ViewProvider(obj.ViewObject)" + ) FreeCADGui.doCommand("PathScripts.PathUtils.addToJob(obj)") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/CAM/Path/Op/Slot.py b/src/Mod/CAM/Path/Op/Slot.py index b283afe897..1a38a8372f 100644 --- a/src/Mod/CAM/Path/Op/Slot.py +++ b/src/Mod/CAM/Path/Op/Slot.py @@ -394,6 +394,9 @@ class ObjectSlot(PathOp.ObjectOp): self.updateEnumerations(obj) self.opSetEditorModes(obj) + if prop == "Active" and obj.ViewObject: + obj.ViewObject.signalChangeIcon() + def opOnDocumentRestored(self, obj): self.propertiesReady = False job = PathUtils.findParentJob(obj) diff --git a/src/Mod/CAM/Path/Op/Surface.py b/src/Mod/CAM/Path/Op/Surface.py index 4dbe7541d6..107087f709 100644 --- a/src/Mod/CAM/Path/Op/Surface.py +++ b/src/Mod/CAM/Path/Op/Surface.py @@ -577,6 +577,9 @@ class ObjectSurface(PathOp.ObjectOp): if prop in ["ScanType", "CutPattern"]: self.setEditorProperties(obj) + if prop == "Active" and obj.ViewObject: + obj.ViewObject.signalChangeIcon() + def opOnDocumentRestored(self, obj): self.propertiesReady = False job = PathUtils.findParentJob(obj) diff --git a/src/Mod/CAM/Path/Op/Waterline.py b/src/Mod/CAM/Path/Op/Waterline.py index 0806a9c843..836cff25ea 100644 --- a/src/Mod/CAM/Path/Op/Waterline.py +++ b/src/Mod/CAM/Path/Op/Waterline.py @@ -556,6 +556,9 @@ class ObjectWaterline(PathOp.ObjectOp): if prop in ["Algorithm", "CutPattern"]: self.setEditorProperties(obj) + if prop == "Active" and obj.ViewObject: + obj.ViewObject.signalChangeIcon() + def opOnDocumentRestored(self, obj): self.propertiesReady = False job = PathUtils.findParentJob(obj)