Multiplying now also gives a message if it could not find a suitable spot for some objects

This commit is contained in:
Jaime van Kessel 2017-04-07 16:40:39 +02:00
parent f9fbd8c02e
commit e26ade0e6f
3 changed files with 19 additions and 6 deletions

View file

@ -84,11 +84,13 @@ class Arrange:
if x is not None: # We could find a place
new_node.setPosition(Vector(x, center_y, y))
found_spot = True
self.place(x, y, hull_shape_arr) # place the object in arranger
else:
Logger.log("d", "Could not find spot!")
Logger.log("d", "Could not find spot!"),
found_spot = False
new_node.setPosition(Vector(200, center_y, 100))
return new_node
return new_node, found_spot
## Fill priority, center is best. Lower value is better
# This is a strategy for the arranger.

View file

@ -1284,7 +1284,7 @@ class CuraApplication(QtApplication):
offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset)
# Step is for skipping tests to make it a lot faster. it also makes the outcome somewhat rougher
node = arranger.findNodePlacement(node, offset_shape_arr, hull_shape_arr, step = 10)
node,_ = arranger.findNodePlacement(node, offset_shape_arr, hull_shape_arr, step = 10)
op = AddSceneNodeOperation(node, scene.getRoot())
op.push()

View file

@ -49,10 +49,17 @@ class MultiplyObjectsJob(Job):
arranger = Arrange.create(scene_root=root)
offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(current_node, min_offset=self._min_offset)
nodes = []
found_solution_for_all = True
for i in range(self._count):
# We do place the nodes one by one, as we want to yield in between.
nodes.append(arranger.findNodePlacement(current_node, offset_shape_arr, hull_shape_arr))
node, solution_found = arranger.findNodePlacement(current_node, offset_shape_arr, hull_shape_arr)
if not solution_found:
found_solution_for_all = False
new_location = node.getPosition()
new_location = new_location.set(z = 100 - i * 20)
node.setPosition(new_location)
nodes.append(node)
Job.yieldThread()
status_message.setProgress((i + 1) / self._count * 100)
@ -62,3 +69,7 @@ class MultiplyObjectsJob(Job):
op.addOperation(AddSceneNodeOperation(new_node, current_node.getParent()))
op.push()
status_message.hide()
if not found_solution_for_all:
no_full_solution_message = Message(i18n_catalog.i18nc("@info:status", "Unable to find a location within the build volume for all objects"))
no_full_solution_message.show()