Split up arrange

This splits up the finding of new positions with the actual move. This is needed
for when we want to place new nodes on model load.

CURA-7440
This commit is contained in:
Jaime van Kessel 2020-10-02 11:21:57 +02:00
parent c25351c98a
commit 274dc8d06c
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -10,7 +10,7 @@ from UM.Operations.RotateOperation import RotateOperation
from UM.Operations.TranslateOperation import TranslateOperation
def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) -> bool:
def findNodePlacement(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000):
machine_width = build_volume.getWidth()
machine_depth = build_volume.getDepth()
build_plate_bounding_box = Box(machine_width * factor, machine_depth * factor)
@ -61,6 +61,13 @@ def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000)
node_items = node_items[:-num_disallowed_areas_added]
found_solution_for_all = num_bins == 1
return found_solution_for_all, node_items
def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000) -> bool:
found_solution_for_all, node_items = findNodePlacement(nodes_to_arrange, build_volume, fixed_nodes, factor)
not_fit_count = 0
grouped_operation = GroupedOperation()
for node, node_item in zip(nodes_to_arrange, node_items):
@ -78,4 +85,4 @@ def arrange(nodes_to_arrange, build_volume, fixed_nodes = None, factor = 10000)
not_fit_count += 1
grouped_operation.push()
return found_solution_for_all
return found_solution_for_all