Skip to content

Commit

Permalink
Switched job assignments to be empty which uses the default from the …
Browse files Browse the repository at this point in the history
…prefrences - if no preferences can't be found the user is prompted.
  • Loading branch information
mlampert authored and wwmayer committed Nov 2, 2016
1 parent e1a5b9a commit 1879103
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 146 deletions.
1 change: 1 addition & 0 deletions src/Mod/Path/CMakeLists.txt
Expand Up @@ -69,6 +69,7 @@ SET(PathScripts_SRCS
PathScripts/PathToolLibraryManager.py
PathScripts/DogboneDressup.py
PathScripts/PathPreferencesPathJob.py
PathScripts/PathPreferences.py
)

SET(PathScripts_NC_SRCS
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/Gui/Resources/Path.qrc
Expand Up @@ -86,6 +86,7 @@
<file>panels/ContourEdit.ui</file>
<file>panels/ProfileEdgesEdit.ui</file>
<file>panels/DogboneEdit.ui</file>
<file>panels/DlgSelectPostProcessor.ui</file>
<file>preferences/PathJob.ui</file>
</qresource>
</RCC>
81 changes: 81 additions & 0 deletions src/Mod/Path/Gui/Resources/panels/DlgSelectPostProcessor.ui
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Post Processor</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QListWidget" name="lwPostProcessor">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>351</width>
<height>191</height>
</rect>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select one of the post processors.&lt;/p&gt;&lt;p&gt;FreeCAD comes with several post processors pre-installed, please make sure at least one of them is enabled in your preferences.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
14 changes: 7 additions & 7 deletions src/Mod/Path/Gui/Resources/panels/JobEdit.ui
Expand Up @@ -35,15 +35,15 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="General">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>409</height>
<width>363</width>
<height>443</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -146,7 +146,7 @@
<x>0</x>
<y>0</y>
<width>378</width>
<height>409</height>
<height>391</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -215,8 +215,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>409</height>
<width>424</width>
<height>376</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -283,7 +283,7 @@
</property>
<item>
<property name="text">
<string>Use default</string>
<string></string>
</property>
</item>
<item>
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/Gui/Resources/preferences/PathJob.ui
Expand Up @@ -62,7 +62,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="browseFileSystem">
<widget class="QPushButton" name="pbBrowseFileSystem">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down
27 changes: 11 additions & 16 deletions src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -25,11 +25,11 @@
import FreeCAD
import Path
from PySide import QtCore, QtGui
import os
import glob
from PathScripts.PathPostProcessor import PostProcessor
from PathScripts.PathPost import CommandPathPost as PathPost
from PathScripts.PathPreferences import PathPreferences
import Draft
import os
import glob


FreeCADGui = None
Expand All @@ -49,7 +49,7 @@ def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)

class OutputPolicy:
Default = 'Use default'
Default = ''
Dialog = 'Open File Dialog'
DialogOnConflict = 'Open File Dialog on conflict'
Overwrite = 'Overwrite existing file'
Expand All @@ -61,18 +61,18 @@ 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"))
obj.OutputFile = PathPost.defaultOutputFile()
obj.OutputFile = ''
obj.setEditorMode("OutputFile", 0) # set to default mode
obj.addProperty("App::PropertyEnumeration", "OutputPolicy", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The policy on how to save output files and resolve name conflicts"))
obj.OutputPolicy = OutputPolicy.All
obj.OutputPolicy = OutputPolicy.Default

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 = PostProcessor.allEnabled()
obj.PostProcessor = 'dumper'
obj.PostProcessor = PathPreferences.allEnabledPostProcessors([''])
obj.PostProcessor = ''
obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
obj.PostProcessorArgs = ""
obj.PostProcessorArgs = ''
obj.addProperty("App::PropertyString", "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program"))

obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program"))
Expand All @@ -92,11 +92,6 @@ def __init__(self, obj):

obj.Proxy = self

defaultPostProcessor = PostProcessor.default()
if defaultPostProcessor:
obj.PostProcessor = defaultPostProcessor
obj.PostProcessorArgs = PostProcessor.defaultArgs()

if FreeCAD.GuiUp:
ViewProviderJob(obj.ViewObject)

Expand All @@ -111,7 +106,7 @@ def onChanged(self, obj, prop):
mode = 2
obj.setEditorMode('Placement', mode)

if prop == "PostProcessor":
if prop == "PostProcessor" and obj.PostProcessor:
processor = PostProcessor.load(obj.PostProcessor)
if processor.units:
obj.MachineUnits = processor.units
Expand Down Expand Up @@ -236,7 +231,7 @@ def __init__(self):
self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui")
#self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/JobEdit.ui")

for post in PostProcessor.allEnabled():
for post in PathPreferences.allEnabledPostProcessors(['']):
self.form.cboPostProcessor.addItem(post)
self.updating = False

Expand Down Expand Up @@ -341,7 +336,7 @@ def open(self):

def setFile(self):
filename = QtGui.QFileDialog.getSaveFileName(self.form, translate("PathJob", "Select Output File", None), None, translate("Path Job", "All Files (*.*)", None))
if filename:
if filename and filename[0]:
self.obj.OutputFile = str(filename[0])
self.setFields()

Expand Down

0 comments on commit 1879103

Please sign in to comment.