diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt
index 3742c2170..1b064b1de 100644
--- a/src/Mod/Path/CMakeLists.txt
+++ b/src/Mod/Path/CMakeLists.txt
@@ -52,7 +52,6 @@ SET(PathScripts_SRCS
PathScripts/PathComment.py
PathScripts/PathStop.py
PathScripts/PathFromShape.py
- PathScripts/DlgSettingsPath.ui
PathScripts/PathKurveUtils.py
PathScripts/PathAreaUtils.py
PathScripts/slic3r_pre.py
@@ -68,6 +67,7 @@ SET(PathScripts_SRCS
PathScripts/PathSanity.py
PathScripts/PathToolLibraryManager.py
PathScripts/DogboneDressup.py
+ PathScripts/PathPreferencesPathJob.py
)
SET(PathScripts_NC_SRCS
diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc
index cf3e2b7b0..c85011817 100644
--- a/src/Mod/Path/Gui/Resources/Path.qrc
+++ b/src/Mod/Path/Gui/Resources/Path.qrc
@@ -86,5 +86,6 @@
panels/ContourEdit.ui
panels/ProfileEdgesEdit.ui
panels/DogboneEdit.ui
+ preferences/PathJob.ui
diff --git a/src/Mod/Path/PathScripts/DlgSettingsPath.ui b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
similarity index 79%
rename from src/Mod/Path/PathScripts/DlgSettingsPath.ui
rename to src/Mod/Path/Gui/Resources/preferences/PathJob.ui
index 6878e593a..f7ab52128 100644
--- a/src/Mod/Path/PathScripts/DlgSettingsPath.ui
+++ b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
@@ -11,7 +11,7 @@
- General Path settings
+ Job Preferences
@@ -29,7 +29,7 @@
-
-
-
+
If this option is enabled, new paths will automatically be placed in the active project, which will be created if necessary.
@@ -55,25 +55,38 @@
-
- Job Output
+ Post Processor
-
-
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
Default Post Processor
- -
+
-
+
+
+ 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>
@@ -85,16 +98,16 @@
- -
-
-
- DefaultPostProcessor
-
-
- Mod/Path
+
-
+
+
+ Enabled Post Processors
+ -
+
+
@@ -115,13 +128,6 @@
qPixmapFromMimeSource
-
-
- Gui::PrefCheckBox
- QCheckBox
-
-
-
diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py
index fe530fbc4..f620d22f2 100644
--- a/src/Mod/Path/InitGui.py
+++ b/src/Mod/Path/InitGui.py
@@ -70,6 +70,7 @@ class PathWorkbench (Workbench):
from PathScripts import PathContour
from PathScripts import PathProfileEdges
from PathScripts import DogboneDressup
+ from PathScripts import PathPreferencesPathJob
import PathCommands
# build commands list
@@ -115,9 +116,7 @@ class PathWorkbench (Workbench):
self.appendMenu([translate("Path", "&Path")], extracmdlist)
# Add preferences pages
- import os
- FreeCADGui.addPreferencePage(FreeCAD.getHomePath(
- ) + os.sep + "Mod" + os.sep + "Path" + os.sep + "PathScripts" + os.sep + "DlgSettingsPath.ui", "Path")
+ FreeCADGui.addPreferencePage(PathPreferencesPathJob.Page, "Path")
Log('Loading Path workbench... done\n')
diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py
index a24675f9e..b1d78398f 100644
--- a/src/Mod/Path/PathScripts/PathJob.py
+++ b/src/Mod/Path/PathScripts/PathJob.py
@@ -47,11 +47,14 @@ except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
+class PostProcessor:
-class ObjectPathJob:
+ Default = "PostProcessorDefault"
+ DefaultArgs = "PostProcessorDefaultArgs"
+ Blacklist = "PostProcessorBlacklist"
@classmethod
- def allPostProcessors(cls):
+ def all(cls):
path = FreeCAD.getHomePath() + ("Mod/Path/PathScripts/")
posts = glob.glob(path + '/*_post.py')
allposts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts]
@@ -64,6 +67,39 @@ class ObjectPathJob:
allposts.sort()
return allposts
+ @classmethod
+ def allEnabled(cls):
+ blacklist = cls.blacklist()
+ return [processor for processor in cls.all() if not processor in blacklist]
+
+
+ @classmethod
+ def default(cls):
+ preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ return preferences.GetString(cls.Default, "")
+
+ @classmethod
+ def defaultArgs(cls):
+ preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ return preferences.GetString(cls.DefaultArgs, "")
+
+ @classmethod
+ def blacklist(cls):
+ preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ blacklist = preferences.GetString(cls.Blacklist, "")
+ if not blacklist:
+ return []
+ return eval(blacklist)
+
+ @classmethod
+ def saveDefaults(cls, processor, args, blacklist):
+ preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ preferences.SetString(cls.Default, processor)
+ preferences.SetString(cls.DefaultArgs, args)
+ preferences.SetString(cls.Blacklist, "%s" % (blacklist))
+
+class ObjectPathJob:
+
def __init__(self, obj):
# obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
@@ -71,7 +107,7 @@ class ObjectPathJob:
obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
- obj.PostProcessor = self.allPostProcessors()
+ obj.PostProcessor = PostProcessor.allEnabled()
obj.PostProcessor = 'dumper'
obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
obj.PostProcessorArgs = ""
@@ -94,12 +130,10 @@ class ObjectPathJob:
obj.Proxy = self
- preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
- defaultPostProcessor = preferences.GetString("DefaultPostProcessor", "")
- print("DefaultPostProcessor = '%s'" % defaultPostProcessor)
+ defaultPostProcessor = PostProcessor.default()
if defaultPostProcessor:
obj.PostProcessor = defaultPostProcessor
- obj.PostProcessorArgs = preferences.GetString("DefaultPostProcessorArgs", "")
+ obj.PostProcessorArgs = PostProcessor.defaultArgs()
if FreeCAD.GuiUp:
ViewProviderJob(obj.ViewObject)
@@ -258,7 +292,7 @@ class TaskPanel:
self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui")
#self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/JobEdit.ui")
- for post in ObjectPathJob.allPostProcessors():
+ for post in PostProcessor.allEnabled():
self.form.cboPostProcessor.addItem(post)
self.updating = False
diff --git a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
new file mode 100644
index 000000000..5073bd97a
--- /dev/null
+++ b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+
+# ***************************************************************************
+# * *
+# * Copyright (c) 2014 Yorik van Havre *
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU Lesser General Public License (LGPL) *
+# * as published by the Free Software Foundation; either version 2 of *
+# * the License, or (at your option) any later version. *
+# * for detail see the LICENCE text file. *
+# * *
+# * This program is distributed in the hope that it will be useful, *
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# * GNU Library General Public License for more details. *
+# * *
+# * You should have received a copy of the GNU Library General Public *
+# * License along with this program; if not, write to the Free Software *
+# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
+# * USA *
+# * *
+# ***************************************************************************
+
+import FreeCAD
+import FreeCADGui
+from PySide import QtCore, QtGui
+from PathScripts import PathJob
+
+
+class Page:
+ def __init__(self, parent=None):
+ self.form = FreeCADGui.PySideUic.loadUi(":preferences/PathJob.ui")
+
+ def saveSettings(self):
+ print("saveSettings")
+ processor = str(self.form.defaultPostProcessor.currentText())
+ args = str(self.form.defaultPostProcessorArgs.text())
+ blacklist = []
+ for i in range(0, self.form.postProcessorList.count()):
+ item = self.form.postProcessorList.item(i)
+ if item.checkState() == QtCore.Qt.CheckState.Unchecked:
+ blacklist.append(item.text())
+ PathJob.PostProcessor.saveDefaults(processor, args, blacklist)
+
+ def loadSettings(self):
+ print("loadSettings")
+ self.form.defaultPostProcessor.addItem("")
+ blacklist = PathJob.PostProcessor.blacklist()
+ for processor in PathJob.PostProcessor.all():
+ self.form.defaultPostProcessor.addItem(processor)
+ item = QtGui.QListWidgetItem(processor)
+ if processor in blacklist:
+ item.setCheckState(QtCore.Qt.CheckState.Unchecked)
+ else:
+ item.setCheckState(QtCore.Qt.CheckState.Checked)
+ item.setFlags( QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable)
+ self.form.postProcessorList.addItem(item)
+
+ postindex = self.form.defaultPostProcessor.findText(PathJob.PostProcessor.default(), QtCore.Qt.MatchFixedString)
+
+ if postindex >= 0:
+ self.form.defaultPostProcessor.blockSignals(True)
+ self.form.defaultPostProcessor.setCurrentIndex(postindex)
+ self.form.defaultPostProcessor.blockSignals(False)
+
+ self.form.defaultPostProcessorArgs.setText(PathJob.PostProcessor.defaultArgs())
+