Added preference to choose between legacy tools and new tool bits.
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>422</width>
|
||||
<height>558</height>
|
||||
<width>467</width>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -142,8 +142,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>406</width>
|
||||
<height>360</height>
|
||||
<width>665</width>
|
||||
<height>449</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -348,8 +348,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>422</width>
|
||||
<height>558</height>
|
||||
<width>431</width>
|
||||
<height>718</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -620,6 +620,49 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4">
|
||||
<attribute name="label">
|
||||
<string>Tools</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toolsUseLegacy">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Legacy Tools have no accurate shape representation and are stored in the user preferences of FreeCAD.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use Legacy Tools</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toolsRelativePaths">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>References to Tool Bits and their shapes can either be stored with an absolute path or with a relative path to the search path.</p><p><br/></p><p>Generally it is recommended to use relative paths due to their flexibility and robustness to layout changes.</p><p><br/></p><p>Should multiple tools or tool shapes with the same name exist in different directories it can be required to use absolute paths. </p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Store Relative Paths</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -43,7 +43,10 @@ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
|
||||
|
||||
LastPathToolBit = "LastPathToolBit"
|
||||
LastPathToolLibrary = "LastPathToolLibrary"
|
||||
LastPathToolShape = "LastPathToolShape"
|
||||
LastPathToolShape = "LastPathToolShape"
|
||||
|
||||
UseLegacyTools = "UseLegacyTools"
|
||||
UseRelativeToolPaths = "UseRelativeToolPaths"
|
||||
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
@@ -146,6 +149,17 @@ def searchPathsTool(sub='Bit'):
|
||||
appendPath(os.path.join(FreeCAD.getHomePath(), "Mod/Path/"), sub)
|
||||
return paths
|
||||
|
||||
def toolsUseLegacyTools():
|
||||
return preferences().GetBool(UseLegacyTools, True)
|
||||
|
||||
def toolsStoreRelativePaths():
|
||||
return preferences().GetBool(UseRelativeToolPaths, True)
|
||||
|
||||
def setToolsSettings(legacy, relative):
|
||||
pref = preferences()
|
||||
pref.SetBool(UseLegacyTools, legacy)
|
||||
pref.SetBool(UseRelativeToolPaths, relative)
|
||||
|
||||
def defaultJobTemplate():
|
||||
template = preferences().GetString(DefaultJobTemplate)
|
||||
if 'xml' not in template:
|
||||
|
||||
@@ -71,6 +71,7 @@ class JobPreferencesPage:
|
||||
policy = str(self.form.cboOutputPolicy.currentText())
|
||||
PathPreferences.setOutputFileDefaults(path, policy)
|
||||
self.saveStockSettings()
|
||||
self.saveToolsSettings()
|
||||
|
||||
def saveStockSettings(self):
|
||||
if self.form.stockGroup.isChecked():
|
||||
@@ -107,6 +108,9 @@ class JobPreferencesPage:
|
||||
else:
|
||||
PathPreferences.setDefaultStockTemplate('')
|
||||
|
||||
def saveToolsSettings(self):
|
||||
PathPreferences.setToolsSettings(self.form.toolsUseLegacy.isChecked(), self.form.toolsRelativePaths.isChecked())
|
||||
|
||||
def selectComboEntry(self, widget, text):
|
||||
index = widget.findText(text, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
@@ -167,6 +171,7 @@ class JobPreferencesPage:
|
||||
self.form.tbOutputFile.clicked.connect(self.browseOutputFile)
|
||||
|
||||
self.loadStockSettings()
|
||||
self.loadToolSettings()
|
||||
|
||||
def loadStockSettings(self):
|
||||
stock = PathPreferences.defaultStockTemplate()
|
||||
@@ -244,6 +249,10 @@ class JobPreferencesPage:
|
||||
self.form.stockCreateBox.hide()
|
||||
self.form.stockCreateCylinder.hide()
|
||||
|
||||
def loadToolSettings(self):
|
||||
self.form.toolsUseLegacy.setChecked(PathPreferences.toolsUseLegacyTools())
|
||||
self.form.toolsRelativePaths.setChecked(PathPreferences.toolsStoreRelativePaths())
|
||||
|
||||
def getPostProcessor(self, name):
|
||||
if not name in self.processor.keys():
|
||||
processor = PostProcessor.load(name)
|
||||
|
||||
@@ -74,15 +74,22 @@ class CommandToolBitLibraryLoad:
|
||||
return not self.selectedJob() is None
|
||||
|
||||
def Activated(self):
|
||||
job = self.selectedJob()
|
||||
self.Execute(job)
|
||||
|
||||
@classmethod
|
||||
def Execute(cls, job):
|
||||
import PathScripts.PathToolBitLibraryGui as PathToolBitLibraryGui
|
||||
import PathScripts.PathToolControllerGui as PathToolControllerGui
|
||||
job = self.selectedJob()
|
||||
|
||||
library = PathToolBitLibraryGui.ToolBitLibrary()
|
||||
if 1 == library.open(dialog=True):
|
||||
if 1 == library.open(dialog=True) and job:
|
||||
for nr, tool in library.selectedOrAllTools():
|
||||
tc = PathToolControllerGui.Create("TC: {}".format(tool.Label), tool, nr)
|
||||
job.Proxy.addToolController(tc)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return True
|
||||
return False
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Path_ToolBitLibraryOpen', CommandToolBitLibraryOpen())
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathToolBit as PathToolBit
|
||||
|
||||
from PySide import QtCore
|
||||
@@ -195,20 +196,25 @@ class ToolController:
|
||||
def Create(name = 'Default Tool', tool=None, toolNumber=1, assignViewProvider=True):
|
||||
PathLog.track(tool, toolNumber)
|
||||
|
||||
legacyTool = PathPreferences.toolsUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)
|
||||
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
obj.Label = name
|
||||
obj.Proxy = ToolController(obj, tool is None or isinstance(tool, Path.Tool))
|
||||
obj.Proxy = ToolController(obj, legacyTool)
|
||||
|
||||
if FreeCAD.GuiUp and assignViewProvider:
|
||||
ViewProvider(obj.ViewObject)
|
||||
|
||||
if tool is None:
|
||||
tool = Path.Tool()
|
||||
tool.Diameter = 5.0
|
||||
tool.Name = "Default Tool"
|
||||
tool.CuttingEdgeHeight = 15.0
|
||||
tool.ToolType = "EndMill"
|
||||
tool.Material = "HighSpeedSteel"
|
||||
if legacyTool:
|
||||
tool = Path.Tool()
|
||||
tool.Diameter = 5.0
|
||||
tool.Name = "Default Tool"
|
||||
tool.CuttingEdgeHeight = 15.0
|
||||
tool.ToolType = "EndMill"
|
||||
tool.Material = "HighSpeedSteel"
|
||||
else:
|
||||
tool = PathToolBit.Factory.Create()
|
||||
|
||||
obj.Tool = tool
|
||||
obj.ToolNumber = toolNumber
|
||||
|
||||
@@ -29,6 +29,8 @@ import FreeCADGui
|
||||
import Path
|
||||
import PathScripts
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathToolBitLibraryCmd as PathToolBitLibraryCmd
|
||||
import PathScripts.PathToolEdit as PathToolEdit
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathToolLibraryManager as ToolLibraryManager
|
||||
@@ -439,12 +441,14 @@ class CommandToolLibraryEdit():
|
||||
pass
|
||||
|
||||
def edit(self, job=None, cb=None):
|
||||
editor = EditorPanel(job, cb)
|
||||
editor.setupUi()
|
||||
|
||||
r = editor.form.exec_()
|
||||
if r:
|
||||
pass
|
||||
if PathPreferences.toolsUseLegacyTools():
|
||||
editor = EditorPanel(job, cb)
|
||||
editor.setupUi()
|
||||
editor.form.exec_()
|
||||
else:
|
||||
if PathToolBitLibraryCmd.CommandToolBitLibraryLoad.Execute(job):
|
||||
if cb:
|
||||
cb()
|
||||
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Path-ToolTable',
|
||||
@@ -456,7 +460,6 @@ class CommandToolLibraryEdit():
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
|
||||
self.edit()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
|
||||
Reference in New Issue
Block a user