CAM: Fix icon and Active state for class ObjectOp
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user