Merge pull request #24872 from tarman3/toggle_operation
CAM: ToggleOperation - Allow for Job and Operations group
This commit is contained in:
@@ -181,6 +181,14 @@ class _ToggleOperation:
|
||||
if not selection:
|
||||
return False
|
||||
|
||||
if len(selection) == 1:
|
||||
# allows to toggle all operations in Job
|
||||
sel = selection[0]
|
||||
if hasattr(sel, "Group") and sel.Name.startswith("Job"):
|
||||
return True
|
||||
if hasattr(sel, "Group") and sel.Name.startswith("Operations"):
|
||||
return True
|
||||
|
||||
for sel in selection:
|
||||
baseOp = Path.Dressup.Utils.baseOp(sel)
|
||||
if not hasattr(baseOp, "Active"):
|
||||
@@ -190,9 +198,32 @@ class _ToggleOperation:
|
||||
|
||||
def Activated(self):
|
||||
selection = FreeCADGui.Selection.getSelection()
|
||||
for sel in selection:
|
||||
baseOp = Path.Dressup.Utils.baseOp(sel)
|
||||
baseOp.Active = not baseOp.Active
|
||||
if (len(selection) == 1 and hasattr(selection[0], "Group")) and (
|
||||
selection[0].Name.startswith("Job") or selection[0].Name.startswith("Operations")
|
||||
):
|
||||
sel = selection[0]
|
||||
# process all Operations in Job
|
||||
if sel.Name.startswith("Job"):
|
||||
selection = sel.Operations.Group
|
||||
elif sel.Name.startswith("Operations"):
|
||||
selection = sel.Group
|
||||
|
||||
states = [Path.Dressup.Utils.baseOp(sel).Active for sel in selection]
|
||||
if all(states) or not any(states):
|
||||
# all operations in one state (active or inactive) - toggle state
|
||||
for sel in selection:
|
||||
baseOp = Path.Dressup.Utils.baseOp(sel)
|
||||
baseOp.Active = not baseOp.Active
|
||||
else:
|
||||
# operations in different states - set Active state
|
||||
for sel in selection:
|
||||
baseOp = Path.Dressup.Utils.baseOp(sel)
|
||||
baseOp.Active = True
|
||||
|
||||
else:
|
||||
for sel in selection:
|
||||
baseOp = Path.Dressup.Utils.baseOp(sel)
|
||||
baseOp.Active = not baseOp.Active
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user