mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 06:33:55 -06:00

This class no longer applies to quality changes. Quality changes groups don't exist any more. Done during Turbo Testing and Tooling.
82 lines
3.2 KiB
Python
82 lines
3.2 KiB
Python
# Copyright (c) 2019 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
from typing import Dict, Optional, List, Set
|
|
|
|
from PyQt5.QtCore import QObject, pyqtSlot
|
|
|
|
from UM.Logger import Logger
|
|
from UM.Util import parseBool
|
|
|
|
from cura.Machines.ContainerNode import ContainerNode
|
|
|
|
|
|
## A QualityGroup represents a group of quality containers that must be applied
|
|
# to each ContainerStack when it's used.
|
|
#
|
|
# A concrete example: When there are two extruders and the user selects the
|
|
# quality type "normal", this quality type must be applied to all stacks in a
|
|
# machine, although each stack can have different containers. So one global
|
|
# profile gets put on the global stack and one extruder profile gets put on
|
|
# each extruder stack. This quality group then contains the following
|
|
# profiles (for instance):
|
|
# GlobalStack ExtruderStack 1 ExtruderStack 2
|
|
# quality container: um3_global_normal um3_aa04_pla_normal um3_aa04_abs_normal
|
|
#
|
|
# The purpose of these quality groups is to group the containers that can be
|
|
# applied to a configuration, so that when a quality level is selected, the
|
|
# container can directly be applied to each stack instead of looking them up
|
|
# again.
|
|
class QualityGroup(QObject):
|
|
|
|
def __init__(self, name: str, quality_type: str, parent: Optional["QObject"] = None) -> None:
|
|
super().__init__(parent)
|
|
|
|
self.name = name
|
|
self.node_for_global = None # type: Optional[ContainerNode]
|
|
self.nodes_for_extruders = {} # type: Dict[int, ContainerNode]
|
|
self.quality_type = quality_type
|
|
self.is_available = False
|
|
self.is_experimental = False
|
|
|
|
@pyqtSlot(result = str)
|
|
def getName(self) -> str:
|
|
return self.name
|
|
|
|
def getAllKeys(self) -> Set[str]:
|
|
result = set() # type: Set[str]
|
|
for node in [self.node_for_global] + list(self.nodes_for_extruders.values()):
|
|
if node is None:
|
|
continue
|
|
container = node.container
|
|
if container:
|
|
result.update(container.getAllKeys())
|
|
return result
|
|
|
|
def getAllNodes(self) -> List[ContainerNode]:
|
|
result = []
|
|
if self.node_for_global is not None:
|
|
result.append(self.node_for_global)
|
|
for extruder_node in self.nodes_for_extruders.values():
|
|
result.append(extruder_node)
|
|
return result
|
|
|
|
def setGlobalNode(self, node: "ContainerNode") -> None:
|
|
self.node_for_global = node
|
|
|
|
# Update is_experimental flag
|
|
if not node.container:
|
|
Logger.log("w", "Node {0} doesn't have a container.".format(node.container_id))
|
|
return
|
|
is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
|
|
self.is_experimental |= is_experimental
|
|
|
|
def setExtruderNode(self, position: int, node: "ContainerNode") -> None:
|
|
self.nodes_for_extruders[position] = node
|
|
|
|
# Update is_experimental flag
|
|
if not node.container:
|
|
Logger.log("w", "Node {0} doesn't have a container.".format(node.container_id))
|
|
return
|
|
is_experimental = parseBool(node.container.getMetaDataEntry("is_experimental", False))
|
|
self.is_experimental |= is_experimental
|