mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 13:49:39 +08:00
Merge branch 'fix_multiple_extruder_issues' of github.com:Ultimaker/Cura into fix_multiple_extruder_issues
This commit is contained in:
commit
0900a0ff07
@ -41,7 +41,7 @@ class ExtruderManager(QObject):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
||||
self._active_extruder_index = -1
|
||||
self._active_extruder_index = -1 # Indicates the index of the active extruder stack. -1 means no active extruder stack
|
||||
self._selected_object_extruders = []
|
||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||
self._global_container_stack_definition_id = None
|
||||
@ -74,15 +74,18 @@ class ExtruderManager(QObject):
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
## Gets a dict with the extruder stack ids with the extruder number as the key.
|
||||
# The key "-1" indicates the global stack id.
|
||||
#
|
||||
@pyqtProperty("QVariantMap", notify = extrudersChanged)
|
||||
def extruderIds(self):
|
||||
map = {}
|
||||
extruder_stack_ids = {}
|
||||
global_stack_id = Application.getInstance().getGlobalContainerStack().getId()
|
||||
map["-1"] = global_stack_id
|
||||
extruder_stack_ids["-1"] = global_stack_id
|
||||
if global_stack_id in self._extruder_trains:
|
||||
for position in self._extruder_trains[global_stack_id]:
|
||||
map[position] = self._extruder_trains[global_stack_id][position].getId()
|
||||
return map
|
||||
extruder_stack_ids[position] = self._extruder_trains[global_stack_id][position].getId()
|
||||
return extruder_stack_ids
|
||||
|
||||
@pyqtSlot(str, result = str)
|
||||
def getQualityChangesIdByExtruderStackId(self, id: str) -> str:
|
||||
@ -516,7 +519,8 @@ class ExtruderManager(QObject):
|
||||
result = []
|
||||
machine_extruder_count = global_stack.getProperty("machine_extruder_count", "value")
|
||||
|
||||
if machine_extruder_count is 1:
|
||||
# In case the printer is using one extruder, shouldn't exist active extruder stacks
|
||||
if machine_extruder_count == 1:
|
||||
return result
|
||||
|
||||
if global_stack and global_stack.getId() in self._extruder_trains:
|
||||
@ -530,6 +534,16 @@ class ExtruderManager(QObject):
|
||||
if global_container_stack and global_container_stack.getBottom() and global_container_stack.getBottom().getId() != self._global_container_stack_definition_id:
|
||||
self._global_container_stack_definition_id = global_container_stack.getBottom().getId()
|
||||
self.globalContainerStackDefinitionChanged.emit()
|
||||
|
||||
# If the global container changed, the number of extruders could be changed and so the active_extruder_index is updated
|
||||
extruder_count = global_container_stack.getProperty("machine_extruder_count", "value")
|
||||
if extruder_count > 1:
|
||||
if self._active_extruder_index == -1:
|
||||
self.setActiveExtruderIndex(0)
|
||||
else:
|
||||
if self._active_extruder_index != -1:
|
||||
self.setActiveExtruderIndex(-1)
|
||||
|
||||
self.activeExtruderChanged.emit()
|
||||
|
||||
self.resetSelectedObjectExtruders()
|
||||
|
@ -545,6 +545,10 @@ class MachineManager(QObject):
|
||||
|
||||
return result
|
||||
|
||||
## Gets a dict with the active materials ids set in all extruder stacks and the global stack
|
||||
# (when there is one extruder, the material is set in the global stack)
|
||||
#
|
||||
# \return The material ids in all stacks
|
||||
@pyqtProperty("QVariantMap", notify = activeMaterialChanged)
|
||||
def allActiveMaterialIds(self) -> Dict[str, str]:
|
||||
result = {}
|
||||
|
@ -98,16 +98,10 @@ class ProfilesModel(InstanceContainersModel):
|
||||
extruder_manager = ExtruderManager.getInstance()
|
||||
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||
if extruder_stacks:
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
if active_extruder in extruder_stacks:
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
else:
|
||||
# The active extruder is the first in the list and only the active extruder is use to compute the usable qualities
|
||||
active_extruder = None
|
||||
extruder_stacks = []
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
|
||||
# Get a list of usable/available qualities for this machine and material
|
||||
qualities = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||
|
@ -31,16 +31,10 @@ class QualityAndUserProfilesModel(ProfilesModel):
|
||||
extruder_manager = ExtruderManager.getInstance()
|
||||
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||
if extruder_stacks:
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
if active_extruder in extruder_stacks:
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
else:
|
||||
# The active extruder is the first in the list and only the active extruder is use to compute the usable qualities
|
||||
active_extruder = None
|
||||
extruder_stacks = []
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
|
||||
# Fetch the list of useable qualities across all extruders.
|
||||
# The actual list of quality profiles come from the first extruder in the extruder list.
|
||||
@ -53,6 +47,7 @@ class QualityAndUserProfilesModel(ProfilesModel):
|
||||
if multiple_extrusion:
|
||||
# If the printer has multiple extruders then quality changes related to the current extruder are kept
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is not None and
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId()]
|
||||
else:
|
||||
|
@ -31,16 +31,10 @@ class UserProfilesModel(ProfilesModel):
|
||||
extruder_manager = ExtruderManager.getInstance()
|
||||
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||
if extruder_stacks:
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
if active_extruder in extruder_stacks:
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
else:
|
||||
# The active extruder is the first in the list and only the active extruder is use to compute the usable qualities
|
||||
active_extruder = None
|
||||
extruder_stacks = []
|
||||
if multiple_extrusion:
|
||||
# Place the active extruder at the front of the list.
|
||||
extruder_stacks.remove(active_extruder)
|
||||
extruder_stacks = [active_extruder] + extruder_stacks
|
||||
|
||||
# Fetch the list of useable qualities across all extruders.
|
||||
# The actual list of quality profiles come from the first extruder in the extruder list.
|
||||
@ -52,9 +46,13 @@ class UserProfilesModel(ProfilesModel):
|
||||
|
||||
if multiple_extrusion:
|
||||
# If the printer has multiple extruders then quality changes related to the current extruder are kept
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition")]
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is not None and
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId()]
|
||||
else:
|
||||
# If not, the quality changes of the global stack are selected
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and qc.getMetaDataEntry("extruder") is None]
|
||||
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||
qc.getMetaDataEntry("extruder") is None]
|
||||
|
||||
return filtered_quality_changes
|
||||
|
@ -5,7 +5,8 @@
|
||||
"inherits": "fdmextruder",
|
||||
"metadata": {
|
||||
"machine": "ultimaker3_extended",
|
||||
"position": "0"
|
||||
"position": "0",
|
||||
"quality_definition": "ultimaker3_extruder_left"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -5,7 +5,8 @@
|
||||
"inherits": "fdmextruder",
|
||||
"metadata": {
|
||||
"machine": "ultimaker3_extended",
|
||||
"position": "1"
|
||||
"position": "1",
|
||||
"quality_definition": "ultimaker3_extruder_right"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -5,7 +5,8 @@
|
||||
"inherits": "fdmextruder",
|
||||
"metadata": {
|
||||
"machine": "ultimaker3",
|
||||
"position": "0"
|
||||
"position": "0",
|
||||
"quality_definition": "ultimaker3_extruder_left"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -5,7 +5,8 @@
|
||||
"inherits": "fdmextruder",
|
||||
"metadata": {
|
||||
"machine": "ultimaker3",
|
||||
"position": "1"
|
||||
"position": "1",
|
||||
"quality_definition": "ultimaker3_extruder_right"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
|
@ -66,7 +66,15 @@ Menu
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||
onTriggered:
|
||||
{
|
||||
// This workaround is done because of the application menus for materials and variants for multiextrusion printers.
|
||||
// The extruder menu would always act on the correspoding extruder only, instead of acting on the extruder selected in the UI.
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
@ -101,7 +109,15 @@ Menu
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||
onTriggered:
|
||||
{
|
||||
// This workaround is done because of the application menus for materials and variants for multiextrusion printers.
|
||||
// The extruder menu would always act on the correspoding extruder only, instead of acting on the extruder selected in the UI.
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
||||
|
Loading…
x
Reference in New Issue
Block a user