Browse Source

Merge branch '2.7'

Lipu Fei 7 years ago
parent
commit
e17a88fe11

+ 1 - 0
.gitignore

@@ -6,6 +6,7 @@ __pycache__
 docs/html
 *.log
 resources/i18n/en
+resources/i18n/7s
 resources/i18n/x-test
 resources/firmware
 resources/materials

+ 34 - 1
plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml

@@ -151,10 +151,43 @@ Item {
                         UM.SettingPropertyProvider
                         {
                             id: inheritStackProvider
-                            containerStackId: Cura.MachineManager.activeMachineId
+                            containerStackId: UM.ActiveTool.properties.getValue("ContainerID")
                             key: model.key
                             watchedProperties: [ "limit_to_extruder" ]
                         }
+
+                        Binding
+                        {
+                            target: provider
+                            property: "containerStackId"
+                            when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0);
+                            value:
+                            {
+                                // associate this binding with Cura.MachineManager.activeMachineId in the beginning so this
+                                // binding will be triggered when activeMachineId is changed too.
+                                // Otherwise, if this value only depends on the extruderIds, it won't get updated when the
+                                // machine gets changed.
+                                var activeMachineId = Cura.MachineManager.activeMachineId;
+
+                                if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1)
+                                {
+                                    //Not settable per extruder or there only is global, so we must pick global.
+                                    return activeMachineId;
+                                }
+                                if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0)
+                                {
+                                    //We have limit_to_extruder, so pick that stack.
+                                    return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)];
+                                }
+                                if(ExtruderManager.activeExtruderStackId)
+                                {
+                                    //We're on an extruder tab. Pick the current extruder.
+                                    return ExtruderManager.activeExtruderStackId;
+                                }
+                                //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab.
+                                return activeMachineId;
+                            }
+                        }
                     }
                 }
             }

+ 8 - 2
plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py

@@ -114,6 +114,10 @@ class VersionUpgrade25to26(VersionUpgrade):
         parser.write(output)
         return [filename], [output.getvalue()]
 
+    ##  Upgrades a machine stack from version 2.5 to 2.6
+    #
+    #   \param serialised The serialised form of a quality profile.
+    #   \param filename The name of the file to upgrade.
     def upgradeMachineStack(self, serialised, filename):
         parser = configparser.ConfigParser(interpolation=None)
         parser.read_string(serialised)
@@ -127,7 +131,7 @@ class VersionUpgrade25to26(VersionUpgrade):
 
         if definition_container_id == "custom" and not self._checkCustomFdmPrinterHasExtruderStack(machine_id):
             # go through all extruders and make sure that this custom FDM printer has 8 extruder stacks.
-            self._getNextUniqueCustomFdmPrinterExtruderStackIdIndex()
+            self._acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex()
             for position in range(8):
                 self._createCustomFdmPrinterExtruderStack(machine_id, position, quality_container_id, material_container_id)
 
@@ -141,7 +145,8 @@ class VersionUpgrade25to26(VersionUpgrade):
 
         return [filename], [output.getvalue()]
 
-    def _getNextUniqueCustomFdmPrinterExtruderStackIdIndex(self):
+    ##  Acquires the next unique extruder stack index number for the Custom FDM Printer.
+    def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self):
         extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack)
         file_name_list = os.listdir(extruder_stack_dir)
         file_name_list = [os.path.basename(file_name) for file_name in file_name_list]
@@ -185,6 +190,7 @@ class VersionUpgrade25to26(VersionUpgrade):
             if machine_id != parser["metadata"]["machine"]:
                 continue
             has_extruders = True
+            break
 
         return has_extruders
 

+ 24 - 4
plugins/XmlMaterialProfile/XmlMaterialProfile.py

@@ -548,7 +548,17 @@ class XmlMaterialProfile(InstanceContainer):
                 if machine_compatibility:
                     new_material_id = self.id + "_" + machine_id
 
-                    new_material = XmlMaterialProfile(new_material_id)
+                    # The child or derived material container may already exist. This can happen when a material in a
+                    # project file and the a material in Cura have the same ID.
+                    # In the case if a derived material already exists, override that material container because if
+                    # the data in the parent material has been changed, the derived ones should be updated too.
+                    found_materials = ContainerRegistry.getInstance().findInstanceContainers(id = new_material_id)
+                    is_new_material = False
+                    if found_materials:
+                        new_material = found_materials[0]
+                    else:
+                        new_material = XmlMaterialProfile(new_material_id)
+                        is_new_material = True
 
                     # Update the private directly, as we want to prevent the lookup that is done when using setName
                     new_material._name = self.getName()
@@ -562,7 +572,8 @@ class XmlMaterialProfile(InstanceContainer):
 
                     new_material._dirty = False
 
-                    ContainerRegistry.getInstance().addContainer(new_material)
+                    if is_new_material:
+                        ContainerRegistry.getInstance().addContainer(new_material)
 
                 hotends = machine.iterfind("./um:hotend", self.__namespaces)
                 for hotend in hotends:
@@ -594,7 +605,15 @@ class XmlMaterialProfile(InstanceContainer):
 
                     new_hotend_id = self.id + "_" + machine_id + "_" + hotend_id.replace(" ", "_")
 
-                    new_hotend_material = XmlMaterialProfile(new_hotend_id)
+                    # Same as machine compatibility, keep the derived material containers consistent with the parent
+                    # material
+                    found_materials = ContainerRegistry.getInstance().findInstanceContainers(id = new_hotend_id)
+                    is_new_material = False
+                    if found_materials:
+                        new_hotend_material = found_materials[0]
+                    else:
+                        new_hotend_material = XmlMaterialProfile(new_hotend_id)
+                        is_new_material = True
 
                     # Update the private directly, as we want to prevent the lookup that is done when using setName
                     new_hotend_material._name = self.getName()
@@ -612,7 +631,8 @@ class XmlMaterialProfile(InstanceContainer):
 
                     new_hotend_material._dirty = False
 
-                    ContainerRegistry.getInstance().addContainer(new_hotend_material)
+                    if is_new_material:
+                        ContainerRegistry.getInstance().addContainer(new_hotend_material)
 
     def _addSettingElement(self, builder, instance):
         try:

+ 6 - 0
resources/qml/Preferences/GeneralPage.qml

@@ -161,6 +161,12 @@ UM.PreferencesPage
                             append({ text: "Português do Brasil", code: "ptbr" })
                             append({ text: "Русский", code: "ru" })
                             append({ text: "Türkçe", code: "tr" })
+
+                            var date_object = new Date();
+                            if (date_object.getUTCMonth() == 8 && date_object.getUTCDate() == 19) //Only add Pirate on the 19th of September.
+                            {
+                                append({ text: "Pirate", code: "7s" })
+                            }
                         }
                     }