Exemple #1
0
def lineSegFromSequence(seq):
    """
    Return a LineSeg.

    (arg seq) is a sequence of the form '((start_x.start_y),(end_x,end_y))'.
    """
    l = LineSeg()
    l.setStart(pointFromSequence(seq[0]))
    l.setEnd(pointFromSequence(seq[1]))
    return l
Exemple #2
0
def lineSegFromSequence(seq):
    """
    Return a LineSeg.

    (arg seq) is a sequence of the form '((start_x.start_y),(end_x,end_y))'.
    """
    l = LineSeg()
    l.setStart(pointFromSequence(seq[0]))
    l.setEnd(pointFromSequence(seq[1]))
    return l
Exemple #3
0
def boxFromSequence(seq):
    """
    Return a Box.

    (arg seq) is a sequence of the form '((x,y),(x1,y1))' where (x,y) is
    the upper right corner and (x1,y1) is the lower left corner.
    """
    b = Box()
    b._setUpperRight(pointFromSequence(seq[0]))
    b._setLowerLeft(pointFromSequence(seq[1]))
    b._normaliseCornerCoords()
    return b
Exemple #4
0
    def fromString(self,s):
        """
        Initialise the Box from a string.        

        (arg s) should be of the form '((x,y),(x,y))' where x and y are floating
        point numbers.
        
        """        
        seq = eval(s,{},{})
        self._setUpperRight(pointFromSequence(seq[0]))
        self._setLowerLeft(pointFromSequence(seq[1]))
        self._normaliseCornerCoords()
Exemple #5
0
    def fromString(self, s):
        """
        Initialise the Box from a string.        

        (arg s) should be of the form '((x,y),(x,y))' where x and y are floating
        point numbers.
        
        """
        seq = eval(s, {}, {})
        self._setUpperRight(pointFromSequence(seq[0]))
        self._setLowerLeft(pointFromSequence(seq[1]))
        self._normaliseCornerCoords()
Exemple #6
0
def boxFromSequence(seq):
    """
    Return a Box.

    (arg seq) is a sequence of the form '((x,y),(x1,y1))' where (x,y) is
    the upper right corner and (x1,y1) is the lower left corner.
    """
    b = Box()
    b._setUpperRight(pointFromSequence(seq[0]))
    b._setLowerLeft(pointFromSequence(seq[1]))
    b._normaliseCornerCoords()
    return b
Exemple #7
0
def circelFromSequence(seq):
    """
    Return a Circle.

    (arg seq) is a sequence of the form ((x,y),r) where x,y and r
    are floats.
    """
    c = Circle()
    c.setCentre(pointFromSequence(seq[0]))
    c.setRadius(seq[1])
    return c
Exemple #8
0
def circelFromSequence(seq):
    """
    Return a Circle.

    (arg seq) is a sequence of the form ((x,y),r) where x,y and r
    are floats.
    """
    c = Circle()
    c.setCentre(pointFromSequence(seq[0]))
    c.setRadius(seq[1])
    return c
Exemple #9
0
def polygonFromSequence(seq):
    """
    Return a Polygon.

    (arg *seq) a sequence of the form ((x,y),...,(x,y)) that make up the Polygon,
    where x and y are floats.
    """
    poly = Polygon()
    for point in seq:
        poly.append(pointFromSequence(point))
        
    return poly
Exemple #10
0
def polygonFromSequence(seq):
    """
    Return a Polygon.

    (arg *seq) a sequence of the form ((x,y),...,(x,y)) that make up the Polygon,
    where x and y are floats.
    """
    poly = Polygon()
    for point in seq:
        poly.append(pointFromSequence(point))
        
    return poly
               
Exemple #11
0
    def fromString(self,s):
        """
        Initalise the Circle from a string.

        (arg s) should be of the form '<(x,y),r>' although this
        method will also work with the form '((x,y),r)'.
        """
        # circles come out of the db as '<(x,y),r>'
        # so we must first convert them to '((x,y),r'
        s = s.replace('<','(')
        s = s.replace('>',')')        
        seq = eval(s,{},{})
        self.setCentre(pointFromSequence(seq[0]))
        self.setRadius(seq[1])
Exemple #12
0
    def fromString(self, s):
        """
        Initalise the Circle from a string.

        (arg s) should be of the form '<(x,y),r>' although this
        method will also work with the form '((x,y),r)'.
        """
        # circles come out of the db as '<(x,y),r>'
        # so we must first convert them to '((x,y),r'
        s = s.replace('<', '(')
        s = s.replace('>', ')')
        seq = eval(s, {}, {})
        self.setCentre(pointFromSequence(seq[0]))
        self.setRadius(seq[1])
Exemple #13
0
def pathFromSequence(seq):
    """
    Return a Path.

    (arg *seq) a sequence of the form ((x,y),...,(x,y)) that make up the Path,
    where x and y are floats.

    NOTE: The Path will be closed by default.
    """

    path = Path()
    for point in seq:
        path.append(pointFromSequence(point))
        
    return path
Exemple #14
0
def pathFromSequence(seq):
    """
    Return a Path.

    (arg *seq) a sequence of the form ((x,y),...,(x,y)) that make up the Path,
    where x and y are floats.

    NOTE: The Path will be closed by default.
    """

    path = Path()
    for point in seq:
        path.append(pointFromSequence(point))

    return path
Exemple #15
0
    def fromString(self, s):
        """
        Initialse the Path from a string.

        (arg s) is of the form described in
        http://www.postgresql.org/docs/7.3/static/datatype-geometric.html
        
        """
        seq = eval(s, {}, {})
        self.emptyPointList()

        # If it is a tuple PG defines it as closed
        # If it is a list PG defines it as open
        # not nice but what can you do ?
        if type(seq) == types.TupleType:
            self.setClosed()
        elif type(seq) == types.ListType:
            self.setOpen()
        else:
            raise TypeError, 'Bad initalise string must be a Tuple or a List'
        for p in seq:
            self.append(pointFromSequence(p))
Exemple #16
0
    def fromString(self,s):
        """
        Initialse the Path from a string.

        (arg s) is of the form described in
        http://www.postgresql.org/docs/7.3/static/datatype-geometric.html
        
        """
        seq = eval(s,{},{})
        self.emptyPointList()

        # If it is a tuple PG defines it as closed
        # If it is a list PG defines it as open
        # not nice but what can you do ?
        if type(seq) == types.TupleType:
            self.setClosed()
        elif type(seq) == types.ListType:
            self.setOpen()
        else:
            raise TypeError, 'Bad initalise string must be a Tuple or a List'
        for p in seq:
            self.append(pointFromSequence(p))
Exemple #17
0
 def fromString(self,s):
     seq = eval(s,{},{})
     self.setStart(pointFromSequence(seq[0]))
     self.setEnd(pointFromSequence(seq[1]))
Exemple #18
0
 def fromString(self, s):
     seq = eval(s, {}, {})
     self.setStart(pointFromSequence(seq[0]))
     self.setEnd(pointFromSequence(seq[1]))