Moved usage of ToolBit into the experimental features.
This commit is contained in:
@@ -152,6 +152,9 @@ def searchPathsTool(sub='Bit'):
|
||||
def toolsUseLegacyTools():
|
||||
return preferences().GetBool(UseLegacyTools, True)
|
||||
|
||||
def toolsReallyUseLegacyTools():
|
||||
return toolsUseLegacyTools() or not experimentalFeaturesEnabled()
|
||||
|
||||
def toolsStoreAbsolutePaths():
|
||||
return preferences().GetBool(UseAbsoluteToolPaths, False)
|
||||
|
||||
|
||||
@@ -149,9 +149,12 @@ class ToolBit(object):
|
||||
obj.addProperty('App::PropertyLink', 'BitBody', 'Base', translate('PathToolBit', 'The parametrized body representing the tool bit'))
|
||||
obj.addProperty('App::PropertyFile', 'File', 'Base', translate('PathToolBit', 'The file of the tool'))
|
||||
if shapeFile is None:
|
||||
shapeFile = 'endmill.fcstd'
|
||||
obj.BitShape = shapeFile
|
||||
self._setupBitShape(obj)
|
||||
obj.BitShape = 'endmill.fcstd'
|
||||
self._setupBitShape(obj)
|
||||
self.unloadBitBody(obj)
|
||||
else:
|
||||
obj.BitShape = shapeFile
|
||||
self._setupBitShape(obj)
|
||||
self.onDocumentRestored(obj)
|
||||
|
||||
def __getstate__(self):
|
||||
@@ -189,6 +192,10 @@ class ToolBit(object):
|
||||
#elif obj.getGroupOfProperty(prop) == PropertyGroupBit:
|
||||
# self._updateBitShape(obj, [prop])
|
||||
|
||||
def onDelete(self, obj, arg2=None):
|
||||
PathLog.track(obj.Label)
|
||||
self.unloadBitBody(obj)
|
||||
|
||||
def _updateBitShape(self, obj, properties=None):
|
||||
if not obj.BitBody is None:
|
||||
if not properties:
|
||||
@@ -237,9 +244,9 @@ class ToolBit(object):
|
||||
|
||||
def loadBitBody(self, obj, force=False):
|
||||
if force or not obj.BitBody:
|
||||
activeDoc = FreeCAD.ActiveDocument
|
||||
if force:
|
||||
self._removeBitBody(obj)
|
||||
activeDoc = FreeCAD.ActiveDocument
|
||||
(doc, opened) = self._loadBitBody(obj)
|
||||
obj.BitBody = obj.Document.copyObject(doc.RootObjects[0], True)
|
||||
if opened:
|
||||
|
||||
@@ -77,6 +77,10 @@ class ViewProvider(object):
|
||||
# pylint: disable=unused-argument
|
||||
return None
|
||||
|
||||
def onDelete(self, vobj, arg2=None):
|
||||
PathLog.track(vobj.Object.Label)
|
||||
vobj.Object.Proxy.onDelete(vobj.Object)
|
||||
|
||||
def getDisplayMode(self, mode):
|
||||
# pylint: disable=unused-argument
|
||||
return 'Default'
|
||||
|
||||
@@ -31,13 +31,8 @@ import PathScripts.PathToolBit as PathToolBit
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
LOGLEVEL = False
|
||||
|
||||
if LOGLEVEL:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
#PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
#PathLog.trackModule(PathLog.thisModule())
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
@@ -86,6 +81,8 @@ class ToolController:
|
||||
# pylint: disable=unused-argument
|
||||
if not self.usesLegacyTool(obj):
|
||||
if len(obj.Tool.InList) == 1:
|
||||
if hasattr(obj.Tool.Proxy, 'onDelete'):
|
||||
obj.Tool.Proxy.onDelete(obj.Tool)
|
||||
obj.Document.removeObject(obj.Tool.Name)
|
||||
|
||||
def setFromTemplate(self, obj, template):
|
||||
@@ -186,17 +183,23 @@ class ToolController:
|
||||
|
||||
def ensureUseLegacyTool(self, obj, legacy):
|
||||
if not hasattr(obj, 'Tool') or (legacy != self.usesLegacyTool(obj)):
|
||||
if legacy and hasattr(obj, 'Tool') and len(obj.Tool.InList) == 1:
|
||||
if hasattr(obj.Tool.Proxy, 'onDelete'):
|
||||
obj.Tool.Proxy.onDelete(obj.Tool)
|
||||
obj.Document.removeObject(obj.Tool.Name)
|
||||
|
||||
if hasattr(obj, 'Tool'):
|
||||
obj.removeProperty('Tool')
|
||||
|
||||
if legacy:
|
||||
obj.addProperty("Path::PropertyTool", "Tool", "Base", QtCore.QT_TRANSLATE_NOOP("PathToolController", "The tool used by this controller"))
|
||||
else:
|
||||
obj.addProperty("App::PropertyLink", "Tool", "Base", QtCore.QT_TRANSLATE_NOOP("PathToolController", "The tool used by this controller"))
|
||||
|
||||
def Create(name = 'Default Tool', tool=None, toolNumber=1, assignViewProvider=True):
|
||||
PathLog.track(tool, toolNumber)
|
||||
legacyTool = PathPreferences.toolsReallyUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)
|
||||
|
||||
legacyTool = PathPreferences.toolsUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)
|
||||
PathLog.track(tool, toolNumber, legacyTool)
|
||||
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
obj.Label = name
|
||||
@@ -215,6 +218,8 @@ def Create(name = 'Default Tool', tool=None, toolNumber=1, assignViewProvider=Tr
|
||||
tool.Material = "HighSpeedSteel"
|
||||
else:
|
||||
tool = PathToolBit.Factory.Create()
|
||||
if tool.ViewObject:
|
||||
tool.ViewObject.Visibility = False
|
||||
|
||||
obj.Tool = tool
|
||||
obj.ToolNumber = toolNumber
|
||||
|
||||
@@ -441,7 +441,7 @@ class CommandToolLibraryEdit():
|
||||
pass
|
||||
|
||||
def edit(self, job=None, cb=None):
|
||||
if PathPreferences.toolsUseLegacyTools():
|
||||
if PathPreferences.toolsReallyUseLegacyTools():
|
||||
editor = EditorPanel(job, cb)
|
||||
editor.setupUi()
|
||||
editor.form.exec_()
|
||||
|
||||
Reference in New Issue
Block a user