mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 14:34:01 -06:00
Merge branch 'feature_intent_container_tree' of github.com:Ultimaker/Cura into feature_intent_upgrade
This commit is contained in:
commit
958d3698db
8 changed files with 38 additions and 41 deletions
|
@ -14,7 +14,6 @@ from UM.Application import Application
|
|||
from UM.Logger import Logger
|
||||
from UM.Message import Message
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Signal import postponeSignals, CompressTechnique
|
||||
from UM.Settings.ContainerFormatError import ContainerFormatError
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||
|
@ -575,24 +574,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
# \param file_name
|
||||
@call_on_qt_thread
|
||||
def read(self, file_name):
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
signals = [container_registry.containerAdded,
|
||||
container_registry.containerRemoved,
|
||||
container_registry.containerMetaDataChanged]
|
||||
# The container tree updates its lookup tables upon container changes.
|
||||
# It is critical to make sure that it has a complete set of data when it
|
||||
# updates.
|
||||
#
|
||||
# In project loading, lots of the container-related signals are loosely emitted, which can create timing gaps
|
||||
# for incomplete data update or other kinds of issues to happen.
|
||||
#
|
||||
# To avoid this, we postpone all signals so they don't get emitted immediately. But, please also be aware that,
|
||||
# because of this, do not expect to have the latest data in the lookup tables in project loading.
|
||||
#
|
||||
with postponeSignals(*signals, compress = CompressTechnique.NoCompression):
|
||||
return self._read(file_name)
|
||||
|
||||
def _read(self, file_name):
|
||||
application = CuraApplication.getInstance()
|
||||
material_manager = application.getMaterialManager()
|
||||
|
||||
|
@ -760,6 +741,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
|
||||
quality_changes_info = self._machine_info.quality_changes_info
|
||||
quality_changes_quality_type = quality_changes_info.global_info.parser["metadata"]["quality_type"]
|
||||
quality_changes_intent_category_per_extruder = {position: info.parser["metadata"].get("intent_category", "default") for position, info in quality_changes_info.extruder_info_dict.items()}
|
||||
|
||||
quality_changes_name = quality_changes_info.name
|
||||
create_new = self._resolve_strategies.get("quality_changes") != "override"
|
||||
|
@ -770,9 +752,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
quality_changes_name = self._container_registry.uniqueName(quality_changes_name)
|
||||
for position, container_info in container_info_dict.items():
|
||||
extruder_stack = None
|
||||
intent_category = None # type: Optional[str]
|
||||
if position is not None:
|
||||
extruder_stack = global_stack.extruders[position]
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
||||
intent_category = quality_changes_intent_category_per_extruder[position]
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||
container_info.container = container
|
||||
self._container_registry.addContainer(container)
|
||||
|
||||
|
@ -801,8 +785,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
if not global_stack.extruders:
|
||||
ExtruderManager.getInstance().fixSingleExtrusionMachineExtruderDefinition(global_stack)
|
||||
extruder_stack = global_stack.extruders["0"]
|
||||
intent_category = quality_changes_intent_category_per_extruder["0"]
|
||||
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||
container_info.container = container
|
||||
self._container_registry.addContainer(container)
|
||||
|
||||
|
@ -829,7 +814,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
|
||||
if container_info.container is None:
|
||||
extruder_stack = global_stack.extruders[position]
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
||||
intent_category = quality_changes_intent_category_per_extruder[position]
|
||||
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||
container_info.container = container
|
||||
self._container_registry.addContainer(container)
|
||||
|
||||
|
@ -842,6 +828,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
#
|
||||
# This will then later be filled with the appropriate data.
|
||||
# \param quality_type The quality type of the new profile.
|
||||
# \param intent_category The intent category of the new profile.
|
||||
# \param name The name for the profile. This will later be made unique so
|
||||
# it doesn't need to be unique yet.
|
||||
# \param global_stack The global stack showing the configuration that the
|
||||
|
@ -849,7 +836,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
# \param extruder_stack The extruder stack showing the configuration that
|
||||
# the profile should be created for. If this is None, it will be created
|
||||
# for the global stack.
|
||||
def _createNewQualityChanges(self, quality_type: str, name: str, global_stack: GlobalStack, extruder_stack: Optional[ExtruderStack]) -> InstanceContainer:
|
||||
def _createNewQualityChanges(self, quality_type: str, intent_category: Optional[str], name: str, global_stack: GlobalStack, extruder_stack: Optional[ExtruderStack]) -> InstanceContainer:
|
||||
container_registry = CuraApplication.getInstance().getContainerRegistry()
|
||||
base_id = global_stack.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
||||
new_id = base_id + "_" + name
|
||||
|
@ -861,6 +848,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
quality_changes.setName(name)
|
||||
quality_changes.setMetaDataEntry("type", "quality_changes")
|
||||
quality_changes.setMetaDataEntry("quality_type", quality_type)
|
||||
if intent_category is not None:
|
||||
quality_changes.setMetaDataEntry("intent_category", intent_category)
|
||||
|
||||
# If we are creating a container for an extruder, ensure we add that to the container.
|
||||
if extruder_stack is not None:
|
||||
|
|
|
@ -131,6 +131,8 @@ class GCodeWriter(MeshWriter):
|
|||
container_with_profile.setName(quality_name)
|
||||
container_with_profile.setMetaDataEntry("type", "quality_changes")
|
||||
container_with_profile.setMetaDataEntry("quality_type", quality_type)
|
||||
if stack.getMetaDataEntry("position") is not None: # For extruder stacks, the quality changes should include an intent category.
|
||||
container_with_profile.setMetaDataEntry("intent_category", stack.intent.getMetaDataEntry("intent_category", "default"))
|
||||
container_with_profile.setDefinition(machine_definition_id_for_quality)
|
||||
|
||||
flat_global_container = self._createFlattenedContainerInstance(stack.userChanges, container_with_profile)
|
||||
|
|
|
@ -68,10 +68,10 @@ class SendMaterialJob(Job):
|
|||
# \param materials_to_send A set with id's of materials that must be sent.
|
||||
def _sendMaterials(self, materials_to_send: Set[str]) -> None:
|
||||
container_registry = CuraApplication.getInstance().getContainerRegistry()
|
||||
material_manager = CuraApplication.getInstance().getMaterialManager()
|
||||
material_group_dict = material_manager.getAllMaterialGroups()
|
||||
all_materials = container_registry.findInstanceContainersMetadata(type = "material")
|
||||
all_root_materials = {material["base_file"] for material in all_materials if "base_file" in material} # Filters out uniques by making it a set. Don't include files without base file (i.e. empty material).
|
||||
|
||||
for root_material_id in material_group_dict:
|
||||
for root_material_id in all_root_materials:
|
||||
if root_material_id not in materials_to_send:
|
||||
# If the material does not have to be sent we skip it.
|
||||
continue
|
||||
|
@ -128,20 +128,18 @@ class SendMaterialJob(Job):
|
|||
@staticmethod
|
||||
def _getLocalMaterials() -> Dict[str, LocalMaterial]:
|
||||
result = {} # type: Dict[str, LocalMaterial]
|
||||
material_manager = CuraApplication.getInstance().getMaterialManager()
|
||||
material_group_dict = material_manager.getAllMaterialGroups()
|
||||
all_materials = CuraApplication.getInstance().getContainerRegistry().findInstanceContainersMetadata(type = "material")
|
||||
all_root_materials = [material for material in all_materials if material["id"] == material.get("base_file")] # Don't send materials without base_file: The empty material doesn't need to be sent.
|
||||
|
||||
# Find the latest version of all material containers in the registry.
|
||||
for root_material_id, material_group in material_group_dict.items():
|
||||
material_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = material_group.root_material_node.container_id)[0]
|
||||
|
||||
for material_metadata in all_root_materials:
|
||||
try:
|
||||
# material version must be an int
|
||||
material_metadata["version"] = int(material_metadata["version"])
|
||||
|
||||
# Create a new local material
|
||||
local_material = LocalMaterial(**material_metadata)
|
||||
local_material.id = root_material_id
|
||||
local_material.id = material_metadata["id"]
|
||||
|
||||
if local_material.GUID not in result or \
|
||||
local_material.GUID not in result or \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue