mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 00:37:50 -06:00
Working on fixing several issues with profiles - CURA-4327
This commit is contained in:
parent
0fa3bdd68b
commit
cf94c8d37d
4 changed files with 88 additions and 30 deletions
|
@ -64,6 +64,19 @@ class QualityManager:
|
||||||
result = [quality_change for quality_change in result if quality_change.getName() == quality_changes_name]
|
result = [quality_change for quality_change in result if quality_change.getName() == quality_changes_name]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
## Fetch the list of available quality types for this machine definition.
|
||||||
|
#
|
||||||
|
# \param machine_definition \type{DefinitionContainer}
|
||||||
|
# \param material_containers \type{List[InstanceContainer]}
|
||||||
|
# \return \type{List[str]}
|
||||||
|
def findAllQualityTypesForMachine(self, machine_definition: "DefinitionContainerInterface") -> List[str]:
|
||||||
|
# Determine the common set of quality types which can be
|
||||||
|
# applied to all of the materials for this machine.
|
||||||
|
quality_type_dict = self.__fetchQualityTypeDict(machine_definition)
|
||||||
|
common_quality_types = set(quality_type_dict.keys())
|
||||||
|
|
||||||
|
return list(common_quality_types)
|
||||||
|
|
||||||
## Fetch the list of available quality types for this combination of machine definition and materials.
|
## Fetch the list of available quality types for this combination of machine definition and materials.
|
||||||
#
|
#
|
||||||
# \param machine_definition \type{DefinitionContainer}
|
# \param machine_definition \type{DefinitionContainer}
|
||||||
|
@ -91,6 +104,18 @@ class QualityManager:
|
||||||
|
|
||||||
return list(qualities)
|
return list(qualities)
|
||||||
|
|
||||||
|
## Fetches a dict of quality types names to quality profiles for a combination of machine and material.
|
||||||
|
#
|
||||||
|
# \param machine_definition \type{DefinitionContainer} the machine definition.
|
||||||
|
# \param material \type{InstanceContainer} the material.
|
||||||
|
# \return \type{Dict[str, InstanceContainer]} the dict of suitable quality type names mapping to qualities.
|
||||||
|
def __fetchQualityTypeDict(self, machine_definition: "DefinitionContainerInterface") -> Dict[str, InstanceContainer]:
|
||||||
|
qualities = self.findAllQualitiesForMachineMaterial(machine_definition, None)
|
||||||
|
quality_type_dict = {}
|
||||||
|
for quality in qualities:
|
||||||
|
quality_type_dict[quality.getMetaDataEntry("quality_type")] = quality
|
||||||
|
return quality_type_dict
|
||||||
|
|
||||||
## Fetches a dict of quality types names to quality profiles for a combination of machine and material.
|
## Fetches a dict of quality types names to quality profiles for a combination of machine and material.
|
||||||
#
|
#
|
||||||
# \param machine_definition \type{DefinitionContainer} the machine definition.
|
# \param machine_definition \type{DefinitionContainer} the machine definition.
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack is None:
|
if global_container_stack is None:
|
||||||
return []
|
return []
|
||||||
global_stack_definition = global_container_stack.getBottom()
|
# global_stack_definition = global_container_stack.getBottom()
|
||||||
|
|
||||||
# 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()
|
||||||
|
@ -64,23 +64,26 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
extruder_stacks.remove(active_extruder)
|
extruder_stacks.remove(active_extruder)
|
||||||
extruder_stacks = [active_extruder] + extruder_stacks
|
extruder_stacks = [active_extruder] + extruder_stacks
|
||||||
|
|
||||||
if ExtruderManager.getInstance().getActiveExtruderStacks():
|
# if ExtruderManager.getInstance().getActiveExtruderStacks():
|
||||||
# Multi-extruder machine detected.
|
# # Multi-extruder machine detected.
|
||||||
materials = [extruder.material for extruder in extruder_stacks]
|
# materials = [extruder.material for extruder in extruder_stacks]
|
||||||
else:
|
# else:
|
||||||
# Machine with one extruder.
|
# # Machine with one extruder.
|
||||||
materials = [global_container_stack.material]
|
# materials = [global_container_stack.material]
|
||||||
|
#
|
||||||
|
# # Fetch the list of usable qualities across all extruders.
|
||||||
|
# # The actual list of quality profiles come from the first extruder in the extruder list.
|
||||||
|
# result = QualityManager.getInstance().findAllQualitiesForMachineAndMaterials(global_stack_definition,
|
||||||
|
# materials)
|
||||||
|
#
|
||||||
|
# for quality in QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(
|
||||||
|
# global_container_stack, extruder_stacks):
|
||||||
|
# if quality not in result:
|
||||||
|
# result.append(quality)
|
||||||
|
quality_list = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||||
|
extruder_stacks)
|
||||||
|
|
||||||
# Fetch the list of usable qualities across all extruders.
|
return quality_list
|
||||||
# The actual list of quality profiles come from the first extruder in the extruder list.
|
|
||||||
result = QualityManager.getInstance().findAllQualitiesForMachineAndMaterials(global_stack_definition,
|
|
||||||
materials)
|
|
||||||
|
|
||||||
for quality in QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(
|
|
||||||
global_container_stack, extruder_stacks):
|
|
||||||
if quality not in result:
|
|
||||||
result.append(quality)
|
|
||||||
return result
|
|
||||||
|
|
||||||
## Re-computes the items in this model, and adds the layer height role.
|
## Re-computes the items in this model, and adds the layer height role.
|
||||||
def _recomputeItems(self):
|
def _recomputeItems(self):
|
||||||
|
@ -93,12 +96,18 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
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()
|
||||||
|
material = global_container_stack.material
|
||||||
if active_extruder in extruder_stacks:
|
if active_extruder in extruder_stacks:
|
||||||
extruder_stacks.remove(active_extruder)
|
extruder_stacks.remove(active_extruder)
|
||||||
extruder_stacks = [active_extruder] + extruder_stacks
|
extruder_stacks = [active_extruder] + extruder_stacks
|
||||||
|
material = active_extruder.material
|
||||||
|
|
||||||
# Get a list of available qualities for this machine and material
|
# Get a list of available qualities for this machine and material
|
||||||
qualities = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
qualities = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||||
extruder_stacks)
|
extruder_stacks)
|
||||||
|
|
||||||
|
all_qualities = QualityManager.getInstance().findAllQualitiesForMachineMaterial(global_container_stack.getBottom(), material)
|
||||||
|
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
machine_manager = Application.getInstance().getMachineManager()
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
|
|
||||||
|
@ -125,12 +134,23 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
for key in reversed(tmp_all_quality_items.keys()):
|
for key in reversed(tmp_all_quality_items.keys()):
|
||||||
all_quality_items[key] = tmp_all_quality_items[key]
|
all_quality_items[key] = tmp_all_quality_items[key]
|
||||||
|
|
||||||
|
# First the suitable containers are set in the model
|
||||||
|
containers = []
|
||||||
for data_item in all_quality_items.values():
|
for data_item in all_quality_items.values():
|
||||||
item = data_item["suitable_container"]
|
suitable_item = data_item["suitable_container"]
|
||||||
if item is None:
|
if suitable_item is None:
|
||||||
item = data_item["all_containers"][0]
|
suitable_item = data_item["all_containers"][0]
|
||||||
|
containers.append(suitable_item)
|
||||||
|
|
||||||
profile = container_registry.findContainers(id = item["id"])
|
# Once the suitable containers are collected, the rest of the containers are appended
|
||||||
|
for data_item in all_quality_items.values():
|
||||||
|
for item in data_item["all_containers"]:
|
||||||
|
if item not in containers:
|
||||||
|
containers.append(item)
|
||||||
|
|
||||||
|
# Now all the containers are set
|
||||||
|
for item in containers:
|
||||||
|
profile = container_registry.findContainers(id=item["id"])
|
||||||
if not profile:
|
if not profile:
|
||||||
item["layer_height"] = "" # Can't update a profile that is unknown.
|
item["layer_height"] = "" # Can't update a profile that is unknown.
|
||||||
item["available"] = False
|
item["available"] = False
|
||||||
|
|
|
@ -25,17 +25,30 @@ class UserProfilesModel(ProfilesModel):
|
||||||
machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
|
machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
|
||||||
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
|
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
|
||||||
|
|
||||||
# Fetch the list of qualities
|
# Detecting if the machine has multiple extrusion
|
||||||
quality_list = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
multiple_extrusion = False
|
||||||
ExtruderManager.getInstance().getActiveExtruderStacks())
|
# Get the list of extruders and place the selected extruder at the front of the list.
|
||||||
|
extruder_manager = ExtruderManager.getInstance()
|
||||||
|
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||||
|
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||||
|
if active_extruder in extruder_stacks:
|
||||||
|
multiple_extrusion = True
|
||||||
|
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.
|
||||||
|
quality_list = quality_manager.findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||||
|
extruder_stacks)
|
||||||
|
|
||||||
# Filter the quality_change by the list of available quality_types
|
# Filter the quality_change by the list of available quality_types
|
||||||
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in quality_list])
|
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in quality_list])
|
||||||
|
|
||||||
|
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()]
|
||||||
|
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]
|
filtered_quality_changes = [qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set]
|
||||||
|
|
||||||
#Only display the global quality changes.
|
|
||||||
#Otherwise you get multiple copies of every quality changes profile.
|
|
||||||
#The actual profile switching goes by profile name (not ID), and as long as the names are consistent, switching to any of the profiles will cause all stacks to switch.
|
|
||||||
filtered_quality_changes = list(filter(lambda quality_changes: quality_changes.getMetaDataEntry("extruder") is None, filtered_quality_changes))
|
|
||||||
|
|
||||||
return filtered_quality_changes
|
return filtered_quality_changes
|
||||||
|
|
|
@ -43,7 +43,7 @@ Menu
|
||||||
{
|
{
|
||||||
text: model.name + " - " + model.layer_height
|
text: model.name + " - " + model.layer_height
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: Cura.MachineManager.globalQualityId == model.id
|
checked: Cura.MachineManager.activeQualityChangesId == model.id
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered: Cura.MachineManager.setActiveQuality(model.id)
|
onTriggered: Cura.MachineManager.setActiveQuality(model.id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue