Merge pull request #6357 from sliptonic/master
[Path] Warn user if current schema doesn't generate proper velocity (unit/min)
This commit is contained in:
@@ -58,6 +58,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="WarningSuppressVelocity">
|
||||
<property name="toolTip">
|
||||
<string>Suppress warning whenever a Path selection mode is activated</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Suppress Velocity warning</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>WarningSuppressSelectionMode</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Path</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="WarningSuppressSelectionMode">
|
||||
<property name="toolTip">
|
||||
@@ -113,12 +132,12 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:16pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If openCAMlib is installed with its python interface it can be used by some additional 3d operations.</p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Changing this value requires a restart of FreeCAD to take effect.</p></body></html></string>
|
||||
</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:16pt;">If openCAMlib is installed with its python interface it can be used by some additional 3d operations.</span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:16pt;">Changing this value requires a restart of FreeCAD to take effect.</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -61,6 +61,8 @@ class PathWorkbench(Workbench):
|
||||
# Add preferences pages - before loading PathGui to properly order pages of Path group
|
||||
from PathScripts import PathPreferencesPathJob, PathPreferencesPathDressup
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
FreeCADGui.addPreferencePage(PathPreferencesPathJob.JobPreferencesPage, "Path")
|
||||
FreeCADGui.addPreferencePage(
|
||||
PathPreferencesPathDressup.DressupPreferencesPage, "Path"
|
||||
@@ -141,7 +143,8 @@ class PathWorkbench(Workbench):
|
||||
FreeCADGui.addCommand(
|
||||
"Path_EngraveTools",
|
||||
PathCommandGroup(
|
||||
engravecmdlist, QT_TRANSLATE_NOOP("Path_EngraveTools", "Engraving Operations")
|
||||
engravecmdlist,
|
||||
QT_TRANSLATE_NOOP("Path_EngraveTools", "Engraving Operations"),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -172,12 +175,8 @@ class PathWorkbench(Workbench):
|
||||
if not PathPreferences.suppressOpenCamLibWarning():
|
||||
FreeCAD.Console.PrintError("OpenCamLib is not working!\n")
|
||||
|
||||
self.appendToolbar(
|
||||
QT_TRANSLATE_NOOP("Workbench", "Project Setup"), projcmdlist
|
||||
)
|
||||
self.appendToolbar(
|
||||
QT_TRANSLATE_NOOP("Workbench", "Tool Commands"), toolcmdlist
|
||||
)
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Project Setup"), projcmdlist)
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Tool Commands"), toolcmdlist)
|
||||
self.appendToolbar(
|
||||
QT_TRANSLATE_NOOP("Workbench", "New Operations"),
|
||||
twodopcmdlist + engravecmdgroup + threedcmdgroup,
|
||||
@@ -258,6 +257,25 @@ class PathWorkbench(Workbench):
|
||||
)
|
||||
Log("Loading Path workbench... done\n")
|
||||
|
||||
# Warn user if current schema doesn't use minute for time in velocity
|
||||
if not PathPreferences.suppressVelocity():
|
||||
velString = FreeCAD.Units.Quantity(
|
||||
1, FreeCAD.Units.Velocity
|
||||
).getUserPreferred()[2][3:]
|
||||
|
||||
if velString != "min":
|
||||
current_schema = FreeCAD.Units.listSchemas(FreeCAD.Units.getSchema())
|
||||
|
||||
msg = translate(
|
||||
"Path",
|
||||
f"The currently selected unit schema: \n '{current_schema}'\n Does not use 'minutes' for velocity values. \n \nCNC machines require feed rate to be expressed in \nunit/minute. To ensure correct gcode: \nSelect a minute-based schema in preferences.\nFor example:\n 'Metric, Small Parts & CNC'\n 'US Customary'\n 'Imperial Decimal'",
|
||||
)
|
||||
header = translate("Path", "Warning")
|
||||
msgbox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, header, msg)
|
||||
|
||||
msgbox.addButton(translate("Path", "Ok"), QtGui.QMessageBox.AcceptRole)
|
||||
msgbox.exec_()
|
||||
|
||||
def GetClassName(self):
|
||||
return "Gui::PythonWorkbench"
|
||||
|
||||
|
||||
@@ -28,40 +28,41 @@ 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"
|
||||
UseLegacyTools = "UseLegacyTools"
|
||||
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
|
||||
# OpenLastLibrary = "OpenLastLibrary"
|
||||
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuracy"
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuracy"
|
||||
|
||||
WarningSuppressRapidSpeeds = "WarningSuppressRapidSpeeds"
|
||||
WarningSuppressAllSpeeds = "WarningSuppressAllSpeeds"
|
||||
WarningSuppressSelectionMode = "WarningSuppressSelectionMode"
|
||||
WarningSuppressOpenCamLib = "WarningSuppressOpenCamLib"
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
EnableAdvancedOCLFeatures = "EnableAdvancedOCLFeatures"
|
||||
WarningSuppressRapidSpeeds = "WarningSuppressRapidSpeeds"
|
||||
WarningSuppressAllSpeeds = "WarningSuppressAllSpeeds"
|
||||
WarningSuppressSelectionMode = "WarningSuppressSelectionMode"
|
||||
WarningSuppressOpenCamLib = "WarningSuppressOpenCamLib"
|
||||
WarningSuppressVelocity = "WarningSuppressVelocity"
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
EnableAdvancedOCLFeatures = "EnableAdvancedOCLFeatures"
|
||||
|
||||
|
||||
def preferences():
|
||||
@@ -81,7 +82,10 @@ def pathDefaultToolsPath(sub=None):
|
||||
def allAvailablePostProcessors():
|
||||
allposts = []
|
||||
for path in searchPathsPost():
|
||||
posts = [str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in glob.glob(path + '/*_post.py')]
|
||||
posts = [
|
||||
str(os.path.split(os.path.splitext(p)[0])[1][:-5])
|
||||
for p in glob.glob(path + "/*_post.py")
|
||||
]
|
||||
allposts.extend(posts)
|
||||
allposts.sort()
|
||||
return allposts
|
||||
@@ -89,7 +93,11 @@ def allAvailablePostProcessors():
|
||||
|
||||
def allEnabledPostProcessors(include=None):
|
||||
blacklist = postProcessorBlacklist()
|
||||
enabled = [processor for processor in allAvailablePostProcessors() if processor not in blacklist]
|
||||
enabled = [
|
||||
processor
|
||||
for processor in allAvailablePostProcessors()
|
||||
if processor not in blacklist
|
||||
]
|
||||
if include:
|
||||
postlist = list(set(include + enabled))
|
||||
postlist.sort()
|
||||
@@ -153,7 +161,7 @@ def searchPathsPost():
|
||||
|
||||
def searchPathsTool(sub):
|
||||
paths = []
|
||||
paths.append(os.path.join(FreeCAD.getHomePath(), 'Mod', 'Path', 'Tools', sub))
|
||||
paths.append(os.path.join(FreeCAD.getHomePath(), "Mod", "Path", "Tools", sub))
|
||||
return paths
|
||||
|
||||
|
||||
@@ -178,13 +186,16 @@ def setToolsSettings(legacy, relative):
|
||||
|
||||
def defaultJobTemplate():
|
||||
template = preferences().GetString(DefaultJobTemplate)
|
||||
if 'xml' not in template:
|
||||
if "xml" not in template:
|
||||
return template
|
||||
return ''
|
||||
return ""
|
||||
|
||||
|
||||
def setJobDefaults(fileName, jobTemplate, geometryTolerance, curveAccuracy):
|
||||
PathLog.track("(%s='%s', %s, %s, %s)" % (DefaultFilePath, fileName, jobTemplate, geometryTolerance, curveAccuracy))
|
||||
PathLog.track(
|
||||
"(%s='%s', %s, %s, %s)"
|
||||
% (DefaultFilePath, fileName, jobTemplate, geometryTolerance, curveAccuracy)
|
||||
)
|
||||
pref = preferences()
|
||||
pref.SetString(DefaultFilePath, fileName)
|
||||
pref.SetString(DefaultJobTemplate, jobTemplate)
|
||||
@@ -252,7 +263,9 @@ def suppressAllSpeedsWarning():
|
||||
|
||||
|
||||
def suppressRapidSpeedsWarning(user=True):
|
||||
return (user and suppressAllSpeedsWarning()) or preferences().GetBool(WarningSuppressRapidSpeeds, True)
|
||||
return (user and suppressAllSpeedsWarning()) or preferences().GetBool(
|
||||
WarningSuppressRapidSpeeds, True
|
||||
)
|
||||
|
||||
|
||||
def suppressSelectionModeWarning():
|
||||
@@ -262,20 +275,31 @@ def suppressSelectionModeWarning():
|
||||
def suppressOpenCamLibWarning():
|
||||
return preferences().GetBool(WarningSuppressOpenCamLib, True)
|
||||
|
||||
def setPreferencesAdvanced(ocl, warnSpeeds, warnRapids, warnModes, warnOCL):
|
||||
preferences().SetBool(EnableAdvancedOCLFeatures, ocl)
|
||||
preferences().SetBool(WarningSuppressAllSpeeds, warnSpeeds)
|
||||
preferences().SetBool(WarningSuppressRapidSpeeds, warnRapids)
|
||||
|
||||
def suppressVelocity():
|
||||
return preferences().GetBool(WarningSuppressVelocity, False)
|
||||
|
||||
|
||||
def setPreferencesAdvanced(
|
||||
ocl, warnSpeeds, warnRapids, warnModes, warnOCL, warnVelocity
|
||||
):
|
||||
preferences().SetBool(EnableAdvancedOCLFeatures, ocl)
|
||||
preferences().SetBool(WarningSuppressAllSpeeds, warnSpeeds)
|
||||
preferences().SetBool(WarningSuppressRapidSpeeds, warnRapids)
|
||||
preferences().SetBool(WarningSuppressSelectionMode, warnModes)
|
||||
preferences().SetBool(WarningSuppressOpenCamLib, warnOCL)
|
||||
preferences().SetBool(WarningSuppressOpenCamLib, warnOCL)
|
||||
preferences().SetBool(WarningSuppressVelocity, warnVelocity)
|
||||
|
||||
|
||||
def lastFileToolLibrary():
|
||||
filename = preferences().GetString(LastFileToolLibrary)
|
||||
if filename.endswith('.fctl') and os.path.isfile(filename):
|
||||
if filename.endswith(".fctl") and os.path.isfile(filename):
|
||||
return filename
|
||||
|
||||
libpath = preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath('Library'))
|
||||
libFiles = [f for f in glob.glob(libpath + '/*.fctl')]
|
||||
libpath = preferences().GetString(
|
||||
LastPathToolLibrary, pathDefaultToolsPath("Library")
|
||||
)
|
||||
libFiles = [f for f in glob.glob(libpath + "/*.fctl")]
|
||||
libFiles.sort()
|
||||
if len(libFiles) >= 1:
|
||||
filename = libFiles[0]
|
||||
@@ -294,7 +318,7 @@ def setLastFileToolLibrary(path):
|
||||
|
||||
|
||||
def lastPathToolBit():
|
||||
return preferences().GetString(LastPathToolBit, pathDefaultToolsPath('Bit'))
|
||||
return preferences().GetString(LastPathToolBit, pathDefaultToolsPath("Bit"))
|
||||
|
||||
|
||||
def setLastPathToolBit(path):
|
||||
@@ -303,20 +327,20 @@ def setLastPathToolBit(path):
|
||||
|
||||
def lastPathToolLibrary():
|
||||
PathLog.track()
|
||||
return preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath('Library'))
|
||||
return preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath("Library"))
|
||||
|
||||
|
||||
def setLastPathToolLibrary(path):
|
||||
PathLog.track(path)
|
||||
curLib = lastFileToolLibrary()
|
||||
PathLog.debug('curLib: {}'.format(curLib))
|
||||
PathLog.debug("curLib: {}".format(curLib))
|
||||
if curLib and os.path.split(curLib)[0] != path:
|
||||
setLastFileToolLibrary('') # a path is known but not specific file
|
||||
setLastFileToolLibrary("") # a path is known but not specific file
|
||||
return preferences().SetString(LastPathToolLibrary, path)
|
||||
|
||||
|
||||
def lastPathToolShape():
|
||||
return preferences().GetString(LastPathToolShape, pathDefaultToolsPath('Shape'))
|
||||
return preferences().GetString(LastPathToolShape, pathDefaultToolsPath("Shape"))
|
||||
|
||||
|
||||
def setLastPathToolShape(path):
|
||||
|
||||
@@ -38,6 +38,7 @@ class AdvancedPreferencesPage:
|
||||
self.form.WarningSuppressRapidSpeeds.isChecked(),
|
||||
self.form.WarningSuppressSelectionMode.isChecked(),
|
||||
self.form.WarningSuppressOpenCamLib.isChecked(),
|
||||
self.form.WarningSuppressVelocity.isChecked(),
|
||||
)
|
||||
|
||||
def loadSettings(self):
|
||||
@@ -56,12 +57,14 @@ class AdvancedPreferencesPage:
|
||||
self.form.WarningSuppressOpenCamLib.setChecked(
|
||||
PathPreferences.suppressOpenCamLibWarning()
|
||||
)
|
||||
self.form.WarningSuppressVelocity.setChecked(PathPreferences.suppressVelocity())
|
||||
self.updateSelection()
|
||||
|
||||
def updateSelection(self, state=None):
|
||||
self.form.WarningSuppressOpenCamLib.setEnabled(
|
||||
self.form.EnableAdvancedOCLFeatures.isChecked()
|
||||
)
|
||||
|
||||
if self.form.WarningSuppressAllSpeeds.isChecked():
|
||||
self.form.WarningSuppressRapidSpeeds.setChecked(True)
|
||||
self.form.WarningSuppressRapidSpeeds.setEnabled(False)
|
||||
|
||||
Reference in New Issue
Block a user