CAM: Fix icon and Active state for class ObjectOp

This commit is contained in:
tarman3
2025-10-15 07:39:02 +03:00
parent a2e9fbddad
commit 4c3f6fc21f
6 changed files with 44 additions and 1 deletions

View File

@@ -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:

View File

@@ -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(

View File

@@ -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()

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)