Merge branch 'CURA-7951_lock_rotation' into optimal_offset

This commit is contained in:
Saumya Jain 2023-08-24 11:54:19 +02:00 committed by GitHub
commit 1e7c975929
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions

View file

@ -5,7 +5,7 @@ if TYPE_CHECKING:
class Arranger: class Arranger:
def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = True) -> Tuple["GroupedOperation", int]: def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = False) -> Tuple["GroupedOperation", int]:
""" """
Find placement for a set of scene nodes, but don't actually move them just yet. Find placement for a set of scene nodes, but don't actually move them just yet.
:param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations :param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations
@ -16,7 +16,7 @@ class Arranger:
""" """
raise NotImplementedError raise NotImplementedError
def arrange(self, add_new_nodes_in_scene: bool = True) -> bool: def arrange(self, add_new_nodes_in_scene: bool = False) -> bool:
""" """
Find placement for a set of scene nodes, and move them by using a single grouped operation. Find placement for a set of scene nodes, and move them by using a single grouped operation.
:param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations :param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations

View file

@ -64,7 +64,7 @@ class GridArrange(Arranger):
self._allowed_grid_idx = self._build_plate_grid_ids.difference(self._fixed_nodes_grid_ids) self._allowed_grid_idx = self._build_plate_grid_ids.difference(self._fixed_nodes_grid_ids)
def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = True) -> Tuple[GroupedOperation, int]: def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = False) -> Tuple[GroupedOperation, int]:
# Find the sequence in which items are placed # Find the sequence in which items are placed
coord_build_plate_center_x = self._build_volume_bounding_box.width * 0.5 + self._build_volume_bounding_box.left coord_build_plate_center_x = self._build_volume_bounding_box.width * 0.5 + self._build_volume_bounding_box.left
coord_build_plate_center_y = self._build_volume_bounding_box.depth * 0.5 + self._build_volume_bounding_box.back coord_build_plate_center_y = self._build_volume_bounding_box.depth * 0.5 + self._build_volume_bounding_box.back
@ -77,7 +77,8 @@ class GridArrange(Arranger):
grouped_operation = GroupedOperation() grouped_operation = GroupedOperation()
for grid_id, node in zip(sequence, self._nodes_to_arrange): for grid_id, node in zip(sequence, self._nodes_to_arrange):
grouped_operation.addOperation(AddSceneNodeOperation(node, scene_root)) if add_new_nodes_in_scene:
grouped_operation.addOperation(AddSceneNodeOperation(node, scene_root))
grid_x, grid_y = grid_id grid_x, grid_y = grid_id
operation = self._moveNodeOnGrid(node, grid_x, grid_y) operation = self._moveNodeOnGrid(node, grid_x, grid_y)
grouped_operation.addOperation(operation) grouped_operation.addOperation(operation)

View file

@ -124,7 +124,7 @@ class Nest2DArrange(Arranger):
return found_solution_for_all, node_items return found_solution_for_all, node_items
def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = True) -> Tuple[GroupedOperation, int]: def createGroupOperationForArrange(self, add_new_nodes_in_scene: bool = False) -> Tuple[GroupedOperation, int]:
scene_root = Application.getInstance().getController().getScene().getRoot() scene_root = Application.getInstance().getController().getScene().getRoot()
found_solution_for_all, node_items = self.findNodePlacement() found_solution_for_all, node_items = self.findNodePlacement()

View file

@ -243,7 +243,7 @@ class CuraActions(QObject):
# Add the new nodes to the scene, and arrange them # Add the new nodes to the scene, and arrange them
arranger = GridArrange(nodes, application.getBuildVolume(), fixed_nodes) arranger = GridArrange(nodes, application.getBuildVolume(), fixed_nodes)
group_operation, not_fit_count = arranger.createGroupOperationForArrange() group_operation, not_fit_count = arranger.createGroupOperationForArrange(add_new_nodes_in_scene = True)
group_operation.push() group_operation.push()
# deselect currently selected nodes, and select the new nodes # deselect currently selected nodes, and select the new nodes