From b39d6c7d8738d08b13b02b269d7d3ec31b11397f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 13 Sep 2018 13:27:21 +0200 Subject: [PATCH 1/9] Package upgrade should also check SDK version --- plugins/Toolbox/src/Toolbox.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 9488b50e4e..9e9fdd6f29 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -488,7 +488,17 @@ class Toolbox(QObject, Extension): local_version = Version(local_package["package_version"]) remote_version = Version(remote_package["package_version"]) - return remote_version > local_version + + can_upgrade = False + if remote_version > local_version: + can_upgrade = True + # A package with the same version can be built to have different SDK versions. So, for a package with the same + # version, we also need to check if the current one has a lower SDK version. If so, this package should also + # be upgradable. + elif remote_version == local_version and local_package.get("sdk_version", 0) < int(self._getSDKVersion()): + can_upgrade = True + + return can_upgrade @pyqtSlot(str, result = bool) def canDowngrade(self, package_id: str) -> bool: From c962b519b192f2a66be79e0ae0cd47c97631a248 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 13 Sep 2018 16:56:14 +0200 Subject: [PATCH 2/9] Clarify PRIME_CLEARANCE global better --- cura/BuildVolume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 10ae8bb87a..4059283a32 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -28,7 +28,7 @@ import copy from typing import List, Optional -# Setting for clearance around the prime +# Radius of disallowed area in mm around prime. I.e. how much distance to keep from prime position. PRIME_CLEARANCE = 6.5 From 8298f76d91314fe3eda865859341c07000b6fb8d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 14 Sep 2018 09:43:24 +0200 Subject: [PATCH 3/9] Add material_diameter into fdmprinter When saving a material to a file, it will save all the settings in that container, which needs to create SettingInstances for all the cached ones, and for those instances, their definitions will be retrieved from the machine definition. material_diameter is one of the settings, but it only exists in the extruder definitions, so when it tries to save a material profile, a lot of warnings/errors will occur due to the missing "material_diameter" in fdmprinter. Adding it back fixes this problem. --- resources/definitions/fdmprinter.def.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 4c87a3bcf0..6833e921da 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -77,6 +77,20 @@ "type": "str", "enabled": false }, + "material_diameter": + { + "label": "Diameter", + "description": "Adjusts the diameter of the filament used. Match this value with the diameter of the used filament.", + "unit": "mm", + "type": "float", + "default_value": 2.85, + "minimum_value": "0.0001", + "minimum_value_warning": "0.4", + "maximum_value_warning": "3.5", + "enabled": "machine_gcode_flavor != \"UltiGCode\"", + "settable_per_mesh": false, + "settable_per_extruder": true + }, "material_bed_temp_wait": { "label": "Wait for Build Plate Heatup", From 572afb052e9a0d38ed874b1282a2f4b14a30bf47 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 14 Sep 2018 11:30:25 +0200 Subject: [PATCH 4/9] Remove unused import This import was actually causing the test to fail on my computer due to a dependency on the order of importing libArcus vs. PyQt. --- .../VersionUpgrade26to27/VersionUpgrade26to27.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py index 2037a0211d..dfa436e5bd 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py @@ -1,11 +1,10 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse the files we need to upgrade and write the new files. import io #To serialise configparser output to a string. from UM.VersionUpgrade import VersionUpgrade -from cura.CuraApplication import CuraApplication # a dict of renamed quality profiles: : _renamed_quality_profiles = { From 2e6401b7dc69436306fc8dc27b1a71d52f6ae81f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 14 Sep 2018 11:36:31 +0200 Subject: [PATCH 5/9] Don't depend on the name of resource folders not changing If we choose to rename the resource folders, then this plug-in should still look in the old resource folders. So hard-code these resource folders in the state that they were in at version 2.5 so that we can freely change them in a modern version. --- .../VersionUpgrade25to26/VersionUpgrade25to26.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py index 54b561c847..2430b35ea0 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse the files we need to upgrade and write the new files. @@ -9,8 +9,6 @@ from urllib.parse import quote_plus from UM.Resources import Resources from UM.VersionUpgrade import VersionUpgrade -from cura.CuraApplication import CuraApplication - _removed_settings = { #Settings that were removed in 2.5. "start_layers_at_same_position", "sub_div_rad_mult" @@ -152,7 +150,7 @@ class VersionUpgrade25to26(VersionUpgrade): ## Acquires the next unique extruder stack index number for the Custom FDM Printer. def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self): - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") file_name_list = os.listdir(extruder_stack_dir) file_name_list = [os.path.basename(file_name) for file_name in file_name_list] while True: @@ -173,7 +171,7 @@ class VersionUpgrade25to26(VersionUpgrade): def _checkCustomFdmPrinterHasExtruderStack(self, machine_id): # go through all extruders and make sure that this custom FDM printer has extruder stacks. - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") has_extruders = False for item in os.listdir(extruder_stack_dir): file_path = os.path.join(extruder_stack_dir, item) @@ -245,9 +243,9 @@ class VersionUpgrade25to26(VersionUpgrade): parser.write(extruder_output) extruder_filename = quote_plus(stack_id) + ".extruder.cfg" - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) - definition_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer) - user_settings_dir = Resources.getPath(CuraApplication.ResourceTypes.UserInstanceContainer) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") + definition_changes_dir = os.path.join(Resources.getDataStoragePath(), "definition_changes") + user_settings_dir = os.path.join(Resources.getDataStoragePath(), "user") with open(os.path.join(definition_changes_dir, definition_changes_filename), "w", encoding = "utf-8") as f: f.write(definition_changes_output.getvalue()) From f8da8c14e5a1fcdcab0b7d4bf2ea2f083b02e961 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 14 Sep 2018 11:38:14 +0200 Subject: [PATCH 6/9] Fix running tests with PyQt 5.11 This was causing the test runner to crash. --- tests/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 77d215815a..ad0bc609ee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,8 @@ import unittest.mock import pytest +import Arcus #Prevents error: "PyCapsule_GetPointer called with incorrect name" with conflicting SIP configurations between Arcus and PyQt: Import Arcus and Savitar first! +import Savitar from UM.Qt.QtApplication import QtApplication #QtApplication import is required, even though it isn't used. from cura.CuraApplication import CuraApplication from cura.MachineActionManager import MachineActionManager From e9cdd47a03b1d30524ed46ebf2254935a3c59fa9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 14 Sep 2018 12:38:16 +0200 Subject: [PATCH 7/9] Fix types of getGlobalContainerStack call results We know in these places that there must be a global stack at this point. So to hide the type error we'll cast it here. Of course, the danger in this is that someone might call this function that doesn't know about this requirement and calls it when there is potentially no global stack yet. Hopefully they'll discover this crash when that happens then. --- cura/Settings/ExtruderManager.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 230759e775..26a030ffde 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -15,12 +15,11 @@ from UM.Settings.SettingFunction import SettingFunction from UM.Settings.ContainerStack import ContainerStack from UM.Settings.PropertyEvaluationContext import PropertyEvaluationContext -from typing import Optional, TYPE_CHECKING, Dict, List, Any +from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING if TYPE_CHECKING: from cura.Settings.ExtruderStack import ExtruderStack from cura.Settings.GlobalStack import GlobalStack - from UM.Scene.SceneNode import SceneNode ## Manages all existing extruder stacks. @@ -377,7 +376,7 @@ class ExtruderManager(QObject): # If no extruder has the value, the list will contain the global value. @staticmethod def getExtruderValues(key: str) -> List[Any]: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) #We know that there must be a global stack by the time you're requesting setting values. result = [] for extruder in ExtruderManager.getInstance().getActiveExtruderStacks(): @@ -412,7 +411,7 @@ class ExtruderManager(QObject): # If no extruder has the value, the list will contain the global value. @staticmethod def getDefaultExtruderValues(key: str) -> List[Any]: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) #We know that there must be a global stack by the time you're requesting setting values. context = PropertyEvaluationContext(global_stack) context.context["evaluate_from_container_index"] = 1 # skip the user settings container context.context["override_operators"] = { @@ -479,7 +478,7 @@ class ExtruderManager(QObject): value = value(extruder) else: # Just a value from global. - value = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().getProperty(key, "value") + value = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()).getProperty(key, "value") return value @@ -508,7 +507,7 @@ class ExtruderManager(QObject): if isinstance(value, SettingFunction): value = value(extruder, context = context) else: # Just a value from global. - value = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().getProperty(key, "value", context = context) + value = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()).getProperty(key, "value", context = context) return value @@ -521,7 +520,7 @@ class ExtruderManager(QObject): # \return The effective value @staticmethod def getResolveOrValue(key: str) -> Any: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) resolved_value = global_stack.getProperty(key, "value") return resolved_value @@ -535,7 +534,7 @@ class ExtruderManager(QObject): # \return The effective value @staticmethod def getDefaultResolveOrValue(key: str) -> Any: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) context = PropertyEvaluationContext(global_stack) context.context["evaluate_from_container_index"] = 1 # skip the user settings container context.context["override_operators"] = { From fb9c21e9149b421440ad8ae77640f68a55b108d7 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 14 Sep 2018 12:41:03 +0200 Subject: [PATCH 8/9] Fix imports --- cura/Settings/ExtruderManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 26a030ffde..ed7f6dd4f8 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -5,6 +5,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant # For comm from UM.FlameProfiler import pyqtSlot import cura.CuraApplication # To get the global container stack to find the current machine. +from cura.Settings.GlobalStack import GlobalStack from UM.Logger import Logger from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.SceneNode import SceneNode @@ -19,7 +20,6 @@ from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING if TYPE_CHECKING: from cura.Settings.ExtruderStack import ExtruderStack - from cura.Settings.GlobalStack import GlobalStack ## Manages all existing extruder stacks. From 5c739219439f8bc8b2865bdfbbbea1df8f56d228 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Fri, 14 Sep 2018 14:35:10 +0200 Subject: [PATCH 9/9] [CURA-5725] Revert "Set simulation path to 0 after updating layer" This reverts commit 3da6e3c4535db85a921bf5770903bd1a729946e1. --- plugins/SimulationView/SimulationView.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/SimulationView/SimulationView.qml b/plugins/SimulationView/SimulationView.qml index 8d671dcb56..b4ca9584c7 100644 --- a/plugins/SimulationView/SimulationView.qml +++ b/plugins/SimulationView/SimulationView.qml @@ -670,7 +670,6 @@ Item onCurrentLayerChanged: { playButton.pauseSimulation() - pathSlider.setHandleValue(0) // After updating the layer set Path slider to 0 layerSlider.setUpperValue(UM.SimulationView.currentLayer) } }