Browse Source

re-add functions for arrange

To avoid api break
new functions are added with the depricated decorator
c.lamboo 1 year ago
parent
commit
4eb0ba9861
1 changed files with 28 additions and 0 deletions
  1. 28 0
      cura/Arranging/Nest2DArrange.py

+ 28 - 0
cura/Arranging/Nest2DArrange.py

@@ -6,6 +6,7 @@ from pynest2d import Point, Box, Item, NfpConfig, nest
 from typing import List, TYPE_CHECKING, Optional, Tuple
 
 from UM.Application import Application
+from UM.Decorators import deprecated
 from UM.Logger import Logger
 from UM.Math.Matrix import Matrix
 from UM.Math.Polygon import Polygon
@@ -149,3 +150,30 @@ class Nest2DArrange(Arranger):
                 not_fit_count += 1
 
         return grouped_operation, not_fit_count
+
+
+@deprecated("Use the Nest2DArrange class instead")
+def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildVolume",
+                      fixed_nodes: Optional[List["SceneNode"]] = None, factor=10000) -> Tuple[bool, List[Item]]:
+    arranger = Nest2DArrange(nodes_to_arrange, build_volume, fixed_nodes, factor=factor)
+    return arranger.findNodePlacement()
+
+
+@deprecated("Use the Nest2DArrange class instead")
+def createGroupOperationForArrange(nodes_to_arrange: List["SceneNode"],
+                                   build_volume: "BuildVolume",
+                                   fixed_nodes: Optional[List["SceneNode"]] = None,
+                                   factor=10000,
+                                   add_new_nodes_in_scene: bool = False) -> Tuple[GroupedOperation, int]:
+    arranger = Nest2DArrange(nodes_to_arrange, build_volume, fixed_nodes, factor=factor)
+    return arranger.createGroupOperationForArrange(add_new_nodes_in_scene=add_new_nodes_in_scene)
+
+
+@deprecated("Use the Nest2DArrange class instead")
+def arrange(nodes_to_arrange: List["SceneNode"],
+            build_volume: "BuildVolume",
+            fixed_nodes: Optional[List["SceneNode"]] = None,
+            factor=10000,
+            add_new_nodes_in_scene: bool = False) -> bool:
+    arranger = Nest2DArrange(nodes_to_arrange, build_volume, fixed_nodes, factor=factor)
+    return arranger.arrange(add_new_nodes_in_scene=add_new_nodes_in_scene)