Browse Source

Merge branch 'master' into layer_view_statistic_limits_only_visible

Ghostkeeper 3 years ago
parent
commit
cd551555ef

+ 1 - 1
.github/ISSUE_TEMPLATE/featurerequest.yaml

@@ -28,7 +28,7 @@ body:
 - type: textarea
   attributes:
     label: Describe alternatives you've considered
-    description: A clear and concise description of any alternative solutions or features you've considered. Again, if possible, think about why these alternatives are not working out.
+    description: A clear and concise description of any alternative solutions or features you've considered. If possible, think about why these alternatives are not working out.
     placeholder: The alternatives I've considered are...
   validations:
     required: true

+ 6 - 4
cura/API/Account.py

@@ -58,6 +58,11 @@ class Account(QObject):
     manualSyncEnabledChanged = pyqtSignal(bool)
     updatePackagesEnabledChanged = pyqtSignal(bool)
 
+    CLIENT_SCOPES = "account.user.read drive.backup.read drive.backup.write packages.download " \
+                    "packages.rating.read packages.rating.write connect.cluster.read connect.cluster.write " \
+                    "library.project.read library.project.write cura.printjob.read cura.printjob.write " \
+                    "cura.mesh.read cura.mesh.write"
+
     def __init__(self, application: "CuraApplication", parent = None) -> None:
         super().__init__(parent)
         self._application = application
@@ -79,10 +84,7 @@ class Account(QObject):
             CALLBACK_PORT=self._callback_port,
             CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port),
             CLIENT_ID="um----------------------------ultimaker_cura",
-            CLIENT_SCOPES="account.user.read drive.backup.read drive.backup.write packages.download "
-                          "packages.rating.read packages.rating.write connect.cluster.read connect.cluster.write "
-                          "library.project.read library.project.write cura.printjob.read cura.printjob.write "
-                          "cura.mesh.read cura.mesh.write",
+            CLIENT_SCOPES=self.CLIENT_SCOPES,
             AUTH_DATA_PREFERENCE_KEY="general/ultimaker_auth_data",
             AUTH_SUCCESS_REDIRECT="{}/app/auth-success".format(self._oauth_root),
             AUTH_FAILED_REDIRECT="{}/app/auth-error".format(self._oauth_root)

+ 1 - 1
cura/ApplicationMetadata.py

@@ -13,7 +13,7 @@ DEFAULT_CURA_DEBUG_MODE = False
 # 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 = "7.4.0"
+CuraSDKVersion = "7.5.0"
 
 try:
     from cura.CuraVersion import CuraAppName  # type: ignore

+ 2 - 2
cura/Arranging/Nest2DArrange.py

@@ -75,7 +75,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV
         # Clip the disallowed areas so that they don't overlap the bounding box (The arranger chokes otherwise)
         clipped_area = area.intersectionConvexHulls(build_plate_polygon)
 
-        if clipped_area.getPoints() is not None:  # numpy array has to be explicitly checked against None
+        if clipped_area.getPoints() is not None and len(clipped_area.getPoints()) > 2:  # numpy array has to be explicitly checked against None
             for point in clipped_area.getPoints():
                 converted_points.append(Point(int(point[0] * factor), int(point[1] * factor)))
 
@@ -88,7 +88,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV
         converted_points = []
         hull_polygon = node.callDecoration("getConvexHull")
 
-        if hull_polygon is not None and hull_polygon.getPoints() is not None:  # numpy array has to be explicitly checked against None
+        if hull_polygon is not None and hull_polygon.getPoints() is not None and len(hull_polygon.getPoints()) > 2:  # numpy array has to be explicitly checked against None
             for point in hull_polygon.getPoints():
                 converted_points.append(Point(point[0] * factor, point[1] * factor))
             item = Item(converted_points)

+ 6 - 6
cura/Arranging/ShapeArray.py

@@ -3,7 +3,7 @@
 
 import numpy
 import copy
-from typing import Optional, Tuple, TYPE_CHECKING
+from typing import Optional, Tuple, TYPE_CHECKING, Union
 
 from UM.Math.Polygon import Polygon
 
@@ -14,14 +14,14 @@ if TYPE_CHECKING:
 class ShapeArray:
     """Polygon representation as an array for use with :py:class:`cura.Arranging.Arrange.Arrange`"""
 
-    def __init__(self, arr: numpy.array, offset_x: float, offset_y: float, scale: float = 1) -> None:
+    def __init__(self, arr: numpy.ndarray, offset_x: float, offset_y: float, scale: float = 1) -> None:
         self.arr = arr
         self.offset_x = offset_x
         self.offset_y = offset_y
         self.scale = scale
 
     @classmethod
-    def fromPolygon(cls, vertices: numpy.array, scale: float = 1) -> "ShapeArray":
+    def fromPolygon(cls, vertices: numpy.ndarray, scale: float = 1) -> "ShapeArray":
         """Instantiate from a bunch of vertices
 
         :param vertices:
@@ -98,7 +98,7 @@ class ShapeArray:
         return offset_shape_arr, hull_shape_arr
 
     @classmethod
-    def arrayFromPolygon(cls, shape: Tuple[int, int], vertices: numpy.array) -> numpy.array:
+    def arrayFromPolygon(cls, shape: Union[Tuple[int, int], numpy.ndarray], vertices: numpy.ndarray) -> numpy.ndarray:
         """Create :py:class:`numpy.ndarray` with dimensions defined by shape
 
         Fills polygon defined by vertices with ones, all other values zero
@@ -110,7 +110,7 @@ class ShapeArray:
         :return: numpy array with dimensions defined by shape
         """
 
-        base_array = numpy.zeros(shape, dtype = numpy.int32)  # Initialize your array of zeros
+        base_array = numpy.zeros(shape, dtype = numpy.int32)  # type: ignore # Initialize your array of zeros
 
         fill = numpy.ones(base_array.shape) * True  # Initialize boolean array defining shape fill
 
@@ -126,7 +126,7 @@ class ShapeArray:
         return base_array
 
     @classmethod
-    def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> Optional[numpy.array]:
+    def _check(cls, p1: numpy.ndarray, p2: numpy.ndarray, base_array: numpy.ndarray) -> Optional[numpy.ndarray]:
         """Return indices that mark one side of the line, used by arrayFromPolygon
 
         Uses the line defined by p1 and p2 to check array of

+ 10 - 9
cura/CuraApplication.py

@@ -458,15 +458,16 @@ class CuraApplication(QtApplication):
 
         self._version_upgrade_manager.setCurrentVersions(
             {
-                ("quality", InstanceContainer.Version * 1000000 + self.SettingVersion):             (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
-                ("quality_changes", InstanceContainer.Version * 1000000 + self.SettingVersion):     (self.ResourceTypes.QualityChangesInstanceContainer, "application/x-uranium-instancecontainer"),
-                ("intent", InstanceContainer.Version * 1000000 + self.SettingVersion):              (self.ResourceTypes.IntentInstanceContainer, "application/x-uranium-instancecontainer"),
-                ("machine_stack", GlobalStack.Version * 1000000 + self.SettingVersion):             (self.ResourceTypes.MachineStack, "application/x-cura-globalstack"),
-                ("extruder_train", ExtruderStack.Version * 1000000 + self.SettingVersion):          (self.ResourceTypes.ExtruderStack, "application/x-cura-extruderstack"),
-                ("preferences", Preferences.Version * 1000000 + self.SettingVersion):               (Resources.Preferences, "application/x-uranium-preferences"),
-                ("user", InstanceContainer.Version * 1000000 + self.SettingVersion):                (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer"),
-                ("definition_changes", InstanceContainer.Version * 1000000 + self.SettingVersion):  (self.ResourceTypes.DefinitionChangesContainer, "application/x-uranium-instancecontainer"),
-                ("variant", InstanceContainer.Version * 1000000 + self.SettingVersion):             (self.ResourceTypes.VariantInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("quality", InstanceContainer.Version * 1000000 + self.SettingVersion):                         (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("quality_changes", InstanceContainer.Version * 1000000 + self.SettingVersion):                 (self.ResourceTypes.QualityChangesInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("intent", InstanceContainer.Version * 1000000 + self.SettingVersion):                          (self.ResourceTypes.IntentInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("machine_stack", GlobalStack.Version * 1000000 + self.SettingVersion):                         (self.ResourceTypes.MachineStack, "application/x-cura-globalstack"),
+                ("extruder_train", ExtruderStack.Version * 1000000 + self.SettingVersion):                      (self.ResourceTypes.ExtruderStack, "application/x-cura-extruderstack"),
+                ("preferences", Preferences.Version * 1000000 + self.SettingVersion):                           (Resources.Preferences, "application/x-uranium-preferences"),
+                ("user", InstanceContainer.Version * 1000000 + self.SettingVersion):                            (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("definition_changes", InstanceContainer.Version * 1000000 + self.SettingVersion):              (self.ResourceTypes.DefinitionChangesContainer, "application/x-uranium-instancecontainer"),
+                ("variant", InstanceContainer.Version * 1000000 + self.SettingVersion):                         (self.ResourceTypes.VariantInstanceContainer, "application/x-uranium-instancecontainer"),
+                ("setting_visibility", SettingVisibilityPresetsModel.Version * 1000000 + self.SettingVersion):  (self.ResourceTypes.SettingVisibilityPreset, "application/x-uranium-preferences"),
             }
         )
 

+ 4 - 5
cura/LayerPolygon.py

@@ -65,7 +65,7 @@ class LayerPolygon:
 
         # When type is used as index returns true if type == LayerPolygon.InfillType or type == LayerPolygon.SkinType or type == LayerPolygon.SupportInfillType
         # Should be generated in better way, not hardcoded.
-        self._is_infill_or_skin_type_map = numpy.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0], dtype = numpy.bool)
+        self._is_infill_or_skin_type_map = numpy.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0], dtype = bool)
 
         self._build_cache_line_mesh_mask = None  # type: Optional[numpy.ndarray]
         self._build_cache_needed_points = None  # type: Optional[numpy.ndarray]
@@ -73,18 +73,17 @@ class LayerPolygon:
     def buildCache(self) -> None:
         # For the line mesh we do not draw Infill or Jumps. Therefore those lines are filtered out.
         self._build_cache_line_mesh_mask = numpy.ones(self._jump_mask.shape, dtype = bool)
-        mesh_line_count = numpy.sum(self._build_cache_line_mesh_mask)
         self._index_begin = 0
-        self._index_end = mesh_line_count
+        self._index_end = cast(int, numpy.sum(self._build_cache_line_mesh_mask))
 
-        self._build_cache_needed_points = numpy.ones((len(self._types), 2), dtype = numpy.bool)
+        self._build_cache_needed_points = numpy.ones((len(self._types), 2), dtype = bool)
         # Only if the type of line segment changes do we need to add an extra vertex to change colors
         self._build_cache_needed_points[1:, 0][:, numpy.newaxis] = self._types[1:] != self._types[:-1]
         # Mark points as unneeded if they are of types we don't want in the line mesh according to the calculated mask
         numpy.logical_and(self._build_cache_needed_points, self._build_cache_line_mesh_mask, self._build_cache_needed_points )
 
         self._vertex_begin = 0
-        self._vertex_end = numpy.sum( self._build_cache_needed_points )
+        self._vertex_end = cast(int, numpy.sum(self._build_cache_needed_points))
 
     def build(self, vertex_offset: int, index_offset: int, vertices: numpy.ndarray, colors: numpy.ndarray, line_dimensions: numpy.ndarray, feedrates: numpy.ndarray, extruders: numpy.ndarray, line_types: numpy.ndarray, indices: numpy.ndarray) -> None:
         """Set all the arrays provided by the function caller, representing the LayerPolygon

+ 2 - 0
cura/Machines/Models/SettingVisibilityPresetsModel.py

@@ -19,6 +19,8 @@ class SettingVisibilityPresetsModel(QObject):
     onItemsChanged = pyqtSignal()
     activePresetChanged = pyqtSignal()
 
+    Version = 2
+
     def __init__(self, preferences: Preferences, parent = None) -> None:
         super().__init__(parent)
 

+ 12 - 7
cura/OAuth2/KeyringAttribute.py

@@ -1,6 +1,6 @@
 # Copyright (c) 2021 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
-from typing import Type, TYPE_CHECKING
+from typing import Type, TYPE_CHECKING, Optional, List
 
 import keyring
 from keyring.backend import KeyringBackend
@@ -18,18 +18,23 @@ if Platform.isWindows() and hasattr(sys, "frozen"):
     import win32timezone
     from keyring.backends.Windows import WinVaultKeyring
     keyring.set_keyring(WinVaultKeyring())
+if Platform.isOSX() and hasattr(sys, "frozen"):
+    from keyring.backends.macOS import Keyring
+    keyring.set_keyring(Keyring())
 
 # Even if errors happen, we don't want this stored locally:
-DONT_EVER_STORE_LOCALLY = ["refresh_token"]
+DONT_EVER_STORE_LOCALLY: List[str] = ["refresh_token"]
+
 
 class KeyringAttribute:
     """
     Descriptor for attributes that need to be stored in the keyring. With Fallback behaviour to the preference cfg file
     """
-    def __get__(self, instance: Type["BaseModel"], owner: type) -> str:
-        if self._store_secure:
+    def __get__(self, instance: "BaseModel", owner: type) -> Optional[str]:
+        if self._store_secure:  # type: ignore
             try:
-                return keyring.get_password("cura", self._keyring_name)
+                value = keyring.get_password("cura", self._keyring_name)
+                return value if value != "" else None
             except NoKeyringError:
                 self._store_secure = False
                 Logger.logException("w", "No keyring backend present")
@@ -37,11 +42,11 @@ class KeyringAttribute:
         else:
             return getattr(instance, self._name)
 
-    def __set__(self, instance: Type["BaseModel"], value: str):
+    def __set__(self, instance: "BaseModel", value: Optional[str]):
         if self._store_secure:
             setattr(instance, self._name, None)
             try:
-                keyring.set_password("cura", self._keyring_name, value)
+                keyring.set_password("cura", self._keyring_name, value if value is not None else "")
             except PasswordSetError:
                 self._store_secure = False
                 if self._name not in DONT_EVER_STORE_LOCALLY:

+ 2 - 2
cura/Snapshot.py

@@ -25,8 +25,8 @@ class Snapshot:
         pixels = numpy.frombuffer(pixel_array, dtype=numpy.uint8).reshape([height, width, 4])
         # Find indices of non zero pixels
         nonzero_pixels = numpy.nonzero(pixels)
-        min_y, min_x, min_a_ = numpy.amin(nonzero_pixels, axis=1)
-        max_y, max_x, max_a_ = numpy.amax(nonzero_pixels, axis=1)
+        min_y, min_x, min_a_ = numpy.amin(nonzero_pixels, axis=1)  # type: ignore
+        max_y, max_x, max_a_ = numpy.amax(nonzero_pixels, axis=1)  # type: ignore
 
         return min_x, max_x, min_y, max_y
 

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