Skip to content

Commit

Permalink
Added suppor for default OutputFile with templates and a policy on ho…
Browse files Browse the repository at this point in the history
…w to deal with file name conflicts.
  • Loading branch information
mlampert authored and wwmayer committed Nov 2, 2016
1 parent a3c4903 commit e1a5b9a
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 78 deletions.
68 changes: 58 additions & 10 deletions src/Mod/Path/Gui/Resources/panels/JobEdit.ui
Expand Up @@ -42,8 +42,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>363</width>
<height>443</height>
<width>378</width>
<height>409</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -146,7 +146,7 @@
<x>0</x>
<y>0</y>
<width>378</width>
<height>391</height>
<height>409</height>
</rect>
</property>
<attribute name="icon">
Expand Down Expand Up @@ -216,7 +216,7 @@
<x>0</x>
<y>0</y>
<width>378</width>
<height>391</height>
<height>409</height>
</rect>
</property>
<attribute name="icon">
Expand All @@ -229,14 +229,27 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QGridLayout" name="gridLayout_6">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Output File</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btnSelectFile">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="leOutputFile">
<property name="sizePolicy">
Expand All @@ -245,19 +258,54 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter a path and optionally file name (see below) to be used as the default for the post processor export.&lt;/p&gt;&lt;p&gt;The following substitutions are performed before the name is resolved at the time of the post processing:&lt;/p&gt;&lt;p&gt;%D ... directory of the active document&lt;br/&gt;%d ... name of the active document (with extension)&lt;br/&gt;%M ... user macro directory&lt;br/&gt;%j ... name of the active Job object&lt;/p&gt;&lt;p&gt;The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):&lt;/p&gt;&lt;p&gt;&amp;quot;/home/cnc/%d.g-code&amp;quot;&lt;/p&gt;&lt;p&gt;See the file save policy below on how to deal with name conflicts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btnSelectFile">
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>File Save Policy</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="cboOutputPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>...</string>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Use default</string>
</property>
</item>
<item>
<property name="text">
<string>Open File Dialog</string>
</property>
</item>
<item>
<property name="text">
<string>Open File Dialog on conflict</string>
</property>
</item>
<item>
<property name="text">
<string>Overwrite existing file</string>
</property>
</item>
<item>
<property name="text">
<string>Append Unique ID on conflict</string>
</property>
</item>
</widget>
</item>
</layout>
Expand Down
165 changes: 124 additions & 41 deletions src/Mod/Path/Gui/Resources/preferences/PathJob.ui
Expand Up @@ -22,32 +22,115 @@
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>General Path settings</string>
<string>Output File</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<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>
<property name="text">
<string>Automatic project handling</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>pathAutoProject</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default Path</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="leOutputFile">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter a path and optionally file name (see below) to be used as the default for the post processor export.&lt;/p&gt;&lt;p&gt;The following substitutions are performed before the name is resolved at the time of the post processing:&lt;/p&gt;&lt;p&gt;%D ... directory of the active document&lt;br/&gt;%d ... name of the active document (with extension)&lt;br/&gt;%M ... user macro directory&lt;br/&gt;%j ... name of the active Job object&lt;/p&gt;&lt;p&gt;The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):&lt;/p&gt;&lt;p&gt;&amp;quot;/home/cnc/%d.g-code&amp;quot;&lt;/p&gt;&lt;p&gt;See the file save policy below on how to deal with name conflicts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="browseFileSystem">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Open a file system browser to select default path for output files.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>File Save Policy</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="cboOutputPolicy">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Open File Dialog</string>
</property>
</item>
<item>
<property name="text">
<string>Open File Dialog on conflict</string>
</property>
</item>
<item>
<property name="text">
<string>Overwrite existing file</string>
</property>
</item>
<item>
<property name="text">
<string>Append Unique ID on conflict</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
Expand All @@ -61,6 +144,23 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Post Processors Selection </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QListWidget" name="postProcessorList">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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 &amp;quot;_post.py&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
Expand Down Expand Up @@ -101,23 +201,6 @@
</property>
</widget>
</item>
<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">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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 &amp;quot;_post.py&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Path/InitGui.py
Expand Up @@ -31,6 +31,10 @@ def __init__(self):
self.__class__.ToolTip = "Path workbench"

def Initialize(self):
# Add preferences pages - before loading PathGui to properly order pages of Path group
from PathScripts import PathPreferencesPathJob
FreeCADGui.addPreferencePage(PathPreferencesPathJob.Page, "Path")

# load the builtin modules
import Path
import PathGui
Expand Down Expand Up @@ -70,7 +74,6 @@ def Initialize(self):
from PathScripts import PathContour
from PathScripts import PathProfileEdges
from PathScripts import DogboneDressup
from PathScripts import PathPreferencesPathJob
import PathCommands

# build commands list
Expand Down Expand Up @@ -115,9 +118,6 @@ def translate(context, text):
# "Path", "Remote Operations")], remotecmdlist)
self.appendMenu([translate("Path", "&Path")], extracmdlist)

# Add preferences pages
FreeCADGui.addPreferencePage(PathPreferencesPathJob.Page, "Path")

Log('Loading Path workbench... done\n')

def GetClassName(self):
Expand Down

0 comments on commit e1a5b9a

Please sign in to comment.