text stringlengths 0 93.6k |
|---|
label.grid(row=1, column=2, sticky="nsew") |
entry = tk.Entry(master=optFrame, text=self.repulsion) |
entry.grid(row=1, column=3) |
button = tk.Button(text="Reset", master=optFrame, command=self.Reset) |
button.grid(row=1, column=5, sticky="nsew") |
self.w = window |
self.c = c |
def Load(self, nets): |
#net #, name, count, checked |
activenets = 0 |
for net in enumerate(nets.netnames): |
self.tk_nets.append([net,tk.IntVar(value=1)]) |
netlabel = tk.Checkbutton(text=net, master=self.netCanvas, justify=tk.LEFT, variable=self.tk_nets[activenets][1]) |
self.netCanvas.window_create('end', window=netlabel) |
self.netCanvas.insert('end', '\n') |
activenets += 1 |
self.netCanvas['state'] = 'disabled' |
def Draw(self, footprints, nets, activenets): |
self.footprints = footprints |
self.nets = nets |
z = self.zoom |
self.c.delete("all") |
#Footprints |
for fp in footprints: |
move = fp.coord_current |
i = 0 |
while i < len(fp.shapes): |
poly = [] |
shape = fp.rotate(fp.shapes[i], move[2], [0,0]) |
for pts in shape: |
poly.append([(pts[0] + move[0]) * z, (pts[1] + move[1]) * z]) |
if len(poly) > 0: |
self.tk_shapes.append(self.c.create_polygon(*poly, fill=fp.shape_fills[i])) |
i += 1 |
for hole in fp.holes: |
pts = fp.rotate([[hole[0],hole[1]],[hole[2],hole[3]]], move[2], [0,0]) |
pts = [(pts[0][0] + move[0]) * z, (pts[0][1] + move[1]) * z, (pts[1][0] + move[0]) * z, (pts[1][1] + move[1]) * z] |
self.c.create_oval(*pts, fill="grey") |
#Nets |
for net in activenets: |
# print(net) |
for i, conn in enumerate(nets.netnames[net]): |
for e in range(i): |
pos1 = nets.netnames[net][i] |
xy1 = footprints[pos1[0]].anchors_rotated[pos1[1]].copy() |
xy1[0] += footprints[pos1[0]].coord_current[0] |
xy1[1] += footprints[pos1[0]].coord_current[1] |
pos2 = nets.netnames[net][e] |
xy2 = footprints[pos2[0]].anchors_rotated[pos2[1]].copy() |
xy2[0] += footprints[pos2[0]].coord_current[0] |
xy2[1] += footprints[pos2[0]].coord_current[1] |
self.tk_lines.append(self.c.create_line(xy1[0] * z,xy1[1] * z,xy2[0] * z,xy2[1] * z, fill="white")) |
def Animate_calc(self): |
global ELECTRON_CONSTANT |
global SPRING_CONSTANT |
global TORQUE_CONSTANT |
global DAMPING |
try: |
DAMPING = float(self.damping.get()) |
except: |
DAMPING = 1 |
try: |
ELECTRON_CONSTANT = float(self.repulsion.get()) |
except: |
ELECTRON_CONSTANT = 0 |
try: |
SPRING_CONSTANT = float(self.attraction.get()) |
except: |
SPRING_CONSTANT = 0 |
for fp in self.footprints: |
fp.Move() |
# nets.Draw(footprints) |
activenets = [] |
for net in self.tk_nets: |
if int(net[1].get()) == 1: |
activenets.append(net[0][1]) |
nets.Calc(footprints, activenets) |
self.Draw(self.footprints, self.nets,activenets) |
def Animate(self): |
startTime = time.time_ns() |
# cProfile.runctx('self.Animate_calc()', globals(), locals()) |
self.Animate_calc() |
try: |
speed = int(self.speed.get()) |
except: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.