Adapting the code in case a multiextruder printer will use only one extruder - CURA-4359

This commit is contained in:
Diego Prado Gesto 2017-09-26 17:49:53 +02:00
parent 28aadc1b05
commit 568535e3e2
4 changed files with 40 additions and 18 deletions

View file

@ -506,7 +506,7 @@ class ExtruderManager(QObject):
result.extend(self.getActiveExtruderStacks()) result.extend(self.getActiveExtruderStacks())
return result return result
## Returns the list of active extruder stacks. ## Returns the list of active extruder stacks, taking into account the machine extruder count.
# #
# \return \type{List[ContainerStack]} a list of # \return \type{List[ContainerStack]} a list of
def getActiveExtruderStacks(self) -> List["ExtruderStack"]: def getActiveExtruderStacks(self) -> List["ExtruderStack"]:
@ -516,7 +516,8 @@ class ExtruderManager(QObject):
if global_stack and global_stack.getId() in self._extruder_trains: if global_stack and global_stack.getId() in self._extruder_trains:
for extruder in sorted(self._extruder_trains[global_stack.getId()]): for extruder in sorted(self._extruder_trains[global_stack.getId()]):
result.append(self._extruder_trains[global_stack.getId()][extruder]) result.append(self._extruder_trains[global_stack.getId()][extruder])
return result
return result[:global_stack.getProperty("machine_extruder_count", "value")]
def __globalContainerStackChanged(self) -> None: def __globalContainerStackChanged(self) -> None:
global_container_stack = Application.getInstance().getGlobalContainerStack() global_container_stack = Application.getInstance().getGlobalContainerStack()

View file

@ -92,13 +92,22 @@ class ProfilesModel(InstanceContainersModel):
if global_container_stack is None: if global_container_stack is None:
return return
# Detecting if the machine has multiple extrusion
multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
# Get the list of extruders and place the selected extruder at the front of the list. # Get the list of extruders and place the selected extruder at the front of the list.
extruder_manager = ExtruderManager.getInstance() extruder_manager = ExtruderManager.getInstance()
active_extruder = extruder_manager.getActiveExtruderStack() active_extruder = extruder_manager.getActiveExtruderStack()
extruder_stacks = extruder_manager.getActiveExtruderStacks() extruder_stacks = extruder_manager.getActiveExtruderStacks()
if active_extruder in extruder_stacks: if extruder_stacks:
extruder_stacks.remove(active_extruder) if multiple_extrusion:
extruder_stacks = [active_extruder] + extruder_stacks # 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 = []
# Get a list of usable/available qualities for this machine and material # Get a list of usable/available qualities for this machine and material
qualities = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, qualities = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,

View file

@ -26,15 +26,21 @@ class QualityAndUserProfilesModel(ProfilesModel):
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition) quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
# Detecting if the machine has multiple extrusion # Detecting if the machine has multiple extrusion
multiple_extrusion = False multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
# Get the list of extruders and place the selected extruder at the front of the list. # Get the list of extruders
extruder_manager = ExtruderManager.getInstance() extruder_manager = ExtruderManager.getInstance()
active_extruder = extruder_manager.getActiveExtruderStack() active_extruder = extruder_manager.getActiveExtruderStack()
extruder_stacks = extruder_manager.getActiveExtruderStacks() extruder_stacks = extruder_manager.getActiveExtruderStacks()
if active_extruder in extruder_stacks: if extruder_stacks:
multiple_extrusion = True if multiple_extrusion:
extruder_stacks.remove(active_extruder) # Place the active extruder at the front of the list.
extruder_stacks = [active_extruder] + extruder_stacks 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 = []
# Fetch the list of useable qualities across all extruders. # Fetch the list of useable qualities across all extruders.
# The actual list of quality profiles come from the first extruder in the extruder list. # The actual list of quality profiles come from the first extruder in the extruder list.
@ -49,6 +55,6 @@ class QualityAndUserProfilesModel(ProfilesModel):
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") == active_extruder.definition.getId()]
else: else:
# If not, the quality changes of the global stack are selected # 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] 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 return quality_list + filtered_quality_changes

View file

@ -26,15 +26,21 @@ class UserProfilesModel(ProfilesModel):
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition) quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
# Detecting if the machine has multiple extrusion # Detecting if the machine has multiple extrusion
multiple_extrusion = False multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
# Get the list of extruders and place the selected extruder at the front of the list. # Get the list of extruders and place the selected extruder at the front of the list.
extruder_manager = ExtruderManager.getInstance() extruder_manager = ExtruderManager.getInstance()
active_extruder = extruder_manager.getActiveExtruderStack() active_extruder = extruder_manager.getActiveExtruderStack()
extruder_stacks = extruder_manager.getActiveExtruderStacks() extruder_stacks = extruder_manager.getActiveExtruderStacks()
if active_extruder in extruder_stacks: if extruder_stacks:
multiple_extrusion = True if multiple_extrusion:
extruder_stacks.remove(active_extruder) # Place the active extruder at the front of the list.
extruder_stacks = [active_extruder] + extruder_stacks 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 = []
# Fetch the list of useable qualities across all extruders. # Fetch the list of useable qualities across all extruders.
# The actual list of quality profiles come from the first extruder in the extruder list. # The actual list of quality profiles come from the first extruder in the extruder list.
@ -49,6 +55,6 @@ class UserProfilesModel(ProfilesModel):
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") == active_extruder.definition.getId()]
else: else:
# If not, the quality changes of the global stack are selected # 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] 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 return filtered_quality_changes