QualityChangesGroup.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2019 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Any, Dict, Optional
  4. from PyQt6.QtCore import QObject, pyqtProperty, pyqtSignal
  5. class QualityChangesGroup(QObject):
  6. """Data struct to group several quality changes instance containers together.
  7. Each group represents one "custom profile" as the user sees it, which contains an instance container for the
  8. global stack and one instance container per extruder.
  9. """
  10. def __init__(self, name: str, quality_type: str, intent_category: str, parent: Optional["QObject"] = None) -> None:
  11. super().__init__(parent)
  12. self._name = name
  13. self.quality_type = quality_type
  14. self.intent_category = intent_category
  15. self.is_available = False
  16. self.metadata_for_global = {} # type: Dict[str, Any]
  17. self.metadata_per_extruder = {} # type: Dict[int, Dict[str, Any]]
  18. nameChanged = pyqtSignal()
  19. def setName(self, name: str) -> None:
  20. if self._name != name:
  21. self._name = name
  22. self.nameChanged.emit()
  23. @pyqtProperty(str, fset = setName, notify = nameChanged)
  24. def name(self) -> str:
  25. return self._name
  26. def __str__(self) -> str:
  27. return "{class_name}[{name}, available = {is_available}]".format(class_name = self.__class__.__name__, name = self.name, is_available = self.is_available)