Beispiel #1
0
    def _draw_line(self, visible_points, area=False):
        if not visible_points:
            return
        linepts=[]
        step=1
        linewidth = 1.5
        maxPointsToDraw = self.canvas.props.x2 / 2
        if len(visible_points) > maxPointsToDraw:
            step = int(len(visible_points) / maxPointsToDraw)
            linewidth = .8
        for p in visible_points[::step]:
            try:
                x,y = self.screen_from_world(p)
            except ZeroDivisionError:
                x = y = -100
            linepts.append((int(x) + .5, int(y) + .5))

        if self.curve.muted:
            fill = 'grey34'
        else:
            fill = 'white'

        if area:
            try:
                base = self.screen_from_world((0, 0))[1]
            except ZeroDivisionError:
                base = -100
            base = base + linewidth / 2
            areapts = linepts[:]
            if len(areapts) >= 1:
                areapts.insert(0, (0, areapts[0][1]))
                areapts.append((self.canvas.props.x2, areapts[-1][1]))
            polyline_new_line(parent=self.curveGroup,
                              points=Points(
                                  [(areapts[0][0], base)] +
                                  areapts +
                                  [(areapts[-1][0], base)]),
                              close_path=True,
                              line_width=0,
                              # transparent as a workaround for
                              # covering some selectmanips (which
                              # become unclickable)
                              fill_color_rgba=0x00800080,
            )

        self.pl = polyline_new_line(parent=self.curveGroup,
                                     points=Points(linepts),
                                     line_width=linewidth,
                                     stroke_color=fill,
                                     )
Beispiel #2
0
 def _draw_markers(self, pts):
     colorMap = {
         'q':'#598522',
         'w':'#662285',
         'e':'#852922',
         'r':'#85225C',
         't':'#856B22',
         'y':'#227085',
         }
     for t, name in pts:
         x = int(self.screen_from_world((t,0))[0]) + .5
         polyline_new_line(self.curveGroup,
                           x, 0, x, self.canvas.props.y2,
                           line_width=.4 if name in 'rty' else .8,
                           stroke_color=colorMap.get(name, 'gray'))
Beispiel #3
0
    def __init__(self, **kw):
        self.widget = GooCanvas.Canvas(bounds_padding=5)
        self.widget.set_property("background-color", "gray60")
        self.widget.set_size_request(-1, 30)
        self.widget.props.x2 = 2000

        endtimes = dispatcher.send("get max time")
        if endtimes:
            self.maxtime = endtimes[0][1]
        else:
            self.maxtime = 0

        self.start = 0
        self.end = 250

        self.root = self.widget.get_root_item()
        self.leftbrack = polyline_new_line(parent=self.root,
                                            line_width=5, stroke_color='black')
        self.rightbrack = polyline_new_line(parent=self.root,
                                             line_width=5, stroke_color='black')
        self.shade = GooCanvas.CanvasRect(parent=self.root,
                                    fill_color='gray70',
                                    line_width=.5)
        self.time = polyline_new_line(parent=self.root,
                                       line_width=2,
                                       stroke_color='red')

        self.redrawzoom()
        self.widget.connect("size-allocate", self.redrawzoom)

        self.widget.connect("motion-notify-event", self.adjust)
        self.widget.connect("button-release-event", self.release)
        self.leftbrack.connect("button-press-event",
                               lambda i, t, ev: self.press(ev, 'start'))
        self.rightbrack.connect("button-press-event",
                                lambda i, t, ev: self.press(ev, 'end'))
        self.shade.connect("button-press-event",
                           lambda i, t, ev: self.press(ev, 'offset'))
        
        dispatcher.connect(self.input_time,"input time")
        dispatcher.connect(self.max_time, "max time")
        dispatcher.connect(self.zoom_about_mouse, "zoom about mouse")
        dispatcher.connect(self.see_time, "see time")
        dispatcher.connect(self.see_time_until_end, "see time until end")
        dispatcher.connect(self.show_all, "show all")
        dispatcher.connect(self.zoom_to_range, "zoom to range")
        self.created=1
        self.lastTime = 0
Beispiel #4
0
    def __init__(self, parent, getSelectedIndices, getWorldPoint,
                 getScreenPoint, getCanvasHeight, setPoints,
                 getWorldTime, getWorldValue, getDragRange):
        """parent goocanvas group"""
        self.getSelectedIndices = getSelectedIndices
        self.getWorldPoint = getWorldPoint
        self.getScreenPoint = getScreenPoint
        self.getCanvasHeight = getCanvasHeight
        self.setPoints = setPoints
        self.getWorldTime = getWorldTime
        self.getDragRange = getDragRange
        self.getWorldValue = getWorldValue
        self.grp = GooCanvas.CanvasGroup(parent=parent)
        
        self.title = GooCanvas.CanvasText(parent=self.grp, text="selectmanip",
                                    x=10, y=10, fill_color='white', font="ubuntu 10")

        self.bbox = GooCanvas.CanvasRect(parent=self.grp,
                                   fill_color_rgba=0xffff0030,
                                   line_width=0)

        self.xTrans = polyline_new_line(parent=self.grp, close_path=True,
                                         fill_color_rgba=0xffffff88,
                                         )
        self.centerScale = polyline_new_line(parent=self.grp, close_path=True,
                                              fill_color_rgba=0xffffff88,
                                         )

        thickLine = lambda: polyline_new_line(parent=self.grp,
                                               stroke_color_rgba=0xffffccff,
                                               line_width=6)
        self.leftScale = thickLine()
        self.rightScale = thickLine()
        self.topScale = thickLine()
        
        for grp, name in [(self.xTrans, 'x'),
                          (self.leftScale, 'left'),
                          (self.rightScale, 'right'),
                          (self.topScale, 'top'),
                          (self.centerScale, 'centerScale'),
                          ]:
            grp.connect("button-press-event", self.onPress, name)
            grp.connect("button-release-event", self.onRelease, name)
            grp.connect("motion-notify-event", self.onMotion, name)
            grp.connect("enter-notify-event", self.onEnter, name)
            grp.connect("leave-notify-event", self.onLeave, name)
            # and hover highlight
        self.update()
Beispiel #5
0
    def update_time_bar(self, t):
        if not self.alive():
            return
        if not getattr(self, 'timelineLine', None):
            self.timelineGroup = GooCanvas.CanvasGroup(
                parent=self.canvas.get_root_item())
            self.timelineLine = polyline_new_line(
                parent=self.timelineGroup,
                points=Points([(0,0), (0,0)]),
                line_width=2, stroke_color='red')

        try:
            pts = [self.screen_from_world((t, 0)),
                   self.screen_from_world((t, 1))]
        except ZeroDivisionError:
            pts = [(-1, -1), (-1, -1)]
        self.timelineLine.set_property('points', Points(pts))
        
        self._time = t
        if self.knobEnabled:
            self.delete('knob')
            prevKey = self.curve.point_before(t)
            if prevKey is not None:
                pos = self.screen_from_world(prevKey)
                self.create_oval(pos[0] - 8, pos[1] - 8,
                                 pos[0] + 8, pos[1] + 8,
                                 outline='#800000',
                                 tags=('knob',))
                dispatcher.send("knob out", value=prevKey[1], curve=self.curve)
Beispiel #6
0
 def _draw_one_tic(self,t,label):
     try:
         x = self.screen_from_world((t,0))[0]
         if not 0 <= x < self.canvas.props.x2:
             return
         x = max(5, x) # cheat left-edge stuff onscreen
     except ZeroDivisionError:
         x = -100
         
     ht = self.canvas.props.y2
     polyline_new_line(self.curveGroup,
                                 x, ht,
                                 x, ht - 20,
                                 line_width=.5,
                                 stroke_color='gray70')
     GooCanvas.CanvasText(parent=self.curveGroup,
                    fill_color="white",
                    anchor=GooCanvas.CanvasAnchorType.SOUTH,
                    font="ubuntu 7",
                    x=x+3, y=ht-20,
                    text=label)