File size: 8,713 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | # SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * Copyright (c) 2017 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 FreeCAD
import FreeCADGui
import Path
import Path.Base.Gui.Util as PathGuiUtil
import Path.Op.Gui.Base as PathOpGui
import Path.Op.Pocket as PathPocket
import PathGui
__title__ = "CAM Pocket Base Operation UI"
__author__ = "sliptonic (Brad Collette)"
__url__ = "https://www.freecad.org"
__doc__ = "Base page controller and command implementation for pocket operations."
if False:
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
Path.Log.trackModule(Path.Log.thisModule())
else:
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
translate = FreeCAD.Qt.translate
FeaturePocket = 0x01
FeatureFacing = 0x02
FeatureOutline = 0x04
FeatureRestMachining = 0x08
class TaskPanelOpPage(PathOpGui.TaskPanelPage):
"""Page controller class for pocket operations, supports:
FeaturePocket ... used for pocketing operation
FeatureFacing ... used for face milling operation
FeatureOutline ... used for pocket-shape operation
"""
def pocketFeatures(self):
"""pocketFeatures() ... return which features of the UI are supported by the operation.
FeaturePocket ... used for pocketing operation
FeatureFacing ... used for face milling operation
FeatureOutline ... used for pocket-shape operation
Must be overwritten by subclasses"""
pass
def getForm(self):
"""getForm() ... returns UI, adapted to the results from pocketFeatures()"""
form = FreeCADGui.PySideUic.loadUi(":/panels/PageOpPocketFullEdit.ui")
comboToPropertyMap = [
("cutMode", "CutMode"),
("clearingPattern", "ClearingPattern"),
]
enumTups = PathPocket.ObjectPocket.pocketPropertyEnumerations(dataType="raw")
self.populateCombobox(form, enumTups, comboToPropertyMap)
if not FeatureFacing & self.pocketFeatures():
form.facingWidget.hide()
form.clearEdges.hide()
if FeaturePocket & self.pocketFeatures():
form.extraOffset_label.setText(translate("PathPocket", "Pass Extension"))
form.extraOffset.setToolTip(
translate(
"PathPocket",
"The distance the facing operation will extend beyond the boundary shape.",
)
)
if not (FeatureOutline & self.pocketFeatures()):
form.useOutline.hide()
if not (FeatureRestMachining & self.pocketFeatures()):
form.useRestMachining.hide()
return form
def updateMinTravel(self, obj, setModel=True):
if setModel and obj.MinTravel != self.form.minTravel.isChecked():
obj.MinTravel = self.form.minTravel.isChecked()
def updateZigZagAngle(self, obj, setModel=True):
if obj.ClearingPattern in ["Offset"]:
self.form.zigZagAngle.setEnabled(False)
else:
self.form.zigZagAngle.setEnabled(True)
if setModel:
PathGuiUtil.updateInputField(obj, "ZigZagAngle", self.form.zigZagAngle)
def getFields(self, obj):
"""getFields(obj) ... transfers values from UI to obj's properties"""
if obj.CutMode != str(self.form.cutMode.currentData()):
obj.CutMode = str(self.form.cutMode.currentData())
if obj.StepOver != self.form.stepOverPercent.value():
obj.StepOver = self.form.stepOverPercent.value()
if obj.ClearingPattern != str(self.form.clearingPattern.currentData()):
obj.ClearingPattern = str(self.form.clearingPattern.currentData())
PathGuiUtil.updateInputField(obj, "ExtraOffset", self.form.extraOffset)
self.updateToolController(obj, self.form.toolController)
self.updateCoolant(obj, self.form.coolantController)
self.updateZigZagAngle(obj)
if obj.UseStartPoint != self.form.useStartPoint.isChecked():
obj.UseStartPoint = self.form.useStartPoint.isChecked()
if obj.UseRestMachining != self.form.useRestMachining.isChecked():
obj.UseRestMachining = self.form.useRestMachining.isChecked()
if FeatureOutline & self.pocketFeatures():
if obj.UseOutline != self.form.useOutline.isChecked():
obj.UseOutline = self.form.useOutline.isChecked()
self.updateMinTravel(obj)
if FeatureFacing & self.pocketFeatures():
print(obj.BoundaryShape)
print(self.form.boundaryShape.currentText())
print(self.form.boundaryShape.currentData())
if obj.BoundaryShape != str(self.form.boundaryShape.currentData()):
obj.BoundaryShape = str(self.form.boundaryShape.currentData())
if obj.ClearEdges != self.form.clearEdges.isChecked():
obj.ClearEdges = self.form.clearEdges.isChecked()
def setFields(self, obj):
"""setFields(obj) ... transfers obj's property values to UI"""
self.form.stepOverPercent.setValue(obj.StepOver)
self.form.extraOffset.setText(
FreeCAD.Units.Quantity(obj.ExtraOffset.Value, FreeCAD.Units.Length).UserString
)
self.form.useStartPoint.setChecked(obj.UseStartPoint)
self.form.useRestMachining.setChecked(obj.UseRestMachining)
if FeatureOutline & self.pocketFeatures():
self.form.useOutline.setChecked(obj.UseOutline)
self.form.zigZagAngle.setText(
FreeCAD.Units.Quantity(obj.ZigZagAngle, FreeCAD.Units.Angle).UserString
)
self.updateZigZagAngle(obj, False)
self.form.minTravel.setChecked(obj.MinTravel)
self.updateMinTravel(obj, False)
self.selectInComboBox(obj.ClearingPattern, self.form.clearingPattern)
self.selectInComboBox(obj.CutMode, self.form.cutMode)
self.setupToolController(obj, self.form.toolController)
self.setupCoolant(obj, self.form.coolantController)
if FeatureFacing & self.pocketFeatures():
self.selectInComboBox(obj.BoundaryShape, self.form.boundaryShape)
self.form.clearEdges.setChecked(obj.ClearEdges)
def getSignalsForUpdate(self, obj):
"""getSignalsForUpdate(obj) ... return list of signals for updating obj"""
signals = []
signals.append(self.form.cutMode.currentIndexChanged)
signals.append(self.form.clearingPattern.currentIndexChanged)
signals.append(self.form.stepOverPercent.editingFinished)
signals.append(self.form.zigZagAngle.editingFinished)
signals.append(self.form.toolController.currentIndexChanged)
signals.append(self.form.extraOffset.editingFinished)
signals.append(self.form.useStartPoint.clicked)
signals.append(self.form.useRestMachining.clicked)
signals.append(self.form.useOutline.clicked)
signals.append(self.form.minTravel.clicked)
signals.append(self.form.coolantController.currentIndexChanged)
if FeatureFacing & self.pocketFeatures():
signals.append(self.form.boundaryShape.currentIndexChanged)
signals.append(self.form.clearEdges.clicked)
return signals
|