Commit 7d3bff4d authored by fred's avatar fred
Browse files

fix vertical stacking in grid

parent 669a7371
...@@ -26,7 +26,9 @@ class TimeCell: ...@@ -26,7 +26,9 @@ class TimeCell:
w = 1 w = 1
h = 1 h = 1
def __init__(self): def __init__(self, i, j):
self.x = i
self.y = j
self.emissions = [] self.emissions = []
def add_emission(self, emission): def add_emission(self, emission):
...@@ -67,7 +69,7 @@ class Grid(TemplateView): ...@@ -67,7 +69,7 @@ class Grid(TemplateView):
for i in range(nb_lines): for i in range(nb_lines):
grid.append([]) grid.append([])
for j in range(7): for j in range(7):
grid[-1].append(TimeCell()) grid[-1].append(TimeCell(i, j))
nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0] nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0]
for time_cell in grid[-1]: for time_cell in grid[-1]:
...@@ -101,6 +103,7 @@ class Grid(TemplateView): ...@@ -101,6 +103,7 @@ class Grid(TemplateView):
t += 1 t += 1
except IndexError: except IndexError:
pass pass
grid[i] = [x for x in grid[i] if x is not None]
for i in range(nb_lines): for i in range(nb_lines):
grid[i] = [x for x in grid[i] if x is not None] grid[i] = [x for x in grid[i] if x is not None]
...@@ -109,10 +112,14 @@ class Grid(TemplateView): ...@@ -109,10 +112,14 @@ class Grid(TemplateView):
continue continue
t = 1 t = 1
try: try:
while grid[i+t][j] == cell and grid[i+t][j].w == cell.w: while True:
same_cell_below = [(bj, x) for bj, x in enumerate(grid[i+cell.h])
if x == cell and x.y == cell.y and x.w == cell.w]
if not same_cell_below:
break
bj, same_cell_below = same_cell_below[0]
del grid[i+cell.h][bj]
cell.h += 1 cell.h += 1
grid[i+t][j] = None
t += 1
except IndexError: except IndexError:
pass pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment