mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
CURA-4400 introduced value -1 for extruder number setting (not optional_extruder); this one takes the defaultExtruderPosition in MachineManager
This commit is contained in:
parent
2538c689f1
commit
53ec846436
6 changed files with 56 additions and 31 deletions
|
@ -241,6 +241,13 @@ class ExtruderManager(QObject):
|
||||||
result.append(extruder_stack.getProperty(setting_key, prop))
|
result.append(extruder_stack.getProperty(setting_key, prop))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def extruderValueWithDefault(self, value):
|
||||||
|
machine_manager = self._application.getMachineManager()
|
||||||
|
if value == "-1":
|
||||||
|
return machine_manager.defaultExtruderPosition
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
## Gets the extruder stacks that are actually being used at the moment.
|
## Gets the extruder stacks that are actually being used at the moment.
|
||||||
#
|
#
|
||||||
# An extruder stack is being used if it is the extruder to print any mesh
|
# An extruder stack is being used if it is the extruder to print any mesh
|
||||||
|
@ -252,7 +259,7 @@ class ExtruderManager(QObject):
|
||||||
#
|
#
|
||||||
# \return A list of extruder stacks.
|
# \return A list of extruder stacks.
|
||||||
def getUsedExtruderStacks(self) -> List["ContainerStack"]:
|
def getUsedExtruderStacks(self) -> List["ContainerStack"]:
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = self._application.getGlobalContainerStack()
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
used_extruder_stack_ids = set()
|
used_extruder_stack_ids = set()
|
||||||
|
@ -302,16 +309,19 @@ class ExtruderManager(QObject):
|
||||||
|
|
||||||
# Check support extruders
|
# Check support extruders
|
||||||
if support_enabled:
|
if support_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("support_infill_extruder_nr", "value"))])
|
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_infill_extruder_nr", "value")))])
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("support_extruder_nr_layer_0", "value"))])
|
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_extruder_nr_layer_0", "value")))])
|
||||||
if support_bottom_enabled:
|
if support_bottom_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("support_bottom_extruder_nr", "value"))])
|
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_bottom_extruder_nr", "value")))])
|
||||||
if support_roof_enabled:
|
if support_roof_enabled:
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("support_roof_extruder_nr", "value"))])
|
used_extruder_stack_ids.add(self.extruderIds[self.extruderValueWithDefault(str(global_stack.getProperty("support_roof_extruder_nr", "value")))])
|
||||||
|
|
||||||
# The platform adhesion extruder. Not used if using none.
|
# The platform adhesion extruder. Not used if using none.
|
||||||
if global_stack.getProperty("adhesion_type", "value") != "none":
|
if global_stack.getProperty("adhesion_type", "value") != "none":
|
||||||
used_extruder_stack_ids.add(self.extruderIds[str(global_stack.getProperty("adhesion_extruder_nr", "value"))])
|
extruder_nr = str(global_stack.getProperty("adhesion_extruder_nr", "value"))
|
||||||
|
if extruder_nr == "-1":
|
||||||
|
extruder_nr = Application.getInstance().getMachineManager().defaultExtruderPosition
|
||||||
|
used_extruder_stack_ids.add(self.extruderIds[extruder_nr])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids]
|
return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids]
|
||||||
|
|
|
@ -699,7 +699,6 @@ class MachineManager(QObject):
|
||||||
return containers[0].definition.getId()
|
return containers[0].definition.getId()
|
||||||
|
|
||||||
## Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed
|
## Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed
|
||||||
# \return if any properties has been added
|
|
||||||
def correctExtruderSettings(self):
|
def correctExtruderSettings(self):
|
||||||
extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
||||||
|
|
||||||
|
@ -717,22 +716,6 @@ class MachineManager(QObject):
|
||||||
self._global_container_stack.userChanges.removeInstance(setting_key)
|
self._global_container_stack.userChanges.removeInstance(setting_key)
|
||||||
Logger.log("d", "Reset [%s] because its old value [%s] is no longer valid (2)", setting_key, old_value)
|
Logger.log("d", "Reset [%s] because its old value [%s] is no longer valid (2)", setting_key, old_value)
|
||||||
|
|
||||||
added_properties = False
|
|
||||||
for setting_key in self._global_container_stack.definition.getAllKeys():
|
|
||||||
if not self._global_container_stack.getProperty(setting_key, "type") in ("extruder", "optional_extruder"):
|
|
||||||
continue
|
|
||||||
current_value = self._global_container_stack.getProperty(setting_key, "value")
|
|
||||||
if current_value is None:
|
|
||||||
continue
|
|
||||||
if current_value == "-1":
|
|
||||||
continue
|
|
||||||
if not self._global_container_stack.extruders[str(current_value)].isEnabled:
|
|
||||||
self._global_container_stack.userChanges.setProperty(setting_key, "value", str(self._default_extruder_position))
|
|
||||||
added_properties = True
|
|
||||||
Logger.log("d", "Change [%s] to [%s] because its value [%s] is not valid", setting_key, self._default_extruder_position, current_value)
|
|
||||||
|
|
||||||
return added_properties
|
|
||||||
|
|
||||||
## Set the amount of extruders on the active machine (global stack)
|
## Set the amount of extruders on the active machine (global stack)
|
||||||
# \param extruder_count int the number of extruders to set
|
# \param extruder_count int the number of extruders to set
|
||||||
def setActiveMachineExtruderCount(self, extruder_count):
|
def setActiveMachineExtruderCount(self, extruder_count):
|
||||||
|
|
|
@ -91,6 +91,8 @@ class CuraEngineBackend(QObject, Backend):
|
||||||
self._onGlobalStackChanged()
|
self._onGlobalStackChanged()
|
||||||
|
|
||||||
Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished)
|
Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished)
|
||||||
|
# extruder enable / disable. Actually wanted to use machine manager here, but the initialization order causes it to crash
|
||||||
|
ExtruderManager.getInstance().extrudersChanged.connect(self._extruderChanged)
|
||||||
|
|
||||||
# A flag indicating if an error check was scheduled
|
# A flag indicating if an error check was scheduled
|
||||||
# If so, we will stop the auto-slice timer and start upon the error check
|
# If so, we will stop the auto-slice timer and start upon the error check
|
||||||
|
@ -773,3 +775,9 @@ class CuraEngineBackend(QObject, Backend):
|
||||||
def tickle(self):
|
def tickle(self):
|
||||||
if self._use_timer:
|
if self._use_timer:
|
||||||
self._change_timer.start()
|
self._change_timer.start()
|
||||||
|
|
||||||
|
def _extruderChanged(self):
|
||||||
|
for build_plate_number in range(Application.getInstance().getMultiBuildPlateModel().maxBuildPlate + 1):
|
||||||
|
if build_plate_number not in self._build_plates_to_be_sliced:
|
||||||
|
self._build_plates_to_be_sliced.append(build_plate_number)
|
||||||
|
self._invokeSlice()
|
||||||
|
|
|
@ -280,9 +280,15 @@ class StartSliceJob(Job):
|
||||||
# \return A dictionary of replacement tokens to the values they should be
|
# \return A dictionary of replacement tokens to the values they should be
|
||||||
# replaced with.
|
# replaced with.
|
||||||
def _buildReplacementTokens(self, stack) -> dict:
|
def _buildReplacementTokens(self, stack) -> dict:
|
||||||
|
default_extruder_position = Application.getInstance().getMachineManager().defaultExtruderPosition
|
||||||
result = {}
|
result = {}
|
||||||
for key in stack.getAllKeys():
|
for key in stack.getAllKeys():
|
||||||
result[key] = stack.getProperty(key, "value")
|
setting_type = stack.getProperty(key, "type")
|
||||||
|
value = stack.getProperty(key, "value")
|
||||||
|
if setting_type == "extruder" and value == "-1":
|
||||||
|
# replace with the default value
|
||||||
|
value = default_extruder_position
|
||||||
|
result[key] = value
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
result["print_bed_temperature"] = result["material_bed_temperature"] # Renamed settings.
|
result["print_bed_temperature"] = result["material_bed_temperature"] # Renamed settings.
|
||||||
|
|
|
@ -3458,7 +3458,7 @@
|
||||||
"label": "Support Extruder",
|
"label": "Support Extruder",
|
||||||
"description": "The extruder train to use for printing the support. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the support. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
"settable_per_extruder": false,
|
"settable_per_extruder": false,
|
||||||
|
@ -3468,7 +3468,7 @@
|
||||||
"label": "Support Infill Extruder",
|
"label": "Support Infill Extruder",
|
||||||
"description": "The extruder train to use for printing the infill of the support. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the infill of the support. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"value": "support_extruder_nr",
|
"value": "support_extruder_nr",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
|
@ -3479,7 +3479,7 @@
|
||||||
"label": "First Layer Support Extruder",
|
"label": "First Layer Support Extruder",
|
||||||
"description": "The extruder train to use for printing the first layer of support infill. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the first layer of support infill. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"value": "support_extruder_nr",
|
"value": "support_extruder_nr",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
|
@ -3490,7 +3490,7 @@
|
||||||
"label": "Support Interface Extruder",
|
"label": "Support Interface Extruder",
|
||||||
"description": "The extruder train to use for printing the roofs and floors of the support. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the roofs and floors of the support. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"value": "support_extruder_nr",
|
"value": "support_extruder_nr",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
|
@ -3502,7 +3502,7 @@
|
||||||
"label": "Support Roof Extruder",
|
"label": "Support Roof Extruder",
|
||||||
"description": "The extruder train to use for printing the roofs of the support. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the roofs of the support. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"value": "support_interface_extruder_nr",
|
"value": "support_interface_extruder_nr",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
|
@ -3513,7 +3513,7 @@
|
||||||
"label": "Support Floor Extruder",
|
"label": "Support Floor Extruder",
|
||||||
"description": "The extruder train to use for printing the floors of the support. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the floors of the support. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"value": "support_interface_extruder_nr",
|
"value": "support_interface_extruder_nr",
|
||||||
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
"enabled": "(support_enable or support_tree_enable) and machine_extruder_count > 1",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
|
@ -4184,7 +4184,7 @@
|
||||||
"label": "Build Plate Adhesion Extruder",
|
"label": "Build Plate Adhesion Extruder",
|
||||||
"description": "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.",
|
"description": "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.",
|
||||||
"type": "extruder",
|
"type": "extruder",
|
||||||
"default_value": "0",
|
"default_value": "-1",
|
||||||
"enabled": "machine_extruder_count > 1 and resolveOrValue('adhesion_type') != 'none'",
|
"enabled": "machine_extruder_count > 1 and resolveOrValue('adhesion_type') != 'none'",
|
||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
"settable_per_extruder": false
|
"settable_per_extruder": false
|
||||||
|
|
|
@ -72,6 +72,24 @@ SettingItem
|
||||||
value: control.currentText != "" ? control.model.getItem(control.currentIndex).color : ""
|
value: control.currentText != "" ? control.model.getItem(control.currentIndex).color : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binding
|
||||||
|
{
|
||||||
|
target: control
|
||||||
|
property: "currentIndex"
|
||||||
|
value:
|
||||||
|
{
|
||||||
|
if(propertyProvider.properties.value == -1)
|
||||||
|
{
|
||||||
|
// TODO: accidently the extruder position is also the index. fix it
|
||||||
|
return Cura.MachineManager.defaultExtruderPosition;
|
||||||
|
}
|
||||||
|
return propertyProvider.properties.value
|
||||||
|
}
|
||||||
|
// Sometimes when the value is already changed, the model is still being built.
|
||||||
|
// The when clause ensures that the current index is not updated when this happens.
|
||||||
|
when: control.model.items.length > 0
|
||||||
|
}
|
||||||
|
|
||||||
indicator: UM.RecolorImage
|
indicator: UM.RecolorImage
|
||||||
{
|
{
|
||||||
id: downArrow
|
id: downArrow
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue