mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 02:36:02 +08:00
Resolve circular imports
Some of these are only used for the type checks. Contributes to issue CURA-6600.
This commit is contained in:
parent
b05784e607
commit
8e49991087
@ -17,12 +17,11 @@ class ContainerTree:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
container_registry.allMetadataLoaded.connect(self._reloadAll)
|
|
||||||
container_registry.containerAdded.connect(self._machineAdded)
|
container_registry.containerAdded.connect(self._machineAdded)
|
||||||
self._reloadAll()
|
self._loadAll()
|
||||||
|
|
||||||
## (Re)builds the initial container tree.
|
## Builds the initial container tree.
|
||||||
def _reloadAll(self):
|
def _loadAll(self):
|
||||||
all_stacks = ContainerRegistry.getInstance().findContainerStacks()
|
all_stacks = ContainerRegistry.getInstance().findContainerStacks()
|
||||||
for stack in all_stacks:
|
for stack in all_stacks:
|
||||||
definition_id = stack.definition.getId()
|
definition_id = stack.definition.getId()
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
# Copyright (c) 2019 Ultimaker B.V.
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.QualityNode import QualityNode
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from cura.Machines.QualityNode import QualityNode
|
||||||
|
|
||||||
## This class represents an intent profile in the container tree.
|
## This class represents an intent profile in the container tree.
|
||||||
#
|
#
|
||||||
# This class has no more subnodes.
|
# This class has no more subnodes.
|
||||||
class IntentNode(ContainerNode):
|
class IntentNode(ContainerNode):
|
||||||
def __init__(self, container_id: str, quality: QualityNode) -> None:
|
def __init__(self, container_id: str, quality: "QualityNode") -> None:
|
||||||
super().__init__(container_id)
|
super().__init__(container_id)
|
||||||
self.quality = quality
|
self.quality = quality
|
@ -7,16 +7,16 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
|||||||
from UM.Settings.Interfaces import ContainerInterface
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.QualityNode import QualityNode
|
from cura.Machines.QualityNode import QualityNode
|
||||||
from cura.Machines.VariantNode import VariantNode
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from cura.Machines.VariantNode import VariantNode
|
||||||
|
|
||||||
## Represents a material in the container tree.
|
## Represents a material in the container tree.
|
||||||
#
|
#
|
||||||
# Its subcontainers are quality profiles.
|
# Its subcontainers are quality profiles.
|
||||||
class MaterialNode(ContainerNode):
|
class MaterialNode(ContainerNode):
|
||||||
def __init__(self, container_id, variant: VariantNode) -> None:
|
def __init__(self, container_id, variant: "VariantNode") -> None:
|
||||||
super().__init__(container_id)
|
super().__init__(container_id)
|
||||||
self.variant = variant
|
self.variant = variant
|
||||||
self.qualities = {} # type: Dict[str, QualityNode] # Mapping container IDs to quality profiles.
|
self.qualities = {} # type: Dict[str, QualityNode] # Mapping container IDs to quality profiles.
|
||||||
|
@ -12,6 +12,7 @@ from UM.Settings.InstanceContainer import InstanceContainer
|
|||||||
|
|
||||||
from cura.Settings.ExtruderStack import ExtruderStack
|
from cura.Settings.ExtruderStack import ExtruderStack
|
||||||
|
|
||||||
|
from cura.Machines.ContainerTree import ContainerTree
|
||||||
from .QualityGroup import QualityGroup
|
from .QualityGroup import QualityGroup
|
||||||
from .QualityNode import QualityNode
|
from .QualityNode import QualityNode
|
||||||
|
|
||||||
@ -66,6 +67,18 @@ class QualityManager(QObject):
|
|||||||
self._update_timer.timeout.connect(self._updateMaps)
|
self._update_timer.timeout.connect(self._updateMaps)
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
|
container_tree = ContainerTree()
|
||||||
|
for machine_id, machine in container_tree.machines.items():
|
||||||
|
print("--", machine_id)
|
||||||
|
for variant_name, variant in machine.variants.items():
|
||||||
|
print("-- --", variant_name)
|
||||||
|
for material_base_file, material in variant.materials.items():
|
||||||
|
print("-- -- --", material_base_file)
|
||||||
|
for quality_id, quality in material.qualities.items():
|
||||||
|
print("-- -- -- --", quality_id)
|
||||||
|
for intent_id in quality.intents:
|
||||||
|
print("-- -- -- -- --", intent_id)
|
||||||
|
|
||||||
# Initialize the lookup tree for quality profiles with following structure:
|
# Initialize the lookup tree for quality profiles with following structure:
|
||||||
# <machine> -> <nozzle> -> <buildplate> -> <material>
|
# <machine> -> <nozzle> -> <buildplate> -> <material>
|
||||||
# <machine> -> <material>
|
# <machine> -> <material>
|
||||||
|
@ -7,16 +7,16 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
|||||||
from UM.Settings.Interfaces import ContainerInterface
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.IntentNode import IntentNode
|
from cura.Machines.IntentNode import IntentNode
|
||||||
from cura.Machines.MaterialNode import MaterialNode
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from cura.Machines.MaterialNode import MaterialNode
|
||||||
|
|
||||||
## Represents a material profile in the container tree.
|
## Represents a material profile in the container tree.
|
||||||
#
|
#
|
||||||
# Its subcontainers are intent profiles.
|
# Its subcontainers are intent profiles.
|
||||||
class QualityNode(ContainerNode):
|
class QualityNode(ContainerNode):
|
||||||
def __init__(self, container_id: str, material: MaterialNode) -> None:
|
def __init__(self, container_id: str, material: "MaterialNode") -> None:
|
||||||
super().__init__(container_id)
|
super().__init__(container_id)
|
||||||
self.material = material
|
self.material = material
|
||||||
self.intents = {} # type: Dict[str, IntentNode]
|
self.intents = {} # type: Dict[str, IntentNode]
|
||||||
|
@ -6,11 +6,11 @@ from typing import TYPE_CHECKING
|
|||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.Interfaces import ContainerInterface
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.MachineNode import MachineNode
|
|
||||||
from cura.Machines.MaterialNode import MaterialNode
|
from cura.Machines.MaterialNode import MaterialNode
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from cura.Machines.MachineNode import MachineNode
|
||||||
|
|
||||||
## This class represents an extruder variant in the container tree.
|
## This class represents an extruder variant in the container tree.
|
||||||
#
|
#
|
||||||
@ -22,7 +22,7 @@ if TYPE_CHECKING:
|
|||||||
# material diameter setting, we cannot filter them here. Filtering must be
|
# material diameter setting, we cannot filter them here. Filtering must be
|
||||||
# done in the model.
|
# done in the model.
|
||||||
class VariantNode(ContainerNode):
|
class VariantNode(ContainerNode):
|
||||||
def __init__(self, container_id: str, machine: MachineNode) -> None:
|
def __init__(self, container_id: str, machine: "MachineNode") -> None:
|
||||||
super().__init__(container_id)
|
super().__init__(container_id)
|
||||||
self.machine = machine
|
self.machine = machine
|
||||||
self.materials = {} # type: Dict[str, MaterialNode] # Mapping material base files to their nodes.
|
self.materials = {} # type: Dict[str, MaterialNode] # Mapping material base files to their nodes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user