diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt
index f01eb9b64..32ce98cae 100644
--- a/src/Mod/Path/CMakeLists.txt
+++ b/src/Mod/Path/CMakeLists.txt
@@ -45,6 +45,7 @@ SET(PathScripts_SRCS
PathScripts/PathPost.py
PathScripts/PathPostProcessor.py
PathScripts/PathPreferences.py
+ PathScripts/PathPreferencesPathDressup.py
PathScripts/PathPreferencesPathJob.py
PathScripts/PathProfile.py
PathScripts/PathProfileEdges.py
diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc
index 7299f8d86..b6800333c 100644
--- a/src/Mod/Path/Gui/Resources/Path.qrc
+++ b/src/Mod/Path/Gui/Resources/Path.qrc
@@ -66,6 +66,7 @@
panels/ToolControl.ui
panels/ToolEdit.ui
panels/ToolLibraryEditor.ui
+ preferences/PathDressupHoldingTags.ui
preferences/PathJob.ui
translations/Path_af.qm
translations/Path_cs.qm
diff --git a/src/Mod/Path/Gui/Resources/preferences/PathDressupHoldingTags.ui b/src/Mod/Path/Gui/Resources/preferences/PathDressupHoldingTags.ui
new file mode 100644
index 000000000..c805d52a9
--- /dev/null
+++ b/src/Mod/Path/Gui/Resources/preferences/PathDressupHoldingTags.ui
@@ -0,0 +1,133 @@
+
+
+ Form
+
+
+
+ 0
+ 0
+ 477
+ 478
+
+
+
+ Form
+
+
+ -
+
+
+ Tag Parameters
+
+
+
-
+
+
+ Default Width
+
+
+
+ -
+
+
+ <html><head/><body><p>Set the default width of holding tags.</p><p>If the width is set to 0 the dressup will try to guess a reasonable value based on the path itself.</p></body></html>
+
+
+
+ -
+
+
+ Default Height
+
+
+
+ -
+
+
+ <html><head/><body><p>Default height of holding tags.</p><p>If the specified height is 0 the dressup will use half the height of the part. Should the height be bigger than the height of the part the dressup will reduce the height to the height of the part.</p></body></html>
+
+
+
+ -
+
+
+ Default Angle
+
+
+
+ -
+
+
+ <html><head/><body><p>Plunge angle for the holding tags ascent and descent.</p></body></html>
+
+
+ 5.000000000000000
+
+
+ 90.000000000000000
+
+
+ 15.000000000000000
+
+
+ 45.000000000000000
+
+
+
+
+
+
+ -
+
+
+ Tag Generation
+
+
+
-
+
+
+ Initial # Tags
+
+
+
+ -
+
+
+ <html><head/><body><p>Specify the number of tags generated when a new dressup is created.</p></body></html>
+
+
+ 2
+
+
+ 4
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Gui::InputField
+ QLineEdit
+
+
+
+
+
+
diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py
index 22b13882b..dd0c1d6f3 100644
--- a/src/Mod/Path/InitGui.py
+++ b/src/Mod/Path/InitGui.py
@@ -31,8 +31,9 @@ class PathWorkbench (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")
+ from PathScripts import PathPreferencesPathJob, PathPreferencesPathDressup
+ FreeCADGui.addPreferencePage(PathPreferencesPathJob.JobPreferencesPage, "Path")
+ FreeCADGui.addPreferencePage(PathPreferencesPathDressup.DressupPreferencesPage, "Path")
# load the builtin modules
import Path
diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
index 8841f4bca..d7f31bacd 100644
--- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
+++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
@@ -27,6 +27,7 @@ import Draft
import DraftGeomUtils
import DraftGui
import Path
+import PathScripts.PathPreferencesPathDressup as PathPreferencesPathDressup
import Part
import copy
import math
@@ -103,19 +104,65 @@ def debugCone(vector, r1, r2, height, label, color = None):
if color:
obj.ViewObject.ShapeColor = color
-class Tag:
+
+class HoldingTagsPreferences:
+ DefaultHoldingTagWidth = 'DefaultHoldingTagWidth'
+ DefaultHoldingTagHeight = 'DefaultHoldingTagHeight'
+ DefaultHoldingTagAngle = 'DefaultHoldingTagAngle'
+ DefaultHoldingTagCount = 'DefaultHoldingTagCount'
@classmethod
- def FromString(cls, string):
- try:
- t = eval(string)
- return Tag(t[0], t[1], t[2], t[3], t[4], t[5])
- except:
- return None
+ def defaultWidth(cls, ifNotSet):
+ value = PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagWidth, ifNotSet)
+ if value == 0.0:
+ return ifNotSet
+ return value
- def toString(self):
- return str((self.x, self.y, self.width, self.height, self.angle, self.enabled))
+ @classmethod
+ def defaultHeight(cls, ifNotSet):
+ value = PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagHeight, ifNotSet)
+ if value == 0.0:
+ return ifNotSet
+ return value
+ @classmethod
+ def defaultAngle(cls, ifNotSet = 45.0):
+ value = PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagAngle, ifNotSet)
+ if value < 10.0:
+ return ifNotSet
+ return value
+
+ @classmethod
+ def defaultCount(cls, ifNotSet = 4):
+ value = PathPreferences.preferences().GetUnsigned(cls.DefaultHoldingTagCount, ifNotSet)
+ if value < 2:
+ return float(ifNotSet)
+ return float(value)
+
+ def __init__(self):
+ self.form = FreeCADGui.PySideUic.loadUi(":/preferences/PathDressupHoldingTags.ui")
+ self.label = 'Holding Tags'
+
+ def loadSettings(self):
+ print("holding tags - load settings")
+ self.form.ifWidth.setText(FreeCAD.Units.Quantity(self.defaultWidth(0), FreeCAD.Units.Length).UserString)
+ self.form.ifHeight.setText(FreeCAD.Units.Quantity(self.defaultHeight(0), FreeCAD.Units.Length).UserString)
+ self.form.dsbAngle.setValue(self.defaultAngle())
+ self.form.sbCount.setValue(self.defaultCount())
+
+ def saveSettings(self):
+ print("holding tags - save settings")
+ pref = PathPreferences.preferences()
+ pref.SetFloat(self.DefaultHoldingTagWidth, FreeCAD.Units.Quantity(self.form.ifWidth.text()).Value)
+ pref.SetFloat(self.DefaultHoldingTagHeight, FreeCAD.Units.Quantity(self.form.ifHeight.text()).Value)
+ pref.SetFloat(self.DefaultHoldingTagAngle, self.form.dsbAngle.value())
+ pref.SetUnsigned(self.DefaultHoldingTagCount, self.form.sbCount.value())
+
+ @classmethod
+ def preferencesPage(cls):
+ return HoldingTagsPreferences()
+
+class Tag:
def __init__(self, x, y, width, height, angle, enabled=True):
debugPrint("Tag(%.2f, %.2f, %.2f, %.2f, %.2f, %d)" % (x, y, width, height, angle/math.pi, enabled))
self.x = x
@@ -456,7 +503,7 @@ class PathData:
edges = sorted(self.base.Edges, key=lambda e: e.Length)
return (edges[0], edges[-1])
- def generateTags(self, obj, count=None, width=None, height=None, angle=90, spacing=None):
+ def generateTags(self, obj, count, width=None, height=None, angle=None, spacing=None):
debugPrint("generateTags(%s, %s, %s, %s, %s)" % (count, width, height, angle, spacing))
#for e in self.base.Edges:
# debugMarker(e.Vertexes[0].Point, 'base', (0.0, 1.0, 1.0), 0.2)
@@ -544,14 +591,20 @@ class PathData:
def defaultTagHeight(self):
if hasattr(self.obj, 'Base') and hasattr(self.obj.Base, 'StartDepth') and hasattr(self.obj.Base, 'FinalDepth'):
- return (self.obj.Base.StartDepth - self.obj.Base.FinalDepth).Value / 2
- return (self.maxZ - self.minZ) / 2
+ pathHeight = (self.obj.Base.StartDepth - self.obj.Base.FinalDepth).Value
+ else:
+ pathHeight = self.maxZ - self.minZ
+ height = HoldingTagsPreferences.defaultHeight(pathHeight / 2)
+ if height > pathHeight:
+ return pathHeight
+ return height
def defaultTagWidth(self):
- return self.shortestAndLongestPathEdge()[1].Length / 10
+ width = self.shortestAndLongestPathEdge()[1].Length / 10
+ return HoldingTagsPreferences.defaultWidth(width)
def defaultTagAngle(self):
- return 45
+ return HoldingTagsPreferences.defaultAngle()
def sortedTags(self, tags):
ordered = []
@@ -762,7 +815,7 @@ class ObjectDressup:
obj.Path = self.createPath(self.pathData.edges, self.tags, self.pathData.rapid)
print("execute - done")
- def setup(self, obj, generate=None):
+ def setup(self, obj, generate=False):
print("setup")
self.obj = obj
try:
@@ -786,7 +839,8 @@ class ObjectDressup:
obj.Height = self.pathData.defaultTagHeight()
obj.Width = self.pathData.defaultTagWidth()
obj.Angle = self.pathData.defaultTagAngle()
- self.generateTags(obj, min(2, generate))
+ count = HoldingTagsPreferences.defaultCount()
+ self.generateTags(obj, count)
return self.pathData
def setXyEnabled(self, triples):
@@ -807,6 +861,12 @@ class ObjectDressup:
self.setup(obj)
return self.pathData.pointIsOnPath(point)
+ @classmethod
+ def preferencesPage(cls):
+ return HoldingTagsPreferences()
+
+PathPreferencesPathDressup.RegisterDressup(ObjectDressup)
+
class TaskPanel:
DataX = QtCore.Qt.ItemDataRole.UserRole
DataY = QtCore.Qt.ItemDataRole.UserRole + 1
@@ -1292,10 +1352,11 @@ class CommandPathDressupHoldingTags:
FreeCADGui.doCommand('PathScripts.PathDressupHoldingTags.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
- FreeCADGui.doCommand('dbo.setup(obj, 4.)')
+ FreeCADGui.doCommand('dbo.setup(obj, True)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
+
if FreeCAD.GuiUp:
# register the FreeCAD command
FreeCADGui.addCommand('PathDressup_HoldingTags', CommandPathDressupHoldingTags())
diff --git a/src/Mod/Path/PathScripts/PathPreferencesPathDressup.py b/src/Mod/Path/PathScripts/PathPreferencesPathDressup.py
new file mode 100644
index 000000000..86fa52507
--- /dev/null
+++ b/src/Mod/Path/PathScripts/PathPreferencesPathDressup.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+# ***************************************************************************
+# * *
+# * Copyright (c) 2016 sliptonic *
+# * *
+# * 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.PathPreferences import PathPreferences
+
+_dressups = []
+
+def RegisterDressup(dressup):
+ _dressups.append(dressup)
+
+class DressupPreferencesPage:
+ def __init__(self, parent=None):
+ print('dressup - __init__')
+ self.form = QtGui.QToolBox()
+ self.form.setWindowTitle('Dressups')
+ pages = []
+ for dressup in _dressups:
+ page = dressup.preferencesPage()
+ if hasattr(page, 'icon') and page.icon:
+ self.form.addItem(page.form, page.icon, page.label)
+ else:
+ self.form.addItem(page.form, page.label)
+ pages.append(page)
+ self.pages = pages
+
+ def saveSettings(self):
+ print('dressup - save settings')
+ for page in self.pages:
+ page.saveSettings()
+
+ def loadSettings(self):
+ print('dressup - load settings')
+ for page in self.pages:
+ page.loadSettings()
+
diff --git a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
index 25e12f28a..cb374133d 100644
--- a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
+++ b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
@@ -29,7 +29,7 @@ from PathScripts.PathPreferences import PathPreferences
from PathScripts.PathPostProcessor import PostProcessor
-class Page:
+class JobPreferencesPage:
def __init__(self, parent=None):
self.form = FreeCADGui.PySideUic.loadUi(":preferences/PathJob.ui")