From 719b11655ce3e002f04b065439ae3e80ab4e5d73 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Thu, 24 Aug 2023 11:24:21 +0200 Subject: [PATCH 1/2] Fix ctrl+z issues CURA-7951` --- cura/Arranging/Arranger.py | 4 ++-- cura/Arranging/GridArrange.py | 2 +- cura/Arranging/Nest2DArrange.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/Arranging/Arranger.py b/cura/Arranging/Arranger.py index 684fa1258b..fd93ab1846 100644 --- a/cura/Arranging/Arranger.py +++ b/cura/Arranging/Arranger.py @@ -5,7 +5,7 @@ if TYPE_CHECKING: 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. :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 - 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. :param add_new_nodes_in_scene: Whether to create new scene nodes before applying the transformations and rotations diff --git a/cura/Arranging/GridArrange.py b/cura/Arranging/GridArrange.py index 4866e99b69..9c7f0d31fb 100644 --- a/cura/Arranging/GridArrange.py +++ b/cura/Arranging/GridArrange.py @@ -37,7 +37,7 @@ class GridArrange(Arranger): self._initial_leftover_grid_x = math.floor(self._initial_leftover_grid_x) self._initial_leftover_grid_y = math.floor(self._initial_leftover_grid_y) - 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 grid indexes that intersect with fixed objects fixed_nodes_grid_ids = set() for node in self._fixed_nodes: diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index ea45fe0b8e..bad57c5045 100644 --- a/cura/Arranging/Nest2DArrange.py +++ b/cura/Arranging/Nest2DArrange.py @@ -124,7 +124,7 @@ class Nest2DArrange(Arranger): 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() found_solution_for_all, node_items = self.findNodePlacement() From 1591a2a0c37cd8dc7a443a6f14101ddbf6e605af Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Thu, 24 Aug 2023 11:48:43 +0200 Subject: [PATCH 2/2] ctrl+z for grid CURA-7951 --- cura/Arranging/GridArrange.py | 3 ++- cura/CuraActions.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cura/Arranging/GridArrange.py b/cura/Arranging/GridArrange.py index 9c7f0d31fb..c430de4d73 100644 --- a/cura/Arranging/GridArrange.py +++ b/cura/Arranging/GridArrange.py @@ -67,7 +67,8 @@ class GridArrange(Arranger): grouped_operation = GroupedOperation() 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 operation = self.moveNodeOnGrid(node, grid_x, grid_y) grouped_operation.addOperation(operation) diff --git a/cura/CuraActions.py b/cura/CuraActions.py index 29f50d88b2..9a61a1c4f0 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -243,7 +243,7 @@ class CuraActions(QObject): # Add the new nodes to the scene, and arrange them 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() # deselect currently selected nodes, and select the new nodes