|
@@ -184,7 +184,7 @@ class MachineManager(QObject):
|
|
|
# Create the configuration model with the current data in Cura
|
|
|
self._current_printer_configuration.printerType = self._global_container_stack.definition.getName()
|
|
|
self._current_printer_configuration.extruderConfigurations = []
|
|
|
- for extruder in self._global_container_stack.extruders.values():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
extruder_configuration = ExtruderConfigurationModel()
|
|
|
# For compare just the GUID is needed at this moment
|
|
|
mat_type = extruder.material.getMetaDataEntry("material") if extruder.material != empty_material_container else None
|
|
@@ -294,13 +294,13 @@ class MachineManager(QObject):
|
|
|
## Given a global_stack, make sure that it's all valid by searching for this quality group and applying it again
|
|
|
def _initMachineState(self, global_stack: "CuraContainerStack") -> None:
|
|
|
material_dict = {}
|
|
|
- for position, extruder in global_stack.extruders.items():
|
|
|
- material_dict[position] = extruder.material.getMetaDataEntry("base_file")
|
|
|
+ for position, extruder in enumerate(global_stack.extruderList):
|
|
|
+ material_dict[str(position)] = extruder.material.getMetaDataEntry("base_file")
|
|
|
self._current_root_material_id = material_dict
|
|
|
|
|
|
# Update materials to make sure that the diameters match with the machine's
|
|
|
- for position in global_stack.extruders:
|
|
|
- self.updateMaterialWithVariant(position)
|
|
|
+ for position, _ in enumerate(global_stack.extruderList):
|
|
|
+ self.updateMaterialWithVariant(str(position))
|
|
|
|
|
|
global_quality = global_stack.quality
|
|
|
quality_type = global_quality.getMetaDataEntry("quality_type")
|
|
@@ -686,7 +686,7 @@ class MachineManager(QObject):
|
|
|
def isCurrentSetupSupported(self) -> bool:
|
|
|
if not self._global_container_stack:
|
|
|
return False
|
|
|
- for stack in [self._global_container_stack] + list(self._global_container_stack.extruders.values()):
|
|
|
+ for stack in [self._global_container_stack] + self._global_container_stack.extruderList:
|
|
|
for container in stack.getContainers():
|
|
|
if not container:
|
|
|
return False
|
|
@@ -712,8 +712,8 @@ class MachineManager(QObject):
|
|
|
def copyAllValuesToExtruders(self) -> None:
|
|
|
if self._active_container_stack is None or self._global_container_stack is None:
|
|
|
return
|
|
|
- extruder_stacks = list(self._global_container_stack.extruders.values())
|
|
|
- for extruder_stack in extruder_stacks:
|
|
|
+
|
|
|
+ for extruder_stack in self._global_container_stack.extruderList:
|
|
|
if extruder_stack != self._active_container_stack:
|
|
|
for key in self._active_container_stack.userChanges.getAllKeys():
|
|
|
new_value = self._active_container_stack.getProperty(key, "value")
|
|
@@ -843,8 +843,7 @@ class MachineManager(QObject):
|
|
|
return True
|
|
|
|
|
|
buildplate_compatible = True # It is compatible by default
|
|
|
- extruder_stacks = self._global_container_stack.extruders.values()
|
|
|
- for stack in extruder_stacks:
|
|
|
+ for stack in self._global_container_stack.extruderList:
|
|
|
if not stack.isEnabled:
|
|
|
continue
|
|
|
material_container = stack.material
|
|
@@ -867,8 +866,8 @@ class MachineManager(QObject):
|
|
|
# (material_left_compatible or material_left_usable) and
|
|
|
# (material_right_compatible or material_right_usable)
|
|
|
result = not self.variantBuildplateCompatible
|
|
|
- extruder_stacks = self._global_container_stack.extruders.values()
|
|
|
- for stack in extruder_stacks:
|
|
|
+
|
|
|
+ for stack in self._global_container_stack.extruderList:
|
|
|
material_container = stack.material
|
|
|
if material_container == empty_material_container:
|
|
|
continue
|
|
@@ -904,7 +903,7 @@ class MachineManager(QObject):
|
|
|
old_value = old_value(self._global_container_stack)
|
|
|
if int(old_value) < 0:
|
|
|
continue
|
|
|
- if int(old_value) >= extruder_count or not self._global_container_stack.extruders[str(old_value)].isEnabled:
|
|
|
+ if int(old_value) >= extruder_count or not self._global_container_stack.extruderList[int(old_value)].isEnabled:
|
|
|
result.append(setting_key)
|
|
|
Logger.log("d", "Reset setting [%s] in [%s] because its old value [%s] is no longer valid", setting_key, container, old_value)
|
|
|
return result
|
|
@@ -993,18 +992,18 @@ class MachineManager(QObject):
|
|
|
@deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
|
|
|
def _getExtruder(self, position) -> Optional[ExtruderStack]:
|
|
|
if self._global_container_stack:
|
|
|
- return self._global_container_stack.extruders.get(str(position))
|
|
|
+ return self._global_container_stack.extruderList[int(position)]
|
|
|
return None
|
|
|
|
|
|
def updateDefaultExtruder(self) -> None:
|
|
|
if self._global_container_stack is None:
|
|
|
return
|
|
|
- extruder_items = sorted(self._global_container_stack.extruders.items())
|
|
|
+
|
|
|
old_position = self._default_extruder_position
|
|
|
new_default_position = "0"
|
|
|
- for position, extruder in extruder_items:
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
if extruder.isEnabled:
|
|
|
- new_default_position = position
|
|
|
+ new_default_position = extruder.getMetaDataEntry("position", "0")
|
|
|
break
|
|
|
if new_default_position != old_position:
|
|
|
self._default_extruder_position = new_default_position
|
|
@@ -1016,7 +1015,7 @@ class MachineManager(QObject):
|
|
|
definition_changes_container = self._global_container_stack.definitionChanges
|
|
|
machine_extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
|
|
extruder_count = 0
|
|
|
- for position, extruder in self._global_container_stack.extruders.items():
|
|
|
+ for position, extruder in enumerate(self._global_container_stack.extruderList):
|
|
|
if extruder.isEnabled and int(position) < machine_extruder_count:
|
|
|
extruder_count += 1
|
|
|
if self.numberExtrudersEnabled != extruder_count:
|
|
@@ -1040,7 +1039,7 @@ class MachineManager(QObject):
|
|
|
return
|
|
|
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
|
|
property_names = ["value", "resolve", "validationState"]
|
|
|
- for container in [self._global_container_stack] + list(self._global_container_stack.extruders.values()):
|
|
|
+ for container in [self._global_container_stack] + self._global_container_stack.extruderList:
|
|
|
for setting_key in container.getAllKeys():
|
|
|
container.propertiesChanged.emit(setting_key, property_names)
|
|
|
|
|
@@ -1089,7 +1088,7 @@ class MachineManager(QObject):
|
|
|
def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str) -> None:
|
|
|
if self._global_container_stack is None:
|
|
|
return
|
|
|
- for key, extruder in self._global_container_stack.extruders.items():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
container = extruder.userChanges
|
|
|
container.setProperty(setting_name, property_name, property_value)
|
|
|
|
|
@@ -1099,7 +1098,7 @@ class MachineManager(QObject):
|
|
|
def resetSettingForAllExtruders(self, setting_name: str) -> None:
|
|
|
if self._global_container_stack is None:
|
|
|
return
|
|
|
- for key, extruder in self._global_container_stack.extruders.items():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
container = extruder.userChanges
|
|
|
container.removeInstance(setting_name)
|
|
|
|
|
@@ -1117,8 +1116,9 @@ class MachineManager(QObject):
|
|
|
changed = False
|
|
|
|
|
|
if self._global_container_stack:
|
|
|
- for position in self._global_container_stack.extruders:
|
|
|
- material_id = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
+ material_id = extruder.material.getMetaDataEntry("base_file")
|
|
|
+ position = extruder.getMetaDataEntry("position")
|
|
|
if position not in self._current_root_material_id or material_id != self._current_root_material_id[position]:
|
|
|
changed = True
|
|
|
self._current_root_material_id[position] = material_id
|
|
@@ -1155,7 +1155,7 @@ class MachineManager(QObject):
|
|
|
self._current_quality_changes_group = None
|
|
|
self._global_container_stack.quality = empty_quality_container
|
|
|
self._global_container_stack.qualityChanges = empty_quality_changes_container
|
|
|
- for extruder in self._global_container_stack.extruders.values():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
extruder.quality = empty_quality_container
|
|
|
extruder.qualityChanges = empty_quality_changes_container
|
|
|
|
|
@@ -1186,9 +1186,9 @@ class MachineManager(QObject):
|
|
|
|
|
|
# Set quality and quality_changes for each ExtruderStack
|
|
|
for position, node in quality_group.nodes_for_extruders.items():
|
|
|
- self._global_container_stack.extruders[str(position)].quality = node.getContainer()
|
|
|
+ self._global_container_stack.extruderList[int(position)].quality = node.getContainer()
|
|
|
if empty_quality_changes:
|
|
|
- self._global_container_stack.extruders[str(position)].qualityChanges = empty_quality_changes_container
|
|
|
+ self._global_container_stack.extruderList[int(position)].qualityChanges = empty_quality_changes_container
|
|
|
|
|
|
self.activeQualityGroupChanged.emit()
|
|
|
self.activeQualityChangesGroupChanged.emit()
|
|
@@ -1224,7 +1224,8 @@ class MachineManager(QObject):
|
|
|
self._global_container_stack.quality = quality_container
|
|
|
self._global_container_stack.qualityChanges = quality_changes_container
|
|
|
|
|
|
- for position, extruder in self._global_container_stack.extruders.items():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
+ position = str(extruder.getMetaDataEntry("position", "0"))
|
|
|
quality_changes_node = quality_changes_group.nodes_for_extruders.get(position)
|
|
|
quality_node = None
|
|
|
if quality_group is not None:
|
|
@@ -1248,7 +1249,7 @@ class MachineManager(QObject):
|
|
|
def _setVariantNode(self, position: str, container_node: "ContainerNode") -> None:
|
|
|
if container_node.getContainer() is None or self._global_container_stack is None:
|
|
|
return
|
|
|
- self._global_container_stack.extruders[position].variant = container_node.getContainer()
|
|
|
+ self._global_container_stack.extruderList[int(position)].variant = container_node.getContainer()
|
|
|
self.activeVariantChanged.emit()
|
|
|
|
|
|
def _setGlobalVariant(self, container_node: "ContainerNode") -> None:
|
|
@@ -1262,10 +1263,10 @@ class MachineManager(QObject):
|
|
|
if self._global_container_stack is None:
|
|
|
return
|
|
|
if container_node and container_node.getContainer():
|
|
|
- self._global_container_stack.extruders[position].material = container_node.getContainer()
|
|
|
+ self._global_container_stack.extruderList[int(position)].material = container_node.getContainer()
|
|
|
root_material_id = container_node.getMetaDataEntry("base_file", None)
|
|
|
else:
|
|
|
- self._global_container_stack.extruders[position].material = empty_material_container
|
|
|
+ self._global_container_stack.extruderList[int(position)].material = empty_material_container
|
|
|
root_material_id = None
|
|
|
# The _current_root_material_id is used in the MaterialMenu to see which material is selected
|
|
|
if root_material_id != self._current_root_material_id[position]:
|
|
@@ -1276,7 +1277,7 @@ class MachineManager(QObject):
|
|
|
# Check material - variant compatibility
|
|
|
if self._global_container_stack is not None:
|
|
|
if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)):
|
|
|
- for position, extruder in self._global_container_stack.extruders.items():
|
|
|
+ for extruder in self._global_container_stack.extruderList:
|
|
|
if not extruder.isEnabled:
|
|
|
continue
|
|
|
if not extruder.material.getMetaDataEntry("compatible"):
|
|
@@ -1336,7 +1337,7 @@ class MachineManager(QObject):
|
|
|
buildplate_name = self._global_container_stack.variant.getName()
|
|
|
|
|
|
for position_item in position_list:
|
|
|
- extruder = self._global_container_stack.extruders[position_item]
|
|
|
+ extruder = self._global_container_stack.extruderList[int(position_item)]
|
|
|
|
|
|
current_material_base_name = extruder.material.getMetaDataEntry("base_file")
|
|
|
current_nozzle_name = None
|
|
@@ -1421,7 +1422,7 @@ class MachineManager(QObject):
|
|
|
extruders_to_disable.add(extruder_configuration.position)
|
|
|
|
|
|
# If there's no material and/or nozzle on the printer, enable the first extruder and disable the rest.
|
|
|
- if len(extruders_to_disable) == len(self._global_container_stack.extruders):
|
|
|
+ if len(extruders_to_disable) == len(self._global_container_stack.extruderList):
|
|
|
extruders_to_disable.remove(min(extruders_to_disable))
|
|
|
|
|
|
for extruder_configuration in configuration.extruderConfigurations:
|
|
@@ -1429,7 +1430,7 @@ class MachineManager(QObject):
|
|
|
|
|
|
# If the machine doesn't have a hotend or material, disable this extruder
|
|
|
if int(position) in extruders_to_disable:
|
|
|
- self._global_container_stack.extruders[position].setEnabled(False)
|
|
|
+ self._global_container_stack.extruderList[int(position)].setEnabled(False)
|
|
|
|
|
|
need_to_show_message = True
|
|
|
disabled_used_extruder_position_set.add(int(position))
|
|
@@ -1445,13 +1446,13 @@ class MachineManager(QObject):
|
|
|
if variant_container_node:
|
|
|
self._setVariantNode(position, variant_container_node)
|
|
|
else:
|
|
|
- self._global_container_stack.extruders[position].variant = empty_variant_container
|
|
|
+ self._global_container_stack.extruderList[int(position)].variant = empty_variant_container
|
|
|
|
|
|
if material_container_node:
|
|
|
self._setMaterial(position, material_container_node)
|
|
|
else:
|
|
|
- self._global_container_stack.extruders[position].material = empty_material_container
|
|
|
- self._global_container_stack.extruders[position].setEnabled(True)
|
|
|
+ self._global_container_stack.extruderList[int(position)].material = empty_material_container
|
|
|
+ self._global_container_stack.extruderList[int(position)].setEnabled(True)
|
|
|
self.updateMaterialWithVariant(position)
|
|
|
|
|
|
self.updateDefaultExtruder()
|
|
@@ -1473,7 +1474,7 @@ class MachineManager(QObject):
|
|
|
# Show human-readable extruder names such as "Extruder Left", "Extruder Front" instead of "Extruder 1, 2, 3".
|
|
|
extruder_names = []
|
|
|
for extruder_position in sorted(disabled_used_extruder_position_set):
|
|
|
- extruder_stack = self._global_container_stack.extruders[str(extruder_position)]
|
|
|
+ extruder_stack = self._global_container_stack.extruderList[int(extruder_position)]
|
|
|
extruder_name = extruder_stack.definition.getName()
|
|
|
extruder_names.append(extruder_name)
|
|
|
extruders_str = ", ".join(extruder_names)
|
|
@@ -1504,7 +1505,7 @@ class MachineManager(QObject):
|
|
|
|
|
|
machine_definition_id = self._global_container_stack.definition.id
|
|
|
position = str(position)
|
|
|
- extruder_stack = self._global_container_stack.extruders[position]
|
|
|
+ extruder_stack = self._global_container_stack.extruderList[int(position)]
|
|
|
nozzle_name = extruder_stack.variant.getName()
|
|
|
material_diameter = extruder_stack.getApproximateMaterialDiameter()
|
|
|
material_node = self._material_manager.getMaterialNode(machine_definition_id, nozzle_name, buildplate_name,
|
|
@@ -1516,7 +1517,7 @@ class MachineManager(QObject):
|
|
|
@pyqtSlot(str, "QVariant")
|
|
|
def setMaterial(self, position: str, container_node, global_stack: Optional["GlobalStack"] = None) -> None:
|
|
|
if global_stack is not None and global_stack != self._global_container_stack:
|
|
|
- global_stack.extruders[position].material = container_node.getContainer()
|
|
|
+ global_stack.extruderList[int(position)].material = container_node.getContainer()
|
|
|
return
|
|
|
position = str(position)
|
|
|
self.blurSettings.emit()
|