Basic Job preferences dialog
This commit is contained in:
parent
4262094bb6
commit
f5f85eba70
|
@ -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
|
||||
|
|
|
@ -86,5 +86,6 @@
|
|||
<file>panels/ContourEdit.ui</file>
|
||||
<file>panels/ProfileEdgesEdit.ui</file>
|
||||
<file>panels/DogboneEdit.ui</file>
|
||||
<file>preferences/PathJob.ui</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>General Path settings</string>
|
||||
<string>Job Preferences</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
|
@ -29,7 +29,7 @@
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="pathTestSetting1">
|
||||
<widget class="QCheckBox" name="pathTestSetting1">
|
||||
<property name="toolTip">
|
||||
<string>If this option is enabled, new paths will automatically be placed in the active project, which will be created if necessary.</string>
|
||||
</property>
|
||||
|
@ -55,25 +55,38 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Job Output</string>
|
||||
<string>Post Processor</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default Post Processor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="defaultPostProcessor">
|
||||
<property name="prefEntry" stdset="0">
|
||||
<string>DefaultPostProcessor</string>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<string>Mod/Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Default Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefLineEdit" name="defaultPostProcessorArgs">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="defaultPostProcessorArgs">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
|
@ -85,16 +98,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefLineEdit" name="defaultPostProcessor">
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DefaultPostProcessor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Path</cstring>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Enabled Post Processors </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QListWidget" name="postProcessorList"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -115,13 +128,6 @@
|
|||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
68
src/Mod/Path/PathScripts/PathPreferencesPathJob.py
Normal file
68
src/Mod/Path/PathScripts/PathPreferencesPathJob.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
|
||||
# * *
|
||||
# * 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())
|
||||
|
Loading…
Reference in New Issue
Block a user