diff options
author | Jaime van Kessel <nallath@gmail.com> | 2017-09-29 16:17:11 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2017-09-29 16:17:11 +0300 |
commit | 437da52f6599b85758cfce4ce30e196b09fb62ae (patch) | |
tree | 35bbd1958d553f0c61c16a1d4dc639eae93d88e3 /cura | |
parent | 0912348cbe7888a15fc69d576e711d3870232126 (diff) | |
parent | 402617af1ea9dedfa53b68cd49c65c7628bd5486 (diff) |
Merge branch 'fix_multiple_extruder_issues' of github.com:Ultimaker/Cura into 3.0
Diffstat (limited to 'cura')
-rwxr-xr-x | cura/Settings/ExtruderManager.py | 30 | ||||
-rwxr-xr-x | cura/Settings/MachineManager.py | 14 | ||||
-rw-r--r-- | cura/Settings/ProfilesModel.py | 14 | ||||
-rw-r--r-- | cura/Settings/QualityAndUserProfilesModel.py | 22 | ||||
-rw-r--r-- | cura/Settings/UserProfilesModel.py | 22 |
5 files changed, 60 insertions, 42 deletions
diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 93e781cd5e..9e17ce028d 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -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 = 0 + 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,14 +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() + 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: @@ -513,17 +517,33 @@ class ExtruderManager(QObject): global_stack = Application.getInstance().getGlobalContainerStack() result = [] + machine_extruder_count = global_stack.getProperty("machine_extruder_count", "value") + + # 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: for extruder in sorted(self._extruder_trains[global_stack.getId()]): result.append(self._extruder_trains[global_stack.getId()][extruder]) - return result[:global_stack.getProperty("machine_extruder_count", "value")] + return result[:machine_extruder_count] def __globalContainerStackChanged(self) -> None: global_container_stack = Application.getInstance().getGlobalContainerStack() 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() diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 4a321d0529..82edebec60 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -271,7 +271,6 @@ class MachineManager(QObject): extruder_stack.containersChanged.disconnect(self._onInstanceContainersChanged) self._global_container_stack = Application.getInstance().getGlobalContainerStack() - self._active_container_stack = self._global_container_stack self.globalContainerChanged.emit() @@ -303,6 +302,9 @@ class MachineManager(QObject): quality = self._global_container_stack.quality quality.nameChanged.connect(self._onQualityNameChanged) + + self._active_container_stack = self._global_container_stack + self._error_check_timer.start() ## Update self._stacks_valid according to _checkStacksForErrors and emit if change. @@ -543,16 +545,22 @@ 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 = {} active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks() - if active_stacks is not None: #If we have a global stack. + + result[self._global_container_stack.getId()] = self._global_container_stack.material.getId() + + if active_stacks is not None: # If we have extruder stacks for stack in active_stacks: material_container = stack.material if not material_container: continue - result[stack.getId()] = material_container.getId() return result diff --git a/cura/Settings/ProfilesModel.py b/cura/Settings/ProfilesModel.py index 2600645b91..331292e255 100644 --- a/cura/Settings/ProfilesModel.py +++ b/cura/Settings/ProfilesModel.py @@ -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,
diff --git a/cura/Settings/QualityAndUserProfilesModel.py b/cura/Settings/QualityAndUserProfilesModel.py index 6b898b4934..51b4c1bb1a 100644 --- a/cura/Settings/QualityAndUserProfilesModel.py +++ b/cura/Settings/QualityAndUserProfilesModel.py @@ -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.
@@ -52,9 +46,13 @@ 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") == active_extruder.definition.getId()]
+ 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 quality_list + filtered_quality_changes
diff --git a/cura/Settings/UserProfilesModel.py b/cura/Settings/UserProfilesModel.py index 1979a59e27..b9710f7df2 100644 --- a/cura/Settings/UserProfilesModel.py +++ b/cura/Settings/UserProfilesModel.py @@ -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.getId()]
+ 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
|