From 329cb909b0afd4662848b1ed8ce961840c3de69e Mon Sep 17 00:00:00 2001 From: daid Date: Thu, 22 Aug 2013 13:56:39 +0200 Subject: [PATCH] Proper fix for #518 by animacide. Update for UltiGCode GCode viewing. --- Cura/gui/sceneView.py | 9 +++++++-- Cura/util/gcodeInterpreter.py | 7 ++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 62a6da2a..5b59e78a 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -885,7 +885,8 @@ void main(void) self._gcodeLoadThread.start() if self._gcode is not None and self._gcode.layerList is not None: glPushMatrix() - glTranslate(-self._machineSize[0] / 2, -self._machineSize[1] / 2, 0) + if profile.getPreference('machine_center_is_zero') != 'True': + glTranslate(-self._machineSize[0] / 2, -self._machineSize[1] / 2, 0) t = time.time() drawUpTill = min(len(self._gcode.layerList), self.layerSelect.getValue() + 1) for n in xrange(0, drawUpTill): @@ -1224,6 +1225,7 @@ void main(void) def _generateGCodeVBOs2(self, layer): filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 filamentArea = math.pi * filamentRadius * filamentRadius + useFilamentArea = profile.getPreference('gcode_flavor') == 'UltiGCode' ret = [] for extrudeType in ['WALL-OUTER:0', 'WALL-OUTER:1', 'WALL-OUTER:2', 'WALL-OUTER:3', 'WALL-INNER', 'FILL', 'SUPPORT', 'SKIRT']: @@ -1245,7 +1247,10 @@ void main(void) normal[:,2] /= lens ePerDist = path['extrusion'][1:] / lens - lineWidth = ePerDist * (filamentArea / path['layerThickness'] / 2) + if useFilamentArea: + lineWidth = ePerDist / path['layerThickness'] / 2.0 + else: + lineWidth = ePerDist * (filamentArea / path['layerThickness'] / 2) normal[:,0] *= lineWidth normal[:,1] *= lineWidth diff --git a/Cura/util/gcodeInterpreter.py b/Cura/util/gcodeInterpreter.py index 15f16279..c13b0bf2 100644 --- a/Cura/util/gcodeInterpreter.py +++ b/Cura/util/gcodeInterpreter.py @@ -63,7 +63,7 @@ class gcode(object): def _load(self, gcodeFile): self.layerList = [] - pos = [0.0, 0.0, 0.0] + pos = [0.0,0.0,0.0] posOffset = [0.0, 0.0, 0.0] currentE = 0.0 totalExtrusion = 0.0 @@ -194,10 +194,7 @@ class gcode(object): x = getCodeFloat(line, 'X') y = getCodeFloat(line, 'Y') z = getCodeFloat(line, 'Z') - if profile.getPreference('machine_center_is_zero') == 'True': - center = [profile.getProfileSettingFloat('machine_width') / 2, profile.getProfileSettingFloat('machine_depth') / 2,0.0] - else: - center = [0.0,0.0,0.0] + center = [0.0,0.0,0.0] if x is None and y is None and z is None: pos = center else: -- 2.30.2