ProfilesModel.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (c) 2016 Ultimaker B.V.
  2. # Uranium is released under the terms of the AGPLv3 or higher.
  3. from UM.Application import Application
  4. from UM.Settings.Models.InstanceContainersModel import InstanceContainersModel
  5. from cura.QualityManager import QualityManager
  6. from cura.Settings.ExtruderManager import ExtruderManager
  7. from cura.Settings.MachineManager import MachineManager
  8. ## QML Model for listing the current list of valid quality profiles.
  9. #
  10. class ProfilesModel(InstanceContainersModel):
  11. def __init__(self, parent = None):
  12. super().__init__(parent)
  13. Application.getInstance().globalContainerStackChanged.connect(self._update)
  14. Application.getInstance().getMachineManager().activeVariantChanged.connect(self._update)
  15. Application.getInstance().getMachineManager().activeStackChanged.connect(self._update)
  16. Application.getInstance().getMachineManager().activeMaterialChanged.connect(self._update)
  17. ## Fetch the list of containers to display.
  18. #
  19. # See UM.Settings.Models.InstanceContainersModel._fetchInstanceContainers().
  20. def _fetchInstanceContainers(self):
  21. global_container_stack = Application.getInstance().getGlobalContainerStack()
  22. if global_container_stack is None:
  23. return []
  24. # Get the list of extruders and place the selected extruder at the front of the list.
  25. extruder_manager = ExtruderManager.getInstance()
  26. active_extruder = extruder_manager.getActiveExtruderStack()
  27. extruder_stacks = extruder_manager.getActiveExtruderStacks()
  28. if active_extruder in extruder_stacks:
  29. extruder_stacks.remove(active_extruder)
  30. extruder_stacks = [active_extruder] + extruder_stacks
  31. # Fetch the list of useable qualities across all extruders.
  32. # The actual list of quality profiles come from the first extruder in the extruder list.
  33. return QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_container_stack,
  34. extruder_stacks)