mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-02 23:31:42 -07:00
Add some profiling decorators to the ContainerTree
This commit is contained in:
parent
71e9fb8a22
commit
85ed22de4c
6 changed files with 15 additions and 3 deletions
|
|
@ -11,11 +11,13 @@ from cura.Settings.GlobalStack import GlobalStack # To listen only to global st
|
||||||
|
|
||||||
from typing import Dict, List, TYPE_CHECKING
|
from typing import Dict, List, TYPE_CHECKING
|
||||||
import time
|
import time
|
||||||
|
import UM.FlameProfiler
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from cura.Machines.QualityGroup import QualityGroup
|
from cura.Machines.QualityGroup import QualityGroup
|
||||||
from cura.Machines.QualityChangesGroup import QualityChangesGroup
|
from cura.Machines.QualityChangesGroup import QualityChangesGroup
|
||||||
|
|
||||||
|
|
||||||
## This class contains a look-up tree for which containers are available at
|
## This class contains a look-up tree for which containers are available at
|
||||||
# which stages of configuration.
|
# which stages of configuration.
|
||||||
#
|
#
|
||||||
|
|
@ -77,6 +79,7 @@ class ContainerTree:
|
||||||
# Add a machine node by the id of it's definition.
|
# Add a machine node by the id of it's definition.
|
||||||
# This is automatically called by the _machineAdded function, but it's sometimes needed to add a machine node
|
# This is automatically called by the _machineAdded function, but it's sometimes needed to add a machine node
|
||||||
# faster than would have been done when waiting on any signals (for instance; when creating an entirely new machine)
|
# faster than would have been done when waiting on any signals (for instance; when creating an entirely new machine)
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def addMachineNodeByDefinitionId(self, definition_id: str) -> None:
|
def addMachineNodeByDefinitionId(self, definition_id: str) -> None:
|
||||||
if definition_id in self.machines:
|
if definition_id in self.machines:
|
||||||
return # Already have this definition ID.
|
return # Already have this definition ID.
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from cura.Machines.ContainerNode import ContainerNode
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from cura.Machines.QualityNode import QualityNode
|
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.
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from cura.Machines.QualityChangesGroup import QualityChangesGroup # To construc
|
||||||
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
|
||||||
|
import UM.FlameProfiler
|
||||||
|
|
||||||
|
|
||||||
## This class represents a machine in the container tree.
|
## This class represents a machine in the container tree.
|
||||||
|
|
@ -168,6 +169,7 @@ class MachineNode(ContainerNode):
|
||||||
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.
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _loadAll(self):
|
def _loadAll(self):
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
if not self.has_variants:
|
if not self.has_variants:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from UM.Settings.Interfaces import ContainerInterface
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.QualityNode import QualityNode
|
from cura.Machines.QualityNode import QualityNode
|
||||||
|
import UM.FlameProfiler
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from cura.Machines.VariantNode import VariantNode
|
from cura.Machines.VariantNode import VariantNode
|
||||||
|
|
@ -55,6 +55,7 @@ class MaterialNode(ContainerNode):
|
||||||
))
|
))
|
||||||
return fallback
|
return fallback
|
||||||
|
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _loadAll(self) -> None:
|
def _loadAll(self) -> None:
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
# Find all quality profiles that fit on this material.
|
# Find all quality profiles that fit on this material.
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ from typing import Union, TYPE_CHECKING
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.IntentNode import IntentNode
|
from cura.Machines.IntentNode import IntentNode
|
||||||
|
import UM.FlameProfiler
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from cura.Machines.MaterialNode import MaterialNode
|
from cura.Machines.MaterialNode import MaterialNode
|
||||||
from cura.Machines.MachineNode import MachineNode
|
from cura.Machines.MachineNode import MachineNode
|
||||||
|
|
||||||
|
|
||||||
## Represents a quality profile in the container tree.
|
## Represents a quality profile in the container tree.
|
||||||
#
|
#
|
||||||
# This may either be a normal quality profile or a global quality profile.
|
# This may either be a normal quality profile or a global quality profile.
|
||||||
|
|
@ -29,6 +30,7 @@ class QualityNode(ContainerNode):
|
||||||
self._material = my_metadata.get("material")
|
self._material = my_metadata.get("material")
|
||||||
self._loadAll()
|
self._loadAll()
|
||||||
|
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _loadAll(self) -> None:
|
def _loadAll(self) -> None:
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from UM.Settings.Interfaces import ContainerInterface
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from cura.Machines.ContainerNode import ContainerNode
|
from cura.Machines.ContainerNode import ContainerNode
|
||||||
from cura.Machines.MaterialNode import MaterialNode
|
from cura.Machines.MaterialNode import MaterialNode
|
||||||
|
import UM.FlameProfiler
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from cura.Machines.MachineNode import MachineNode
|
from cura.Machines.MachineNode import MachineNode
|
||||||
|
|
@ -38,6 +38,7 @@ class VariantNode(ContainerNode):
|
||||||
self._loadAll()
|
self._loadAll()
|
||||||
|
|
||||||
## (Re)loads all materials under this variant.
|
## (Re)loads all materials under this variant.
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _loadAll(self) -> None:
|
def _loadAll(self) -> None:
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
|
|
@ -92,6 +93,7 @@ class VariantNode(ContainerNode):
|
||||||
|
|
||||||
## When a material gets added to the set of profiles, we need to update our
|
## When a material gets added to the set of profiles, we need to update our
|
||||||
# tree here.
|
# tree here.
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _materialAdded(self, container: ContainerInterface) -> None:
|
def _materialAdded(self, container: ContainerInterface) -> None:
|
||||||
if container.getMetaDataEntry("type") != "material":
|
if container.getMetaDataEntry("type") != "material":
|
||||||
return # Not interested.
|
return # Not interested.
|
||||||
|
|
@ -125,6 +127,7 @@ class VariantNode(ContainerNode):
|
||||||
self.materials[base_file].materialChanged.connect(self.materialsChanged)
|
self.materials[base_file].materialChanged.connect(self.materialsChanged)
|
||||||
self.materialsChanged.emit(self.materials[base_file])
|
self.materialsChanged.emit(self.materials[base_file])
|
||||||
|
|
||||||
|
@UM.FlameProfiler.profile
|
||||||
def _materialRemoved(self, container: ContainerInterface) -> None:
|
def _materialRemoved(self, container: ContainerInterface) -> None:
|
||||||
if container.getMetaDataEntry("type") != "material":
|
if container.getMetaDataEntry("type") != "material":
|
||||||
return # Only interested in materials.
|
return # Only interested in materials.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue