diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt
index f700376e8c..392eabda92 100644
--- a/src/Mod/Path/CMakeLists.txt
+++ b/src/Mod/Path/CMakeLists.txt
@@ -102,6 +102,7 @@ SET(PathScripts_SRCS
PathScripts/PathSurface.py
PathScripts/PathSurfaceGui.py
PathScripts/PathToolBit.py
+ PathScripts/PathToolBitCmd.py
PathScripts/PathToolBitEdit.py
PathScripts/PathToolBitGui.py
PathScripts/PathToolController.py
diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc
index e6eae76dbc..26f744bec8 100644
--- a/src/Mod/Path/Gui/Resources/Path.qrc
+++ b/src/Mod/Path/Gui/Resources/Path.qrc
@@ -48,9 +48,10 @@
icons/Path-Speed.svg
icons/Path-Stock.svg
icons/Path-Stop.svg
+ icons/Path-ToolBit.svg
icons/Path-ToolChange.svg
icons/Path-ToolController.svg
- icons/Path-ToolDuplicate.svg
+ icons/Path-ToolDuplicate.svg
icons/Path-Toolpath.svg
icons/Path-ToolTable.svg
icons/Path-Area.svg
diff --git a/src/Mod/Path/Gui/Resources/icons/Path-ToolBit.svg b/src/Mod/Path/Gui/Resources/icons/Path-ToolBit.svg
new file mode 100644
index 0000000000..025637f1bc
--- /dev/null
+++ b/src/Mod/Path/Gui/Resources/icons/Path-ToolBit.svg
@@ -0,0 +1,933 @@
+
+
+
+
diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py
index bca94eef9f..04bc791896 100644
--- a/src/Mod/Path/InitGui.py
+++ b/src/Mod/Path/InitGui.py
@@ -71,6 +71,7 @@ class PathWorkbench (Workbench):
FreeCADGui.addIconPath(":/icons")
from PathScripts import PathGuiInit
from PathScripts import PathJobCmd
+ from PathScripts import PathToolBitCmd
import PathCommands
PathGuiInit.Startup()
@@ -112,7 +113,7 @@ class PathWorkbench (Workbench):
if extracmdlist:
self.appendToolbar(QtCore.QT_TRANSLATE_NOOP("Path", "Helpful Tools"), extracmdlist)
- self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], projcmdlist +["Path_ExportTemplate", "Separator"] + toolcmdlist +["Separator"] + twodopcmdlist + engravecmdlist +["Separator"] +threedopcmdlist +["Separator"])
+ self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")], projcmdlist +["Path_ExportTemplate", "Path_ToolBitCreate", "Separator"] + toolcmdlist +["Separator"] + twodopcmdlist + engravecmdlist +["Separator"] +threedopcmdlist +["Separator"])
self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path"), QtCore.QT_TRANSLATE_NOOP(
"Path", "Path Dressup")], dressupcmdlist)
self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path"), QtCore.QT_TRANSLATE_NOOP(
diff --git a/src/Mod/Path/PathScripts/PathToolBitCmd.py b/src/Mod/Path/PathScripts/PathToolBitCmd.py
new file mode 100644
index 0000000000..e3a81a3f24
--- /dev/null
+++ b/src/Mod/Path/PathScripts/PathToolBitCmd.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+
+# ***************************************************************************
+# * *
+# * Copyright (c) 2019 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
+from PySide import QtCore
+
+class CommandToolBitCreate:
+ '''
+ Command used to create a new Tool.
+ '''
+
+ def __init__(self):
+ pass
+
+ def GetResources(self):
+ return {'Pixmap': 'Path-ToolBit',
+ 'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Tool", "Create Tool"),
+ 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Job", "Creates a new ToolBit object")}
+
+ def IsActive(self):
+ return FreeCAD.ActiveDocument is not None
+
+ def Activated(self):
+ import PathScripts.PathToolBitGui as PathToolBitGui
+ obj = PathToolBitGui.Create()
+ obj.ViewObject.Proxy.setCreate(obj.ViewObject)
+
+if FreeCAD.GuiUp:
+ import FreeCADGui
+ FreeCADGui.addCommand('Path_ToolBitCreate', CommandToolBitCreate())
+
+FreeCAD.Console.PrintLog("Loading PathToolBitCmd... done\n")
diff --git a/src/Mod/Path/PathScripts/PathToolBitGui.py b/src/Mod/Path/PathScripts/PathToolBitGui.py
index 1fe0932d07..ac8c51536f 100644
--- a/src/Mod/Path/PathScripts/PathToolBitGui.py
+++ b/src/Mod/Path/PathScripts/PathToolBitGui.py
@@ -67,7 +67,7 @@ class ViewProvider(object):
pixmap = QtGui.QPixmap()
pixmap.loadFromData(png, "PNG")
return QtGui.QIcon(pixmap)
- return ':/icons/Path-ToolChange.svg'
+ return ':/icons/Path-ToolBit.svg'
def __getstate__(self):
return None
@@ -80,13 +80,20 @@ class ViewProvider(object):
# pylint: disable=unused-argument
return 'Default'
- def setEdit(self, vobj, mode=0):
- # pylint: disable=unused-argument
+ def _openTaskPanel(self, vobj, deleteOnReject):
PathLog.track()
- self.taskPanel = TaskPanel(vobj)
+ self.taskPanel = TaskPanel(vobj, deleteOnReject)
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(self.taskPanel)
self.taskPanel.setupUi()
+
+ def setCreate(self, vobj):
+ PathLog.track()
+ self._openTaskPanel(vobj, True)
+
+ def setEdit(self, vobj, mode=0):
+ # pylint: disable=unused-argument
+ self._openTaskPanel(vobj, False)
return True
def unsetEdit(self, vobj, mode):
@@ -106,18 +113,24 @@ class ViewProvider(object):
class TaskPanel:
'''TaskPanel for the SetupSheet - if it is being edited directly.'''
- def __init__(self, vobj):
+ def __init__(self, vobj, deleteOnReject):
PathLog.track(vobj.Object.Label)
self.vobj = vobj
self.obj = vobj.Object
self.editor = PathToolBitEdit.ToolBitEditor(self.obj)
self.form = self.editor.form
+ self.deleteOnReject = deleteOnReject
FreeCAD.ActiveDocument.openTransaction(translate("PathToolBit", "Edit ToolBit"))
def reject(self):
- self.editor.reject()
FreeCAD.ActiveDocument.abortTransaction()
+ self.editor.reject()
FreeCADGui.Control.closeDialog()
+ if self.deleteOnReject:
+ FreeCAD.ActiveDocument.openTransaction(translate("PathToolBit", "Uncreate ToolBit"))
+ self.editor.reject()
+ FreeCAD.ActiveDocument.removeObject(self.obj.Name)
+ FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def accept(self):