Merge pull request #4144 from mlampert/feature/suppress-warnings-preferences

Path: Feature/suppress warnings preferences
This commit is contained in:
sliptonic
2020-12-19 15:39:30 -06:00
committed by GitHub
24 changed files with 280 additions and 101 deletions

View File

@@ -23,6 +23,7 @@
import FreeCAD
import PathScripts.PathEngraveBase as PathEngraveBase
import PathScripts.PathGeom as PathGeom
import PathScripts.PathLog as PathLog
import PathScripts.PathOp as PathOp
import PathScripts.PathOpTools as PathOpTools
@@ -48,35 +49,44 @@ def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
def toolDepthAndOffset(width, extraDepth, tool):
def toolDepthAndOffset(width, extraDepth, tool, printInfo):
'''toolDepthAndOffset(width, extraDepth, tool) ... return tuple for given\n
parameters.'''
if not hasattr(tool, 'Diameter'):
raise ValueError('Deburr requires tool with diameter\n')
if not hasattr(tool, 'CuttingEdgeAngle'):
angle = 180
FreeCAD.Console.PrintMessage('The selected tool has No CuttingEdgeAngle property. Assuming Endmill\n')
else:
suppressInfo = False
if hasattr(tool, 'CuttingEdgeAngle'):
angle = float(tool.CuttingEdgeAngle)
if not hasattr(tool, 'FlatRadius'):
toolOffset = float(tool.Diameter / 2)
FreeCAD.Console.PrintMessage('The selected tool has no FlatRadius property. Using Diameter\n')
if PathGeom.isRoughly(angle, 180) or PathGeom.isRoughly(angle, 0):
angle = 180
toolOffset = float(tool.Diameter) / 2
else:
if hasattr(tool, 'TipDiameter'):
toolOffset = float(tool.TipDiameter) / 2
elif hasattr(tool, 'FlatRadius'):
toolOffset = float(tool.FlatRadius)
else:
toolOffset = 0.0
if printInfo and not suppressInfo:
FreeCAD.Console.PrintMessage(translate('PathDeburr', "The selected tool has no FlatRadius and no TipDiameter property. Assuming {}\n").format("Endmill" if angle == 180 else "V-Bit"))
suppressInfo = True
else:
toolOffset = float(tool.FlatRadius)
if angle == 0:
angle = 180
toolOffset = float(tool.Diameter) / 2
if printInfo:
FreeCAD.Console.PrintMessage(translate('PathDeburr', 'The selected tool has no CuttingEdgeAngle property. Assuming Endmill\n'))
suppressInfo = True
tan = math.tan(math.radians(angle / 2))
toolDepth = 0 if 0 == tan else width / tan
toolDepth = 0 if PathGeom.isRoughly(tan, 0) else width / tan
depth = toolDepth + extraDepth
extraOffset = float(tool.Diameter) / 2 - width if angle == 180 else extraDepth / tan
extraOffset = -width if angle == 180 else (extraDepth / tan)
offset = toolOffset + extraOffset
return (depth, offset)
return (depth, offset, suppressInfo)
class ObjectDeburr(PathEngraveBase.ObjectOp):
@@ -110,8 +120,11 @@ class ObjectDeburr(PathEngraveBase.ObjectOp):
def opExecute(self, obj):
PathLog.track(obj.Label)
if not hasattr(self, 'printInfo'):
self.printInfo = True
try:
(depth, offset) = toolDepthAndOffset(obj.Width.Value, obj.ExtraDepth.Value, self.tool)
(depth, offset, suppressInfo) = toolDepthAndOffset(obj.Width.Value, obj.ExtraDepth.Value, self.tool, self.printInfo)
self.printInfo = not suppressInfo
except ValueError as e:
msg = "{} \n No path will be generated".format(e)
raise ValueError(msg)

View File

@@ -41,12 +41,8 @@ __doc__ = "Class and implementation of Mill Facing operation."
__contributors__ = "russ4262 (Russell Johnson)"
DEBUG = False
if DEBUG:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule()
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
# PathLog.trackModule()
# Qt translation handling
@@ -82,7 +78,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
obj.OpStartDepth = job.Stock.Shape.BoundBox.ZMax
if len(obj.Base) >= 1:
print('processing')
PathLog.debug('processing')
sublist = []
for i in obj.Base:
o = i[0]

View File

@@ -27,6 +27,7 @@ from PySide import QtCore
import Path
import PathScripts.PathGeom as PathGeom
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathUtil as PathUtil
import PathScripts.PathUtils as PathUtils
from PathScripts.PathUtils import waiting_effects
@@ -547,11 +548,11 @@ class ObjectOp(object):
hRapidrate = tc.HorizRapid.Value
vRapidrate = tc.VertRapid.Value
if hFeedrate == 0 or vFeedrate == 0:
if (hFeedrate == 0 or vFeedrate == 0) and not PathPreferences.suppressAllSpeedsWarning():
PathLog.warning(translate("Path", "Tool Controller feedrates required to calculate the cycle time."))
return translate('Path', 'Feedrate Error')
if hRapidrate == 0 or vRapidrate == 0:
if (hRapidrate == 0 or vRapidrate == 0) and not PathPreferences.suppressRapidSpeedsWarning():
PathLog.warning(translate("Path", "Add Tool Controller Rapid Speeds on the SetupSheet for more accurate cycle times."))
# Get the cycle time in seconds

View File

@@ -29,35 +29,39 @@ import PathScripts.PathLog as PathLog
# PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
# PathLog.trackModule()
DefaultFilePath = "DefaultFilePath"
DefaultJobTemplate = "DefaultJobTemplate"
DefaultStockTemplate = "DefaultStockTemplate"
DefaultTaskPanelLayout = "DefaultTaskPanelLayout"
DefaultFilePath = "DefaultFilePath"
DefaultJobTemplate = "DefaultJobTemplate"
DefaultStockTemplate = "DefaultStockTemplate"
DefaultTaskPanelLayout = "DefaultTaskPanelLayout"
PostProcessorDefault = "PostProcessorDefault"
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
PostProcessorBlacklist = "PostProcessorBlacklist"
PostProcessorOutputFile = "PostProcessorOutputFile"
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
PostProcessorDefault = "PostProcessorDefault"
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
PostProcessorBlacklist = "PostProcessorBlacklist"
PostProcessorOutputFile = "PostProcessorOutputFile"
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
LastPathToolBit = "LastPathToolBit"
LastPathToolLibrary = "LastPathToolLibrary"
LastPathToolShape = "LastPathToolShape"
LastPathToolTable = "LastPathToolTable"
LastPathToolBit = "LastPathToolBit"
LastPathToolLibrary = "LastPathToolLibrary"
LastPathToolShape = "LastPathToolShape"
LastPathToolTable = "LastPathToolTable"
LastFileToolBit = "LastFileToolBit"
LastFileToolLibrary = "LastFileToolLibrary"
LastFileToolShape = "LastFileToolShape"
LastFileToolBit = "LastFileToolBit"
LastFileToolLibrary = "LastFileToolLibrary"
LastFileToolShape = "LastFileToolShape"
UseLegacyTools = "UseLegacyTools"
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
OpenLastLibrary = "OpenLastLibrary"
UseLegacyTools = "UseLegacyTools"
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
OpenLastLibrary = "OpenLastLibrary"
# Linear tolerance to use when generating Paths, eg when tessellating geometry
GeometryTolerance = "GeometryTolerance"
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
GeometryTolerance = "GeometryTolerance"
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
EnableExperimentalFeatures = "EnableExperimentalFeatures"
WarningSuppressRapidSpeeds = "WarningSuppressRapidSpeeds"
WarningSuppressAllSpeeds = "WarningSuppressAllSpeeds"
WarningSuppressSelectionMode = "WarningSuppressSelectionMode"
WarningSuppressOpenCamLib = "WarningSuppressOpenCamLib"
EnableExperimentalFeatures = "EnableExperimentalFeatures"
def preferences():
@@ -259,6 +263,18 @@ def setDefaultTaskPanelLayout(style):
def experimentalFeaturesEnabled():
return preferences().GetBool(EnableExperimentalFeatures, False)
def suppressAllSpeedsWarning():
return preferences().GetBool(WarningSuppressAllSpeeds, True)
def suppressRapidSpeedsWarning():
return suppressAllSpeedsWarning() or preferences().GetBool(WarningSuppressRapidSpeeds, True)
def suppressSelectionModeWarning():
return preferences().GetBool(WarningSuppressSelectionMode, True)
def suppressOpenCamLibWarning():
return preferences().GetBool(WarningSuppressOpenCamLib, True)
def lastFileToolLibrary():
filename = preferences().GetString(LastFileToolLibrary)

View File

@@ -25,6 +25,7 @@
import FreeCAD
import FreeCADGui
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathUtils as PathUtils
import math
@@ -286,52 +287,62 @@ class ALLGate(PathBaseGate):
def contourselect():
FreeCADGui.Selection.addSelectionGate(CONTOURGate())
FreeCAD.Console.PrintWarning("Contour Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Contour Select Mode\n")
def eselect():
FreeCADGui.Selection.addSelectionGate(EGate())
FreeCAD.Console.PrintWarning("Edge Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Edge Select Mode\n")
def drillselect():
FreeCADGui.Selection.addSelectionGate(DRILLGate())
FreeCAD.Console.PrintWarning("Drilling Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Drilling Select Mode\n")
def engraveselect():
FreeCADGui.Selection.addSelectionGate(ENGRAVEGate())
FreeCAD.Console.PrintWarning("Engraving Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Engraving Select Mode\n")
def fselect():
FreeCADGui.Selection.addSelectionGate(FACEGate()) # Was PROFILEGate()
FreeCAD.Console.PrintWarning("Profiling Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Profiling Select Mode\n")
def chamferselect():
FreeCADGui.Selection.addSelectionGate(CHAMFERGate())
FreeCAD.Console.PrintWarning("Deburr Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Deburr Select Mode\n")
def profileselect():
FreeCADGui.Selection.addSelectionGate(PROFILEGate())
FreeCAD.Console.PrintWarning("Profiling Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Profiling Select Mode\n")
def pocketselect():
FreeCADGui.Selection.addSelectionGate(POCKETGate())
FreeCAD.Console.PrintWarning("Pocketing Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Pocketing Select Mode\n")
def adaptiveselect():
FreeCADGui.Selection.addSelectionGate(ADAPTIVEGate())
FreeCAD.Console.PrintWarning("Adaptive Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Adaptive Select Mode\n")
def slotselect():
FreeCADGui.Selection.addSelectionGate(ALLGate())
FreeCAD.Console.PrintWarning("Slot Cutter Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Slot Cutter Select Mode\n")
def surfaceselect():
@@ -339,26 +350,31 @@ def surfaceselect():
if(MESHGate() or FACEGate()):
gate = True
FreeCADGui.Selection.addSelectionGate(gate)
FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")
def vcarveselect():
FreeCADGui.Selection.addSelectionGate(VCARVEGate())
FreeCAD.Console.PrintWarning("Vcarve Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Vcarve Select Mode\n")
def probeselect():
FreeCADGui.Selection.addSelectionGate(PROBEGate())
FreeCAD.Console.PrintWarning("Probe Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Probe Select Mode\n")
def customselect():
FreeCAD.Console.PrintWarning("Custom Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Custom Select Mode\n")
def turnselect():
FreeCADGui.Selection.addSelectionGate(TURNGate())
FreeCAD.Console.PrintWarning("Turning Select Mode\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Turning Select Mode\n")
def select(op):
@@ -392,4 +408,5 @@ def select(op):
def clear():
FreeCADGui.Selection.removeSelectionGate()
FreeCAD.Console.PrintWarning("Free Select\n")
if not PathPreferences.suppressSelectionModeWarning():
FreeCAD.Console.PrintWarning("Free Select\n")

View File

@@ -401,7 +401,7 @@ def getToolControllers(obj, proxy=None):
except Exception: # pylint: disable=broad-except
job = None
print("op={} ({})".format(obj.Label, type(obj)))
PathLog.debug("op={} ({})".format(obj.Label, type(obj)))
if job:
return [c for c in job.ToolController if proxy.isToolSupported(obj, c.Tool)]
return []
@@ -538,7 +538,7 @@ def arc(cx, cy, sx, sy, ex, ey, horizFeed=0, ez=None, ccw=False):
eps = 0.01
if (math.sqrt((cx - sx)**2 + (cy - sy)**2) - math.sqrt((cx - ex)**2 + (cy - ey)**2)) >= eps:
print("ERROR: Illegal arc: Start and end radii not equal")
PathLog.error(translate("Path", "Illegal arc: Start and end radii not equal"))
return ""
retstr = ""

View File

@@ -324,4 +324,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -94,4 +94,4 @@ def parse(pathobj):
out += str(c) + "\n"
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -367,4 +367,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -100,4 +100,4 @@ def parse(inputstring):
print("done postprocessing.")
return output
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -300,4 +300,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -570,4 +570,4 @@ def drill_translate(outstring, cmd, params):
return trBuff
print(__name__ + ": GCode postprocessor loaded.")
# print(__name__ + ": GCode postprocessor loaded.")

View File

@@ -333,4 +333,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -398,4 +398,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -434,4 +434,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -763,7 +763,7 @@ def drill_translate(outlist, cmd, params):
return Drill.gcode
print(__name__ + ': GCode postprocessor loaded.')
# print(__name__ + ': GCode postprocessor loaded.')
# PEP8 format passed using: http://pep8online.com/, which primarily covers
# indentation and line length. Some other aspects of PEP8 which have not

View File

@@ -364,4 +364,4 @@ def linenumber():
return ""
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")

View File

@@ -256,5 +256,5 @@ def parse(inputstring):
return '\n'.join(output)
print (__name__ + " gcode postprocessor loaded.")
# print (__name__ + " gcode postprocessor loaded.")

View File

@@ -425,4 +425,4 @@ def parse(pathobj):
return out
print(__name__ + " gcode postprocessor loaded.")
# print(__name__ + " gcode postprocessor loaded.")