Merge branch 'master' into print_simulation_view

This commit is contained in:
Diego Prado Gesto 2017-11-20 09:29:18 +01:00 committed by GitHub
commit 41d0df5b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 5134 additions and 1003 deletions

View file

@ -57,6 +57,7 @@ class GCodeReader(MeshReader):
self._previous_z = 0
self._layer_data_builder = LayerDataBuilder.LayerDataBuilder()
self._center_is_zero = False
self._is_absolute_positioning = True # It can be absolute (G90) or relative (G91)
@staticmethod
def _getValue(line, code):
@ -165,18 +166,26 @@ class GCodeReader(MeshReader):
return line_width
def _gCode0(self, position, params, path):
x, y, z, f, e = position
x = params.x if params.x is not None else x
y = params.y if params.y is not None else y
z = params.z if params.z is not None else position.z
f = params.f if params.f is not None else position.f
if self._is_absolute_positioning:
x = params.x if params.x is not None else x
y = params.y if params.y is not None else y
z = params.z if params.z is not None else z
else:
x += params.x if params.x is not None else 0
y += params.y if params.y is not None else 0
z += params.z if params.z is not None else 0
f = params.f if params.f is not None else f
if params.e is not None:
if params.e > e[self._extruder_number]:
new_extrusion_value = params.e if self._is_absolute_positioning else e[self._extruder_number] + params.e
if new_extrusion_value > e[self._extruder_number]:
path.append([x, y, z, f, params.e + self._extrusion_length_offset[self._extruder_number], self._layer_type]) # extrusion
else:
path.append([x, y, z, f, params.e + self._extrusion_length_offset[self._extruder_number], LayerPolygon.MoveRetractionType]) # retraction
e[self._extruder_number] = params.e
e[self._extruder_number] = new_extrusion_value
# Only when extruding we can determine the latest known "layer height" which is the difference in height between extrusions
# Also, 1.5 is a heuristic for any priming or whatsoever, we skip those.
@ -199,6 +208,16 @@ class GCodeReader(MeshReader):
position.f,
position.e)
## Set the absolute positioning
def _gCode90(self, position, params, path):
self._is_absolute_positioning = True
return position
## Set the relative positioning
def _gCode91(self, position, params, path):
self._is_absolute_positioning = False
return position
## Reset the current position to the values specified.
# For example: G92 X10 will set the X to 10 without any physical motion.
def _gCode92(self, position, params, path):
@ -234,7 +253,7 @@ class GCodeReader(MeshReader):
f = float(item[1:]) / 60
if item[0] == "E":
e = float(item[1:])
if (x is not None and x < 0) or (y is not None and y < 0):
if self._is_absolute_positioning and ((x is not None and x < 0) or (y is not None and y < 0)):
self._center_is_zero = True
params = self._position(x, y, z, f, e)
return func(position, params, path)