From e835bf45a747850002b79f86a119449578b1aee7 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 7 May 2020 23:20:26 -0500 Subject: [PATCH] Path: Update selection gates pertaining to unified `Profile` operation --- src/Mod/Path/PathScripts/PathSelection.py | 81 ++++++++++++++++++----- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index e34f03e699..943d6ae28a 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -102,8 +102,29 @@ class DRILLGate(PathBaseGate): return False -class PROFILEGate(PathBaseGate): +class FACEGate(PathBaseGate): # formerly PROFILEGate class using allow_ORIG method as allow() def allow(self, doc, obj, sub): # pylint: disable=unused-argument + profileable = False + + try: + obj = obj.Shape + except Exception: # pylint: disable=broad-except + return False + + if obj.ShapeType == 'Compound': + if sub and sub[0:4] == 'Face': + profileable = True + + elif obj.ShapeType == 'Face': # 3D Face, not flat, planar? + profileable = True # Was False + + elif obj.ShapeType == 'Solid': + if sub and sub[0:4] == 'Face': + profileable = True + + return profileable + + def allow_ORIG(self, doc, obj, sub): # pylint: disable=unused-argument profileable = False try: @@ -137,6 +158,33 @@ class PROFILEGate(PathBaseGate): return profileable +class PROFILEGate(PathBaseGate): + def allow(self, doc, obj, sub): # pylint: disable=unused-argument + if sub and sub[0:4] == 'Edge': + return True + + try: + obj = obj.Shape + except Exception: # pylint: disable=broad-except + return False + + if obj.ShapeType == 'Compound': + if sub and sub[0:4] == 'Face': + return True + + elif obj.ShapeType == 'Face': + return True + + elif obj.ShapeType == 'Solid': + if sub and sub[0:4] == 'Face': + return True + + elif obj.ShapeType == 'Wire': + return True + + return False + + class POCKETGate(PathBaseGate): def allow(self, doc, obj, sub): # pylint: disable=unused-argument @@ -179,10 +227,12 @@ class CONTOURGate(PathBaseGate): def allow(self, doc, obj, sub): # pylint: disable=unused-argument pass + class PROBEGate: def allow(self, doc, obj, sub): pass + def contourselect(): FreeCADGui.Selection.addSelectionGate(CONTOURGate()) FreeCAD.Console.PrintWarning("Contour Select Mode\n") @@ -203,17 +253,18 @@ def engraveselect(): FreeCAD.Console.PrintWarning("Engraving Select Mode\n") +def fselect(): + FreeCADGui.Selection.addSelectionGate(FACEGate()) # Was PROFILEGate() + FreeCAD.Console.PrintWarning("Profiling Select Mode\n") + + def chamferselect(): FreeCADGui.Selection.addSelectionGate(CHAMFERGate()) FreeCAD.Console.PrintWarning("Deburr Select Mode\n") def profileselect(): - gate = False - if(PROFILEGate() or EGate()): - gate = True - FreeCADGui.Selection.addSelectionGate(gate) - # FreeCADGui.Selection.addSelectionGate(PROFILEGate()) + FreeCADGui.Selection.addSelectionGate(PROFILEGate()) FreeCAD.Console.PrintWarning("Profiling Select Mode\n") @@ -228,21 +279,21 @@ def adaptiveselect(): def surfaceselect(): - if(MESHGate() is True or PROFILEGate() is True): - FreeCADGui.Selection.addSelectionGate(True) - else: - FreeCADGui.Selection.addSelectionGate(False) - # FreeCADGui.Selection.addSelectionGate(MESHGate()) - # FreeCADGui.Selection.addSelectionGate(PROFILEGate()) # Added for face selection + gate = False + if(MESHGate() or FACEGate()): + gate = True + FreeCADGui.Selection.addSelectionGate(gate) FreeCAD.Console.PrintWarning("Surfacing Select Mode\n") + def probeselect(): FreeCADGui.Selection.addSelectionGate(PROBEGate()) FreeCAD.Console.PrintWarning("Probe Select Mode\n") + def select(op): opsel = {} - opsel['Contour'] = contourselect + opsel['Contour'] = contourselect # (depreciated) opsel['Deburr'] = chamferselect opsel['Drilling'] = drillselect opsel['Engrave'] = engraveselect @@ -251,8 +302,8 @@ def select(op): opsel['Pocket'] = pocketselect opsel['Pocket 3D'] = pocketselect opsel['Pocket Shape'] = pocketselect - opsel['Profile Edges'] = eselect - opsel['Profile Faces'] = profileselect + opsel['Profile Edges'] = eselect # (depreciated) + opsel['Profile Faces'] = fselect # (depreciated) opsel['Profile'] = profileselect opsel['Surface'] = surfaceselect opsel['Waterline'] = surfaceselect