ArrangeObjectsJob.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (c) 2019 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import List
  4. from UM.Application import Application
  5. from UM.Job import Job
  6. from UM.Message import Message
  7. from UM.Scene.SceneNode import SceneNode
  8. from UM.i18n import i18nCatalog
  9. from cura.Arranging.Nest2DArrange import arrange
  10. i18n_catalog = i18nCatalog("cura")
  11. class ArrangeObjectsJob(Job):
  12. def __init__(self, nodes: List[SceneNode], fixed_nodes: List[SceneNode], min_offset = 8) -> None:
  13. super().__init__()
  14. self._nodes = nodes
  15. self._fixed_nodes = fixed_nodes
  16. self._min_offset = min_offset
  17. def run(self):
  18. status_message = Message(i18n_catalog.i18nc("@info:status", "Finding new location for objects"),
  19. lifetime = 0,
  20. dismissable = False,
  21. progress = 0,
  22. title = i18n_catalog.i18nc("@info:title", "Finding Location"))
  23. status_message.show()
  24. found_solution_for_all = arrange(self._nodes, Application.getInstance().getBuildVolume(), self._fixed_nodes)
  25. status_message.hide()
  26. if not found_solution_for_all:
  27. no_full_solution_message = Message(
  28. i18n_catalog.i18nc("@info:status",
  29. "Unable to find a location within the build volume for all objects"),
  30. title = i18n_catalog.i18nc("@info:title", "Can't Find Location"))
  31. no_full_solution_message.show()
  32. self.finished.emit(self)