Browse Source

Merge branch 'master' into mypy_fixes

Lipu Fei 6 years ago
parent
commit
dc8d9e0f96

+ 1 - 1
cura.appdata.xml

@@ -26,6 +26,6 @@
   <screenshots>
     <screenshot type="default" width="1280" height="720">http://software.ultimaker.com/Cura.png</screenshot>
   </screenshots>
-  <url type="homepage">https://ultimaker.com/en/products/cura-software?utm_source=cura&utm_medium=software&utm_campaign=resources</url>
+  <url type="homepage">https://ultimaker.com/en/products/cura-software?utm_source=cura&amp;utm_medium=software&amp;utm_campaign=resources</url>
   <translation type="gettext">Cura</translation>
 </component>

+ 2 - 1
cura/CuraApplication.py

@@ -123,7 +123,7 @@ class CuraApplication(QtApplication):
     # SettingVersion represents the set of settings available in the machine/extruder definitions.
     # You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
     # changes of the settings.
-    SettingVersion = 4
+    SettingVersion = 5
 
     Created = False
 
@@ -669,6 +669,7 @@ class CuraApplication(QtApplication):
         self._plugins_loaded = True
 
     def run(self):
+        super().run()
         container_registry = self._container_registry
 
         Logger.log("i", "Initializing variant manager")

+ 0 - 7
cura_app.py

@@ -134,11 +134,4 @@ import Arcus #@UnusedImport
 from cura.CuraApplication import CuraApplication
 
 app = CuraApplication()
-app.addCommandLineOptions()
-app.parseCliOptions()
-app.initialize()
-
-app.startSplashWindowPhase()
-app.startPostSplashWindowPhase()
-
 app.run()

+ 23 - 23
plugins/3MFReader/ThreeMFReader.py

@@ -1,6 +1,7 @@
 # Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
+from typing import Optional
 import os.path
 import zipfile
 
@@ -37,8 +38,8 @@ except ImportError:
 
 ##    Base implementation for reading 3MF files. Has no support for textures. Only loads meshes!
 class ThreeMFReader(MeshReader):
-    def __init__(self, application):
-        super().__init__(application)
+    def __init__(self) -> None:
+        super().__init__()
 
         MimeTypeDatabase.addMimeType(
             MimeType(
@@ -168,6 +169,8 @@ class ThreeMFReader(MeshReader):
             archive = zipfile.ZipFile(file_name, "r")
             self._base_name = os.path.basename(file_name)
             parser = Savitar.ThreeMFParser()
+            with open("/tmp/test.xml", "wb") as f:
+                f.write(archive.open("3D/3dmodel.model").read())
             scene_3mf = parser.parse(archive.open("3D/3dmodel.model").read())
             self._unit = scene_3mf.getUnit()
             for node in scene_3mf.getSceneNodes():
@@ -198,9 +201,9 @@ class ThreeMFReader(MeshReader):
                 # Second step: 3MF defines the left corner of the machine as center, whereas cura uses the center of the
                 # build volume.
                 if global_container_stack:
-                    translation_vector = Vector(x=-global_container_stack.getProperty("machine_width", "value") / 2,
-                                                y=-global_container_stack.getProperty("machine_depth", "value") / 2,
-                                                z=0)
+                    translation_vector = Vector(x = -global_container_stack.getProperty("machine_width", "value") / 2,
+                                                y = -global_container_stack.getProperty("machine_depth", "value") / 2,
+                                                z = 0)
                     translation_matrix = Matrix()
                     translation_matrix.setByTranslation(translation_vector)
                     transformation_matrix.multiply(translation_matrix)
@@ -236,23 +239,20 @@ class ThreeMFReader(MeshReader):
     #   * inch
     #   * foot
     #   * meter
-    def _getScaleFromUnit(self, unit):
+    def _getScaleFromUnit(self, unit: Optional[str]) -> Vector:
+        conversion_to_mm = {
+            "micron": 0.001,
+            "millimeter": 1,
+            "centimeter": 10,
+            "meter": 1000,
+            "inch": 25.4,
+            "foot": 304.8
+        }
         if unit is None:
             unit = "millimeter"
-        if unit == "micron":
-            scale = 0.001
-        elif unit == "millimeter":
-            scale = 1
-        elif unit == "centimeter":
-            scale = 10
-        elif unit == "inch":
-            scale = 25.4
-        elif unit == "foot":
-            scale = 304.8
-        elif unit == "meter":
-            scale = 1000
-        else:
-            Logger.log("w", "Unrecognised unit %s used. Assuming mm instead", unit)
-            scale = 1
-
-        return Vector(scale, scale, scale)
+        elif unit not in conversion_to_mm:
+            Logger.log("w", "Unrecognised unit {unit} used. Assuming mm instead.".format(unit = unit))
+            unit = "millimeter"
+
+        scale = conversion_to_mm[unit]
+        return Vector(scale, scale, scale)

+ 2 - 2
plugins/3MFReader/__init__.py

@@ -18,7 +18,7 @@ catalog = i18nCatalog("cura")
 
 
 def getMetaData() -> Dict:
-    # Workarround for osx not supporting double file extensions correctly.
+    # Workaround for osx not supporting double file extensions correctly.
     if Platform.isOSX():
         workspace_extension = "3mf"
     else:
@@ -44,7 +44,7 @@ def getMetaData() -> Dict:
 
 def register(app):
     if "3MFReader.ThreeMFReader" in sys.modules:
-        return {"mesh_reader": ThreeMFReader.ThreeMFReader(app),
+        return {"mesh_reader": ThreeMFReader.ThreeMFReader(),
                 "workspace_reader": ThreeMFWorkspaceReader.ThreeMFWorkspaceReader()}
     else:
         return {}

+ 4 - 5
plugins/CuraEngineBackend/StartSliceJob.py

@@ -219,7 +219,7 @@ class StartSliceJob(Job):
             extruders_enabled = {position: stack.isEnabled for position, stack in CuraApplication.getInstance().getGlobalContainerStack().extruders.items()}
             filtered_object_groups = []
             has_model_with_disabled_extruders = False
-            associated_siabled_extruders = set()
+            associated_disabled_extruders = set()
             for group in object_groups:
                 stack = CuraApplication.getInstance().getGlobalContainerStack()
                 skip_group = False
@@ -228,15 +228,14 @@ class StartSliceJob(Job):
                     if not extruders_enabled[extruder_position]:
                         skip_group = True
                         has_model_with_disabled_extruders = True
-                        associated_siabled_extruders.add(extruder_position)
-                        break
+                        associated_disabled_extruders.add(extruder_position)
                 if not skip_group:
                     filtered_object_groups.append(group)
 
             if has_model_with_disabled_extruders:
                 self.setResult(StartJobResult.ObjectsWithDisabledExtruder)
-                associated_siabled_extruders = {str(c) for c in sorted([int(p) + 1 for p in associated_siabled_extruders])}
-                self.setMessage(", ".join(associated_siabled_extruders))
+                associated_disabled_extruders = [str(c) for c in sorted([int(p) + 1 for p in associated_disabled_extruders])]
+                self.setMessage(", ".join(associated_disabled_extruders))
                 return
 
             # There are cases when there is nothing to slice. This can happen due to one at a time slicing not being

+ 2 - 3
plugins/GCodeGzReader/GCodeGzReader.py

@@ -11,9 +11,8 @@ from UM.PluginRegistry import PluginRegistry
 #
 #   If you're zipping g-code, you might as well use gzip!
 class GCodeGzReader(MeshReader):
-
-    def __init__(self, application):
-        super().__init__(application)
+    def __init__(self) -> None:
+        super().__init__()
         self._supported_extensions = [".gcode.gz"]
 
     def _read(self, file_name):

+ 2 - 1
plugins/GCodeGzReader/__init__.py

@@ -19,6 +19,7 @@ def getMetaData():
         ]
     }
 
+
 def register(app):
     app.addNonSliceableExtension(".gz")
-    return { "mesh_reader": GCodeGzReader.GCodeGzReader(app) }
+    return {"mesh_reader": GCodeGzReader.GCodeGzReader()}

+ 3 - 3
plugins/GCodeReader/GCodeReader.py

@@ -19,16 +19,16 @@ MimeTypeDatabase.addMimeType(
     )
 )
 
+
 # Class for loading and parsing G-code files
 class GCodeReader(MeshReader):
-
     _flavor_default = "Marlin"
     _flavor_keyword = ";FLAVOR:"
     _flavor_readers_dict = {"RepRap" : RepRapFlavorParser.RepRapFlavorParser(),
                             "Marlin" : MarlinFlavorParser.MarlinFlavorParser()}
 
-    def __init__(self, application):
-        super(GCodeReader, self).__init__(application)
+    def __init__(self) -> None:
+        super().__init__()
         self._supported_extensions = [".gcode", ".g"]
         self._flavor_reader = None
 

+ 2 - 1
plugins/GCodeReader/__init__.py

@@ -20,7 +20,8 @@ def getMetaData():
         ]
     }
 
+
 def register(app):
     app.addNonSliceableExtension(".gcode")
     app.addNonSliceableExtension(".g")
-    return { "mesh_reader": GCodeReader.GCodeReader(app) }
+    return {"mesh_reader": GCodeReader.GCodeReader()}

Some files were not shown because too many files changed in this diff