File size: 8,525 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
# 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.Tapping as PathTapping
import Path.Op.Gui.Base as PathOpGui
import Path.Op.Gui.CircularHoleBase as PathCircularHoleBaseGui
import PathGui

from PySide import QtCore

__title__ = "Path Tapping Operation UI."
__author__ = "sliptonic (Brad Collette)"
__url__ = "https://www.freecad.org"
__doc__ = "UI and Command for Path Tapping Operation."
__contributors__ = "luvtofish"

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())


class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
    """Controller for the tapping operation's page"""

    def initPage(self, obj):
        #        self.peckDepthSpinBox = PathGuiUtil.QuantitySpinBox(
        #           self.form.peckDepth, obj, "PeckDepth"
        #       )
        #       self.peckRetractSpinBox = PathGuiUtil.QuantitySpinBox(
        #           self.form.peckRetractHeight, obj, "RetractHeight"
        #       )
        self.dwellTimeSpinBox = PathGuiUtil.QuantitySpinBox(self.form.dwellTime, obj, "DwellTime")

    #       self.form.chipBreakEnabled.setEnabled(False)

    def registerSignalHandlers(self, obj):
        #       self.form.peckEnabled.toggled.connect(self.form.peckDepth.setEnabled)
        #       self.form.peckEnabled.toggled.connect(self.form.dwellEnabled.setDisabled)
        #       self.form.peckEnabled.toggled.connect(self.setChipBreakControl)

        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)
        #       self.form.dwellEnabled.toggled.connect(self.setChipBreakControl)

        #       self.form.peckRetractHeight.setEnabled(True)
        #       self.form.retractLabel.setEnabled(True)

        #        if self.form.peckEnabled.isChecked():
        #            self.form.dwellEnabled.setEnabled(False)
        #            self.form.peckDepth.setEnabled(True)
        #            self.form.peckDepthLabel.setEnabled(True)
        #            self.form.chipBreakEnabled.setEnabled(True)
        #        elif self.form.dwellEnabled.isChecked():
        if self.form.dwellEnabled.isChecked():
            #            self.form.peckEnabled.setEnabled(False)
            self.form.dwellTime.setEnabled(True)
            self.form.dwellTimelabel.setEnabled(True)

    #            self.form.chipBreakEnabled.setEnabled(False)
    #        else:
    #            self.form.chipBreakEnabled.setEnabled(False)

    #    def setChipBreakControl(self):
    #        self.form.chipBreakEnabled.setEnabled(self.form.peckEnabled.isChecked())

    def getForm(self):
        """getForm() ... return UI"""
        form = FreeCADGui.PySideUic.loadUi(":/panels/PageOpTappingEdit.ui")

        comboToPropertyMap = [("ExtraOffset", "ExtraOffset")]
        enumTups = PathTapping.ObjectTapping.propertyEnumerations(dataType="raw")
        self.populateCombobox(form, enumTups, comboToPropertyMap)

        return form

    def updateQuantitySpinBoxes(self, index=None):
        #        self.peckDepthSpinBox.updateWidget()
        #        self.peckRetractSpinBox.updateWidget()
        self.dwellTimeSpinBox.updateWidget()

    def getFields(self, obj):
        """setFields(obj) ... update obj's properties with values from the UI"""
        Path.Log.track()
        #        self.peckDepthSpinBox.updateProperty()
        #        self.peckRetractSpinBox.updateProperty()
        self.dwellTimeSpinBox.updateProperty()

        if obj.DwellEnabled != self.form.dwellEnabled.isChecked():
            obj.DwellEnabled = self.form.dwellEnabled.isChecked()
        #        if obj.PeckEnabled != self.form.peckEnabled.isChecked():
        #            obj.PeckEnabled = self.form.peckEnabled.isChecked()
        #        if obj.chipBreakEnabled != self.form.chipBreakEnabled.isChecked():
        #            obj.chipBreakEnabled = self.form.chipBreakEnabled.isChecked()
        if obj.ExtraOffset != str(self.form.ExtraOffset.currentData()):
            obj.ExtraOffset = str(self.form.ExtraOffset.currentData())

        self.updateToolController(obj, self.form.toolController)
        self.updateCoolant(obj, self.form.coolantController)

    def setFields(self, obj):
        """setFields(obj) ... update UI with obj properties' values"""
        Path.Log.track()
        self.updateQuantitySpinBoxes()

        if obj.DwellEnabled:
            self.form.dwellEnabled.setCheckState(QtCore.Qt.Checked)
        else:
            self.form.dwellEnabled.setCheckState(QtCore.Qt.Unchecked)

        #        if obj.PeckEnabled:
        #            self.form.peckEnabled.setCheckState(QtCore.Qt.Checked)
        #        else:
        #            self.form.peckEnabled.setCheckState(QtCore.Qt.Unchecked)
        #            self.form.chipBreakEnabled.setEnabled(False)

        #        if obj.chipBreakEnabled:
        #            self.form.chipBreakEnabled.setCheckState(QtCore.Qt.Checked)
        #        else:
        #            self.form.chipBreakEnabled.setCheckState(QtCore.Qt.Unchecked)

        self.selectInComboBox(obj.ExtraOffset, self.form.ExtraOffset)

        self.setupToolController(obj, self.form.toolController)
        self.setupCoolant(obj, self.form.coolantController)

    def getSignalsForUpdate(self, obj):
        """getSignalsForUpdate(obj) ... return list of signals which cause the receiver to update the model"""
        signals = []

        #        signals.append(self.form.peckRetractHeight.editingFinished)
        #        signals.append(self.form.peckDepth.editingFinished)
        signals.append(self.form.dwellTime.editingFinished)
        signals.append(self.form.dwellEnabled.stateChanged)
        #        signals.append(self.form.peckEnabled.stateChanged)
        #        signals.append(self.form.chipBreakEnabled.stateChanged)
        signals.append(self.form.toolController.currentIndexChanged)
        signals.append(self.form.coolantController.currentIndexChanged)
        signals.append(self.form.ExtraOffset.currentIndexChanged)

        return signals


#    def updateData(self, obj, prop):
#        if prop in ["PeckDepth", "RetractHeight"] and not prop in ["Base", "Disabled"]:
#            self.updateQuantitySpinBoxes()


Command = PathOpGui.SetupOperation(
    "Tapping",
    PathTapping.Create,
    TaskPanelOpPage,
    "CAM_Tapping",
    QtCore.QT_TRANSLATE_NOOP("CAM_Tapping", "Tapping"),
    QtCore.QT_TRANSLATE_NOOP(
        "CAM_Tapping",
        "Creates a Tapping toolpath from the features of a base object",
    ),
    PathTapping.SetupProperties,
)

FreeCAD.Console.PrintLog("Loading PathTappingGui... done\n")