Browse Source

Merge branch 'master' into CURA-6665_api_decorator

Nino van Hooff 5 years ago
parent
commit
dd9e6e4abe

+ 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.3.0"
+DEFAULT_CURA_SDK_VERSION = "7.0.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.3.0"
+CuraSDKVersion = "7.0.0"

+ 1 - 13
cura/Machines/ContainerNode.py

@@ -7,7 +7,7 @@ from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
 from UM.Settings.ContainerRegistry import ContainerRegistry
 from UM.Logger import Logger
 from UM.Settings.InstanceContainer import InstanceContainer
-from UM.Decorators import deprecated
+
 
 ##  A node in the container tree. It represents one container.
 #
@@ -43,18 +43,6 @@ class ContainerNode:
             return default
         return container_metadata[0].get(entry, default)
 
-    ##  Get the child with the specified container ID.
-    #   \param child_id The container ID to get from among the children.
-    #   \return The child node, or ``None`` if no child is present with the
-    #   specified ID.
-    @deprecated("Iterate over the children instead of requesting them one by one.", "4.3")
-    def getChildNode(self, child_id: str) -> Optional["ContainerNode"]:
-        return self.children_map.get(child_id)
-
-    @deprecated("Use `.container` instead.", "4.3")
-    def getContainer(self) -> Optional[InstanceContainer]:
-        return self.container
-
     ##  The container that this node's container ID refers to.
     #
     #   This can be used to finally instantiate the container in order to put it

+ 0 - 5
cura/PrinterOutput/PrinterOutputDevice.py

@@ -10,7 +10,6 @@ from UM.Logger import Logger
 from UM.Signal import signalemitter
 from UM.Qt.QtApplication import QtApplication
 from UM.FlameProfiler import pyqtSlot
-from UM.Decorators import deprecated
 from UM.i18n import i18nCatalog
 from UM.OutputDevice.OutputDevice import OutputDevice
 
@@ -203,10 +202,6 @@ class PrinterOutputDevice(QObject, OutputDevice):
     def acceptsCommands(self) -> bool:
         return self._accepts_commands
 
-    @deprecated("Please use the protected function instead", "3.2")
-    def setAcceptsCommands(self, accepts_commands: bool) -> None:
-        self._setAcceptsCommands(accepts_commands)
-
     ##  Set a flag to signal the UI that the printer is not (yet) ready to receive commands
     def _setAcceptsCommands(self, accepts_commands: bool) -> None:
         if self._accepts_commands != accepts_commands:

+ 0 - 11
cura/Settings/ExtruderManager.py

@@ -91,17 +91,6 @@ class ExtruderManager(QObject):
     def activeExtruderIndex(self) -> int:
         return self._active_extruder_index
 
-    ##  Gets the extruder name of an extruder of the currently active machine.
-    #
-    #   \param index The index of the extruder whose name to get.
-    @pyqtSlot(int, result = str)
-    @deprecated("Use Cura.MachineManager.activeMachine.extruders[index].name instead", "4.3")
-    def getExtruderName(self, index: int) -> str:
-        try:
-            return self.getActiveExtruderStacks()[index].getName()
-        except IndexError:
-            return ""
-
     ## Emitted whenever the selectedObjectExtruders property changes.
     selectedObjectExtrudersChanged = pyqtSignal()
 

+ 4 - 0
cura/Settings/ExtruderStack.py

@@ -51,6 +51,10 @@ class ExtruderStack(CuraContainerStack):
     def getNextStack(self) -> Optional["GlobalStack"]:
         return super().getNextStack()
 
+    @pyqtProperty(int, constant = True)
+    def position(self) -> int:
+        return int(self.getMetaDataEntry("position"))
+
     def setEnabled(self, enabled: bool) -> None:
         if self.getMetaDataEntry("enabled", True) == enabled: # No change.
             return # Don't emit a signal then.

+ 19 - 5
cura/Settings/GlobalStack.py

@@ -20,6 +20,7 @@ from UM.Platform import Platform
 from UM.Util import parseBool
 
 import cura.CuraApplication
+from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
 
 from . import Exceptions
 from .CuraContainerStack import CuraContainerStack
@@ -108,6 +109,19 @@ class GlobalStack(CuraContainerStack):
                     pass
         return result
 
+    # Returns a boolean indicating if this machine has a remote connection. A machine is considered as remotely
+    # connected if its connection types contain one of the following values:
+    #   - ConnectionType.NetworkConnection
+    #   - ConnectionType.CloudConnection
+    @pyqtProperty(bool, notify = configuredConnectionTypesChanged)
+    def hasRemoteConnection(self) -> bool:
+        has_remote_connection = False
+
+        for connection_type in self.configuredConnectionTypes:
+            has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value,
+                                                         ConnectionType.CloudConnection.value]
+        return has_remote_connection
+
     ##  \sa configuredConnectionTypes
     def addConfiguredConnectionType(self, connection_type: int) -> None:
         configured_connection_types = self.configuredConnectionTypes
@@ -273,15 +287,15 @@ class GlobalStack(CuraContainerStack):
     def getHeadAndFansCoordinates(self):
         return self.getProperty("machine_head_with_fans_polygon", "value")
 
-    @pyqtProperty(int, constant=True)
-    def hasMaterials(self):
+    @pyqtProperty(bool, constant = True)
+    def hasMaterials(self) -> bool:
         return parseBool(self.getMetaDataEntry("has_materials", False))
 
-    @pyqtProperty(int, constant=True)
-    def hasVariants(self):
+    @pyqtProperty(bool, constant = True)
+    def hasVariants(self) -> bool:
         return parseBool(self.getMetaDataEntry("has_variants", False))
 
-    @pyqtProperty(int, constant=True)
+    @pyqtProperty(bool, constant = True)
     def hasVariantBuildplates(self) -> bool:
         return parseBool(self.getMetaDataEntry("has_variant_buildplates", False))
 

+ 6 - 143
cura/Settings/MachineManager.py

@@ -447,27 +447,6 @@ class MachineManager(QObject):
     def stacksHaveErrors(self) -> bool:
         return bool(self._stacks_have_errors)
 
-    @pyqtProperty(str, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.definition.name instead", "4.1")
-    def activeMachineDefinitionName(self) -> str:
-        if self._global_container_stack:
-            return self._global_container_stack.definition.getName()
-        return ""
-
-    @pyqtProperty(str, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.name instead", "4.1")
-    def activeMachineName(self) -> str:
-        if self._global_container_stack:
-            return self._global_container_stack.getMetaDataEntry("group_name", self._global_container_stack.getName())
-        return ""
-
-    @pyqtProperty(str, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.id instead", "4.1")
-    def activeMachineId(self) -> str:
-        if self._global_container_stack:
-            return self._global_container_stack.getId()
-        return ""
-
     @pyqtProperty(str, notify = globalContainerChanged)
     def activeMachineFirmwareVersion(self) -> str:
         if not self._printer_output_devices:
@@ -484,25 +463,6 @@ class MachineManager(QObject):
     def printerConnected(self) -> bool:
         return bool(self._printer_output_devices)
 
-    @pyqtProperty(bool, notify = printerConnectedStatusChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.configuredConnectionTypes instead", "4.2")
-    def activeMachineHasRemoteConnection(self) -> bool:
-        if self._global_container_stack:
-            has_remote_connection = False
-
-            for connection_type in self._global_container_stack.configuredConnectionTypes:
-                has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value,
-                                                             ConnectionType.CloudConnection.value]
-            return has_remote_connection
-        return False
-
-    @pyqtProperty("QVariantList", notify=globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.configuredConnectionTypes instead", "4.1")
-    def activeMachineConfiguredConnectionTypes(self):
-        if self._global_container_stack:
-            return self._global_container_stack.configuredConnectionTypes
-        return []
-
     @pyqtProperty(bool, notify = printerConnectedStatusChanged)
     def activeMachineIsGroup(self) -> bool:
         return bool(self._printer_output_devices) and len(self._printer_output_devices[0].printers) > 1
@@ -554,24 +514,6 @@ class MachineManager(QObject):
                 return material.getId()
         return ""
 
-    ##  Gets a dict with the active materials ids set in all extruder stacks and the global stack
-    #   (when there is one extruder, the material is set in the global stack)
-    #
-    #   \return The material ids in all stacks
-    @pyqtProperty("QVariantMap", notify = activeMaterialChanged)
-    @deprecated("use Cura.MachineManager.activeStack.extruders instead.", "4.3")
-    def allActiveMaterialIds(self) -> Dict[str, str]:
-        result = {}
-
-        active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
-        for stack in active_stacks:
-            material_container = stack.material
-            if not material_container:
-                continue
-            result[stack.getId()] = material_container.getId()
-
-        return result
-
     ##  Gets the layer height of the currently active quality profile.
     #
     #   This is indicated together with the name of the active quality profile.
@@ -693,44 +635,6 @@ class MachineManager(QObject):
                     # Check if the value has to be replaced
                     extruder_stack.userChanges.setProperty(key, "value", new_value)
 
-    @pyqtProperty(str, notify = activeVariantChanged)
-    @deprecated("use Cura.MachineManager.activeStack.variant.name instead", "4.1")
-    def activeVariantName(self) -> str:
-        if self._active_container_stack:
-            variant = self._active_container_stack.variant
-            if variant:
-                return variant.getName()
-
-        return ""
-
-    @pyqtProperty(str, notify = activeVariantChanged)
-    @deprecated("use Cura.MachineManager.activeStack.variant.id instead", "4.1")
-    def activeVariantId(self) -> str:
-        if self._active_container_stack:
-            variant = self._active_container_stack.variant
-            if variant:
-                return variant.getId()
-
-        return ""
-
-    @pyqtProperty(str, notify = activeVariantChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.variant.name instead", "4.1")
-    def activeVariantBuildplateName(self) -> str:
-        if self._global_container_stack:
-            variant = self._global_container_stack.variant
-            if variant:
-                return variant.getName()
-
-        return ""
-
-    @pyqtProperty(str, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.definition.id instead", "4.1")
-    def activeDefinitionId(self) -> str:
-        if self._global_container_stack:
-            return self._global_container_stack.definition.id
-
-        return ""
-
     ##  Get the Definition ID to use to select quality profiles for the currently active machine
     #   \returns DefinitionID (string) if found, empty string otherwise
     @pyqtProperty(str, notify = globalContainerChanged)
@@ -788,27 +692,6 @@ class MachineManager(QObject):
                 # This reuses the method and remove all printers recursively
                 self.removeMachine(hidden_containers[0].getId())
 
-    @pyqtProperty(bool, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.hasMaterials instead", "4.2")
-    def hasMaterials(self) -> bool:
-        if self._global_container_stack:
-            return self._global_container_stack.hasMaterials
-        return False
-
-    @pyqtProperty(bool, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.hasVariants instead", "4.2")
-    def hasVariants(self) -> bool:
-        if self._global_container_stack:
-            return self._global_container_stack.hasVariants
-        return False
-
-    @pyqtProperty(bool, notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.hasVariantBuildplates instead", "4.2")
-    def hasVariantBuildplates(self) -> bool:
-        if self._global_container_stack:
-            return self._global_container_stack.hasVariantBuildplates
-        return False
-
     ##  The selected buildplate is compatible if it is compatible with all the materials in all the extruders
     @pyqtProperty(bool, notify = activeMaterialChanged)
     def variantBuildplateCompatible(self) -> bool:
@@ -823,7 +706,8 @@ class MachineManager(QObject):
             if material_container == empty_material_container:
                 continue
             if material_container.getMetaDataEntry("buildplate_compatible"):
-                buildplate_compatible = buildplate_compatible and material_container.getMetaDataEntry("buildplate_compatible")[self.activeVariantBuildplateName]
+                active_buildplate_name = self.activeMachine.variant.name
+                buildplate_compatible = buildplate_compatible and material_container.getMetaDataEntry("buildplate_compatible")[active_buildplate_name]
 
         return buildplate_compatible
 
@@ -946,7 +830,7 @@ class MachineManager(QObject):
             if settable_per_extruder:
                 limit_to_extruder = int(self._global_container_stack.getProperty(setting_key, "limit_to_extruder"))
                 extruder_position = max(0, limit_to_extruder)
-                extruder_stack = self.getExtruder(extruder_position)
+                extruder_stack = self._global_container_stack.extruderList[extruder_position]
                 if extruder_stack:
                     extruder_stack.userChanges.setProperty(setting_key, "value", global_user_container.getProperty(setting_key, "value"))
                 else:
@@ -957,20 +841,6 @@ class MachineManager(QObject):
         self._application.globalContainerStackChanged.emit()
         self.forceUpdateAllSettings()
 
-    @pyqtSlot(int, result = QObject)
-    def getExtruder(self, position: int) -> Optional[ExtruderStack]:
-        return self._getExtruder(position)
-
-    # This is a workaround for the deprecated decorator and the pyqtSlot not playing well together.
-    @deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
-    def _getExtruder(self, position) -> Optional[ExtruderStack]:
-        if self._global_container_stack:
-            try:
-                return self._global_container_stack.extruderList[int(position)]
-            except IndexError:
-                return None
-        return None
-
     def updateDefaultExtruder(self) -> None:
         if self._global_container_stack is None:
             return
@@ -1021,10 +891,10 @@ class MachineManager(QObject):
 
     @pyqtSlot(int, bool)
     def setExtruderEnabled(self, position: int, enabled: bool) -> None:
-        extruder = self.getExtruder(position)
-        if not extruder or self._global_container_stack is None:
+        if self._global_container_stack is None:
             Logger.log("w", "Could not find extruder on position %s", position)
             return
+        extruder = self._global_container_stack.extruderList[position]
 
         extruder.setEnabled(enabled)
         self.updateDefaultExtruder()
@@ -1078,13 +948,6 @@ class MachineManager(QObject):
             container = extruder.userChanges
             container.removeInstance(setting_name)
 
-    @pyqtProperty("QVariantList", notify = globalContainerChanged)
-    @deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
-    def currentExtruderPositions(self) -> List[str]:
-        if self._global_container_stack is None:
-            return []
-        return sorted(list(self._global_container_stack.extruders.keys()))
-
     ##  Update _current_root_material_id when the current root material was changed.
     def _onRootMaterialChanged(self) -> None:
         self._current_root_material_id = {}
@@ -1363,7 +1226,7 @@ class MachineManager(QObject):
     @pyqtSlot(str)
     def switchPrinterType(self, machine_name: str) -> None:
         # Don't switch if the user tries to change to the same type of printer
-        if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name:
+        if self._global_container_stack is None or self._global_container_stack.definition.name == machine_name:
             return
         Logger.log("i", "Attempting to switch the printer type to [%s]", machine_name)
         # Get the definition id corresponding to this machine name

+ 1 - 1
plugins/3MFReader/plugin.json

@@ -3,6 +3,6 @@
     "author": "Ultimaker B.V.",
     "version": "1.0.1",
     "description": "Provides support for reading 3MF files.",
-    "api": "6.0",
+    "api": "7.0",
     "i18n-catalog": "cura"
 }

+ 1 - 1
plugins/3MFWriter/plugin.json

@@ -3,6 +3,6 @@
     "author": "Ultimaker B.V.",
     "version": "1.0.1",
     "description": "Provides support for writing 3MF files.",
-    "api": "6.0",
+    "api": "7.0",
     "i18n-catalog": "cura"
 }

+ 1 - 1
plugins/AMFReader/plugin.json

@@ -3,5 +3,5 @@
     "author": "fieldOfView",
     "version": "1.0.0",
     "description": "Provides support for reading AMF files.",
-    "api": "6.0.0"
+    "api": "7.0.0"
 }

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