diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc
index cb19bd7a15..b461c8cdf6 100644
--- a/src/Mod/Path/Gui/Resources/Path.qrc
+++ b/src/Mod/Path/Gui/Resources/Path.qrc
@@ -109,6 +109,7 @@
panels/SetupGlobal.ui
panels/SetupOp.ui
panels/ToolBitEditor.ui
+ panels/ToolBitLibraryEdit.ui
panels/ToolBitSelector.ui
panels/ToolEditor.ui
panels/ToolLibraryEditor.ui
diff --git a/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui b/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
new file mode 100644
index 0000000000..7f0f2b040f
--- /dev/null
+++ b/src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui
@@ -0,0 +1,249 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 958
+ 508
+
+
+
+ ToolBit Library
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ ...
+
+
+
+ :/icons/document-new.svg:/icons/document-new.svg
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/document-open.svg:/icons/document-open.svg
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/document-save.svg:/icons/document-save.svg
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/document-save-as.svg:/icons/document-save-as.svg
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/preferences-system.svg:/icons/preferences-system.svg
+
+
+
+
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ QAbstractItemView::SelectRows
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Add ...
+
+
+
+ :/icons/list-add.svg:/icons/list-add.svg
+
+
+
+ -
+
+
+ Delete
+
+
+
+ :/icons/list-remove.svg:/icons/list-remove.svg
+
+
+
+ -
+
+
+ Up
+
+
+
+ :/icons/button_up.svg:/icons/button_up.svg
+
+
+
+ -
+
+
+ Down
+
+
+
+ :/icons/button_down.svg:/icons/button_down.svg
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 115
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ Dialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ Dialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/Mod/Path/PathScripts/PathToolBit.py b/src/Mod/Path/PathScripts/PathToolBit.py
index 25825a1e67..4d5ae87a79 100644
--- a/src/Mod/Path/PathScripts/PathToolBit.py
+++ b/src/Mod/Path/PathScripts/PathToolBit.py
@@ -261,10 +261,13 @@ class ToolBit(object):
PathLog.error("Could not save tool %s to %s (%s)" % (obj.Label, path, e))
raise
+def Declaration(path):
+ with open(path, 'r') as fp:
+ return json.load(fp)
+
def CreateFrom(path, name = 'ToolBit'):
try:
- with open(path, 'r') as fp:
- data = json.load(fp)
+ data = Declaration(path)
obj = Create(name, data['template'])
obj.Label = data['name']
params = data['parameter']
diff --git a/src/Mod/Path/PathScripts/PathToolBitGui.py b/src/Mod/Path/PathScripts/PathToolBitGui.py
index d6d6c2b7a6..35e13f5c9a 100644
--- a/src/Mod/Path/PathScripts/PathToolBitGui.py
+++ b/src/Mod/Path/PathScripts/PathToolBitGui.py
@@ -163,7 +163,7 @@ class ToolBitSelector(object):
ToolRole = QtCore.Qt.UserRole + 1
def __init__(self):
- self.form = FreeCADGui.PySideUic.loadUi(":/panels/ToolBitSelector.ui")
+ self.form = FreeCADGui.PySideUic.loadUi(':/panels/ToolBitSelector.ui')
self.setupUI()
def updateTools(self, selected=None):
@@ -269,13 +269,17 @@ def CreateFrom(path, name = 'ToolBit'):
FreeCAD.ActiveDocument.commitTransaction()
return tool
-def LoadTool(parent = None):
- '''LoadTool(parent=None) ... Open a file dialog to load a tool from a file.'''
+def GetToolFile(parent = None):
if parent is None:
parent = QtGui.QApplication.activeWindow()
foo = QtGui.QFileDialog.getOpenFileName(parent, "Tool", PathPreferences.lastPathToolBit(), "*.fctb")
if foo and foo[0]:
- return CreateFrom(foo[0])
+ return foo[0]
return None
+def LoadTool(parent = None):
+ '''LoadTool(parent=None) ... Open a file dialog to load a tool from a file.'''
+ foo = GetToolFile(parent)
+ return CreateFrom(foo) if foo else foo
+
PathIconViewProvider.RegisterViewProvider('ToolBit', ViewProvider)
diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
new file mode 100644
index 0000000000..00bc56104f
--- /dev/null
+++ b/src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
@@ -0,0 +1,117 @@
+# -*- 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 FreeCADGui
+import PathScripts.PathLog as PathLog
+import PathScripts.PathToolBit as PathToolBit
+import PathScripts.PathToolBitGui as PathToolBitGui
+import PySide
+
+import os
+import traceback
+
+PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
+PathLog.trackModule(PathLog.thisModule())
+
+class Delegate(PySide.QtGui.QStyledItemDelegate):
+
+ def createEditor(self, parent, option, index):
+ PathLog.track(index)
+ return None
+ def setEditorData(self, widget, index):
+ PathLog.track(index)
+ def setModelData(self, widget, model, index):
+ PathLog.track(index)
+ def updateEditorGeometry(self, widget, option, index):
+ PathLog.track(index)
+ widget.setGeometry(option.rect)
+
+class ToolBitLibrary(object):
+
+ def __init__(self):
+ self.form = FreeCADGui.PySideUic.loadUi(':/panels/ToolBitLibraryEdit.ui')
+ #self.form = FreeCADGui.PySideUic.loadUi('src/Mod/Path/Gui/Resources/panels/ToolBitLibraryEdit.ui')
+ self.setupUI()
+
+ def toolAdd(self):
+ PathLog.track()
+ try:
+ foo = PathToolBitGui.GetToolFile(self.form)
+ if foo:
+ tool = PathToolBit.Declaration(foo)
+ nr = 0
+ for row in range(self.model.rowCount()):
+ itemNr = int(self.model.item(row, 0).data(PySide.QtCore.Qt.EditRole))
+ nr = max(nr, itemNr)
+
+ toolNr = PySide.QtGui.QStandardItem()
+ toolNr.setData(nr + 1, PySide.QtCore.Qt.EditRole)
+
+ toolName = PySide.QtGui.QStandardItem()
+ toolName.setData(tool['name'], PySide.QtCore.Qt.EditRole)
+ toolName.setEditable(False)
+
+ toolTemplate = PySide.QtGui.QStandardItem()
+ toolTemplate.setData(os.path.splitext(os.path.basename(tool['template']))[0], PySide.QtCore.Qt.EditRole)
+ toolTemplate.setEditable(False)
+
+ toolDiameter = PySide.QtGui.QStandardItem()
+ toolDiameter.setData(tool['parameter']['Diameter'], PySide.QtCore.Qt.EditRole)
+ toolDiameter.setEditable(False)
+
+ self.model.appendRow([toolNr, toolName, toolTemplate, toolDiameter])
+
+ self.form.toolTable.resizeColumnsToContents()
+ else:
+ PathLog.info("no tool")
+ except:
+ PathLog.error('something happened')
+ PathLog.error(traceback.print_exc())
+
+ def toolDelete(self):
+ PathLog.track()
+ def toolUp(self):
+ PathLog.track()
+ def toolDown(self):
+ PathLog.track()
+
+ def columnNames(self):
+ return ['Nr', 'Tool', 'Template', 'Diameter']
+
+ def setupUI(self):
+ PathLog.track('+')
+ self.delegate = Delegate(self.form)
+ self.model = PySide.QtGui.QStandardItemModel(0, len(self.columnNames()), self.form)
+ self.model.setHorizontalHeaderLabels(self.columnNames())
+
+ self.form.toolTable.setModel(self.model)
+ self.form.toolTable.resizeColumnsToContents()
+
+ self.form.toolAdd.clicked.connect(self.toolAdd)
+ self.form.toolDelete.clicked.connect(self.toolDelete)
+ self.form.toolUp.clicked.connect(self.toolUp)
+ self.form.toolDown.clicked.connect(self.toolDown)
+
+ PathLog.track('-')