diff --git a/src/Mod/Path/Gui/Resources/preferences/PathJob.ui b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
index 2f28d723a4..8bd0781282 100644
--- a/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
+++ b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
@@ -6,8 +6,8 @@
0
0
- 503
- 557
+ 560
+ 609
@@ -15,235 +15,337 @@
-
-
-
-
- 0
- 0
-
+
+
+ 0
-
- Output File
-
-
-
-
-
-
-
-
-
-
- Default Path
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
-
- <html><head/><body><p>Enter a path and optionally file name (see below) to be used as the default for the post processor export.</p><p>The following substitutions are performed before the name is resolved at the time of the post processing:</p><p>%D ... directory of the active document<br/>%d ... name of the active document (with extension)<br/>%M ... user macro directory<br/>%j ... name of the active Job object</p><p>The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):</p><p>"/home/cnc/%d.g-code"</p><p>See the file save policy below on how to deal with name conflicts.</p></body></html>
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p>Open a file system browser to select default path for output files.</p></body></html>
-
-
- ...
-
-
-
-
-
-
- -
-
-
-
-
-
-
- File Save Policy
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p>Choose how to deal with potential file name conflicts. Always open a dialog, only open a dialog if the output file already exists, overwrite any existing file or add a unique (3 digit) sequential ID to the file name.</p></body></html>
-
-
-
-
- Open File Dialog
-
-
- -
-
- Open File Dialog on conflict
-
-
- -
-
- Overwrite existing file
-
-
- -
-
- Append Unique ID on conflict
-
-
-
-
-
-
-
-
-
-
- -
-
-
- Post Processor
-
-
-
- QFormLayout::AllNonFixedFieldsGrow
+
+
+
+ 0
+ 0
+ 542
+ 519
+
-
-
-
-
- Post Processors Selection
-
-
-
- -
-
-
- true
-
-
- <html><head/><body><p>It doesn't seem there are any post processor scripts installed. Pleas add some into your macro directory and make sure the file name ends with "_post.py".</p></body></html>
-
-
-
- -
-
-
- Default Post Processor
-
-
-
- -
-
-
- <html><head/><body><p>Select one of the post processors as the default.</p></body></html>
-
-
- DefaultPostProcessor
-
-
- Mod/Path
-
-
-
- -
-
-
- Default Arguments
-
-
-
- -
-
-
- <html><head/><body><p>Optional arguments passed to the default Post Processor specified above. See the Post Processor's documentation for supported arguments.</p></body></html>
-
-
- DefaultPostProcessorArgs
-
-
- Mod/Path
-
-
-
-
+
+ General
+
+
+ -
+
+
+ Defaults
+
+
+
-
+
+
+ <html><head/><body><p>Path to look for templates, post processors, tool tables and other external files.</p><p><br/></p><p>If left empty the macro directory is used.</p></body></html>
+
+
+
+ -
+
+
+ Path
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ Template
+
+
+
+ -
+
+
+ <html><head/><body><p>The default template to be selected when creating a new Job. </p><p><br/></p><p>This can be helpful when almost all jobs will be processed by the same machine with a similar setup.</p><p><br/></p><p>If left empty no template will be preselected.</p></body></html>
+
+
+
+ -
+
+
+ ...
+
+
+
+
+
+
+ -
+
+
+ Geometry
+
+
+
-
+
+
+
-
+
+
+ Default Geometry Tolerance
+
+
+
+ -
+
+
+ Default value for new Jobs, used for computing Paths. Smaller increases accuracy, but slows down computation
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 542
+ 519
+
+
+
+ Post Processor
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Output File
+
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
+
+
+
-
+
+
+ Default Path
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
-
+
+
+ <html><head/><body><p>Enter a path and optionally file name (see below) to be used as the default for the post processor export.</p><p>The following substitutions are performed before the name is resolved at the time of the post processing:</p><p>%D ... directory of the active document<br/>%d ... name of the active document (with extension)<br/>%M ... user macro directory<br/>%j ... name of the active Job object</p><p>The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):</p><p>"/home/cnc/%d.g-code"</p><p>See the file save policy below on how to deal with name conflicts.</p></body></html>
+
+
+
+ -
+
+
+ ...
+
+
+
+
+
+
+ -
+
+
+
-
+
+
+ File Save Policy
+
+
+
+
+
+
+ -
+
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ <html><head/><body><p>Choose how to deal with potential file name conflicts. Always open a dialog, only open a dialog if the output file already exists, overwrite any existing file or add a unique (3 digit) sequential ID to the file name.</p></body></html>
+
+
-
+
+ Open File Dialog
+
+
+ -
+
+ Open File Dialog on conflict
+
+
+ -
+
+ Overwrite existing file
+
+
+ -
+
+ Append Unique ID on conflict
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Post Processor
+
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
+
+
+ Post Processors Selection
+
+
+
+ -
+
+
+ true
+
+
+ <html><head/><body><p>It doesn't seem there are any post processor scripts installed. Pleas add some into your macro directory and make sure the file name ends with "_post.py".</p></body></html>
+
+
+
+ -
+
+
+ Default Post Processor
+
+
+
+ -
+
+
+ <html><head/><body><p>Select one of the post processors as the default.</p></body></html>
+
+
+ DefaultPostProcessor
+
+
+ Mod/Path
+
+
+
+ -
+
+
+ Default Arguments
+
+
+
+ -
+
+
+ <html><head/><body><p>Optional arguments passed to the default Post Processor specified above. See the Post Processor's documentation for supported arguments.</p></body></html>
+
+
+ DefaultPostProcessorArgs
+
+
+ Mod/Path
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
- -
-
-
- Geometry
-
-
-
-
-
-
-
-
-
-
- Default Geometry Tolerance
-
-
-
- -
-
-
- Default value for new Jobs, used for computing Paths. Smaller increases accuracy, but slows down computation
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
qPixmapFromMimeSource
+
+
+ Gui::InputField
+ QWidget
+
+
+
diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py
index babba2d3fe..afa448d431 100644
--- a/src/Mod/Path/PathScripts/PathPreferences.py
+++ b/src/Mod/Path/PathScripts/PathPreferences.py
@@ -26,12 +26,23 @@ import FreeCAD
import os
import glob
+import PathScripts.PathLog as PathLog
+
+PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
+PathLog.trackModule()
+
class PathPreferences:
- PostProcessorDefault = "PostProcessorDefault"
- PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
- PostProcessorBlacklist = "PostProcessorBlacklist"
+ DefaultFilePath = "DefaultFilePath"
+ DefaultJobTemplate = "DefaultJobTemplate"
+
+ PostProcessorDefault = "PostProcessorDefault"
+ PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
+ PostProcessorBlacklist = "PostProcessorBlacklist"
+ PostProcessorOutputFile = "PostProcessorOutputFile"
+ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
+
# Linear tolerance to use when generating Paths, eg when tesselating geometry
- GeometryTolerance = "GeometryTolerance"
+ GeometryTolerance = "GeometryTolerance"
@classmethod
def preferences(cls):
@@ -76,6 +87,30 @@ class PathPreferences:
def defaultGeometryTolerance(cls):
return cls.preferences().GetFloat(cls.GeometryTolerance, 0.01)
+ @classmethod
+ def defaultFilePath(cls):
+ return cls.preferences().GetString(cls.DefaultFilePath)
+
+ @classmethod
+ def filePath(cls):
+ path = cls.defaultFilePath()
+ if not path:
+ grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
+ path = grp.GetString("MacroPath", FreeCAD.getUserAppDataDir())
+ return path
+
+ @classmethod
+ def defaultJobTemplate(cls):
+ return cls.preferences().GetString(cls.DefaultJobTemplate)
+
+ @classmethod
+ def setJobDefaults(cls, filePath, jobTemplate, geometryTolerance):
+ PathLog.track("(%s='%s', %s, %s)" % (cls.DefaultFilePath, filePath, jobTemplate, geometryTolerance))
+ pref = cls.preferences()
+ pref.SetString(cls.DefaultFilePath, filePath)
+ pref.SetString(cls.DefaultJobTemplate, jobTemplate)
+ pref.SetFloat(cls.GeometryTolerance, geometryTolerance)
+
@classmethod
def postProcessorBlacklist(cls):
pref = cls.preferences()
@@ -85,19 +120,15 @@ class PathPreferences:
return eval(blacklist)
@classmethod
- def savePostProcessorDefaults(cls, processor, args, blacklist, geometryTolerance):
+ def setPostProcessorDefaults(cls, processor, args, blacklist):
pref = cls.preferences()
pref.SetString(cls.PostProcessorDefault, processor)
pref.SetString(cls.PostProcessorDefaultArgs, args)
pref.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist))
- pref.SetFloat(cls.GeometryTolerance, geometryTolerance)
- PostProcessorOutputFile = "PostProcessorOutputFile"
- PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
-
@classmethod
- def saveOutputFileDefaults(cls, file, policy):
+ def setOutputFileDefaults(cls, file, policy):
pref = cls.preferences()
pref.SetString(cls.PostProcessorOutputFile, file)
pref.SetString(cls.PostProcessorOutputPolicy, policy)
@@ -111,3 +142,4 @@ class PathPreferences:
def defaultOutputPolicy(cls):
pref = cls.preferences()
return pref.GetString(cls.PostProcessorOutputPolicy, "")
+
diff --git a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
index c40cf4dc67..605358ffa1 100644
--- a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
+++ b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
@@ -24,12 +24,17 @@
import FreeCAD
import FreeCADGui
+import PathScripts.PathLog as PathLog
+
from FreeCAD import Units
from PySide import QtCore, QtGui
from PathScripts.PathPreferences import PathPreferences
from PathScripts.PathPostProcessor import PostProcessor
+PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
+
+
class JobPreferencesPage:
def __init__(self, parent=None):
self.form = FreeCADGui.PySideUic.loadUi(":preferences/PathJob.ui")
@@ -39,6 +44,11 @@ class JobPreferencesPage:
self.processor = { }
def saveSettings(self):
+ filePath = self.form.leDefaultFilePath.text()
+ jobTemplate = self.form.leDefaultJobTemplate.text()
+ geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
+ PathPreferences.setJobDefaults(filePath, jobTemplate, geometryTolerance)
+
processor = str(self.form.defaultPostProcessor.currentText())
args = str(self.form.defaultPostProcessorArgs.text())
blacklist = []
@@ -46,12 +56,11 @@ class JobPreferencesPage:
item = self.form.postProcessorList.item(i)
if item.checkState() == QtCore.Qt.CheckState.Unchecked:
blacklist.append(item.text())
- geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
- PathPreferences.savePostProcessorDefaults(processor, args, blacklist, geometryTolerance)
+ PathPreferences.setPostProcessorDefaults(processor, args, blacklist)
path = str(self.form.leOutputFile.text())
policy = str(self.form.cboOutputPolicy.currentText())
- PathPreferences.saveOutputFileDefaults(path, policy)
+ PathPreferences.setOutputFileDefaults(path, policy)
def selectComboEntry(self, widget, text):
index = widget.findText(text, QtCore.Qt.MatchFixedString)
@@ -82,6 +91,9 @@ class JobPreferencesPage:
self.verifyAndUpdateDefaultPostProcessorWith(str(self.form.defaultPostProcessor.currentText()))
def loadSettings(self):
+ self.form.leDefaultFilePath.setText(PathPreferences.defaultFilePath())
+ self.form.leDefaultJobTemplate.setText(PathPreferences.defaultJobTemplate())
+
blacklist = PathPreferences.postProcessorBlacklist()
for processor in PathPreferences.allAvailablePostProcessors():
item = QtGui.QListWidgetItem(processor)
@@ -101,10 +113,12 @@ class JobPreferencesPage:
self.form.leOutputFile.setText(PathPreferences.defaultOutputFile())
self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy())
+ self.form.tbDefaultFilePath.clicked.connect(self.browseDefaultFilePath)
+ self.form.tbDefaultJobTemplate.clicked.connect(self.browseDefaultJobTemplate)
self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip)
self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor)
self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip)
- self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)
+ self.form.tbOutputFile.clicked.connect(self.browseOutputFile)
def getPostProcessor(self, name):
if not name in self.processor.keys():
@@ -136,7 +150,35 @@ class JobPreferencesPage:
self.form.defaultPostProcessor.setToolTip(self.postProcessorDefaultTooltip)
self.form.defaultPostProcessorArgs.setToolTip(self.postProcessorArgsDefaultTooltip)
- def browseFileSystem(self):
- foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - Output File/Directory", self.form.leOutputFile.text())
+ def bestGuessForFilePath(self):
+ path = self.form.leDefaultFilePath.text()
+ if not path:
+ path = PathPreferences.filePath()
+ return path
+
+ def browseDefaultJobTemplate(self):
+ path = self.form.leDefaultJobTemplate.text()
+ if not path:
+ path = self.bestGuessForFilePath()
+ foo = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),
+ "Path - Job Template",
+ path,
+ "job_*.xml")[0]
+ if foo:
+ self.form.leDefaultJobTemplate.setText(foo)
+
+
+ def browseDefaultFilePath(self):
+ path = self.bestGuessForFilePath()
+ foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - External File Directory", path)
+ if foo:
+ self.form.leDefaultFilePath.setText(foo)
+
+ def browseOutputFile(self):
+ path = self.form.leOutputFile.text()
+ foo = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow(), "Path - Output File/Directory", path)
if foo:
self.form.leOutputFile.setText(foo)
+
+
+