Browse Source

Merge branch 'main' into mingda_printers

HellAholic 6 months ago
parent
commit
d189958410

+ 3 - 3
.github/ISSUE_TEMPLATE/SlicingCrash.yaml

@@ -6,9 +6,9 @@ body:
   attributes:
     value: |      
        ### ✨Try our improved Cura 5.7✨
-       Before filling out the report below, we want you to try the latest Cura 5.7 Beta. 
+       Before filling out the report below, we want you to try the latest Cura 5.7. 
        This version of Cura has become significantly more reliable and has an updated slicing engine that will automatically send a report to the Cura Team for analysis. 
-       #### [You can find the downloads here](https://github.com/Ultimaker/Cura/releases/tag/5.7.0-beta.1) #### 
+       #### [You can find the downloads here](https://github.com/Ultimaker/Cura/releases/latest) #### 
        If you still encounter a crash you are still welcome to report the issue so we can use your model as a test case, you can find instructions on how to do that below.      
        
        ### Project File
@@ -35,7 +35,7 @@ body:
 - type: markdown
   attributes:
     value: |
-      We work hard on improving our slicing crashes. Our most recent release is 5.6.0.
+      We work hard on improving our slicing crashes. Our most recent release is 5.7.1.
       If you are not on the latest version of Cura, [you can download it here](https://github.com/Ultimaker/Cura/releases/latest)
 - type: input
   attributes:

+ 17 - 9
.github/workflows/release-process_release-candidate.yml

@@ -65,6 +65,8 @@ jobs:
     name: Create tags
     runs-on: ubuntu-latest
     needs: [parse-version, find-rc-tag]
+    outputs:
+      main_commit: ${{ steps.export-main-commit.outputs.main_commit }}
     strategy:
       matrix:
         repository: [Cura, Uranium, CuraEngine, cura-binary-data, fdm_materials]
@@ -76,11 +78,23 @@ jobs:
           ref: ${{ needs.parse-version.outputs.branch_name }}
           token: ${{ secrets.CURA_AUTORELEASE_PAT }}
 
-      - name: Create tag
+      - name: Create RC tag
         run: |
           git tag ${{ needs.find-rc-tag.outputs.tag_name }}
           git push origin tag ${{ needs.find-rc-tag.outputs.tag_name }}
 
+      - name: Create or update release tag
+        run: |
+          git tag -f ${{ inputs.cura_version }}
+          git push -f origin tag ${{ inputs.cura_version }}
+
+      - name: Export Cura tagged commit
+        id: export-main-commit
+        if: ${{ matrix.repository == 'Cura' }}
+        run: |
+          echo "main_commit=`git rev-parse HEAD`" >> "$GITHUB_OUTPUT"
+
+
   create-dependencies-packages:
     name: Create conan packages for dependencies
     uses: ultimaker/cura-workflows/.github/workflows/conan-package-release.yml@main
@@ -131,7 +145,7 @@ jobs:
   create-release-draft:
     name: Create the release draft
     runs-on: ubuntu-latest
-    needs: [create-installers, parse-version]
+    needs: [create-installers, parse-version, create-tags]
     steps:
       - name: Checkout Cura repo
         uses: actions/checkout@v4
@@ -141,16 +155,10 @@ jobs:
       - name: Extract changelog
         run: python ./scripts/extract_changelog.py --version ${{ needs.parse-version.outputs.version_major }}.${{ needs.parse-version.outputs.version_minor }}.${{ needs.parse-version.outputs.version_patch }} --changelog ./resources/texts/change_log.txt > formatted_changelog.txt
 
-      - name: Get commit id for release
-        id: get-commit-id
-        uses: iawia002/get-tag-or-commit-id@v1.0.1
-        with:
-          length: 40
-
       - name: Create release
         uses: notpeelz/action-gh-create-release@v5.0.1
         with:
-          target: ${{ steps.get-commit-id.outputs.id }}
+          target: ${{ needs.create-tags.outputs.main_commit }}
           tag: ${{ inputs.cura_version }}
           strategy: replace
           title: UltiMaker Cura ${{ inputs.cura_version }}

+ 2 - 16
conandata.yml

@@ -1,12 +1,11 @@
-version: "5.8.0-alpha.0"
+version: "5.9.0-alpha.0"
 requirements:
   - "cura_resources/(latest)@ultimaker/testing"
   - "uranium/(latest)@ultimaker/testing"
   - "curaengine/(latest)@ultimaker/testing"
   - "cura_binary_data/(latest)@ultimaker/testing"
   - "fdm_materials/(latest)@ultimaker/testing"
-  - "curaengine_plugin_gradual_flow/0.1.1-beta.3"
-  - "dulcificum/latest@ultimaker/testing"
+  - "dulcificum/0.2.1"
   - "pysavitar/5.3.0"
   - "pynest2d/5.3.0"
   - "native_cad_plugin/2.0.0"
@@ -34,14 +33,6 @@ pyinstaller:
             package: "cura"
             src: "plugins"
             dst: "share/cura/plugins"
-        curaengine_gradual_flow_plugin:
-            package: "curaengine_plugin_gradual_flow"
-            src: "res/plugins/CuraEngineGradualFlow"
-            dst: "share/cura/plugins/CuraEngineGradualFlow"
-        curaengine_gradual_flow_plugin_bundled:
-            package: "curaengine_plugin_gradual_flow"
-            src: "res/bundled_packages"
-            dst: "share/cura/resources/bundled_packages"
         native_cad_plugin:
           package: "native_cad_plugin"
           src: "res/plugins/NativeCADplugin"
@@ -105,11 +96,6 @@ pyinstaller:
             src: "bin"
             dst: "."
             binary: "CuraEngine"
-        curaengine_gradual_flow_plugin_service:
-            package: "curaengine_plugin_gradual_flow"
-            src: "bin"
-            dst: "."
-            binary: "curaengine_plugin_gradual_flow"
     hiddenimports:
         - "pySavitar"
         - "pyArcus"

+ 3 - 13
conanfile.py

@@ -390,17 +390,11 @@ class CuraConan(ConanFile):
             copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path = False)
 
             # Copy the external plugins that we want to bundle with Cura
-            rmdir(self,str(self.source_path.joinpath("plugins", "CuraEngineGradualFlow")))
-            curaengine_plugin_gradual_flow = self.dependencies["curaengine_plugin_gradual_flow"].cpp_info
-            copy(self, "*", curaengine_plugin_gradual_flow.resdirs[0], str(self.source_path.joinpath("plugins", "CuraEngineGradualFlow")), keep_path = True)
-            copy(self, "*", curaengine_plugin_gradual_flow.bindirs[0], self.source_folder, keep_path = False)
-            copy(self, "bundled_*.json", curaengine_plugin_gradual_flow.resdirs[1], str(self.source_path.joinpath("resources", "bundled_packages")), keep_path = False)
-
             if self._enterprise:
                 rmdir(self, str(self.source_path.joinpath("plugins", "NativeCADplugin")))
-                curaengine_plugin_gradual_flow = self.dependencies["native_cad_plugin"].cpp_info
-                copy(self, "*", curaengine_plugin_gradual_flow.resdirs[0], str(self.source_path.joinpath("plugins", "NativeCADplugin")), keep_path = True)
-                copy(self, "bundled_*.json", curaengine_plugin_gradual_flow.resdirs[1], str(self.source_path.joinpath("resources", "bundled_packages")), keep_path = False)
+                native_cad_plugin = self.dependencies["native_cad_plugin"].cpp_info
+                copy(self, "*", native_cad_plugin.resdirs[0], str(self.source_path.joinpath("plugins", "NativeCADplugin")), keep_path = True)
+                copy(self, "bundled_*.json", native_cad_plugin.resdirs[1], str(self.source_path.joinpath("resources", "bundled_packages")), keep_path = False)
 
         # Copy resources of cura_binary_data
         cura_binary_data = self.dependencies["cura_binary_data"].cpp_info
@@ -517,10 +511,6 @@ echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
         copy(self, "requirement*.txt", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.resdirs[-1]))
         copy(self, "*", src = os.path.join(self.source_folder, "packaging"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[2]))
 
-        # Remove the CuraEngineGradualFlow plugin from the package
-        rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[1], "CuraEngineGradualFlow"))
-        rm(self, "bundled_*.json", os.path.join(self.package_folder, self.cpp.package.resdirs[0], "bundled_packages"), recursive = False)
-
         # Remove the fdm_materials from the package
         rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials"))
 

+ 61 - 1
cura/API/Interface/Settings.py

@@ -1,7 +1,13 @@
 # Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
-from typing import TYPE_CHECKING
+from dataclasses import asdict
+
+from typing import cast, Dict, TYPE_CHECKING
+
+from UM.Settings.InstanceContainer import InstanceContainer
+from UM.Settings.SettingFunction import SettingFunction
+from cura.Settings.GlobalStack import GlobalStack
 
 if TYPE_CHECKING:
     from cura.CuraApplication import CuraApplication
@@ -47,3 +53,57 @@ class Settings:
         """
 
         return self.application.getSidebarCustomMenuItems()
+
+    def getSliceMetadata(self) -> Dict[str, Dict[str, Dict[str, str]]]:
+        """Get all changed settings and all settings. For each extruder and the global stack"""
+        print_information = self.application.getPrintInformation()
+        machine_manager = self.application.getMachineManager()
+        settings = {
+            "material": {
+                "length": print_information.materialLengths,
+                "weight": print_information.materialWeights,
+                "cost": print_information.materialCosts,
+            },
+            "global": {
+                "changes": {},
+                "all_settings": {},
+            },
+            "quality": asdict(machine_manager.activeQualityDisplayNameMap()),
+        }
+
+        def _retrieveValue(container: InstanceContainer, setting_: str):
+            value_ = container.getProperty(setting_, "value")
+            for _ in range(0, 1024):  # Prevent possibly endless loop by not using a limit.
+                if not isinstance(value_, SettingFunction):
+                    return value_  # Success!
+                value_ = value_(container)
+            return 0  # Fallback value after breaking possibly endless loop.
+
+        global_stack = cast(GlobalStack, self.application.getGlobalContainerStack())
+
+        # Add global user or quality changes
+        global_flattened_changes = InstanceContainer.createMergedInstanceContainer(global_stack.userChanges, global_stack.qualityChanges)
+        for setting in global_flattened_changes.getAllKeys():
+            settings["global"]["changes"][setting] = _retrieveValue(global_flattened_changes, setting)
+
+        # Get global all settings values without user or quality changes
+        for setting in global_stack.getAllKeys():
+            settings["global"]["all_settings"][setting] = _retrieveValue(global_stack, setting)
+
+        for i, extruder in enumerate(global_stack.extruderList):
+            # Add extruder fields to settings dictionary
+            settings[f"extruder_{i}"] = {
+                "changes": {},
+                "all_settings": {},
+            }
+
+            # Add extruder user or quality changes
+            extruder_flattened_changes = InstanceContainer.createMergedInstanceContainer(extruder.userChanges, extruder.qualityChanges)
+            for setting in extruder_flattened_changes.getAllKeys():
+                settings[f"extruder_{i}"]["changes"][setting] = _retrieveValue(extruder_flattened_changes, setting)
+
+            # Get extruder all settings values without user or quality changes
+            for setting in extruder.getAllKeys():
+                settings[f"extruder_{i}"]["all_settings"][setting] = _retrieveValue(extruder, setting)
+
+        return settings

+ 1 - 1
cura/ApplicationMetadata.py

@@ -14,7 +14,7 @@ DEFAULT_CURA_LATEST_URL = "https://software.ultimaker.com/latest.json"
 # 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 = "8.7.0"
+CuraSDKVersion = "8.8.0"
 
 try:
     from cura.CuraVersion import CuraLatestURL

+ 9 - 3
cura/Machines/MachineNode.py

@@ -1,8 +1,9 @@
-# Copyright (c) 2019 Ultimaker B.V.
+# Copyright (c) 2024 UltiMaker
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from typing import Dict, List
 
+from UM.Decorators import deprecated
 from UM.Logger import Logger
 from UM.Signal import Signal
 from UM.Util import parseBool
@@ -168,13 +169,18 @@ class MachineNode(ContainerNode):
 
         return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
 
-    def isExcludedMaterial(self, material: MaterialNode) -> bool:
+    def isExcludedMaterialBaseFile(self, material_base_file: str) -> bool:
         """Returns whether the material should be excluded from the list of materials."""
         for exclude_material in self.exclude_materials:
-            if exclude_material in material["id"]:
+            if exclude_material in material_base_file:
                 return True
         return False
 
+    @deprecated("Use isExcludedMaterialBaseFile instead.", since = "5.9.0")
+    def isExcludedMaterial(self, material: MaterialNode) -> bool:
+        """Returns whether the material should be excluded from the list of materials."""
+        return self.isExcludedMaterialBaseFile(material.base_file)
+
     @UM.FlameProfiler.profile
     def _loadAll(self) -> None:
         """(Re)loads all variants under this printer."""

+ 2 - 2
cura/Machines/VariantNode.py

@@ -60,7 +60,7 @@ class VariantNode(ContainerNode):
             materials = list(materials_per_base_file.values())
 
         # Filter materials based on the exclude_materials property.
-        filtered_materials = [material for material in materials if not self.machine.isExcludedMaterial(material)]
+        filtered_materials = [material for material in materials if not self.machine.isExcludedMaterialBaseFile(material["id"])]
 
         for material in filtered_materials:
             base_file = material["base_file"]
@@ -127,7 +127,7 @@ class VariantNode(ContainerNode):
         material_definition = container.getMetaDataEntry("definition")
 
         base_file = container.getMetaDataEntry("base_file")
-        if base_file in self.machine.exclude_materials:
+        if self.machine.isExcludedMaterialBaseFile(base_file):
             return  # Material is forbidden for this printer.
         if base_file not in self.materials:  # Completely new base file. Always better than not having a file as long as it matches our set-up.
             if material_definition != "fdmprinter" and material_definition != self.machine.container_id:

+ 1 - 1
cura/OAuth2/AuthorizationHelpers.py

@@ -96,7 +96,7 @@ class AuthorizationHelpers:
             return
 
         if token_response.error() != QNetworkReply.NetworkError.NoError:
-            callback(AuthenticationResponse(success = False, err_message = token_data["error_description"]))
+            callback(AuthenticationResponse(success = False, err_message = token_data.get("error_description", "an unknown server error occurred")))
             return
 
         callback(AuthenticationResponse(success = True,

+ 106 - 0
cura/PrinterOutput/FormatMaps.py

@@ -0,0 +1,106 @@
+# Copyright (c) 2024 UltiMaker
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from UM.Resources import Resources
+
+import json
+from typing import Dict, List, Optional
+
+class FormatMaps:
+
+    # A map from the printer-type in their native file-formats to the internal name we use.
+    PRINTER_TYPE_NAME = {
+        "fire_e": "ultimaker_method",
+        "lava_f": "ultimaker_methodx",
+        "magma_10": "ultimaker_methodxl",
+        "sketch": "ultimaker_sketch"
+    }
+
+    # A map from the extruder-name in their native file-formats to the internal name we use.
+    EXTRUDER_NAME_MAP = {
+        "mk14_hot": "1XA",
+        "mk14_hot_s": "2XA",
+        "mk14_c": "1C",
+        "mk14": "1A",
+        "mk14_s": "2A",
+        "mk14_e": "LABS"
+    }
+
+    # A map from the material-name in their native file-formats to some info, including the internal name we use.
+    MATERIAL_MAP = {
+        "abs": {"name": "ABS", "guid": "2780b345-577b-4a24-a2c5-12e6aad3e690"},
+         "abs-cf10": {"name": "ABS-CF", "guid": "495a0ce5-9daf-4a16-b7b2-06856d82394d"},
+         "abs-wss1": {"name": "ABS-R", "guid": "88c8919c-6a09-471a-b7b6-e801263d862d"},
+         "asa": {"name": "ASA", "guid": "f79bc612-21eb-482e-ad6c-87d75bdde066"},
+         "nylon12-cf": {"name": "Nylon 12 CF", "guid": "3c6f2877-71cc-4760-84e6-4b89ab243e3b"},
+         "nylon": {"name": "Nylon", "guid": "283d439a-3490-4481-920c-c51d8cdecf9c"},
+         "pc": {"name": "PC", "guid": "62414577-94d1-490d-b1e4-7ef3ec40db02"},
+         "petg": {"name": "PETG", "guid": "69386c85-5b6c-421a-bec5-aeb1fb33f060"},
+         "pla": {"name": "PLA", "guid": "abb9c58e-1f56-48d1-bd8f-055fde3a5b56"},
+         "pva": {"name": "PVA", "guid": "add51ef2-86eb-4c39-afd5-5586564f0715"},
+         "wss1": {"name": "RapidRinse", "guid": "a140ef8f-4f26-4e73-abe0-cfc29d6d1024"},
+         "sr30": {"name": "SR-30", "guid": "77873465-83a9-4283-bc44-4e542b8eb3eb"},
+         "bvoh": {"name": "BVOH", "guid": "923e604c-8432-4b09-96aa-9bbbd42207f4"},
+         "cpe": {"name": "CPE", "guid": "da1872c1-b991-4795-80ad-bdac0f131726"},
+         "hips": {"name": "HIPS", "guid": "a468d86a-220c-47eb-99a5-bbb47e514eb0"},
+         "tpu": {"name": "TPU 95A", "guid": "19baa6a9-94ff-478b-b4a1-8157b74358d2"},
+         "im-pla": {"name": "Tough", "guid": "de031137-a8ca-4a72-bd1b-17bb964033ad"}
+    }
+
+    __inverse_printer_name: Optional[Dict[str, str]] = None
+    __inverse_extruder_type: Optional[Dict[str, str]] = None
+    __inverse_material_map: Optional[Dict[str, str]] = None
+    __product_to_id_map: Optional[Dict[str, List[str]]] = None
+
+    @classmethod
+    def getInversePrinterNameMap(cls) -> Dict[str, str]:
+        """Returns the inverse of the printer name map, that is, from the internal name to the name used in output."""
+        if cls.__inverse_printer_name is not None:
+            return cls.__inverse_printer_name
+        cls.__inverse_printer_name = {}
+        for key, value in cls.PRINTER_TYPE_NAME.items():
+            cls.__inverse_printer_name[value] = key
+        return cls.__inverse_printer_name
+
+    @classmethod
+    def getInverseExtruderTypeMap(cls) -> Dict[str, str]:
+        """Returns the inverse of the extruder type map, that is, from the internal name to the name used in output."""
+        if cls.__inverse_extruder_type is not None:
+            return cls.__inverse_extruder_type
+        cls.__inverse_extruder_type = {}
+        for key, value in cls.EXTRUDER_NAME_MAP.items():
+            cls.__inverse_extruder_type[value] = key
+        return cls.__inverse_extruder_type
+
+    @classmethod
+    def getInverseMaterialMap(cls) -> Dict[str, str]:
+        """Returns the inverse of the material map, that is, from the internal name to the name used in output.
+
+        Note that this drops the extra info saved in the non-inverse material map, use that if you need it.
+        """
+        if cls.__inverse_material_map is not None:
+            return cls.__inverse_material_map
+        cls.__inverse_material_map = {}
+        for key, value in cls.MATERIAL_MAP.items():
+            cls.__inverse_material_map[value["name"]] = key
+        return cls.__inverse_material_map
+
+    @classmethod
+    def getProductIdMap(cls) -> Dict[str, List[str]]:
+        """Gets a mapping from product names (for example, in the XML files) to their definition IDs.
+
+        This loads the mapping from a file.
+        """
+        if cls.__product_to_id_map is not None:
+            return cls.__product_to_id_map
+
+        product_to_id_file = Resources.getPath(Resources.Texts, "product_to_id.json")
+        with open(product_to_id_file, encoding = "utf-8") as f:
+            contents = ""
+            for line in f:
+                contents += line if "#" not in line else "".join([line.replace("#", str(n)) for n in range(1, 12)])
+            cls.__product_to_id_map = json.loads(contents)
+        cls.__product_to_id_map = {key: [value] for key, value in cls.__product_to_id_map.items()}
+        #This also loads "Ultimaker S5" -> "ultimaker_s5" even though that is not strictly necessary with the default to change spaces into underscores.
+        #However it is not always loaded with that default; this mapping is also used in serialize() without that default.
+        return cls.__product_to_id_map

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