def __init__(self, vertices, colors, faces, transform, layer=0):
     """
     :param args: vertices, colors, faces, transform, layer
     """
     Shape.__init__(self, vertices, colors, faces, transform)
     transform.add_shape(self)
     self.layer = layer
Ejemplo n.º 2
0
    def __init__(self):
        def initHandle(handle):
            self.handles.append(handle)
            QObject.connect(handle, SIGNAL("moved(QGraphicsObject*)"), self.handleMoved)

        Shape.__init__(self, BubbleItem(self))
        # Item
        self.item.setFlag(QGraphicsItem.ItemIsSelectable)
        self.item.setBrush(COLOR)

        # Text item
        self.textItem = QGraphicsTextItem(self.item)
        self.textItem.setTextInteractionFlags(Qt.TextEditorInteraction)
        QObject.connect(self.textItem.document(), SIGNAL("contentsChanged()"), \
            self.adjustSizeFromText)

        # Handles
        self.anchorHandle = Handle(self.item, 0, 0)
        # Position the bubble to the right of the anchor so that it can grow
        # vertically without overflowing the anchor
        self.bubbleHandle = Handle(self.item, ANCHOR_THICKNESS, -ANCHOR_THICKNESS)
        initHandle(self.anchorHandle)
        initHandle(self.bubbleHandle)
        self.setHandlesVisible(False)

        self.adjustSizeFromText()
Ejemplo n.º 3
0
 def __init__(self, geometricName, contour):
     Shape.__init__(self, geometricName, contour)
     cornerList = []
     self.minX = 1000
     self.maxX = 0
     self.minY = 1000
     self.maxY = 0
     contourCopy = contour
     if len(contourCopy) > 1:
         for corner in contourCopy:
             cornerList.append((corner.item(0), corner.item(1)))
         for corner in cornerList:
             if corner[0] > self.maxX:
                 self.maxX = corner[0]
             if corner[1] > self.maxY:
                 self.maxY = corner[1]
             if corner[0] < self.minX:
                 self.minX = corner[0]
             if corner[1] < self.minY:
                 self.minY = corner[1]
     else:
         self.minX = 0
         self.maxX = 960
         self.minY = 0
         self.maxY = 720
Ejemplo n.º 4
0
 def __init__(self, size, rotation, color="blue"):
     texture_path = Shape.build_texture_path(color, Octagon.shape_type)
     Shape.__init__(self, texture_path, size, rotation, Octagon.shape_type, color)
 
     self.sides = 8
     self.color = color
     
Ejemplo n.º 5
0
 def __init__(self, geometricName, contour):
     Shape.__init__(self, geometricName, contour)
     cornerList = []
     self.minX = 1000
     self.maxX = 0
     self.minY = 1000
     self.maxY = 0
     contourCopy = contour
     if len(contourCopy) > 1:
         for corner in contourCopy:
             cornerList.append((corner.item(0), corner.item(1)))
         for corner in cornerList:
             if (corner[0] > self.maxX):
                 self.maxX = corner[0]
             if (corner[1] > self.maxY):
                 self.maxY = corner[1]
             if (corner[0] < self.minX):
                 self.minX = corner[0]
             if (corner[1] < self.minY):
                 self.minY = corner[1]
     else:
         self.minX = 0
         self.maxX = 960
         self.minY = 0
         self.maxY = 720
Ejemplo n.º 6
0
 def __init__(self, ps, color=None):
     Shape.__init__(self, color)
     self.vs = ps
     self.bound = AABox.from_vectors(*self.vs)
     self.half_planes = []
     for i in xrange(len(self.vs)):
         h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
         self.half_planes.append(h)
Ejemplo n.º 7
0
 def __init__(self, ps, color=None):
     Shape.__init__(self, color)
     self.vs = ps
     self.bound = AABox.from_vectors(*self.vs)
     self.half_planes = []
     for i in xrange(len(self.vs)):
         h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
         self.half_planes.append(h)
 def __init__(self,
              p: wx.Pen,
              x1: int,
              y1: int,
              x2: int = None,
              y2: int = None):
     Shape.__init__(self, p, x1, y1, x2, y2)
     self.GrowTo(self.X2(), self.Y2())
Ejemplo n.º 9
0
 def __init__(self, ps, color=None):
     Shape.__init__(self, color)
     mn = min(enumerate(ps), key=lambda (i,v): (v.y, v.x))[0]
     self.vs = list(ps[mn:]) + list(ps[:mn])
     self.bound = Vector.union(*self.vs)
     self.half_planes = []
     for i in xrange(len(self.vs)):
         h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
         self.half_planes.append(h)
Ejemplo n.º 10
0
    def __init__(self):
        Shape.__init__(self, LineItem(self))
        self.item.setFlag(QGraphicsItem.ItemIsSelectable)

        self.handles.append(Handle(self.item, 0, 0))
        self.handles.append(Handle(self.item, 0, 0))
        self.handles[1].setZValue(self.handles[0].zValue() + 1)
        for handle in self.handles:
            QObject.connect(handle, SIGNAL("moved(QGraphicsObject*)"), self.handleMoved)
        self.setHandlesVisible(False)
Ejemplo n.º 11
0
    def __init__(self, theta1=0, theta2=360, *args, **kwargs):
        '''Create an ellipse '''

        self._theta1 = theta1
        self._theta2 = theta2
        Shape.__init__(self, *args, **kwargs)
        self._fill_mode = GL_TRIANGLES
        self._line_mode = GL_LINE_LOOP
        self._update_position()
        self._update_shape()
Ejemplo n.º 12
0
    def __init__(self, radius=0, *args, **kwargs):
        '''Create an (optionable) round rectangle.

        :Parameters:        
            `radius` : int or tuple of 4 int
                Radius of corners.
        '''
        self._radius = radius
        Shape.__init__(self,*args,**kwargs)
        self._update_position()
        self._update_shape()
Ejemplo n.º 13
0
    def __init__(self, corners):
        """
        Create Square self with vertices corners.

        Assume all sides are equal and corners are square.

        @param Square self: this Square object
        @param list[Point] corners: corners that define this Square
        @rtype: None

        >>> s = Square([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 0)])
        """
        Shape.__init__(self, corners)
Ejemplo n.º 14
0
    def __init__(self, direction='up', *args, **kwargs):
        '''Create an oriented triangle.

        :Parameters:
            `direction` : str
               The triangle is oriented relative to its center to this property,
               which must be one of the alignment constants `left`, `right`,
               `up` or `down`.
        '''

        self._direction = direction
        Shape.__init__(self,*args, **kwargs)
        self._update_position()
        self._update_shape()
Ejemplo n.º 15
0
    def __init__(self, corners):
        """
        Create Square self with vertices corners.

        Assume all sides are equal and corners are square.

        Extended from Shape.

        @param Square self: this Square object
        @param list[Point] corners: corners that define this Square
        @rtype: None

        >>> s = Square([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 0)])
        """
        Shape.__init__(self, corners)
Ejemplo n.º 16
0
    def __init__(self, corners):
        """
        Create RightAngleTriangle self with vertices corners.

        Overrides Shape.__init__

        Assume corners[0] is the 90 degree angle.

        @param RightAngleTriangle self: this RightAngleTriangle object
        @param list[Point] corners: corners that define this RightAngleTriangle
        @rtype: None

        >>> s = RightAngleTriangle([Point(0, 0), Point(1, 0), Point(0, 2)])
        """
        Shape.__init__(self, corners)
Ejemplo n.º 17
0
    def __init__(self, thickness=.4, branches=5, *args, **kwargs):
        '''Create a cross.

        :Parameters:
            `thickness` : int
                Thickness of the cross
            `branches` : int
                Number of branches
        '''
        self._thickness = thickness
        self._branches = branches
        Shape.__init__(self, *args, **kwargs)
        self._fill_mode = GL_TRIANGLES
        self._update_position()
        self._update_shape()
Ejemplo n.º 18
0
    def __init__(self, corners):
        """
        Create RightAngleTriangle self with vertices corners.

        Overrides Shape.__init__

        Assume corners[0] is the 90 degree angle.

        @param RightAngleTriangle self: this RightAngleTriangle object
        @param list[Point] corners: corners that define this RightAngleTriangle
        @rtype: None

        >>> s = RightAngleTriangle([Point(0, 0), Point(1, 0), Point(0, 2)])
        """
        Shape.__init__(self, corners)
Ejemplo n.º 19
0
    def __init__(self, dots):
        # Calculate bounds as minimum/maximum values of x and y for all dots
        max_x = max(x for x, y in dots)
        min_x = min(x for x, y in dots)
        max_y = max(y for x, y in dots)
        min_y = min(y for x, y in dots)

        # This will be the bounding box.
        Shape.__init__(self, geometry.Point(min_x, min_y), max_x - min_x,
                       max_y - min_y)

        geometry.Polygon.__init__(self, dots)

        self.gl_vertices = self.get_gl_vertices()

        self.color = getRandomColor()
Ejemplo n.º 20
0
 def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
     Shape.__init__(self, color)
     self.a = a
     self.b = b
     self.c = c
     self.d = d
     self.e = e
     self.f = f
     t = Transform(2 * a, c, 0, c, 2 * b, 0)
     self.center = t.inverse() * Vector(-d, -e)
     l1, l0 = quadratic(1, 2 * (-a - b), 4 * a * b - c * c)
     v = t.eigv()
     axes = [v[0] * ((l0 / 2) ** -0.5), v[1] * ((l1 / 2) ** -0.5)]
     self.bound = Vector.union(self.center - axes[0] - axes[1],
                               self.center - axes[0] + axes[1],
                               self.center + axes[0] - axes[1],
                               self.center + axes[0] + axes[1])
Ejemplo n.º 21
0
 def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
     Shape.__init__(self, color)
     if c*c - 4*a*b >= 0:
         raise Exception("Not an ellipse")
     self.a = a
     self.b = b
     self.c = c
     self.d = d
     self.e = e
     self.f = f
     self.gradient = Transform(2*a, c, d, c, 2*b, e)
     self.center = self.gradient.inverse() * Vector(0, 0)
     y1, y2 = quadratic(b-c*c/4*a, e-c*d/2*a, f-d*d/4*a)
     x1, x2 = quadratic(a-c*c/4*b, d-c*e/2*b, f-e*e/4*b)
     self.bound = AABox.from_vectors(Vector(-(d + c*y1)/2*a, y1),
                                     Vector(-(d + c*y2)/2*a, y2),
                                     Vector(x1, -(e + c*x1)/2*b),
                                     Vector(x2, -(e + c*x2)/2*b))
     if not self.contains(self.center):
         raise Exception("Internal error, center not inside ellipse")
Ejemplo n.º 22
0
 def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
     Shape.__init__(self, color)
     if c * c - 4 * a * b >= 0:
         raise Exception("Not an ellipse")
     self.a = a
     self.b = b
     self.c = c
     self.d = d
     self.e = e
     self.f = f
     self.gradient = Transform(2 * a, c, d, c, 2 * b, e)
     self.center = self.gradient.inverse() * Vector(0, 0)
     y1, y2 = quadratic(b - c * c / 4 * a, e - c * d / 2 * a,
                        f - d * d / 4 * a)
     x1, x2 = quadratic(a - c * c / 4 * b, d - c * e / 2 * b,
                        f - e * e / 4 * b)
     self.bound = AABox.from_vectors(Vector(-(d + c * y1) / 2 * a, y1),
                                     Vector(-(d + c * y2) / 2 * a, y2),
                                     Vector(x1, -(e + c * x1) / 2 * b),
                                     Vector(x2, -(e + c * x2) / 2 * b))
     if not self.contains(self.center):
         raise Exception("Internal error, center not inside ellipse")
Ejemplo n.º 23
0
 def __init__(self):
     """
         Constructor of Pyramid
     """
     Shape.__init__(self)
     self.subdivision_list = [self.vertices_list]
Ejemplo n.º 24
0
 def __init__(self, x=0, y=0, radius=1):
     Shape.__init__(self, x, y)
     self.radius = radius
Ejemplo n.º 25
0
 def __init__(self, y=0):
     Shape.__init__(self)
     self.y = y
     self.parent = Shape
Ejemplo n.º 26
0
 def __init__(self, r=1, x=0, y=0):
     Shape.__init__(self, x, y)
     self.radius = r
Ejemplo n.º 27
0
 def __init__(self, shape):
     Shape.__init__(self, shape)
Ejemplo n.º 28
0
 def __init__(self, side_length):
   Shape.__init__(self, 'Equilateral Triangle')
   self.__side_length = side_length
 def __init__(self, radius):
   Shape.__init__(self, 'Circle')
   self.__radius = radius
Ejemplo n.º 30
0
 def __init__(self):
     Shape.__init__(self)
     self.drawing_type = GL_TRIANGLES
     self.setup_shaders()
     self.setup_buffers()
Ejemplo n.º 31
0
 def __init__(self, r = 1, x = 0, y = 0):
     Shape.__init__(self, x, y)
     self.radius = r
Ejemplo n.º 32
0
 def __init__(self, shape, scaler):
     Shape.__init__(self, shape.priors)
     self.shape = shape
     self.scaler = scaler
Ejemplo n.º 33
0
 def __init__(self, priors=None):
     Shape.__init__(self, priors)
Ejemplo n.º 34
0
 def __init__(self, s1, s2, s3, s4):
     Shape.__init__(self, 4)
     self.s1 = s1
     self.s2 = s2
     self.s3 = s3
     self.s4 = s4
Ejemplo n.º 35
0
 def __init__(self, sides):
     Shape.__init__(self, sides)
Ejemplo n.º 36
0
    def __init__(self, center, radius):
        Shape.__init__(self, center - radius, radius * 2, radius * 2)
        geometry.Circle.__init__(self, center, radius)

        # Normalization needed for OpenGL color model (vec4([0...1]))
        self.color = getRandomColor()
Ejemplo n.º 37
0
 def __init__(self, x, y, r, c):
     """Inherits all instance variables from parent + adding one"""
     Shape.__init__(self, x, y, r)
     self.c = c
Ejemplo n.º 38
0
 def __init__(self, geometricName, contour):
     Shape.__init__(self, geometricName, contour)
Ejemplo n.º 39
0
 def __init__(self):
     Shape.__init__(self)
     self._fill = '*'
Ejemplo n.º 40
0
 def __init__(self,n,priors=None):
     self.n = n
     Shape.__init__(self, priors)
Ejemplo n.º 41
0
 def __init__(self):
     Shape.__init__(self)
Ejemplo n.º 42
0
 def __init__(self, base, height):
   Shape.__init__(self, 'Isoceles Triangle')
   self.__base = base
   self.__height = height
Ejemplo n.º 43
0
 def __init__(self, v1, v2, color=None):
     Shape.__init__(self, color or v1.color or v2.color)
     self.v1 = v1
     self.v2 = v2
Ejemplo n.º 44
0
 def __init__(self):
     Shape.__init__(self)
     self.parent = Shape
Ejemplo n.º 45
0
 def __init__(self, v1, v2, color=None):
     Shape.__init__(self, color or v1.color or v2.color)
     self.v1 = v1
     self.v2 = v2
Ejemplo n.º 46
0
 def __init__(self, geometricName, contour):
     Shape.__init__(self, geometricName, contour)
Ejemplo n.º 47
0
 def __init__(self):
     """
         Constructor for Cube
     """
     Shape.__init__(self)
     self.subdivision_list = [self.vertices_list]
Ejemplo n.º 48
0
 def __init__(self, base, height):
     Shape.__init__(self, 'Rectangle')
     self.__base = base
     self.__height = height
Ejemplo n.º 49
0
 def __init__(self, origin=Point(0, 0, 0), radius=1):
     Shape.__init__(self)
     self.origin = origin
     self.radius = radius
     self.parent = Shape
Ejemplo n.º 50
0
 def __init__(self):
     Shape.__init__(self, priors=None)
Ejemplo n.º 51
0
 def __init__(self, shape, scaler):
     Shape.__init__(self, shape.priors)
     self.shape = shape
     self.scaler = scaler