mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-30 01:55:55 +08:00
Solved the issue with the slider that was no showing in gray the unavailable profiles - CURA-4327
This commit is contained in:
parent
c22928f5d1
commit
2ae1700a15
@ -64,19 +64,6 @@ 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}
|
||||||
@ -104,18 +91,6 @@ 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,36 +54,36 @@ 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()
|
||||||
active_extruder = extruder_manager.getActiveExtruderStack()
|
active_extruder = extruder_manager.getActiveExtruderStack()
|
||||||
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
extruder_stacks = extruder_manager.getActiveExtruderStacks()
|
||||||
|
materials = [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
|
||||||
|
materials = [extruder.material for extruder in extruder_stacks]
|
||||||
|
|
||||||
# if ExtruderManager.getInstance().getActiveExtruderStacks():
|
# Fetch the list of usable qualities across all extruders.
|
||||||
# # Multi-extruder machine detected.
|
# The actual list of quality profiles come from the first extruder in the extruder list.
|
||||||
# materials = [extruder.material for extruder in extruder_stacks]
|
result = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, extruder_stacks)
|
||||||
# else:
|
|
||||||
# # Machine with one extruder.
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
return quality_list
|
# The usable quality types are set
|
||||||
|
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in result])
|
||||||
|
|
||||||
|
# Fetch all qualities available for this machine and the materials selected in extruders
|
||||||
|
all_qualities = QualityManager.getInstance().findAllQualitiesForMachineAndMaterials(global_stack_definition, materials)
|
||||||
|
|
||||||
|
# If in the all qualities there is some of them that are not available due to incompatibility with materials
|
||||||
|
# we also add it so that they will appear in the slide quality bar. However in recomputeItems will be marked as
|
||||||
|
# not available so they will be shown in gray
|
||||||
|
for quality in all_qualities:
|
||||||
|
if quality.getMetaDataEntry("quality_type") not in quality_type_set:
|
||||||
|
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):
|
||||||
@ -96,21 +96,14 @@ 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 usable/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 = []
|
|
||||||
for extruder in extruder_stacks:
|
|
||||||
all_qualities.append(QualityManager.getInstance().findAllQualitiesForMachineMaterial(global_container_stack.getBottom(), extruder.material))
|
|
||||||
all_qualities2 = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, [])
|
|
||||||
|
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
machine_manager = Application.getInstance().getMachineManager()
|
machine_manager = Application.getInstance().getMachineManager()
|
||||||
|
|
||||||
@ -129,7 +122,7 @@ class ProfilesModel(InstanceContainersModel):
|
|||||||
tmp_all_quality_items[quality_type] = {"suitable_container": None, "all_containers": []}
|
tmp_all_quality_items[quality_type] = {"suitable_container": None, "all_containers": []}
|
||||||
|
|
||||||
tmp_all_quality_items[quality_type]["all_containers"].append(item)
|
tmp_all_quality_items[quality_type]["all_containers"].append(item)
|
||||||
if tmp_all_quality_items[quality_type]["suitable_container"] is None and profile[0] in qualities:
|
if tmp_all_quality_items[quality_type]["suitable_container"] is None:
|
||||||
tmp_all_quality_items[quality_type]["suitable_container"] = item
|
tmp_all_quality_items[quality_type]["suitable_container"] = item
|
||||||
|
|
||||||
# reverse the ordering (finest first, coarsest last)
|
# reverse the ordering (finest first, coarsest last)
|
||||||
@ -154,7 +147,7 @@ class ProfilesModel(InstanceContainersModel):
|
|||||||
for item in containers:
|
for item in containers:
|
||||||
profile = container_registry.findContainers(id=item["id"])
|
profile = container_registry.findContainers(id=item["id"])
|
||||||
if not profile:
|
if not profile:
|
||||||
item["layer_height"] = "" # Can't update a profile that is unknown.
|
self._setItemLayerHeight(item, "", unit)
|
||||||
item["available"] = False
|
item["available"] = False
|
||||||
yield item
|
yield item
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user