diff --git a/src/Mod/Path/Gui/Resources/panels/MillFaceEdit.ui b/src/Mod/Path/Gui/Resources/panels/MillFaceEdit.ui index 254d763508..ecb9506116 100644 --- a/src/Mod/Path/Gui/Resources/panels/MillFaceEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/MillFaceEdit.ui @@ -34,7 +34,7 @@ 0 0 361 - 277 + 279 @@ -243,7 +243,7 @@ 0 0 361 - 329 + 289 @@ -367,6 +367,13 @@ + + + + Pattern + + + @@ -406,27 +413,20 @@ - - - - Pattern - - - - - - - - - - - + ZigZag Angle + + + + + + + @@ -455,11 +455,6 @@ QLineEdit
Gui/InputField.h
- - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
diff --git a/src/Mod/Path/Gui/Resources/panels/ProfileEdgesEdit.ui b/src/Mod/Path/Gui/Resources/panels/ProfileEdgesEdit.ui index fce6b1c7aa..3750b31484 100644 --- a/src/Mod/Path/Gui/Resources/panels/ProfileEdgesEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/ProfileEdgesEdit.ui @@ -33,8 +33,8 @@ 0 0 - 285 - 277 + 334 + 348 @@ -111,8 +111,8 @@ 0 0 - 120 - 96 + 334 + 348 @@ -181,8 +181,8 @@ 0 0 - 154 - 68 + 334 + 348 @@ -351,13 +351,6 @@ - - - - Use End Point - - - @@ -370,23 +363,6 @@ 0 - - - - 0.000000000000000 - - - mm - - - - - - - Roll Radius - - - diff --git a/src/Mod/Path/PathScripts/PathContour.py b/src/Mod/Path/PathScripts/PathContour.py index 57188fe612..e7cd85783a 100644 --- a/src/Mod/Path/PathScripts/PathContour.py +++ b/src/Mod/Path/PathScripts/PathContour.py @@ -22,26 +22,28 @@ # * * # *************************************************************************** +from __future__ import print_function import FreeCAD import Path import PathScripts.PathLog as PathLog +from PySide import QtCore, QtGui from PathScripts import PathUtils -from PathScripts.PathUtils import depth_params -from PySide import QtCore import ArchPanel import Part from PathScripts.PathUtils import waiting_effects from PathScripts.PathUtils import makeWorkplane +from PathScripts.PathUtils import depth_params -LOG_MODULE = 'PathContour' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -PathLog.trackModule('PathContour') FreeCAD.setLogLevel('Path.Area', 0) +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) + if FreeCAD.GuiUp: import FreeCADGui - # from PySide import QtGui - # Qt tanslation handling def translate(context, text, disambig=None): @@ -57,9 +59,10 @@ __url__ = "http://www.freecadweb.org" class ObjectContour: def __init__(self, obj): + PathLog.track() obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code")) obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this Contour")) - obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label")) + #obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label")) # Tool Properties obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) @@ -82,8 +85,8 @@ class ObjectContour: obj.addProperty("App::PropertyDistance", "OffsetExtra", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final Contour- good for roughing toolpath")) # Debug Parameters - obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) - obj.setEditorMode('AreaParams', 2) # hide + # obj.addProperty("App::PropertyString", "AreaParams", "Debug", QtCore.QT_TRANSLATE_NOOP("App::Property", "parameters used by PathArea")) + # obj.setEditorMode('AreaParams', 2) # hide if FreeCAD.GuiUp: _ViewProviderContour(obj.ViewObject) @@ -91,16 +94,19 @@ class ObjectContour: obj.Proxy = self self.endVector = None + def onChanged(self, obj, prop): + PathLog.track('prop: {} state: {}'.format(prop, obj.State)) + #pass + def __getstate__(self): + PathLog.track() return None def __setstate__(self, state): + PathLog.track(state) return None - def onChanged(self, obj, prop): - pass - - def setDepths(proxy, obj): + def setDepths(self, obj): PathLog.track() parentJob = PathUtils.findParentJob(obj) if parentJob is None: @@ -139,7 +145,7 @@ class ObjectContour: heights = [i for i in self.depthparams] PathLog.debug('depths: {}'.format(heights)) profile.setParams(**profileparams) - obj.AreaParams = str(profile.getParams()) + #obj.AreaParams = str(profile.getParams()) PathLog.debug("Contour with params: {}".format(profile.getParams())) sections = profile.makeSections(mode=0, project=True, heights=heights) @@ -191,6 +197,15 @@ class ObjectContour: commandlist = [] toolLoad = obj.ToolController + self.depthparams = depth_params( + clearance_height=obj.ClearanceHeight.Value, + safe_height=obj.SafeHeight.Value, + start_depth=obj.StartDepth.Value, + step_down=obj.StepDown.Value, + z_finish_step=0.0, + final_depth=obj.FinalDepth.Value, + user_depths=None) + if toolLoad is None or toolLoad.ToolNumber == 0: FreeCAD.Console.PrintError("No Tool Controller is selected. We need a tool to build a Path.") return @@ -206,15 +221,6 @@ class ObjectContour: else: self.radius = tool.Diameter/2 - self.depthparams = depth_params( - clearance_height=obj.ClearanceHeight.Value, - safe_height=obj.SafeHeight.Value, - start_depth=obj.StartDepth.Value, - step_down=obj.StepDown.Value, - z_finish_step=0.0, - final_depth=obj.FinalDepth.Value, - user_depths=None) - commandlist.append(Path.Command("(" + obj.Label + ")")) if obj.UseComp: @@ -264,23 +270,27 @@ class ObjectContour: path = Path.Path(commandlist) obj.Path = path - obj.ViewObject.Visibility = True + #obj.ViewObject.Visibility = True return sim class _ViewProviderContour: def __init__(self, vobj): + PathLog.track() vobj.Proxy = self def attach(self, vobj): + PathLog.track() self.Object = vobj.Object return def deleteObjectsOnReject(self): + PathLog.track() return hasattr(self, 'deleteOnReject') and self.deleteOnReject def setEdit(self, vobj, mode=0): + PathLog.track() FreeCADGui.Control.closeDialog() taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject()) taskd.obj = vobj.Object @@ -293,9 +303,11 @@ class _ViewProviderContour: return ":/icons/Path-Contour.svg" def __getstate__(self): + PathLog.track() return None def __setstate__(self, state): + PathLog.track() return None @@ -340,7 +352,6 @@ class CommandPathContour: FreeCADGui.addModule("PathScripts.PathContour") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Contour")') FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour(obj)') - #FreeCADGui.doCommand('PathScripts.PathContour._ViewProviderContour(obj.ViewObject)') FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') FreeCADGui.doCommand('obj.Active = True') @@ -360,7 +371,7 @@ class CommandPathContour: FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() + #FreeCAD.ActiveDocument.recompute() FreeCADGui.doCommand('obj.ViewObject.startEditing()') @@ -370,16 +381,15 @@ class TaskPanel: self.form = FreeCADGui.PySideUic.loadUi(":/panels/ContourEdit.ui") # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ContourEdit.ui") self.deleteOnReject = deleteOnReject - self.updating = False + self.isDirty = True def accept(self): - self.getFields() - FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -392,6 +402,12 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + FreeCAD.ActiveDocument.recompute() + self.isDirty = False + def getFields(self): PathLog.track() if self.obj: @@ -416,15 +432,15 @@ class TaskPanel: if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - self.obj.Proxy.execute(self.obj) + self.isDirty = True def setFields(self): PathLog.track() self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) + self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) - self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) # self.form.useStartPoint.setChecked(self.obj.UseStartPoint) @@ -460,8 +476,8 @@ class TaskPanel: # install the function mode resident FreeCADGui.Selection.addObserver(self.s) - # def getStandardButtons(self): - # return int(QtGui.QDialogButtonBox.Ok) + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) def setupUi(self): PathLog.track() diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 0e09797e7c..84675f470d 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -37,9 +37,11 @@ import ArchPanel if sys.version_info.major >= 3: xrange = range -LOG_MODULE = 'PathDrilling' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -#PathLog.trackModule('PathDrilling') +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) FreeCADGui = None if FreeCAD.GuiUp: @@ -326,6 +328,8 @@ class CommandPathDrilling: return False def Activated(self): + ztop = 10.0 + zbottom = 0.0 # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction(translate("Path_Drilling", "Create Drilling")) @@ -333,20 +337,16 @@ class CommandPathDrilling: FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Drilling")') FreeCADGui.doCommand('PathScripts.PathDrilling.ObjectDrilling(obj)') FreeCADGui.doCommand('obj.Active = True') - #FreeCADGui.doCommand('PathScripts.PathDrilling._ViewProviderDrill(obj.ViewObject)') FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') - ztop = 10.0 - zbottom = 0.0 FreeCADGui.doCommand('obj.ClearanceHeight = ' + str(ztop)) FreeCADGui.doCommand('obj.RetractHeight= ' + str(ztop)) FreeCADGui.doCommand('obj.FinalDepth=' + str(zbottom)) FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') - FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() + FreeCADGui.doCommand('obj.ViewObject.startEditing()') class TaskPanel: @@ -355,12 +355,14 @@ class TaskPanel: self.form = FreeCADGui.PySideUic.loadUi(":/panels/DrillingEdit.ui") self.deleteOnReject = deleteOnReject self.obj = obj + self.isDirty = True def accept(self): FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -372,6 +374,12 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + FreeCAD.ActiveDocument.recompute() + self.isDirty = False + def getFields(self): PathLog.track() if self.obj: @@ -396,22 +404,19 @@ class TaskPanel: self.obj.DwellTime = FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value else: self.form.dwellTime.setText("0.00") - if hasattr(self.obj, "DwellEnabled"): self.obj.DwellEnabled = self.form.dwellEnabled.isChecked() if hasattr(self.obj, "PeckEnabled"): self.obj.PeckEnabled = self.form.peckEnabled.isChecked() - if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc except ValueError: self.setFields() - self.obj.Proxy.execute(self.obj) + self.isDirty = True def updateFeatureList(self): - self.form.baseList.itemChanged.disconnect(self.checkedChanged) # disconnect this slot while creating objects self.form.baseList.clear() self.form.baseList.setColumnCount(2) @@ -587,6 +592,9 @@ class TaskPanel: FreeCAD.ActiveDocument.recompute() + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) + def setupUi(self): PathLog.track() diff --git a/src/Mod/Path/PathScripts/PathEngrave.py b/src/Mod/Path/PathScripts/PathEngrave.py index 1528b8308c..ca8e9bed42 100644 --- a/src/Mod/Path/PathScripts/PathEngrave.py +++ b/src/Mod/Path/PathScripts/PathEngrave.py @@ -23,21 +23,24 @@ # *************************************************************************** import FreeCAD -import FreeCADGui import Path import Part import ArchPanel import PathScripts.PathLog as PathLog -from PySide import QtCore from PathScripts import PathUtils """Path Engrave object and FreeCAD command""" -LOG_MODULE = 'PathEngrave' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -# PathLog.trackModule('PathEngrave') +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) +if FreeCAD.GuiUp: + import FreeCADGui + from PySide import QtCore, QtGui # Qt tanslation handling def translate(context, text, disambig=None): @@ -56,9 +59,13 @@ class ObjectPathEngrave: obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) # Depth Properties + obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Start Depth of Tool")) + obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z")) + + # Heights obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions")) obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations.")) - obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z")) + obj.addProperty("App::PropertyInteger", "StartVertex", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The vertex index to start the path from")) if FreeCAD.GuiUp: @@ -225,10 +232,10 @@ class _ViewProviderEngrave: self.deleteOnReject = False return True - def unsetEdit(self, vobj, mode): - PathLog.track() - if hasattr(self, 'taskPanel') and self.taskPanel: - self.taskPanel.abort() +# def unsetEdit(self, vobj, mode): +# PathLog.track() +# if hasattr(self, 'taskPanel') and self.taskPanel: +# self.taskPanel.abort() def clearTaskPanel(self): self.taskpanel = None @@ -284,51 +291,47 @@ class CommandPathEngrave: FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() class TaskPanel: def __init__(self, vobj, deleteOnReject): FreeCAD.ActiveDocument.openTransaction(translate("Path_Engrave", "Engraving Operation")) + self.form = FreeCADGui.PySideUic.loadUi(":/panels/EngraveEdit.ui") self.vobj = vobj self.obj = vobj.Object self.deleteOnReject = deleteOnReject - self.form = FreeCADGui.PySideUic.loadUi(":/panels/EngraveEdit.ui") - - def abort(self): - FreeCAD.ActiveDocument.abortTransaction() - self.cleanup(False) + self.isDirty = True def accept(self): - PathLog.track() - self.getFields() - + FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() - self.cleanup(True) - FreeCAD.ActiveDocument.recompute() - return True + FreeCADGui.Selection.removeObserver(self.s) + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): - PathLog.track() + FreeCADGui.Control.closeDialog() + FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.abortTransaction() + FreeCADGui.Selection.removeObserver(self.s) if self.deleteOnReject: FreeCAD.ActiveDocument.openTransaction(translate("Path_Engrave", "Uncreate Engrave Operation")) FreeCAD.ActiveDocument.removeObject(self.obj.Name) FreeCAD.ActiveDocument.commitTransaction() - self.cleanup(True) - return True + FreeCAD.ActiveDocument.recompute() - def cleanup(self, gui): - FreeCADGui.Selection.removeObserver(self.s) - - self.vobj.Proxy.clearTaskPanel() - if gui: - FreeCADGui.ActiveDocument.resetEdit() - FreeCADGui.Control.closeDialog() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() FreeCAD.ActiveDocument.recompute() + self.isDirty = False + def getFields(self): if self.obj: + if hasattr(self.obj, "StartDepth"): + self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): @@ -338,11 +341,12 @@ class TaskPanel: if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - - self.obj.Proxy.execute(self.obj) + self.isDirty = True + # self.obj.Proxy.execute(self.obj) def setFields(self): self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) + self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) @@ -370,9 +374,12 @@ class TaskPanel: # install the function mode resident FreeCADGui.Selection.addObserver(self.s) - def setupUi(self): + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) + def setupUi(self): # Connect Signals and Slots + self.form.startDepth.editingFinished.connect(self.getFields) self.form.finalDepth.editingFinished.connect(self.getFields) self.form.safeHeight.editingFinished.connect(self.getFields) self.form.clearanceHeight.editingFinished.connect(self.getFields) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 40fc1723a4..df20d0561f 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -25,30 +25,34 @@ from __future__ import print_function import FreeCAD import Path -from PySide import QtCore +import PathScripts.PathLog as PathLog +from PySide import QtCore, QtGui from PathScripts import PathUtils import Part -from FreeCAD import Vector -import PathScripts.PathLog as PathLog from PathScripts.PathUtils import waiting_effects from PathScripts.PathUtils import makeWorkplane from PathScripts.PathUtils import depth_params -LOG_MODULE = 'PathMillFace' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -PathLog.trackModule() -FreeCAD.setLogLevel('Path.Area', 0) +if True: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) -FreeCADGui = None +#FreeCADGui = None if FreeCAD.GuiUp: import FreeCADGui -"""Path Face object and FreeCAD command""" - # Qt tanslation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) +__title__ = "Path Mill Face Operation" +__author__ = "sliptonic (Brad Collette)" +__url__ = "http://www.freecadweb.org" + +"""Path Face object and FreeCAD command""" + class ObjectFace: @@ -95,11 +99,12 @@ class ObjectFace: obj.setEditorMode('AreaParams', 2) # hide if FreeCAD.GuiUp: - ViewProviderFace(obj.ViewObject) + _ViewProviderFace(obj.ViewObject) obj.Proxy = self def onChanged(self, obj, prop): + PathLog.track(prop) if prop == "StepOver": if obj.StepOver == 0: obj.StepOver = 1 @@ -110,36 +115,33 @@ class ObjectFace: def __setstate__(self, state): return None - def _guessDepths(self, obj, ss, sub=""): - try: - bb = ss.Shape.BoundBox # parent boundbox - subobj = ss.Shape.getElement(sub) - fbb = subobj.BoundBox # feature boundbox - obj.StartDepth = bb.ZMax + 1 - obj.ClearanceHeight = bb.ZMax + 5.0 - obj.SafeHeight = bb.ZMax + 3.0 - if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face - obj.FinalDepth = fbb.ZMin - elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut - obj.FinalDepth = fbb.ZMin - elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall - obj.FinalDepth = fbb.ZMin - elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf - obj.FinalDepth = fbb.ZMin - else: # catch all - obj.FinalDepth = bb.ZMin - except: - obj.StartDepth = 5.0 - obj.ClearanceHeight = 10.0 - obj.SafeHeight = 8.0 + def setDepths(self, obj): + PathLog.track() + parentJob = PathUtils.findParentJob(obj) + if parentJob is None: + return + baseobject = parentJob.Base + if baseobject is None: + return + + d = PathUtils.guessDepths(baseobject.Shape, None) + obj.StartDepth = d.start_depth + obj.ClearanceHeight = d.clearance_height + obj.FinalDepth = d.start_depth - 1.0 + obj.SafeHeight = d.safe_height def addFacebase(self, obj, ss, sub=""): baselist = obj.Base if baselist is None: baselist = [] if len(baselist) == 0: # When adding the first base object, guess at heights - self._guessDepths(obj, ss, sub) + subshape = [ss.Shape.getElement(sub)] + d = PathUtils.guessDepths(ss.Shape, subshape) + obj.StartDepth = d.start_depth + obj.ClearanceHeight =d.clearance_height + obj.FinalDepth = d.final_depth + obj.SafeHeight = d.safe_height item = (ss, sub) if item in baselist: @@ -148,8 +150,9 @@ class ObjectFace: FreeCAD.Console.PrintWarning(translate("Path", "Please select features from the Job model object" + "\n")) else: baselist.append(item) + PathLog.debug('baselist: {}'.format(baselist)) obj.Base = baselist - self.execute(obj) + #self.execute(obj) def getStock(self, obj): """find and return a stock object from hosting project if any""" @@ -186,10 +189,14 @@ class ObjectFace: Pattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle'] pocketparams['PocketMode'] = Pattern.index(obj.OffsetPattern) + 1 + offsetval = self.radius + pocketparams['ToolRadius'] = offsetval heights = [i for i in self.depthparams] boundary.setParams(**pocketparams) obj.AreaParams = str(boundary.getParams()) + PathLog.track('areaparams: {}'.format(obj.AreaParams)) + PathLog.track('height: {}'.format(heights)) sections = boundary.makeSections(mode=0, project=False, heights=heights) shapelist = [sec.getShape() for sec in sections] @@ -200,11 +207,6 @@ class ObjectFace: 'resume_height': obj.StepDown, 'retraction': obj.ClearanceHeight.Value} - # if obj.Direction == 'CCW': - # params['orientation'] = 1 - # else: - # params['orientation'] = 0 - PathLog.debug("Generating Path with params: {}".format(params)) pp = Path.fromShapes(**params) @@ -219,7 +221,6 @@ class ObjectFace: return commandlist = [] - toolLoad = obj.ToolController self.depthparams = depth_params( @@ -284,7 +285,7 @@ class ObjectFace: PathLog.info("Boundary Shape: {}".format(obj.BoundaryShape)) bb = planeshape.BoundBox if obj.BoundaryShape == 'Boundbox': - bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, Vector(bb.XMin, bb.YMin, bb.ZMin), Vector(0, 0, 1)) + bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin), FreeCAD.Vector(0, 0, 1)) env = PathUtils.getEnvelope(partshape=bbperim, depthparams=self.depthparams) else: env = PathUtils.getEnvelope(partshape=planeshape, depthparams=self.depthparams) @@ -303,25 +304,7 @@ class ObjectFace: obj.ViewObject.Visibility = True -class _CommandSetFaceStartPoint: - def GetResources(self): - return {'Pixmap': 'Path-StartPoint', - 'MenuText': QtCore.QT_TRANSLATE_NOOP("PathFace", "Pick Start Point"), - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathFace", "Pick Start Point")} - - def IsActive(self): - return FreeCAD.ActiveDocument is not None - - def setpoint(self, point, o): - obj = FreeCADGui.Selection.getSelection()[0] - obj.StartPoint.x = point.x - obj.StartPoint.y = point.y - - def Activated(self): - FreeCADGui.Snapper.getPoint(callback=self.setpoint) - - -class ViewProviderFace: +class _ViewProviderFace: def __init__(self, vobj): vobj.Proxy = self @@ -368,45 +351,43 @@ class CommandPathMillFace: return False def Activated(self): - - ztop = 10.0 + #ztop = 10.0 # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction(translate("PathFace", "Create Face")) FreeCADGui.addModule("PathScripts.PathMillFace") FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Face")') FreeCADGui.doCommand('PathScripts.PathMillFace.ObjectFace(obj)') - FreeCADGui.doCommand('obj.Active = True') - #FreeCADGui.doCommand('PathScripts.PathMillFace.ViewProviderFace(obj.ViewObject)') - FreeCADGui.doCommand('from PathScripts import PathUtils') - FreeCADGui.doCommand('obj.StepOver = 50') - FreeCADGui.doCommand('obj.ClearanceHeight = 10') # + str(bb.ZMax + 2.0)) - FreeCADGui.doCommand('obj.StepDown = 1.0') - FreeCADGui.doCommand('obj.StartDepth = ' + str(ztop + 1)) - FreeCADGui.doCommand('obj.FinalDepth =' + str(ztop)) - FreeCADGui.doCommand('obj.ZigZagAngle = 45.0') FreeCADGui.doCommand('obj.ViewObject.Proxy.deleteOnReject = True') - FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') - snippet = ''' -parentJob = PathUtils.findParentJob(obj) -if parentJob is None: - pass -else: - baseobject = parentJob.Base - if baseobject is None: - pass - else: - obj.StartDepth = str(baseobject.Shape.BoundBox.ZMax + 1) - obj.FinalDepth = str(baseobject.Shape.BoundBox.ZMax) -''' - FreeCADGui.doCommand(snippet) + FreeCADGui.doCommand('PathScripts.PathMillFace.ObjectFace.setDepths(obj.Proxy, obj)') + + FreeCADGui.doCommand('obj.Active = True') + FreeCADGui.doCommand('obj.StepOver = 50') + FreeCADGui.doCommand('obj.StepDown = 1.0') + FreeCADGui.doCommand('obj.ZigZagAngle = 45.0') + FreeCAD.ActiveDocument.commitTransaction() + FreeCADGui.doCommand('obj.ViewObject.startEditing()') - FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() +class _CommandSetFaceStartPoint: + def GetResources(self): + return {'Pixmap': 'Path-StartPoint', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("PathFace", "Pick Start Point"), + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathFace", "Pick Start Point")} + + def IsActive(self): + return FreeCAD.ActiveDocument is not None + + def setpoint(self, point, o): + obj = FreeCADGui.Selection.getSelection()[0] + obj.StartPoint.x = point.x + obj.StartPoint.y = point.y + + def Activated(self): + FreeCADGui.Snapper.getPoint(callback=self.setpoint) class TaskPanel: def __init__(self, obj, deleteOnReject): @@ -415,16 +396,15 @@ class TaskPanel: self.form = FreeCADGui.PySideUic.loadUi(":/panels/MillFaceEdit.ui") self.deleteOnReject = deleteOnReject self.obj = obj - self.updating = False + self.isDirty = True def accept(self): - self.getFields() - FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -437,6 +417,12 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + FreeCAD.ActiveDocument.recompute() + self.isDirty = False + def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): @@ -445,12 +431,12 @@ class TaskPanel: self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value + if hasattr(self.obj, "StepDown"): + self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value - if hasattr(self.obj, "StepDown"): - self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "PassExtension"): self.obj.PassExtension = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "CutMode"): @@ -467,7 +453,8 @@ class TaskPanel: if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - self.obj.Proxy.execute(self.obj) + + self.isDirty = True def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) @@ -478,7 +465,7 @@ class TaskPanel: self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) - self.form.zigZagAngle.setValue(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle)) + self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString) self.form.extraOffset.setValue(self.obj.PassExtension.Value) index = self.form.cutMode.findText( @@ -552,7 +539,6 @@ class TaskPanel: for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) - FreeCAD.ActiveDocument.recompute() def deleteBase(self): dlist = self.form.baseList.selectedItems() @@ -574,7 +560,6 @@ class TaskPanel: newlist.append(i) self.form.baseList.takeItem(self.form.baseList.row(d)) self.obj.Base = newlist - FreeCAD.ActiveDocument.recompute() def itemActivated(self): FreeCADGui.Selection.clearSelection() @@ -600,14 +585,8 @@ class TaskPanel: newlist.append(item) self.obj.Base = newlist - FreeCAD.ActiveDocument.recompute() - - # def getStandardButtons(self): - # return int(QtGui.QDialogButtonBox.Ok) - - def edit(self, item, column): - if not self.updating: - self.resetObject() + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) def resetObject(self, remove=None): "transfers the values from the widget to the object" diff --git a/src/Mod/Path/PathScripts/PathPocket.py b/src/Mod/Path/PathScripts/PathPocket.py index 77c1381db6..1926bf9f4d 100644 --- a/src/Mod/Path/PathScripts/PathPocket.py +++ b/src/Mod/Path/PathScripts/PathPocket.py @@ -24,7 +24,7 @@ import FreeCAD import Path -from PySide import QtCore +from PySide import QtCore, QtGui from PathScripts import PathUtils import PathScripts.PathLog as PathLog from PathScripts.PathUtils import waiting_effects, depth_params @@ -36,10 +36,11 @@ if FreeCAD.GuiUp: """Path Pocket object and FreeCAD command""" -LOG_MODULE = 'PathPocket' -PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) -#PathLog.trackModule('PathPocket') -FreeCAD.setLogLevel('Path.Area', 0) +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) # Qt tanslation handling @@ -187,6 +188,9 @@ class ObjectPocket: 'PocketStepover': stepover, 'PocketExtraOffset': obj.MaterialAllowance.Value} + offsetval = self.radius + pocketparams['ToolRadius'] = offsetval + Pattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle'] pocketparams['PocketMode'] = Pattern.index(obj.OffsetPattern) + 1 @@ -431,16 +435,15 @@ class TaskPanel: # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/PocketEdit.ui") self.form = FreeCADGui.PySideUic.loadUi(":/panels/PocketEdit.ui") self.deleteOnReject = deleteOnReject - self.updating = False + self.isDirty = True def accept(self): - self.getFields() - FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -453,18 +456,26 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + self.obj.Proxy.execute(self.obj) + self.isDirty = False + def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value + if hasattr(self.obj, "FinishDepth"): + self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value + if hasattr(self.obj, "StepDown"): + self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value - if hasattr(self.obj, "StepDown"): - self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "MaterialAllowance"): self.obj.MaterialAllowance = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseStartPoint"): @@ -481,16 +492,16 @@ class TaskPanel: PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - - self.obj.Proxy.execute(self.obj) + self.isDirty = True def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) + self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) + self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) - self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) - self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.MaterialAllowance, FreeCAD.Units.Length).UserString) + self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.MaterialAllowance.Value, FreeCAD.Units.Length).UserString) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) @@ -599,12 +610,8 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() - # def getStandardButtons(self): - # return int(QtGui.QDialogButtonBox.Ok) - - def edit(self, item, column): - if not self.updating: - self.resetObject() + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) def setupUi(self): @@ -619,6 +626,7 @@ class TaskPanel: # Depths self.form.startDepth.editingFinished.connect(self.getFields) self.form.finalDepth.editingFinished.connect(self.getFields) + self.form.finishDepth.editingFinished.connect(self.getFields) self.form.stepDown.editingFinished.connect(self.getFields) # Heights @@ -628,11 +636,13 @@ class TaskPanel: # operation self.form.cutMode.currentIndexChanged.connect(self.getFields) self.form.useStartPoint.clicked.connect(self.getFields) - self.form.extraOffset.editingFinished.connect(self.getFields) # Pattern + self.form.offsetpattern.currentIndexChanged.connect(self.getFields) self.form.stepOverPercent.editingFinished.connect(self.getFields) self.form.zigZagAngle.editingFinished.connect(self.getFields) + self.form.extraOffset.editingFinished.connect(self.getFields) + self.form.uiToolController.currentIndexChanged.connect(self.getFields) self.setFields() diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 7d57c3dd9b..7291bdb323 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -39,7 +39,7 @@ FreeCAD.setLogLevel('Path.Area', 0) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore + from PySide import QtCore, QtGui # Qt tanslation handling def translate(context, text, disambig=None): @@ -442,18 +442,17 @@ class TaskPanel: def __init__(self, obj, deleteOnReject): FreeCAD.ActiveDocument.openTransaction(translate("Path_Profile", "Profile Operation")) self.form = FreeCADGui.PySideUic.loadUi(":/panels/ProfileEdit.ui") - self.updating = False + self.isDirty = True self.deleteOnReject = deleteOnReject self.obj = obj def accept(self): - self.getFields() - FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -466,6 +465,12 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + self.obj.Proxy.execute(self.obj) + self.isDirty = False + def getFields(self): if self.obj: @@ -473,12 +478,12 @@ class TaskPanel: self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value + if hasattr(self.obj, "StepDown"): + self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value - if hasattr(self.obj, "StepDown"): - self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "OffsetExtra"): self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseComp"): @@ -500,14 +505,14 @@ class TaskPanel: tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - self.obj.Proxy.execute(self.obj) + self.isDirty = True def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) + self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) - self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) @@ -623,6 +628,9 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) + def setupUi(self): # Connect Signals and Slots @@ -644,6 +652,7 @@ class TaskPanel: # operation self.form.cutSide.currentIndexChanged.connect(self.getFields) + self.form.uiToolController.currentIndexChanged.connect(self.getFields) self.form.direction.currentIndexChanged.connect(self.getFields) self.form.useCompensation.clicked.connect(self.getFields) self.form.useStartPoint.clicked.connect(self.getFields) diff --git a/src/Mod/Path/PathScripts/PathProfileEdges.py b/src/Mod/Path/PathScripts/PathProfileEdges.py index 6a395bb690..d0bbb7f845 100644 --- a/src/Mod/Path/PathScripts/PathProfileEdges.py +++ b/src/Mod/Path/PathScripts/PathProfileEdges.py @@ -34,13 +34,15 @@ from PathScripts.PathUtils import waiting_effects """Path Profile from Edges Object and Command""" -LOG_MODULE = 'PathProfileEdges' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -# PathLog.trackModule('PathProfileEdges') +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore + from PySide import QtCore, QtGui # Qt tanslation handling def translate(context, text, disambig=None): @@ -65,11 +67,13 @@ class ObjectProfile: obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) # Depth Properties - obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions")) - obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations")) - obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool")) obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z")) obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z")) + obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool")) + + # Heights + obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations")) + obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions")) # Start Point Properties obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The start point of this path")) @@ -407,16 +411,17 @@ class TaskPanel: # self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ProfileEdgesEdit.ui") self.deleteOnReject = deleteOnReject self.obj = obj - self.updating = False + self.isDirty = True def accept(self): - self.getFields() + #self.getFields() FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -429,6 +434,12 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + self.obj.Proxy.execute(self.obj) + self.isDirty = False + def getFields(self): if self.obj: @@ -436,12 +447,12 @@ class TaskPanel: self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value + if hasattr(self.obj, "StepDown"): + self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value - if hasattr(self.obj, "StepDown"): - self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "OffsetExtra"): self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseComp"): @@ -450,21 +461,25 @@ class TaskPanel: self.obj.Side = str(self.form.cutSide.currentText()) if hasattr(self.obj, "Direction"): self.obj.Direction = str(self.form.direction.currentText()) + if hasattr(self.obj, "UseStartPoint"): + self.obj.UseStartPoint = self.form.useStartPoint.isChecked() + if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - self.obj.Proxy.execute(self.obj) + self.isDirty = True def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) + self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) - self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) + self.form.useStartPoint.setChecked(self.obj.UseStartPoint) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] @@ -576,6 +591,9 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) + def setupUi(self): # Connect Signals and Slots @@ -600,6 +618,8 @@ class TaskPanel: self.form.direction.currentIndexChanged.connect(self.getFields) self.form.useCompensation.clicked.connect(self.getFields) self.form.extraOffset.editingFinished.connect(self.getFields) + self.form.useStartPoint.clicked.connect(self.getFields) + self.setFields() sel = FreeCADGui.Selection.getSelectionEx() diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 0500ef3769..7eec8e1895 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -34,13 +34,15 @@ import sys if sys.version_info.major >= 3: xrange = range -LOG_MODULE = 'PathSurface' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -# PathLog.trackModule('PathSurface') +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) if FreeCAD.GuiUp: import FreeCADGui - from PySide import QtCore + from PySide import QtCore, QtGui __title__ = "Path Surface Operation" __author__ = "sliptonic (Brad Collette)" @@ -414,8 +416,6 @@ class CommandPathSurfacing: 'obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Surface")') FreeCADGui.doCommand('PathScripts.PathSurface.ObjectSurface(obj)') FreeCADGui.doCommand('obj.Active = True') - # FreeCADGui.doCommand( - # 'PathScripts.PathSurface.ViewProviderSurface(obj.ViewObject)') FreeCADGui.doCommand('from PathScripts import PathUtils') FreeCADGui.doCommand('obj.ClearanceHeight = ' + str(ztop + 2)) FreeCADGui.doCommand('obj.StartDepth = ' + str(ztop)) @@ -429,7 +429,6 @@ class CommandPathSurfacing: FreeCADGui.doCommand('obj.ViewObject.startEditing()') FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() class TaskPanel: @@ -441,15 +440,15 @@ class TaskPanel: FreeCAD.Console.PrintWarning("Surface calculations can be slow. Don't Panic.\n") self.deleteOnReject = deleteOnReject self.obj = obj + self.isDirty = True def accept(self): - self.getFields() - FreeCADGui.Control.closeDialog() FreeCADGui.ActiveDocument.resetEdit() FreeCAD.ActiveDocument.commitTransaction() FreeCADGui.Selection.removeObserver(self.s) - FreeCAD.ActiveDocument.recompute() + if self.isDirty: + FreeCAD.ActiveDocument.recompute() def reject(self): FreeCADGui.Control.closeDialog() @@ -462,9 +461,14 @@ class TaskPanel: FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + def clicked(self,button): + if button == QtGui.QDialogButtonBox.Apply: + self.getFields() + FreeCAD.ActiveDocument.recompute() + self.isDirty = False + def getFields(self): if self.obj: - if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): @@ -485,7 +489,7 @@ class TaskPanel: tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc - self.obj.Proxy.execute(self.obj) + self.isDirty = True def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) @@ -593,8 +597,8 @@ class TaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() - # def getStandardButtons(self): - # return int(QtGui.QDialogButtonBox.Ok) + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel) def setupUi(self): # Base Geometry @@ -602,7 +606,6 @@ class TaskPanel: self.form.deleteBase.clicked.connect(self.deleteBase) self.form.reorderBase.clicked.connect(self.reorderBase) self.form.baseList.itemSelectionChanged.connect(self.itemActivated) - self.form.uiToolController.currentIndexChanged.connect(self.getFields) # Depths self.form.startDepth.editingFinished.connect(self.getFields) @@ -616,6 +619,7 @@ class TaskPanel: # Operation self.form.algorithmSelect.currentIndexChanged.connect(self.getFields) + self.form.uiToolController.currentIndexChanged.connect(self.getFields) sel = FreeCADGui.Selection.getSelectionEx() self.setFields() diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index f2001a8f46..9710167b17 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -36,9 +36,11 @@ import Path from PySide import QtCore from PySide import QtGui -LOG_MODULE = 'PathUtils' -PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) -#PathLog.trackModule('PathUtils') +if False: + PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) + PathLog.trackModule(PathLog.thisModule()) +else: + PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) FreeCAD.setLogLevel('Path.Area', 0) @@ -112,6 +114,15 @@ def curvetowire(obj, steps): def isDrillable(obj, candidate, tooldiameter=None): + """ + Checks candidates to see if they can be drilled. + Candidates can be either faces - circular or cylindrical or circular edges. + The tooldiameter can be optionally passed. if passed, the check will return + False for any holes smaller than the tooldiameter. + obj=Shape + candidate = Face or Edge + tooldiameter=float + """ PathLog.track('obj: {} candidate: {} tooldiameter {}'.format(obj, candidate, tooldiameter)) drillable = False if candidate.ShapeType == 'Face': @@ -123,15 +134,23 @@ def isDrillable(obj, candidate, tooldiameter=None): PathLog.debug("candidate is a circle") v0 = edge.Vertexes[0].Point v1 = edge.Vertexes[1].Point - if (v1.sub(v0).x == 0) and (v1.sub(v0).y == 0): + #check if the cylinder seam is vertically aligned. Eliminate tilted holes + if (numpy.isclose(v1.sub(v0).x, 0, rtol=1e-05, atol=1e-06)) and \ + (numpy.isclose(v1.sub(v0).y, 0, rtol=1e-05, atol=1e-06)): + drillable = True # vector of top center lsp = Vector(face.BoundBox.Center.x, face.BoundBox.Center.y, face.BoundBox.ZMax) # vector of bottom center lep = Vector(face.BoundBox.Center.x, face.BoundBox.Center.y, face.BoundBox.ZMin) - if obj.isInside(lsp, 0, False) or obj.isInside(lep, 0, False): + # check if the cylindrical 'lids' are inside the base + # object. This eliminates extruded circles but allows + # actual holes. + if obj.isInside(lsp, 1e-6, False) or obj.isInside(lep, 1e-6, False): + PathLog.track("inside check failed. lsp: {} lep: {}".format(lsp,lep)) drillable = False # eliminate elliptical holes elif not hasattr(face.Surface, "Radius"): + PathLog.debug("candidate face has no radius attribute") drillable = False else: if tooldiameter is not None: