From 2d2b8601a02fd0b66c4c57364e07c97b6203973d Mon Sep 17 00:00:00 2001 From: Victor Larchenko Date: Thu, 3 Nov 2016 17:14:15 +0600 Subject: [PATCH] T466: Added progress indicator --- plugins/GCODEReader/GCODEReader.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/GCODEReader/GCODEReader.py b/plugins/GCODEReader/GCODEReader.py index 9346c8cc4f..80d0e45260 100644 --- a/plugins/GCODEReader/GCODEReader.py +++ b/plugins/GCODEReader/GCODEReader.py @@ -9,6 +9,10 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Math.Vector import Vector from UM.Math.AxisAlignedBox import AxisAlignedBox from UM.Application import Application +from UM.Message import Message + +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") from cura import LayerDataBuilder @@ -16,6 +20,7 @@ from cura import LayerDataDecorator from cura import LayerPolygon import numpy +import math class GCODEReader(MeshReader): @@ -92,6 +97,14 @@ class GCODEReader(MeshReader): file = open(file_name, "r") + file_lines = 0 + current_line = 0 + for line in file: + file_lines += 1 + file.seek(0) + + file_step = math.floor(file_lines / 100) + layer_data = LayerDataBuilder.LayerDataBuilder() current_extruder = 1 @@ -102,6 +115,10 @@ class GCODEReader(MeshReader): current_e = 0 current_layer = 0 + message = Message(catalog.i18nc("@info:status", "Parsing GCODE"), lifetime=0, dismissable=False) + message.setProgress(0) + message.show() + def CreatePolygon(): countvalid = False for point in current_path: @@ -142,6 +159,10 @@ class GCODEReader(MeshReader): return True for line in file: + current_line += 1 + if current_line % file_step == 0: + # print(current_line/file_lines*100) + message.setProgress(math.floor(current_line/file_lines*100)) if len(line) == 0: continue if line[0] == ";": @@ -204,6 +225,8 @@ class GCODEReader(MeshReader): decorator.setLayerData(layer_mesh) scene_node.addDecorator(decorator) + message.hide() + Application.getInstance().getPrintInformation()._pre_sliced = True scene_node.parentChanged.connect(self.parent_changed)