Commit 7883a7e5 authored by Guillaume Seguin's avatar Guillaume Seguin

Follow tool changes in GCoder and GCView

parent 5ffc3ac5
......@@ -31,7 +31,7 @@ class Line(object):
'raw','split_raw',
'command','is_move',
'relative','relative_e',
'current_x', 'current_y', 'current_z', 'extruding',
'current_x', 'current_y', 'current_z', 'extruding', 'current_tool',
'gcview_end_vertex')
def __init__(self, l):
......@@ -131,6 +131,7 @@ class GCode(object):
imperial = False
relative = False
relative_e = False
current_tool = 0
filament_length = None
xmin = None
......@@ -178,10 +179,12 @@ class GCode(object):
imperial = self.imperial
relative = self.relative
relative_e = self.relative_e
current_tool = self.current_tool
for line in lines:
if line.is_move:
line.relative = relative
line.relative_e = relative_e
line.current_tool = current_tool
elif line.command == "G20":
imperial = True
elif line.command == "G21":
......@@ -196,11 +199,14 @@ class GCode(object):
relative_e = False
elif line.command == "M83":
relative_e = True
elif line.command[0] == "T":
current_tool = int(line.command[1:])
if line.command[0] == "G":
line.parse_coordinates(imperial)
self.imperial = imperial
self.relative = relative
self.relative_e = relative_e
self.current_tool = current_tool
def _preprocess_extrusion(self, lines = None, cur_e = 0):
if not lines:
......
......@@ -237,6 +237,9 @@ class GcodeModel(Model):
Model for displaying Gcode data.
"""
color_travel = (0.6, 0.6, 0.6, 0.6)
color_tool0 = (1.0, 0.0, 0.0, 0.6)
color_tool1 = (0.0, 0.0, 1.0, 0.6)
color_printed = (0.2, 0.75, 0, 0.6)
use_vbos = True
......@@ -297,28 +300,13 @@ class GcodeModel(Model):
"""
Return the color to use for particular type of movement.
"""
# default movement color is gray
color = [0.6, 0.6, 0.6, 0.6]
"""
extruder_on = (move.flags & Movement.FLAG_EXTRUDER_ON or
move.delta_e > 0)
outer_perimeter = (move.flags & Movement.FLAG_PERIMETER and
move.flags & Movement.FLAG_PERIMETER_OUTER)
if extruder_on and outer_perimeter:
color = [0.0, 0.875, 0.875, 0.6] # cyan
elif extruder_on and move.flags & Movement.FLAG_PERIMETER:
color = [0.0, 1.0, 0.0, 0.6] # green
elif extruder_on and move.flags & Movement.FLAG_LOOP:
color = [1.0, 0.875, 0.0, 0.6] # yellow
elif extruder_on:
color = [1.0, 0.0, 0.0, 0.6] # red
"""
if move.extruding:
color = [1.0, 0.0, 0.0, 0.6] # red
if move.current_tool == 0:
return self.color_tool0
else:
return self.color_tool1
return color
return self.color_travel
# ------------------------------------------------------------------------
# DRAWING
......
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