diff options
author | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2017-09-25 16:52:31 +0300 |
---|---|---|
committer | Diego Prado Gesto <d.pradogesto@ultimaker.com> | 2017-09-25 16:52:31 +0300 |
commit | b82309fb6a6258e01bbe82d5d9b9af9e4e1e3a74 (patch) | |
tree | 9bc3816840d7c1ad432f2b48382d082cb3daf7e9 /cura | |
parent | c33bd80818a72995755bb3c3eeb9b43cc15c26ce (diff) | |
parent | 2ae1700a156eebbd6a930245fd5d0f81cf78ee75 (diff) |
Merge branch 'custom_profiles' into 3.0
Diffstat (limited to 'cura')
-rw-r--r-- | cura/Settings/ProfilesModel.py | 51 | ||||
-rw-r--r-- | cura/Settings/UserProfilesModel.py | 29 |
2 files changed, 54 insertions, 26 deletions
diff --git a/cura/Settings/ProfilesModel.py b/cura/Settings/ProfilesModel.py index c7348ea920..c5de9b9136 100644 --- a/cura/Settings/ProfilesModel.py +++ b/cura/Settings/ProfilesModel.py @@ -60,26 +60,29 @@ class ProfilesModel(InstanceContainersModel): extruder_manager = ExtruderManager.getInstance()
active_extruder = extruder_manager.getActiveExtruderStack()
extruder_stacks = extruder_manager.getActiveExtruderStacks()
+ materials = [global_container_stack.material]
if active_extruder in extruder_stacks:
extruder_stacks.remove(active_extruder)
extruder_stacks = [active_extruder] + extruder_stacks
-
- if ExtruderManager.getInstance().getActiveExtruderStacks():
- # Multi-extruder machine detected.
materials = [extruder.material for extruder in 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)
+ result = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack, extruder_stacks)
+
+ # 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)
- for quality in QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(
- global_container_stack, extruder_stacks):
- if quality not in result:
+ # 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.
@@ -96,9 +99,11 @@ class ProfilesModel(InstanceContainersModel): if active_extruder in extruder_stacks:
extruder_stacks.remove(active_extruder)
extruder_stacks = [active_extruder] + extruder_stacks
- # 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,
extruder_stacks)
+
container_registry = ContainerRegistry.getInstance()
machine_manager = Application.getInstance().getMachineManager()
@@ -117,7 +122,7 @@ class ProfilesModel(InstanceContainersModel): tmp_all_quality_items[quality_type] = {"suitable_container": None, "all_containers": []}
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
# reverse the ordering (finest first, coarsest last)
@@ -125,14 +130,24 @@ class ProfilesModel(InstanceContainersModel): for key in reversed(tmp_all_quality_items.keys()):
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():
+ suitable_item = data_item["suitable_container"]
+ if suitable_item is not None:
+ containers.append(suitable_item)
+
+ # Once the suitable containers are collected, the rest of the containers are appended
for data_item in all_quality_items.values():
- item = data_item["suitable_container"]
- if item is None:
- item = data_item["all_containers"][0]
+ for item in data_item["all_containers"]:
+ if item not in containers:
+ containers.append(item)
- profile = container_registry.findContainers(id = item["id"])
+ # Now all the containers are set
+ for item in containers:
+ profile = container_registry.findContainers(id=item["id"])
if not profile:
- item["layer_height"] = "" # Can't update a profile that is unknown.
+ self._setItemLayerHeight(item, "", unit)
item["available"] = False
yield item
continue
diff --git a/cura/Settings/UserProfilesModel.py b/cura/Settings/UserProfilesModel.py index 07669422d2..fdb44ce313 100644 --- a/cura/Settings/UserProfilesModel.py +++ b/cura/Settings/UserProfilesModel.py @@ -25,17 +25,30 @@ class UserProfilesModel(ProfilesModel): machine_definition = quality_manager.getParentMachineDefinition(global_container_stack.getBottom())
quality_changes_list = quality_manager.findAllQualityChangesForMachine(machine_definition)
- # Fetch the list of qualities
- quality_list = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
- ExtruderManager.getInstance().getActiveExtruderStacks())
+ # Detecting if the machine has multiple extrusion
+ multiple_extrusion = False
+ # 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
quality_type_set = set([x.getMetaDataEntry("quality_type") for x in quality_list])
- 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))
+ 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]
return filtered_quality_changes
|