Added comments. CURA-3239

This commit is contained in:
Jack Ha 2017-04-04 10:29:10 +02:00
parent 3d16c4120e
commit 535330ef51
2 changed files with 18 additions and 7 deletions

View file

@ -847,9 +847,9 @@ class CuraApplication(QtApplication):
op.push() op.push()
## Create a number of copies of existing object. ## Create a number of copies of existing object.
# object_id # \param object_id
# count: number of copies # \param count number of copies
# min_offset: minimum offset to other objects. # \param min_offset minimum offset to other objects.
@pyqtSlot("quint64", int) @pyqtSlot("quint64", int)
def multiplyObject(self, object_id, count, min_offset = 8): def multiplyObject(self, object_id, count, min_offset = 8):
node = self.getController().getScene().findObject(object_id) node = self.getController().getScene().findObject(object_id)
@ -1027,6 +1027,8 @@ class CuraApplication(QtApplication):
self.arrange(nodes, fixed_nodes) self.arrange(nodes, fixed_nodes)
## Arrange the nodes, given fixed nodes ## Arrange the nodes, given fixed nodes
# \param nodes nodes that we have to place
# \param fixed_nodes nodes that are placed in the arranger before finding spots for nodes
def arrange(self, nodes, fixed_nodes): def arrange(self, nodes, fixed_nodes):
min_offset = 8 min_offset = 8

View file

@ -4,8 +4,7 @@ import copy
from UM.Math.Polygon import Polygon from UM.Math.Polygon import Polygon
## Polygon representation as an array ## Polygon representation as an array for use with Arrange
#
class ShapeArray: class ShapeArray:
def __init__(self, arr, offset_x, offset_y, scale = 1): def __init__(self, arr, offset_x, offset_y, scale = 1):
self.arr = arr self.arr = arr
@ -13,6 +12,9 @@ class ShapeArray:
self.offset_y = offset_y self.offset_y = offset_y
self.scale = scale self.scale = scale
## Instantiate from a bunch of vertices
# \param vertices
# \param scale scale the coordinates
@classmethod @classmethod
def fromPolygon(cls, vertices, scale = 1): def fromPolygon(cls, vertices, scale = 1):
# scale # scale
@ -31,7 +33,10 @@ class ShapeArray:
arr = cls.arrayFromPolygon(shape, flip_vertices) arr = cls.arrayFromPolygon(shape, flip_vertices)
return cls(arr, offset_x, offset_y) return cls(arr, offset_x, offset_y)
## Return an offset and hull ShapeArray from a scene node. ## Instantiate an offset and hull ShapeArray from a scene node.
# \param node source node where the convex hull must be present
# \param min_offset offset for the offset ShapeArray
# \param scale scale the coordinates
@classmethod @classmethod
def fromNode(cls, node, min_offset, scale = 0.5): def fromNode(cls, node, min_offset, scale = 0.5):
transform = node._transformation transform = node._transformation
@ -52,11 +57,12 @@ class ShapeArray:
return offset_shape_arr, hull_shape_arr return offset_shape_arr, hull_shape_arr
## Create np.array with dimensions defined by shape ## Create np.array with dimensions defined by shape
# Fills polygon defined by vertices with ones, all other values zero # Fills polygon defined by vertices with ones, all other values zero
# Only works correctly for convex hull vertices # Only works correctly for convex hull vertices
# Originally from: http://stackoverflow.com/questions/37117878/generating-a-filled-polygon-inside-a-numpy-array # Originally from: http://stackoverflow.com/questions/37117878/generating-a-filled-polygon-inside-a-numpy-array
# \param shape numpy format shape, [x-size, y-size]
# \param vertices
@classmethod @classmethod
def arrayFromPolygon(cls, shape, vertices): def arrayFromPolygon(cls, shape, vertices):
base_array = numpy.zeros(shape, dtype=float) # Initialize your array of zeros base_array = numpy.zeros(shape, dtype=float) # Initialize your array of zeros
@ -77,6 +83,9 @@ class ShapeArray:
# input indices against interpolated value # input indices against interpolated value
# Returns boolean array, with True inside and False outside of shape # Returns boolean array, with True inside and False outside of shape
# Originally from: http://stackoverflow.com/questions/37117878/generating-a-filled-polygon-inside-a-numpy-array # Originally from: http://stackoverflow.com/questions/37117878/generating-a-filled-polygon-inside-a-numpy-array
# \param p1 2-tuple with x, y for point 1
# \param p2 2-tuple with x, y for point 2
# \param base_array boolean array to project the line on
@classmethod @classmethod
def _check(cls, p1, p2, base_array): def _check(cls, p1, p2, base_array):
if p1[0] == p2[0] and p1[1] == p2[1]: if p1[0] == p2[0] and p1[1] == p2[1]: