Path: Make a command and icon to toggle op active status

This commit is contained in:
sliptonic
2018-10-15 18:13:56 -05:00
committed by wmayer
parent 6a26e3e484
commit 77a54cf607
2 changed files with 31 additions and 6 deletions

View File

@@ -76,7 +76,7 @@ class PathWorkbench (Workbench):
# build commands list
projcmdlist = ["Path_Job", "Path_Post"]
toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop"]
toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop", "Path_OpActiveToggle"]
prepcmdlist = ["Path_Fixture", "Path_Comment", "Path_Stop", "Path_Custom"]
twodopcmdlist = ["Path_Contour", "Path_Profile_Faces", "Path_Profile_Edges", "Path_Pocket_Shape", "Path_Drilling", "Path_MillFace", "Path_Helix", "Path_Adaptive" ]
threedopcmdlist = ["Path_Pocket_3D"]
@@ -151,7 +151,7 @@ class PathWorkbench (Workbench):
if "Job" in selectedName:
self.appendContextMenu("", ["Path_ExportTemplate"])
if isinstance (obj.Proxy, PathScripts.PathOp.ObjectOp):
self.appendContextMenu("", ["Path_OperationCopy"])
self.appendContextMenu("", ["Path_OperationCopy", "Path_OpActiveToggle"])
if obj.isDerivedFrom("Path::Feature"):
if "Profile" in selectedName or "Contour" in selectedName or "Dressup" in selectedName:
self.appendContextMenu("", "Separator")
@@ -164,6 +164,6 @@ Gui.addWorkbench(PathWorkbench())
FreeCAD.addImportType(
"GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")
FreeCAD.addExportType(
"GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")
# FreeCAD.addExportType(
# "GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")

View File

@@ -78,9 +78,9 @@ class _CommandSelectLoop:
PathLog.error(exc)
traceback.print_exc(exc)
return False
def Activated(self):
from PathScripts.PathUtils import loopdetect
#from PathScripts.PathUtils import loopdetect
from PathScripts.PathUtils import horizontalEdgeLoop
from PathScripts.PathUtils import horizontalFaceLoop
sel = FreeCADGui.Selection.getSelectionEx()[0]
@@ -120,6 +120,31 @@ class _CommandSelectLoop:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Path_SelectLoop', _CommandSelectLoop())
class _ToggleOperation:
"command definition to toggle Operation Active state"
def GetResources(self):
return {'Pixmap': 'Path-OpActive',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_OpActiveToggle", "Toggle the Active State of the Operation"),
'Accel': "P, X",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_OpActiveToggle", "Toggle the Active State of the Operation"),
'CmdType': "ForEdit"}
def IsActive(self):
if bool(FreeCADGui.Selection.getSelection()) is False:
return False
try:
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
return isinstance(obj.Proxy, PathScripts.PathOp.ObjectOp)
except:
return False
def Activated(self):
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
obj.Active = not(obj.Active)
FreeCAD.ActiveDocument.recompute()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Path_OpActiveToggle', _ToggleOperation())
class _CopyOperation:
"the Path Copy Operation command definition"