Skip to content

Commit

Permalink
Path: Update selection gates pertaining to unified Profile operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ4262 committed May 11, 2020
1 parent dcd6f0e commit a17c3e9
Showing 1 changed file with 66 additions and 15 deletions.
81 changes: 66 additions & 15 deletions src/Mod/Path/PathScripts/PathSelection.py
Expand Up @@ -102,8 +102,29 @@ def allow(self, doc, obj, sub): # pylint: disable=unused-argument
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:
Expand Down Expand Up @@ -137,6 +158,33 @@ def allow(self, doc, obj, sub): # pylint: disable=unused-argument
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

Expand Down Expand Up @@ -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")
Expand All @@ -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")


Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a17c3e9

Please sign in to comment.