-
Notifications
You must be signed in to change notification settings - Fork 5
/
entities.py
207 lines (153 loc) · 5.28 KB
/
entities.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
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
197
198
199
200
201
202
203
204
205
206
207
"""Drawing entity objects:
Some future ones:
GR Geometry Rectangle
GP Geometry Polygon
GO Geometry Oval
GE Geometry Ellipse
GS Geometry Slot
DA Dimension Angular
DR Dimension Radial
"""
class CL:
"""Construction Line object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (a, b, c)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'cl'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
class CC:
"""Construction Circle object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (pc, r)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'cc'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
class GL:
"""Geometry Line object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (a, b, c)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'gl'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
class GC:
"""Geometry Circle object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (pc, r)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'gc'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
class GA:
"""Geometry Arc object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (pc, r, a0, a1)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'ga'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
class TX:
"""Text object initialized with a tuple of attributes.
attribs = (coords, text, style, size, color)
"""
def __init__(self, attribs):
self.coords, self.text, self.style, self.size, self.color = attribs
self.type = 'tx'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.text == other.text and
self.style == other.style and
self.size == other.size and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.text, self.style, self.size, self.color)
class DL:
"""Dimension Linear object initialized with a tuple of attributes.
attribs = (coords, color)
coords = (p1, p2, p3, d)
"""
def __init__(self, attribs):
self.coords, self.color = attribs
self.type = 'dl'
self.show = True
def __hash__(self):
return hash(self.get_attribs())
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self.coords == other.coords and
self.color == other.color)
def __repr__(self):
return "{} object with coordinates {}".format(self.type, self.coords)
def get_attribs(self):
return (self.coords, self.color)
if __name__ == "__main__":
attribs = ((50,50), "this is some text", 'Verdana', 10, 'cyan',)
t1 = TX(attribs)
print(t1)
print(t1.coords)
t1.coords = (100, 100)
print(t1.get_attribs())
print(t1)