mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Handle empty hotend and material in config syncing
CURA-5693 - Disable an extruder if the config states no material or nozzle for it. - Show a warning message if an used extruder gets disabled.
This commit is contained in:
parent
3dcb6b9c37
commit
b70e9c9080
2 changed files with 49 additions and 20 deletions
|
@ -107,17 +107,19 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
# that signal. Application.globalContainerStackChanged doesn't fill this
|
# that signal. Application.globalContainerStackChanged doesn't fill this
|
||||||
# signal; it's assumed to be the current printer in that case.
|
# signal; it's assumed to be the current printer in that case.
|
||||||
def _extrudersChanged(self, machine_id = None):
|
def _extrudersChanged(self, machine_id = None):
|
||||||
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
if machine_id is not None:
|
if machine_id is not None:
|
||||||
if Application.getInstance().getGlobalContainerStack() is None:
|
if machine_manager.activeMachine is None:
|
||||||
# No machine, don't need to update the current machine's extruders
|
# No machine, don't need to update the current machine's extruders
|
||||||
return
|
return
|
||||||
if machine_id != Application.getInstance().getGlobalContainerStack().getId():
|
if machine_id != machine_manager.activeMachine.getId():
|
||||||
# Not the current machine
|
# Not the current machine
|
||||||
return
|
return
|
||||||
|
|
||||||
# Unlink from old extruders
|
# Unlink from old extruders
|
||||||
for extruder in self._active_machine_extruders:
|
for extruder in self._active_machine_extruders:
|
||||||
extruder.containersChanged.disconnect(self._onExtruderStackContainersChanged)
|
extruder.containersChanged.disconnect(self._onExtruderStackContainersChanged)
|
||||||
|
extruder.enabledChanged.disconnect(self._updateExtruders)
|
||||||
|
|
||||||
# Link to new extruders
|
# Link to new extruders
|
||||||
self._active_machine_extruders = []
|
self._active_machine_extruders = []
|
||||||
|
@ -126,6 +128,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
if extruder is None: #This extruder wasn't loaded yet. This happens asynchronously while this model is constructed from QML.
|
if extruder is None: #This extruder wasn't loaded yet. This happens asynchronously while this model is constructed from QML.
|
||||||
continue
|
continue
|
||||||
extruder.containersChanged.connect(self._onExtruderStackContainersChanged)
|
extruder.containersChanged.connect(self._onExtruderStackContainersChanged)
|
||||||
|
extruder.enabledChanged.connect(self._updateExtruders)
|
||||||
self._active_machine_extruders.append(extruder)
|
self._active_machine_extruders.append(extruder)
|
||||||
|
|
||||||
self._updateExtruders() # Since the new extruders may have different properties, update our own model.
|
self._updateExtruders() # Since the new extruders may have different properties, update our own model.
|
||||||
|
|
|
@ -117,10 +117,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
self._application.callLater(self.setInitialActiveMachine)
|
self._application.callLater(self.setInitialActiveMachine)
|
||||||
|
|
||||||
self._material_incompatible_message = Message(catalog.i18nc("@info:status",
|
|
||||||
"The selected material is incompatible with the selected machine or configuration."),
|
|
||||||
title = catalog.i18nc("@info:title", "Incompatible Material")) # type: Message
|
|
||||||
|
|
||||||
containers = CuraContainerRegistry.getInstance().findInstanceContainers(id = self.activeMaterialId) # type: List[InstanceContainer]
|
containers = CuraContainerRegistry.getInstance().findInstanceContainers(id = self.activeMaterialId) # type: List[InstanceContainer]
|
||||||
if containers:
|
if containers:
|
||||||
containers[0].nameChanged.connect(self._onMaterialNameChanged)
|
containers[0].nameChanged.connect(self._onMaterialNameChanged)
|
||||||
|
@ -1369,25 +1365,47 @@ class MachineManager(QObject):
|
||||||
self.blurSettings.emit()
|
self.blurSettings.emit()
|
||||||
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
|
||||||
self.switchPrinterType(configuration.printerType)
|
self.switchPrinterType(configuration.printerType)
|
||||||
|
|
||||||
|
used_extruder_stack_list = ExtruderManager.getInstance().getUsedExtruderStacks()
|
||||||
|
used_extruder_position_set = {es.getMetaDataEntry("position") for es in used_extruder_stack_list}
|
||||||
|
disabled_used_extruder_position_set = set()
|
||||||
|
|
||||||
|
# If an extruder that's currently used to print a model gets disabled due to the syncing, we need to show
|
||||||
|
# a message explaining why.
|
||||||
|
need_to_show_message = False
|
||||||
|
|
||||||
for extruder_configuration in configuration.extruderConfigurations:
|
for extruder_configuration in configuration.extruderConfigurations:
|
||||||
position = str(extruder_configuration.position)
|
position = str(extruder_configuration.position)
|
||||||
variant_container_node = self._variant_manager.getVariantNode(self._global_container_stack.definition.getId(), extruder_configuration.hotendID)
|
|
||||||
material_container_node = self._material_manager.getMaterialNodeByType(self._global_container_stack,
|
|
||||||
position,
|
|
||||||
extruder_configuration.hotendID,
|
|
||||||
configuration.buildplateConfiguration,
|
|
||||||
extruder_configuration.material.guid)
|
|
||||||
|
|
||||||
if variant_container_node:
|
extruder_has_hotend = extruder_configuration.hotendID != ""
|
||||||
self._setVariantNode(position, variant_container_node)
|
extruder_has_material = extruder_configuration.material.guid != ""
|
||||||
else:
|
|
||||||
self._global_container_stack.extruders[position].variant = empty_variant_container
|
# If the machine doesn't have a hotend or material, disable this extruder
|
||||||
|
if not extruder_has_hotend or not extruder_has_material:
|
||||||
|
self._global_container_stack.extruders[position].setEnabled(False)
|
||||||
|
if position in used_extruder_position_set:
|
||||||
|
need_to_show_message = True
|
||||||
|
disabled_used_extruder_position_set.add(int(position))
|
||||||
|
|
||||||
if material_container_node:
|
|
||||||
self._setMaterial(position, material_container_node)
|
|
||||||
else:
|
else:
|
||||||
self._global_container_stack.extruders[position].material = empty_material_container
|
variant_container_node = self._variant_manager.getVariantNode(self._global_container_stack.definition.getId(),
|
||||||
self.updateMaterialWithVariant(position)
|
extruder_configuration.hotendID)
|
||||||
|
material_container_node = self._material_manager.getMaterialNodeByType(self._global_container_stack,
|
||||||
|
position,
|
||||||
|
extruder_configuration.hotendID,
|
||||||
|
configuration.buildplateConfiguration,
|
||||||
|
extruder_configuration.material.guid)
|
||||||
|
if variant_container_node:
|
||||||
|
self._setVariantNode(position, variant_container_node)
|
||||||
|
else:
|
||||||
|
self._global_container_stack.extruders[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.updateMaterialWithVariant(position)
|
||||||
|
|
||||||
if configuration.buildplateConfiguration is not None:
|
if configuration.buildplateConfiguration is not None:
|
||||||
global_variant_container_node = self._variant_manager.getBuildplateVariantNode(self._global_container_stack.definition.getId(), configuration.buildplateConfiguration)
|
global_variant_container_node = self._variant_manager.getBuildplateVariantNode(self._global_container_stack.definition.getId(), configuration.buildplateConfiguration)
|
||||||
|
@ -1399,6 +1417,14 @@ class MachineManager(QObject):
|
||||||
self._global_container_stack.variant = empty_variant_container
|
self._global_container_stack.variant = empty_variant_container
|
||||||
self._updateQualityWithMaterial()
|
self._updateQualityWithMaterial()
|
||||||
|
|
||||||
|
if need_to_show_message:
|
||||||
|
msg_str = "Extruder {extruders} is disabled because there is no material loaded. Please load a material or use custom configurations."
|
||||||
|
extruders_str = ", ".join(str(x) for x in sorted(disabled_used_extruder_position_set))
|
||||||
|
msg_str = msg_str.format(extruders = extruders_str)
|
||||||
|
message = Message(catalog.i18nc("@info:status", msg_str),
|
||||||
|
title = catalog.i18nc("@info:title", "Extruders Disabled"))
|
||||||
|
message.show()
|
||||||
|
|
||||||
# See if we need to show the Discard or Keep changes screen
|
# See if we need to show the Discard or Keep changes screen
|
||||||
if self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1:
|
if self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1:
|
||||||
self._application.discardOrKeepProfileChanges()
|
self._application.discardOrKeepProfileChanges()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue