checkpoint
This commit is contained in:
@@ -15,20 +15,12 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>670</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<widget class="QWidget" name="tabWidgetPage1">
|
||||
<attribute name="title">
|
||||
<string>Shape</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@@ -180,16 +172,8 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>670</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<widget class="QWidget" name="tabWidgetPage2">
|
||||
<attribute name="title">
|
||||
<string>Attributes</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
@@ -228,6 +212,8 @@
|
||||
<header>Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../../../../Gui/Icons/resource.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -16,27 +16,13 @@
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="createToolBit">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Create a New Toolbit and add it to the library</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Toolbit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/document-new.svg</normaloff>:/icons/document-new.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolAdd">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add another Tool Bit to this library.</p><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Existing ...</string>
|
||||
<string>Add Toolbit ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
@@ -121,23 +107,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="addToolController">
|
||||
<property name="text">
|
||||
<string>Add Selected as Tool Controllers in the Job</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/edit-undo.svg</normaloff>:/icons/edit-undo.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<widget class="QPushButton" name="addToolController">
|
||||
<property name="text">
|
||||
<string>Add Selected as Tool Controllers in the Job</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/edit_OK.svg</normaloff>:/icons/edit_OK.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -154,24 +133,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="libraryOpen">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/document-open.svg</normaloff>:/icons/document-open.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="libraryCancel">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Close the Tool Bit Library Editor</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
@@ -179,13 +147,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="libraryOpen">
|
||||
<property name="text">
|
||||
<string>Open Table</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/document-open.svg</normaloff>:/icons/document-open.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="librarySave">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Save the current Library</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
<string>Save Table</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
@@ -199,7 +178,7 @@
|
||||
<string><html><head/><body><p>Save the library to a new file</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save As...</string>
|
||||
<string>Save Table As...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
|
||||
@@ -654,7 +654,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="toolsOpenLastLibrary">
|
||||
<property name="text">
|
||||
<string>Remember last library</string>
|
||||
</property>
|
||||
|
||||
@@ -47,6 +47,7 @@ LastPathToolShape = "LastPathToolShape"
|
||||
|
||||
UseLegacyTools = "UseLegacyTools"
|
||||
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
|
||||
OpenLastLibrary = "OpenLastLibrary"
|
||||
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
@@ -161,11 +162,11 @@ def toolsStoreAbsolutePaths():
|
||||
def toolsOpenLastLibrary():
|
||||
return preferences().GetBool(OpenLastLibrary, False)
|
||||
|
||||
def setToolsSettings(legacy, relative):
|
||||
def setToolsSettings(legacy, relative, lastlibrary):
|
||||
pref = preferences()
|
||||
pref.SetBool(UseLegacyTools, legacy)
|
||||
pref.SetBool(UseAbsoluteToolPaths, relative)
|
||||
pref.SetBool(OpenLastLibrary, False)
|
||||
pref.SetBool(OpenLastLibrary, lastlibrary)
|
||||
|
||||
def defaultJobTemplate():
|
||||
template = preferences().GetString(DefaultJobTemplate)
|
||||
|
||||
@@ -109,7 +109,9 @@ class JobPreferencesPage:
|
||||
PathPreferences.setDefaultStockTemplate('')
|
||||
|
||||
def saveToolsSettings(self):
|
||||
PathPreferences.setToolsSettings(self.form.toolsUseLegacy.isChecked(), self.form.toolsAbsolutePaths.isChecked())
|
||||
PathPreferences.setToolsSettings(self.form.toolsUseLegacy.isChecked(),
|
||||
self.form.toolsAbsolutePaths.isChecked(),
|
||||
self.form.toolsOpenLastLibrary.isChecked())
|
||||
|
||||
def selectComboEntry(self, widget, text):
|
||||
index = widget.findText(text, QtCore.Qt.MatchFixedString)
|
||||
|
||||
@@ -142,6 +142,13 @@ class PropertyString(Property):
|
||||
def typeString(self):
|
||||
return "String"
|
||||
|
||||
class PropertyMap(Property):
|
||||
def typeString(self)
|
||||
return "Map"
|
||||
|
||||
def displayString(self, value):
|
||||
return str(value)
|
||||
|
||||
class OpPrototype(object):
|
||||
|
||||
PropertyType = {
|
||||
@@ -159,6 +166,7 @@ class OpPrototype(object):
|
||||
'App::PropertyLink': Property,
|
||||
'App::PropertyLinkList': Property,
|
||||
'App::PropertyLinkSubListGlobal': Property,
|
||||
'App::PropertyMap': PropertyMap,
|
||||
'App::PropertyPercent': PropertyPercent,
|
||||
'App::PropertyString': PropertyString,
|
||||
'App::PropertyStringList': Property,
|
||||
|
||||
@@ -195,6 +195,7 @@ class ToolBit(object):
|
||||
def onDelete(self, obj, arg2=None):
|
||||
PathLog.track(obj.Label)
|
||||
self.unloadBitBody(obj)
|
||||
obj.Document.removeObject(obj.Name)
|
||||
|
||||
def _updateBitShape(self, obj, properties=None):
|
||||
if not obj.BitBody is None:
|
||||
@@ -230,6 +231,7 @@ class ToolBit(object):
|
||||
return (doc, docOpened)
|
||||
|
||||
def _removeBitBody(self, obj):
|
||||
print('in _removebitbody')
|
||||
if obj.BitBody:
|
||||
obj.BitBody.removeObjectsFromDocument()
|
||||
obj.Document.removeObject(obj.BitBody.Name)
|
||||
@@ -326,6 +328,7 @@ class ToolBit(object):
|
||||
attrs['parameter'] = params
|
||||
params = {}
|
||||
for name in self.propertyNamesAttribute(obj):
|
||||
print(f"shapeattr {name}")
|
||||
params[name] = PathUtil.getPropertyValueString(obj, name)
|
||||
attrs['attribute'] = params
|
||||
return attrs
|
||||
@@ -343,6 +346,7 @@ class AttributePrototype(PathSetupSheetOpPrototype.OpPrototype):
|
||||
self.addProperty('App::PropertyDistance', 'LengthOffset', PropertyGroupAttribute, translate('PathToolBit', 'Length offset in Z direction'))
|
||||
self.addProperty('App::PropertyInteger', 'Flutes', PropertyGroupAttribute, translate('PathToolBit', 'The number of flutes'))
|
||||
self.addProperty('App::PropertyDistance', 'ChipLoad', PropertyGroupAttribute, translate('PathToolBit', 'Chipload as per manufacturer'))
|
||||
# self.addProperty('App::PropertyMap', 'UserAttributes', PropertyGroupAttribute, translate('PathTooolBit', 'User Defined Values'))
|
||||
|
||||
|
||||
class ToolBitFactory(object):
|
||||
@@ -358,11 +362,21 @@ class ToolBitFactory(object):
|
||||
obj.Proxy.unloadBitBody(obj)
|
||||
params = attrs['attribute']
|
||||
proto = AttributePrototype()
|
||||
uservals = {}
|
||||
for pname in params:
|
||||
prop = proto.getProperty(pname)
|
||||
val = prop.valueFromString(params[pname])
|
||||
try:
|
||||
prop = proto.getProperty(pname)
|
||||
val = prop.valueFromString(params[pname])
|
||||
prop.setupProperty(obj, pname, PropertyGroupAttribute, prop.valueFromString(params[pname]))
|
||||
except:
|
||||
prop = obj.addProperty('App::PropertyString', pname, "Attribute", translate('PathTooolBit', 'User Defined Value'))
|
||||
setattr(obj, pname, params[pname])
|
||||
#prop = proto.getProperty("UserAttributes")
|
||||
#uservals.update({pname: params[pname]})
|
||||
#prop = .setupPropertyobj, pname, "UserAttributes", prop.valueFromString(params[pname]))
|
||||
|
||||
print("prop[%s] = %s (%s)" % (pname, params[pname], type(val)))
|
||||
prop.setupProperty(obj, pname, PropertyGroupAttribute, prop.valueFromString(params[pname]))
|
||||
#prop.setupProperty(obj, pname, PropertyGroupAttribute, prop.valueFromString(params[pname]))
|
||||
return obj
|
||||
|
||||
def CreateFrom(self, path, name='ToolBit'):
|
||||
|
||||
@@ -88,6 +88,7 @@ class ToolBitEditor(object):
|
||||
self.model.setHorizontalHeaderLabels(['Set', 'Property', 'Value'])
|
||||
|
||||
for i, name in enumerate(self.props):
|
||||
print(f"propname: {name}")
|
||||
prop = self.proto.getProperty(name)
|
||||
isset = hasattr(tool, name)
|
||||
if isset:
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PySide.QtCore as QtCore
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
|
||||
class CommandToolBitLibraryOpen:
|
||||
'''
|
||||
@@ -45,7 +46,13 @@ class CommandToolBitLibraryOpen:
|
||||
def Activated(self):
|
||||
import PathScripts.PathToolBitLibraryGui as PathToolBitLibraryGui
|
||||
library = PathToolBitLibraryGui.ToolBitLibrary()
|
||||
library.open()
|
||||
|
||||
lastlib = PathPreferences.lastPathToolLibrary()
|
||||
|
||||
if PathPreferences.toolsOpenLastLibrary() and lastlib.endswith('.fctl'):
|
||||
library.open(lastlib)
|
||||
else:
|
||||
library.open()
|
||||
|
||||
class CommandToolBitLibraryLoad:
|
||||
'''
|
||||
@@ -83,6 +90,7 @@ class CommandToolBitLibraryLoad:
|
||||
import PathScripts.PathToolControllerGui as PathToolControllerGui
|
||||
|
||||
library = PathToolBitLibraryGui.ToolBitLibrary()
|
||||
|
||||
if 1 == library.open(dialog=True) and job:
|
||||
for nr, tool in library.selectedOrAllTools():
|
||||
tc = PathToolControllerGui.Create("TC: {}".format(tool.Label), tool, nr)
|
||||
|
||||
@@ -30,6 +30,8 @@ import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathToolBit as PathToolBit
|
||||
import PathScripts.PathToolBitGui as PathToolBitGui
|
||||
import PathScripts.PathToolBitEdit as PathToolBitEdit
|
||||
import PathScripts.PathToolControllerGui as PathToolControllerGui
|
||||
import PathScripts.PathUtilsGui as PathUtilsGui
|
||||
import PySide
|
||||
import json
|
||||
import os
|
||||
@@ -192,6 +194,17 @@ class ToolBitLibrary(object):
|
||||
tools.append((toolNr, PathToolBit.Factory.CreateFrom(toolPath)))
|
||||
return tools
|
||||
|
||||
def selectedOrAllToolControllers(self):
|
||||
tools = self.selectedOrAllTools()
|
||||
|
||||
userinput = PathUtilsGui.PathUtilsUserInput()
|
||||
job = userinput.chooseJob(PathUtilsGui.PathUtils.GetJobs())
|
||||
for tool in tools:
|
||||
print(tool)
|
||||
tc = PathToolControllerGui.Create(tool[1].Label, tool[1], tool[0])
|
||||
job.Proxy.addToolController(tc)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def toolDelete(self):
|
||||
PathLog.track()
|
||||
selectedRows = set([index.row() for index in self.toolTableView.selectedIndexes()])
|
||||
@@ -205,7 +218,17 @@ class ToolBitLibrary(object):
|
||||
|
||||
def toolSelect(self, selected, deselected):
|
||||
# pylint: disable=unused-argument
|
||||
self.form.toolDelete.setEnabled(len(self.toolTableView.selectedIndexes()) > 0)
|
||||
sel = len(self.toolTableView.selectedIndexes()) > 0
|
||||
self.form.toolDelete.setEnabled(sel)
|
||||
|
||||
addTCSelectedText = translate("PathToolLibraryManager", "Add SELECTED as Tool Controllers in the Job")
|
||||
addTCAllText = translate("PathToolLibraryManager", "Add ALL as Tool Controllers in the Job")
|
||||
|
||||
if sel:
|
||||
self.form.addToolController.setText(addTCSelectedText)
|
||||
else:
|
||||
self.form.addToolController.setText(addTCAllText)
|
||||
|
||||
|
||||
def open(self, path=None, dialog=False):
|
||||
'''open(path=None, dialog=False) ... load library stored in path and bring up ui.
|
||||
@@ -230,11 +253,14 @@ class ToolBitLibrary(object):
|
||||
PathLog.track()
|
||||
filename = PySide.QtGui.QFileDialog.getOpenFileName(self.form, 'Tool Library', PathPreferences.lastPathToolLibrary(), '*.fctl')
|
||||
if filename and filename[0]:
|
||||
print(filename)
|
||||
print(filename[0])
|
||||
path = filename[0]
|
||||
PathPreferences.setLastPathToolLibrary(filename[0])
|
||||
|
||||
if not PathPreferences.toolsOpenLastLibrary():
|
||||
path = os.path.dirname(path)
|
||||
PathPreferences.setLastPathToolLibrary(os.path.dirname(filename[0]))
|
||||
#path = os.path.dirname(path)
|
||||
|
||||
self.libraryLoad(path)
|
||||
|
||||
@@ -264,20 +290,20 @@ class ToolBitLibrary(object):
|
||||
def libraryNew(self):
|
||||
self.libraryLoad(None)
|
||||
|
||||
def createToolBit(self):
|
||||
tool = PathToolBit.ToolBitFactory().Create()
|
||||
#def createToolBit(self):
|
||||
# tool = PathToolBit.ToolBitFactory().Create()
|
||||
|
||||
#self.dialog = PySide.QtGui.QDialog(self.form)
|
||||
#layout = PySide.QtGui.QVBoxLayout(self.dialog)
|
||||
self.editor = PathToolBitEdit.ToolBitEditor(tool, self.form.toolTableGroup)
|
||||
self.editor.setupUI()
|
||||
self.buttons = PySide.QtGui.QDialogButtonBox(
|
||||
PySide.QtGui.QDialogButtonBox.Ok | PySide.QtGui.QDialogButtonBox.Cancel,
|
||||
PySide.QtCore.Qt.Horizontal, self.dialog)
|
||||
layout.addWidget(self.buttons)
|
||||
#self.buttons.accepted.connect(accept)
|
||||
#self.buttons.rejected.connect(reject)
|
||||
print(self.dialog.exec_())
|
||||
# #self.dialog = PySide.QtGui.QDialog(self.form)
|
||||
# #layout = PySide.QtGui.QVBoxLayout(self.dialog)
|
||||
# self.editor = PathToolBitEdit.ToolBitEditor(tool, self.form.toolTableGroup)
|
||||
# self.editor.setupUI()
|
||||
# self.buttons = PySide.QtGui.QDialogButtonBox(
|
||||
# PySide.QtGui.QDialogButtonBox.Ok | PySide.QtGui.QDialogButtonBox.Cancel,
|
||||
# PySide.QtCore.Qt.Horizontal, self.dialog)
|
||||
# layout.addWidget(self.buttons)
|
||||
# #self.buttons.accepted.connect(accept)
|
||||
# #self.buttons.rejected.connect(reject)
|
||||
# print(self.dialog.exec_())
|
||||
|
||||
def librarySave(self):
|
||||
library = {}
|
||||
@@ -367,12 +393,22 @@ class ToolBitLibrary(object):
|
||||
self.librarySave()
|
||||
self.updateToolbar()
|
||||
|
||||
|
||||
|
||||
def libraryCancel(self):
|
||||
self.form.close()
|
||||
|
||||
def columnNames(self):
|
||||
return ['Nr', 'Tool', 'Shape', 'Diameter']
|
||||
|
||||
def toolEdit(self, selected):
|
||||
print('here')
|
||||
print(selected)
|
||||
if selected.column() == 0:
|
||||
print('nope')
|
||||
else:
|
||||
print('yep')
|
||||
|
||||
def setupUI(self):
|
||||
PathLog.track('+')
|
||||
self.model = PySide.QtGui.QStandardItemModel(0, len(self.columnNames()), self.toolTableView)
|
||||
@@ -381,11 +417,12 @@ class ToolBitLibrary(object):
|
||||
self.toolTableView.setModel(self.model)
|
||||
self.toolTableView.resizeColumnsToContents()
|
||||
self.toolTableView.selectionModel().selectionChanged.connect(self.toolSelect)
|
||||
self.toolTableView.doubleClicked.connect(self.toolEdit)
|
||||
|
||||
self.form.toolAdd.clicked.connect(self.toolAdd)
|
||||
self.form.toolDelete.clicked.connect(self.toolDelete)
|
||||
self.form.toolEnumerate.clicked.connect(self.toolEnumerate)
|
||||
self.form.createToolBit.clicked.connect(self.createToolBit)
|
||||
# self.form.createToolBit.clicked.connect(self.createToolBit)
|
||||
|
||||
#self.form.libraryNew.clicked.connect(self.libraryNew)
|
||||
self.form.libraryOpen.clicked.connect(self.libraryOpen)
|
||||
@@ -393,6 +430,8 @@ class ToolBitLibrary(object):
|
||||
self.form.librarySaveAs.clicked.connect(self.librarySaveAs)
|
||||
self.form.libraryCancel.clicked.connect(self.libraryCancel)
|
||||
|
||||
self.form.addToolController.clicked.connect(self.selectedOrAllToolControllers)
|
||||
|
||||
self.toolSelect([], [])
|
||||
self.updateToolbar()
|
||||
PathLog.track('-')
|
||||
|
||||
Reference in New Issue
Block a user