Commit b597639e authored by Guillaume Seguin's avatar Guillaume Seguin

Rework GcodeModel a little towards #423

This way we can easily yield at the end of each iteration. The remaining
issue is mostly how to handle the costly numpy.fromiter, which we don't
want to do uselessly several times.
parent c35f5cf6
......@@ -329,7 +329,9 @@ class GcodeModel(Model):
prev_move_y = None
prev_pos = (0, 0, 0)
for layer_idx, layer in enumerate(model_data.all_layers):
layer_idx = 0
while layer_idx < len(model_data.all_layers):
layer = model_data.all_layers[layer_idx]
has_movement = False
for gline_idx, gline in enumerate(layer):
if not gline.is_move:
......@@ -446,6 +448,8 @@ class GcodeModel(Model):
if callback:
callback(layer_idx + 1, num_layers)
layer_idx += 1
self.count_travel_indices = count_travel_indices
self.count_print_indices = count_print_indices
self.count_print_vertices = count_print_vertices
......@@ -682,7 +686,9 @@ class GcodeModelLight(Model):
num_layers = len(model_data.all_layers)
prev_pos = (0, 0, 0)
for layer_idx, layer in enumerate(model_data.all_layers):
layer_idx = 0
while layer_idx < len(model_data.all_layers):
layer = model_data.all_layers[layer_idx]
has_movement = False
for gline in layer:
if not gline.is_move:
......@@ -707,6 +713,8 @@ class GcodeModelLight(Model):
if callback:
callback(layer_idx + 1, num_layers)
layer_idx += 1
self.vertices = numpy.fromiter(vertex_list, dtype = GLfloat,
count = len(vertex_list))
self.colors = numpy.fromiter(color_list, dtype = GLfloat,
......
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