Browse Source

Merge branch 'master' of github.com:Ultimaker/Cura

Jaime van Kessel 7 years ago
parent
commit
cc2ad9dec0

+ 4 - 2
cura/Machines/MaterialManager.py

@@ -498,8 +498,10 @@ class MaterialManager(QObject):
         # Ensure all settings are saved.
         self._application.saveSettings()
 
-        global_stack = self._application.getGlobalContainerStack()
-        approximate_diameter = str(round(global_stack.getProperty("material_diameter", "value")))
+        machine_manager = self._application.getMachineManager()
+        extruder_stack = machine_manager.activeStack
+
+        approximate_diameter = str(extruder_stack.approximateMaterialDiameter)
         root_material_id = "generic_pla"
         root_material_id = self.getRootMaterialIDForDiameter(root_material_id, approximate_diameter)
         material_group = self.getMaterialGroup(root_material_id)

+ 1 - 1
cura/Scene/CuraSceneNode.py

@@ -41,7 +41,7 @@ class CuraSceneNode(SceneNode):
         # Use the support extruder instead of the active extruder if this is a support_mesh
         if per_mesh_stack:
             if per_mesh_stack.getProperty("support_mesh", "value"):
-                return extruders[int(global_container_stack.getProperty("support_extruder_nr", "value"))]
+                return extruders[int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))]
 
         # It's only set if you explicitly choose an extruder
         extruder_id = self.callDecoration("getActiveExtruder")

+ 8 - 0
cura/Settings/CuraContainerStack.py

@@ -8,6 +8,7 @@ from typing import Any, Optional
 from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject
 from UM.FlameProfiler import pyqtSlot
 
+from UM.Application import Application
 from UM.Decorators import override
 from UM.Logger import Logger
 from UM.Settings.ContainerStack import ContainerStack, InvalidContainerStackError
@@ -314,6 +315,13 @@ class CuraContainerStack(ContainerStack):
 
         return cls._findInstanceContainerDefinitionId(definitions[0])
 
+    ##  getProperty for extruder positions, with translation from -1 to default extruder number
+    def getExtruderPositionValueWithDefault(self, key):
+        value = self.getProperty(key, "value")
+        if value == -1:
+            value = int(Application.getInstance().getMachineManager().defaultExtruderPosition)
+        return value
+
 ## private:
 
 # Private helper class to keep track of container positions and their types.

+ 3 - 0
cura/Settings/ExtruderStack.py

@@ -5,6 +5,7 @@ from typing import Any, TYPE_CHECKING, Optional
 
 from PyQt5.QtCore import pyqtProperty, pyqtSignal
 
+from UM.Application import Application
 from UM.Decorators import override
 from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
 from UM.Settings.ContainerStack import ContainerStack
@@ -111,6 +112,8 @@ class ExtruderStack(CuraContainerStack):
 
         limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
         if limit_to_extruder is not None:
+            if limit_to_extruder == -1:
+                limit_to_extruder = int(Application.getInstance().getMachineManager().defaultExtruderPosition)
             limit_to_extruder = str(limit_to_extruder)
         if (limit_to_extruder is not None and limit_to_extruder != "-1") and self.getMetaDataEntry("position") != str(limit_to_extruder):
             if str(limit_to_extruder) in self.getNextStack().extruders:

+ 3 - 0
cura/Settings/GlobalStack.py

@@ -7,6 +7,7 @@ from typing import Any, Dict, Optional
 
 from PyQt5.QtCore import pyqtProperty
 
+from UM.Application import Application
 from UM.Decorators import override
 
 from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
@@ -104,6 +105,8 @@ class GlobalStack(CuraContainerStack):
         # Handle the "limit_to_extruder" property.
         limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
         if limit_to_extruder is not None:
+            if limit_to_extruder == -1:
+                limit_to_extruder = int(Application.getInstance().getMachineManager().defaultExtruderPosition)
             limit_to_extruder = str(limit_to_extruder)
         if limit_to_extruder is not None and limit_to_extruder != "-1" and limit_to_extruder in self._extruders:
             if super().getProperty(key, "settable_per_extruder", context):

+ 1 - 1
cura/Settings/MachineManager.py

@@ -1227,7 +1227,7 @@ class MachineManager(QObject):
             self._updateQualityWithMaterial()
 
     @pyqtSlot(str, "QVariant")
-    def setVariantGroup(self, position, container_node):
+    def setVariant(self, position, container_node):
         position = str(position)
         self.blurSettings.emit()
         with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):

+ 6 - 5
cura/Settings/PerObjectContainerStack.py

@@ -3,13 +3,14 @@ from typing import Any, Optional
 from UM.Application import Application
 from UM.Decorators import override
 from UM.Settings.Interfaces import PropertyEvaluationContext
-from UM.Settings.ContainerStack import ContainerStack
 from UM.Settings.SettingInstance import InstanceState
 
+from .CuraContainerStack import CuraContainerStack
 
-class PerObjectContainerStack(ContainerStack):
 
-    @override(ContainerStack)
+class PerObjectContainerStack(CuraContainerStack):
+
+    @override(CuraContainerStack)
     def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any:
         if context is None:
             context = PropertyEvaluationContext()
@@ -51,8 +52,8 @@ class PerObjectContainerStack(ContainerStack):
         context.popContainer()
         return result
 
-    @override(ContainerStack)
-    def setNextStack(self, stack: ContainerStack):
+    @override(CuraContainerStack)
+    def setNextStack(self, stack: CuraContainerStack):
         super().setNextStack(stack)
 
         # trigger signal to re-evaluate all default settings

+ 4 - 3
cura/Settings/SettingOverrideDecorator.py

@@ -3,7 +3,6 @@
 
 import copy
 
-from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
 from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
 from UM.Signal import Signal, signalemitter
 from UM.Settings.InstanceContainer import InstanceContainer
@@ -33,9 +32,11 @@ class SettingOverrideDecorator(SceneNodeDecorator):
 
     def __init__(self):
         super().__init__()
-        self._stack = PerObjectContainerStack(stack_id = "per_object_stack_" + str(id(self)))
+        self._stack = PerObjectContainerStack(container_id = "per_object_stack_" + str(id(self)))
         self._stack.setDirty(False)  # This stack does not need to be saved.
-        self._stack.addContainer(InstanceContainer(container_id = "SettingOverrideInstanceContainer"))
+        user_container = InstanceContainer(container_id = "SettingOverrideInstanceContainer")
+        user_container.addMetaDataEntry("type", "user")
+        self._stack.userChanges = user_container
         self._extruder_stack = ExtruderManager.getInstance().getExtruderStack(0).getId()
 
         self._is_non_printing_mesh = False

+ 2 - 2
plugins/SliceInfoPlugin/SliceInfo.py

@@ -146,7 +146,7 @@ class SliceInfo(Extension):
                     model_stack = node.callDecoration("getStack")
                     if model_stack:
                         model_settings["support_enabled"] = model_stack.getProperty("support_enable", "value")
-                        model_settings["support_extruder_nr"] = int(model_stack.getProperty("support_extruder_nr", "value"))
+                        model_settings["support_extruder_nr"] = int(model_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
 
                         # Mesh modifiers;
                         model_settings["infill_mesh"] = model_stack.getProperty("infill_mesh", "value")
@@ -177,7 +177,7 @@ class SliceInfo(Extension):
 
             # Support settings
             print_settings["support_enabled"] = global_container_stack.getProperty("support_enable", "value")
-            print_settings["support_extruder_nr"] = int(global_container_stack.getProperty("support_extruder_nr", "value"))
+            print_settings["support_extruder_nr"] = int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
 
             # Platform adhesion settings
             print_settings["adhesion_type"] = global_container_stack.getProperty("adhesion_type", "value")

+ 2 - 2
plugins/SolidView/SolidView.py

@@ -62,7 +62,7 @@ class SolidView(View):
 
         global_container_stack = Application.getInstance().getGlobalContainerStack()
         if global_container_stack:
-            support_extruder_nr = global_container_stack.getProperty("support_extruder_nr", "value")
+            support_extruder_nr = global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr")
             support_angle_stack = Application.getInstance().getExtruderManager().getExtruderStack(support_extruder_nr)
 
             if support_angle_stack is not None and Preferences.getInstance().getValue("view/show_overhang"):
@@ -89,7 +89,7 @@ class SolidView(View):
                     # Use the support extruder instead of the active extruder if this is a support_mesh
                     if per_mesh_stack:
                         if per_mesh_stack.getProperty("support_mesh", "value"):
-                            extruder_index = int(global_container_stack.getProperty("support_extruder_nr", "value"))
+                            extruder_index = int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
 
                     try:
                         material_color = self._extruders_model.getItem(extruder_index)["color"]

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