diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui index c4d2e3530b..b1ad210bb3 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageOpDrillingEdit.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 255 + 572 + 299 @@ -49,55 +49,75 @@ - - + + - Dwell + Use Tip Length - - + + + + false + - 0 sec - - - sec + Time - - - - mm + + + + false - - - - - Retract Height + Depth - + + + + false + + + Retract + + + + + + + false + + + + Peck - - - - mm + + + + Dwell - - - - Use Tip Length + + + + false + + + + + + + false @@ -121,18 +141,15 @@ - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::QuantitySpinBox + QDoubleSpinBox +
Gui/QuantitySpinBox.h
toolController - retractHeight peckEnabled - peckDepth dwellEnabled - dwellTime useTipLength diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 70b3306832..ee58d3e335 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -43,7 +43,7 @@ __title__ = "Path Drilling Operation" __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Path Drilling operation." -__contributors__ = "russ4262 (Russell Johnson)" +__contributors__ = "russ4262 (Russell Johnson), IMBack!" __created__ = "2014" __scriptVersion__ = "1c testing" __lastModified__ = "2019-06-25 14:49 CST" @@ -77,10 +77,9 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): obj.addProperty("App::PropertyFloat", "DwellTime", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "The time to dwell between peck cycles")) obj.addProperty("App::PropertyBool", "DwellEnabled", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "Enable dwell")) obj.addProperty("App::PropertyBool", "AddTipLength", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate the tip length and subtract from final depth")) - obj.addProperty("App::PropertyEnumeration", "ReturnLevel", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "Controls how tool retracts Default=G98")) - obj.ReturnLevel = ['G98', 'G99'] # this is the direction that the Contour runs - - obj.addProperty("App::PropertyDistance", "RetractHeight", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height where feed starts and height during retract tool when path is finished")) + obj.addProperty("App::PropertyEnumeration", "ReturnLevel", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "Controls how tool retracts Default=G99")) + obj.ReturnLevel = ['G99', 'G98'] # Canned Cycle Return Level + obj.addProperty("App::PropertyDistance", "RetractHeight", "Drill", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height where feed starts and height during retract tool when path is finished while in a peck operation")) # Rotation related properties if not hasattr(obj, 'EnableRotation'): @@ -116,20 +115,14 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): self.commandlist.append(Path.Command('G90')) self.commandlist.append(Path.Command(obj.ReturnLevel)) - # ml: I'm not sure whey these were here, they seem redundant - # # rapid to first hole location, with spindle still retracted: - # p0 = holes[0] - # self.commandlist.append(Path.Command('G0', {'X': p0['x'], 'Y': p0['y'], 'F': self.horizRapid})) - # # move tool to clearance plane - # self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid})) - for p in holes: cmd = "G81" cmdParams = {} cmdParams['Z'] = p['trgtDep'] - tiplength cmdParams['F'] = self.vertFeed - cmdParams['R'] = obj.RetractHeight.Value + cmdParams['R'] = obj.SafeHeight.Value if obj.PeckEnabled and obj.PeckDepth.Value > 0: + cmdParams['R'] = obj.RetractHeight.Value cmd = "G83" cmdParams['Q'] = obj.PeckDepth.Value elif obj.DwellEnabled and obj.DwellTime > 0: @@ -172,23 +165,45 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): self.commandlist.append(Path.Command('G0', {axisOfRot: angle, 'F': self.axialRapid})) self.commandlist.append(Path.Command('G0', {'X': p['x'], 'Y': p['y'], 'F': self.horizRapid})) self.commandlist.append(Path.Command('G1', {'Z': p['stkTop'], 'F': self.vertFeed})) - + # Perform and cancel canned drilling cycle self.commandlist.append(Path.Command(cmd, params)) self.commandlist.append(Path.Command('G80')) + + # shift axis and angle values if obj.EnableRotation != 'Off': lastAxis = axisOfRot lastAngle = angle + elif obj.PeckEnabled and obj.PeckDepth.Value > 0 and obj.RetractHeight.Value != obj.SafeHeight.Value: + self.commandlist.append(Path.Command('G0', {'Z': obj.SafeHeight.Value})) if obj.EnableRotation != 'Off': self.commandlist.append(Path.Command('G0', {'Z': obj.SafeHeight.Value, 'F': self.vertRapid})) self.commandlist.append(Path.Command('G0', {lastAxis: 0.0, 'F': self.axialRapid})) + def opSetDefaultValues(self, obj, job): '''opSetDefaultValues(obj, job) ... set default value for RetractHeight''' - obj.RetractHeight = 10.0 + + parentJob = PathUtils.findParentJob(obj) + + if hasattr(parentJob.SetupSheet, 'RetractHeight'): + obj.RetractHeight = parentJob.SetupSheet.RetractHeight + elif self.applyExpression(obj, 'RetractHeight', 'OpStartDepth+1mm'): + obj.RetractHeight = 10 + + if hasattr(parentJob.SetupSheet, 'PeckDepth'): + obj.PeckDepth = parentJob.SetupSheet.PeckDepth + elif self.applyExpression(obj, 'PeckDepth', 'OpToolDiameter*0.75'): + obj.PeckDepth = 1 + + if hasattr(parentJob.SetupSheet, 'DwellTime'): + obj.DwellTime = parentJob.SetupSheet.DwellTime + else: + obj.DwellTime = 1 + obj.ReverseDirection = False obj.InverseAngle = False obj.B_AxisErrorOverride = False @@ -196,7 +211,6 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): # Initial setting for EnableRotation is taken from Job SetupSheet # User may override on per-operation basis as needed. - parentJob = PathUtils.findParentJob(obj) if hasattr(parentJob.SetupSheet, 'SetupEnableRotation'): obj.EnableRotation = parentJob.SetupSheet.SetupEnableRotation else: diff --git a/src/Mod/Path/PathScripts/PathDrillingGui.py b/src/Mod/Path/PathScripts/PathDrillingGui.py index 3415e76f0a..8b053ec6eb 100644 --- a/src/Mod/Path/PathScripts/PathDrillingGui.py +++ b/src/Mod/Path/PathScripts/PathDrillingGui.py @@ -36,6 +36,7 @@ __title__ = "Path Drilling Operation UI." __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "UI and Command for Path Drilling Operation." +__contributors__ = "IMBack!" LOGLEVEL = False @@ -48,17 +49,49 @@ else: class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): '''Controller for the drilling operation's page''' + + def initPage(self, obj): + self.peckDepthSpinBox = PathGui.QuantitySpinBox(self.form.peckDepth, obj, 'PeckDepth') + self.peckRetractSpinBox = PathGui.QuantitySpinBox(self.form.peckRetractHeight, obj, 'RetractHeight') + self.dwellTimeSpinBox = PathGui.QuantitySpinBox(self.form.dwellTime, obj, 'DwellTime') + + def registerSignalHandlers(self, obj): + self.form.peckEnabled.toggled.connect(self.form.peckDepth.setEnabled) + self.form.peckEnabled.toggled.connect(self.form.peckRetractHeight.setEnabled) + self.form.peckEnabled.toggled.connect(self.form.peckDepthLabel.setEnabled) + self.form.peckEnabled.toggled.connect(self.form.retractLabel.setEnabled) + self.form.peckEnabled.toggled.connect(self.form.dwellEnabled.setDisabled) + + self.form.dwellEnabled.toggled.connect(self.form.dwellTime.setEnabled) + self.form.dwellEnabled.toggled.connect(self.form.dwellTimelabel.setEnabled) + self.form.dwellEnabled.toggled.connect(self.form.peckEnabled.setDisabled) + + if self.form.peckEnabled.isChecked(): + self.form.dwellEnabled.setEnabled(False) + self.form.peckDepth.setEnabled(True) + self.form.peckRetractHeight.setEnabled(True) + self.form.peckDepthLabel.setEnabled(True) + self.form.retractLabel.setEnabled(True) + elif self.form.dwellEnabled.isChecked(): + self.form.peckEnabled.setEnabled(False) + self.form.dwellTime.setEnabled(True) + self.form.dwellTimelabel.setEnabled(True) def getForm(self): '''getForm() ... return UI''' return FreeCADGui.PySideUic.loadUi(":/panels/PageOpDrillingEdit.ui") + + def updateQuantitySpinBoxes(self, index = None): + self.peckDepthSpinBox.updateSpinBox() + self.peckRetractSpinBox.updateSpinBox() + self.dwellTimeSpinBox.updateSpinBox() def getFields(self, obj): '''setFields(obj) ... update obj's properties with values from the UI''' PathLog.track() - PathGui.updateInputField(obj, 'PeckDepth', self.form.peckDepth) - PathGui.updateInputField(obj, 'RetractHeight', self.form.retractHeight) - PathGui.updateInputField(obj, 'DwellTime', self.form.dwellTime) + self.peckDepthSpinBox.updateProperty() + self.peckRetractSpinBox.updateProperty() + self.dwellTimeSpinBox.updateProperty() if obj.DwellEnabled != self.form.dwellEnabled.isChecked(): obj.DwellEnabled = self.form.dwellEnabled.isChecked() @@ -72,10 +105,7 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): def setFields(self, obj): '''setFields(obj) ... update UI with obj properties' values''' PathLog.track() - - self.form.peckDepth.setText(FreeCAD.Units.Quantity(obj.PeckDepth.Value, FreeCAD.Units.Length).UserString) - self.form.retractHeight.setText(FreeCAD.Units.Quantity(obj.RetractHeight.Value, FreeCAD.Units.Length).UserString) - self.form.dwellTime.setText(str(obj.DwellTime)) + self.updateQuantitySpinBoxes() if obj.DwellEnabled: self.form.dwellEnabled.setCheckState(QtCore.Qt.Checked) @@ -98,7 +128,7 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): '''getSignalsForUpdate(obj) ... return list of signals which cause the receiver to update the model''' signals = [] - signals.append(self.form.retractHeight.editingFinished) + signals.append(self.form.peckRetractHeight.editingFinished) signals.append(self.form.peckDepth.editingFinished) signals.append(self.form.dwellTime.editingFinished) signals.append(self.form.dwellEnabled.stateChanged) @@ -107,6 +137,10 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): signals.append(self.form.toolController.currentIndexChanged) return signals + + def updateData(self, obj, prop): + if prop in ['PeckDepth', 'RetractHeight'] and not prop in ['Base', 'Disabled']: + self.updateQuantitySpinBoxes() Command = PathOpGui.SetupOperation('Drilling', PathDrilling.Create, diff --git a/src/Mod/Path/PathScripts/PathGui.py b/src/Mod/Path/PathScripts/PathGui.py index cd00faac57..ed2e9e757d 100644 --- a/src/Mod/Path/PathScripts/PathGui.py +++ b/src/Mod/Path/PathScripts/PathGui.py @@ -122,6 +122,11 @@ The spin box gets bound to a given property and supports update in both directio if self.valid: return self.widget.property('expression') return '' + + def setMinimum(self, quantity): + if self.valid: + value = quantity.Value if hasattr(quantity, 'Value') else quantity + self.widget.setProperty('setMinimum', value) def updateSpinBox(self, quantity=None): '''updateSpinBox(quantity=None) ... update the display value of the spin box. diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index ac037a578c..c350c68e87 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -354,6 +354,7 @@ class TaskPanelPage(object): controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] combo.blockSignals(True) + combo.clear() combo.addItems(labels) combo.blockSignals(False)