Merge branch 'master' into bugfix/path-invalid-base-geometry-robustness
This commit is contained in:
@@ -62,6 +62,7 @@ WarningSuppressAllSpeeds = "WarningSuppressAllSpeeds"
|
||||
WarningSuppressSelectionMode = "WarningSuppressSelectionMode"
|
||||
WarningSuppressOpenCamLib = "WarningSuppressOpenCamLib"
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
EnableAdvancedOCLFeatures = "EnableAdvancedOCLFeatures"
|
||||
|
||||
|
||||
def preferences():
|
||||
@@ -161,10 +162,6 @@ def toolsUseLegacyTools():
|
||||
return preferences().GetBool(UseLegacyTools, False)
|
||||
|
||||
|
||||
def toolsReallyUseLegacyTools():
|
||||
return toolsUseLegacyTools()
|
||||
|
||||
|
||||
def toolsStoreAbsolutePaths():
|
||||
return preferences().GetBool(UseAbsoluteToolPaths, False)
|
||||
|
||||
@@ -243,6 +240,10 @@ def setDefaultTaskPanelLayout(style):
|
||||
preferences().SetInt(DefaultTaskPanelLayout, style)
|
||||
|
||||
|
||||
def advancedOCLFeaturesEnabled():
|
||||
return preferences().GetBool(EnableAdvancedOCLFeatures, False)
|
||||
|
||||
|
||||
def experimentalFeaturesEnabled():
|
||||
return preferences().GetBool(EnableExperimentalFeatures, False)
|
||||
|
||||
@@ -251,8 +252,8 @@ def suppressAllSpeedsWarning():
|
||||
return preferences().GetBool(WarningSuppressAllSpeeds, True)
|
||||
|
||||
|
||||
def suppressRapidSpeedsWarning():
|
||||
return suppressAllSpeedsWarning() or preferences().GetBool(WarningSuppressRapidSpeeds, True)
|
||||
def suppressRapidSpeedsWarning(user=True):
|
||||
return (user and suppressAllSpeedsWarning()) or preferences().GetBool(WarningSuppressRapidSpeeds, True)
|
||||
|
||||
|
||||
def suppressSelectionModeWarning():
|
||||
@@ -262,6 +263,12 @@ def suppressSelectionModeWarning():
|
||||
def suppressOpenCamLibWarning():
|
||||
return preferences().GetBool(WarningSuppressOpenCamLib, True)
|
||||
|
||||
def setPreferencesAdvanced(ocl, warnSpeeds, warnRapids, warnModes, warnOCL):
|
||||
preferences().SetBool(EnableAdvancedOCLFeatures, ocl)
|
||||
preferences().SetBool(WarningSuppressAllSpeeds, warnSpeeds)
|
||||
preferences().SetBool(WarningSuppressRapidSpeeds, warnRapids)
|
||||
preferences().SetBool(WarningSuppressSelectionMode, warnModes)
|
||||
preferences().SetBool(WarningSuppressOpenCamLib, warnOCL)
|
||||
|
||||
def lastFileToolLibrary():
|
||||
filename = preferences().GetString(LastFileToolLibrary)
|
||||
|
||||
60
src/Mod/Path/PathScripts/PathPreferencesAdvanced.py
Normal file
60
src/Mod/Path/PathScripts/PathPreferencesAdvanced.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2021 sliptonic <shopinthewoods@gmail.com> *
|
||||
# * *
|
||||
# * 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.PathPreferences as PathPreferences
|
||||
import PySide
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
return PySide.QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
class AdvancedPreferencesPage:
|
||||
def __init__(self, parent=None):
|
||||
self.form = FreeCADGui.PySideUic.loadUi(':preferences/Advanced.ui')
|
||||
self.form.WarningSuppressAllSpeeds.stateChanged.connect(self.updateSelection)
|
||||
self.form.EnableAdvancedOCLFeatures.stateChanged.connect(self.updateSelection)
|
||||
|
||||
def saveSettings(self):
|
||||
PathPreferences.setPreferencesAdvanced(
|
||||
self.form.EnableAdvancedOCLFeatures.isChecked(),
|
||||
self.form.WarningSuppressAllSpeeds.isChecked(),
|
||||
self.form.WarningSuppressRapidSpeeds.isChecked(),
|
||||
self.form.WarningSuppressSelectionMode.isChecked(),
|
||||
self.form.WarningSuppressOpenCamLib.isChecked())
|
||||
|
||||
def loadSettings(self):
|
||||
self.form.WarningSuppressAllSpeeds.setChecked(PathPreferences.suppressAllSpeedsWarning())
|
||||
self.form.WarningSuppressRapidSpeeds.setChecked(PathPreferences.suppressRapidSpeedsWarning(False))
|
||||
self.form.WarningSuppressSelectionMode.setChecked(PathPreferences.suppressSelectionModeWarning())
|
||||
self.form.EnableAdvancedOCLFeatures.setChecked(PathPreferences.advancedOCLFeaturesEnabled())
|
||||
self.form.WarningSuppressOpenCamLib.setChecked(PathPreferences.suppressOpenCamLibWarning())
|
||||
self.updateSelection()
|
||||
|
||||
def updateSelection(self, state=None):
|
||||
self.form.WarningSuppressOpenCamLib.setEnabled(self.form.EnableAdvancedOCLFeatures.isChecked())
|
||||
if self.form.WarningSuppressAllSpeeds.isChecked():
|
||||
self.form.WarningSuppressRapidSpeeds.setChecked(True)
|
||||
self.form.WarningSuppressRapidSpeeds.setEnabled(False)
|
||||
else:
|
||||
self.form.WarningSuppressRapidSpeeds.setEnabled(True)
|
||||
|
||||
@@ -2555,6 +2555,7 @@ class OCL_Tool():
|
||||
if (self.diameter == -1.0 or self.cutEdgeHeight == -1.0):
|
||||
return
|
||||
self.tiltCutter = True
|
||||
if self.cutEdgeHeight==0 : self.cutEdgeHeight = self.diameter/2
|
||||
self.oclTool = self.ocl.BallCutter(
|
||||
self.diameter,
|
||||
self.cutEdgeHeight + self.lengthOffset
|
||||
@@ -2582,8 +2583,8 @@ class OCL_Tool():
|
||||
return
|
||||
self.oclTool = self.ocl.ConeCutter(
|
||||
self.diameter,
|
||||
self.cutEdgeAngle,
|
||||
self.cutEdgeHeight + self.lengthOffset
|
||||
self.cutEdgeAngle/2,
|
||||
self.lengthOffset
|
||||
)
|
||||
|
||||
def _setToolMethod(self):
|
||||
|
||||
@@ -60,35 +60,23 @@ class ToolControllerTemplate:
|
||||
|
||||
class ToolController:
|
||||
|
||||
def __init__(self, obj, cTool=False):
|
||||
PathLog.track('tool: {}'.format(cTool))
|
||||
def __init__(self, obj, legacyTool=False, createTool=True):
|
||||
PathLog.track('tool: {}'.format(legacyTool))
|
||||
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber",
|
||||
"Tool", QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"The active tool"))
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("PathToolController", "The active tool"))
|
||||
obj.ToolNumber = (0, 0, 10000, 1)
|
||||
self.ensureUseLegacyTool(obj, cTool)
|
||||
obj.addProperty("App::PropertyFloat", "SpindleSpeed", "Tool",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"The speed of the cutting spindle in RPM"))
|
||||
obj.addProperty("App::PropertyEnumeration", "SpindleDir", "Tool",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"Direction of spindle rotation"))
|
||||
obj.addProperty("App::PropertyFloat", "SpindleSpeed", "Tool", QtCore.QT_TRANSLATE_NOOP("PathToolController", "The speed of the cutting spindle in RPM"))
|
||||
obj.addProperty("App::PropertyEnumeration", "SpindleDir", "Tool", QtCore.QT_TRANSLATE_NOOP("PathToolController", "Direction of spindle rotation"))
|
||||
obj.SpindleDir = ['Forward', 'Reverse']
|
||||
obj.addProperty("App::PropertySpeed", "VertFeed", "Feed",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"Feed rate for vertical moves in Z"))
|
||||
obj.addProperty("App::PropertySpeed", "HorizFeed", "Feed",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"Feed rate for horizontal moves"))
|
||||
obj.addProperty("App::PropertySpeed", "VertRapid", "Rapid",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"Rapid rate for vertical moves in Z"))
|
||||
obj.addProperty("App::PropertySpeed", "HorizRapid", "Rapid",
|
||||
QtCore.QT_TRANSLATE_NOOP("PathToolController",
|
||||
"Rapid rate for horizontal moves"))
|
||||
obj.addProperty("App::PropertySpeed", "VertFeed", "Feed", QtCore.QT_TRANSLATE_NOOP("PathToolController", "Feed rate for vertical moves in Z"))
|
||||
obj.addProperty("App::PropertySpeed", "HorizFeed", "Feed", QtCore.QT_TRANSLATE_NOOP("PathToolController", "Feed rate for horizontal moves"))
|
||||
obj.addProperty("App::PropertySpeed", "VertRapid", "Rapid", QtCore.QT_TRANSLATE_NOOP("PathToolController", "Rapid rate for vertical moves in Z"))
|
||||
obj.addProperty("App::PropertySpeed", "HorizRapid", "Rapid", QtCore.QT_TRANSLATE_NOOP("PathToolController", "Rapid rate for horizontal moves"))
|
||||
obj.setEditorMode('Placement', 2)
|
||||
|
||||
if createTool:
|
||||
self.ensureUseLegacyTool(obj, legacyTool)
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
obj.setEditorMode('Placement', 2)
|
||||
|
||||
@@ -225,32 +213,31 @@ class ToolController:
|
||||
obj.addProperty("App::PropertyLink", "Tool", "Base", QtCore.QT_TRANSLATE_NOOP("PathToolController", "The tool used by this controller"))
|
||||
|
||||
|
||||
def Create(name='TC: Default Tool', tool=None, toolNumber=1, assignViewProvider=True):
|
||||
legacyTool = PathPreferences.toolsReallyUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)
|
||||
def Create(name='TC: Default Tool', tool=None, toolNumber=1, assignViewProvider=True, assignTool=True):
|
||||
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
|
||||
obj.Proxy = ToolController(obj, legacyTool)
|
||||
obj.Proxy = ToolController(obj, legacyTool, assignTool)
|
||||
|
||||
if FreeCAD.GuiUp and assignViewProvider:
|
||||
ViewProvider(obj.ViewObject)
|
||||
|
||||
if tool is None:
|
||||
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()
|
||||
if tool.ViewObject:
|
||||
tool.ViewObject.Visibility = False
|
||||
|
||||
if tool:
|
||||
if assignTool:
|
||||
if not tool:
|
||||
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()
|
||||
if tool.ViewObject:
|
||||
tool.ViewObject.Visibility = False
|
||||
obj.Tool = tool
|
||||
obj.ToolNumber = toolNumber
|
||||
return obj
|
||||
@@ -261,7 +248,7 @@ def FromTemplate(template, assignViewProvider=True):
|
||||
PathLog.track()
|
||||
|
||||
name = template.get(ToolControllerTemplate.Name, ToolControllerTemplate.Label)
|
||||
obj = Create(name, tool=False, assignViewProvider=True)
|
||||
obj = Create(name, assignViewProvider=True, assignTool=False)
|
||||
obj.Proxy.setFromTemplate(obj, template)
|
||||
|
||||
return obj
|
||||
|
||||
@@ -439,7 +439,7 @@ class CommandToolLibraryEdit():
|
||||
pass
|
||||
|
||||
def edit(self, job=None, cb=None):
|
||||
if PathPreferences.toolsReallyUseLegacyTools():
|
||||
if PathPreferences.toolsUseLegacyTools():
|
||||
editor = EditorPanel(job, cb)
|
||||
editor.setupUi()
|
||||
editor.form.exec_()
|
||||
|
||||
Reference in New Issue
Block a user