Arranger.py 1.5 KB

12345678910111213141516171819202122232425262728
  1. from typing import List, TYPE_CHECKING, Optional, Tuple, Set
  2. if TYPE_CHECKING:
  3. from UM.Operations.GroupedOperation import GroupedOperation
  4. class Arranger:
  5. def createGroupOperationForArrange(self, *, add_new_nodes_in_scene: bool = False) -> Tuple["GroupedOperation", int]:
  6. """
  7. Find placement for a set of scene nodes, but don't actually move them just yet.
  8. :param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations
  9. :return: tuple (found_solution_for_all, node_items)
  10. WHERE
  11. found_solution_for_all: Whether the algorithm found a place on the buildplate for all the objects
  12. node_items: A list of the nodes return by libnest2d, which contain the new positions on the buildplate
  13. """
  14. raise NotImplementedError
  15. def arrange(self, *, add_new_nodes_in_scene: bool = False) -> bool:
  16. """
  17. Find placement for a set of scene nodes, and move them by using a single grouped operation.
  18. :param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations
  19. :return: found_solution_for_all: Whether the algorithm found a place on the buildplate for all the objects
  20. """
  21. grouped_operation, not_fit_count = self.createGroupOperationForArrange(
  22. add_new_nodes_in_scene=add_new_nodes_in_scene)
  23. grouped_operation.push()
  24. return not_fit_count == 0