mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
Let _fetchInstanceContainers return containers split by loaded or not
It must now return two dictionaries: One for the profiles that have been completely loaded and one for the profiles that are only metadata. We could probably improve on these a little bit, since all of these (except the material model) will now load all available quality profiles. I'll see if it is necessary to optimise that. Contributes to issue CURA-4243.
This commit is contained in:
parent
e5427eded6
commit
eb3981b4e0
3 changed files with 17 additions and 15 deletions
|
@ -53,7 +53,7 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
def _fetchInstanceContainers(self):
|
def _fetchInstanceContainers(self):
|
||||||
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.
|
||||||
|
@ -83,7 +83,7 @@ class ProfilesModel(InstanceContainersModel):
|
||||||
if quality.getMetaDataEntry("quality_type") not in quality_type_set:
|
if quality.getMetaDataEntry("quality_type") not in quality_type_set:
|
||||||
result.append(quality)
|
result.append(quality)
|
||||||
|
|
||||||
return result
|
return {item.getId():item for item in 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):
|
||||||
|
|
|
@ -18,7 +18,7 @@ class QualityAndUserProfilesModel(ProfilesModel):
|
||||||
def _fetchInstanceContainers(self):
|
def _fetchInstanceContainers(self):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if not global_container_stack:
|
if not global_container_stack:
|
||||||
return []
|
return {}, {}
|
||||||
|
|
||||||
# Fetch the list of quality changes.
|
# Fetch the list of quality changes.
|
||||||
quality_manager = QualityManager.getInstance()
|
quality_manager = QualityManager.getInstance()
|
||||||
|
@ -50,19 +50,21 @@ class QualityAndUserProfilesModel(ProfilesModel):
|
||||||
# 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.
|
||||||
quality_list = quality_manager.findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
quality_list = quality_manager.findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
|
||||||
extruder_stacks)
|
extruder_stacks)
|
||||||
|
result = {quality.getId():quality for quality in quality_list}
|
||||||
|
|
||||||
# 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 multiple_extrusion:
|
||||||
# If the printer has multiple extruders then quality changes related to the current extruder are kept
|
# 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
|
filtered_quality_changes = {qc.getId():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") is not None and
|
||||||
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())]
|
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 and
|
filtered_quality_changes = {qc.getId():qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||||
qc.getMetaDataEntry("extruder") is None]
|
qc.getMetaDataEntry("extruder") is None}
|
||||||
|
result.update(filtered_quality_changes)
|
||||||
|
|
||||||
return quality_list + filtered_quality_changes
|
return result, {}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class UserProfilesModel(ProfilesModel):
|
||||||
def _fetchInstanceContainers(self):
|
def _fetchInstanceContainers(self):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if not global_container_stack:
|
if not global_container_stack:
|
||||||
return []
|
return {}, {}
|
||||||
|
|
||||||
# Fetch the list of quality changes.
|
# Fetch the list of quality changes.
|
||||||
quality_manager = QualityManager.getInstance()
|
quality_manager = QualityManager.getInstance()
|
||||||
|
@ -27,7 +27,7 @@ class UserProfilesModel(ProfilesModel):
|
||||||
|
|
||||||
# Detecting if the machine has multiple extrusion
|
# Detecting if the machine has multiple extrusion
|
||||||
multiple_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1
|
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()
|
||||||
|
@ -56,13 +56,13 @@ class UserProfilesModel(ProfilesModel):
|
||||||
|
|
||||||
if multiple_extrusion:
|
if multiple_extrusion:
|
||||||
# If the printer has multiple extruders then quality changes related to the current extruder are kept
|
# 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
|
filtered_quality_changes = {qc.getId():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") is not None and
|
||||||
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
(qc.getMetaDataEntry("extruder") == active_extruder.definition.getMetaDataEntry("quality_definition") or
|
||||||
qc.getMetaDataEntry("extruder") == active_extruder.definition.getId())]
|
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 and
|
filtered_quality_changes = {qc.getId():qc for qc in quality_changes_list if qc.getMetaDataEntry("quality_type") in quality_type_set and
|
||||||
qc.getMetaDataEntry("extruder") is None]
|
qc.getMetaDataEntry("extruder") is None}
|
||||||
|
|
||||||
return filtered_quality_changes
|
return filtered_quality_changes, {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue