mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
removing update existing/ create new in case of UCP
also, making sure post processing scripts are not loaded. CURA-11403
This commit is contained in:
parent
b119a010ca
commit
8ef7b65710
3 changed files with 47 additions and 36 deletions
|
@ -117,7 +117,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
self._supported_extensions = [".3mf"]
|
self._supported_extensions = [".3mf"]
|
||||||
self._dialog = WorkspaceDialog()
|
self._dialog = WorkspaceDialog()
|
||||||
self._3mf_mesh_reader = None
|
self._3mf_mesh_reader = None
|
||||||
self._is_ucp = False
|
self._is_ucp = None
|
||||||
self._container_registry = ContainerRegistry.getInstance()
|
self._container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
# suffixes registered with the MimeTypes don't start with a dot '.'
|
# suffixes registered with the MimeTypes don't start with a dot '.'
|
||||||
|
@ -208,6 +208,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
raise FileNotFoundError("No global stack file found!")
|
raise FileNotFoundError("No global stack file found!")
|
||||||
|
|
||||||
return global_stack_file_list[0], extruder_stack_file_list
|
return global_stack_file_list[0], extruder_stack_file_list
|
||||||
|
def _isProjectUcp(self, file_name) -> bool:
|
||||||
|
if self._is_ucp == None:
|
||||||
|
archive = zipfile.ZipFile(file_name, "r")
|
||||||
|
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
|
||||||
|
self._is_ucp =True if USER_SETTINGS_PATH in cura_file_names else False
|
||||||
|
|
||||||
|
def getIsProjectUcp(self) -> bool:
|
||||||
|
return self._is_ucp
|
||||||
|
|
||||||
|
|
||||||
def preRead(self, file_name, show_dialog=True, *args, **kwargs):
|
def preRead(self, file_name, show_dialog=True, *args, **kwargs):
|
||||||
"""Read some info so we can make decisions
|
"""Read some info so we can make decisions
|
||||||
|
@ -217,7 +226,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
we don't want to show a dialog.
|
we don't want to show a dialog.
|
||||||
"""
|
"""
|
||||||
self._clearState()
|
self._clearState()
|
||||||
|
self._isProjectUcp(file_name)
|
||||||
self._3mf_mesh_reader = Application.getInstance().getMeshFileHandler().getReaderForFile(file_name)
|
self._3mf_mesh_reader = Application.getInstance().getMeshFileHandler().getReaderForFile(file_name)
|
||||||
if self._3mf_mesh_reader and self._3mf_mesh_reader.preRead(file_name) == WorkspaceReader.PreReadResult.accepted:
|
if self._3mf_mesh_reader and self._3mf_mesh_reader.preRead(file_name) == WorkspaceReader.PreReadResult.accepted:
|
||||||
pass
|
pass
|
||||||
|
@ -933,7 +942,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
base_file_name = os.path.basename(file_name)
|
base_file_name = os.path.basename(file_name)
|
||||||
self.setWorkspaceName(base_file_name)
|
self.setWorkspaceName(base_file_name)
|
||||||
|
|
||||||
self._is_ucp = False
|
self._is_ucp = None
|
||||||
return nodes, self._loadMetadata(file_name)
|
return nodes, self._loadMetadata(file_name)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1312,39 +1321,40 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
machine_manager.setActiveMachine(global_stack.getId())
|
machine_manager.setActiveMachine(global_stack.getId())
|
||||||
|
|
||||||
# Set metadata fields that are missing from the global stack
|
# Set metadata fields that are missing from the global stack
|
||||||
for key, value in self._machine_info.metadata_dict.items():
|
if not self._is_ucp:
|
||||||
if key not in global_stack.getMetaData() and key not in _ignored_machine_network_metadata:
|
for key, value in self._machine_info.metadata_dict.items():
|
||||||
global_stack.setMetaDataEntry(key, value)
|
if key not in global_stack.getMetaData() and key not in _ignored_machine_network_metadata:
|
||||||
|
global_stack.setMetaDataEntry(key, value)
|
||||||
|
|
||||||
if self._quality_changes_to_apply !=None:
|
if self._quality_changes_to_apply !=None:
|
||||||
quality_changes_group_list = container_tree.getCurrentQualityChangesGroups()
|
quality_changes_group_list = container_tree.getCurrentQualityChangesGroups()
|
||||||
quality_changes_group = next((qcg for qcg in quality_changes_group_list if qcg.name == self._quality_changes_to_apply), None)
|
quality_changes_group = next((qcg for qcg in quality_changes_group_list if qcg.name == self._quality_changes_to_apply), None)
|
||||||
if not quality_changes_group:
|
if not quality_changes_group:
|
||||||
Logger.log("e", "Could not find quality_changes [%s]", self._quality_changes_to_apply)
|
Logger.log("e", "Could not find quality_changes [%s]", self._quality_changes_to_apply)
|
||||||
return
|
return
|
||||||
machine_manager.setQualityChangesGroup(quality_changes_group, no_dialog = True)
|
machine_manager.setQualityChangesGroup(quality_changes_group, no_dialog = True)
|
||||||
else:
|
|
||||||
self._quality_type_to_apply = self._quality_type_to_apply.lower() if self._quality_type_to_apply else None
|
|
||||||
quality_group_dict = container_tree.getCurrentQualityGroups()
|
|
||||||
if self._quality_type_to_apply in quality_group_dict:
|
|
||||||
quality_group = quality_group_dict[self._quality_type_to_apply]
|
|
||||||
else:
|
else:
|
||||||
Logger.log("i", "Could not find quality type [%s], switch to default", self._quality_type_to_apply)
|
self._quality_type_to_apply = self._quality_type_to_apply.lower() if self._quality_type_to_apply else None
|
||||||
preferred_quality_type = global_stack.getMetaDataEntry("preferred_quality_type")
|
quality_group_dict = container_tree.getCurrentQualityGroups()
|
||||||
quality_group = quality_group_dict.get(preferred_quality_type)
|
if self._quality_type_to_apply in quality_group_dict:
|
||||||
if quality_group is None:
|
quality_group = quality_group_dict[self._quality_type_to_apply]
|
||||||
Logger.log("e", "Could not get preferred quality type [%s]", preferred_quality_type)
|
|
||||||
|
|
||||||
if quality_group is not None:
|
|
||||||
machine_manager.setQualityGroup(quality_group, no_dialog = True)
|
|
||||||
|
|
||||||
# Also apply intent if available
|
|
||||||
available_intent_category_list = IntentManager.getInstance().currentAvailableIntentCategories()
|
|
||||||
if self._intent_category_to_apply is not None and self._intent_category_to_apply in available_intent_category_list:
|
|
||||||
machine_manager.setIntentByCategory(self._intent_category_to_apply)
|
|
||||||
else:
|
else:
|
||||||
# if no intent is provided, reset to the default (balanced) intent
|
Logger.log("i", "Could not find quality type [%s], switch to default", self._quality_type_to_apply)
|
||||||
machine_manager.resetIntents()
|
preferred_quality_type = global_stack.getMetaDataEntry("preferred_quality_type")
|
||||||
|
quality_group = quality_group_dict.get(preferred_quality_type)
|
||||||
|
if quality_group is None:
|
||||||
|
Logger.log("e", "Could not get preferred quality type [%s]", preferred_quality_type)
|
||||||
|
|
||||||
|
if quality_group is not None:
|
||||||
|
machine_manager.setQualityGroup(quality_group, no_dialog = True)
|
||||||
|
|
||||||
|
# Also apply intent if available
|
||||||
|
available_intent_category_list = IntentManager.getInstance().currentAvailableIntentCategories()
|
||||||
|
if self._intent_category_to_apply is not None and self._intent_category_to_apply in available_intent_category_list:
|
||||||
|
machine_manager.setIntentByCategory(self._intent_category_to_apply)
|
||||||
|
else:
|
||||||
|
# if no intent is provided, reset to the default (balanced) intent
|
||||||
|
machine_manager.resetIntents()
|
||||||
# Notify everything/one that is to notify about changes.
|
# Notify everything/one that is to notify about changes.
|
||||||
global_stack.containersChanged.emit(global_stack.getTop())
|
global_stack.containersChanged.emit(global_stack.getTop())
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ UM.Dialog
|
||||||
id: qualityChangesResolveComboBox
|
id: qualityChangesResolveComboBox
|
||||||
model: resolveStrategiesModel
|
model: resolveStrategiesModel
|
||||||
textRole: "label"
|
textRole: "label"
|
||||||
visible: manager.qualityChangesConflict
|
visible: manager.qualityChangesConflict && !manager.isUcp
|
||||||
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
|
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
|
||||||
textFont: UM.Theme.getFont("medium")
|
textFont: UM.Theme.getFont("medium")
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ UM.Dialog
|
||||||
id: materialResolveComboBox
|
id: materialResolveComboBox
|
||||||
model: resolveStrategiesModel
|
model: resolveStrategiesModel
|
||||||
textRole: "label"
|
textRole: "label"
|
||||||
visible: manager.materialConflict
|
visible: manager.materialConflict && !manager.isUcp
|
||||||
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
|
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
|
||||||
textFont: UM.Theme.getFont("medium")
|
textFont: UM.Theme.getFont("medium")
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,8 @@ Item
|
||||||
{
|
{
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: comboboxLabel.verticalCenter
|
anchors.verticalCenter: comboboxLabel.verticalCenter
|
||||||
|
color: UM.Theme.getColor("small_button_text")
|
||||||
|
icon: UM.Theme.getIcon("Information")
|
||||||
text: comboboxTooltipText
|
text: comboboxTooltipText
|
||||||
visible: comboboxTooltipText != ""
|
visible: comboboxTooltipText != ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue