-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDrillingDlg.py
123 lines (97 loc) · 4.83 KB
/
DrillingDlg.py
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
from DepthOpDlg import DepthOpDlg
from HeeksObjDlg import HeeksObjDlg
from NiceTextCtrl import LengthCtrl
from NiceTextCtrl import DoubleCtrl
from NiceTextCtrl import ObjectIdsCtrl
import wx
import cad
from HDialog import HControl
from HDialog import ComboBoxBinded
import Drilling
class DrillingDlg(DepthOpDlg):
def __init__(self, object, title = 'Drilling Operation'):
DepthOpDlg.__init__(self, object, True, title)
def AddLeftControls(self):
# add all the controls to the left side
self.idsPoints = ObjectIdsCtrl(self)
self.btnPointsPick = wx.Button(self, wx.ID_ANY, 'Pick')
self.btnPointsPick.Bind(wx.EVT_BUTTON, self.OnPointsPick )
self.MakeLabelAndControl("Points", self.idsPoints, self.btnPointsPick).AddToSizer(self.sizerLeft)
self.dblDwell = DoubleCtrl(self)
self.MakeLabelAndControl("Dwell", self.dblDwell).AddToSizer(self.sizerLeft)
self.chkFeedRetract = wx.CheckBox(self, wx.ID_ANY, 'Feed Retract')
HControl(wx.ALL, self.chkFeedRetract).AddToSizer(self.sizerLeft)
self.chkRapidToClearance = wx.CheckBox(self, wx.ID_ANY, 'Rapid to Clearance')
HControl(wx.ALL, self.chkRapidToClearance).AddToSizer(self.sizerLeft)
self.chkStopSpindleAtBottom = wx.CheckBox(self, wx.ID_ANY, 'Stop Spindle at Bottom')
HControl(wx.ALL, self.chkStopSpindleAtBottom).AddToSizer(self.sizerLeft)
self.chkInternalCoolantOn = wx.CheckBox(self, wx.ID_ANY, 'Interal Coolant On')
HControl(wx.ALL, self.chkInternalCoolantOn).AddToSizer(self.sizerLeft)
DepthOpDlg.AddLeftControls(self)
def GetDataRaw(self):
self.object.points = self.idsPoints.GetIdList()
self.object.dwell = self.dblDwell.GetValue()
self.object.retract_mode = 1 if self.chkFeedRetract.GetValue() else 0
self.object.spindle_mode = 1 if self.chkStopSpindleAtBottom.GetValue() else 0
self.object.internal_coolant_on = self.chkInternalCoolantOn.GetValue()
self.object.rapid_to_clearance = self.chkRapidToClearance.GetValue()
DepthOpDlg.GetDataRaw(self)
def SetFromDataRaw(self):
self.idsPoints.SetFromIdList(self.object.points)
self.dblDwell.SetValue(self.object.dwell)
self.chkFeedRetract.SetValue(self.object.retract_mode != 0)
self.chkStopSpindleAtBottom.SetValue(self.object.spindle_mode != 0)
self.chkInternalCoolantOn.SetValue(self.object.internal_coolant_on)
self.chkRapidToClearance.SetValue(self.object.rapid_to_clearance)
self.EnableControls()
DepthOpDlg.SetFromDataRaw(self)
def EnableControls(self):
pass
def SetPictureByName(self, name):
self.SetPictureByNameAndFolder( name, 'drilling')
def SetPictureByWindow(self, w):
if w == self.dblDwell: DrillingDlg.SetPictureByName(self, 'dwell')
elif w == self.chkFeedRetract:
if self.chkFeedRetract.GetSelection() == 1:
DrillingDlg.SetPictureByName(self, 'feed retract')
else:
DrillingDlg.SetPictureByName(self, 'rapid retract')
elif w == self.chkStopSpindleAtBottom:
if self.chkStopSpindleAtBottom.GetSelection() == 1:
DrillingDlg.SetPictureByName(self, 'stop spindle at bottom')
else:
DrillingDlg.SetPictureByName(self, 'dont stop spindle')
elif w == self.chkInternalCoolantOn:
if self.chkInternalCoolantOn.GetValue():
DrillingDlg.SetPictureByName(self, 'internal coolant on')
else:
DrillingDlg.SetPictureByName(self, 'internal coolant off')
elif w == self.chkRapidToClearance:
if self.chkRapidToClearance.GetValue():
DrillingDlg.SetPictureByName(self, 'rapid to clearance')
else:
DrillingDlg.SetPictureByName(self, 'rapid to standoff')
else:
DepthOpDlg.SetPictureByWindow(self, w)
def OnPointsPick(self, event):
self.EndModal(self.btnPointsPick.GetId())
def PickPoints(self):
cad.ClearSelection()
wx.GetApp().PickObjects('Pick points to drill', cad.Filter(cad.OBJECT_TYPE_POINT), False)
ids = []
for object in cad.GetSelectedObjects():
if object.GetType() == cad.OBJECT_TYPE_POINT:
ids.append(object.GetID())
self.idsPoints.SetFromIdList(ids)
self.Fit()
def Do(object):
dlg = DrillingDlg(object)
while(True):
result = dlg.ShowModal()
if result == wx.ID_OK:
dlg.GetData()
return True
elif result == dlg.btnPointsPick.GetId():
dlg.PickPoints()
else:
return False