mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 16:24:41 +08:00
Fix unit test due to QualityGroup parent changes
This commit is contained in:
parent
961e1e0d7e
commit
bc524b2c14
@ -7,12 +7,14 @@ from UM.Logger import Logger
|
|||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from UM.Util import parseBool
|
from UM.Util import parseBool
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry # To find all the variants for this machine.
|
from UM.Settings.ContainerRegistry import ContainerRegistry # To find all the variants for this machine.
|
||||||
|
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.QualityChangesGroup import QualityChangesGroup # To construct groups of quality changes profiles that belong together.
|
from cura.Machines.QualityChangesGroup import QualityChangesGroup # To construct groups of quality changes profiles that belong together.
|
||||||
from cura.Machines.QualityGroup import QualityGroup # To construct groups of quality profiles that belong together.
|
from cura.Machines.QualityGroup import QualityGroup # To construct groups of quality profiles that belong together.
|
||||||
from cura.Machines.QualityNode import QualityNode
|
from cura.Machines.QualityNode import QualityNode
|
||||||
from cura.Machines.VariantNode import VariantNode
|
from cura.Machines.VariantNode import VariantNode
|
||||||
|
|
||||||
|
|
||||||
## This class represents a machine in the container tree.
|
## This class represents a machine in the container tree.
|
||||||
#
|
#
|
||||||
# The subnodes of these nodes are variants.
|
# The subnodes of these nodes are variants.
|
||||||
@ -80,7 +82,15 @@ class MachineNode(ContainerNode):
|
|||||||
if not global_quality_node.container:
|
if not global_quality_node.container:
|
||||||
Logger.log("w", "Node {0} doesn't have a container.".format(global_quality_node.container_id))
|
Logger.log("w", "Node {0} doesn't have a container.".format(global_quality_node.container_id))
|
||||||
continue
|
continue
|
||||||
quality_groups[quality_type] = QualityGroup(name = global_quality_node.container.getMetaDataEntry("name", "Unnamed profile"), quality_type = quality_type)
|
# CURA-6599
|
||||||
|
# Same as QualityChangesGroup.
|
||||||
|
# For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
|
||||||
|
# a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
|
||||||
|
# parent to application seems to work.
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
quality_groups[quality_type] = QualityGroup(name = global_quality_node.container.getMetaDataEntry("name", "Unnamed profile"),
|
||||||
|
quality_type = quality_type,
|
||||||
|
parent = CuraApplication.getInstance())
|
||||||
quality_groups[quality_type].node_for_global = global_quality_node
|
quality_groups[quality_type].node_for_global = global_quality_node
|
||||||
for extruder, qualities_per_type in enumerate(qualities_per_type_per_extruder):
|
for extruder, qualities_per_type in enumerate(qualities_per_type_per_extruder):
|
||||||
if quality_type in qualities_per_type:
|
if quality_type in qualities_per_type:
|
||||||
@ -123,7 +133,14 @@ class MachineNode(ContainerNode):
|
|||||||
for quality_changes in machine_quality_changes:
|
for quality_changes in machine_quality_changes:
|
||||||
name = quality_changes["name"]
|
name = quality_changes["name"]
|
||||||
if name not in groups_by_name:
|
if name not in groups_by_name:
|
||||||
groups_by_name[name] = QualityChangesGroup(name, quality_type = quality_changes["quality_type"], intent_category = quality_changes.get("intent_category", "default"))
|
# CURA-6599
|
||||||
|
# For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
|
||||||
|
# a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
|
||||||
|
# parent to application seems to work.
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
groups_by_name[name] = QualityChangesGroup(name, quality_type = quality_changes["quality_type"],
|
||||||
|
intent_category = quality_changes.get("intent_category", "default"),
|
||||||
|
parent = CuraApplication.getInstance())
|
||||||
elif groups_by_name[name].intent_category == "default": # Intent category should be stored as "default" if everything is default or as the intent if any of the extruder have an actual intent.
|
elif groups_by_name[name].intent_category == "default": # Intent category should be stored as "default" if everything is default or as the intent if any of the extruder have an actual intent.
|
||||||
groups_by_name[name].intent_category = quality_changes.get("intent_category", "default")
|
groups_by_name[name].intent_category = quality_changes.get("intent_category", "default")
|
||||||
if "position" in quality_changes: # An extruder profile.
|
if "position" in quality_changes: # An extruder profile.
|
||||||
@ -147,7 +164,7 @@ class MachineNode(ContainerNode):
|
|||||||
# If the preferred global quality is not in there, an arbitrary global
|
# If the preferred global quality is not in there, an arbitrary global
|
||||||
# quality is taken.
|
# quality is taken.
|
||||||
# If there are no global qualities, an empty quality is returned.
|
# If there are no global qualities, an empty quality is returned.
|
||||||
def preferredGlobalQuality(self) -> QualityNode:
|
def preferredGlobalQuality(self) -> "QualityNode":
|
||||||
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
|
return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
|
||||||
|
|
||||||
## (Re)loads all variants under this printer.
|
## (Re)loads all variants under this printer.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty
|
from PyQt5.QtCore import QObject, pyqtProperty
|
||||||
|
|
||||||
|
|
||||||
## Data struct to group several quality changes instance containers together.
|
## Data struct to group several quality changes instance containers together.
|
||||||
@ -15,14 +15,6 @@ class QualityChangesGroup(QObject):
|
|||||||
|
|
||||||
def __init__(self, name: str, quality_type: str, intent_category: str, parent: Optional["QObject"] = None) -> None:
|
def __init__(self, name: str, quality_type: str, intent_category: str, parent: Optional["QObject"] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
# CURA-6599
|
|
||||||
# For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
|
|
||||||
# a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
|
|
||||||
# parent to application seems to work.
|
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
self.setParent(CuraApplication.getInstance())
|
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self.quality_type = quality_type
|
self.quality_type = quality_type
|
||||||
self.intent_category = intent_category
|
self.intent_category = intent_category
|
||||||
|
@ -29,14 +29,6 @@ class QualityGroup(QObject):
|
|||||||
def __init__(self, name: str, quality_type: str, parent: Optional["QObject"] = None) -> None:
|
def __init__(self, name: str, quality_type: str, parent: Optional["QObject"] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
# CURA-6599
|
|
||||||
# Same as QualityChangesGroup.
|
|
||||||
# For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
|
|
||||||
# a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
|
|
||||||
# parent to application seems to work.
|
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
self.setParent(CuraApplication.getInstance())
|
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.node_for_global = None # type: Optional[ContainerNode]
|
self.node_for_global = None # type: Optional[ContainerNode]
|
||||||
self.nodes_for_extruders = {} # type: Dict[int, ContainerNode]
|
self.nodes_for_extruders = {} # type: Dict[int, ContainerNode]
|
||||||
|
@ -111,7 +111,13 @@ class QualityManager(QObject):
|
|||||||
quality_group_dict = dict()
|
quality_group_dict = dict()
|
||||||
for node in nodes_to_check:
|
for node in nodes_to_check:
|
||||||
if node and node.quality_type:
|
if node and node.quality_type:
|
||||||
quality_group = QualityGroup(node.getMetaDataEntry("name", ""), node.quality_type)
|
# CURA-6599
|
||||||
|
# Same as QualityChangesGroup.
|
||||||
|
# For some reason, QML will get null or fail to convert type for MachineManager.activeQualityChangesGroup() to
|
||||||
|
# a QObject. Setting the object ownership to QQmlEngine.CppOwnership doesn't work, but setting the object
|
||||||
|
# parent to application seems to work.
|
||||||
|
quality_group = QualityGroup(node.getMetaDataEntry("name", ""), node.quality_type,
|
||||||
|
parent = CuraApplication.getInstance())
|
||||||
quality_group.setGlobalNode(node)
|
quality_group.setGlobalNode(node)
|
||||||
quality_group_dict[node.quality_type] = quality_group
|
quality_group_dict[node.quality_type] = quality_group
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user