mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Remove use of deprecated extruders property
This commit is contained in:
parent
495ed17294
commit
0ff9d72c4c
15 changed files with 111 additions and 90 deletions
|
@ -269,10 +269,11 @@ class BuildVolume(SceneNode):
|
||||||
continue
|
continue
|
||||||
# Mark the node as outside build volume if the set extruder is disabled
|
# Mark the node as outside build volume if the set extruder is disabled
|
||||||
extruder_position = node.callDecoration("getActiveExtruderPosition")
|
extruder_position = node.callDecoration("getActiveExtruderPosition")
|
||||||
if extruder_position not in self._global_container_stack.extruders:
|
try:
|
||||||
continue
|
if not self._global_container_stack.extrudersList[int(extruder_position)].isEnabled:
|
||||||
if not self._global_container_stack.extruders[extruder_position].isEnabled:
|
node.setOutsideBuildArea(True)
|
||||||
node.setOutsideBuildArea(True)
|
continue
|
||||||
|
except IndexError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
node.setOutsideBuildArea(False)
|
node.setOutsideBuildArea(False)
|
||||||
|
@ -319,7 +320,7 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
# Mark the node as outside build volume if the set extruder is disabled
|
# Mark the node as outside build volume if the set extruder is disabled
|
||||||
extruder_position = node.callDecoration("getActiveExtruderPosition")
|
extruder_position = node.callDecoration("getActiveExtruderPosition")
|
||||||
if not self._global_container_stack.extruders[extruder_position].isEnabled:
|
if not self._global_container_stack.extruderList[int(extruder_position)].isEnabled:
|
||||||
node.setOutsideBuildArea(True)
|
node.setOutsideBuildArea(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -549,7 +550,7 @@ class BuildVolume(SceneNode):
|
||||||
return
|
return
|
||||||
|
|
||||||
old_raft_thickness = self._raft_thickness
|
old_raft_thickness = self._raft_thickness
|
||||||
if self._global_container_stack.extruders:
|
if self._global_container_stack.extruderList:
|
||||||
# This might be called before the extruder stacks have initialised, in which case getting the adhesion_type fails
|
# This might be called before the extruder stacks have initialised, in which case getting the adhesion_type fails
|
||||||
self._adhesion_type = self._global_container_stack.getProperty("adhesion_type", "value")
|
self._adhesion_type = self._global_container_stack.getProperty("adhesion_type", "value")
|
||||||
self._raft_thickness = 0.0
|
self._raft_thickness = 0.0
|
||||||
|
@ -1098,7 +1099,7 @@ class BuildVolume(SceneNode):
|
||||||
# not part of the collision radius, such as bed adhesion (skirt/brim/raft)
|
# not part of the collision radius, such as bed adhesion (skirt/brim/raft)
|
||||||
# and travel avoid distance.
|
# and travel avoid distance.
|
||||||
def getEdgeDisallowedSize(self):
|
def getEdgeDisallowedSize(self):
|
||||||
if not self._global_container_stack or not self._global_container_stack.extruders:
|
if not self._global_container_stack or not self._global_container_stack.extruderList:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
container_stack = self._global_container_stack
|
container_stack = self._global_container_stack
|
||||||
|
|
|
@ -660,14 +660,14 @@ class CuraApplication(QtApplication):
|
||||||
def discardOrKeepProfileChangesClosed(self, option: str) -> None:
|
def discardOrKeepProfileChangesClosed(self, option: str) -> None:
|
||||||
global_stack = self.getGlobalContainerStack()
|
global_stack = self.getGlobalContainerStack()
|
||||||
if option == "discard":
|
if option == "discard":
|
||||||
for extruder in global_stack.extruders.values():
|
for extruder in global_stack.extruderList:
|
||||||
extruder.userChanges.clear()
|
extruder.userChanges.clear()
|
||||||
global_stack.userChanges.clear()
|
global_stack.userChanges.clear()
|
||||||
|
|
||||||
# if the user decided to keep settings then the user settings should be re-calculated and validated for errors
|
# if the user decided to keep settings then the user settings should be re-calculated and validated for errors
|
||||||
# before slicing. To ensure that slicer uses right settings values
|
# before slicing. To ensure that slicer uses right settings values
|
||||||
elif option == "keep":
|
elif option == "keep":
|
||||||
for extruder in global_stack.extruders.values():
|
for extruder in global_stack.extruderList:
|
||||||
extruder.userChanges.update()
|
extruder.userChanges.update()
|
||||||
global_stack.userChanges.update()
|
global_stack.userChanges.update()
|
||||||
|
|
||||||
|
@ -1668,7 +1668,7 @@ class CuraApplication(QtApplication):
|
||||||
arranger = Arrange.create(x = machine_width, y = machine_depth, fixed_nodes = fixed_nodes)
|
arranger = Arrange.create(x = machine_width, y = machine_depth, fixed_nodes = fixed_nodes)
|
||||||
min_offset = 8
|
min_offset = 8
|
||||||
default_extruder_position = self.getMachineManager().defaultExtruderPosition
|
default_extruder_position = self.getMachineManager().defaultExtruderPosition
|
||||||
default_extruder_id = self._global_container_stack.extruders[default_extruder_position].getId()
|
default_extruder_id = self._global_container_stack.extruderList[int(default_extruder_position)].getId()
|
||||||
|
|
||||||
select_models_on_load = self.getPreferences().getValue("cura/select_models_on_load")
|
select_models_on_load = self.getPreferences().getValue("cura/select_models_on_load")
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class MachineErrorChecker(QObject):
|
||||||
self._global_stack.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
self._global_stack.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
||||||
self._global_stack.containersChanged.disconnect(self.startErrorCheck)
|
self._global_stack.containersChanged.disconnect(self.startErrorCheck)
|
||||||
|
|
||||||
for extruder in self._global_stack.extruders.values():
|
for extruder in self._global_stack.extruderList:
|
||||||
extruder.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
extruder.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
||||||
extruder.containersChanged.disconnect(self.startErrorCheck)
|
extruder.containersChanged.disconnect(self.startErrorCheck)
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class MachineErrorChecker(QObject):
|
||||||
self._global_stack.propertyChanged.connect(self.startErrorCheckPropertyChanged)
|
self._global_stack.propertyChanged.connect(self.startErrorCheckPropertyChanged)
|
||||||
self._global_stack.containersChanged.connect(self.startErrorCheck)
|
self._global_stack.containersChanged.connect(self.startErrorCheck)
|
||||||
|
|
||||||
for extruder in self._global_stack.extruders.values():
|
for extruder in self._global_stack.extruderList:
|
||||||
extruder.propertyChanged.connect(self.startErrorCheckPropertyChanged)
|
extruder.propertyChanged.connect(self.startErrorCheckPropertyChanged)
|
||||||
extruder.containersChanged.connect(self.startErrorCheck)
|
extruder.containersChanged.connect(self.startErrorCheck)
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class MachineErrorChecker(QObject):
|
||||||
|
|
||||||
# Populate the (stack, key) tuples to check
|
# Populate the (stack, key) tuples to check
|
||||||
self._stacks_and_keys_to_check = deque()
|
self._stacks_and_keys_to_check = deque()
|
||||||
for stack in global_stack.extruders.values():
|
for stack in global_stack.extruderList:
|
||||||
for key in stack.getAllKeys():
|
for key in stack.getAllKeys():
|
||||||
self._stacks_and_keys_to_check.append((stack, key))
|
self._stacks_and_keys_to_check.append((stack, key))
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,12 @@ class BaseMaterialsModel(ListModel):
|
||||||
if self._extruder_stack is not None:
|
if self._extruder_stack is not None:
|
||||||
self._extruder_stack.pyqtContainersChanged.disconnect(self._update)
|
self._extruder_stack.pyqtContainersChanged.disconnect(self._update)
|
||||||
self._extruder_stack.approximateMaterialDiameterChanged.disconnect(self._update)
|
self._extruder_stack.approximateMaterialDiameterChanged.disconnect(self._update)
|
||||||
self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
|
||||||
|
try:
|
||||||
|
self._extruder_stack = global_stack.extruderList[self._extruder_position]
|
||||||
|
except IndexError:
|
||||||
|
self._extruder_stack = None
|
||||||
|
|
||||||
if self._extruder_stack is not None:
|
if self._extruder_stack is not None:
|
||||||
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
||||||
self._extruder_stack.approximateMaterialDiameterChanged.connect(self._update)
|
self._extruder_stack.approximateMaterialDiameterChanged.connect(self._update)
|
||||||
|
@ -113,12 +118,11 @@ class BaseMaterialsModel(ListModel):
|
||||||
if global_stack is None or not self._enabled:
|
if global_stack is None or not self._enabled:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
extruder_position = str(self._extruder_position)
|
try:
|
||||||
|
extruder_stack = global_stack.extruderList[self._extruder_position]
|
||||||
if extruder_position not in global_stack.extruders:
|
except IndexError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
extruder_stack = global_stack.extruders[extruder_position]
|
|
||||||
self._available_materials = self._material_manager.getAvailableMaterialsForMachineExtruder(global_stack, extruder_stack)
|
self._available_materials = self._material_manager.getAvailableMaterialsForMachineExtruder(global_stack, extruder_stack)
|
||||||
if self._available_materials is None:
|
if self._available_materials is None:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -50,7 +50,7 @@ class UserChangesModel(ListModel):
|
||||||
return
|
return
|
||||||
|
|
||||||
stacks = [global_stack]
|
stacks = [global_stack]
|
||||||
stacks.extend(global_stack.extruders.values())
|
stacks.extend(global_stack.extruderList)
|
||||||
|
|
||||||
# Check if the definition container has a translation file and ensure it's loaded.
|
# Check if the definition container has a translation file and ensure it's loaded.
|
||||||
definition = global_stack.getBottom()
|
definition = global_stack.getBottom()
|
||||||
|
|
|
@ -154,8 +154,13 @@ class QualityManager(QObject):
|
||||||
def _updateQualityGroupsAvailability(self, machine: "GlobalStack", quality_group_list) -> None:
|
def _updateQualityGroupsAvailability(self, machine: "GlobalStack", quality_group_list) -> None:
|
||||||
used_extruders = set()
|
used_extruders = set()
|
||||||
for i in range(machine.getProperty("machine_extruder_count", "value")):
|
for i in range(machine.getProperty("machine_extruder_count", "value")):
|
||||||
if str(i) in machine.extruders and machine.extruders[str(i)].isEnabled:
|
try:
|
||||||
used_extruders.add(str(i))
|
extruder = machine.extruderList[int(i)]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if extruder.isEnabled:
|
||||||
|
used_extruders.add(str(i))
|
||||||
|
|
||||||
# Update the "is_available" flag for each quality group.
|
# Update the "is_available" flag for each quality group.
|
||||||
for quality_group in quality_group_list:
|
for quality_group in quality_group_list:
|
||||||
|
|
|
@ -40,8 +40,8 @@ class CuraFormulaFunctions:
|
||||||
|
|
||||||
global_stack = machine_manager.activeMachine
|
global_stack = machine_manager.activeMachine
|
||||||
try:
|
try:
|
||||||
extruder_stack = global_stack.extruders[str(extruder_position)]
|
extruder_stack = global_stack.extruderList[int(extruder_position)]
|
||||||
except KeyError:
|
except IndexError:
|
||||||
if extruder_position != 0:
|
if extruder_position != 0:
|
||||||
Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available. Returning the result form extruder 0 instead" % (property_key, extruder_position))
|
Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available. Returning the result form extruder 0 instead" % (property_key, extruder_position))
|
||||||
# This fixes a very specific fringe case; If a profile was created for a custom printer and one of the
|
# This fixes a very specific fringe case; If a profile was created for a custom printer and one of the
|
||||||
|
@ -104,11 +104,14 @@ class CuraFormulaFunctions:
|
||||||
machine_manager = self._application.getMachineManager()
|
machine_manager = self._application.getMachineManager()
|
||||||
|
|
||||||
global_stack = machine_manager.activeMachine
|
global_stack = machine_manager.activeMachine
|
||||||
extruder_stack = global_stack.extruders[str(extruder_position)]
|
try:
|
||||||
|
extruder_stack = global_stack.extruderList[extruder_position]
|
||||||
|
except IndexError:
|
||||||
|
Logger.log("w", "Unable to find extruder on in index %s", extruder_position)
|
||||||
|
else:
|
||||||
|
context = self.createContextForDefaultValueEvaluation(extruder_stack)
|
||||||
|
|
||||||
context = self.createContextForDefaultValueEvaluation(extruder_stack)
|
return self.getValueInExtruder(extruder_position, property_key, context = context)
|
||||||
|
|
||||||
return self.getValueInExtruder(extruder_position, property_key, context = context)
|
|
||||||
|
|
||||||
# Gets all default setting values as a list from all extruders of the currently active machine.
|
# Gets all default setting values as a list from all extruders of the currently active machine.
|
||||||
# The default values are those excluding the values in the user_changes container.
|
# The default values are those excluding the values in the user_changes container.
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ExtruderManager(QObject):
|
||||||
|
|
||||||
global_container_stack = self._application.getGlobalContainerStack()
|
global_container_stack = self._application.getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
extruder_stack_ids = {position: extruder.id for position, extruder in global_container_stack.extruders.items()}
|
extruder_stack_ids = {extruder.getMetaDataEntry("position", ""): extruder.id for extruder in global_container_stack.extruderList}
|
||||||
|
|
||||||
return extruder_stack_ids
|
return extruder_stack_ids
|
||||||
|
|
||||||
|
@ -360,10 +360,14 @@ class ExtruderManager(QObject):
|
||||||
def fixSingleExtrusionMachineExtruderDefinition(self, global_stack: "GlobalStack") -> None:
|
def fixSingleExtrusionMachineExtruderDefinition(self, global_stack: "GlobalStack") -> None:
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
expected_extruder_definition_0_id = global_stack.getMetaDataEntry("machine_extruder_trains")["0"]
|
expected_extruder_definition_0_id = global_stack.getMetaDataEntry("machine_extruder_trains")["0"]
|
||||||
extruder_stack_0 = global_stack.extruders.get("0")
|
try:
|
||||||
|
extruder_stack_0 = global_stack.extruderList[0]
|
||||||
|
except IndexError:
|
||||||
|
extruder_stack_0 = None
|
||||||
|
|
||||||
# At this point, extruder stacks for this machine may not have been loaded yet. In this case, need to look in
|
# At this point, extruder stacks for this machine may not have been loaded yet. In this case, need to look in
|
||||||
# the container registry as well.
|
# the container registry as well.
|
||||||
if not global_stack.extruders:
|
if not global_stack.extruderList:
|
||||||
extruder_trains = container_registry.findContainerStacks(type = "extruder_train",
|
extruder_trains = container_registry.findContainerStacks(type = "extruder_train",
|
||||||
machine = global_stack.getId())
|
machine = global_stack.getId())
|
||||||
if extruder_trains:
|
if extruder_trains:
|
||||||
|
|
|
@ -135,12 +135,15 @@ class ExtruderStack(CuraContainerStack):
|
||||||
if limit_to_extruder == -1:
|
if limit_to_extruder == -1:
|
||||||
limit_to_extruder = int(cura.CuraApplication.CuraApplication.getInstance().getMachineManager().defaultExtruderPosition)
|
limit_to_extruder = int(cura.CuraApplication.CuraApplication.getInstance().getMachineManager().defaultExtruderPosition)
|
||||||
limit_to_extruder = str(limit_to_extruder)
|
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 (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:
|
try:
|
||||||
result = self.getNextStack().extruders[str(limit_to_extruder)].getProperty(key, property_name, context)
|
result = self.getNextStack().extruderList[int(limit_to_extruder)].getProperty(key, property_name, context)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
context.popContainer()
|
context.popContainer()
|
||||||
return result
|
return result
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
|
||||||
result = super().getProperty(key, property_name, context)
|
result = super().getProperty(key, property_name, context)
|
||||||
context.popContainer()
|
context.popContainer()
|
||||||
|
|
|
@ -184,7 +184,7 @@ class MachineManager(QObject):
|
||||||
# Create the configuration model with the current data in Cura
|
# 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.printerType = self._global_container_stack.definition.getName()
|
||||||
self._current_printer_configuration.extruderConfigurations = []
|
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()
|
extruder_configuration = ExtruderConfigurationModel()
|
||||||
# For compare just the GUID is needed at this moment
|
# For compare just the GUID is needed at this moment
|
||||||
mat_type = extruder.material.getMetaDataEntry("material") if extruder.material != empty_material_container else None
|
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
|
## 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:
|
def _initMachineState(self, global_stack: "CuraContainerStack") -> None:
|
||||||
material_dict = {}
|
material_dict = {}
|
||||||
for position, extruder in global_stack.extruders.items():
|
for position, extruder in enumerate(global_stack.extruderList):
|
||||||
material_dict[position] = extruder.material.getMetaDataEntry("base_file")
|
material_dict[str(position)] = extruder.material.getMetaDataEntry("base_file")
|
||||||
self._current_root_material_id = material_dict
|
self._current_root_material_id = material_dict
|
||||||
|
|
||||||
# Update materials to make sure that the diameters match with the machine's
|
# Update materials to make sure that the diameters match with the machine's
|
||||||
for position in global_stack.extruders:
|
for position, _ in enumerate(global_stack.extruderList):
|
||||||
self.updateMaterialWithVariant(position)
|
self.updateMaterialWithVariant(str(position))
|
||||||
|
|
||||||
global_quality = global_stack.quality
|
global_quality = global_stack.quality
|
||||||
quality_type = global_quality.getMetaDataEntry("quality_type")
|
quality_type = global_quality.getMetaDataEntry("quality_type")
|
||||||
|
@ -686,7 +686,7 @@ class MachineManager(QObject):
|
||||||
def isCurrentSetupSupported(self) -> bool:
|
def isCurrentSetupSupported(self) -> bool:
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
return False
|
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():
|
for container in stack.getContainers():
|
||||||
if not container:
|
if not container:
|
||||||
return False
|
return False
|
||||||
|
@ -712,8 +712,8 @@ class MachineManager(QObject):
|
||||||
def copyAllValuesToExtruders(self) -> None:
|
def copyAllValuesToExtruders(self) -> None:
|
||||||
if self._active_container_stack is None or self._global_container_stack is None:
|
if self._active_container_stack is None or self._global_container_stack is None:
|
||||||
return
|
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:
|
if extruder_stack != self._active_container_stack:
|
||||||
for key in self._active_container_stack.userChanges.getAllKeys():
|
for key in self._active_container_stack.userChanges.getAllKeys():
|
||||||
new_value = self._active_container_stack.getProperty(key, "value")
|
new_value = self._active_container_stack.getProperty(key, "value")
|
||||||
|
@ -843,8 +843,7 @@ class MachineManager(QObject):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
buildplate_compatible = True # It is compatible by default
|
buildplate_compatible = True # It is compatible by default
|
||||||
extruder_stacks = self._global_container_stack.extruders.values()
|
for stack in self._global_container_stack.extruderList:
|
||||||
for stack in extruder_stacks:
|
|
||||||
if not stack.isEnabled:
|
if not stack.isEnabled:
|
||||||
continue
|
continue
|
||||||
material_container = stack.material
|
material_container = stack.material
|
||||||
|
@ -867,8 +866,8 @@ class MachineManager(QObject):
|
||||||
# (material_left_compatible or material_left_usable) and
|
# (material_left_compatible or material_left_usable) and
|
||||||
# (material_right_compatible or material_right_usable)
|
# (material_right_compatible or material_right_usable)
|
||||||
result = not self.variantBuildplateCompatible
|
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
|
material_container = stack.material
|
||||||
if material_container == empty_material_container:
|
if material_container == empty_material_container:
|
||||||
continue
|
continue
|
||||||
|
@ -904,7 +903,7 @@ class MachineManager(QObject):
|
||||||
old_value = old_value(self._global_container_stack)
|
old_value = old_value(self._global_container_stack)
|
||||||
if int(old_value) < 0:
|
if int(old_value) < 0:
|
||||||
continue
|
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)
|
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)
|
Logger.log("d", "Reset setting [%s] in [%s] because its old value [%s] is no longer valid", setting_key, container, old_value)
|
||||||
return result
|
return result
|
||||||
|
@ -993,18 +992,18 @@ class MachineManager(QObject):
|
||||||
@deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
|
@deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
|
||||||
def _getExtruder(self, position) -> Optional[ExtruderStack]:
|
def _getExtruder(self, position) -> Optional[ExtruderStack]:
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
return self._global_container_stack.extruders.get(str(position))
|
return self._global_container_stack.extruderList[int(position)]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def updateDefaultExtruder(self) -> None:
|
def updateDefaultExtruder(self) -> None:
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
extruder_items = sorted(self._global_container_stack.extruders.items())
|
|
||||||
old_position = self._default_extruder_position
|
old_position = self._default_extruder_position
|
||||||
new_default_position = "0"
|
new_default_position = "0"
|
||||||
for position, extruder in extruder_items:
|
for extruder in self._global_container_stack.extruderList:
|
||||||
if extruder.isEnabled:
|
if extruder.isEnabled:
|
||||||
new_default_position = position
|
new_default_position = extruder.getMetaDataEntry("position", "0")
|
||||||
break
|
break
|
||||||
if new_default_position != old_position:
|
if new_default_position != old_position:
|
||||||
self._default_extruder_position = new_default_position
|
self._default_extruder_position = new_default_position
|
||||||
|
@ -1016,7 +1015,7 @@ class MachineManager(QObject):
|
||||||
definition_changes_container = self._global_container_stack.definitionChanges
|
definition_changes_container = self._global_container_stack.definitionChanges
|
||||||
machine_extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
machine_extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
||||||
extruder_count = 0
|
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:
|
if extruder.isEnabled and int(position) < machine_extruder_count:
|
||||||
extruder_count += 1
|
extruder_count += 1
|
||||||
if self.numberExtrudersEnabled != extruder_count:
|
if self.numberExtrudersEnabled != extruder_count:
|
||||||
|
@ -1040,7 +1039,7 @@ class MachineManager(QObject):
|
||||||
return
|
return
|
||||||
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
||||||
property_names = ["value", "resolve", "validationState"]
|
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():
|
for setting_key in container.getAllKeys():
|
||||||
container.propertiesChanged.emit(setting_key, property_names)
|
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:
|
def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str) -> None:
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
for key, extruder in self._global_container_stack.extruders.items():
|
for extruder in self._global_container_stack.extruderList:
|
||||||
container = extruder.userChanges
|
container = extruder.userChanges
|
||||||
container.setProperty(setting_name, property_name, property_value)
|
container.setProperty(setting_name, property_name, property_value)
|
||||||
|
|
||||||
|
@ -1099,7 +1098,7 @@ class MachineManager(QObject):
|
||||||
def resetSettingForAllExtruders(self, setting_name: str) -> None:
|
def resetSettingForAllExtruders(self, setting_name: str) -> None:
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
for key, extruder in self._global_container_stack.extruders.items():
|
for extruder in self._global_container_stack.extruderList:
|
||||||
container = extruder.userChanges
|
container = extruder.userChanges
|
||||||
container.removeInstance(setting_name)
|
container.removeInstance(setting_name)
|
||||||
|
|
||||||
|
@ -1117,8 +1116,9 @@ class MachineManager(QObject):
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
for position in self._global_container_stack.extruders:
|
for extruder in self._global_container_stack.extruderList:
|
||||||
material_id = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
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]:
|
if position not in self._current_root_material_id or material_id != self._current_root_material_id[position]:
|
||||||
changed = True
|
changed = True
|
||||||
self._current_root_material_id[position] = material_id
|
self._current_root_material_id[position] = material_id
|
||||||
|
@ -1155,7 +1155,7 @@ class MachineManager(QObject):
|
||||||
self._current_quality_changes_group = None
|
self._current_quality_changes_group = None
|
||||||
self._global_container_stack.quality = empty_quality_container
|
self._global_container_stack.quality = empty_quality_container
|
||||||
self._global_container_stack.qualityChanges = empty_quality_changes_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.quality = empty_quality_container
|
||||||
extruder.qualityChanges = empty_quality_changes_container
|
extruder.qualityChanges = empty_quality_changes_container
|
||||||
|
|
||||||
|
@ -1186,9 +1186,9 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
# Set quality and quality_changes for each ExtruderStack
|
# Set quality and quality_changes for each ExtruderStack
|
||||||
for position, node in quality_group.nodes_for_extruders.items():
|
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:
|
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.activeQualityGroupChanged.emit()
|
||||||
self.activeQualityChangesGroupChanged.emit()
|
self.activeQualityChangesGroupChanged.emit()
|
||||||
|
@ -1224,7 +1224,8 @@ class MachineManager(QObject):
|
||||||
self._global_container_stack.quality = quality_container
|
self._global_container_stack.quality = quality_container
|
||||||
self._global_container_stack.qualityChanges = quality_changes_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_changes_node = quality_changes_group.nodes_for_extruders.get(position)
|
||||||
quality_node = None
|
quality_node = None
|
||||||
if quality_group is not None:
|
if quality_group is not None:
|
||||||
|
@ -1248,7 +1249,7 @@ class MachineManager(QObject):
|
||||||
def _setVariantNode(self, position: str, container_node: "ContainerNode") -> None:
|
def _setVariantNode(self, position: str, container_node: "ContainerNode") -> None:
|
||||||
if container_node.getContainer() is None or self._global_container_stack is None:
|
if container_node.getContainer() is None or self._global_container_stack is None:
|
||||||
return
|
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()
|
self.activeVariantChanged.emit()
|
||||||
|
|
||||||
def _setGlobalVariant(self, container_node: "ContainerNode") -> None:
|
def _setGlobalVariant(self, container_node: "ContainerNode") -> None:
|
||||||
|
@ -1262,10 +1263,10 @@ class MachineManager(QObject):
|
||||||
if self._global_container_stack is None:
|
if self._global_container_stack is None:
|
||||||
return
|
return
|
||||||
if container_node and container_node.getContainer():
|
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)
|
root_material_id = container_node.getMetaDataEntry("base_file", None)
|
||||||
else:
|
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
|
root_material_id = None
|
||||||
# The _current_root_material_id is used in the MaterialMenu to see which material is selected
|
# 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]:
|
if root_material_id != self._current_root_material_id[position]:
|
||||||
|
@ -1276,7 +1277,7 @@ class MachineManager(QObject):
|
||||||
# Check material - variant compatibility
|
# Check material - variant compatibility
|
||||||
if self._global_container_stack is not None:
|
if self._global_container_stack is not None:
|
||||||
if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)):
|
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:
|
if not extruder.isEnabled:
|
||||||
continue
|
continue
|
||||||
if not extruder.material.getMetaDataEntry("compatible"):
|
if not extruder.material.getMetaDataEntry("compatible"):
|
||||||
|
@ -1336,7 +1337,7 @@ class MachineManager(QObject):
|
||||||
buildplate_name = self._global_container_stack.variant.getName()
|
buildplate_name = self._global_container_stack.variant.getName()
|
||||||
|
|
||||||
for position_item in position_list:
|
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_material_base_name = extruder.material.getMetaDataEntry("base_file")
|
||||||
current_nozzle_name = None
|
current_nozzle_name = None
|
||||||
|
@ -1421,7 +1422,7 @@ class MachineManager(QObject):
|
||||||
extruders_to_disable.add(extruder_configuration.position)
|
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 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))
|
extruders_to_disable.remove(min(extruders_to_disable))
|
||||||
|
|
||||||
for extruder_configuration in configuration.extruderConfigurations:
|
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 the machine doesn't have a hotend or material, disable this extruder
|
||||||
if int(position) in extruders_to_disable:
|
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
|
need_to_show_message = True
|
||||||
disabled_used_extruder_position_set.add(int(position))
|
disabled_used_extruder_position_set.add(int(position))
|
||||||
|
@ -1445,13 +1446,13 @@ class MachineManager(QObject):
|
||||||
if variant_container_node:
|
if variant_container_node:
|
||||||
self._setVariantNode(position, variant_container_node)
|
self._setVariantNode(position, variant_container_node)
|
||||||
else:
|
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:
|
if material_container_node:
|
||||||
self._setMaterial(position, material_container_node)
|
self._setMaterial(position, material_container_node)
|
||||||
else:
|
else:
|
||||||
self._global_container_stack.extruders[position].material = empty_material_container
|
self._global_container_stack.extruderList[int(position)].material = empty_material_container
|
||||||
self._global_container_stack.extruders[position].setEnabled(True)
|
self._global_container_stack.extruderList[int(position)].setEnabled(True)
|
||||||
self.updateMaterialWithVariant(position)
|
self.updateMaterialWithVariant(position)
|
||||||
|
|
||||||
self.updateDefaultExtruder()
|
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".
|
# Show human-readable extruder names such as "Extruder Left", "Extruder Front" instead of "Extruder 1, 2, 3".
|
||||||
extruder_names = []
|
extruder_names = []
|
||||||
for extruder_position in sorted(disabled_used_extruder_position_set):
|
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_name = extruder_stack.definition.getName()
|
||||||
extruder_names.append(extruder_name)
|
extruder_names.append(extruder_name)
|
||||||
extruders_str = ", ".join(extruder_names)
|
extruders_str = ", ".join(extruder_names)
|
||||||
|
@ -1504,7 +1505,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
machine_definition_id = self._global_container_stack.definition.id
|
machine_definition_id = self._global_container_stack.definition.id
|
||||||
position = str(position)
|
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()
|
nozzle_name = extruder_stack.variant.getName()
|
||||||
material_diameter = extruder_stack.getApproximateMaterialDiameter()
|
material_diameter = extruder_stack.getApproximateMaterialDiameter()
|
||||||
material_node = self._material_manager.getMaterialNode(machine_definition_id, nozzle_name, buildplate_name,
|
material_node = self._material_manager.getMaterialNode(machine_definition_id, nozzle_name, buildplate_name,
|
||||||
|
@ -1516,7 +1517,7 @@ class MachineManager(QObject):
|
||||||
@pyqtSlot(str, "QVariant")
|
@pyqtSlot(str, "QVariant")
|
||||||
def setMaterial(self, position: str, container_node, global_stack: Optional["GlobalStack"] = None) -> None:
|
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:
|
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
|
return
|
||||||
position = str(position)
|
position = str(position)
|
||||||
self.blurSettings.emit()
|
self.blurSettings.emit()
|
||||||
|
|
|
@ -39,8 +39,8 @@ class SimpleModeSettingsManager(QObject):
|
||||||
user_setting_keys.update(global_stack.userChanges.getAllKeys())
|
user_setting_keys.update(global_stack.userChanges.getAllKeys())
|
||||||
|
|
||||||
# check user settings in the extruder stacks
|
# check user settings in the extruder stacks
|
||||||
if global_stack.extruders:
|
if global_stack.extruderList:
|
||||||
for extruder_stack in global_stack.extruders.values():
|
for extruder_stack in global_stack.extruderList:
|
||||||
user_setting_keys.update(extruder_stack.userChanges.getAllKeys())
|
user_setting_keys.update(extruder_stack.userChanges.getAllKeys())
|
||||||
|
|
||||||
# remove settings that are visible in recommended (we don't show the reset button for those)
|
# remove settings that are visible in recommended (we don't show the reset button for those)
|
||||||
|
|
|
@ -197,11 +197,7 @@ class PrintInformation(QObject):
|
||||||
|
|
||||||
material_preference_values = json.loads(self._application.getInstance().getPreferences().getValue("cura/material_settings"))
|
material_preference_values = json.loads(self._application.getInstance().getPreferences().getValue("cura/material_settings"))
|
||||||
|
|
||||||
extruder_stacks = global_stack.extruders
|
for index, extruder_stack in enumerate(global_stack.extruderList):
|
||||||
|
|
||||||
for position in extruder_stacks:
|
|
||||||
extruder_stack = extruder_stacks[position]
|
|
||||||
index = int(position)
|
|
||||||
if index >= len(self._material_amounts):
|
if index >= len(self._material_amounts):
|
||||||
continue
|
continue
|
||||||
amount = self._material_amounts[index]
|
amount = self._material_amounts[index]
|
||||||
|
|
|
@ -834,9 +834,8 @@ class CuraEngineBackend(QObject, Backend):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
self._global_container_stack.propertyChanged.disconnect(self._onSettingChanged)
|
self._global_container_stack.propertyChanged.disconnect(self._onSettingChanged)
|
||||||
self._global_container_stack.containersChanged.disconnect(self._onChanged)
|
self._global_container_stack.containersChanged.disconnect(self._onChanged)
|
||||||
extruders = list(self._global_container_stack.extruders.values())
|
|
||||||
|
|
||||||
for extruder in extruders:
|
for extruder in self._global_container_stack.extruderList:
|
||||||
extruder.propertyChanged.disconnect(self._onSettingChanged)
|
extruder.propertyChanged.disconnect(self._onSettingChanged)
|
||||||
extruder.containersChanged.disconnect(self._onChanged)
|
extruder.containersChanged.disconnect(self._onChanged)
|
||||||
|
|
||||||
|
@ -845,8 +844,8 @@ class CuraEngineBackend(QObject, Backend):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
self._global_container_stack.propertyChanged.connect(self._onSettingChanged) # Note: Only starts slicing when the value changed.
|
self._global_container_stack.propertyChanged.connect(self._onSettingChanged) # Note: Only starts slicing when the value changed.
|
||||||
self._global_container_stack.containersChanged.connect(self._onChanged)
|
self._global_container_stack.containersChanged.connect(self._onChanged)
|
||||||
extruders = list(self._global_container_stack.extruders.values())
|
|
||||||
for extruder in extruders:
|
for extruder in self._global_container_stack.extruderList:
|
||||||
extruder.propertyChanged.connect(self._onSettingChanged)
|
extruder.propertyChanged.connect(self._onSettingChanged)
|
||||||
extruder.containersChanged.connect(self._onChanged)
|
extruder.containersChanged.connect(self._onChanged)
|
||||||
self._onChanged()
|
self._onChanged()
|
||||||
|
|
|
@ -76,7 +76,9 @@ class ModelChecker(QObject, Extension):
|
||||||
|
|
||||||
# This function can be triggered in the middle of a machine change, so do not proceed if the machine change
|
# This function can be triggered in the middle of a machine change, so do not proceed if the machine change
|
||||||
# has not done yet.
|
# has not done yet.
|
||||||
if str(node_extruder_position) not in global_container_stack.extruders:
|
try:
|
||||||
|
extruder = global_container_stack.extruderList[int(node_extruder_position)]
|
||||||
|
except IndexError:
|
||||||
Application.getInstance().callLater(lambda: self.onChanged.emit())
|
Application.getInstance().callLater(lambda: self.onChanged.emit())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -131,9 +133,9 @@ class ModelChecker(QObject, Extension):
|
||||||
|
|
||||||
material_shrinkage = {}
|
material_shrinkage = {}
|
||||||
# Get all shrinkage values of materials used
|
# Get all shrinkage values of materials used
|
||||||
for extruder_position, extruder in global_container_stack.extruders.items():
|
for extruder_position, extruder in enumerate(global_container_stack.extruderList):
|
||||||
shrinkage = extruder.material.getProperty("material_shrinkage_percentage", "value")
|
shrinkage = extruder.material.getProperty("material_shrinkage_percentage", "value")
|
||||||
if shrinkage is None:
|
if shrinkage is None:
|
||||||
shrinkage = 0
|
shrinkage = 0
|
||||||
material_shrinkage[extruder_position] = shrinkage
|
material_shrinkage[str(extruder_position)] = shrinkage
|
||||||
return material_shrinkage
|
return material_shrinkage
|
||||||
|
|
|
@ -57,9 +57,12 @@ class SolidView(View):
|
||||||
# As the rendering is called a *lot* we really, dont want to re-evaluate the property every time. So we store em!
|
# As the rendering is called a *lot* we really, dont want to re-evaluate the property every time. So we store em!
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
support_extruder_nr = global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr")
|
support_extruder_nr = int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
|
||||||
support_angle_stack = global_container_stack.extruders.get(str(support_extruder_nr))
|
try:
|
||||||
if support_angle_stack:
|
support_angle_stack = global_container_stack.extruderList[support_extruder_nr]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
self._support_angle = support_angle_stack.getProperty("support_angle", "value")
|
self._support_angle = support_angle_stack.getProperty("support_angle", "value")
|
||||||
|
|
||||||
def beginRendering(self):
|
def beginRendering(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue