Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLipu Fei <lipu.fei815@gmail.com>2019-08-27 14:38:42 +0300
committerLipu Fei <lipu.fei815@gmail.com>2019-08-27 15:42:31 +0300
commit946b2b943e53e6fb5027f1b1c78bbb8c3ab08692 (patch)
treeca05d54cf4cfb1934d34bfbdfcc2d7efd48d8927 /plugins/GCodeReader
parent867a881de91deb017fb05518113ed975c0246397 (diff)
F5 reloads gcode file
CURA-6643
Diffstat (limited to 'plugins/GCodeReader')
-rw-r--r--plugins/GCodeReader/FlavorParser.py3
-rwxr-xr-xplugins/GCodeReader/GCodeReader.py12
2 files changed, 10 insertions, 5 deletions
diff --git a/plugins/GCodeReader/FlavorParser.py b/plugins/GCodeReader/FlavorParser.py
index 12bed210d2..fb97525da9 100644
--- a/plugins/GCodeReader/FlavorParser.py
+++ b/plugins/GCodeReader/FlavorParser.py
@@ -292,7 +292,7 @@ class FlavorParser:
extruder.getProperty("machine_nozzle_offset_y", "value")]
return result
- def processGCodeStream(self, stream: str) -> Optional[CuraSceneNode]:
+ def processGCodeStream(self, stream: str, filename: str) -> Optional[CuraSceneNode]:
Logger.log("d", "Preparing to load GCode")
self._cancelled = False
# We obtain the filament diameter from the selected extruder to calculate line widths
@@ -453,6 +453,7 @@ class FlavorParser:
scene_node.addDecorator(decorator)
gcode_list_decorator = GCodeListDecorator()
+ gcode_list_decorator.setGcodeFileName(filename)
gcode_list_decorator.setGCodeList(gcode_list)
scene_node.addDecorator(gcode_list_decorator)
diff --git a/plugins/GCodeReader/GCodeReader.py b/plugins/GCodeReader/GCodeReader.py
index b9e948dfea..e0d31c340e 100755
--- a/plugins/GCodeReader/GCodeReader.py
+++ b/plugins/GCodeReader/GCodeReader.py
@@ -2,12 +2,16 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
+from typing import Optional
+
from UM.FileHandler.FileReader import FileReader
from UM.Mesh.MeshReader import MeshReader
from UM.i18n import i18nCatalog
from UM.Application import Application
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
+from cura.Scene.CuraSceneNode import CuraSceneNode
+
catalog = i18nCatalog("cura")
from . import MarlinFlavorParser, RepRapFlavorParser
@@ -54,10 +58,10 @@ class GCodeReader(MeshReader):
file_data = file.read()
return self.preReadFromStream(file_data, args, kwargs)
- def readFromStream(self, stream):
- return self._flavor_reader.processGCodeStream(stream)
+ def readFromStream(self, stream: str, filename: str) -> Optional["CuraSceneNode"]:
+ return self._flavor_reader.processGCodeStream(stream, filename)
- def _read(self, file_name):
+ def _read(self, file_name: str) -> Optional["CuraSceneNode"]:
with open(file_name, "r", encoding = "utf-8") as file:
file_data = file.read()
- return self.readFromStream(file_data)
+ return self.readFromStream(file_data, file_name)