mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 15:13:56 -06:00
review comments fixed
Co-authored-by: Casper Lamboo <c.lamboo@ultimaker.com> CURA-7951
This commit is contained in:
parent
7449e2137c
commit
b662da732e
5 changed files with 32 additions and 15 deletions
|
@ -21,7 +21,6 @@ class GridArrange:
|
|||
_build_volume_bounding_box = AxisAlignedBox
|
||||
|
||||
def __init__(self, nodes_to_arrange: List["SceneNode"], build_volume: "BuildVolume", fixed_nodes: List["SceneNode"] = []):
|
||||
print("len(nodes_to_arrange)", len(nodes_to_arrange))
|
||||
self._nodes_to_arrange = nodes_to_arrange
|
||||
self._build_volume_bounding_box = build_volume.getBoundingBox()
|
||||
self._fixed_nodes = fixed_nodes
|
||||
|
@ -72,7 +71,6 @@ class GridArrange:
|
|||
for grid_id, node in zip(sequence, self._nodes_to_arrange):
|
||||
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)
|
||||
|
||||
|
@ -81,18 +79,14 @@ class GridArrange:
|
|||
left_over_grid_y = self._initial_leftover_grid_y
|
||||
for node in leftover_nodes:
|
||||
grouped_operation.addOperation(AddSceneNodeOperation(node, scene_root))
|
||||
|
||||
# find the first next grid position that isn't occupied by a fixed node
|
||||
while (self._initial_leftover_grid_x, left_over_grid_y) in fixed_nodes_grid_ids:
|
||||
left_over_grid_y = left_over_grid_y - 1
|
||||
|
||||
operation = self.moveNodeOnGrid(node, self._initial_leftover_grid_x, left_over_grid_y)
|
||||
grouped_operation.addOperation(operation)
|
||||
|
||||
left_over_grid_y = left_over_grid_y - 1
|
||||
|
||||
self.drawDebugSvg()
|
||||
|
||||
return grouped_operation, len(leftover_nodes)
|
||||
|
||||
def moveNodeOnGrid(self, node: "SceneNode", grid_x: int, grid_y: int) -> "Operation.Operation":
|
||||
|
|
|
@ -83,18 +83,25 @@ class CuraActions(QObject):
|
|||
center_operation = TranslateOperation(current_node, Vector(0, center_y, 0), set_position=True)
|
||||
operation.addOperation(center_operation)
|
||||
operation.push()
|
||||
@pyqtSlot(int)
|
||||
def multiplySelection(self, count: int) -> None:
|
||||
"""Multiply all objects in the selection
|
||||
:param count: The number of times to multiply the selection.
|
||||
"""
|
||||
min_offset = cura.CuraApplication.CuraApplication.getInstance().getBuildVolume().getEdgeDisallowedSize() + 2 # Allow for some rounding errors
|
||||
job = MultiplyObjectsJob(Selection.getAllSelectedObjects(), count, min_offset = max(min_offset, 8))
|
||||
job.start()
|
||||
|
||||
@pyqtSlot(int, bool)
|
||||
def multiplySelection(self, count: int, grid_placement: bool) -> None:
|
||||
@pyqtSlot(int)
|
||||
def multiplySelectionToGrid(self, count: int) -> None:
|
||||
"""Multiply all objects in the selection
|
||||
|
||||
:param count: The number of times to multiply the selection.
|
||||
:param grid_placement: If set to true objects are placed in a grid
|
||||
"""
|
||||
|
||||
min_offset = cura.CuraApplication.CuraApplication.getInstance().getBuildVolume().getEdgeDisallowedSize() + 2 # Allow for some rounding errors
|
||||
job = MultiplyObjectsJob(Selection.getAllSelectedObjects(), count, min_offset=max(min_offset, 8),
|
||||
grid_arrange=grid_placement)
|
||||
grid_arrange=True)
|
||||
job.start()
|
||||
|
||||
@pyqtSlot()
|
||||
|
|
|
@ -1440,8 +1440,15 @@ class CuraApplication(QtApplication):
|
|||
op.push()
|
||||
|
||||
# Single build plate
|
||||
@pyqtSlot(bool)
|
||||
def arrangeAll(self, grid_arrangement: bool) -> None:
|
||||
@pyqtSlot()
|
||||
def arrangeAll(self) -> None:
|
||||
self._arrangeAll(False)
|
||||
|
||||
@pyqtSlot()
|
||||
def arrangeAllInGrid(self) -> None:
|
||||
self._arrangeAll(True)
|
||||
|
||||
def _arrangeAll(self, grid_arrangement: bool) -> None:
|
||||
nodes_to_arrange = []
|
||||
active_build_plate = self.getMultiBuildPlateModel().activeBuildPlate
|
||||
locked_nodes = []
|
||||
|
|
|
@ -458,7 +458,7 @@ Item
|
|||
{
|
||||
id: arrangeAllAction
|
||||
text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models")
|
||||
onTriggered: Printer.arrangeAll(false)
|
||||
onTriggered: Printer.arrangeAll()
|
||||
shortcut: "Ctrl+R"
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ Item
|
|||
{
|
||||
id: arrangeAllGridAction
|
||||
text: catalog.i18nc("@action:inmenu menubar:edit","Arrange All Models in a grid")
|
||||
onTriggered: Printer.arrangeAll(true)
|
||||
onTriggered: Printer.arrangeAllInGrid()
|
||||
shortcut: "Shift+Ctrl+R"
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,16 @@ Cura.Menu
|
|||
minimumWidth: UM.Theme.getSize("small_popup_dialog").width
|
||||
minimumHeight: UM.Theme.getSize("small_popup_dialog").height
|
||||
|
||||
onAccepted: CuraActions.multiplySelection(copiesField.value, gridPlacementSelected.checked)
|
||||
onAccepted: {
|
||||
if (gridPlacementSelected.checked)
|
||||
{
|
||||
CuraActions.multiplySelectionToGrid(copiesField.value)
|
||||
}
|
||||
else
|
||||
{
|
||||
CuraActions.multiplySelection(copiesField.value)
|
||||
}
|
||||
}
|
||||
|
||||
buttonSpacing: UM.Theme.getSize("thin_margin").width
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue