示例#1
0
class Fork(QPrimitive, Bordered):
    left = None
    right = None
    mid = None
    height = 10
    inverted = False

    def get_midx(self):
        lx, ly = self.left.get_xy()
        rx, ry = self.right.get_xy()
        return lx + (rx - lx) / 2.

    def set_points(self, lx, ly, rx, ry, mx, my):
        self.left = Point(lx, ly)
        self.right = Point(rx, ry)
        self.mid = Point(mx, my)

        self.inverted = my > ly

    def set_canvas(self, canvas):
        self.left.set_canvas(canvas)
        self.right.set_canvas(canvas)
        self.mid.set_canvas(canvas)
        super(Fork, self).set_canvas(canvas)

    def _render(self, gc):
        lx, ly = self.left.get_xy()
        rx, ry = self.right.get_xy()
        mx, my = self.mid.get_xy()
        # ly, ry = ly - 30, ry - 30
        mx = lx + (rx - lx) / 2.

        w, h = self.get_wh()
        # print self.height, h, self.canvas
        # M
        # |
        # _|_
        # |   |
        # L   R
        with gc:
            gc.set_line_width(20)
            gc.set_stroke_color(self._get_border_color())

            # gc.set_line_width(5)
            # fill in corners
            gc.move_to(lx - 10, ly + h - 5)
            gc.line_to(rx + 10, ly + h - 5)

            fork(gc, lx, ly, rx, ry, mx, my, h)

        gc.set_line_width(10)
        # self.set_fill_color(gc)
        fork(gc, lx, ly, rx, ry, mx, my, h)
示例#2
0
class Fork(QPrimitive, Bordered):
    left = None
    right = None
    mid = None
    height = 10
    inverted = False

    def get_midx(self):
        lx, ly = self.left.get_xy()
        rx, ry = self.right.get_xy()
        return lx + (rx - lx) / 2.

    def set_points(self, lx, ly, rx, ry, mx, my):
        self.left = Point(lx, ly)
        self.right = Point(rx, ry)
        self.mid = Point(mx, my)

        self.inverted = my > ly

    def set_canvas(self, canvas):
        self.left.set_canvas(canvas)
        self.right.set_canvas(canvas)
        self.mid.set_canvas(canvas)
        super(Fork, self).set_canvas(canvas)

    def _render(self, gc):
        lx, ly = self.left.get_xy()
        rx, ry = self.right.get_xy()
        mx, my = self.mid.get_xy()
        # ly, ry = ly - 30, ry - 30
        mx = lx + (rx - lx) / 2.

        w, h = self.get_wh()
        # print self.height, h, self.canvas
        # M
        # |
        # _|_
        # |   |
        # L   R
        with gc:
            gc.set_line_width(20)
            gc.set_stroke_color(self._get_border_color())

            # gc.set_line_width(5)
            # fill in corners
            gc.move_to(lx - 10, ly + h - 5)
            gc.line_to(rx + 10, ly + h - 5)

            fork(gc, lx, ly, rx, ry, mx, my, h)

        gc.set_line_width(10)
        # self.set_fill_color(gc)
        fork(gc, lx, ly, rx, ry, mx, my, h)
示例#3
0
    def set_points(self, lx, ly, rx, ry, mx, my):
        self.left = Point(lx, ly)
        self.right = Point(rx, ry)
        self.mid = Point(mx, my)

        self.inverted = my > ly
示例#4
0
    def set_points(self, lx, ly, rx, ry, mx, my):
        self.left = Point(lx, ly)
        self.right = Point(rx, ry)
        self.mid = Point(mx, my)

        self.inverted = my > ly