-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPattern.py
84 lines (70 loc) · 2.52 KB
/
Pattern.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
from CamObject import CamObject
import geom
import cad
type = 0
class Pattern(CamObject):
def __init__(self):
CamObject.__init__(self, id_named = True)
self.copies1 = 1
self.x_shift1 = 10.0
self.y_shift1 = 0.0
self.copies2 = 1
self.x_shift2 = 10.0
self.y_shift2 = 0.0
def GetType(self):
return type
def TypeName(self):
return "Pattern"
def icon(self):
# the name of the PNG file in the HeeksCNC icons folder
return "pattern"
def HasEdit(self):
return True
def Edit(self):
from PatternDlg import PatternDlg
import wx
dlg = PatternDlg(self)
if dlg.ShowModal() == wx.ID_OK:
dlg.GetData()
return True
return False
def MakeACopy(self):
copy = Pattern()
copy.CopyFrom(self)
return copy
def CopyFrom(self, object):
CamObject.CopyFrom(self, object)
self.copies1 = object.copies1
self.x_shift1 = object.x_shift1
self.y_shift1 = object.y_shift1
self.copies2 = object.copies2
self.x_shift2 = object.x_shift2
self.y_shift2 = object.y_shift2
def WriteXml(self):
cad.SetXmlValue('copies1', self.copies1)
cad.SetXmlValue('x_shift1', self.x_shift1)
cad.SetXmlValue('y_shift1', self.y_shift1)
cad.SetXmlValue('copies2', self.copies2)
cad.SetXmlValue('x_shift2', self.x_shift2)
cad.SetXmlValue('y_shift2', self.y_shift2)
CamObject.WriteXml(self)
def ReadXml(self):
self.copies1 = cad.GetXmlInt('copies1', self.copies1)
self.x_shift1 = cad.GetXmlFloat('x_shift1', self.x_shift1)
self.y_shift1 = cad.GetXmlFloat('y_shift1', self.y_shift1)
self.copies2 = cad.GetXmlInt('copies2', self.copies2)
self.x_shift2 = cad.GetXmlFloat('x_shift2', self.x_shift2)
self.y_shift2 = cad.GetXmlFloat('y_shift2', self.y_shift2)
CamObject.ReadXml(self)
def GetMatrices(self, matrices):
m2 = geom.Matrix()
shift_m2 = geom.Matrix()
shift_m2.Translate(geom.Point3D(self.x_shift2, self.y_shift2, 0.0))
shift_m1 = geom.Matrix()
shift_m1.Translate(geom.Point3D(self.x_shift1, self.y_shift1, 0.0))
for j in range( 0, self.copies2):
m = geom.Matrix(m2)
for i in range(0, self.copies1):
matrices.append(m)
m = m * shift_m1
m2 = m2 * shift_m2