Browse Source

Merge branch 'master' into feature_intent

Conflicts:
	resources/bundled_packages/cura.json -> 4.1 to 4.2 upgrade package added simultaneously
	tests/TestMachineManager.py -> Due to changes in conftest.py
	tests/conftest.py -> Simultaneously expanding the magic mocks to have some correct properties
Ghostkeeper 5 years ago
parent
commit
20201c65e6

+ 3 - 0
.gitignore

@@ -72,3 +72,6 @@ run.sh
 CuraEngine
 
 /.coverage
+
+#Prevents import failures when plugin running tests
+plugins/__init__.py

+ 5 - 1
.gitlab-ci.yml

@@ -3,8 +3,12 @@ image: registry.gitlab.com/ultimaker/cura/cura-build-environment:centos7
 stages:
   - build
 
-build-and-test:
+build and test linux:
   stage: build
+  tags:
+    - cura
+    - docker
+    - linux
   script:
     - docker/build.sh
   artifacts:

+ 1 - 1
CMakeLists.txt

@@ -22,10 +22,10 @@ set(CURA_VERSION "master" CACHE STRING "Version name of Cura")
 set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'")
 set(CURA_CLOUD_API_ROOT "" CACHE STRING "Alternative Cura cloud API root")
 set(CURA_CLOUD_API_VERSION "" CACHE STRING "Alternative Cura cloud API version")
+set(CURA_CLOUD_ACCOUNT_API_ROOT "" CACHE STRING "Alternative Cura cloud account API version")
 
 configure_file(${CMAKE_SOURCE_DIR}/cura.desktop.in ${CMAKE_BINARY_DIR}/cura.desktop @ONLY)
 
-
 configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)
 
 

+ 1 - 1
cmake/CuraTests.cmake

@@ -47,7 +47,7 @@ function(cura_add_test)
     if (NOT ${test_exists})
         add_test(
             NAME ${_NAME}
-            COMMAND ${Python3_EXECUTABLE} -m pytest --verbose --full-trace --capture=no --no-print-log --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
+            COMMAND ${Python3_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
         )
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT LANG=C)
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${_PYTHONPATH}")

+ 2 - 2
cura/ApplicationMetadata.py

@@ -9,7 +9,7 @@ DEFAULT_CURA_DISPLAY_NAME = "Ultimaker Cura"
 DEFAULT_CURA_VERSION = "master"
 DEFAULT_CURA_BUILD_TYPE = ""
 DEFAULT_CURA_DEBUG_MODE = False
-DEFAULT_CURA_SDK_VERSION = "6.1.0"
+DEFAULT_CURA_SDK_VERSION = "6.2.0"
 
 try:
     from cura.CuraVersion import CuraAppName  # type: ignore
@@ -45,4 +45,4 @@ except ImportError:
 # Each release has a fixed SDK version coupled with it. It doesn't make sense to make it configurable because, for
 # example Cura 3.2 with SDK version 6.1 will not work. So the SDK version is hard-coded here and left out of the
 # CuraVersion.py.in template.
-CuraSDKVersion = "6.1.0"
+CuraSDKVersion = "6.2.0"

+ 8 - 5
cura/Arranging/ShapeArray.py

@@ -1,5 +1,5 @@
-#Copyright (c) 2019 Ultimaker B.V.
-#Cura is released under the terms of the LGPLv3 or higher.
+# Copyright (c) 2019 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
 
 import numpy
 import copy
@@ -10,6 +10,7 @@ from UM.Math.Polygon import Polygon
 if TYPE_CHECKING:
     from UM.Scene.SceneNode import SceneNode
 
+
 ##  Polygon representation as an array for use with Arrange
 class ShapeArray:
     def __init__(self, arr: numpy.array, offset_x: float, offset_y: float, scale: float = 1) -> None:
@@ -101,7 +102,9 @@ class ShapeArray:
 
         # Create check array for each edge segment, combine into fill array
         for k in range(vertices.shape[0]):
-            fill = numpy.all([fill, cls._check(vertices[k - 1], vertices[k], base_array)], axis=0)
+            check_array = cls._check(vertices[k - 1], vertices[k], base_array)
+            if check_array is not None:
+                fill = numpy.all([fill, check_array], axis=0)
 
         # Set all values inside polygon to one
         base_array[fill] = 1
@@ -117,9 +120,9 @@ class ShapeArray:
     #   \param p2 2-tuple with x, y for point 2
     #   \param base_array boolean array to project the line on
     @classmethod
-    def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> bool:
+    def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> Optional[numpy.array]:
         if p1[0] == p2[0] and p1[1] == p2[1]:
-            return False
+            return None
         idxs = numpy.indices(base_array.shape)  # Create 3D array of indices
 
         p1 = p1.astype(float)

+ 4 - 4
cura/BuildVolume.py

@@ -64,7 +64,7 @@ class BuildVolume(SceneNode):
 
         self._origin_mesh = None  # type: Optional[MeshData]
         self._origin_line_length = 20
-        self._origin_line_width = 0.5
+        self._origin_line_width = 1.5
 
         self._grid_mesh = None   # type: Optional[MeshData]
         self._grid_shader = None
@@ -258,7 +258,7 @@ class BuildVolume(SceneNode):
                     node.setOutsideBuildArea(True)
                     continue
 
-                if node.collidesWithArea(self.getDisallowedAreas()):
+                if node.collidesWithAreas(self.getDisallowedAreas()):
                     node.setOutsideBuildArea(True)
                     continue
                 # If the entire node is below the build plate, still mark it as outside.
@@ -312,7 +312,7 @@ class BuildVolume(SceneNode):
                 node.setOutsideBuildArea(True)
                 return
 
-            if node.collidesWithArea(self.getDisallowedAreas()):
+            if node.collidesWithAreas(self.getDisallowedAreas()):
                 node.setOutsideBuildArea(True)
                 return
 
@@ -770,7 +770,7 @@ class BuildVolume(SceneNode):
 
         self._has_errors = len(self._error_areas) > 0
 
-        self._disallowed_areas = []  # type: List[Polygon]
+        self._disallowed_areas = []
         for extruder_id in result_areas:
             self._disallowed_areas.extend(result_areas[extruder_id])
         self._disallowed_areas_no_brim = []

+ 2 - 3
cura/CuraActions.py

@@ -3,7 +3,7 @@
 
 from PyQt5.QtCore import QObject, QUrl
 from PyQt5.QtGui import QDesktopServices
-from typing import List, TYPE_CHECKING, cast
+from typing import List, cast
 
 from UM.Event import CallFunctionEvent
 from UM.FlameProfiler import pyqtSlot
@@ -23,9 +23,8 @@ from cura.Settings.ExtruderManager import ExtruderManager
 from cura.Operations.SetBuildPlateNumberOperation import SetBuildPlateNumberOperation
 
 from UM.Logger import Logger
+from UM.Scene.SceneNode import SceneNode
 
-if TYPE_CHECKING:
-    from UM.Scene.SceneNode import SceneNode
 
 class CuraActions(QObject):
     def __init__(self, parent: QObject = None) -> None:

+ 8 - 8
cura/CuraApplication.py

@@ -147,7 +147,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 = 8
+    SettingVersion = 9
 
     Created = False
 
@@ -428,7 +428,7 @@ class CuraApplication(QtApplication):
         # Add empty variant, material and quality containers.
         # Since they are empty, they should never be serialized and instead just programmatically created.
         # We need them to simplify the switching between materials.
-        self.empty_container = cura.Settings.cura_empty_instance_containers.empty_container  # type: EmptyInstanceContainer
+        self.empty_container = cura.Settings.cura_empty_instance_containers.empty_container
 
         self._container_registry.addContainer(
             cura.Settings.cura_empty_instance_containers.empty_definition_changes_container)
@@ -1279,7 +1279,7 @@ class CuraApplication(QtApplication):
     @pyqtSlot()
     def arrangeObjectsToAllBuildPlates(self) -> None:
         nodes_to_arrange = []
-        for node in DepthFirstIterator(self.getController().getScene().getRoot()):  # type: ignore
+        for node in DepthFirstIterator(self.getController().getScene().getRoot()):
             if not isinstance(node, SceneNode):
                 continue
 
@@ -1306,7 +1306,7 @@ class CuraApplication(QtApplication):
     def arrangeAll(self) -> None:
         nodes_to_arrange = []
         active_build_plate = self.getMultiBuildPlateModel().activeBuildPlate
-        for node in DepthFirstIterator(self.getController().getScene().getRoot()):  # type: ignore
+        for node in DepthFirstIterator(self.getController().getScene().getRoot()):
             if not isinstance(node, SceneNode):
                 continue
 
@@ -1344,7 +1344,7 @@ class CuraApplication(QtApplication):
         Logger.log("i", "Reloading all loaded mesh data.")
         nodes = []
         has_merged_nodes = False
-        for node in DepthFirstIterator(self.getController().getScene().getRoot()):  # type: ignore
+        for node in DepthFirstIterator(self.getController().getScene().getRoot()):
             if not isinstance(node, CuraSceneNode) or not node.getMeshData():
                 if node.getName() == "MergedMesh":
                     has_merged_nodes = True
@@ -1356,9 +1356,9 @@ class CuraApplication(QtApplication):
             return
 
         for node in nodes:
-            file_name = node.getMeshData().getFileName()
-            if file_name:
-                job = ReadMeshJob(file_name)
+            mesh_data = node.getMeshData()
+            if mesh_data and mesh_data.getFileName():
+                job = ReadMeshJob(mesh_data.getFileName())
                 job._node = node  # type: ignore
                 job.finished.connect(self._reloadMeshFinished)
                 if has_merged_nodes:

+ 19 - 13
cura/Layer.py

@@ -1,14 +1,20 @@
-from UM.Mesh.MeshBuilder import MeshBuilder
+# Copyright (c) 2019 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
 
+from typing import List
 import numpy
 
+from UM.Mesh.MeshBuilder import MeshBuilder
+from UM.Mesh.MeshData import MeshData
+from cura.LayerPolygon import LayerPolygon
+
 
 class Layer:
-    def __init__(self, layer_id):
+    def __init__(self, layer_id: int) -> None:
         self._id = layer_id
         self._height = 0.0
         self._thickness = 0.0
-        self._polygons = []
+        self._polygons = []  # type: List[LayerPolygon]
         self._element_count = 0
 
     @property
@@ -20,7 +26,7 @@ class Layer:
         return self._thickness
 
     @property
-    def polygons(self):
+    def polygons(self) -> List[LayerPolygon]:
         return self._polygons
 
     @property
@@ -33,14 +39,14 @@ class Layer:
     def setThickness(self, thickness):
         self._thickness = thickness
 
-    def lineMeshVertexCount(self):
+    def lineMeshVertexCount(self) -> int:
         result = 0
         for polygon in self._polygons:
             result += polygon.lineMeshVertexCount()
 
         return result
 
-    def lineMeshElementCount(self):
+    def lineMeshElementCount(self) -> int:
         result = 0
         for polygon in self._polygons:
             result += polygon.lineMeshElementCount()
@@ -57,18 +63,18 @@ class Layer:
             result_index_offset += polygon.lineMeshElementCount()
             self._element_count += polygon.elementCount
 
-        return (result_vertex_offset, result_index_offset)
+        return result_vertex_offset, result_index_offset
 
-    def createMesh(self):
+    def createMesh(self) -> MeshData:
         return self.createMeshOrJumps(True)
 
-    def createJumps(self):
+    def createJumps(self) -> MeshData:
         return self.createMeshOrJumps(False)
 
     # Defines the two triplets of local point indices to use to draw the two faces for each line segment in createMeshOrJump
     __index_pattern = numpy.array([[0, 3, 2, 0, 1, 3]], dtype = numpy.int32 )
 
-    def createMeshOrJumps(self, make_mesh):
+    def createMeshOrJumps(self, make_mesh: bool) -> MeshData:
         builder = MeshBuilder()
         
         line_count = 0
@@ -79,14 +85,14 @@ class Layer:
             for polygon in self._polygons:
                 line_count += polygon.jumpCount
 
-        # Reserve the neccesary space for the data upfront
+        # Reserve the necessary space for the data upfront
         builder.reserveFaceAndVertexCount(2 * line_count, 4 * line_count)
         
         for polygon in self._polygons:
-            # Filter out the types of lines we are not interesed in depending on whether we are drawing the mesh or the jumps.
+            # Filter out the types of lines we are not interested in depending on whether we are drawing the mesh or the jumps.
             index_mask = numpy.logical_not(polygon.jumpMask) if make_mesh else polygon.jumpMask
 
-            # Create an array with rows [p p+1] and only keep those we whant to draw based on make_mesh
+            # Create an array with rows [p p+1] and only keep those we want to draw based on make_mesh
             points = numpy.concatenate((polygon.data[:-1], polygon.data[1:]), 1)[index_mask.ravel()]
             # Line types of the points we want to draw
             line_types = polygon.types[index_mask]

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