mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
WIP - CURA-4451
This commit is contained in:
parent
7bf854aa0f
commit
9b62b48509
3 changed files with 95 additions and 27 deletions
|
@ -50,6 +50,7 @@ class MachineManager(QObject):
|
|||
# Used to store the new containers until after confirming the dialog
|
||||
self._new_variant_container = None
|
||||
self._new_material_container = None
|
||||
self._new_quality_containers = []
|
||||
|
||||
self._error_check_timer = QTimer()
|
||||
self._error_check_timer.setInterval(250)
|
||||
|
@ -70,10 +71,10 @@ class MachineManager(QObject):
|
|||
|
||||
self._stacks_have_errors = None
|
||||
|
||||
self._empty_variant_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||
self._empty_material_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||
self._empty_quality_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||
self._empty_quality_changes_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||
self._empty_variant_container = ContainerRegistry.getInstance().findContainers(id = "empty_variant")[0]
|
||||
self._empty_material_container = ContainerRegistry.getInstance().findContainers(id = "empty_material")[0]
|
||||
self._empty_quality_container = ContainerRegistry.getInstance().findContainers(id = "empty_quality")[0]
|
||||
self._empty_quality_changes_container = ContainerRegistry.getInstance().findContainers(id = "empty_quality_changes")[0]
|
||||
|
||||
self._onGlobalContainerChanged()
|
||||
|
||||
|
@ -147,6 +148,14 @@ class MachineManager(QObject):
|
|||
|
||||
self.outputDevicesChanged.emit()
|
||||
|
||||
@property
|
||||
def newVariant(self):
|
||||
return self._new_variant_container
|
||||
|
||||
@property
|
||||
def newMaterial(self):
|
||||
return self._new_material_container
|
||||
|
||||
@pyqtProperty("QVariantList", notify = outputDevicesChanged)
|
||||
def printerOutputDevices(self):
|
||||
return self._printer_output_devices
|
||||
|
@ -818,6 +827,7 @@ class MachineManager(QObject):
|
|||
if old_material:
|
||||
preferred_material_name = old_material.getName()
|
||||
preferred_material_id = self._updateMaterialContainer(self._global_container_stack.getBottom(), self._global_container_stack, containers[0], preferred_material_name).id
|
||||
Logger.log("d", "preferred_material_id=%s", preferred_material_id)
|
||||
self.setActiveMaterial(preferred_material_id)
|
||||
else:
|
||||
Logger.log("w", "While trying to set the active variant, no variant was found to replace.")
|
||||
|
@ -854,20 +864,20 @@ class MachineManager(QObject):
|
|||
if new_quality_settings_list is None:
|
||||
return
|
||||
|
||||
name_changed_connect_stacks = [] # Connect these stacks to the name changed callback
|
||||
self._new_quality_containers.clear()
|
||||
|
||||
for setting_info in new_quality_settings_list:
|
||||
stack = setting_info["stack"]
|
||||
stack_quality = setting_info["quality"]
|
||||
stack_quality_changes = setting_info["quality_changes"]
|
||||
|
||||
name_changed_connect_stacks.append(stack_quality)
|
||||
name_changed_connect_stacks.append(stack_quality_changes)
|
||||
self._replaceQualityOrQualityChangesInStack(stack, stack_quality, postpone_emit = True)
|
||||
self._replaceQualityOrQualityChangesInStack(stack, stack_quality_changes, postpone_emit = True)
|
||||
Logger.log("d", "=======================setting new quality=%s, %s", stack.getId(), stack_quality.getId())
|
||||
|
||||
# Connect to onQualityNameChanged
|
||||
for stack in name_changed_connect_stacks:
|
||||
stack.nameChanged.connect(self._onQualityNameChanged)
|
||||
self._new_quality_containers.append({
|
||||
"stack": stack,
|
||||
"quality": stack_quality,
|
||||
"quality_changes": stack_quality_changes
|
||||
})
|
||||
|
||||
has_user_interaction = False
|
||||
|
||||
|
@ -890,13 +900,24 @@ class MachineManager(QObject):
|
|||
# before the user decided to keep or discard any of their changes using the dialog.
|
||||
# The Application.onDiscardOrKeepProfileChangesClosed signal triggers this method.
|
||||
def _executeDelayedActiveContainerStackChanges(self):
|
||||
if self._new_variant_container is not None:
|
||||
self._active_container_stack.variant = self._new_variant_container
|
||||
self._new_variant_container = None
|
||||
|
||||
if self._new_material_container is not None:
|
||||
self._active_container_stack.material = self._new_material_container
|
||||
self._new_material_container = None
|
||||
|
||||
if self._new_variant_container is not None:
|
||||
self._active_container_stack.variant = self._new_variant_container
|
||||
self._new_variant_container = None
|
||||
if self._new_quality_containers:
|
||||
for new_quality in self._new_quality_containers:
|
||||
Logger.log("d", "stack=%s, quality=%s", new_quality["stack"].getId(), new_quality["quality"].getId())
|
||||
self._replaceQualityOrQualityChangesInStack(new_quality["stack"], new_quality["quality"], postpone_emit = True)
|
||||
self._replaceQualityOrQualityChangesInStack(new_quality["stack"], new_quality["quality_changes"], postpone_emit = True)
|
||||
|
||||
for new_quality in self._new_quality_containers:
|
||||
new_quality["stack"].nameChanged.connect(self._onQualityNameChanged)
|
||||
|
||||
self._new_quality_containers.clear()
|
||||
|
||||
## Cancel set changes for material and variant in the active container stack.
|
||||
# Used for ignoring any changes when switching between printers (setActiveMachine)
|
||||
|
@ -926,6 +947,11 @@ class MachineManager(QObject):
|
|||
|
||||
for stack in stacks:
|
||||
material = stack.material
|
||||
|
||||
# TODO: fix this
|
||||
if self._new_material_container and stack.getId() == self._active_container_stack.getId():
|
||||
material = self._new_material_container
|
||||
|
||||
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
||||
if not quality:
|
||||
# No quality profile is found for this quality type.
|
||||
|
@ -963,8 +989,12 @@ class MachineManager(QObject):
|
|||
else:
|
||||
Logger.log("e", "Could not find the global quality changes container with name %s", quality_changes_name)
|
||||
return None
|
||||
|
||||
material = global_container_stack.material
|
||||
|
||||
if self._new_material_container and self._active_container_stack.getId() == global_container_stack.getId():
|
||||
material = self._new_material_container
|
||||
|
||||
# For the global stack, find a quality which matches the quality_type in
|
||||
# the quality changes profile and also satisfies any material constraints.
|
||||
quality_type = global_quality_changes.getMetaDataEntry("quality_type")
|
||||
|
@ -991,6 +1021,10 @@ class MachineManager(QObject):
|
|||
quality_changes = self._empty_quality_changes_container
|
||||
|
||||
material = stack.material
|
||||
|
||||
if self._new_material_container and self._active_container_stack.getId() == stack.getId():
|
||||
material = self._new_material_container
|
||||
|
||||
quality = quality_manager.findQualityByQualityType(quality_type, global_machine_definition, [material])
|
||||
if not quality: #No quality profile found for this quality type.
|
||||
quality = self._empty_quality_container
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue