From 6c6e05bf0608fb6e17541e05cba8d0408fadbcc4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Aug 2018 17:22:04 +0200 Subject: [PATCH 1/5] Don't send JSON file to back-end any more They are no longer using it. The back-end now just takes all settings that come in via setting messages. It doesn't need to set its defaults any more because all settings are set at the beginning. Only when slicing via command line does it need a JSON file. Contributes to issue CURA-4410. --- plugins/CuraEngineBackend/CuraEngineBackend.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 56763a6632..bc0b275bb7 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -178,8 +178,7 @@ class CuraEngineBackend(QObject, Backend): # This is useful for debugging and used to actually start the engine. # \return list of commands and args / parameters. def getEngineCommand(self) -> List[str]: - json_path = Resources.getPath(Resources.DefinitionContainers, "fdmprinter.def.json") - return [self._application.getPreferences().getValue("backend/location"), "connect", "127.0.0.1:{0}".format(self._port), "-j", json_path, ""] + return [self._application.getPreferences().getValue("backend/location"), "connect", "127.0.0.1:{0}".format(self._port), ""] ## Emitted when we get a message containing print duration and material amount. # This also implies the slicing has finished. From 1fbf9c973145c202ecc6773d18e70234ca6af8d4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 29 Aug 2018 17:21:47 +0200 Subject: [PATCH 2/5] Add default value to extruders_enabled_count Otherwise CuraEngine can't parse this setting from the JSON file in command line slicing. Contributes to issue CURA-4410. --- resources/definitions/fdmprinter.def.json | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 3eb7cb1c32..f00fecbaab 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -216,6 +216,7 @@ "label": "Number of Extruders that are enabled", "description": "Number of extruder trains that are enabled; automatically set in software", "value": "machine_extruder_count", + "default_value": 1, "minimum_value": "1", "maximum_value": "16", "type": "int", From 1717281d2b84f2f60d3695c61a8a6d3f18a75165 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 27 Sep 2018 11:20:24 +0200 Subject: [PATCH 3/5] Always provide extruder_nr for all models Even if you only have one extruder in your printer. This is more consistent, and probably also faster because executing one set-addition in Python is probably still slower than sending those 20 extra bytes over the socket and parsing them in C++... Contributes to issue CURA-4410. --- plugins/CuraEngineBackend/StartSliceJob.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index 28e442033b..dd0d9db0a2 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -440,8 +440,7 @@ class StartSliceJob(Job): Job.yieldThread() # Ensure that the engine is aware what the build extruder is. - if stack.getProperty("machine_extruder_count", "value") > 1: - changed_setting_keys.add("extruder_nr") + changed_setting_keys.add("extruder_nr") # Get values for all changed settings for key in changed_setting_keys: From 88ba2ac3451834db5a11169214d410c8aa3f726d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 27 Sep 2018 13:27:42 +0200 Subject: [PATCH 4/5] Define gcode.gz extension in GCodeGzReader So if you were to disable the GCodeGzReader plug-in, you will now no longer see the extension in the files you can read. Fixes #4151. --- plugins/GCodeGzReader/GCodeGzReader.py | 8 ++++++++ plugins/GCodeReader/GCodeReader.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/GCodeGzReader/GCodeGzReader.py b/plugins/GCodeGzReader/GCodeGzReader.py index 73a08075d2..4d33f00870 100644 --- a/plugins/GCodeGzReader/GCodeGzReader.py +++ b/plugins/GCodeGzReader/GCodeGzReader.py @@ -4,8 +4,16 @@ import gzip from UM.Mesh.MeshReader import MeshReader #The class we're extending/implementing. +from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType #To add the .gcode.gz files to the MIME type database. from UM.PluginRegistry import PluginRegistry +MimeTypeDatabase.addMimeType( + MimeType( + name = "application/x-cura-compressed-gcode-file", + comment = "Cura Compressed GCode File", + suffixes = ["gcode.gz"] + ) +) ## A file reader that reads gzipped g-code. # diff --git a/plugins/GCodeReader/GCodeReader.py b/plugins/GCodeReader/GCodeReader.py index 45ef1e1058..498c425f68 100755 --- a/plugins/GCodeReader/GCodeReader.py +++ b/plugins/GCodeReader/GCodeReader.py @@ -1,4 +1,5 @@ # Copyright (c) 2017 Aleph Objects, Inc. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from UM.FileHandler.FileReader import FileReader @@ -15,7 +16,7 @@ MimeTypeDatabase.addMimeType( MimeType( name = "application/x-cura-gcode-file", comment = "Cura GCode File", - suffixes = ["gcode", "gcode.gz"] + suffixes = ["gcode"] ) ) From 0ce9bf61beb1ed6bf72319b42330cd69251b959e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 27 Sep 2018 13:58:06 +0200 Subject: [PATCH 5/5] Move MIME type declarations into constructors of readers So that if you disable the plug-in, the MIME type declaration is also not added. Fixes #4151. --- plugins/GCodeGzReader/GCodeGzReader.py | 15 +++++++-------- plugins/GCodeReader/GCodeReader.py | 16 +++++++++------- plugins/UFPWriter/UFPWriter.py | 11 +++++++++++ plugins/UFPWriter/__init__.py | 10 ---------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/plugins/GCodeGzReader/GCodeGzReader.py b/plugins/GCodeGzReader/GCodeGzReader.py index 4d33f00870..d075e4e3b0 100644 --- a/plugins/GCodeGzReader/GCodeGzReader.py +++ b/plugins/GCodeGzReader/GCodeGzReader.py @@ -7,20 +7,19 @@ from UM.Mesh.MeshReader import MeshReader #The class we're extending/implementin from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType #To add the .gcode.gz files to the MIME type database. from UM.PluginRegistry import PluginRegistry -MimeTypeDatabase.addMimeType( - MimeType( - name = "application/x-cura-compressed-gcode-file", - comment = "Cura Compressed GCode File", - suffixes = ["gcode.gz"] - ) -) - ## A file reader that reads gzipped g-code. # # If you're zipping g-code, you might as well use gzip! class GCodeGzReader(MeshReader): def __init__(self) -> None: super().__init__() + MimeTypeDatabase.addMimeType( + MimeType( + name = "application/x-cura-compressed-gcode-file", + comment = "Cura Compressed GCode File", + suffixes = ["gcode.gz"] + ) + ) self._supported_extensions = [".gcode.gz"] def _read(self, file_name): diff --git a/plugins/GCodeReader/GCodeReader.py b/plugins/GCodeReader/GCodeReader.py index 498c425f68..1bc22a3e62 100755 --- a/plugins/GCodeReader/GCodeReader.py +++ b/plugins/GCodeReader/GCodeReader.py @@ -12,13 +12,7 @@ catalog = i18nCatalog("cura") from . import MarlinFlavorParser, RepRapFlavorParser -MimeTypeDatabase.addMimeType( - MimeType( - name = "application/x-cura-gcode-file", - comment = "Cura GCode File", - suffixes = ["gcode"] - ) -) + # Class for loading and parsing G-code files @@ -30,7 +24,15 @@ class GCodeReader(MeshReader): def __init__(self) -> None: super().__init__() + MimeTypeDatabase.addMimeType( + MimeType( + name = "application/x-cura-gcode-file", + comment = "Cura GCode File", + suffixes = ["gcode"] + ) + ) self._supported_extensions = [".gcode", ".g"] + self._flavor_reader = None Application.getInstance().getPreferences().addPreference("gcodereader/show_caution", True) diff --git a/plugins/UFPWriter/UFPWriter.py b/plugins/UFPWriter/UFPWriter.py index a85ee489cb..d318a0e77d 100644 --- a/plugins/UFPWriter/UFPWriter.py +++ b/plugins/UFPWriter/UFPWriter.py @@ -1,5 +1,6 @@ #Copyright (c) 2018 Ultimaker B.V. #Cura is released under the terms of the LGPLv3 or higher. + from typing import cast from Charon.VirtualFile import VirtualFile #To open UFP files. @@ -9,6 +10,7 @@ from io import StringIO #For converting g-code to bytes. from UM.Application import Application from UM.Logger import Logger from UM.Mesh.MeshWriter import MeshWriter #The writer we need to implement. +from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType from UM.PluginRegistry import PluginRegistry #To get the g-code writer. from PyQt5.QtCore import QBuffer @@ -22,6 +24,15 @@ catalog = i18nCatalog("cura") class UFPWriter(MeshWriter): def __init__(self): super().__init__(add_to_recent_files = False) + + MimeTypeDatabase.addMimeType( + MimeType( + name = "application/x-cura-stl-file", + comment = "Cura UFP File", + suffixes = ["ufp"] + ) + ) + self._snapshot = None Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._createSnapshot) diff --git a/plugins/UFPWriter/__init__.py b/plugins/UFPWriter/__init__.py index a2ec99044f..9db6b042f8 100644 --- a/plugins/UFPWriter/__init__.py +++ b/plugins/UFPWriter/__init__.py @@ -11,16 +11,6 @@ except ImportError: from UM.i18n import i18nCatalog #To translate the file format description. from UM.Mesh.MeshWriter import MeshWriter #For the binary mode flag. -from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType - - -MimeTypeDatabase.addMimeType( - MimeType( - name = "application/x-cura-stl-file", - comment = "Cura UFP File", - suffixes = ["ufp"] - ) -) i18n_catalog = i18nCatalog("cura")