mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Move createQualityChanges function to QualityManagementModel
This function is specific to the management page (for the most part; some things seem to call the _createQualityChanges private function nonetheless). Contributes to issue CURA-6600.
This commit is contained in:
parent
b05de3e6d8
commit
b5d32a9b70
3 changed files with 60 additions and 41 deletions
|
@ -9,6 +9,7 @@ from UM.Qt.ListModel import ListModel
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer # To create new profiles.
|
from UM.Settings.InstanceContainer import InstanceContainer # To create new profiles.
|
||||||
|
|
||||||
import cura.CuraApplication # Imported this way to prevent circular imports.
|
import cura.CuraApplication # Imported this way to prevent circular imports.
|
||||||
|
from cura.Settings.ContainerManager import ContainerManager
|
||||||
from cura.Machines.ContainerTree import ContainerTree
|
from cura.Machines.ContainerTree import ContainerTree
|
||||||
from cura.Settings.cura_empty_instance_containers import empty_quality_changes_container
|
from cura.Settings.cura_empty_instance_containers import empty_quality_changes_container
|
||||||
|
|
||||||
|
@ -127,6 +128,54 @@ class QualityManagementModel(ListModel):
|
||||||
new_id = container_registry.uniqueName(container.getId())
|
new_id = container_registry.uniqueName(container.getId())
|
||||||
container_registry.addContainer(container.duplicate(new_id, new_name))
|
container_registry.addContainer(container.duplicate(new_id, new_name))
|
||||||
|
|
||||||
|
## Create quality changes containers from the user containers in the active
|
||||||
|
# stacks.
|
||||||
|
#
|
||||||
|
# This will go through the global and extruder stacks and create
|
||||||
|
# quality_changes containers from the user containers in each stack. These
|
||||||
|
# then replace the quality_changes containers in the stack and clear the
|
||||||
|
# user settings.
|
||||||
|
# \param base_name The new name for the quality changes profile. The final
|
||||||
|
# name of the profile might be different from this, because it needs to be
|
||||||
|
# made unique.
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def createQualityChanges(self, base_name: str) -> None:
|
||||||
|
machine_manager = cura.CuraApplication.CuraApplication.getInstance().getMachineManager()
|
||||||
|
|
||||||
|
global_stack = machine_manager.activeMachine
|
||||||
|
if not global_stack:
|
||||||
|
return
|
||||||
|
|
||||||
|
active_quality_name = machine_manager.activeQualityOrQualityChangesName
|
||||||
|
if active_quality_name == "":
|
||||||
|
Logger.log("w", "No quality container found in stack %s, cannot create profile", global_stack.getId())
|
||||||
|
return
|
||||||
|
|
||||||
|
machine_manager.blurSettings.emit()
|
||||||
|
if base_name is None or base_name == "":
|
||||||
|
base_name = active_quality_name
|
||||||
|
unique_name = self._container_registry.uniqueName(base_name)
|
||||||
|
|
||||||
|
# Go through the active stacks and create quality_changes containers from the user containers.
|
||||||
|
container_manager = ContainerManager.getInstance()
|
||||||
|
container_registry = cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry()
|
||||||
|
stack_list = [global_stack] + list(global_stack.extruders.values())
|
||||||
|
for stack in stack_list:
|
||||||
|
quality_container = stack.quality
|
||||||
|
quality_changes_container = stack.qualityChanges
|
||||||
|
if not quality_container or not quality_changes_container:
|
||||||
|
Logger.log("w", "No quality or quality changes container found in stack %s, ignoring it", stack.getId())
|
||||||
|
continue
|
||||||
|
|
||||||
|
extruder_stack = None
|
||||||
|
if isinstance(stack, ExtruderStack):
|
||||||
|
extruder_stack = stack
|
||||||
|
new_changes = self._createQualityChanges(quality_container.getMetaDataEntry("quality_type"), unique_name, global_stack, extruder_stack)
|
||||||
|
container_manager._performMerge(new_changes, quality_changes_container, clear_settings = False)
|
||||||
|
container_manager._performMerge(new_changes, stack.userChanges)
|
||||||
|
|
||||||
|
container_registry.addContainer(new_changes)
|
||||||
|
|
||||||
## Create a quality changes container with the given set-up.
|
## Create a quality changes container with the given set-up.
|
||||||
# \param quality_type The quality type of the new container.
|
# \param quality_type The quality type of the new container.
|
||||||
# \param new_name The name of the container. This name must be unique.
|
# \param new_name The name of the container. This name must be unique.
|
||||||
|
|
|
@ -169,49 +169,19 @@ class QualityManager(QObject):
|
||||||
def duplicateQualityChanges(self, quality_changes_name: str, quality_model_item: Dict[str, Any]) -> None:
|
def duplicateQualityChanges(self, quality_changes_name: str, quality_model_item: Dict[str, Any]) -> None:
|
||||||
return cura.CuraApplication.CuraApplication.getInstance().getQualityManagementModel().duplicateQualityChanges(quality_changes_name, quality_model_item)
|
return cura.CuraApplication.CuraApplication.getInstance().getQualityManagementModel().duplicateQualityChanges(quality_changes_name, quality_model_item)
|
||||||
|
|
||||||
## Create quality changes containers from the user containers in the active stacks.
|
## Create quality changes containers from the user containers in the active
|
||||||
|
# stacks.
|
||||||
#
|
#
|
||||||
# This will go through the global and extruder stacks and create quality_changes containers from
|
# This will go through the global and extruder stacks and create
|
||||||
# the user containers in each stack. These then replace the quality_changes containers in the
|
# quality_changes containers from the user containers in each stack. These
|
||||||
# stack and clear the user settings.
|
# then replace the quality_changes containers in the stack and clear the
|
||||||
|
# user settings.
|
||||||
|
# \param base_name The new name for the quality changes profile. The final
|
||||||
|
# name of the profile might be different from this, because it needs to be
|
||||||
|
# made unique.
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def createQualityChanges(self, base_name: str) -> None:
|
def createQualityChanges(self, base_name: str) -> None:
|
||||||
machine_manager = cura.CuraApplication.CuraApplication.getInstance().getMachineManager()
|
return cura.CuraApplication.CuraApplication.getInstance().getQualityManagementModel().createQualityChanges(base_name)
|
||||||
|
|
||||||
global_stack = machine_manager.activeMachine
|
|
||||||
if not global_stack:
|
|
||||||
return
|
|
||||||
|
|
||||||
active_quality_name = machine_manager.activeQualityOrQualityChangesName
|
|
||||||
if active_quality_name == "":
|
|
||||||
Logger.log("w", "No quality container found in stack %s, cannot create profile", global_stack.getId())
|
|
||||||
return
|
|
||||||
|
|
||||||
machine_manager.blurSettings.emit()
|
|
||||||
if base_name is None or base_name == "":
|
|
||||||
base_name = active_quality_name
|
|
||||||
unique_name = self._container_registry.uniqueName(base_name)
|
|
||||||
|
|
||||||
# Go through the active stacks and create quality_changes containers from the user containers.
|
|
||||||
stack_list = [global_stack] + list(global_stack.extruders.values())
|
|
||||||
for stack in stack_list:
|
|
||||||
user_container = stack.userChanges
|
|
||||||
quality_container = stack.quality
|
|
||||||
quality_changes_container = stack.qualityChanges
|
|
||||||
if not quality_container or not quality_changes_container:
|
|
||||||
Logger.log("w", "No quality or quality changes container found in stack %s, ignoring it", stack.getId())
|
|
||||||
continue
|
|
||||||
|
|
||||||
quality_type = quality_container.getMetaDataEntry("quality_type")
|
|
||||||
extruder_stack = None
|
|
||||||
if isinstance(stack, ExtruderStack):
|
|
||||||
extruder_stack = stack
|
|
||||||
new_changes = self._createQualityChanges(quality_type, unique_name, global_stack, extruder_stack)
|
|
||||||
from cura.Settings.ContainerManager import ContainerManager
|
|
||||||
ContainerManager.getInstance()._performMerge(new_changes, quality_changes_container, clear_settings = False)
|
|
||||||
ContainerManager.getInstance()._performMerge(new_changes, user_container)
|
|
||||||
|
|
||||||
self._container_registry.addContainer(new_changes)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create a quality changes container with the given setup.
|
# Create a quality changes container with the given setup.
|
||||||
|
|
|
@ -182,7 +182,7 @@ Item
|
||||||
{
|
{
|
||||||
base.newQualityNameToSelect = newName; // We want to switch to the new profile once it's created
|
base.newQualityNameToSelect = newName; // We want to switch to the new profile once it's created
|
||||||
base.toActivateNewQuality = true;
|
base.toActivateNewQuality = true;
|
||||||
base.qualityManager.createQualityChanges(newName);
|
base.qualityManagementModel.createQualityChanges(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue