text stringlengths 0 93.6k |
|---|
self.coord_current = [0,0,0] |
self.shapes_initial = [] |
self.shapes = [] |
self.shape_fills = [] |
self.holes = [] |
self.holes_initial = [] |
self.anchors_initial = [] |
self.anchors = [] |
self.anchors_rotated = [] |
self.nets = [] |
self.force = 1 |
self.momentum = [0,0,0] |
self.locked = False |
if mod != False: |
self.Load(mod) |
def Load(self, mod): |
self.locked = mod.locked |
self.coord_initial = mod.at |
if len(self.coord_initial) == 2: |
self.coord_initial.append(0) |
self.coord_current = self.coord_initial.copy() |
#courtyard |
points = {} |
polypoints = [] |
for line in mod.fp_line: |
if line.layer == 'F.CrtYd': |
if len(polypoints) == 0: |
polypoints.append(line.start) |
#Conversion of mixed up start/end points to a polygon, by way of dictionary entries |
key = "{},{}".format(line.start[0],line.start[1]) |
if key in points.keys(): |
key = "{},{}".format(line.end[0],line.end[1]) |
if key in points.keys(): |
temp = points[key] |
points[key] = line.start |
key = "{},{}".format(temp[0],temp[1]) |
points[key] = line.end |
else: |
line.end = line.start |
points[key] = line.end |
for i in range(len(points)): |
key = "{},{}".format(polypoints[i][0],polypoints[i][1]) |
polypoints.append(points[key]) |
# polypoints = self.rotate(polypoints, self.coord_current[2], [0,0]) |
self.shapes_initial.append(polypoints) |
self.shapes.append(polypoints) |
self.shape_fills.append('red') |
#pads |
for pad in mod.pad: |
if pad.attribute == "smd": |
polypoints = [] |
# pad.at = self.rotate([pad.at], self.coord_current[2], [0,0])[0] |
polypoints.append([(pad.at[0] - (pad.size[0] / 2.0)), (pad.at[1] - (pad.size[1] / 2.0))]) |
polypoints.append([(pad.at[0] + (pad.size[0] / 2.0)), (pad.at[1] - (pad.size[1] / 2.0))]) |
polypoints.append([(pad.at[0] + (pad.size[0] / 2.0)), (pad.at[1] + (pad.size[1] / 2.0))]) |
polypoints.append([(pad.at[0] - (pad.size[0] / 2.0)), (pad.at[1] + (pad.size[1] / 2.0))]) |
# polypoints = self.rotate(polypoints, self.coord_current[2], [0,0]) |
self.shapes.append(polypoints) |
self.shapes_initial.append(polypoints) |
self.shape_fills.append('grey') |
else: |
at = [(pad.at[0] - (pad.size[0] / 2.0)), (pad.at[1] - (pad.size[1] / 2.0))] |
at.append((pad.at[0] + (pad.size[0] / 2.0))) |
at.append((pad.at[1] + (pad.size[1] / 2.0))) |
self.holes.append(at) |
self.holes_initial.append(at) |
self.nets.append(pad.net) |
self.anchors.append([pad.at[0], pad.at[1]]) |
self.anchors_initial.append([pad.at[0], pad.at[1]]) |
self.anchors_rotated = self.rotate(self.anchors, self.coord_current[2], [0,0]) |
def rotate(self, points, angle, center): |
angle = math.radians(angle) |
cos_val = math.cos(angle) |
sin_val = math.sin(angle) |
cx, cy = center |
new_points = [] |
for x_old, y_old in points: |
x_old -= cx |
y_old -= cy |
x_new = x_old * cos_val - y_old * sin_val |
y_new = x_old * sin_val + y_old * cos_val |
new_points.append([x_new + cx, y_new + cy]) |
return new_points |
def Move(self, move = False): |
if move is False: |
move = self.momentum |
# new_shapes = [] |
# for shape in self.shapes: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.